@seamless-auth/react 0.12.0 → 0.14.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 +78 -0
- package/README.md +122 -6
- package/dist/AuthProvider.d.ts +33 -5
- package/dist/authRoutePaths.d.ts +21 -0
- package/dist/chunks/shared-BzrBuR0z.js +3 -0
- package/dist/chunks/shared-BzrBuR0z.js.map +1 -0
- package/dist/components/AuthFallbackOptions.d.ts +1 -1
- package/dist/hooks/useAuthClient.d.ts +6 -1
- package/dist/hooks/useAuthorizedFetch.d.ts +6 -0
- package/dist/hooks/useLoginMethods.d.ts +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/routes.d.ts +1 -21
- package/dist/routes.js +3 -0
- package/dist/routes.js.map +1 -0
- package/package.json +18 -65
- package/LICENSE.md +0 -26
- package/dist/client/createSeamlessAuthClient.d.ts +0 -189
- package/dist/client/errors.d.ts +0 -90
- package/dist/client/result.d.ts +0 -36
- package/dist/client/webauthnPrf.d.ts +0 -27
- package/dist/client/webauthnSupport.d.ts +0 -10
- package/dist/fetchWithAuth.d.ts +0 -5
- package/dist/scopedRoles.d.ts +0 -2
- package/dist/session/createAuthSession.d.ts +0 -61
- package/dist/session/storage.d.ts +0 -17
- package/dist/types.d.ts +0 -5
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import type { AddOrganizationMemberRequest, AuthenticatorAttachmentPolicy, CreateOrganizationRequest, CredentialUpdateResponse, LoginMethod as LoginMethodShape, LoginSuccessResponse, LogoutScope as LogoutScopeShape, MeResponse, MessageResponse, OAuthLoginSuccessResponse, OAuthProvidersResponse, OrganizationEnvelopeResponse, OrganizationListResponse, OrganizationMembersResponse, OrganizationMembershipEnvelopeResponse, OrganizationSwitchResponse, PublicOAuthProvider, PublicSystemConfigResponse, RegistrationRequest, StartOAuthLoginResponse, StepUpMethod as StepUpMethodShape, StepUpStatus as StepUpStatusShape, TotpEnrollmentStartResponse, TotpStatus as TotpStatusShape, UpdateOrganizationMemberRequest, UpdateOrganizationRequest } from '@seamless-auth/types';
|
|
2
|
-
import { type SeamlessAuthResult } from './result';
|
|
3
|
-
import { PasskeyPrfInput, PasskeyPrfResult } from './webauthnPrf';
|
|
4
|
-
export interface SeamlessAuthClientOptions {
|
|
5
|
-
apiHost: string;
|
|
6
|
-
/**
|
|
7
|
-
* Default destination for `requestMagicLink()`. Every send from this client
|
|
8
|
-
* uses it unless a call passes its own, which keeps a resend on the same
|
|
9
|
-
* destination as the send it repeats. Omit it to keep the deployment's.
|
|
10
|
-
*/
|
|
11
|
-
magicLinkRedirectUri?: string;
|
|
12
|
-
}
|
|
13
|
-
export interface LoginInput {
|
|
14
|
-
identifier: string;
|
|
15
|
-
passkeyAvailable: boolean;
|
|
16
|
-
}
|
|
17
|
-
export type LoginMethod = LoginMethodShape;
|
|
18
|
-
/**
|
|
19
|
-
* The login response minus its session material. The API returns a token and
|
|
20
|
-
* subject here, which this SDK deliberately does not surface: sessions are
|
|
21
|
-
* carried by cookies, so adopters have no reason to handle raw tokens.
|
|
22
|
-
*/
|
|
23
|
-
export type LoginStartResult = Omit<LoginSuccessResponse, 'token' | 'sub'>;
|
|
24
|
-
export type RegisterInput = RegistrationRequest;
|
|
25
|
-
export interface PasskeyMetadata {
|
|
26
|
-
friendlyName: string;
|
|
27
|
-
platform: string;
|
|
28
|
-
browser: string;
|
|
29
|
-
deviceInfo: string;
|
|
30
|
-
}
|
|
31
|
-
export type CurrentUserResult = MeResponse;
|
|
32
|
-
export type CreateOrganizationInput = CreateOrganizationRequest;
|
|
33
|
-
export type UpdateOrganizationInput = UpdateOrganizationRequest;
|
|
34
|
-
export type OrganizationMemberInput = AddOrganizationMemberRequest;
|
|
35
|
-
export type OrganizationMemberUpdateInput = UpdateOrganizationMemberRequest;
|
|
36
|
-
export type OrganizationsResult = OrganizationListResponse;
|
|
37
|
-
export type OrganizationResult = OrganizationEnvelopeResponse;
|
|
38
|
-
export type OrganizationMembersResult = OrganizationMembersResponse;
|
|
39
|
-
/** Response body for a single membership mutation. */
|
|
40
|
-
export type OrganizationMembershipResult = OrganizationMembershipEnvelopeResponse;
|
|
41
|
-
/**
|
|
42
|
-
* Response body when the active organization changes, minus its session
|
|
43
|
-
* material. See `LoginStartResult` for why the token and subject are dropped.
|
|
44
|
-
*/
|
|
45
|
-
export type OrganizationSwitchResult = Omit<OrganizationSwitchResponse, 'token' | 'sub' | 'sessionId'>;
|
|
46
|
-
export type OAuthProvider = PublicOAuthProvider;
|
|
47
|
-
export type OAuthProvidersResult = OAuthProvidersResponse;
|
|
48
|
-
/**
|
|
49
|
-
* The configuration a signed-out client may read. Fetched before there is a
|
|
50
|
-
* session, so the sign-in screens can match how this instance is configured
|
|
51
|
-
* instead of assuming a default set of methods.
|
|
52
|
-
*/
|
|
53
|
-
export type PublicSystemConfigResult = PublicSystemConfigResponse;
|
|
54
|
-
export interface StartOAuthLoginInput {
|
|
55
|
-
providerId: string;
|
|
56
|
-
redirectUri?: string;
|
|
57
|
-
returnTo?: string;
|
|
58
|
-
}
|
|
59
|
-
export type StartOAuthLoginResult = StartOAuthLoginResponse;
|
|
60
|
-
export interface FinishOAuthLoginInput {
|
|
61
|
-
providerId: string;
|
|
62
|
-
code: string;
|
|
63
|
-
state: string;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* The completed OAuth response minus its session material, for the same reason
|
|
67
|
-
* `LoginStartResult` drops it: sessions are carried by cookies.
|
|
68
|
-
*
|
|
69
|
-
* What this does surface is `returnTo`, the destination the caller asked for when it
|
|
70
|
-
* started the flow. It comes back out of the state the auth server signed, so it is
|
|
71
|
-
* the value that was validated against the configured origins at the start and not
|
|
72
|
-
* one introduced at the callback. Absent when the caller asked for nothing, so treat
|
|
73
|
-
* that as "use my own default" rather than as a failure.
|
|
74
|
-
*/
|
|
75
|
-
export type FinishOAuthLoginResult = Omit<OAuthLoginSuccessResponse, 'token' | 'refreshToken' | 'sub'>;
|
|
76
|
-
/** Response body for endpoints that only acknowledge the request. */
|
|
77
|
-
export type MessageResult = MessageResponse;
|
|
78
|
-
/** Payload returned by a completed passkey login. */
|
|
79
|
-
export interface PasskeyLoginData {
|
|
80
|
-
prf?: PasskeyPrfResult;
|
|
81
|
-
}
|
|
82
|
-
/** Payload returned by a completed passkey registration. */
|
|
83
|
-
export interface PasskeyRegistrationData {
|
|
84
|
-
credentialId: string;
|
|
85
|
-
prfCapable: boolean;
|
|
86
|
-
}
|
|
87
|
-
/** Response body returned when credential metadata is updated. */
|
|
88
|
-
export type CredentialUpdateResult = CredentialUpdateResponse;
|
|
89
|
-
/**
|
|
90
|
-
* Which kind of authenticator to offer at registration. Omitting it leaves the
|
|
91
|
-
* choice to the deployment's `authenticator_policy.attachment`, which offers
|
|
92
|
-
* both kinds by default.
|
|
93
|
-
*
|
|
94
|
-
* Derived from the deployment policy type rather than restating its members:
|
|
95
|
-
* `any` is a standing default a deployment sets, not something a single request
|
|
96
|
-
* can ask for, so the request type is that policy minus that one member.
|
|
97
|
-
*/
|
|
98
|
-
export type PasskeyAttachment = Exclude<AuthenticatorAttachmentPolicy, 'any'>;
|
|
99
|
-
export interface RegisterPasskeyOptions {
|
|
100
|
-
metadata: PasskeyMetadata;
|
|
101
|
-
requestPrf?: boolean;
|
|
102
|
-
requirePrf?: boolean;
|
|
103
|
-
/**
|
|
104
|
-
* Narrows the browser picker to one kind of authenticator, for example
|
|
105
|
-
* `cross-platform` to send a user straight to an issued security key. A
|
|
106
|
-
* deployment that has pinned a different kind refuses this, so it is a
|
|
107
|
-
* request rather than an override.
|
|
108
|
-
*/
|
|
109
|
-
attachment?: PasskeyAttachment;
|
|
110
|
-
}
|
|
111
|
-
export type StepUpMethod = StepUpMethodShape;
|
|
112
|
-
export type TotpStatus = TotpStatusShape;
|
|
113
|
-
export type TotpEnrollmentStartResult = TotpEnrollmentStartResponse;
|
|
114
|
-
export type StepUpStatus = StepUpStatusShape;
|
|
115
|
-
export interface PasskeyLoginOptions {
|
|
116
|
-
prf?: PasskeyPrfInput;
|
|
117
|
-
}
|
|
118
|
-
/** Step-up payload that also carries the PRF output for the caller. */
|
|
119
|
-
export interface StepUpPrfData extends StepUpStatus {
|
|
120
|
-
credentialId: string;
|
|
121
|
-
prf: PasskeyPrfResult;
|
|
122
|
-
}
|
|
123
|
-
export type LogoutScope = LogoutScopeShape;
|
|
124
|
-
export interface LogoutOptions {
|
|
125
|
-
scope?: LogoutScope;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Headless auth client.
|
|
129
|
-
*
|
|
130
|
-
* Every request resolves to a `SeamlessAuthResult`: check `error` first, then
|
|
131
|
-
* read `data`. Nothing here throws for an HTTP or transport failure.
|
|
132
|
-
* `isPasskeyPrfSupported` is the one exception, since it is a local capability
|
|
133
|
-
* check rather than a request.
|
|
134
|
-
*/
|
|
135
|
-
export interface SeamlessAuthClient {
|
|
136
|
-
getCurrentUser: () => Promise<SeamlessAuthResult<CurrentUserResult>>;
|
|
137
|
-
login: (input: LoginInput) => Promise<SeamlessAuthResult<LoginStartResult>>;
|
|
138
|
-
loginWithPasskey: (options?: PasskeyLoginOptions) => Promise<SeamlessAuthResult<PasskeyLoginData>>;
|
|
139
|
-
logout: (options?: LogoutOptions) => Promise<SeamlessAuthResult<MessageResult>>;
|
|
140
|
-
logoutAllSessions: () => Promise<SeamlessAuthResult<MessageResult>>;
|
|
141
|
-
deleteUser: () => Promise<SeamlessAuthResult<MessageResult>>;
|
|
142
|
-
register: (input: RegisterInput) => Promise<SeamlessAuthResult<MessageResult>>;
|
|
143
|
-
requestPhoneOtp: () => Promise<SeamlessAuthResult<MessageResult>>;
|
|
144
|
-
verifyPhoneOtp: (verificationToken: string) => Promise<SeamlessAuthResult<MessageResult>>;
|
|
145
|
-
requestLoginPhoneOtp: () => Promise<SeamlessAuthResult<MessageResult>>;
|
|
146
|
-
verifyLoginPhoneOtp: (verificationToken: string) => Promise<SeamlessAuthResult<MessageResult>>;
|
|
147
|
-
requestEmailOtp: () => Promise<SeamlessAuthResult<MessageResult>>;
|
|
148
|
-
verifyEmailOtp: (verificationToken: string) => Promise<SeamlessAuthResult<MessageResult>>;
|
|
149
|
-
requestLoginEmailOtp: () => Promise<SeamlessAuthResult<MessageResult>>;
|
|
150
|
-
verifyLoginEmailOtp: (verificationToken: string) => Promise<SeamlessAuthResult<MessageResult>>;
|
|
151
|
-
/**
|
|
152
|
-
* @param redirectUri Where the emailed link should land. The deployment validates
|
|
153
|
-
* it against its configured origins and refuses anything else, so a tenant serving
|
|
154
|
-
* a web app and a mobile app can send each to its own destination. Omit it to fall
|
|
155
|
-
* back to the client's `magicLinkRedirectUri`, then to the deployment's own.
|
|
156
|
-
*/
|
|
157
|
-
requestMagicLink: (redirectUri?: string) => Promise<SeamlessAuthResult<MessageResult>>;
|
|
158
|
-
checkMagicLink: () => Promise<SeamlessAuthResult<MessageResult>>;
|
|
159
|
-
verifyMagicLink: (token: string) => Promise<SeamlessAuthResult<MessageResult>>;
|
|
160
|
-
listOAuthProviders: () => Promise<SeamlessAuthResult<OAuthProvidersResult>>;
|
|
161
|
-
getPublicSystemConfig: () => Promise<SeamlessAuthResult<PublicSystemConfigResult>>;
|
|
162
|
-
startOAuthLogin: (input: StartOAuthLoginInput) => Promise<SeamlessAuthResult<StartOAuthLoginResult>>;
|
|
163
|
-
finishOAuthLogin: (input: FinishOAuthLoginInput) => Promise<SeamlessAuthResult<FinishOAuthLoginResult>>;
|
|
164
|
-
registerPasskey: (input: PasskeyMetadata | RegisterPasskeyOptions) => Promise<SeamlessAuthResult<PasskeyRegistrationData>>;
|
|
165
|
-
isPasskeyPrfSupported: () => Promise<boolean>;
|
|
166
|
-
getStepUpStatus: () => Promise<SeamlessAuthResult<StepUpStatus>>;
|
|
167
|
-
verifyStepUpWithPasskey: () => Promise<SeamlessAuthResult<StepUpStatus>>;
|
|
168
|
-
verifyStepUpWithPasskeyPrf: (input: PasskeyPrfInput) => Promise<SeamlessAuthResult<StepUpPrfData>>;
|
|
169
|
-
getTotpStatus: () => Promise<SeamlessAuthResult<TotpStatus>>;
|
|
170
|
-
startTotpEnrollment: () => Promise<SeamlessAuthResult<TotpEnrollmentStartResult>>;
|
|
171
|
-
verifyTotpEnrollment: (code: string) => Promise<SeamlessAuthResult<MessageResult>>;
|
|
172
|
-
disableTotp: (code: string) => Promise<SeamlessAuthResult<MessageResult>>;
|
|
173
|
-
verifyStepUpWithTotp: (code: string) => Promise<SeamlessAuthResult<StepUpStatus>>;
|
|
174
|
-
updateCredential: (input: {
|
|
175
|
-
id: string;
|
|
176
|
-
friendlyName: string | null;
|
|
177
|
-
}) => Promise<SeamlessAuthResult<CredentialUpdateResult>>;
|
|
178
|
-
deleteCredential: (id: string) => Promise<SeamlessAuthResult<MessageResult>>;
|
|
179
|
-
listOrganizations: () => Promise<SeamlessAuthResult<OrganizationsResult>>;
|
|
180
|
-
createOrganization: (input: CreateOrganizationInput) => Promise<SeamlessAuthResult<OrganizationResult>>;
|
|
181
|
-
getOrganization: (organizationId: string) => Promise<SeamlessAuthResult<OrganizationResult>>;
|
|
182
|
-
updateOrganization: (organizationId: string, input: UpdateOrganizationInput) => Promise<SeamlessAuthResult<OrganizationResult>>;
|
|
183
|
-
switchOrganization: (organizationId: string) => Promise<SeamlessAuthResult<OrganizationSwitchResult>>;
|
|
184
|
-
listOrganizationMembers: (organizationId: string) => Promise<SeamlessAuthResult<OrganizationMembersResult>>;
|
|
185
|
-
addOrganizationMember: (organizationId: string, input: OrganizationMemberInput) => Promise<SeamlessAuthResult<OrganizationMembershipResult>>;
|
|
186
|
-
updateOrganizationMember: (organizationId: string, userId: string, input: OrganizationMemberUpdateInput) => Promise<SeamlessAuthResult<OrganizationMembershipResult>>;
|
|
187
|
-
removeOrganizationMember: (organizationId: string, userId: string) => Promise<SeamlessAuthResult<MessageResult>>;
|
|
188
|
-
}
|
|
189
|
-
export declare const createSeamlessAuthClient: (opts: SeamlessAuthClientOptions) => SeamlessAuthClient;
|
package/dist/client/errors.d.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { OAuthErrorCode as OAuthErrorCodeShape, WebAuthnErrorCode as WebAuthnErrorCodeShape } from '@seamless-auth/types';
|
|
2
|
-
/**
|
|
3
|
-
* Error carrying the auth server's response detail, so callers can map known
|
|
4
|
-
* failures to their own messaging instead of only seeing a generic string.
|
|
5
|
-
*/
|
|
6
|
-
export declare class SeamlessAuthError extends Error {
|
|
7
|
-
readonly status: number;
|
|
8
|
-
readonly body: unknown;
|
|
9
|
-
/**
|
|
10
|
-
* The underlying failure when the error was raised locally rather than by a
|
|
11
|
-
* response, for example the `DOMException` a WebAuthn ceremony throws.
|
|
12
|
-
*/
|
|
13
|
-
readonly cause: unknown;
|
|
14
|
-
constructor(message: string, status: number, body?: unknown, cause?: unknown);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Machine-readable codes the auth API returns alongside `error` on an OAuth
|
|
18
|
-
* callback failure the user can act on.
|
|
19
|
-
*/
|
|
20
|
-
export type OAuthErrorCode = OAuthErrorCodeShape;
|
|
21
|
-
/**
|
|
22
|
-
* Read the OAuth failure code off a result error. Returns `undefined` for
|
|
23
|
-
* anything unrecognized, including codes added by a newer API, so callers keep
|
|
24
|
-
* their generic messaging instead of showing a raw code.
|
|
25
|
-
*
|
|
26
|
-
* The auth API puts `code` at the top level of the error body, but a proxy in
|
|
27
|
-
* front of it may normalize that body and nest the siblings of `error` under
|
|
28
|
-
* `details`. Both locations are accepted so such a proxy does not silently
|
|
29
|
-
* downgrade OAuth messaging to a generic failure.
|
|
30
|
-
*/
|
|
31
|
-
export declare function getOAuthErrorCode(error: unknown): OAuthErrorCode | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Machine-readable codes registration is refused with when a deployment will not
|
|
34
|
-
* enrol the authenticator on policy grounds.
|
|
35
|
-
*
|
|
36
|
-
* `attachment_not_allowed` comes from register/start with a `400`, before any
|
|
37
|
-
* ceremony runs. The rest come from register/finish with a `403`, once the
|
|
38
|
-
* credential exists and can be inspected.
|
|
39
|
-
*/
|
|
40
|
-
export type PasskeyPolicyErrorCode = Exclude<WebAuthnErrorCodeShape, 'prf_output_not_allowed'>;
|
|
41
|
-
/**
|
|
42
|
-
* Read the passkey policy refusal off a registration error, from either stage of
|
|
43
|
-
* the ceremony. Returns `undefined` for anything unrecognized, including codes
|
|
44
|
-
* added by a newer API, so callers keep their generic messaging instead of
|
|
45
|
-
* showing a raw code.
|
|
46
|
-
*
|
|
47
|
-
* The auth API sends the code as the whole of `error`, which is also what
|
|
48
|
-
* becomes `error.message`. A proxy in front of it may instead derive a
|
|
49
|
-
* human-readable `error` and keep the upstream body under `details`, so an
|
|
50
|
-
* unrecognized top-level value falls through to the nested one rather than
|
|
51
|
-
* ending the lookup.
|
|
52
|
-
*/
|
|
53
|
-
export declare function getPasskeyPolicyErrorCode(error: unknown): PasskeyPolicyErrorCode | undefined;
|
|
54
|
-
/**
|
|
55
|
-
* Whether a failure means nobody is signed in.
|
|
56
|
-
*
|
|
57
|
-
* Enrollment takes the signed-in session, so a `401` there is an expired or missing
|
|
58
|
-
* one rather than anything about the authenticator, and the two need different
|
|
59
|
-
* messages: one asks the user to sign in again, the other to reach for a different
|
|
60
|
-
* key. Raised locally, a ceremony failure carries `NETWORK_ERROR_STATUS`, so this
|
|
61
|
-
* matches on the response status alone.
|
|
62
|
-
*/
|
|
63
|
-
export declare function isUnauthenticated(error: unknown): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Detail recovered from a failed WebAuthn ceremony.
|
|
66
|
-
*
|
|
67
|
-
* `name` is the `DOMException` name, which is what distinguishes the cases a
|
|
68
|
-
* user can act on: `NotAllowedError` for a dismissed prompt or no usable
|
|
69
|
-
* credential, `SecurityError` for an origin or RP ID mismatch,
|
|
70
|
-
* `InvalidStateError` for an already registered passkey. `code` is
|
|
71
|
-
* SimpleWebAuthn's narrower reason when it identified one, for example
|
|
72
|
-
* `ERROR_CEREMONY_ABORTED`.
|
|
73
|
-
*/
|
|
74
|
-
export type WebAuthnErrorDetail = {
|
|
75
|
-
name: string;
|
|
76
|
-
code?: string;
|
|
77
|
-
message: string;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Read the WebAuthn failure behind a result error. Returns `undefined` for
|
|
81
|
-
* errors that did not come from a ceremony, so callers can branch on the
|
|
82
|
-
* specific failure and otherwise fall back to `error.message`.
|
|
83
|
-
*/
|
|
84
|
-
export declare function getWebAuthnErrorDetail(error: unknown): WebAuthnErrorDetail | undefined;
|
|
85
|
-
/**
|
|
86
|
-
* Build a `SeamlessAuthError` from a failed response, preserving the status and
|
|
87
|
-
* the parsed body. The body may be empty or non-JSON, which is not treated as a
|
|
88
|
-
* failure: the fallback message is used instead.
|
|
89
|
-
*/
|
|
90
|
-
export declare function toSeamlessAuthError(response: Response, fallbackMessage: string): Promise<SeamlessAuthError>;
|
package/dist/client/result.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { SeamlessAuthError } from './errors';
|
|
2
|
-
/**
|
|
3
|
-
* Outcome of an auth request.
|
|
4
|
-
*
|
|
5
|
-
* Auth failures are expected outcomes rather than exceptions: a wrong OTP, an
|
|
6
|
-
* expired magic link, or a disabled provider all map directly to UI state. So
|
|
7
|
-
* requests resolve to a result instead of throwing, and `data` is only readable
|
|
8
|
-
* once `error` has been checked.
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* const { data, error } = await authClient.getCurrentUser();
|
|
12
|
-
* if (error) {
|
|
13
|
-
* setMessage(error.message);
|
|
14
|
-
* return;
|
|
15
|
-
* }
|
|
16
|
-
* setUser(data.user);
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
export type SeamlessAuthResult<T> = {
|
|
20
|
-
data: T;
|
|
21
|
-
error: null;
|
|
22
|
-
} | {
|
|
23
|
-
data: null;
|
|
24
|
-
error: SeamlessAuthError;
|
|
25
|
-
};
|
|
26
|
-
/** Status used when the request never reached the server. */
|
|
27
|
-
export declare const NETWORK_ERROR_STATUS = 0;
|
|
28
|
-
/**
|
|
29
|
-
* Run a request and convert it into a result. Never throws for HTTP outcomes,
|
|
30
|
-
* and also absorbs transport failures so callers only handle one shape.
|
|
31
|
-
*/
|
|
32
|
-
export declare function requestResult<T>(request: Promise<Response>, fallbackMessage: string): Promise<SeamlessAuthResult<T>>;
|
|
33
|
-
/** Wrap an already-derived value as a successful result. */
|
|
34
|
-
export declare function resultOf<T>(data: T): SeamlessAuthResult<T>;
|
|
35
|
-
/** Wrap a failure as a result. */
|
|
36
|
-
export declare function resultError<T>(message: string, status?: number, body?: unknown, cause?: unknown): SeamlessAuthResult<T>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { type AuthenticationResponseJSON, type PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/browser';
|
|
2
|
-
export type PasskeyPrfSalt = ArrayBuffer | ArrayBufferView | string;
|
|
3
|
-
export interface PasskeyPrfInput {
|
|
4
|
-
salt: PasskeyPrfSalt;
|
|
5
|
-
secondSalt?: PasskeyPrfSalt;
|
|
6
|
-
credentialId?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface PasskeyPrfResult {
|
|
9
|
-
credentialId: string;
|
|
10
|
-
output: Uint8Array;
|
|
11
|
-
outputBase64url: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function encodePrfSalt(salt: PasskeyPrfSalt): string;
|
|
14
|
-
export declare function createPrfRequestBody(input: PasskeyPrfInput): {
|
|
15
|
-
prf: {
|
|
16
|
-
secondSalt?: string | undefined;
|
|
17
|
-
salt: string;
|
|
18
|
-
};
|
|
19
|
-
credentialId?: string | undefined;
|
|
20
|
-
};
|
|
21
|
-
export declare function isPasskeyPrfSupported(): Promise<boolean>;
|
|
22
|
-
export declare function preparePrfRequestOptions(optionsJSON: PublicKeyCredentialRequestOptionsJSON): PublicKeyCredentialRequestOptionsJSON;
|
|
23
|
-
export declare function extractPasskeyPrfResult(credential: AuthenticationResponseJSON): PasskeyPrfResult | null;
|
|
24
|
-
export declare function stripPrfResultsFromAssertion(credential: AuthenticationResponseJSON): AuthenticationResponseJSON;
|
|
25
|
-
export declare function getRegistrationPrfCapable(attestationResponse: {
|
|
26
|
-
clientExtensionResults?: unknown;
|
|
27
|
-
}): boolean;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* True when the browser exposes a usable WebAuthn API in a secure context.
|
|
3
|
-
* This is the coarse gate for any passkey flow, including PRF assertions.
|
|
4
|
-
*/
|
|
5
|
-
export declare function isWebAuthnAvailable(): boolean;
|
|
6
|
-
/**
|
|
7
|
-
* True when a user-verifying platform authenticator (Touch ID, Windows Hello,
|
|
8
|
-
* and similar) can be used on this device.
|
|
9
|
-
*/
|
|
10
|
-
export declare function isPlatformAuthenticatorAvailable(): Promise<boolean>;
|
package/dist/fetchWithAuth.d.ts
DELETED
package/dist/scopedRoles.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { CurrentUserResult, FinishOAuthLoginInput, FinishOAuthLoginResult, LoginStartResult, MessageResult, OAuthProvidersResult, OrganizationSwitchResult, PasskeyLoginData, PasskeyMetadata, PasskeyRegistrationData, RegisterPasskeyOptions, StartOAuthLoginInput, StartOAuthLoginResult, StepUpPrfData, StepUpStatus } from '../client/createSeamlessAuthClient';
|
|
2
|
-
import type { SeamlessAuthResult } from '../client/result';
|
|
3
|
-
import { PasskeyPrfInput } from '../client/webauthnPrf';
|
|
4
|
-
import { Credential, Organization, User } from '../types';
|
|
5
|
-
import { SessionStoragePort } from './storage';
|
|
6
|
-
/** Everything a UI binding renders from. Replaced wholesale on every change. */
|
|
7
|
-
export interface AuthSessionState {
|
|
8
|
-
user: User | null;
|
|
9
|
-
credentials: Credential[];
|
|
10
|
-
organizations: Organization[];
|
|
11
|
-
activeOrganization: Organization | null;
|
|
12
|
-
stepUpStatus: StepUpStatus | null;
|
|
13
|
-
isAuthenticated: boolean;
|
|
14
|
-
loading: boolean;
|
|
15
|
-
hasSignedInBefore: boolean;
|
|
16
|
-
}
|
|
17
|
-
export interface AuthSessionActions {
|
|
18
|
-
login: (identifier: string, passkeyAvailable: boolean) => Promise<SeamlessAuthResult<LoginStartResult>>;
|
|
19
|
-
handlePasskeyLogin: () => Promise<SeamlessAuthResult<PasskeyLoginData>>;
|
|
20
|
-
registerPasskey: (input: PasskeyMetadata | RegisterPasskeyOptions) => Promise<SeamlessAuthResult<PasskeyRegistrationData>>;
|
|
21
|
-
refreshSession: () => Promise<SeamlessAuthResult<CurrentUserResult>>;
|
|
22
|
-
logout: () => Promise<SeamlessAuthResult<MessageResult>>;
|
|
23
|
-
logoutAllSessions: () => Promise<SeamlessAuthResult<MessageResult>>;
|
|
24
|
-
deleteUser: () => Promise<SeamlessAuthResult<MessageResult>>;
|
|
25
|
-
updateCredential: (credential: Credential) => Promise<SeamlessAuthResult<Credential>>;
|
|
26
|
-
deleteCredential: (credentialId: string) => Promise<SeamlessAuthResult<MessageResult>>;
|
|
27
|
-
switchOrganization: (organizationId: string) => Promise<SeamlessAuthResult<OrganizationSwitchResult>>;
|
|
28
|
-
listOAuthProviders: () => Promise<SeamlessAuthResult<OAuthProvidersResult>>;
|
|
29
|
-
startOAuthLogin: (input: StartOAuthLoginInput) => Promise<SeamlessAuthResult<StartOAuthLoginResult>>;
|
|
30
|
-
finishOAuthLogin: (input: FinishOAuthLoginInput) => Promise<SeamlessAuthResult<FinishOAuthLoginResult>>;
|
|
31
|
-
refreshStepUpStatus: () => Promise<SeamlessAuthResult<StepUpStatus>>;
|
|
32
|
-
verifyStepUpWithPasskey: () => Promise<SeamlessAuthResult<StepUpStatus>>;
|
|
33
|
-
verifyStepUpWithPasskeyPrf: (input: PasskeyPrfInput) => Promise<SeamlessAuthResult<StepUpPrfData>>;
|
|
34
|
-
verifyStepUpWithTotp: (code: string) => Promise<SeamlessAuthResult<StepUpStatus>>;
|
|
35
|
-
hasRole: (role: string) => boolean | undefined;
|
|
36
|
-
hasScopedRole: (role: string | string[]) => boolean | undefined;
|
|
37
|
-
markSignedIn: () => void;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Framework-agnostic session store.
|
|
41
|
-
*
|
|
42
|
-
* `getState` and `subscribe` are the shape React's `useSyncExternalStore` wants,
|
|
43
|
-
* and they adapt directly to a Vue ref or an Angular observable, so bindings stay
|
|
44
|
-
* thin instead of each reimplementing this state machine.
|
|
45
|
-
*/
|
|
46
|
-
export interface AuthSession {
|
|
47
|
-
getState: () => AuthSessionState;
|
|
48
|
-
subscribe: (listener: () => void) => () => void;
|
|
49
|
-
actions: AuthSessionActions;
|
|
50
|
-
destroy: () => void;
|
|
51
|
-
}
|
|
52
|
-
export interface AuthSessionOptions {
|
|
53
|
-
apiHost: string;
|
|
54
|
-
storage?: SessionStoragePort;
|
|
55
|
-
/**
|
|
56
|
-
* When false, a previous sign-in is still recorded but never surfaced, so a UI
|
|
57
|
-
* cannot branch on it.
|
|
58
|
-
*/
|
|
59
|
-
detectPreviousSignIn?: boolean;
|
|
60
|
-
}
|
|
61
|
-
export declare function createAuthSession(options: AuthSessionOptions): AuthSession;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The session store's only browser dependency, expressed as a port so the store
|
|
3
|
-
* itself stays framework and environment agnostic. Implementations never throw:
|
|
4
|
-
* private browsing and disabled storage are normal, and neither is a reason to
|
|
5
|
-
* fail an auth flow.
|
|
6
|
-
*/
|
|
7
|
-
export interface SessionStoragePort {
|
|
8
|
-
get(key: string): string | null;
|
|
9
|
-
set(key: string, value: string): void;
|
|
10
|
-
}
|
|
11
|
-
export declare function createMemoryStorage(): SessionStoragePort;
|
|
12
|
-
export declare function createBrowserStorage(): SessionStoragePort;
|
|
13
|
-
/**
|
|
14
|
-
* Browser storage where there is a `localStorage`, memory otherwise. The memory
|
|
15
|
-
* fallback is what keeps the store usable during server-side rendering.
|
|
16
|
-
*/
|
|
17
|
-
export declare function createDefaultStorage(): SessionStoragePort;
|
package/dist/types.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { CredentialResponse, MeUser, Organization as OrganizationShape, OrganizationMembership as OrganizationMembershipShape } from '@seamless-auth/types';
|
|
2
|
-
export type User = MeUser;
|
|
3
|
-
export type OrganizationMembership = OrganizationMembershipShape;
|
|
4
|
-
export type Organization = OrganizationShape;
|
|
5
|
-
export type Credential = CredentialResponse;
|