Registry / auth-security / affinidi-auth-sdk-kernel

affinidi-auth-sdk-kernel

JSON →
library1.9.0jsnpmunverified

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.

npm install affinidi-auth-sdk-kernel
INSTALL
IMPORT
SIG · AFFINIDI-AUTH-SDK-
A
affinidi-auth-sdk-kernel
auth-securityjavascriptv1.9.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AffinidiAuth
import { AffinidiAuth } from '@affinidi/affinidi-auth-sdk-kernel'
const AffinidiAuth = require('@affinidi/affinidi-auth-sdk-kernel')
ESM-only since v1, also supports named exports.
AuthConfig
import type { AuthConfig } from '@affinidi/affinidi-auth-sdk-kernel'
import { AuthConfig } from '@affinidi/affinidi-auth-sdk-kernel'
AuthConfig is a TypeScript interface, import as type to avoid runtime errors.
AuthProvider
import { AuthProvider } from '@affinidi/affinidi-auth-sdk-kernel'
import AuthProvider from '@affinidi/affinidi-auth-sdk-kernel'
AuthProvider is a named export, not default.
useAuth
import { useAuth } from '@affinidi/affinidi-auth-sdk-kernel'
import { useAuth } from '@affinidi/affinidi-auth-sdk-kernel'
Hook for React, ensure react and react-native peer deps are installed.

Sets up Affinidi authentication with React, including configuration, provider, and login button using hooks.

import { AffinidiAuth, AuthProvider, useAuth } from '@affinidi/affinidi-auth-sdk-kernel'; import React from 'react'; const config = { clientId: process.env.AFFINIDI_CLIENT_ID ?? '', redirectUri: 'myapp://callback', }; function App() { return ( <AuthProvider config={config}> <LoginButton /> </AuthProvider> ); } function LoginButton() { const { login, isAuthenticated, user } = useAuth(); return ( <button onClick={() => login()}> {isAuthenticated ? `Hello ${user.name}` : 'Sign in with Affinidi'} </button> ); } export default App;
Debug
Known issues
breakingv1.0.0-rc.1 introduced a breaking change: AuthConfig interface renamed old 'clientSecret' to 'clientId'
fix
Replace 'clientSecret' with 'clientId' in config objects.
affects: <1.0.0-rc.1
deprecatedThe 'AuthProvider' component's 'onError' prop is deprecated; use error handling via useAuth errors
fix
Migrate to try-catch around login() or handle errors from useAuth().
affects: >=1.5.0
gotchaReact Native requires linking the native module; auto-linking may fail in older RN versions
fix
Run 'npx react-native link @affinidi/affinidi-auth-sdk-kernel' for RN <0.60.
affects: >=1.0.0
gotchaToken refresh silently fails if the refresh token is expired; no automatic refresh
fix
Handle 401 errors and re-initiate login flow.
affects: >=1.0.0
Errors
Common errors & fixes
Module not found: Can't resolve '@affinidi/affinidi-auth-sdk-kernel'
Peer dependencies (react, react-native) not installed or misconfigured module resolution
fix
Run 'npm install react react-native' and ensure bundler config resolves node_modules correctly.
TypeError: Cannot read properties of undefined (reading 'login')
useAuth() called outside of AuthProvider context
fix
Wrap the component with <AuthProvider> and ensure useAuth() is used inside the provider tree.
Invariant Violation: Native module cannot be null
React Native native module not linked
fix
Run 'npx react-native link @affinidi/affinidi-auth-sdk-kernel' or rebuild the app.
Upgrade
Version history
1.9.0latest on npm
Audit
Dependencies
reactrequiredPeer dependency for UI rendering in React Native and web
react-nativerequiredPeer dependency for native mobile platform support
Agent activity
75 hits · last 30 days
node
64
Perplexity
1
OpenAI (training)
1
Resources
affinidi-auth-sdk-kernel — npm install affinidi-auth-sdk-kernel · libregistry