{"id":24895,"library":"affinidi-auth-sdk-kernel","title":"Affinidi Auth SDK Kernel","description":"The Affinidi Auth SDK Kernel is a foundational authentication library for building decentralized identity solutions on the Affinidi platform. Current stable version is 1.9.0, with monthly releases following semantic versioning. It provides secure token management, cryptographic operations, and authentication flow orchestration for React and React Native applications. Unlike generic auth SDKs, it is tightly integrated with Affinidi's decentralized identity protocols and includes built-in key management. Ships TypeScript types and requires react and react-native as peer dependencies.","status":"active","version":"1.9.0","language":"javascript","source_language":"en","source_url":"https://github.com/demchenkoalex/affinidiAuthSdk#readme","tags":["javascript","typescript"],"install":[{"cmd":"npm install affinidi-auth-sdk-kernel","lang":"bash","label":"npm"},{"cmd":"yarn add affinidi-auth-sdk-kernel","lang":"bash","label":"yarn"},{"cmd":"pnpm add affinidi-auth-sdk-kernel","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for UI rendering in React Native and web","package":"react","optional":false},{"reason":"Peer dependency for native mobile platform support","package":"react-native","optional":false}],"imports":[{"note":"ESM-only since v1, also supports named exports.","wrong":"const AffinidiAuth = require('@affinidi/affinidi-auth-sdk-kernel')","symbol":"AffinidiAuth","correct":"import { AffinidiAuth } from '@affinidi/affinidi-auth-sdk-kernel'"},{"note":"AuthConfig is a TypeScript interface, import as type to avoid runtime errors.","wrong":"import { AuthConfig } from '@affinidi/affinidi-auth-sdk-kernel'","symbol":"AuthConfig","correct":"import type { AuthConfig } from '@affinidi/affinidi-auth-sdk-kernel'"},{"note":"AuthProvider is a named export, not default.","wrong":"import AuthProvider from '@affinidi/affinidi-auth-sdk-kernel'","symbol":"AuthProvider","correct":"import { AuthProvider } from '@affinidi/affinidi-auth-sdk-kernel'"},{"note":"Hook for React, ensure react and react-native peer deps are installed.","wrong":"import { useAuth } from '@affinidi/affinidi-auth-sdk-kernel'","symbol":"useAuth","correct":"import { useAuth } from '@affinidi/affinidi-auth-sdk-kernel'"}],"quickstart":{"code":"import { AffinidiAuth, AuthProvider, useAuth } from '@affinidi/affinidi-auth-sdk-kernel';\nimport React from 'react';\n\nconst config = {\n  clientId: process.env.AFFINIDI_CLIENT_ID ?? '',\n  redirectUri: 'myapp://callback',\n};\n\nfunction App() {\n  return (\n    <AuthProvider config={config}>\n      <LoginButton />\n    </AuthProvider>\n  );\n}\n\nfunction LoginButton() {\n  const { login, isAuthenticated, user } = useAuth();\n  return (\n    <button onClick={() => login()}>\n      {isAuthenticated ? `Hello ${user.name}` : 'Sign in with Affinidi'}\n    </button>\n  );\n}\n\nexport default App;","lang":"typescript","description":"Sets up Affinidi authentication with React, including configuration, provider, and login button using hooks."},"warnings":[{"fix":"Replace 'clientSecret' with 'clientId' in config objects.","message":"v1.0.0-rc.1 introduced a breaking change: AuthConfig interface renamed old 'clientSecret' to 'clientId'","severity":"breaking","affected_versions":"<1.0.0-rc.1"},{"fix":"Migrate to try-catch around login() or handle errors from useAuth().","message":"The 'AuthProvider' component's 'onError' prop is deprecated; use error handling via useAuth errors","severity":"deprecated","affected_versions":">=1.5.0"},{"fix":"Run 'npx react-native link @affinidi/affinidi-auth-sdk-kernel' for RN <0.60.","message":"React Native requires linking the native module; auto-linking may fail in older RN versions","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Handle 401 errors and re-initiate login flow.","message":"Token refresh silently fails if the refresh token is expired; no automatic refresh","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install react react-native' and ensure bundler config resolves node_modules correctly.","cause":"Peer dependencies (react, react-native) not installed or misconfigured module resolution","error":"Module not found: Can't resolve '@affinidi/affinidi-auth-sdk-kernel'"},{"fix":"Wrap the component with <AuthProvider> and ensure useAuth() is used inside the provider tree.","cause":"useAuth() called outside of AuthProvider context","error":"TypeError: Cannot read properties of undefined (reading 'login')"},{"fix":"Run 'npx react-native link @affinidi/affinidi-auth-sdk-kernel' or rebuild the app.","cause":"React Native native module not linked","error":"Invariant Violation: Native module cannot be null"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}