@chipmobilesdk/rn-auth 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +111 -0
- package/README.md +8 -5
- package/lib/commonjs/access/accessTier.js +111 -0
- package/lib/commonjs/access/accessTier.js.map +1 -0
- package/lib/commonjs/app-auth.js +13 -0
- package/lib/commonjs/app-auth.js.map +1 -0
- package/lib/commonjs/config/types.js +50 -0
- package/lib/commonjs/config/types.js.map +1 -0
- package/lib/commonjs/config/validateConfig.js +114 -0
- package/lib/commonjs/config/validateConfig.js.map +1 -0
- package/lib/commonjs/core/authMachine.js +406 -0
- package/lib/commonjs/core/authMachine.js.map +1 -0
- package/lib/commonjs/core/profile.js +59 -0
- package/lib/commonjs/core/profile.js.map +1 -0
- package/lib/commonjs/core/session.js +125 -0
- package/lib/commonjs/core/session.js.map +1 -0
- package/lib/commonjs/diagnostics/errors.js +83 -0
- package/lib/commonjs/diagnostics/errors.js.map +1 -0
- package/lib/commonjs/diagnostics/messageKeys.js +51 -0
- package/lib/commonjs/diagnostics/messageKeys.js.map +1 -0
- package/lib/commonjs/index.js +175 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/keychain.js +13 -0
- package/lib/commonjs/keychain.js.map +1 -0
- package/lib/commonjs/oidc/authClient.js +157 -0
- package/lib/commonjs/oidc/authClient.js.map +1 -0
- package/lib/commonjs/oidc/classifyError.js +65 -0
- package/lib/commonjs/oidc/classifyError.js.map +1 -0
- package/lib/commonjs/oidc/socialRouting.js +58 -0
- package/lib/commonjs/oidc/socialRouting.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/react/AuthProvider.js +37 -0
- package/lib/commonjs/react/AuthProvider.js.map +1 -0
- package/lib/commonjs/react/hooks.js +122 -0
- package/lib/commonjs/react/hooks.js.map +1 -0
- package/lib/commonjs/testing/conformance.js +148 -0
- package/lib/commonjs/testing/conformance.js.map +1 -0
- package/lib/commonjs/testing/index.js +53 -0
- package/lib/commonjs/testing/index.js.map +1 -0
- package/lib/commonjs/tokens/accessToken.js +165 -0
- package/lib/commonjs/tokens/accessToken.js.map +1 -0
- package/lib/commonjs/tokens/secureStore.js +60 -0
- package/lib/commonjs/tokens/secureStore.js.map +1 -0
- package/lib/module/access/accessTier.js +106 -0
- package/lib/module/access/accessTier.js.map +1 -0
- package/lib/module/app-auth.js +9 -0
- package/lib/module/app-auth.js.map +1 -0
- package/lib/module/config/types.js +46 -0
- package/lib/module/config/types.js.map +1 -0
- package/lib/module/config/validateConfig.js +110 -0
- package/lib/module/config/validateConfig.js.map +1 -0
- package/lib/module/core/authMachine.js +402 -0
- package/lib/module/core/authMachine.js.map +1 -0
- package/lib/module/core/profile.js +54 -0
- package/lib/module/core/profile.js.map +1 -0
- package/lib/module/core/session.js +118 -0
- package/lib/module/core/session.js.map +1 -0
- package/lib/module/diagnostics/errors.js +74 -0
- package/lib/module/diagnostics/errors.js.map +1 -0
- package/lib/module/diagnostics/messageKeys.js +46 -0
- package/lib/module/diagnostics/messageKeys.js.map +1 -0
- package/lib/module/index.js +33 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/keychain.js +9 -0
- package/lib/module/keychain.js.map +1 -0
- package/lib/module/oidc/authClient.js +152 -0
- package/lib/module/oidc/authClient.js.map +1 -0
- package/lib/module/oidc/classifyError.js +60 -0
- package/lib/module/oidc/classifyError.js.map +1 -0
- package/lib/module/oidc/socialRouting.js +52 -0
- package/lib/module/oidc/socialRouting.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/react/AuthProvider.js +31 -0
- package/lib/module/react/AuthProvider.js.map +1 -0
- package/lib/module/react/hooks.js +111 -0
- package/lib/module/react/hooks.js.map +1 -0
- package/lib/module/testing/conformance.js +140 -0
- package/lib/module/testing/conformance.js.map +1 -0
- package/lib/module/testing/index.js +25 -0
- package/lib/module/testing/index.js.map +1 -0
- package/lib/module/tokens/accessToken.js +161 -0
- package/lib/module/tokens/accessToken.js.map +1 -0
- package/lib/module/tokens/secureStore.js +56 -0
- package/lib/module/tokens/secureStore.js.map +1 -0
- package/lib/typescript/commonjs/access/accessTier.d.ts +14 -0
- package/lib/typescript/commonjs/access/accessTier.d.ts.map +1 -0
- package/lib/typescript/commonjs/app-auth.d.ts +7 -0
- package/lib/typescript/commonjs/app-auth.d.ts.map +1 -0
- package/lib/typescript/commonjs/config/types.d.ts +171 -0
- package/lib/typescript/commonjs/config/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/config/validateConfig.d.ts +8 -0
- package/lib/typescript/commonjs/config/validateConfig.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/authMachine.d.ts +14 -0
- package/lib/typescript/commonjs/core/authMachine.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/profile.d.ts +15 -0
- package/lib/typescript/commonjs/core/profile.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/session.d.ts +60 -0
- package/lib/typescript/commonjs/core/session.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/errors.d.ts +37 -0
- package/lib/typescript/commonjs/diagnostics/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/messageKeys.d.ts +57 -0
- package/lib/typescript/commonjs/diagnostics/messageKeys.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +27 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/keychain.d.ts +7 -0
- package/lib/typescript/commonjs/keychain.d.ts.map +1 -0
- package/lib/typescript/commonjs/oidc/authClient.d.ts +75 -0
- package/lib/typescript/commonjs/oidc/authClient.d.ts.map +1 -0
- package/lib/typescript/commonjs/oidc/classifyError.d.ts +28 -0
- package/lib/typescript/commonjs/oidc/classifyError.d.ts.map +1 -0
- package/lib/typescript/commonjs/oidc/socialRouting.d.ts +22 -0
- package/lib/typescript/commonjs/oidc/socialRouting.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/react/AuthProvider.d.ts +17 -0
- package/lib/typescript/commonjs/react/AuthProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/hooks.d.ts +42 -0
- package/lib/typescript/commonjs/react/hooks.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance.d.ts +32 -0
- package/lib/typescript/commonjs/testing/conformance.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/index.d.ts +11 -0
- package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/tokens/accessToken.d.ts +45 -0
- package/lib/typescript/commonjs/tokens/accessToken.d.ts.map +1 -0
- package/lib/typescript/commonjs/tokens/secureStore.d.ts +26 -0
- package/lib/typescript/commonjs/tokens/secureStore.d.ts.map +1 -0
- package/lib/typescript/module/access/accessTier.d.ts +14 -0
- package/lib/typescript/module/access/accessTier.d.ts.map +1 -0
- package/lib/typescript/module/app-auth.d.ts +7 -0
- package/lib/typescript/module/app-auth.d.ts.map +1 -0
- package/lib/typescript/module/config/types.d.ts +171 -0
- package/lib/typescript/module/config/types.d.ts.map +1 -0
- package/lib/typescript/module/config/validateConfig.d.ts +8 -0
- package/lib/typescript/module/config/validateConfig.d.ts.map +1 -0
- package/lib/typescript/module/core/authMachine.d.ts +14 -0
- package/lib/typescript/module/core/authMachine.d.ts.map +1 -0
- package/lib/typescript/module/core/profile.d.ts +15 -0
- package/lib/typescript/module/core/profile.d.ts.map +1 -0
- package/lib/typescript/module/core/session.d.ts +60 -0
- package/lib/typescript/module/core/session.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/errors.d.ts +37 -0
- package/lib/typescript/module/diagnostics/errors.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/messageKeys.d.ts +57 -0
- package/lib/typescript/module/diagnostics/messageKeys.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +27 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/keychain.d.ts +7 -0
- package/lib/typescript/module/keychain.d.ts.map +1 -0
- package/lib/typescript/module/oidc/authClient.d.ts +75 -0
- package/lib/typescript/module/oidc/authClient.d.ts.map +1 -0
- package/lib/typescript/module/oidc/classifyError.d.ts +28 -0
- package/lib/typescript/module/oidc/classifyError.d.ts.map +1 -0
- package/lib/typescript/module/oidc/socialRouting.d.ts +22 -0
- package/lib/typescript/module/oidc/socialRouting.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/react/AuthProvider.d.ts +17 -0
- package/lib/typescript/module/react/AuthProvider.d.ts.map +1 -0
- package/lib/typescript/module/react/hooks.d.ts +42 -0
- package/lib/typescript/module/react/hooks.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance.d.ts +32 -0
- package/lib/typescript/module/testing/conformance.d.ts.map +1 -0
- package/lib/typescript/module/testing/index.d.ts +11 -0
- package/lib/typescript/module/testing/index.d.ts.map +1 -0
- package/lib/typescript/module/tokens/accessToken.d.ts +45 -0
- package/lib/typescript/module/tokens/accessToken.d.ts.map +1 -0
- package/lib/typescript/module/tokens/secureStore.d.ts +26 -0
- package/lib/typescript/module/tokens/secureStore.d.ts.map +1 -0
- package/package.json +68 -21
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public hooks (LIB-002). Each reads the controller's state through
|
|
3
|
+
* `useSyncExternalStore` (rn-core's `useExternalStore`), selecting only what it
|
|
4
|
+
* returns, so `useProfile` does not re-render when only the status changes.
|
|
5
|
+
*/
|
|
6
|
+
import type { AccessTier, AccessTokenResult, AuthState, GlobalSignOutResult, PremiumGateResult, Profile, ProviderConfig, ProviderId } from '../config/types.js';
|
|
7
|
+
import type { AccessTokenRequestOptions } from '../tokens/accessToken.js';
|
|
8
|
+
import type { AuthMessageMap } from '../diagnostics/messageKeys.js';
|
|
9
|
+
export interface UseAuthResult {
|
|
10
|
+
state: AuthState;
|
|
11
|
+
signIn(providerId: ProviderId): Promise<AuthState>;
|
|
12
|
+
signOut(): Promise<void>;
|
|
13
|
+
signOutGlobal(): Promise<GlobalSignOutResult>;
|
|
14
|
+
restore(): Promise<AuthState>;
|
|
15
|
+
/** Whether a premium-only path is open. Changes nothing: show the denial where it happened. */
|
|
16
|
+
canAccessPremium(): PremiumGateResult;
|
|
17
|
+
/** @deprecated Use `canAccessPremium`; this moves the whole controller to `access-denied` (AUTH-12). */
|
|
18
|
+
requirePremium(): PremiumGateResult;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Any slice of the auth state; the component re-renders only when the slice
|
|
22
|
+
* changes by `isEqual` (default `Object.is`).
|
|
23
|
+
*/
|
|
24
|
+
export declare function useAuthSelector<Selected>(select: (state: AuthState) => Selected, isEqual?: (a: Selected, b: Selected) => boolean): Selected;
|
|
25
|
+
export declare function useAuth(): UseAuthResult;
|
|
26
|
+
/** This package's copy, with the app's `messages` overrides applied. */
|
|
27
|
+
export declare function useAuthMessages(): AuthMessageMap;
|
|
28
|
+
export declare function useProfile(): Profile | undefined;
|
|
29
|
+
export declare function useAccessTier(): AccessTier;
|
|
30
|
+
/** The first provider to present on the current platform (UX-004), or undefined. */
|
|
31
|
+
export declare function useSignInProvider(): ProviderConfig | undefined;
|
|
32
|
+
/** All available providers for the current platform, in configuration order (FR-003/FR-004). */
|
|
33
|
+
export declare function useSignInProviders(): ProviderConfig[];
|
|
34
|
+
export type UseAccessTokenStatus = 'idle' | 'loading' | 'success' | 'denied' | 'unavailable' | 'error';
|
|
35
|
+
export interface UseAccessTokenResult {
|
|
36
|
+
status: UseAccessTokenStatus;
|
|
37
|
+
token?: string | undefined;
|
|
38
|
+
/** `{ forceRefresh: true }` after a server refused the token this returned. */
|
|
39
|
+
request(options?: AccessTokenRequestOptions): Promise<AccessTokenResult>;
|
|
40
|
+
}
|
|
41
|
+
export declare function useAccessToken(resourceKey: string): UseAccessTokenResult;
|
|
42
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../../src/react/hooks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EACX,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,mBAAmB,EACnB,iBAAiB,EACjB,OAAO,EACP,cAAc,EACd,UAAU,EACV,MAAM,oBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA4B,CAAC;AAEjE,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IACnD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,aAAa,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC9C,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9B,+FAA+F;IAC/F,gBAAgB,IAAI,iBAAiB,CAAC;IACtC,wGAAwG;IACxG,cAAc,IAAI,iBAAiB,CAAC;CACpC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EACvC,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,QAAQ,EACtC,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,KAAK,OAAO,GAC7C,QAAQ,CAGV;AAMD,wBAAgB,OAAO,IAAI,aAAa,CAYvC;AAED,wEAAwE;AACxE,wBAAgB,eAAe,IAAI,cAAc,CAEhD;AAED,wBAAgB,UAAU,IAAI,OAAO,GAAG,SAAS,CAEhD;AAED,wBAAgB,aAAa,IAAI,UAAU,CAE1C;AAED,oFAAoF;AACpF,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,SAAS,CAG9D;AAED,gGAAgG;AAChG,wBAAgB,kBAAkB,IAAI,cAAc,EAAE,CAGrD;AAED,MAAM,MAAM,oBAAoB,GAC/B,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,GAAG,OAAO,CAAC;AAErE,MAAM,WAAW,oBAAoB;IACpC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,+EAA+E;IAC/E,OAAO,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACzE;AAED,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,oBAAoB,CAyCxE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What any `SecureTokenStore` and `OidcAuthClient` must do (IOS-12, AUTH-13).
|
|
3
|
+
*
|
|
4
|
+
* The same checks run against the in-memory doubles and against the keychain and
|
|
5
|
+
* app-auth adapters (native modules mocked in Jest, or for real from a demo
|
|
6
|
+
* screen on a device), so a test that drives a double proves something about the
|
|
7
|
+
* device path. Each check builds its own subject through a harness.
|
|
8
|
+
*/
|
|
9
|
+
import { type Check, type ConformanceReport } from '@chipmobilesdk/rn-core/testing';
|
|
10
|
+
import type { OidcAuthClient } from '../oidc/authClient.js';
|
|
11
|
+
import type { SecureTokenStore } from '../tokens/secureStore.js';
|
|
12
|
+
export interface SecureStoreHarness {
|
|
13
|
+
/** An empty store. */
|
|
14
|
+
create(): SecureTokenStore;
|
|
15
|
+
}
|
|
16
|
+
export interface OidcSubject {
|
|
17
|
+
readonly client: OidcAuthClient;
|
|
18
|
+
/** The identity provider answers sign-in and refresh with tokens for these claims. */
|
|
19
|
+
issues(claims: Record<string, unknown>): void;
|
|
20
|
+
/** The user closes the sign-in sheet. */
|
|
21
|
+
userCancels(): void;
|
|
22
|
+
/** The provider no longer accepts the refresh token. */
|
|
23
|
+
rejectsRefresh(): void;
|
|
24
|
+
}
|
|
25
|
+
export interface OidcHarness {
|
|
26
|
+
create(): OidcSubject;
|
|
27
|
+
}
|
|
28
|
+
export declare const secureTokenStoreChecks: readonly Check<SecureStoreHarness>[];
|
|
29
|
+
export declare const oidcAuthClientChecks: readonly Check<OidcHarness>[];
|
|
30
|
+
export declare function runSecureTokenStoreConformance(harness: SecureStoreHarness): Promise<ConformanceReport>;
|
|
31
|
+
export declare function runOidcAuthClientConformance(harness: OidcHarness): Promise<ConformanceReport>;
|
|
32
|
+
//# sourceMappingURL=conformance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.d.ts","sourceRoot":"","sources":["../../../../src/testing/conformance.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAGN,KAAK,KAAK,EACV,KAAK,iBAAiB,EACtB,MAAM,gCAAgC,CAAC;AAExC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAAuB,CAAC;AAE9D,MAAM,WAAW,kBAAkB;IAClC,sBAAsB;IACtB,MAAM,IAAI,gBAAgB,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,sFAAsF;IACtF,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC9C,yCAAyC;IACzC,WAAW,IAAI,IAAI,CAAC;IACpB,wDAAwD;IACxD,cAAc,IAAI,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC3B,MAAM,IAAI,WAAW,CAAC;CACtB;AAKD,eAAO,MAAM,sBAAsB,EAAE,SAAS,KAAK,CAAC,kBAAkB,CAAC,EA+CtE,CAAC;AAaF,eAAO,MAAM,oBAAoB,EAAE,SAAS,KAAK,CAAC,WAAW,CAAC,EAkE7D,CAAC;AAEF,wBAAgB,8BAA8B,CAC7C,OAAO,EAAE,kBAAkB,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAE5B;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAE7F"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@chipmobilesdk/rn-auth/testing`: test doubles and the port conformance suites.
|
|
3
|
+
*
|
|
4
|
+
* A separate entrypoint so neither can reach a production bundle.
|
|
5
|
+
*/
|
|
6
|
+
import type { SecureTokenStore } from '../tokens/secureStore.js';
|
|
7
|
+
/** A `SecureTokenStore` held in memory, for tests and for the conformance suite. */
|
|
8
|
+
export declare function createMemorySecureStore(seed?: Record<string, string>): SecureTokenStore;
|
|
9
|
+
export { oidcAuthClientChecks, runOidcAuthClientConformance, runSecureTokenStoreConformance, secureTokenStoreChecks, } from './conformance.js';
|
|
10
|
+
export type { OidcHarness, OidcSubject, SecureStoreHarness } from './conformance.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAAuB,CAAC;AAE9D,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAAG,gBAAgB,CAa3F;AAED,OAAO,EACN,oBAAoB,EACpB,4BAA4B,EAC5B,8BAA8B,EAC9B,sBAAsB,GACtB,MAAM,kBAAe,CAAC;AACvB,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAe,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-resource delegated access-token acquisition with an in-memory cache and
|
|
3
|
+
* silent refresh (FR-007, PERF-003, R4). Access tokens are never persisted to
|
|
4
|
+
* disk (FR-021) — only kept in memory keyed by resource until expiry.
|
|
5
|
+
*/
|
|
6
|
+
import type { AccessTokenResult, ResourceConfig } from '../config/types.js';
|
|
7
|
+
import type { OidcAuthClient } from '../oidc/authClient.js';
|
|
8
|
+
export interface AccessTokenManagerDeps {
|
|
9
|
+
authority: string;
|
|
10
|
+
clientId: string;
|
|
11
|
+
redirectUrl: string;
|
|
12
|
+
resources: ResourceConfig[];
|
|
13
|
+
authClient: OidcAuthClient;
|
|
14
|
+
getRefreshToken: () => string | null;
|
|
15
|
+
/**
|
|
16
|
+
* The session generation, bumped by every sign-in, sign-out and restore. A
|
|
17
|
+
* refresh that started under one generation and finished under another
|
|
18
|
+
* belongs to a session that no longer exists, so its result is discarded.
|
|
19
|
+
*/
|
|
20
|
+
sessionEpoch: () => number;
|
|
21
|
+
/**
|
|
22
|
+
* The provider rotated the refresh token. Resolves once the new token is
|
|
23
|
+
* live, and persisted where it can be: the old one may already be dead, so a
|
|
24
|
+
* restart must not come back with it.
|
|
25
|
+
*/
|
|
26
|
+
onRefreshTokenRotated: (token: string, epoch: number) => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
export interface AccessTokenRequestOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Ignore the cached token and ask the provider for a new one.
|
|
31
|
+
*
|
|
32
|
+
* For the caller that just had one rejected: a token the server refused is
|
|
33
|
+
* still unexpired by this device's clock, so asking again without this
|
|
34
|
+
* returns the same token and the retry is the same request (AI-01).
|
|
35
|
+
*/
|
|
36
|
+
forceRefresh?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface AccessTokenManager {
|
|
39
|
+
request(resourceKey: string, options?: AccessTokenRequestOptions): Promise<AccessTokenResult>;
|
|
40
|
+
/** Whether `request` would answer from the cache, without touching the network. */
|
|
41
|
+
hasFreshToken(resourceKey: string): boolean;
|
|
42
|
+
clear(): void;
|
|
43
|
+
}
|
|
44
|
+
export declare function createAccessTokenManager(deps: AccessTokenManagerDeps): AccessTokenManager;
|
|
45
|
+
//# sourceMappingURL=accessToken.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessToken.d.ts","sourceRoot":"","sources":["../../../../src/tokens/accessToken.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAoB,CAAC;AAUzD,MAAM,WAAW,sBAAsB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,UAAU,EAAE,cAAc,CAAC;IAC3B,eAAe,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACrC;;;;OAIG;IACH,YAAY,EAAE,MAAM,MAAM,CAAC;IAC3B;;;;OAIG;IACH,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE;AAED,MAAM,WAAW,yBAAyB;IACzC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IAClC,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9F,mFAAmF;IACnF,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5C,KAAK,IAAI,IAAI,CAAC;CACd;AAOD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,sBAAsB,GAAG,kBAAkB,CA4GzF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SecureTokenStore port + default react-native-keychain adapter (FR-021, R2).
|
|
3
|
+
*
|
|
4
|
+
* Refresh tokens and the session-restore artifact persist ONLY through this
|
|
5
|
+
* port, backed by platform secure storage (iOS Keychain / Android Keystore).
|
|
6
|
+
* Access tokens are never written here — they stay in memory (see accessToken).
|
|
7
|
+
* The default adapter loads the native module on its first read or write, so
|
|
8
|
+
* creating it, and unit tests that inject a fake, load no native code.
|
|
9
|
+
*/
|
|
10
|
+
/** Single key under which the persisted session artifact is stored. */
|
|
11
|
+
export declare const AUTH_STORAGE_KEY = "@chipmobilesdk/rn-auth/session";
|
|
12
|
+
export interface SecureTokenStore {
|
|
13
|
+
getItem(key: string): Promise<string | null>;
|
|
14
|
+
setItem(key: string, value: string): Promise<void>;
|
|
15
|
+
removeItem(key: string): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export interface KeychainSecureStoreOptions {
|
|
18
|
+
/** Optional Keychain access-control accessibility constant. */
|
|
19
|
+
accessible?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Default secure store backed by react-native-keychain. Each logical key maps to
|
|
23
|
+
* a Keychain "service" so multiple keys can coexist. Validated on device.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createKeychainSecureStore(options?: KeychainSecureStoreOptions): SecureTokenStore;
|
|
26
|
+
//# sourceMappingURL=secureStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secureStore.d.ts","sourceRoot":"","sources":["../../../../src/tokens/secureStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,uEAAuE;AACvE,eAAO,MAAM,gBAAgB,mCAAmC,CAAC;AAEjE,MAAM,WAAW,gBAAgB;IAChC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,0BAA0B;IAC1C,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACxC,OAAO,GAAE,0BAA+B,GACtC,gBAAgB,CAoBlB"}
|
package/package.json
CHANGED
|
@@ -1,30 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chipmobilesdk/rn-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"source": "./src/index.ts",
|
|
7
|
+
"main": "./lib/commonjs/index.js",
|
|
8
|
+
"module": "./lib/module/index.js",
|
|
9
|
+
"types": "./lib/typescript/commonjs/index.d.ts",
|
|
8
10
|
"exports": {
|
|
9
11
|
".": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
12
|
+
"chipmobilesdk-source": "./src/index.ts",
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./lib/typescript/module/index.d.ts",
|
|
15
|
+
"default": "./lib/module/index.js"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./lib/typescript/commonjs/index.d.ts",
|
|
19
|
+
"default": "./lib/commonjs/index.js"
|
|
20
|
+
}
|
|
13
21
|
},
|
|
14
22
|
"./app-auth": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
23
|
+
"chipmobilesdk-source": "./src/app-auth.ts",
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./lib/typescript/module/app-auth.d.ts",
|
|
26
|
+
"default": "./lib/module/app-auth.js"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./lib/typescript/commonjs/app-auth.d.ts",
|
|
30
|
+
"default": "./lib/commonjs/app-auth.js"
|
|
31
|
+
}
|
|
18
32
|
},
|
|
19
33
|
"./keychain": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
34
|
+
"chipmobilesdk-source": "./src/keychain.ts",
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./lib/typescript/module/keychain.d.ts",
|
|
37
|
+
"default": "./lib/module/keychain.js"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./lib/typescript/commonjs/keychain.d.ts",
|
|
41
|
+
"default": "./lib/commonjs/keychain.js"
|
|
42
|
+
}
|
|
23
43
|
},
|
|
24
44
|
"./testing": {
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
|
|
45
|
+
"chipmobilesdk-source": "./src/testing/index.ts",
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./lib/typescript/module/testing/index.d.ts",
|
|
48
|
+
"default": "./lib/module/testing/index.js"
|
|
49
|
+
},
|
|
50
|
+
"require": {
|
|
51
|
+
"types": "./lib/typescript/commonjs/testing/index.d.ts",
|
|
52
|
+
"default": "./lib/commonjs/testing/index.js"
|
|
53
|
+
}
|
|
28
54
|
}
|
|
29
55
|
},
|
|
30
56
|
"files": [
|
|
@@ -41,21 +67,23 @@
|
|
|
41
67
|
"src/testing",
|
|
42
68
|
"skills",
|
|
43
69
|
"README.md",
|
|
44
|
-
"CHANGELOG.md"
|
|
70
|
+
"CHANGELOG.md",
|
|
71
|
+
"lib"
|
|
45
72
|
],
|
|
46
73
|
"sideEffects": false,
|
|
47
74
|
"scripts": {
|
|
75
|
+
"build": "bob build",
|
|
48
76
|
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.test.json",
|
|
49
|
-
"pack:check": "npm pack --dry-run"
|
|
77
|
+
"pack:check": "npm pack --dry-run",
|
|
78
|
+
"prepack": "npm run build"
|
|
50
79
|
},
|
|
51
80
|
"dependencies": {
|
|
52
|
-
"@chipmobilesdk/rn-core": "^0.
|
|
81
|
+
"@chipmobilesdk/rn-core": "^0.2.0"
|
|
53
82
|
},
|
|
54
83
|
"peerDependencies": {
|
|
55
84
|
"react": ">=19",
|
|
56
|
-
"react-native": "
|
|
57
|
-
"react-native-
|
|
58
|
-
"react-native-keychain": ">=10"
|
|
85
|
+
"react-native-app-auth": "^8.0.0",
|
|
86
|
+
"react-native-keychain": "^10.0.0"
|
|
59
87
|
},
|
|
60
88
|
"peerDependenciesMeta": {
|
|
61
89
|
"react-native-app-auth": {
|
|
@@ -68,5 +96,24 @@
|
|
|
68
96
|
"publishConfig": {
|
|
69
97
|
"access": "public",
|
|
70
98
|
"registry": "https://registry.npmjs.org/"
|
|
99
|
+
},
|
|
100
|
+
"react-native-builder-bob": {
|
|
101
|
+
"source": "src",
|
|
102
|
+
"output": "lib",
|
|
103
|
+
"targets": [
|
|
104
|
+
[
|
|
105
|
+
"commonjs",
|
|
106
|
+
{
|
|
107
|
+
"esm": true
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
"module",
|
|
112
|
+
{
|
|
113
|
+
"esm": true
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"typescript"
|
|
117
|
+
]
|
|
71
118
|
}
|
|
72
119
|
}
|