@baukit/auth-native 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Patrick Koss
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # `@baukit/auth-native`
2
+
3
+ Provider-neutral native OIDC authorization-code client with S256 PKCE, standard discovery, secure-storage and browser-flow ports, refresh rotation, and local-first sign-out. The core has no React, router, or product UI dependency.
4
+
5
+ ```ts
6
+ import { createExpoOidcClient } from '@baukit/auth-native/expo';
7
+ import * as AuthSession from 'expo-auth-session';
8
+
9
+ const auth = createExpoOidcClient({
10
+ issuer: 'https://identity.example.com/tenant',
11
+ clientId: 'product-mobile',
12
+ redirectUri: AuthSession.makeRedirectUri({ scheme: 'product', path: 'oauth' }),
13
+ offlineAccess: true,
14
+ });
15
+
16
+ await auth.initialize();
17
+ const result = await auth.signIn();
18
+ if (result.status === 'cancelled') {
19
+ // Restore focus or announce cancellation. This is not an authentication error.
20
+ }
21
+ ```
22
+
23
+ The issuer is resolved only through `/.well-known/openid-configuration`; provider-specific paths are never manufactured. A successful authorization-code exchange is followed by an authenticated UserInfo request. Its non-empty `sub` is the authoritative subject stored in the immutable session. The package does not trust an unverified, locally decoded ID-token claim as identity.
24
+
25
+ `session()` exposes the subject, access token, optional refresh and ID tokens, and absolute expiry. Refresh responses retain the previous refresh token or ID token when the provider omits either. When a session inside the configured refresh window has no refresh token, `accessToken()` clears it and returns `undefined`; callers should present sign-in again.
26
+
27
+ `offlineAccess` deliberately defaults to `false`; set it to `true` only when the provider is configured to issue refresh tokens for `offline_access`. `accessToken()` shares one refresh across concurrent callers. Pass `{ forceRefresh: true }` after a 401 to bypass the proactive expiry window while still joining any refresh already in flight.
28
+
29
+ Terminal refresh rejection (`invalid_grant`, `invalid_token`, or HTTP 400/401) clears the session and resolves to `undefined`. Subscribe with `subscribeSessionExpired()` to stop schedulers and move UI to signed-out state. Network, malformed-response, rate-limit, and provider 5xx failures preserve the stored session and reject with a sanitized `OidcError` whose `retryable` property is `true`.
30
+
31
+ `signOut()` deletes the local session before provider interaction. It then attempts the discovered end-session endpoint. A missing, cancelled, or failing provider logout persists a fail-safe flag so the next `signIn()` includes `prompt=login`; that flag is removed only after provider logout or a later successful sign-in. Corrupt secure-storage state is deleted and treated as signed out.
32
+
33
+ Use `safeAuthErrorMessage(error)` at UI boundaries. Errors contain only allowlisted library codes/messages and optional HTTP status numbers. Provider bodies, authorization codes, tokens, and adapter exception messages are never copied into errors or logs.
34
+
35
+ The default Expo entry point uses `expo-auth-session`, `expo-secure-store`, and `expo-web-browser`, which are peer dependencies. For deterministic tests or another native stack, construct `NativeOidcClient` with your own `SecureStoragePort`, `BrowserFlowPort`, `fetch`, and clock.
36
+
37
+ Universal Expo products can pass a `storage` port to
38
+ `createExpoOidcEnvironment` or `createExpoOidcClient`. This supports a web
39
+ localStorage adapter or a product-owned compatibility/migration wrapper while
40
+ retaining the standard Expo browser flow.
package/dist/expo.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import * as SecureStore from 'expo-secure-store';
2
+ import { NativeOidcClient } from './index.js';
3
+ import type { FetchPort, NativeOidcConfig, NativeOidcEnvironment, SecureStoragePort } from './index.js';
4
+ export interface ExpoOidcEnvironmentOptions {
5
+ readonly fetch?: FetchPort;
6
+ readonly now?: () => number;
7
+ /** Overrides SecureStore for universal Expo apps or product-owned migration adapters. */
8
+ readonly storage?: SecureStoragePort;
9
+ readonly secureStoreOptions?: SecureStore.SecureStoreOptions;
10
+ }
11
+ /** Completes an Expo web auth redirect when the module is used on web. */
12
+ export declare function completeExpoAuthSession(): void;
13
+ /** Creates thin Expo implementations of the native client's storage and browser ports. */
14
+ export declare function createExpoOidcEnvironment(options?: ExpoOidcEnvironmentOptions): NativeOidcEnvironment;
15
+ export declare function createExpoOidcClient(config: NativeOidcConfig, options?: ExpoOidcEnvironmentOptions): NativeOidcClient;
16
+ //# sourceMappingURL=expo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expo.d.ts","sourceRoot":"","sources":["../src/expo.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAGV,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,yFAAyF;IACzF,QAAQ,CAAC,OAAO,CAAC,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC;CAC9D;AAED,0EAA0E;AAC1E,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C;AAED,0FAA0F;AAC1F,wBAAgB,yBAAyB,CACvC,OAAO,GAAE,0BAA+B,GACvC,qBAAqB,CAyCvB;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE,0BAA+B,GACvC,gBAAgB,CAElB"}
package/dist/expo.js ADDED
@@ -0,0 +1,62 @@
1
+ import * as AuthSession from 'expo-auth-session';
2
+ import * as SecureStore from 'expo-secure-store';
3
+ import * as WebBrowser from 'expo-web-browser';
4
+ import { NativeOidcClient } from './index.js';
5
+ /** Completes an Expo web auth redirect when the module is used on web. */
6
+ export function completeExpoAuthSession() {
7
+ WebBrowser.maybeCompleteAuthSession();
8
+ }
9
+ /** Creates thin Expo implementations of the native client's storage and browser ports. */
10
+ export function createExpoOidcEnvironment(options = {}) {
11
+ const storage = options.storage ?? createExpoSecureStorage(options.secureStoreOptions);
12
+ const browser = {
13
+ async authorize(request) {
14
+ const authRequest = new AuthSession.AuthRequest({
15
+ clientId: request.clientId,
16
+ redirectUri: request.redirectUri,
17
+ responseType: AuthSession.ResponseType.Code,
18
+ scopes: [...request.scopes],
19
+ usePKCE: true,
20
+ ...(request.prompt === undefined ? {} : { prompt: AuthSession.Prompt.Login }),
21
+ });
22
+ const result = await authRequest.promptAsync({
23
+ authorizationEndpoint: request.authorizationEndpoint,
24
+ });
25
+ if (result.type === 'cancel' || result.type === 'dismiss') {
26
+ return { type: result.type };
27
+ }
28
+ if (result.type !== 'success') {
29
+ return { type: 'error' };
30
+ }
31
+ return {
32
+ type: 'success',
33
+ code: result.params['code'] ?? '',
34
+ state: result.params['state'] ?? '',
35
+ expectedState: authRequest.state,
36
+ codeVerifier: authRequest.codeVerifier ?? '',
37
+ };
38
+ },
39
+ async endSession(request) {
40
+ const result = await WebBrowser.openAuthSessionAsync(request.url, request.redirectUri);
41
+ return result.type === 'success';
42
+ },
43
+ };
44
+ const fetchImplementation = options.fetch ?? globalThis.fetch.bind(globalThis);
45
+ return {
46
+ fetch: fetchImplementation,
47
+ storage,
48
+ browser,
49
+ now: options.now ?? (() => Date.now()),
50
+ };
51
+ }
52
+ export function createExpoOidcClient(config, options = {}) {
53
+ return new NativeOidcClient(config, createExpoOidcEnvironment(options));
54
+ }
55
+ function createExpoSecureStorage(options) {
56
+ return {
57
+ get: (key) => SecureStore.getItemAsync(key, options),
58
+ set: (key, value) => SecureStore.setItemAsync(key, value, options),
59
+ delete: (key) => SecureStore.deleteItemAsync(key, options),
60
+ };
61
+ }
62
+ //# sourceMappingURL=expo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expo.js","sourceRoot":"","sources":["../src/expo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAkB9C,0EAA0E;AAC1E,MAAM,UAAU,uBAAuB;IACrC,UAAU,CAAC,wBAAwB,EAAE,CAAC;AACxC,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,yBAAyB,CACvC,UAAsC,EAAE;IAExC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,uBAAuB,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACvF,MAAM,OAAO,GAAoB;QAC/B,KAAK,CAAC,SAAS,CAAC,OAAO;YACrB,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,WAAW,CAAC;gBAC9C,QAAQ,EAAE,OAAO,CAAC,QAAQ;gBAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;gBAChC,YAAY,EAAE,WAAW,CAAC,YAAY,CAAC,IAAI;gBAC3C,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;gBAC3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AAO;QACP,OAAO;QACP,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;KACvC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,MAAwB,EACxB,UAAsC,EAAE;IAExC,OAAO,IAAI,gBAAgB,CAAC,MAAM,EAAE,yBAAyB,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,uBAAuB,CAC9B,OAAmD;IAEnD,OAAO;QACL,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC;QACpD,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC;QAClE,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,CAAC;KAC3D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,151 @@
1
+ export type OidcErrorCode = 'authorization_failed' | 'callback_state_mismatch' | 'discovery_failed' | 'invalid_discovery_document' | 'invalid_token_response' | 'invalid_userinfo_response' | 'issuer_mismatch' | 'pkce_verifier_missing' | 'refresh_failed' | 'storage_failed' | 'token_exchange_failed' | 'userinfo_failed';
2
+ /** An authentication failure whose message is safe to display or log. */
3
+ export declare class OidcError extends Error {
4
+ readonly code: OidcErrorCode;
5
+ readonly status: number | undefined;
6
+ /** True only when retrying the failed operation may succeed without signing in again. */
7
+ readonly retryable: boolean;
8
+ constructor(code: OidcErrorCode, options?: {
9
+ readonly retryable?: boolean;
10
+ readonly status?: number;
11
+ });
12
+ }
13
+ export interface NativeOidcConfig {
14
+ readonly issuer: string;
15
+ readonly clientId: string;
16
+ readonly redirectUri: string;
17
+ /** `openid` is prepended when omitted. Defaults to `openid profile email`. */
18
+ readonly scopes?: readonly string[];
19
+ /** Adds `offline_access` to the requested scopes. Defaults to false. */
20
+ readonly offlineAccess?: boolean;
21
+ /** Defaults to `redirectUri`. */
22
+ readonly postLogoutRedirectUri?: string;
23
+ /** Defaults to 30 seconds. */
24
+ readonly refreshLeewaySeconds?: number;
25
+ /** Overrides the deterministic issuer/client-specific storage prefix. */
26
+ readonly storageKeyPrefix?: string;
27
+ }
28
+ export interface OidcProviderMetadata {
29
+ readonly issuer: string;
30
+ readonly authorizationEndpoint: string;
31
+ readonly tokenEndpoint: string;
32
+ readonly userInfoEndpoint: string;
33
+ readonly endSessionEndpoint?: string;
34
+ }
35
+ export interface OidcSession {
36
+ /** Immutable OIDC subject obtained from the authenticated UserInfo response. */
37
+ readonly subject: string;
38
+ readonly accessToken: string;
39
+ readonly refreshToken?: string;
40
+ readonly idToken?: string;
41
+ readonly expiresAt: number;
42
+ }
43
+ export type SignInResult = {
44
+ readonly status: 'success';
45
+ readonly subject: string;
46
+ } | {
47
+ readonly status: 'cancelled';
48
+ readonly reason: 'cancel' | 'dismiss';
49
+ };
50
+ export type SignOutResult = {
51
+ readonly providerLogout: 'completed';
52
+ } | {
53
+ readonly providerLogout: 'unavailable';
54
+ } | {
55
+ readonly providerLogout: 'failed';
56
+ };
57
+ export type SessionExpiredReason = 'refresh_rejected' | 'refresh_unavailable';
58
+ export interface SessionExpiredEvent {
59
+ readonly type: 'session-expired';
60
+ readonly reason: SessionExpiredReason;
61
+ }
62
+ export interface SecureStoragePort {
63
+ get(key: string): Promise<string | null>;
64
+ set(key: string, value: string): Promise<void>;
65
+ delete(key: string): Promise<void>;
66
+ }
67
+ export interface AuthorizationRequest {
68
+ readonly authorizationEndpoint: string;
69
+ readonly clientId: string;
70
+ readonly redirectUri: string;
71
+ readonly scopes: readonly string[];
72
+ readonly prompt?: 'login';
73
+ }
74
+ export type AuthorizationResult = {
75
+ readonly type: 'cancel';
76
+ } | {
77
+ readonly type: 'dismiss';
78
+ } | {
79
+ readonly type: 'error';
80
+ } | {
81
+ readonly type: 'success';
82
+ readonly code: string;
83
+ readonly state: string;
84
+ readonly expectedState: string;
85
+ readonly codeVerifier: string;
86
+ };
87
+ export interface EndSessionRequest {
88
+ readonly url: string;
89
+ readonly redirectUri: string;
90
+ }
91
+ /** AuthSession-like browser seam. Implementations own S256 PKCE and transaction state creation. */
92
+ export interface BrowserFlowPort {
93
+ authorize(request: AuthorizationRequest): Promise<AuthorizationResult>;
94
+ endSession(request: EndSessionRequest): Promise<boolean>;
95
+ }
96
+ export type FetchPort = (input: string, init?: RequestInit) => Promise<Response>;
97
+ export interface NativeOidcEnvironment {
98
+ readonly fetch: FetchPort;
99
+ readonly storage: SecureStoragePort;
100
+ readonly browser: BrowserFlowPort;
101
+ readonly now: () => number;
102
+ }
103
+ type SessionListener = (session: OidcSession | undefined) => void;
104
+ type SessionExpiredListener = (event: SessionExpiredEvent) => void;
105
+ /** Provider-neutral native OIDC client. It has no React or router dependency. */
106
+ export declare class NativeOidcClient {
107
+ private readonly config;
108
+ private readonly environment;
109
+ private readonly sessionStorageKey;
110
+ private readonly forceLoginStorageKey;
111
+ private readonly listeners;
112
+ private readonly sessionExpiredListeners;
113
+ private currentSession;
114
+ private initialized;
115
+ private initializePromise;
116
+ private metadataPromise;
117
+ private refreshPromise;
118
+ constructor(config: NativeOidcConfig, environment: NativeOidcEnvironment);
119
+ /** Loads secure storage once. Corrupt values are removed and treated as signed out. */
120
+ initialize(): Promise<OidcSession | undefined>;
121
+ /** Returns the last initialized session without performing I/O. */
122
+ session(): OidcSession | undefined;
123
+ subscribe(listener: SessionListener): () => void;
124
+ /** Observes terminal expiry separately from explicit sign-out or manual clearing. */
125
+ subscribeSessionExpired(listener: SessionExpiredListener): () => void;
126
+ discover(): Promise<OidcProviderMetadata>;
127
+ signIn(): Promise<SignInResult>;
128
+ /** Returns a current token, refreshing once when needed. */
129
+ accessToken(options?: {
130
+ readonly forceRefresh?: boolean;
131
+ }): Promise<string | undefined>;
132
+ /** Clears local state first, then makes a best-effort provider logout attempt. */
133
+ signOut(): Promise<SignOutResult>;
134
+ /** Clears local authentication state without contacting the provider. */
135
+ clearSession(): Promise<void>;
136
+ private initializeOnce;
137
+ private refresh;
138
+ private exchange;
139
+ private writeSession;
140
+ private readForceLogin;
141
+ private setForceLogin;
142
+ private deleteForceLoginBestEffort;
143
+ private setCurrentSession;
144
+ private expireSession;
145
+ }
146
+ /** Removes trailing issuer slashes while rejecting query strings and fragments. */
147
+ export declare function normalizeIssuer(issuer: string): string;
148
+ /** Returns an allowlisted message without reflecting untrusted error content. */
149
+ export declare function safeAuthErrorMessage(cause: unknown): string;
150
+ export {};
151
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GACrB,sBAAsB,GACtB,yBAAyB,GACzB,kBAAkB,GAClB,4BAA4B,GAC5B,wBAAwB,GACxB,2BAA2B,GAC3B,iBAAiB,GACjB,uBAAuB,GACvB,gBAAgB,GAChB,gBAAgB,GAChB,uBAAuB,GACvB,iBAAiB,CAAC;AAiBtB,yEAAyE;AACzE,qBAAa,SAAU,SAAQ,KAAK;IAClC,SAAgB,IAAI,EAAE,aAAa,CAAC;IACpC,SAAgB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,yFAAyF;IACzF,SAAgB,SAAS,EAAE,OAAO,CAAC;gBAGjC,IAAI,EAAE,aAAa,EACnB,OAAO,GAAE;QAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAO;CAQ3E;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,8EAA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iBAAiB,CAA+C;IACxE,OAAO,CAAC,eAAe,CAA4C;IACnE,OAAO,CAAC,cAAc,CAA0C;gBAE7C,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,qBAAqB;IAO/E,uFAAuF;IAChF,UAAU,IAAI,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAQrD,mEAAmE;IAC5D,OAAO,IAAI,WAAW,GAAG,SAAS;IAIlC,SAAS,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,IAAI;IAOvD,qFAAqF;IAC9E,uBAAuB,CAAC,QAAQ,EAAE,sBAAsB,GAAG,MAAM,IAAI;IAOrE,QAAQ,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAKnC,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC;IAoD5C,4DAA4D;IAC/C,WAAW,CACtB,OAAO,GAAE;QAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAA;KAAO,GAChD,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IA4B9B,kFAAkF;IACrE,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC;IAqC9C,yEAAyE;IAC5D,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;YAS5B,cAAc;YAsBd,OAAO;YAoCP,QAAQ;YAqCR,YAAY;YASZ,cAAc;YAgBd,aAAa;YAQb,0BAA0B;IAQxC,OAAO,CAAC,iBAAiB;YAWX,aAAa;CAW5B;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAUtD;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE3D"}
package/dist/index.js ADDED
@@ -0,0 +1,581 @@
1
+ const SAFE_ERROR_MESSAGES = {
2
+ authorization_failed: 'OIDC authorization failed.',
3
+ callback_state_mismatch: 'OIDC callback state did not match the login transaction.',
4
+ discovery_failed: 'OIDC provider discovery failed.',
5
+ invalid_discovery_document: 'OIDC provider returned invalid discovery metadata.',
6
+ invalid_token_response: 'OIDC token endpoint returned an invalid response.',
7
+ invalid_userinfo_response: 'OIDC UserInfo endpoint returned an invalid response.',
8
+ issuer_mismatch: 'OIDC provider issuer did not match the configured issuer.',
9
+ pkce_verifier_missing: 'OIDC login did not produce a PKCE verifier.',
10
+ refresh_failed: 'OIDC token refresh failed.',
11
+ storage_failed: 'Secure authentication storage failed.',
12
+ token_exchange_failed: 'OIDC token exchange failed.',
13
+ userinfo_failed: 'OIDC UserInfo request failed.',
14
+ };
15
+ /** An authentication failure whose message is safe to display or log. */
16
+ export class OidcError extends Error {
17
+ code;
18
+ status;
19
+ /** True only when retrying the failed operation may succeed without signing in again. */
20
+ retryable;
21
+ constructor(code, options = {}) {
22
+ super(SAFE_ERROR_MESSAGES[code]);
23
+ this.name = 'OidcError';
24
+ this.code = code;
25
+ this.status = options.status;
26
+ this.retryable = options.retryable ?? false;
27
+ }
28
+ }
29
+ /** Provider-neutral native OIDC client. It has no React or router dependency. */
30
+ export class NativeOidcClient {
31
+ config;
32
+ environment;
33
+ sessionStorageKey;
34
+ forceLoginStorageKey;
35
+ listeners = new Set();
36
+ sessionExpiredListeners = new Set();
37
+ currentSession;
38
+ initialized = false;
39
+ initializePromise;
40
+ metadataPromise;
41
+ refreshPromise;
42
+ constructor(config, environment) {
43
+ this.config = normalizeConfig(config);
44
+ this.environment = environment;
45
+ this.sessionStorageKey = `${this.config.storageKeyPrefix}:session`;
46
+ this.forceLoginStorageKey = `${this.config.storageKeyPrefix}:force-login`;
47
+ }
48
+ /** Loads secure storage once. Corrupt values are removed and treated as signed out. */
49
+ initialize() {
50
+ if (this.initialized) {
51
+ return Promise.resolve(this.currentSession);
52
+ }
53
+ this.initializePromise ??= this.initializeOnce();
54
+ return this.initializePromise;
55
+ }
56
+ /** Returns the last initialized session without performing I/O. */
57
+ session() {
58
+ return this.currentSession;
59
+ }
60
+ subscribe(listener) {
61
+ this.listeners.add(listener);
62
+ return () => {
63
+ this.listeners.delete(listener);
64
+ };
65
+ }
66
+ /** Observes terminal expiry separately from explicit sign-out or manual clearing. */
67
+ subscribeSessionExpired(listener) {
68
+ this.sessionExpiredListeners.add(listener);
69
+ return () => {
70
+ this.sessionExpiredListeners.delete(listener);
71
+ };
72
+ }
73
+ discover() {
74
+ this.metadataPromise ??= discoverProvider(this.config.issuer, this.environment.fetch);
75
+ return this.metadataPromise;
76
+ }
77
+ async signIn() {
78
+ await this.initialize();
79
+ const metadata = await this.discover();
80
+ const forceLogin = await this.readForceLogin();
81
+ let result;
82
+ try {
83
+ result = await this.environment.browser.authorize({
84
+ authorizationEndpoint: metadata.authorizationEndpoint,
85
+ clientId: this.config.clientId,
86
+ redirectUri: this.config.redirectUri,
87
+ scopes: this.config.scopes,
88
+ ...(forceLogin ? { prompt: 'login' } : {}),
89
+ });
90
+ }
91
+ catch {
92
+ throw new OidcError('authorization_failed');
93
+ }
94
+ if (result.type === 'cancel' || result.type === 'dismiss') {
95
+ return { status: 'cancelled', reason: result.type };
96
+ }
97
+ if (result.type === 'error' || result.code.length === 0) {
98
+ throw new OidcError('authorization_failed');
99
+ }
100
+ if (result.state.length === 0 || result.state !== result.expectedState) {
101
+ throw new OidcError('callback_state_mismatch');
102
+ }
103
+ if (result.codeVerifier.length === 0) {
104
+ throw new OidcError('pkce_verifier_missing');
105
+ }
106
+ const tokens = await this.exchange(metadata.tokenEndpoint, new URLSearchParams({
107
+ grant_type: 'authorization_code',
108
+ client_id: this.config.clientId,
109
+ redirect_uri: this.config.redirectUri,
110
+ code: result.code,
111
+ code_verifier: result.codeVerifier,
112
+ }), 'token_exchange_failed');
113
+ const subject = await fetchSubject(metadata.userInfoEndpoint, tokens.access_token, this.environment.fetch);
114
+ const session = makeSession(tokens, subject);
115
+ await this.writeSession(session);
116
+ await this.deleteForceLoginBestEffort();
117
+ return { status: 'success', subject };
118
+ }
119
+ /** Returns a current token, refreshing once when needed. */
120
+ async accessToken(options = {}) {
121
+ await this.initialize();
122
+ const session = this.currentSession;
123
+ if (session === undefined) {
124
+ return undefined;
125
+ }
126
+ const expiresSoon = session.expiresAt <= this.environment.now() + this.config.refreshLeewayMs;
127
+ if (options.forceRefresh !== true && !expiresSoon) {
128
+ return session.accessToken;
129
+ }
130
+ if (session.refreshToken === undefined) {
131
+ await this.expireSession('refresh_unavailable');
132
+ return undefined;
133
+ }
134
+ if (this.refreshPromise !== undefined) {
135
+ return this.refreshPromise;
136
+ }
137
+ const pending = this.refresh(session);
138
+ this.refreshPromise = pending;
139
+ try {
140
+ return await pending;
141
+ }
142
+ finally {
143
+ if (this.refreshPromise === pending) {
144
+ this.refreshPromise = undefined;
145
+ }
146
+ }
147
+ }
148
+ /** Clears local state first, then makes a best-effort provider logout attempt. */
149
+ async signOut() {
150
+ await this.initialize();
151
+ const idToken = this.currentSession?.idToken;
152
+ await this.clearSession();
153
+ await this.setForceLogin();
154
+ let metadata;
155
+ try {
156
+ metadata = await this.discover();
157
+ }
158
+ catch {
159
+ return { providerLogout: 'failed' };
160
+ }
161
+ if (metadata.endSessionEndpoint === undefined) {
162
+ return { providerLogout: 'unavailable' };
163
+ }
164
+ const endpoint = new URL(metadata.endSessionEndpoint);
165
+ endpoint.searchParams.set('client_id', this.config.clientId);
166
+ endpoint.searchParams.set('post_logout_redirect_uri', this.config.postLogoutRedirectUri);
167
+ if (idToken !== undefined) {
168
+ endpoint.searchParams.set('id_token_hint', idToken);
169
+ }
170
+ try {
171
+ const completed = await this.environment.browser.endSession({
172
+ url: endpoint.toString(),
173
+ redirectUri: this.config.postLogoutRedirectUri,
174
+ });
175
+ if (!completed) {
176
+ return { providerLogout: 'failed' };
177
+ }
178
+ await this.deleteForceLoginBestEffort();
179
+ return { providerLogout: 'completed' };
180
+ }
181
+ catch {
182
+ return { providerLogout: 'failed' };
183
+ }
184
+ }
185
+ /** Clears local authentication state without contacting the provider. */
186
+ async clearSession() {
187
+ this.setCurrentSession(undefined);
188
+ try {
189
+ await this.environment.storage.delete(this.sessionStorageKey);
190
+ }
191
+ catch {
192
+ throw new OidcError('storage_failed');
193
+ }
194
+ }
195
+ async initializeOnce() {
196
+ let raw;
197
+ try {
198
+ raw = await this.environment.storage.get(this.sessionStorageKey);
199
+ }
200
+ catch {
201
+ throw new OidcError('storage_failed');
202
+ }
203
+ const session = parseSession(raw);
204
+ if (raw !== null && session === undefined) {
205
+ this.setCurrentSession(undefined);
206
+ try {
207
+ await this.environment.storage.delete(this.sessionStorageKey);
208
+ }
209
+ catch {
210
+ throw new OidcError('storage_failed');
211
+ }
212
+ }
213
+ else {
214
+ this.setCurrentSession(session);
215
+ }
216
+ this.initialized = true;
217
+ return this.currentSession;
218
+ }
219
+ async refresh(previous) {
220
+ const refreshToken = previous.refreshToken;
221
+ if (refreshToken === undefined) {
222
+ return undefined;
223
+ }
224
+ let tokens;
225
+ try {
226
+ const metadata = await this.discover();
227
+ tokens = await this.exchange(metadata.tokenEndpoint, new URLSearchParams({
228
+ grant_type: 'refresh_token',
229
+ client_id: this.config.clientId,
230
+ refresh_token: refreshToken,
231
+ scope: this.config.scopes.join(' '),
232
+ }), 'refresh_failed');
233
+ }
234
+ catch (cause) {
235
+ if (isTerminalRefreshError(cause)) {
236
+ if (this.currentSession !== previous) {
237
+ return this.currentSession?.accessToken;
238
+ }
239
+ await this.expireSession('refresh_rejected');
240
+ return undefined;
241
+ }
242
+ throw transientRefreshError(cause);
243
+ }
244
+ if (this.currentSession !== previous) {
245
+ return this.currentSession?.accessToken;
246
+ }
247
+ const session = makeSession(tokens, previous.subject, previous);
248
+ await this.writeSession(session);
249
+ return session.accessToken;
250
+ }
251
+ async exchange(endpoint, body, failureCode) {
252
+ let response;
253
+ try {
254
+ response = await this.environment.fetch(endpoint, {
255
+ method: 'POST',
256
+ headers: { 'content-type': 'application/x-www-form-urlencoded' },
257
+ body,
258
+ });
259
+ }
260
+ catch {
261
+ throw new OidcError(failureCode, { retryable: failureCode === 'refresh_failed' });
262
+ }
263
+ const receivedAt = this.environment.now();
264
+ if (!response.ok) {
265
+ const providerError = await readProviderError(response);
266
+ throw new OidcError(failureCode, {
267
+ status: response.status,
268
+ retryable: failureCode === 'refresh_failed' &&
269
+ !isTerminalRefreshRejection(response.status, providerError),
270
+ });
271
+ }
272
+ let value;
273
+ try {
274
+ value = await response.json();
275
+ }
276
+ catch {
277
+ throw new OidcError('invalid_token_response');
278
+ }
279
+ if (!isTokenResponse(value)) {
280
+ throw new OidcError('invalid_token_response');
281
+ }
282
+ return { ...value, receivedAt };
283
+ }
284
+ async writeSession(session) {
285
+ try {
286
+ await this.environment.storage.set(this.sessionStorageKey, JSON.stringify(session));
287
+ }
288
+ catch {
289
+ throw new OidcError('storage_failed');
290
+ }
291
+ this.setCurrentSession(session);
292
+ }
293
+ async readForceLogin() {
294
+ let stored;
295
+ try {
296
+ stored = await this.environment.storage.get(this.forceLoginStorageKey);
297
+ }
298
+ catch {
299
+ throw new OidcError('storage_failed');
300
+ }
301
+ if (stored === null || stored === '0') {
302
+ return false;
303
+ }
304
+ if (stored !== '1') {
305
+ await this.setForceLogin();
306
+ }
307
+ return true;
308
+ }
309
+ async setForceLogin() {
310
+ try {
311
+ await this.environment.storage.set(this.forceLoginStorageKey, '1');
312
+ }
313
+ catch {
314
+ throw new OidcError('storage_failed');
315
+ }
316
+ }
317
+ async deleteForceLoginBestEffort() {
318
+ try {
319
+ await this.environment.storage.delete(this.forceLoginStorageKey);
320
+ }
321
+ catch {
322
+ // Retaining prompt=login is the fail-safe outcome when storage deletion fails.
323
+ }
324
+ }
325
+ setCurrentSession(session) {
326
+ this.currentSession = session;
327
+ for (const listener of this.listeners) {
328
+ try {
329
+ listener(session);
330
+ }
331
+ catch {
332
+ // Observers cannot interrupt persistence or authentication transitions.
333
+ }
334
+ }
335
+ }
336
+ async expireSession(reason) {
337
+ await this.clearSession();
338
+ const event = { type: 'session-expired', reason };
339
+ for (const listener of this.sessionExpiredListeners) {
340
+ try {
341
+ listener(event);
342
+ }
343
+ catch {
344
+ // Observers cannot change the terminal unauthenticated result.
345
+ }
346
+ }
347
+ }
348
+ }
349
+ /** Removes trailing issuer slashes while rejecting query strings and fragments. */
350
+ export function normalizeIssuer(issuer) {
351
+ const trimmed = issuer.trim();
352
+ if (trimmed.length === 0) {
353
+ throw new TypeError('OIDC issuer must not be empty.');
354
+ }
355
+ const url = new URL(trimmed);
356
+ if (url.search.length !== 0 || url.hash.length !== 0) {
357
+ throw new TypeError('OIDC issuer must not include a query string or fragment.');
358
+ }
359
+ return url.toString().replace(/\/+$/u, '');
360
+ }
361
+ /** Returns an allowlisted message without reflecting untrusted error content. */
362
+ export function safeAuthErrorMessage(cause) {
363
+ return cause instanceof OidcError ? SAFE_ERROR_MESSAGES[cause.code] : 'OIDC login failed.';
364
+ }
365
+ async function discoverProvider(issuer, fetchImplementation) {
366
+ let response;
367
+ try {
368
+ response = await fetchImplementation(`${issuer}/.well-known/openid-configuration`);
369
+ }
370
+ catch {
371
+ throw new OidcError('discovery_failed');
372
+ }
373
+ if (!response.ok) {
374
+ throw new OidcError('discovery_failed', { status: response.status });
375
+ }
376
+ let value;
377
+ try {
378
+ value = await response.json();
379
+ }
380
+ catch {
381
+ throw new OidcError('invalid_discovery_document');
382
+ }
383
+ if (!isProviderMetadata(value)) {
384
+ throw new OidcError('invalid_discovery_document');
385
+ }
386
+ if (normalizeIssuer(value.issuer) !== issuer) {
387
+ throw new OidcError('issuer_mismatch');
388
+ }
389
+ return Object.freeze({
390
+ issuer,
391
+ authorizationEndpoint: value.authorization_endpoint,
392
+ tokenEndpoint: value.token_endpoint,
393
+ userInfoEndpoint: value.userinfo_endpoint,
394
+ ...(value.end_session_endpoint === undefined
395
+ ? {}
396
+ : { endSessionEndpoint: value.end_session_endpoint }),
397
+ });
398
+ }
399
+ async function fetchSubject(endpoint, accessToken, fetchImplementation) {
400
+ let response;
401
+ try {
402
+ response = await fetchImplementation(endpoint, {
403
+ headers: { authorization: `Bearer ${accessToken}` },
404
+ });
405
+ }
406
+ catch {
407
+ throw new OidcError('userinfo_failed');
408
+ }
409
+ if (!response.ok) {
410
+ throw new OidcError('userinfo_failed', { status: response.status });
411
+ }
412
+ let value;
413
+ try {
414
+ value = await response.json();
415
+ }
416
+ catch {
417
+ throw new OidcError('invalid_userinfo_response');
418
+ }
419
+ if (!isObject(value) || typeof value['sub'] !== 'string' || value['sub'].length === 0) {
420
+ throw new OidcError('invalid_userinfo_response');
421
+ }
422
+ return value['sub'];
423
+ }
424
+ function normalizeConfig(config) {
425
+ const issuer = normalizeIssuer(config.issuer);
426
+ const clientId = requiredText(config.clientId, 'OIDC client ID');
427
+ const redirectUri = requiredUrl(config.redirectUri, 'OIDC redirect URI');
428
+ const refreshLeewaySeconds = config.refreshLeewaySeconds ?? 30;
429
+ if (!Number.isFinite(refreshLeewaySeconds) || refreshLeewaySeconds < 0) {
430
+ throw new RangeError('OIDC refresh leeway must be a non-negative number.');
431
+ }
432
+ const storageKeyPrefix = config.storageKeyPrefix ?? `@baukit/auth-native:${encodeURIComponent(issuer)}:${clientId}`;
433
+ if (storageKeyPrefix.length === 0) {
434
+ throw new TypeError('OIDC storage key prefix must not be empty.');
435
+ }
436
+ return {
437
+ issuer,
438
+ clientId,
439
+ redirectUri,
440
+ scopes: normalizeScopes(config.scopes, config.offlineAccess),
441
+ postLogoutRedirectUri: requiredUrl(config.postLogoutRedirectUri ?? redirectUri, 'OIDC post-logout redirect URI'),
442
+ refreshLeewayMs: refreshLeewaySeconds * 1000,
443
+ storageKeyPrefix,
444
+ };
445
+ }
446
+ function normalizeScopes(scopes, offlineAccess = false) {
447
+ const requested = scopes ?? ['openid', 'profile', 'email'];
448
+ const normalized = [];
449
+ for (const scope of ['openid', ...requested, ...(offlineAccess ? ['offline_access'] : [])]) {
450
+ const trimmed = scope.trim();
451
+ if (trimmed.length === 0 || /\s/u.test(trimmed)) {
452
+ throw new TypeError('OIDC scopes must be non-empty and contain no whitespace.');
453
+ }
454
+ if (!normalized.includes(trimmed)) {
455
+ normalized.push(trimmed);
456
+ }
457
+ }
458
+ return normalized;
459
+ }
460
+ function requiredText(value, label) {
461
+ const trimmed = value.trim();
462
+ if (trimmed.length === 0) {
463
+ throw new TypeError(`${label} must not be empty.`);
464
+ }
465
+ return trimmed;
466
+ }
467
+ function requiredUrl(value, label) {
468
+ const trimmed = requiredText(value, label);
469
+ try {
470
+ return new URL(trimmed).toString();
471
+ }
472
+ catch {
473
+ throw new TypeError(`${label} must be an absolute URL.`);
474
+ }
475
+ }
476
+ function makeSession(tokens, subject, previous) {
477
+ const refreshToken = tokens.refresh_token ?? previous?.refreshToken;
478
+ const idToken = tokens.id_token ?? previous?.idToken;
479
+ return Object.freeze({
480
+ subject,
481
+ accessToken: tokens.access_token,
482
+ expiresAt: tokens.receivedAt + tokens.expires_in * 1000,
483
+ ...(refreshToken === undefined ? {} : { refreshToken }),
484
+ ...(idToken === undefined ? {} : { idToken }),
485
+ });
486
+ }
487
+ async function readProviderError(response) {
488
+ try {
489
+ const value = await response.json();
490
+ return isObject(value) && typeof value['error'] === 'string' ? value['error'] : undefined;
491
+ }
492
+ catch {
493
+ return undefined;
494
+ }
495
+ }
496
+ function isTerminalRefreshRejection(status, providerError) {
497
+ return (status === 400 ||
498
+ status === 401 ||
499
+ providerError === 'invalid_grant' ||
500
+ providerError === 'invalid_token');
501
+ }
502
+ function isTerminalRefreshError(cause) {
503
+ return cause instanceof OidcError && cause.code === 'refresh_failed' && !cause.retryable;
504
+ }
505
+ function transientRefreshError(cause) {
506
+ if (cause instanceof OidcError && cause.code === 'refresh_failed' && cause.retryable) {
507
+ return cause;
508
+ }
509
+ return new OidcError('refresh_failed', {
510
+ retryable: true,
511
+ ...(cause instanceof OidcError && cause.status !== undefined ? { status: cause.status } : {}),
512
+ });
513
+ }
514
+ function parseSession(raw) {
515
+ if (raw === null) {
516
+ return undefined;
517
+ }
518
+ try {
519
+ const value = JSON.parse(raw);
520
+ if (isSession(value)) {
521
+ return Object.freeze({ ...value });
522
+ }
523
+ }
524
+ catch {
525
+ // Corrupt state is discarded by the caller without reflecting its content.
526
+ }
527
+ return undefined;
528
+ }
529
+ function isSession(value) {
530
+ return (isObject(value) &&
531
+ typeof value['subject'] === 'string' &&
532
+ value['subject'].length > 0 &&
533
+ typeof value['accessToken'] === 'string' &&
534
+ value['accessToken'].length > 0 &&
535
+ typeof value['expiresAt'] === 'number' &&
536
+ Number.isFinite(value['expiresAt']) &&
537
+ (value['refreshToken'] === undefined ||
538
+ (typeof value['refreshToken'] === 'string' && value['refreshToken'].length > 0)) &&
539
+ (value['idToken'] === undefined ||
540
+ (typeof value['idToken'] === 'string' && value['idToken'].length > 0)));
541
+ }
542
+ function isTokenResponse(value) {
543
+ return (isObject(value) &&
544
+ typeof value['access_token'] === 'string' &&
545
+ value['access_token'].length > 0 &&
546
+ typeof value['expires_in'] === 'number' &&
547
+ Number.isFinite(value['expires_in']) &&
548
+ value['expires_in'] > 0 &&
549
+ (value['refresh_token'] === undefined ||
550
+ (typeof value['refresh_token'] === 'string' && value['refresh_token'].length > 0)) &&
551
+ (value['id_token'] === undefined ||
552
+ (typeof value['id_token'] === 'string' && value['id_token'].length > 0)));
553
+ }
554
+ function isProviderMetadata(value) {
555
+ if (!isObject(value) ||
556
+ typeof value['issuer'] !== 'string' ||
557
+ typeof value['authorization_endpoint'] !== 'string' ||
558
+ typeof value['token_endpoint'] !== 'string' ||
559
+ typeof value['userinfo_endpoint'] !== 'string' ||
560
+ (value['end_session_endpoint'] !== undefined &&
561
+ typeof value['end_session_endpoint'] !== 'string')) {
562
+ return false;
563
+ }
564
+ try {
565
+ normalizeIssuer(value['issuer']);
566
+ requiredUrl(value['authorization_endpoint'], 'OIDC authorization endpoint');
567
+ requiredUrl(value['token_endpoint'], 'OIDC token endpoint');
568
+ requiredUrl(value['userinfo_endpoint'], 'OIDC UserInfo endpoint');
569
+ if (value['end_session_endpoint'] !== undefined) {
570
+ requiredUrl(value['end_session_endpoint'], 'OIDC end-session endpoint');
571
+ }
572
+ return true;
573
+ }
574
+ catch {
575
+ return false;
576
+ }
577
+ }
578
+ function isObject(value) {
579
+ return typeof value === 'object' && value !== null;
580
+ }
581
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,MAAM,mBAAmB,GAAG;IAC1B,oBAAoB,EAAE,4BAA4B;IAClD,uBAAuB,EAAE,0DAA0D;IACnF,gBAAgB,EAAE,iCAAiC;IACnD,0BAA0B,EAAE,oDAAoD;IAChF,sBAAsB,EAAE,mDAAmD;IAC3E,yBAAyB,EAAE,sDAAsD;IACjF,eAAe,EAAE,2DAA2D;IAC5E,qBAAqB,EAAE,6CAA6C;IACpE,cAAc,EAAE,4BAA4B;IAC5C,cAAc,EAAE,uCAAuC;IACvD,qBAAqB,EAAE,6BAA6B;IACpD,eAAe,EAAE,+BAA+B;CACA,CAAC;AAEnD,yEAAyE;AACzE,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClB,IAAI,CAAgB;IACpB,MAAM,CAAqB;IAC3C,yFAAyF;IACzE,SAAS,CAAU;IAEnC,YACE,IAAmB,EACnB,UAAsE,EAAE;QAExE,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,KAAK,CAAC;IAC9C,CAAC;CACF;AAiID,iFAAiF;AACjF,MAAM,OAAO,gBAAgB;IACV,MAAM,CAAmB;IACzB,WAAW,CAAwB;IACnC,iBAAiB,CAAS;IAC1B,oBAAoB,CAAS;IAC7B,SAAS,GAAG,IAAI,GAAG,EAAmB,CAAC;IACvC,uBAAuB,GAAG,IAAI,GAAG,EAA0B,CAAC;IACrE,cAAc,CAA0B;IACxC,WAAW,G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AAC,sBAAsB,CAAC,EAAE,2BAA2B,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@baukit/auth-native",
3
+ "version": "0.1.0",
4
+ "description": "Provider-neutral native OIDC authorization-code client with S256 PKCE, secure-storage and browser-flow ports, and refresh rotation.",
5
+ "license": "MIT",
6
+ "author": "Patrick Koss",
7
+ "homepage": "https://github.com/PatrickKoss/baukit#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/PatrickKoss/baukit.git",
11
+ "directory": "typescript/packages/auth-native"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/PatrickKoss/baukit/issues"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "type": "module",
20
+ "engines": {
21
+ "node": ">=24.0.0"
22
+ },
23
+ "types": "./dist/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js"
28
+ },
29
+ "./expo": {
30
+ "types": "./dist/expo.d.ts",
31
+ "import": "./dist/expo.js"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "README.md",
37
+ "LICENSE"
38
+ ],
39
+ "devDependencies": {
40
+ "expo-auth-session": "57.0.6",
41
+ "expo-secure-store": "57.0.1",
42
+ "expo-web-browser": "57.0.2",
43
+ "typescript": "6.0.3"
44
+ },
45
+ "peerDependencies": {
46
+ "expo-auth-session": "^57.0.6",
47
+ "expo-secure-store": "^57.0.1",
48
+ "expo-web-browser": "^57.0.2"
49
+ },
50
+ "scripts": {
51
+ "build": "tsc -p tsconfig.json",
52
+ "test": "vitest run --config ../../vitest.config.ts",
53
+ "lint": "eslint src --max-warnings=0",
54
+ "format:check": "prettier --check src package.json tsconfig.json"
55
+ }
56
+ }