@authowl/core 0.11.0 → 0.12.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/README.md +4 -0
- package/dist/chunk-M4QJVSXT.js +1 -0
- package/dist/chunk-SM5LS47O.js +1 -0
- package/dist/client-1cjryEHU.d.cts +1294 -0
- package/dist/client-CzV2XWt6.d.ts +1294 -0
- package/dist/index-hIdXOzRp.d.cts +15 -0
- package/dist/index-hIdXOzRp.d.ts +15 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +5 -1263
- package/dist/index.d.ts +5 -1263
- package/dist/index.js +3 -3
- package/dist/messages.cjs +1 -0
- package/dist/messages.d.cts +473 -0
- package/dist/messages.d.ts +473 -0
- package/dist/messages.js +1 -0
- package/dist/native.cjs +1 -0
- package/dist/native.d.cts +149 -0
- package/dist/native.d.ts +149 -0
- package/dist/native.js +1 -0
- package/dist/{transport-BObDKlIh.d.cts → organization-membership-B3m6PbmO.d.cts} +1 -15
- package/dist/{transport-BObDKlIh.d.ts → organization-membership-B3m6PbmO.d.ts} +1 -15
- package/dist/server.d.cts +3 -2
- package/dist/server.d.ts +3 -2
- package/dist/transport-DcWDTRd4.d.cts +15 -0
- package/dist/transport-DcWDTRd4.d.ts +15 -0
- package/package.json +22 -2
package/dist/native.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { R as ResolvedAuthConfig, A as AuthConfig } from './organization-membership-B3m6PbmO.js';
|
|
2
|
+
export { D as DecodedPublishableKey, H as HasParams, O as OrganizationMembership, c as createMembershipHas, d as decodePublishableKey, r as resolveConfig, s as sessionCookieName } from './organization-membership-B3m6PbmO.js';
|
|
3
|
+
import { j as AuthOwlClient, aJ as SocialIdTokenOptions, bb as createAuthHttpClient, bc as AuthHttpClient, aj as PasskeySignInOptions, e as ActionFetchOptions, g as AuthActionResult, ai as PasskeyAuthData, f as AddPasskeyOptions, l as AuthPasskey } from './client-CzV2XWt6.js';
|
|
4
|
+
export { h as AuthClientError, o as AuthSession, p as AuthUser, a2 as Organization, a3 as OrganizationClient, a4 as OrganizationDetails, aq as ProjectCapabilities, ar as PublicConfig, aC as SessionState, aD as SessionStore, aE as SetActiveOrganizationOptions, aI as SocialAuthData, b9 as getPublicConfig, ba as resolveProjectCapabilities } from './client-CzV2XWt6.js';
|
|
5
|
+
import { startAuthentication, startRegistration } from '@simplewebauthn/browser';
|
|
6
|
+
|
|
7
|
+
type AuthActionClient = Omit<AuthOwlClient, 'getToken' | 'getConsentStatus' | 'acceptConsent' | 'waitlist'>;
|
|
8
|
+
/** Native social sign-in uses an ID token obtained from the provider SDK. */
|
|
9
|
+
interface NativeSocialSignInOptions {
|
|
10
|
+
provider: string;
|
|
11
|
+
idToken: SocialIdTokenOptions;
|
|
12
|
+
requestSignUp?: boolean;
|
|
13
|
+
}
|
|
14
|
+
type NativeSignInClient = Omit<AuthActionClient['signIn'], 'social' | 'sso' | 'passkey'> & {
|
|
15
|
+
social(params: NativeSocialSignInOptions, fetchOptions?: Parameters<AuthActionClient['signIn']['social']>[1]): ReturnType<AuthActionClient['signIn']['social']>;
|
|
16
|
+
};
|
|
17
|
+
type NativePasskeyClient = Omit<AuthActionClient['passkey'], 'addPasskey'>;
|
|
18
|
+
interface PasskeyCeremonyClient {
|
|
19
|
+
signIn: AuthActionClient['signIn']['passkey'];
|
|
20
|
+
add: AuthActionClient['passkey']['addPasskey'];
|
|
21
|
+
}
|
|
22
|
+
type PasskeyCeremonyClientFactory = (http: ReturnType<typeof createAuthHttpClient>, sessionChanged: () => void) => PasskeyCeremonyClient;
|
|
23
|
+
/**
|
|
24
|
+
* Auth actions that can execute without browser navigation or WebAuthn.
|
|
25
|
+
*
|
|
26
|
+
* Social sign-in requires a provider ID token. Redirect OAuth, enterprise SSO,
|
|
27
|
+
* passkey sign-in, and passkey registration need browser state or WebAuthn and
|
|
28
|
+
* are deliberately absent from the native surface.
|
|
29
|
+
*/
|
|
30
|
+
type NativeAuthClient = Omit<AuthActionClient, 'signIn' | 'passkey'> & {
|
|
31
|
+
signIn: NativeSignInClient;
|
|
32
|
+
passkey: NativePasskeyClient;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A native client whose host supplied a platform passkey ceremony.
|
|
36
|
+
*
|
|
37
|
+
* The passkey methods appear in the TYPE only when an adapter is passed, so an
|
|
38
|
+
* app without one cannot call a ceremony that would fail at runtime.
|
|
39
|
+
*/
|
|
40
|
+
type NativePasskeyCapableClient = Omit<NativeAuthClient, 'passkey' | 'signIn'> & {
|
|
41
|
+
passkey: NativePasskeyClient & Pick<AuthActionClient['passkey'], 'addPasskey'>;
|
|
42
|
+
signIn: NativeSignInClient & Pick<AuthActionClient['signIn'], 'passkey'>;
|
|
43
|
+
};
|
|
44
|
+
/** Build the runtime-native subset without leaving browser-only methods reachable. */
|
|
45
|
+
declare function createNativeAuthClient(config: ResolvedAuthConfig, onSessionMutation?: () => void): NativeAuthClient;
|
|
46
|
+
declare function createNativeAuthClient(config: ResolvedAuthConfig, onSessionMutation: (() => void) | undefined, createPasskeys: PasskeyCeremonyClientFactory): NativePasskeyCapableClient;
|
|
47
|
+
|
|
48
|
+
type AuthenticationOptions = Parameters<typeof startAuthentication>[0]['optionsJSON'];
|
|
49
|
+
type RegistrationOptions = Parameters<typeof startRegistration>[0]['optionsJSON'];
|
|
50
|
+
declare function decodeAuthenticationOptions(value: unknown): AuthenticationOptions;
|
|
51
|
+
declare function decodeRegistrationOptions(value: unknown): RegistrationOptions;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The two ceremony responses, as the server expects to receive them.
|
|
55
|
+
*
|
|
56
|
+
* Kept distinct: an assertion carries `authenticatorData`, an attestation
|
|
57
|
+
* carries `attestationObject`, and collapsing them into one type would let a
|
|
58
|
+
* registration response be posted to the authentication endpoint.
|
|
59
|
+
*/
|
|
60
|
+
type PasskeyRegistrationResponse = {
|
|
61
|
+
id: string;
|
|
62
|
+
rawId: string;
|
|
63
|
+
type: 'public-key';
|
|
64
|
+
response: {
|
|
65
|
+
clientDataJSON: string;
|
|
66
|
+
attestationObject: string;
|
|
67
|
+
transports?: string[];
|
|
68
|
+
publicKeyAlgorithm?: number;
|
|
69
|
+
publicKey?: string;
|
|
70
|
+
};
|
|
71
|
+
clientExtensionResults?: unknown;
|
|
72
|
+
authenticatorAttachment?: string;
|
|
73
|
+
};
|
|
74
|
+
type PasskeyAuthenticationResponse = {
|
|
75
|
+
id: string;
|
|
76
|
+
rawId: string;
|
|
77
|
+
type: 'public-key';
|
|
78
|
+
response: {
|
|
79
|
+
clientDataJSON: string;
|
|
80
|
+
authenticatorData: string;
|
|
81
|
+
signature: string;
|
|
82
|
+
userHandle?: string;
|
|
83
|
+
};
|
|
84
|
+
clientExtensionResults?: unknown;
|
|
85
|
+
authenticatorAttachment?: string;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Runs the platform's WebAuthn ceremonies.
|
|
89
|
+
*
|
|
90
|
+
* Injected so a non-browser runtime can supply its own. React Native has no
|
|
91
|
+
* `navigator.credentials`, but it does have platform passkey APIs
|
|
92
|
+
* (`ASAuthorization` on iOS, Credential Manager on Android) whose libraries
|
|
93
|
+
* speak the same WebAuthn JSON. Parameterizing only the ceremony lets those
|
|
94
|
+
* runtimes reuse every line of option decoding, response projection, and
|
|
95
|
+
* in-flight de-duplication below, instead of reimplementing the protocol.
|
|
96
|
+
*/
|
|
97
|
+
interface PasskeyCeremony {
|
|
98
|
+
authenticate(input: {
|
|
99
|
+
optionsJSON: ReturnType<typeof decodeAuthenticationOptions>;
|
|
100
|
+
useBrowserAutofill?: boolean;
|
|
101
|
+
}): Promise<PasskeyAuthenticationResponse>;
|
|
102
|
+
register(input: {
|
|
103
|
+
optionsJSON: ReturnType<typeof decodeRegistrationOptions>;
|
|
104
|
+
}): Promise<PasskeyRegistrationResponse>;
|
|
105
|
+
/**
|
|
106
|
+
* Classify a ceremony failure, returning the platform's error code.
|
|
107
|
+
*
|
|
108
|
+
* Supplied by the ceremony because only it knows its own error type. The
|
|
109
|
+
* browser implementation tests `instanceof WebAuthnError`; doing that here
|
|
110
|
+
* would require importing the browser helper into this module, and a
|
|
111
|
+
* structural stand-in cannot work - a real WebAuthnError takes its `name`
|
|
112
|
+
* from the underlying cause, not from the class.
|
|
113
|
+
*/
|
|
114
|
+
errorCode?(error: unknown): string | undefined;
|
|
115
|
+
}
|
|
116
|
+
declare function createPasskeyClient(http: AuthHttpClient, sessionChanged: () => void, ceremony: PasskeyCeremony): {
|
|
117
|
+
signIn(options?: PasskeySignInOptions, fetchOptions?: ActionFetchOptions): Promise<AuthActionResult<PasskeyAuthData>>;
|
|
118
|
+
add(options?: AddPasskeyOptions, fetchOptions?: ActionFetchOptions): Promise<AuthActionResult<AuthPasskey>>;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Native (React Native / Expo) entry point.
|
|
123
|
+
*
|
|
124
|
+
* The browser client relies on the browser's cookie jar, `BroadcastChannel`, and
|
|
125
|
+
* `window.location` redirects - none of which exist on a phone. This entry
|
|
126
|
+
* exposes the native-safe auth surface built on `createNativeAuthClient`, which
|
|
127
|
+
* drops browser navigation and WebAuthn ceremonies, and leaves session storage
|
|
128
|
+
* to the caller:
|
|
129
|
+
*
|
|
130
|
+
* 1. WHERE the session lives. Pass a `fetch` that persists and replays the
|
|
131
|
+
* session cookie from secure storage (`@authowl/react-native` supplies one).
|
|
132
|
+
*
|
|
133
|
+
* Social providers are supported through ID tokens obtained from their native
|
|
134
|
+
* SDKs. Redirect OAuth cannot share state cookies with this client-side jar.
|
|
135
|
+
*
|
|
136
|
+
* Kept separate from `./index` so a React Native bundler never pulls the
|
|
137
|
+
* browser-only modules into an app that cannot use them.
|
|
138
|
+
*/
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Build a native auth client from a publishable key and API URL.
|
|
142
|
+
*
|
|
143
|
+
* `config.fetch` is the seam a native app must use to persist its session:
|
|
144
|
+
* without one, requests fall back to whatever cookie behaviour the platform's
|
|
145
|
+
* `fetch` happens to have, which does not survive an app restart.
|
|
146
|
+
*/
|
|
147
|
+
declare function createNativeClient(config: AuthConfig, onSessionMutation?: () => void): NativeAuthClient;
|
|
148
|
+
|
|
149
|
+
export { AddPasskeyOptions, AuthActionResult, AuthConfig, AuthOwlClient, AuthPasskey, type NativeAuthClient, type NativePasskeyCapableClient, type NativeSocialSignInOptions, PasskeyAuthData, type PasskeyAuthenticationResponse, type PasskeyCeremony, type PasskeyCeremonyClientFactory, type PasskeyRegistrationResponse, ResolvedAuthConfig, SocialIdTokenOptions, createNativeAuthClient, createNativeClient, createPasskeyClient };
|
package/dist/native.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {f}from'./chunk-SM5LS47O.js';export{f as createNativeAuthClient,g as createPasskeyClient,k as getPublicConfig,a as resolveProjectCapabilities}from'./chunk-SM5LS47O.js';import {e}from'./chunk-KPXCQZUX.js';export{v as createMembershipHas,a as decodePublishableKey,e as resolveConfig,b as sessionCookieName}from'./chunk-KPXCQZUX.js';function u(i,o){return f(e(i),o)}export{u as createNativeClient};
|
|
@@ -114,18 +114,4 @@ declare function createMembershipHas(membership: OrganizationMembership | null |
|
|
|
114
114
|
}) => boolean;
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
type
|
|
118
|
-
/**
|
|
119
|
-
* Stable, secret-safe failure from the shared HTTP boundary.
|
|
120
|
-
*
|
|
121
|
-
* Deliberately does not retain the request URL, headers, body, or underlying
|
|
122
|
-
* error. Server clients may carry secret authorization headers and hostile
|
|
123
|
-
* fetch implementations may echo those values in their error messages.
|
|
124
|
-
*/
|
|
125
|
-
declare class TransportError extends Error {
|
|
126
|
-
readonly kind: TransportErrorKind;
|
|
127
|
-
readonly requestId?: string;
|
|
128
|
-
constructor(kind: TransportErrorKind, requestId?: string);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export { type AuthConfig as A, type DecodedPublishableKey as D, type HasParams as H, type OrganizationMembership as O, type ResolvedAuthConfig as R, TransportError as T, type TransportErrorKind as a, membershipHasPermission as b, createMembershipHas as c, decodePublishableKey as d, membershipHasTeam as e, membershipHas as m, resolveConfig as r, sessionCookieName as s };
|
|
117
|
+
export { type AuthConfig as A, type DecodedPublishableKey as D, type HasParams as H, type OrganizationMembership as O, type ResolvedAuthConfig as R, membershipHasPermission as a, membershipHasTeam as b, createMembershipHas as c, decodePublishableKey as d, membershipHas as m, resolveConfig as r, sessionCookieName as s };
|
|
@@ -114,18 +114,4 @@ declare function createMembershipHas(membership: OrganizationMembership | null |
|
|
|
114
114
|
}) => boolean;
|
|
115
115
|
};
|
|
116
116
|
|
|
117
|
-
type
|
|
118
|
-
/**
|
|
119
|
-
* Stable, secret-safe failure from the shared HTTP boundary.
|
|
120
|
-
*
|
|
121
|
-
* Deliberately does not retain the request URL, headers, body, or underlying
|
|
122
|
-
* error. Server clients may carry secret authorization headers and hostile
|
|
123
|
-
* fetch implementations may echo those values in their error messages.
|
|
124
|
-
*/
|
|
125
|
-
declare class TransportError extends Error {
|
|
126
|
-
readonly kind: TransportErrorKind;
|
|
127
|
-
readonly requestId?: string;
|
|
128
|
-
constructor(kind: TransportErrorKind, requestId?: string);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export { type AuthConfig as A, type DecodedPublishableKey as D, type HasParams as H, type OrganizationMembership as O, type ResolvedAuthConfig as R, TransportError as T, type TransportErrorKind as a, membershipHasPermission as b, createMembershipHas as c, decodePublishableKey as d, membershipHasTeam as e, membershipHas as m, resolveConfig as r, sessionCookieName as s };
|
|
117
|
+
export { type AuthConfig as A, type DecodedPublishableKey as D, type HasParams as H, type OrganizationMembership as O, type ResolvedAuthConfig as R, membershipHasPermission as a, membershipHasTeam as b, createMembershipHas as c, decodePublishableKey as d, membershipHas as m, resolveConfig as r, sessionCookieName as s };
|
package/dist/server.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { O as OrganizationMembership,
|
|
2
|
-
export { A as AuthConfig, R as ResolvedAuthConfig, r as resolveConfig, s as sessionCookieName } from './
|
|
1
|
+
import { O as OrganizationMembership, H as HasParams } from './organization-membership-B3m6PbmO.cjs';
|
|
2
|
+
export { A as AuthConfig, R as ResolvedAuthConfig, r as resolveConfig, s as sessionCookieName } from './organization-membership-B3m6PbmO.cjs';
|
|
3
|
+
import { a as TransportErrorKind } from './transport-DcWDTRd4.cjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Stateless verification of an AuthOwl project JWT for SERVER-side authorization
|
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { O as OrganizationMembership,
|
|
2
|
-
export { A as AuthConfig, R as ResolvedAuthConfig, r as resolveConfig, s as sessionCookieName } from './
|
|
1
|
+
import { O as OrganizationMembership, H as HasParams } from './organization-membership-B3m6PbmO.js';
|
|
2
|
+
export { A as AuthConfig, R as ResolvedAuthConfig, r as resolveConfig, s as sessionCookieName } from './organization-membership-B3m6PbmO.js';
|
|
3
|
+
import { a as TransportErrorKind } from './transport-DcWDTRd4.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Stateless verification of an AuthOwl project JWT for SERVER-side authorization
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type TransportErrorKind = 'aborted' | 'timeout' | 'network' | 'response_too_large' | 'invalid_response';
|
|
2
|
+
/**
|
|
3
|
+
* Stable, secret-safe failure from the shared HTTP boundary.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately does not retain the request URL, headers, body, or underlying
|
|
6
|
+
* error. Server clients may carry secret authorization headers and hostile
|
|
7
|
+
* fetch implementations may echo those values in their error messages.
|
|
8
|
+
*/
|
|
9
|
+
declare class TransportError extends Error {
|
|
10
|
+
readonly kind: TransportErrorKind;
|
|
11
|
+
readonly requestId?: string;
|
|
12
|
+
constructor(kind: TransportErrorKind, requestId?: string);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { TransportError as T, type TransportErrorKind as a };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type TransportErrorKind = 'aborted' | 'timeout' | 'network' | 'response_too_large' | 'invalid_response';
|
|
2
|
+
/**
|
|
3
|
+
* Stable, secret-safe failure from the shared HTTP boundary.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately does not retain the request URL, headers, body, or underlying
|
|
6
|
+
* error. Server clients may carry secret authorization headers and hostile
|
|
7
|
+
* fetch implementations may echo those values in their error messages.
|
|
8
|
+
*/
|
|
9
|
+
declare class TransportError extends Error {
|
|
10
|
+
readonly kind: TransportErrorKind;
|
|
11
|
+
readonly requestId?: string;
|
|
12
|
+
constructor(kind: TransportErrorKind, requestId?: string);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { TransportError as T, type TransportErrorKind as a };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@authowl/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Framework-agnostic client for AuthOwl, the multi-tenant auth SaaS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -42,6 +42,26 @@
|
|
|
42
42
|
"types": "./dist/server.d.cts",
|
|
43
43
|
"default": "./dist/server.cjs"
|
|
44
44
|
}
|
|
45
|
+
},
|
|
46
|
+
"./native": {
|
|
47
|
+
"import": {
|
|
48
|
+
"types": "./dist/native.d.ts",
|
|
49
|
+
"default": "./dist/native.js"
|
|
50
|
+
},
|
|
51
|
+
"require": {
|
|
52
|
+
"types": "./dist/native.d.cts",
|
|
53
|
+
"default": "./dist/native.cjs"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"./i18n": {
|
|
57
|
+
"import": {
|
|
58
|
+
"types": "./dist/messages.d.ts",
|
|
59
|
+
"default": "./dist/messages.js"
|
|
60
|
+
},
|
|
61
|
+
"require": {
|
|
62
|
+
"types": "./dist/messages.d.cts",
|
|
63
|
+
"default": "./dist/messages.cjs"
|
|
64
|
+
}
|
|
45
65
|
}
|
|
46
66
|
},
|
|
47
67
|
"main": "./dist/index.cjs",
|
|
@@ -58,7 +78,7 @@
|
|
|
58
78
|
"vitest": "^4.1.10"
|
|
59
79
|
},
|
|
60
80
|
"scripts": {
|
|
61
|
-
"build": "tsup && node ../../scripts/gen-notices.mjs src/index.ts src/server.ts",
|
|
81
|
+
"build": "tsup && node ../../scripts/gen-notices.mjs src/index.ts src/server.ts src/native.ts src/messages.ts",
|
|
62
82
|
"dev": "tsup --watch",
|
|
63
83
|
"typecheck": "tsc --noEmit",
|
|
64
84
|
"test": "vitest run --passWithNoTests"
|