@chipmobilesdk/rn-auth 0.4.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 +139 -0
- package/README.md +74 -14
- 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
- package/skills/sdk-rn-auth/SKILL.md +35 -2
- package/src/config/types.ts +53 -5
- package/src/config/validateConfig.ts +32 -1
- package/src/core/authMachine.ts +40 -6
- package/src/core/profile.ts +6 -1
- package/src/core/session.ts +49 -3
- package/src/diagnostics/errors.ts +7 -5
- package/src/index.ts +7 -0
- package/src/oidc/authClient.ts +19 -1
- package/src/oidc/classifyError.ts +2 -1
- package/src/oidc/socialRouting.ts +3 -1
- package/src/react/hooks.ts +53 -14
- package/src/tokens/accessToken.ts +20 -9
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claims → Profile mapping (FR-006). Tolerant of Apple private-relay emails and
|
|
3
|
+
* missing display name / given name (edge cases).
|
|
4
|
+
*/
|
|
5
|
+
import type { Profile, ProviderId, ProviderIdentity } from '../config/types';
|
|
6
|
+
/** Map id-token claims to the app-visible Profile. */
|
|
7
|
+
export declare function mapClaimsToProfile(claims: Record<string, unknown>, providerId?: ProviderId): Profile;
|
|
8
|
+
/**
|
|
9
|
+
* Describe the external provider identity behind the profile (FR-004 edge
|
|
10
|
+
* cases). `emailBehavior` is what a screen needs to explain an address the user
|
|
11
|
+
* did not choose: Apple's private relay forwards mail and is not the address
|
|
12
|
+
* they type anywhere else.
|
|
13
|
+
*/
|
|
14
|
+
export declare function describeProviderIdentity(claims: Record<string, unknown>, providerId?: ProviderId): ProviderIdentity;
|
|
15
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../../src/core/profile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAU7E,sDAAsD;AACtD,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,CAAC,EAAE,UAAU,GACrB,OAAO,CAsBT;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACvC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,CAAC,EAAE,UAAU,GACrB,gBAAgB,CASlB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session restoration (FR-008, R5). Reads the persisted artifact, attempts a
|
|
3
|
+
* silent refresh, and classifies the outcome:
|
|
4
|
+
* - restored: fresh tokens + claims → authenticated
|
|
5
|
+
* - offline: the refresh could not complete for any reason other than the
|
|
6
|
+
* session being invalid — no network, a timeout, a 5xx, an error we
|
|
7
|
+
* cannot classify → cached profile read-only, tier unverified (fail
|
|
8
|
+
* closed) — clarify Q3
|
|
9
|
+
* - unavailable: no artifact, or the provider said the refresh token is no
|
|
10
|
+
* longer valid → signed-out reauth
|
|
11
|
+
*
|
|
12
|
+
* Only `unavailable` deletes the stored session, so it is reserved for a verdict
|
|
13
|
+
* the provider actually gave. Treating every unclassified error as expiry signed
|
|
14
|
+
* users out whenever the token endpoint had a bad moment.
|
|
15
|
+
*/
|
|
16
|
+
import type { AccessTier, AccessTierMapping, Profile, RestoreStatus } from '../config/types';
|
|
17
|
+
import type { OidcAuthClient } from '../oidc/authClient';
|
|
18
|
+
import type { SecureTokenStore } from '../tokens/secureStore';
|
|
19
|
+
/**
|
|
20
|
+
* The identity in the stored artifact: who, not what the token said.
|
|
21
|
+
*
|
|
22
|
+
* The whole claim set used to be written to the Keychain on every launch — all
|
|
23
|
+
* of it, groups included — for a value nothing reads back: the access tier is
|
|
24
|
+
* recomputed from fresh claims, and a restore that cannot reach the provider
|
|
25
|
+
* fails closed anyway (AUTH-23).
|
|
26
|
+
*/
|
|
27
|
+
export type StoredProfile = Omit<Profile, 'claims'>;
|
|
28
|
+
export interface PersistedSession {
|
|
29
|
+
refreshToken: string;
|
|
30
|
+
profile: StoredProfile;
|
|
31
|
+
/** The id token hint for end-session (AUTH-04). Absent in artifacts written before 0.2.2. */
|
|
32
|
+
idToken?: string | undefined;
|
|
33
|
+
}
|
|
34
|
+
/** The artifact's identity as a profile. Artifacts written before 0.4.0 carry claims; they are kept. */
|
|
35
|
+
export declare function profileFromStored(stored: StoredProfile | Profile): Profile;
|
|
36
|
+
/** What goes to the store: everything but the claims. */
|
|
37
|
+
export declare function storedProfileFrom(profile: Profile): StoredProfile;
|
|
38
|
+
/** True when the artifact would be byte-identical, so the write can be skipped. */
|
|
39
|
+
export declare function sameSession(a: PersistedSession, b: PersistedSession): boolean;
|
|
40
|
+
export interface RestoreDeps {
|
|
41
|
+
secureStore: SecureTokenStore;
|
|
42
|
+
authority: string;
|
|
43
|
+
clientId: string;
|
|
44
|
+
redirectUrl: string;
|
|
45
|
+
scopes: string[];
|
|
46
|
+
authClient: OidcAuthClient;
|
|
47
|
+
mapping: AccessTierMapping;
|
|
48
|
+
}
|
|
49
|
+
export interface RestoreResult {
|
|
50
|
+
outcome: RestoreStatus;
|
|
51
|
+
profile?: Profile;
|
|
52
|
+
/** The artifact this restore read, so a rewrite that changes nothing can be skipped. */
|
|
53
|
+
persisted?: PersistedSession;
|
|
54
|
+
accessTier?: AccessTier;
|
|
55
|
+
refreshToken?: string;
|
|
56
|
+
idToken?: string | undefined;
|
|
57
|
+
}
|
|
58
|
+
export declare function parsePersistedSession(raw: string | null): PersistedSession | null;
|
|
59
|
+
export declare function restoreSession(deps: RestoreDeps): Promise<RestoreResult>;
|
|
60
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/core/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAM9D;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AAEpD,MAAM,WAAW,gBAAgB;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,aAAa,CAAC;IACvB,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,wGAAwG;AACxG,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,GAAG,OAAO,CAE1E;AAED,yDAAyD;AACzD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CAOjE;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,CAAC,EAAE,gBAAgB,EAAE,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAS7E;AAED,MAAM,WAAW,WAAW;IAC3B,WAAW,EAAE,gBAAgB,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,UAAU,EAAE,cAAc,CAAC;IAC3B,OAAO,EAAE,iBAAiB,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wFAAwF;IACxF,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,gBAAgB,GAAG,IAAI,CAajF;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC,CA+C9E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Developer-facing diagnostics. AuthError carries a stable machine-readable
|
|
3
|
+
* code, an audience (user vs developer/tenant), and a localizable message key.
|
|
4
|
+
* `detail` is always passed through `redact` so tokens and secrets never appear
|
|
5
|
+
* in logs or error objects (FR-014).
|
|
6
|
+
*/
|
|
7
|
+
import { SdkError } from '@chipmobilesdk/rn-core';
|
|
8
|
+
import type { AuthMessageKey } from './messageKeys';
|
|
9
|
+
export type AuthErrorCode = 'configuration-error' | 'provider-cancelled' | 'redirect-mismatch' | 'token-acquisition-failed' | 'session-expired' | 'consent-denied' | 'network-unavailable';
|
|
10
|
+
export type AuthErrorAudience = 'user' | 'developer';
|
|
11
|
+
export interface AuthErrorArgs {
|
|
12
|
+
code: AuthErrorCode;
|
|
13
|
+
/** A key of this package's catalogue: the copy an app shows for this error. */
|
|
14
|
+
messageKey: AuthMessageKey;
|
|
15
|
+
audience?: AuthErrorAudience;
|
|
16
|
+
detail?: string | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Replace token-like substrings with a placeholder so diagnostics never leak
|
|
20
|
+
* secrets or token values (FR-014): JWTs become `[redacted-token]`; URLs, e-mail
|
|
21
|
+
* addresses, UUIDs and other opaque runs become `[redacted]` (rn-core's patterns).
|
|
22
|
+
*/
|
|
23
|
+
export declare function redact(value: string | undefined): string | undefined;
|
|
24
|
+
/** The package's error; an `SdkError` (`@chipmobilesdk/rn-core`) with `pkg: 'rn-auth'`. */
|
|
25
|
+
export declare class AuthError extends SdkError<AuthErrorCode> {
|
|
26
|
+
readonly audience: AuthErrorAudience;
|
|
27
|
+
readonly messageKey: AuthMessageKey;
|
|
28
|
+
readonly detail?: string | undefined;
|
|
29
|
+
constructor(args: AuthErrorArgs);
|
|
30
|
+
}
|
|
31
|
+
export declare class AuthConfigError extends AuthError {
|
|
32
|
+
constructor(messageKey: AuthMessageKey, detail?: string);
|
|
33
|
+
}
|
|
34
|
+
export declare function isAuthError(value: unknown): value is AuthError;
|
|
35
|
+
/** Normalize any thrown value into an AuthError without leaking secrets. */
|
|
36
|
+
export declare function toAuthError(value: unknown, fallbackCode?: AuthErrorCode, fallbackMessageKey?: AuthMessageKey): AuthError;
|
|
37
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/diagnostics/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAmB,QAAQ,EAAkB,MAAM,wBAAwB,CAAC;AAEnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,MAAM,aAAa,GACtB,qBAAqB,GACrB,oBAAoB,GACpB,mBAAmB,GACnB,0BAA0B,GAC1B,iBAAiB,GACjB,gBAAgB,GAChB,qBAAqB,CAAC;AAEzB,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,WAAW,CAAC;AAErD,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,aAAa,CAAC;IACpB,+EAA+E;IAC/E,UAAU,EAAE,cAAc,CAAC;IAC3B,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAOD;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAQpE;AAKD,2FAA2F;AAC3F,qBAAa,SAAU,SAAQ,QAAQ,CAAC,aAAa,CAAC;IACrD,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEzB,IAAI,EAAE,aAAa;CAY/B;AAED,qBAAa,eAAgB,SAAQ,SAAS;gBACjC,UAAU,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM;CAIvD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED,4EAA4E;AAC5E,wBAAgB,WAAW,CAC1B,KAAK,EAAE,OAAO,EACd,YAAY,GAAE,aAA0C,EACxD,kBAAkB,GAAE,cAAmC,GACrD,SAAS,CAWX"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable, localizable message keys with English default copy (UX-006 / LIB-011).
|
|
3
|
+
* The library takes no i18n runtime dependency: consuming apps map these keys to
|
|
4
|
+
* localized strings via their own i18n system. User-actionable copy and
|
|
5
|
+
* developer/tenant-configuration copy are kept separate (UX-005).
|
|
6
|
+
*/
|
|
7
|
+
export interface AuthMessageMap {
|
|
8
|
+
'auth.action.continueGoogle': string;
|
|
9
|
+
'auth.action.continueApple': string;
|
|
10
|
+
'auth.action.continueFacebook': string;
|
|
11
|
+
'auth.state.signedOut': string;
|
|
12
|
+
'auth.state.authenticating': string;
|
|
13
|
+
'auth.state.signedIn': string;
|
|
14
|
+
'auth.state.signingOut': string;
|
|
15
|
+
'auth.tier.free': string;
|
|
16
|
+
'auth.tier.premium': string;
|
|
17
|
+
'auth.tier.unverified': string;
|
|
18
|
+
'auth.error.cancelled': string;
|
|
19
|
+
'auth.error.sessionExpired': string;
|
|
20
|
+
'auth.error.entitlement': string;
|
|
21
|
+
'auth.error.network': string;
|
|
22
|
+
'auth.error.configuration': string;
|
|
23
|
+
'auth.error.redirectMismatch': string;
|
|
24
|
+
'auth.error.token': string;
|
|
25
|
+
'auth.error.consentDenied': string;
|
|
26
|
+
}
|
|
27
|
+
export type AuthMessageKey = keyof AuthMessageMap;
|
|
28
|
+
/**
|
|
29
|
+
* The catalog, as an rn-core message set: `user` copy may reach an end user,
|
|
30
|
+
* `developer` copy describes a tenant or configuration fault (UX-005). Register
|
|
31
|
+
* `authMessages.user` with rn-i18n to translate it like app copy.
|
|
32
|
+
*/
|
|
33
|
+
export declare const authMessages: import("@chipmobilesdk/rn-core").MessageSet<{
|
|
34
|
+
'auth.action.continueGoogle': string;
|
|
35
|
+
'auth.action.continueApple': string;
|
|
36
|
+
'auth.action.continueFacebook': string;
|
|
37
|
+
'auth.state.signedOut': string;
|
|
38
|
+
'auth.state.authenticating': string;
|
|
39
|
+
'auth.state.signedIn': string;
|
|
40
|
+
'auth.state.signingOut': string;
|
|
41
|
+
'auth.tier.free': string;
|
|
42
|
+
'auth.tier.premium': string;
|
|
43
|
+
'auth.tier.unverified': string;
|
|
44
|
+
'auth.error.cancelled': string;
|
|
45
|
+
'auth.error.sessionExpired': string;
|
|
46
|
+
'auth.error.entitlement': string;
|
|
47
|
+
'auth.error.network': string;
|
|
48
|
+
}, {
|
|
49
|
+
'auth.error.configuration': string;
|
|
50
|
+
'auth.error.redirectMismatch': string;
|
|
51
|
+
'auth.error.token': string;
|
|
52
|
+
'auth.error.consentDenied': string;
|
|
53
|
+
}>;
|
|
54
|
+
export declare const DEFAULT_MESSAGES: AuthMessageMap;
|
|
55
|
+
/** Resolve a message, preferring app overrides over the English defaults. */
|
|
56
|
+
export declare function resolveMessages(overrides?: Partial<AuthMessageMap>): AuthMessageMap;
|
|
57
|
+
//# sourceMappingURL=messageKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageKeys.d.ts","sourceRoot":"","sources":["../../../../src/diagnostics/messageKeys.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,MAAM,WAAW,cAAc;IAE9B,4BAA4B,EAAE,MAAM,CAAC;IACrC,2BAA2B,EAAE,MAAM,CAAC;IACpC,8BAA8B,EAAE,MAAM,CAAC;IACvC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2BAA2B,EAAE,MAAM,CAAC;IACpC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,uBAAuB,EAAE,MAAM,CAAC;IAEhC,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAE/B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2BAA2B,EAAE,MAAM,CAAC;IACpC,wBAAwB,EAAE,MAAM,CAAC;IACjC,oBAAoB,EAAE,MAAM,CAAC;IAE7B,0BAA0B,EAAE,MAAM,CAAC;IACnC,6BAA6B,EAAE,MAAM,CAAC;IACtC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,MAAM,CAAC;CACnC;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,cAAc,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;EAuBvB,CAAC;AAEH,eAAO,MAAM,gBAAgB,EAAE,cAAsC,CAAC;AAEtE,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,cAAc,CAEnF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @chipmobilesdk/rn-auth — reusable Microsoft Entra External ID authentication
|
|
3
|
+
* for ChipMobileSdk-family React Native apps (public OIDC/PKCE client, no
|
|
4
|
+
* backend). This is the single public entrypoint (LIB-003); modules under
|
|
5
|
+
* `core/`, `tokens/`, `oidc/`, `access/`, and `diagnostics/` are private.
|
|
6
|
+
*/
|
|
7
|
+
import type { Auth, AuthConfig, CreateAuthOptions } from './config/types';
|
|
8
|
+
/** Create the auth controller. Throws AuthConfigError on invalid config (FR-005). */
|
|
9
|
+
export declare function createAuth(config: AuthConfig, options?: CreateAuthOptions): Auth;
|
|
10
|
+
export type { Auth, AuthConfig, CreateAuthOptions, AuthState, AuthStatus, RestoreStatus, Profile, ProviderIdentity, ProviderConfig, ProviderId, KnownProviderId, DevicePlatform, ResourceConfig, ClaimMatcher, AccessTierMapping, AccessTier, AccessTokenResult, AccessTokenStatus, PremiumGateResult, GlobalSignOutResult, } from './config/types';
|
|
11
|
+
export { describeProviderIdentity, mapClaimsToProfile } from './core/profile';
|
|
12
|
+
export type { AccessTokenRequestOptions } from './tokens/accessToken';
|
|
13
|
+
export type { SecureTokenStore } from './tokens/secureStore';
|
|
14
|
+
export { createKeychainSecureStore, AUTH_STORAGE_KEY } from './tokens/secureStore';
|
|
15
|
+
export type { OidcAuthClient, OidcTokens, OidcServiceConfiguration, AppAuthClientOptions, AuthorizeParams, RefreshParams, EndSessionParams, } from './oidc/authClient';
|
|
16
|
+
export { createAppAuthClient } from './oidc/authClient';
|
|
17
|
+
export { evaluateAccessTier, failClosedTier } from './access/accessTier';
|
|
18
|
+
export { AuthError, AuthConfigError, isAuthError, redact } from './diagnostics/errors';
|
|
19
|
+
export type { AuthErrorCode, AuthErrorAudience } from './diagnostics/errors';
|
|
20
|
+
export { DEFAULT_MESSAGES, authMessages, resolveMessages } from './diagnostics/messageKeys';
|
|
21
|
+
export type { AuthMessageMap, AuthMessageKey } from './diagnostics/messageKeys';
|
|
22
|
+
export { AuthProvider } from './react/AuthProvider';
|
|
23
|
+
export { useAuthSelector } from './react/hooks';
|
|
24
|
+
export type { AuthProviderProps } from './react/AuthProvider';
|
|
25
|
+
export { useAuth, useAuthMessages, useProfile, useAccessTier, useAccessToken, useSignInProvider, useSignInProviders, } from './react/hooks';
|
|
26
|
+
export type { UseAuthResult, UseAccessTokenResult, UseAccessTokenStatus } from './react/hooks';
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE1E,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAEhF;AAGD,YAAY,EACX,IAAI,EACJ,UAAU,EACV,iBAAiB,EACjB,SAAS,EACT,UAAU,EACV,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,cAAc,EACd,cAAc,EACd,YAAY,EACZ,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,GACnB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE9E,YAAY,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACtE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnF,YAAY,EACX,cAAc,EACd,UAAU,EACV,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,gBAAgB,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGzE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACvF,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5F,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAGhF,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACN,OAAO,EACP,eAAe,EACf,UAAU,EACV,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,kBAAkB,GAClB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@chipmobilesdk/rn-auth/keychain`: the default secure token store over
|
|
3
|
+
* react-native-keychain (AUTH-09). Its own entrypoint, so an app with its own
|
|
4
|
+
* secure storage never reaches this module.
|
|
5
|
+
*/
|
|
6
|
+
export { createKeychainSecureStore, type KeychainSecureStoreOptions } from './tokens/secureStore';
|
|
7
|
+
//# sourceMappingURL=keychain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keychain.d.ts","sourceRoot":"","sources":["../../../src/keychain.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,yBAAyB,EAAE,KAAK,0BAA0B,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OidcAuthClient port + default react-native-app-auth adapter (R1).
|
|
3
|
+
*
|
|
4
|
+
* The port abstracts the Authorization Code + PKCE public-client flow so the
|
|
5
|
+
* auth engine is testable without native code. The default adapter lazily
|
|
6
|
+
* requires react-native-app-auth and is validated on device.
|
|
7
|
+
*/
|
|
8
|
+
export interface OidcTokens {
|
|
9
|
+
/** Resource/audience access token (present for authorize and resource refresh). */
|
|
10
|
+
accessToken?: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Refresh token used for silent acquisition and restore. Absent when the
|
|
13
|
+
* provider issued none — a refresh that does not rotate, or an authorize the
|
|
14
|
+
* tenant answered without `offline_access`.
|
|
15
|
+
*/
|
|
16
|
+
refreshToken?: string | undefined;
|
|
17
|
+
/** Raw id token (JWT). Absent from a refresh requested without `openid`. */
|
|
18
|
+
idToken?: string | undefined;
|
|
19
|
+
/** Decoded id-token (or access-token) claims used for profile + access tier. */
|
|
20
|
+
claims: Record<string, unknown>;
|
|
21
|
+
/** Access-token expiry in epoch milliseconds, when available. */
|
|
22
|
+
accessTokenExpiresAt?: number | undefined;
|
|
23
|
+
}
|
|
24
|
+
export interface AuthorizeParams {
|
|
25
|
+
authority: string;
|
|
26
|
+
clientId: string;
|
|
27
|
+
redirectUrl: string;
|
|
28
|
+
scopes: string[];
|
|
29
|
+
/** Additional OIDC parameters, e.g. `domain_hint` for social routing. */
|
|
30
|
+
additionalParameters?: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
export interface RefreshParams {
|
|
33
|
+
authority: string;
|
|
34
|
+
clientId: string;
|
|
35
|
+
redirectUrl: string;
|
|
36
|
+
refreshToken: string;
|
|
37
|
+
scopes: string[];
|
|
38
|
+
}
|
|
39
|
+
export interface EndSessionParams {
|
|
40
|
+
authority: string;
|
|
41
|
+
clientId: string;
|
|
42
|
+
redirectUrl: string;
|
|
43
|
+
idToken?: string | undefined;
|
|
44
|
+
}
|
|
45
|
+
export interface OidcAuthClient {
|
|
46
|
+
authorize(params: AuthorizeParams): Promise<OidcTokens>;
|
|
47
|
+
refresh(params: RefreshParams): Promise<OidcTokens>;
|
|
48
|
+
endSession(params: EndSessionParams): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/** Decode the payload segment of a JWT without any dependency (device-safe). */
|
|
51
|
+
export declare function decodeJwtClaims(jwt: string | null | undefined): Record<string, unknown>;
|
|
52
|
+
/** The endpoints discovery would have returned, when an app already knows them. */
|
|
53
|
+
export interface OidcServiceConfiguration {
|
|
54
|
+
authorizationEndpoint: string;
|
|
55
|
+
tokenEndpoint: string;
|
|
56
|
+
endSessionEndpoint?: string;
|
|
57
|
+
revocationEndpoint?: string;
|
|
58
|
+
registrationEndpoint?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface AppAuthClientOptions {
|
|
61
|
+
/** When true, the OIDC discovery document is fetched from `${authority}`. */
|
|
62
|
+
useDiscovery?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Static endpoints, used instead of discovery. Every authorize, refresh and
|
|
65
|
+
* sign-out otherwise costs the native module one `.well-known` round-trip,
|
|
66
|
+
* including the refresh on the startup path (AUTH-08).
|
|
67
|
+
*/
|
|
68
|
+
serviceConfiguration?: OidcServiceConfiguration;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Default OidcAuthClient adapter wrapping react-native-app-auth (PKCE public
|
|
72
|
+
* client). Validated on device (R8).
|
|
73
|
+
*/
|
|
74
|
+
export declare function createAppAuthClient(options?: AppAuthClientOptions): OidcAuthClient;
|
|
75
|
+
//# sourceMappingURL=authClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authClient.d.ts","sourceRoot":"","sources":["../../../../src/oidc/authClient.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,MAAM,WAAW,UAAU;IAC1B,mFAAmF;IACnF,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,gFAAgF;IAChF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,iEAAiE;IACjE,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C;AAED,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,yEAAyE;IACzE,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,aAAa;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED,MAAM,WAAW,cAAc;IAC9B,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACxD,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACpD,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAED,gFAAgF;AAChF,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAcvF;AA0CD,mFAAmF;AACnF,MAAM,WAAW,wBAAwB;IACxC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,oBAAoB;IACpC,6EAA6E;IAC7E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,wBAAwB,CAAC;CAChD;AAyCD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,cAAc,CAwEtF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classifies a native OIDC error into an `AuthErrorCode`.
|
|
3
|
+
*
|
|
4
|
+
* The rules are an ordered table rather than a chain of substring checks, so a
|
|
5
|
+
* platform adapter (the iOS one, later) adds its own rows without touching the
|
|
6
|
+
* engine. Order matters: the first matching rule wins.
|
|
7
|
+
*
|
|
8
|
+
* The default is deliberately not "session expired". Restore clears the stored
|
|
9
|
+
* session only on `session-expired`, so anything this table cannot name — a
|
|
10
|
+
* timeout, a 5xx, a discovery failure, a localized message — must keep the
|
|
11
|
+
* session rather than sign the user out.
|
|
12
|
+
*/
|
|
13
|
+
import { AuthError, type AuthErrorCode } from '../diagnostics/errors';
|
|
14
|
+
import type { AuthMessageKey } from '../diagnostics/messageKeys';
|
|
15
|
+
export interface ClassificationRule {
|
|
16
|
+
readonly code: AuthErrorCode;
|
|
17
|
+
readonly messageKey: AuthMessageKey;
|
|
18
|
+
/** Matched against the native error's `code` and `message`, case-insensitively. */
|
|
19
|
+
readonly pattern: RegExp;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* OAuth error codes (RFC 6749 §5.2, OIDC Core §3.1.2.6) and the Entra ID AADSTS
|
|
23
|
+
* codes that mean the same thing, plus the transport failures app-auth reports.
|
|
24
|
+
*/
|
|
25
|
+
export declare const DEFAULT_CLASSIFICATION_RULES: readonly ClassificationRule[];
|
|
26
|
+
/** Maps a native app-auth error to a classified AuthError without leaking tokens. */
|
|
27
|
+
export declare function classifyAppAuthError(error: unknown, rules?: readonly ClassificationRule[]): AuthError;
|
|
28
|
+
//# sourceMappingURL=classifyError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classifyError.d.ts","sourceRoot":"","sources":["../../../../src/oidc/classifyError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,mFAAmF;IACnF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,SAAS,kBAAkB,EA8BrE,CAAC;AAEF,qFAAqF;AACrF,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,OAAO,EACd,KAAK,GAAE,SAAS,kBAAkB,EAAiC,GACjE,SAAS,CAaX"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Social provider routing (FR-002/FR-003, R3). Google and Apple are federated
|
|
3
|
+
* inside the External ID tenant; the app presents the platform-correct action
|
|
4
|
+
* and starts the user flow with a per-provider `domain_hint`.
|
|
5
|
+
*/
|
|
6
|
+
import type { AuthConfig, DevicePlatform, ProviderConfig, ProviderId } from '../config/types';
|
|
7
|
+
/** Find the configured provider, ensuring it is enabled for the platform. */
|
|
8
|
+
export declare function resolveProvider(config: AuthConfig, providerId: ProviderId, platform: DevicePlatform): ProviderConfig;
|
|
9
|
+
/** Build the OIDC additional parameters that route to the chosen IdP. */
|
|
10
|
+
export declare function buildAdditionalParameters(provider: ProviderConfig): Record<string, string>;
|
|
11
|
+
/**
|
|
12
|
+
* All providers to present on a given platform, in configuration array order
|
|
13
|
+
* (FR-003/FR-004). Filtered to providers enabled for the platform and not marked
|
|
14
|
+
* unavailable.
|
|
15
|
+
*/
|
|
16
|
+
export declare function availableProvidersForPlatform(config: AuthConfig, platform: DevicePlatform): ProviderConfig[];
|
|
17
|
+
/**
|
|
18
|
+
* The first available provider for a platform (UX-004, back-compat). Equals
|
|
19
|
+
* `availableProvidersForPlatform(config, platform)[0]`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function defaultProviderForPlatform(config: AuthConfig, platform: DevicePlatform): ProviderConfig | undefined;
|
|
22
|
+
//# sourceMappingURL=socialRouting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socialRouting.d.ts","sourceRoot":"","sources":["../../../../src/oidc/socialRouting.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG9F,6EAA6E;AAC7E,wBAAgB,eAAe,CAC9B,MAAM,EAAE,UAAU,EAClB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,cAAc,GACtB,cAAc,CAqBhB;AAED,yEAAyE;AACzE,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAI1F;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC5C,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,cAAc,GACtB,cAAc,EAAE,CAIlB;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACzC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,cAAc,GACtB,cAAc,GAAG,SAAS,CAE5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React context boundary for the auth controller (LIB-002).
|
|
3
|
+
*
|
|
4
|
+
* The context carries the controller only, never its state: a context value that
|
|
5
|
+
* changed on every transition re-rendered every consumer on every transition
|
|
6
|
+
* (PERF-02). Hooks read the state through `useSyncExternalStore` with a selector,
|
|
7
|
+
* so a component re-renders only when the part it reads changes.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import type { Auth } from '../config/types';
|
|
11
|
+
export interface AuthProviderProps {
|
|
12
|
+
auth: Auth;
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare function AuthProvider({ auth, children }: AuthProviderProps): React.JSX.Element;
|
|
16
|
+
export declare function useAuthInstance(): Auth;
|
|
17
|
+
//# sourceMappingURL=AuthProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../../../src/react/AuthProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAoC,MAAM,OAAO,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAI5C,MAAM,WAAW,iBAAiB;IACjC,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B;AAED,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,iBAAiB,qBAEjE;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC"}
|
|
@@ -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';
|
|
7
|
+
import type { AccessTokenRequestOptions } from '../tokens/accessToken';
|
|
8
|
+
import type { AuthMessageMap } from '../diagnostics/messageKeys';
|
|
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,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,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';
|
|
11
|
+
import type { SecureTokenStore } from '../tokens/secureStore';
|
|
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,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,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';
|
|
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';
|
|
10
|
+
export type { OidcHarness, OidcSubject, SecureStoreHarness } from './conformance';
|
|
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,uBAAuB,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,eAAe,CAAC;AACvB,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,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';
|
|
7
|
+
import type { OidcAuthClient } from '../oidc/authClient';
|
|
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,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Access-tier evaluation (FR-010/FR-011/FR-019/FR-020, R6).
|
|
3
|
+
*
|
|
4
|
+
* Pure function over the authenticated token's claims and the app-specific
|
|
5
|
+
* mapping. Object ids are authoritative; display names never grant access.
|
|
6
|
+
* Missing, stale, ambiguous, or group-overage claims fail closed (premium
|
|
7
|
+
* denied, verification = 'unverified').
|
|
8
|
+
*/
|
|
9
|
+
import type { AccessTier, AccessTierMapping } from '../config/types.js';
|
|
10
|
+
/** The fail-closed default: free + unverified. */
|
|
11
|
+
export declare function failClosedTier(): AccessTier;
|
|
12
|
+
/** Evaluate the access tier, failing closed when entitlement is unverifiable. */
|
|
13
|
+
export declare function evaluateAccessTier(claims: Record<string, unknown>, mapping: AccessTierMapping, now?: number): AccessTier;
|
|
14
|
+
//# sourceMappingURL=accessTier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessTier.d.ts","sourceRoot":"","sources":["../../../../src/access/accessTier.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAgB,MAAM,oBAAiB,CAAC;AAEnF,kDAAkD;AAClD,wBAAgB,cAAc,IAAI,UAAU,CAE3C;AAoCD,iFAAiF;AACjF,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,iBAAiB,EAC1B,GAAG,GAAE,MAAmB,GACtB,UAAU,CAgCZ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@chipmobilesdk/rn-auth/app-auth`: the default OIDC client over
|
|
3
|
+
* react-native-app-auth (AUTH-09). Its own entrypoint, so an app that injects its
|
|
4
|
+
* own client never reaches this module.
|
|
5
|
+
*/
|
|
6
|
+
export { createAppAuthClient, type AppAuthClientOptions } from './oidc/authClient.js';
|
|
7
|
+
//# sourceMappingURL=app-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-auth.d.ts","sourceRoot":"","sources":["../../../src/app-auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,mBAAmB,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAmB,CAAC"}
|