@aura-stack/next 0.2.1 → 0.3.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/dist/@types/index.d.ts +2 -2
- package/dist/client.cjs +1 -1
- package/dist/client.d.ts +2 -2
- package/dist/client.js +1 -1
- package/dist/context.cjs +1 -1
- package/dist/context.js +1 -1
- package/dist/identity/arktype.cjs +1 -0
- package/dist/identity/arktype.d.ts +1 -0
- package/dist/identity/arktype.js +1 -0
- package/dist/identity/index.cjs +1 -0
- package/dist/identity/index.d.ts +1 -0
- package/dist/identity/index.js +1 -0
- package/dist/identity/typebox.cjs +1 -0
- package/dist/identity/typebox.d.ts +1 -0
- package/dist/identity/typebox.js +1 -0
- package/dist/identity/valibot.cjs +1 -0
- package/dist/identity/valibot.d.ts +1 -0
- package/dist/identity/valibot.js +1 -0
- package/dist/identity/zod.cjs +1 -0
- package/dist/identity/zod.d.ts +1 -0
- package/dist/identity/zod.js +1 -0
- package/dist/index-BLRrX4DD.d.ts +68 -0
- package/dist/{index-CbFxTFu9.d.ts → index-BbJId8e2.d.ts} +771 -182
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +25 -1633
- package/dist/index.js +1 -1
- package/dist/pages/client.cjs +1 -1
- package/dist/pages/client.d.ts +2 -2
- package/dist/pages/client.js +1 -1
- package/dist/pages/index.d.ts +7809 -18
- package/package.json +68 -54
- package/dist/_core/identity.cjs +0 -1
- package/dist/_core/identity.d.ts +0 -1
- package/dist/_core/identity.js +0 -1
- package/dist/index-B0R6c-K9.d.ts +0 -45
|
@@ -553,7 +553,7 @@ type MaybePromise<TValue$1> = TValue$1 | Promise<TValue$1>;
|
|
|
553
553
|
* Hint: This type has no effect and is only used so that TypeScript displays
|
|
554
554
|
* the final type in the preview instead of the utility types used.
|
|
555
555
|
*/
|
|
556
|
-
type Prettify$
|
|
556
|
+
type Prettify$2<TObject> = { [TKey in keyof TObject]: TObject[TKey] } & {};
|
|
557
557
|
/**
|
|
558
558
|
* Marks specific keys as optional.
|
|
559
559
|
*/
|
|
@@ -641,11 +641,11 @@ type OutputWithReadonly<TEntries$1 extends ObjectEntries | ObjectEntriesAsync, T
|
|
|
641
641
|
/**
|
|
642
642
|
* Infer object input type.
|
|
643
643
|
*/
|
|
644
|
-
type InferObjectInput<TEntries$1 extends ObjectEntries | ObjectEntriesAsync> = Prettify$
|
|
644
|
+
type InferObjectInput<TEntries$1 extends ObjectEntries | ObjectEntriesAsync> = Prettify$2<InputWithQuestionMarks<TEntries$1, InferEntriesInput<TEntries$1>>>;
|
|
645
645
|
/**
|
|
646
646
|
* Infer object output type.
|
|
647
647
|
*/
|
|
648
|
-
type InferObjectOutput<TEntries$1 extends ObjectEntries | ObjectEntriesAsync> = Prettify$
|
|
648
|
+
type InferObjectOutput<TEntries$1 extends ObjectEntries | ObjectEntriesAsync> = Prettify$2<OutputWithReadonly<TEntries$1, OutputWithQuestionMarks<TEntries$1, InferEntriesOutput<TEntries$1>>>>;
|
|
649
649
|
/**
|
|
650
650
|
* Infer object issue type.
|
|
651
651
|
*/
|
|
@@ -7624,7 +7624,7 @@ type MakeReadonly<T> = T extends Map<infer K, infer V> ? ReadonlyMap<K, V> : T e
|
|
|
7624
7624
|
type SomeObject = Record<PropertyKey, any>;
|
|
7625
7625
|
type Identity$1<T> = T;
|
|
7626
7626
|
type Flatten<T> = Identity$1<{ [k in keyof T]: T[k] }>;
|
|
7627
|
-
type Prettify$
|
|
7627
|
+
type Prettify$1<T> = { [K in keyof T]: T[K] } & {};
|
|
7628
7628
|
type Extend<A extends SomeObject, B extends SomeObject> = Flatten<keyof A & keyof B extends never ? A & B : { [K in keyof A as K extends keyof B ? never : K]: A[K] } & { [K in keyof B]: B[K] }>;
|
|
7629
7629
|
type TupleItems = ReadonlyArray<SomeType>;
|
|
7630
7630
|
type AnyFunc = (...args: any[]) => any;
|
|
@@ -8110,8 +8110,8 @@ type OptionalInSchema = {
|
|
|
8110
8110
|
optin: "optional";
|
|
8111
8111
|
};
|
|
8112
8112
|
};
|
|
8113
|
-
type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, output<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : Prettify$
|
|
8114
|
-
type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, input<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : Prettify$
|
|
8113
|
+
type $InferObjectOutput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, output<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : Prettify$1<{ -readonly [k in keyof T as T[k] extends OptionalOutSchema ? never : k]: T[k]["_zod"]["output"] } & { -readonly [k in keyof T as T[k] extends OptionalOutSchema ? k : never]?: T[k]["_zod"]["output"] } & Extra>;
|
|
8114
|
+
type $InferObjectInput<T extends $ZodLooseShape, Extra extends Record<string, unknown>> = string extends keyof T ? IsAny<T[keyof T]> extends true ? Record<string, unknown> : Record<string, input<T[keyof T]>> : keyof (T & Extra) extends never ? Record<string, never> : Prettify$1<{ -readonly [k in keyof T as T[k] extends OptionalInSchema ? never : k]: T[k]["_zod"]["input"] } & { -readonly [k in keyof T as T[k] extends OptionalInSchema ? k : never]?: T[k]["_zod"]["input"] } & Extra>;
|
|
8115
8115
|
type $ZodObjectConfig = {
|
|
8116
8116
|
out: Record<string, unknown>;
|
|
8117
8117
|
in: Record<string, unknown>;
|
|
@@ -8994,7 +8994,7 @@ type SchemaKind<T> = [T] extends [$ZodType] ? "zod" : [T] extends [ObjectSchema<
|
|
|
8994
8994
|
* const getPostsComments:RoutePattern = "/posts/:postId/comments/:commentId"
|
|
8995
8995
|
*/
|
|
8996
8996
|
type RoutePattern = `/${string}`;
|
|
8997
|
-
type Prettify
|
|
8997
|
+
type Prettify<Obj extends object> = { [Key in keyof Obj]: Obj[Key] } & {};
|
|
8998
8998
|
type GetParam<Route extends string> = Route extends `:${infer Param}` ? { [K in Param]: string } : {};
|
|
8999
8999
|
/**
|
|
9000
9000
|
* Extracts route parameters from a given route pattern through colon-prefixed segments.
|
|
@@ -9011,7 +9011,7 @@ type GetParam<Route extends string> = Route extends `:${infer Param}` ? { [K in
|
|
|
9011
9011
|
* // Expected: {}
|
|
9012
9012
|
* type NoParams = Params<"/about">;
|
|
9013
9013
|
*/
|
|
9014
|
-
type GetRouteParams<Route extends RoutePattern> = Route extends `/${infer Path}/${infer Str}` ? Prettify
|
|
9014
|
+
type GetRouteParams<Route extends RoutePattern> = Route extends `/${infer Path}/${infer Str}` ? Prettify<GetParam<Path> & GetRouteParams<`/${Str}`>> : Route extends `/${infer Path}` ? GetParam<Path> : {};
|
|
9015
9015
|
/**
|
|
9016
9016
|
* Available schemas validation for an endpoint. It can include body and searchParams schemas.
|
|
9017
9017
|
*/
|
|
@@ -9692,8 +9692,7 @@ interface DecodeJWTOptions {
|
|
|
9692
9692
|
decrypt?: DecryptOptions;
|
|
9693
9693
|
}
|
|
9694
9694
|
//#endregion
|
|
9695
|
-
//#region ../core/dist/index-
|
|
9696
|
-
//#endregion
|
|
9695
|
+
//#region ../core/dist/index-vaLptcEI.d.ts
|
|
9697
9696
|
//#region src/jose.d.ts
|
|
9698
9697
|
/**
|
|
9699
9698
|
* Creates the JOSE instance used for signing and verifying tokens. It derives keys
|
|
@@ -9717,14 +9716,16 @@ declare const createJoseInstance: <DefaultUser extends User = User>(secret?: JWT
|
|
|
9717
9716
|
encodeJWT: (payload: TypedJWTPayload<Partial<DefaultUser>>, options?: EncodeJWTOptions) => Promise<string>;
|
|
9718
9717
|
decodeJWT: (token: string, options?: DecodeJWTOptions) => Promise<TypedJWTPayload<DefaultUser>>;
|
|
9719
9718
|
}; //#endregion
|
|
9720
|
-
//#region src/
|
|
9721
|
-
|
|
9719
|
+
//#region src/identity/arktype.d.ts
|
|
9720
|
+
type SchemaTypes = ZodObject<any> | ObjectSchema<any, undefined> | Type<{}> | TObject;
|
|
9721
|
+
//#endregion
|
|
9722
|
+
//#region src/identity/zod.d.ts
|
|
9723
|
+
declare const identitySchema: ZodObject<{
|
|
9722
9724
|
sub: ZodString;
|
|
9723
9725
|
name: ZodOptional<ZodNullable<ZodString>>;
|
|
9724
9726
|
image: ZodOptional<ZodNullable<ZodString>>;
|
|
9725
9727
|
email: ZodOptional<ZodNullable<ZodEmail>>;
|
|
9726
9728
|
}, $strip>;
|
|
9727
|
-
type SchemaTypes = ZodObject<any> | ObjectSchema<any, undefined> | Type<{}> | TObject;
|
|
9728
9729
|
//#endregion
|
|
9729
9730
|
//#region src/api/createApi.d.ts
|
|
9730
9731
|
declare const createAuthAPI: <DefaultUser extends User = User, SignUpSchema extends SchemaTypes = ZodObject<any>>(ctx: GlobalContext) => {
|
|
@@ -9808,6 +9809,93 @@ declare const createAuthAPI: <DefaultUser extends User = User, SignUpSchema exte
|
|
|
9808
9809
|
* })
|
|
9809
9810
|
*/
|
|
9810
9811
|
updateSession: (options: UpdateSessionAPIOptions<DefaultUser>) => Promise<UpdateSessionAPIReturn<DefaultUser>>;
|
|
9812
|
+
/**
|
|
9813
|
+
* Retrieves the access token for a specific OAuth provider on the server-side.
|
|
9814
|
+
* It implements CSRF Protection by default, for server-side calls it only verifies and validates the CSRF Token,
|
|
9815
|
+
* it also provides Double-Submit Cookie protection by requiring the `session_token` cookie to be included in
|
|
9816
|
+
* the request headers.
|
|
9817
|
+
*
|
|
9818
|
+
* @params oauth - The OAuth provider for which to retrieve the access token (e.g., "github", "gitlab", "bitbucket").
|
|
9819
|
+
* @params options - Options for the API call, including headers and request object.
|
|
9820
|
+
* @example
|
|
9821
|
+
* const { success, tokens } = await api.getProviderTokens("github", {
|
|
9822
|
+
* headers: getHeaders()
|
|
9823
|
+
* })
|
|
9824
|
+
*
|
|
9825
|
+
* const { accessToken, refreshToken } = tokens
|
|
9826
|
+
*/
|
|
9827
|
+
getProviderTokens: (oauth: LiteralUnion<BuiltInOAuthProvider>, options?: GetProviderTokensAPIOptions) => Promise<GetProviderTokensAPIReturn>;
|
|
9828
|
+
/**
|
|
9829
|
+
* Retrieves the access token for a specific OAuth provider on the server-side.
|
|
9830
|
+
* It implements CSRF Protection by default, for server-side calls it only verifies and validates the CSRF Token,
|
|
9831
|
+
* it also provides Double-Submit Cookie protection by requiring the `session_token` cookie to be included in
|
|
9832
|
+
* the request headers.
|
|
9833
|
+
*
|
|
9834
|
+
* > **NOTE**: This method is based on `getProviderTokens` and it's recommended for simple use cases where only the
|
|
9835
|
+
* access token is needed. For more advanced scenarios, consider using `getProviderTokens` directly.
|
|
9836
|
+
*
|
|
9837
|
+
* @params oauth - The OAuth provider for which to retrieve the access token (e.g., "github", "gitlab", "bitbucket").
|
|
9838
|
+
* @params options - Options for the API call, including headers and request object.
|
|
9839
|
+
* @example
|
|
9840
|
+
* const { success, accessToken } = await api.getAccessToken("github", {
|
|
9841
|
+
* headers: getHeaders()
|
|
9842
|
+
* })
|
|
9843
|
+
*/
|
|
9844
|
+
getAccessToken: (oauth: LiteralUnion<BuiltInOAuthProvider>, options?: AccessTokenAPIOptions) => Promise<AccessTokenAPIReturn>;
|
|
9845
|
+
/**
|
|
9846
|
+
* Refreshes the user profile data from the OAuth provider on the server-side. It makes a request to the
|
|
9847
|
+
* `userInfo` endpoint of the specified OAuth provider.
|
|
9848
|
+
*
|
|
9849
|
+
* @param oauth - The OAuth provider for which to refresh the user profile data (e.g., "github", "gitlab", "bitbucket").
|
|
9850
|
+
* @param options - Options for the API call, including headers and request object.
|
|
9851
|
+
* @example
|
|
9852
|
+
* const { success, session } = await api.refreshUserInfo("github", {
|
|
9853
|
+
* headers: getHeaders()
|
|
9854
|
+
* })
|
|
9855
|
+
*/
|
|
9856
|
+
refreshUserInfo: (oauth: LiteralUnion<BuiltInOAuthProvider>, options?: RefreshUserInfoAPIOptions) => Promise<RefreshUserInfoAPIReturn<DefaultUser>>;
|
|
9857
|
+
/**
|
|
9858
|
+
* Revokes the access token for a specific OAuth provider on the server-side. It makes a request to the
|
|
9859
|
+
* `revokeToken` endpoint of the specified OAuth provider.
|
|
9860
|
+
*
|
|
9861
|
+
* @param oauth - The OAuth provider for which to revoke the access token (e.g., "github", "gitlab", "bitbucket").
|
|
9862
|
+
* @param options - Options for the API call, including headers and request object.
|
|
9863
|
+
* @example
|
|
9864
|
+
* const { success, headers } = await api.revokeToken("github", {
|
|
9865
|
+
* headers: getHeaders()
|
|
9866
|
+
* })
|
|
9867
|
+
* // Use the returned headers to update the response headers in your server-side logic
|
|
9868
|
+
* return new Response(null, { status: 200, headers })
|
|
9869
|
+
*/
|
|
9870
|
+
revokeToken: (oauth: LiteralUnion<BuiltInOAuthProvider>, options?: RevokeTokenAPIOptions) => Promise<RevokeTokenAPIReturn>;
|
|
9871
|
+
/**
|
|
9872
|
+
* Disconnects the OAuth provider for the current session on the server-side. It removes the association
|
|
9873
|
+
* between the user's session and the specified OAuth provider.
|
|
9874
|
+
* @params oauth - The OAuth provider to disconnect (e.g., "github", "gitlab", "bitbucket").
|
|
9875
|
+
* @params options - Options for the API call, including headers and request object.
|
|
9876
|
+
* @example
|
|
9877
|
+
* const { success, headers } = await api.disconnectProvider("github", {
|
|
9878
|
+
* headers: getHeaders()
|
|
9879
|
+
* })
|
|
9880
|
+
* // Use the returned headers to update the response headers in your server-side logic
|
|
9881
|
+
* return new Response(null, { status: 200, headers })
|
|
9882
|
+
*/
|
|
9883
|
+
disconnectProvider: (oauth: LiteralUnion<BuiltInOAuthProvider>, options?: DisconnectProviderAPIOptions) => Promise<DisconnectProviderAPIReturn>;
|
|
9884
|
+
/**
|
|
9885
|
+
* Checks if the current session is connected to a specific OAuth provider on the server-side. It verifies
|
|
9886
|
+
* the presence of a valid access token for the specified provider in the session.
|
|
9887
|
+
*
|
|
9888
|
+
* @param oauth - The OAuth provider to check for connection (e.g., "github", "gitlab", "bitbucket").
|
|
9889
|
+
* @param options - Options for the API call, including headers and request object.
|
|
9890
|
+
* @example
|
|
9891
|
+
* const { success, connected } = await api.isProviderConnected("github", {
|
|
9892
|
+
* headers: getHeaders()
|
|
9893
|
+
* })
|
|
9894
|
+
* if (connected) {
|
|
9895
|
+
* // The session is connected to the GitHub provider
|
|
9896
|
+
* }
|
|
9897
|
+
*/
|
|
9898
|
+
isProviderConnected: (oauth: LiteralUnion<BuiltInOAuthProvider>, options?: ProviderConnectedAPIOptions) => Promise<ProviderConnectedAPIReturn>;
|
|
9811
9899
|
/**
|
|
9812
9900
|
* Signs out the current session on the server-side. It implements CSRF Protection by default, for
|
|
9813
9901
|
* server-side calls it only verifies and validates the CSRF Token, it also provides Double-Submit
|
|
@@ -9833,6 +9921,484 @@ declare const createAuthAPI: <DefaultUser extends User = User, SignUpSchema exte
|
|
|
9833
9921
|
* Each message includes facility, severity, msgId, and default message.
|
|
9834
9922
|
*/
|
|
9835
9923
|
//#endregion
|
|
9924
|
+
//#region src/@types/entities.d.ts
|
|
9925
|
+
type UserStatus = "active" | "suspended" | "pending_verification" | "deleted";
|
|
9926
|
+
/**
|
|
9927
|
+
* @todo: add "passkey" and "saml" to AccountType when we implement those providers
|
|
9928
|
+
*/
|
|
9929
|
+
type AccountType$1 = "oauth" | "credentials";
|
|
9930
|
+
type AccountStatus = "active" | "unlinked" | "suspended";
|
|
9931
|
+
type SessionStatus = "active" | "expired" | "revoked";
|
|
9932
|
+
/**
|
|
9933
|
+
* Tracks MFA progress within a session.
|
|
9934
|
+
* - "none": MFA not required for this user or session
|
|
9935
|
+
* - "pending": primary auth passed, MFA challenge not yet completed
|
|
9936
|
+
* - "completed": MFA challenge passed
|
|
9937
|
+
* - "skipped": trusted device, MFA step-up bypassed
|
|
9938
|
+
*/
|
|
9939
|
+
type MFAState = "none" | "pending" | "completed" | "skipped";
|
|
9940
|
+
type MFAMethod = "totp" | "webauthn_passkey" | "webauthn_security_key" | "sms" | "email" | "recovery_code";
|
|
9941
|
+
type DeviceType = "desktop" | "mobile" | "tablet" | "tv" | "bot" | "unknown";
|
|
9942
|
+
type RevokeReason = "user_logout" | "admin_action" | "password_changed" | "email_changed" | "all_sessions_revoked" | "mfa_disabled" | "account_suspended" | "max_sessions_exceeded";
|
|
9943
|
+
interface UserEntity {
|
|
9944
|
+
id: string;
|
|
9945
|
+
name: string | null;
|
|
9946
|
+
email: string | null;
|
|
9947
|
+
image: string | null;
|
|
9948
|
+
emailVerifiedAt: Date | null;
|
|
9949
|
+
status: UserStatus;
|
|
9950
|
+
mfaEnabled: boolean;
|
|
9951
|
+
mfaPreferredMethod: MFAMethod | null;
|
|
9952
|
+
createdAt: Date;
|
|
9953
|
+
updatedAt: Date;
|
|
9954
|
+
/**
|
|
9955
|
+
* Used to store the extra user attributes and extended by the `identity.schema`
|
|
9956
|
+
* configuration.
|
|
9957
|
+
*/
|
|
9958
|
+
attributes: Record<string, unknown> | null;
|
|
9959
|
+
}
|
|
9960
|
+
interface AccountEntity {
|
|
9961
|
+
id: string;
|
|
9962
|
+
userId: string;
|
|
9963
|
+
provider: string;
|
|
9964
|
+
providerUserId: string;
|
|
9965
|
+
type: AccountType$1;
|
|
9966
|
+
status: AccountStatus;
|
|
9967
|
+
createdAt: Date;
|
|
9968
|
+
updatedAt: Date;
|
|
9969
|
+
}
|
|
9970
|
+
interface OAuthAccountEntity {
|
|
9971
|
+
accountId: string;
|
|
9972
|
+
accessToken: string;
|
|
9973
|
+
refreshToken: string | null;
|
|
9974
|
+
idToken: string | null;
|
|
9975
|
+
tokenType: string | null;
|
|
9976
|
+
scopes: string | null;
|
|
9977
|
+
issuer: string | null;
|
|
9978
|
+
accessTokenExpiresAt: Date | null;
|
|
9979
|
+
refreshTokenExpiresAt: Date | null;
|
|
9980
|
+
updatedAt: Date;
|
|
9981
|
+
}
|
|
9982
|
+
interface CredentialAccountEntity {
|
|
9983
|
+
accountId: string;
|
|
9984
|
+
passwordHash: string;
|
|
9985
|
+
updatedAt: Date;
|
|
9986
|
+
}
|
|
9987
|
+
interface SessionEntity {
|
|
9988
|
+
id: string;
|
|
9989
|
+
userId: string;
|
|
9990
|
+
deviceId: string | null;
|
|
9991
|
+
authenticatedWith: string;
|
|
9992
|
+
status: SessionStatus;
|
|
9993
|
+
mfaState: MFAState;
|
|
9994
|
+
tokenHash: string;
|
|
9995
|
+
expiresAt: Date;
|
|
9996
|
+
metadata: Record<string, unknown> | null;
|
|
9997
|
+
lastActivityAt: Date;
|
|
9998
|
+
revokedAt: Date | null;
|
|
9999
|
+
createdAt: Date;
|
|
10000
|
+
updatedAt: Date;
|
|
10001
|
+
}
|
|
10002
|
+
type SessionWithUserEntity = SessionEntity & {
|
|
10003
|
+
user: UserEntity;
|
|
10004
|
+
};
|
|
10005
|
+
/**
|
|
10006
|
+
* Tracks physical devices across sessions.
|
|
10007
|
+
*/
|
|
10008
|
+
interface DeviceEntity {
|
|
10009
|
+
id: string;
|
|
10010
|
+
userId: string;
|
|
10011
|
+
/**
|
|
10012
|
+
* User-assigned label for the device, e.g. "Work MacBook" or "iPhone 14 Pro".
|
|
10013
|
+
*/
|
|
10014
|
+
name: string | null;
|
|
10015
|
+
type: DeviceType;
|
|
10016
|
+
/**
|
|
10017
|
+
* Platform name and version, e.g. "macOS 14.1" or "Android 14".
|
|
10018
|
+
*/
|
|
10019
|
+
platform: string | null;
|
|
10020
|
+
/**
|
|
10021
|
+
* Browser name and version, e.g. "Chrome 120" or "Safari 17".
|
|
10022
|
+
*/
|
|
10023
|
+
browser: string | null;
|
|
10024
|
+
/**
|
|
10025
|
+
* User-Agent string captured at first sign-in from this device.
|
|
10026
|
+
* @see https://developer.mozilla.org/es/docs/Web/HTTP/Reference/Headers/User-Agent
|
|
10027
|
+
*/
|
|
10028
|
+
userAgent: string | null;
|
|
10029
|
+
fingerprint: string | null;
|
|
10030
|
+
lastIp: string | null;
|
|
10031
|
+
trusted: boolean;
|
|
10032
|
+
firstSeenAt: Date;
|
|
10033
|
+
lastSeenAt: Date;
|
|
10034
|
+
metadata: Record<string, unknown> | null;
|
|
10035
|
+
}
|
|
10036
|
+
interface MFACredentialEntity {
|
|
10037
|
+
id: string;
|
|
10038
|
+
userId: string;
|
|
10039
|
+
type: MFAMethod;
|
|
10040
|
+
credentialData: Record<string, unknown>;
|
|
10041
|
+
isPrimary: boolean;
|
|
10042
|
+
verifiedAt: Date | null;
|
|
10043
|
+
createdAt: Date;
|
|
10044
|
+
metadata: Record<string, unknown> | null;
|
|
10045
|
+
}
|
|
10046
|
+
/**
|
|
10047
|
+
* Stores the OAuth transaction state during an OAuth or OIDC authorization flow.
|
|
10048
|
+
*/
|
|
10049
|
+
interface OAuthTransactionEntity {
|
|
10050
|
+
id: string;
|
|
10051
|
+
provider: string;
|
|
10052
|
+
state: string;
|
|
10053
|
+
nonce: string | null;
|
|
10054
|
+
codeVerifier: string | null;
|
|
10055
|
+
redirectURI: string;
|
|
10056
|
+
redirectTo: string | null;
|
|
10057
|
+
userAgent: string | null;
|
|
10058
|
+
fingerprint: string | null;
|
|
10059
|
+
deviceId: string | null;
|
|
10060
|
+
createdAt: Date;
|
|
10061
|
+
expiresAt: Date;
|
|
10062
|
+
metadata: Record<string, unknown> | null;
|
|
10063
|
+
} //#endregion
|
|
10064
|
+
//#region src/@types/adapter.d.ts
|
|
10065
|
+
interface UsersAdapter {
|
|
10066
|
+
/**
|
|
10067
|
+
* User management methods
|
|
10068
|
+
*/
|
|
10069
|
+
createUser(input: Partial<Omit<UserEntity, "createdAt" | "updatedAt">>): Promise<UserEntity>;
|
|
10070
|
+
getUserById(id: string): Promise<UserEntity | null>;
|
|
10071
|
+
getUserByEmail(email: string): Promise<UserEntity | null>;
|
|
10072
|
+
updateUser(id: string, input: Partial<Omit<UserEntity, "createdAt" | "updatedAt">>): Promise<UserEntity>;
|
|
10073
|
+
/**
|
|
10074
|
+
* Soft delete: sets status = "deleted", row is preserved.
|
|
10075
|
+
* Hard delete: removes the row and all owned rows (Accounts, Sessions,
|
|
10076
|
+
* Devices, MfaCredentials). Strategy is set in AdapterConfig, not here.
|
|
10077
|
+
*
|
|
10078
|
+
* Delete an user based on the selected strategy.
|
|
10079
|
+
* - `"soft"`: The user is marked as deleted, but the row is preserved in the database.
|
|
10080
|
+
* - `"hard"`: The user and all associated data (Accounts, Sessions, Devices, MfaCredentials) are permanently removed from the database.
|
|
10081
|
+
*/
|
|
10082
|
+
deleteUser(id: string): Promise<void>;
|
|
10083
|
+
}
|
|
10084
|
+
interface AccountsAdapter {
|
|
10085
|
+
/**
|
|
10086
|
+
* Account management methods
|
|
10087
|
+
*/
|
|
10088
|
+
createAccount(input: Partial<Omit<AccountEntity, "createdAt" | "updatedAt">>): Promise<AccountEntity>;
|
|
10089
|
+
getAccountById(id: string): Promise<AccountEntity | null>;
|
|
10090
|
+
getAccountByProvider(provider: string, providerUserId: string): Promise<AccountEntity | null>;
|
|
10091
|
+
getAccountsByUserId(userId: string): Promise<AccountEntity[]>;
|
|
10092
|
+
updateAccountStatus(id: string, status: AccountEntity["status"]): Promise<AccountEntity>;
|
|
10093
|
+
unlinkAccount(id: string): Promise<void>;
|
|
10094
|
+
}
|
|
10095
|
+
interface OAuthAccountsAdapter {
|
|
10096
|
+
/**
|
|
10097
|
+
* OAuthAccount management methods
|
|
10098
|
+
*/
|
|
10099
|
+
createOAuthAccount(input: Partial<Omit<OAuthAccountEntity, "createdAt" | "updatedAt">>): Promise<OAuthAccountEntity>;
|
|
10100
|
+
getOAuthAccount(accountId: string): Promise<OAuthAccountEntity | null>;
|
|
10101
|
+
updateOAuthTokens(accountId: string, input: Partial<Omit<OAuthAccountEntity, "createdAt" | "updatedAt">>): Promise<OAuthAccountEntity>;
|
|
10102
|
+
}
|
|
10103
|
+
interface CredentialAccountsAdapter {
|
|
10104
|
+
/**
|
|
10105
|
+
* CredentialAccounts management methods.
|
|
10106
|
+
*/
|
|
10107
|
+
createCredentialAccount(input: Partial<Omit<CredentialAccountEntity, "updatedAt">>): Promise<CredentialAccountEntity>;
|
|
10108
|
+
getCredentialAccount(accountId: string): Promise<CredentialAccountEntity | null>;
|
|
10109
|
+
updatePasswordHash(accountId: string, passwordHash: string): Promise<CredentialAccountEntity>;
|
|
10110
|
+
}
|
|
10111
|
+
interface SessionsAdapter {
|
|
10112
|
+
/**
|
|
10113
|
+
* Session management methods.
|
|
10114
|
+
*/
|
|
10115
|
+
createSession(input: Omit<SessionEntity, "createdAt" | "updatedAt" | "lastActivityAt" | "revokedAt">): Promise<SessionEntity>;
|
|
10116
|
+
getSessionByToken(token: string): Promise<SessionWithUserEntity | null>;
|
|
10117
|
+
getSessionById(id: string): Promise<SessionEntity | null>;
|
|
10118
|
+
listSessions(filter: Pick<SessionEntity, "userId" | "status" | "deviceId">): Promise<SessionEntity[]>;
|
|
10119
|
+
updateSession(id: string, input: Partial<Omit<SessionEntity, "createdAt" | "updatedAt" | "revokedAt">>): Promise<SessionEntity>;
|
|
10120
|
+
touchSession(id: string, lastActivityAt: Date): Promise<void>;
|
|
10121
|
+
revokeSession(id: string, reason: RevokeReason): Promise<void>;
|
|
10122
|
+
revokeAllSessions(userId: string, reason: RevokeReason, exceptSessionId?: string): Promise<number>;
|
|
10123
|
+
}
|
|
10124
|
+
interface DevicesAdapter {
|
|
10125
|
+
/**
|
|
10126
|
+
* Device management methods.
|
|
10127
|
+
*/
|
|
10128
|
+
createDevice(input: Omit<DeviceEntity, "id" | "createdAt" | "updatedAt">): Promise<DeviceEntity>;
|
|
10129
|
+
getDeviceById(id: string): Promise<DeviceEntity | null>;
|
|
10130
|
+
getDeviceByFingerprint(userId: string, fingerprint: string): Promise<DeviceEntity | null>;
|
|
10131
|
+
getDevicesByUserId(userId: string): Promise<DeviceEntity[]>;
|
|
10132
|
+
updateDevice(id: string, input: Partial<Omit<DeviceEntity, "createdAt" | "updatedAt">>): Promise<DeviceEntity>;
|
|
10133
|
+
trustDevice(id: string, trusted: boolean): Promise<DeviceEntity>;
|
|
10134
|
+
deleteDevice(id: string): Promise<void>;
|
|
10135
|
+
}
|
|
10136
|
+
interface MFACredentialsAdapter {
|
|
10137
|
+
/**
|
|
10138
|
+
* MFACredentials management methods.
|
|
10139
|
+
*/
|
|
10140
|
+
createMfaCredential(input: Omit<MFACredentialEntity, "id" | "verifiedAt" | "updatedAt">): Promise<MFACredentialEntity>;
|
|
10141
|
+
getMfaCredentialById(id: string): Promise<MFACredentialEntity | null>;
|
|
10142
|
+
getMfaCredentialsByUserId(userId: string): Promise<MFACredentialEntity[]>;
|
|
10143
|
+
getMfaCredentialsByType(userId: string, type: MFAMethod): Promise<MFACredentialEntity[]>;
|
|
10144
|
+
verifyMfaCredential(id: string): Promise<MFACredentialEntity>;
|
|
10145
|
+
updateMfaCredential(id: string, input: Omit<MFACredentialEntity, "id" | "verifiedAt" | "updatedAt">): Promise<MFACredentialEntity>;
|
|
10146
|
+
deleteMfaCredential(id: string): Promise<void>;
|
|
10147
|
+
}
|
|
10148
|
+
interface OAuthTransactionsAdapter {
|
|
10149
|
+
/**
|
|
10150
|
+
* OAuthTransaction management methods.
|
|
10151
|
+
*/
|
|
10152
|
+
createOAuthTransaction(input: OAuthTransactionEntity): Promise<OAuthTransactionEntity>;
|
|
10153
|
+
getOAuthTransactionByState(state: string): Promise<OAuthTransactionEntity | null>;
|
|
10154
|
+
consumeOAuthTransaction(state: string): Promise<OAuthTransactionEntity | null>;
|
|
10155
|
+
deleteExpiredOAuthTransactions(): Promise<number>;
|
|
10156
|
+
}
|
|
10157
|
+
/**
|
|
10158
|
+
* The database adapter interface. Each provider package must implement this.
|
|
10159
|
+
*/
|
|
10160
|
+
interface DatabaseAdapter extends UsersAdapter, AccountsAdapter, OAuthAccountsAdapter, CredentialAccountsAdapter, SessionsAdapter, DevicesAdapter, MFACredentialsAdapter, OAuthTransactionsAdapter {} //#endregion
|
|
10161
|
+
//#region src/session/cookie-manager.d.ts
|
|
10162
|
+
//#endregion
|
|
10163
|
+
//#region src/@types/session.d.ts
|
|
10164
|
+
/** Application user type, inferred from the configured identity schema (defaults to the built-in user shape). */
|
|
10165
|
+
type User = output<typeof identitySchema>;
|
|
10166
|
+
/**
|
|
10167
|
+
* Session data returned by the session endpoint.
|
|
10168
|
+
*/
|
|
10169
|
+
interface Session<DefaultUser extends User = User> {
|
|
10170
|
+
user: DefaultUser;
|
|
10171
|
+
expires: string;
|
|
10172
|
+
}
|
|
10173
|
+
interface CryptoSecret {
|
|
10174
|
+
sign: CryptoKey | CryptoKeyPair | JWK | JsonWebKey | AsymmetricKeyPair;
|
|
10175
|
+
encrypt: CryptoKey | CryptoKeyPair | JWK | JsonWebKey | AsymmetricKeyPair;
|
|
10176
|
+
}
|
|
10177
|
+
interface AsymmetricKeyPair {
|
|
10178
|
+
publicKey: CryptoKey | JWK;
|
|
10179
|
+
privateKey: CryptoKey | JWK;
|
|
10180
|
+
}
|
|
10181
|
+
/**
|
|
10182
|
+
* A symmetric secret or asymmetric key pair used for JWT operations.
|
|
10183
|
+
*
|
|
10184
|
+
* - string / Uint8Array: used as-is for HMAC (signed) or AES (encrypted)
|
|
10185
|
+
* - CryptoKey: Web Crypto API key, for environments that support it
|
|
10186
|
+
* - CryptoKeyPair: asymmetric signing/encryption (RS256, ES256, EdDSA, RSA-OAEP, etc.)
|
|
10187
|
+
*/
|
|
10188
|
+
type SecretKey = string | Uint8Array | CryptoKey | CryptoKeyPair | CryptoSecret | JWK | AsymmetricKeyPair;
|
|
10189
|
+
/**
|
|
10190
|
+
* @todo: add key rotation support for "SecretKey | CryptoKeyPair | [SecretKey | CryptoKeyPair, ...(SecretKey | CryptoKeyPair)[]]"
|
|
10191
|
+
*/
|
|
10192
|
+
type JWTKey = SecretKey;
|
|
10193
|
+
/**
|
|
10194
|
+
* - "signed" → standard JWS (e.g. HS256, RS256, ES256).
|
|
10195
|
+
* - "encrypted" → JWE only. (e.g. A256GCM with RSA-OAEP key wrapping).
|
|
10196
|
+
* - "sealed" → JWS nested inside JWE (signed then encrypted).
|
|
10197
|
+
*/
|
|
10198
|
+
/**
|
|
10199
|
+
* Signing algorithms for "signed" and "sealed" modes.
|
|
10200
|
+
* Symmetric: HS256 | HS384 | HS512
|
|
10201
|
+
* Asymmetric: RS256 | RS384 | RS512 | ES256 | ES384 | ES512 | EdDSA | PS256
|
|
10202
|
+
*/
|
|
10203
|
+
type JWTSigningAlgorithm = "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA" | "PS256";
|
|
10204
|
+
/**
|
|
10205
|
+
* Key-wrapping algorithms for "encrypted" and "sealed" modes.
|
|
10206
|
+
* Symmetric: A128KW | A192KW | A256KW | dir (direct)
|
|
10207
|
+
* ECDH: ECDH-ES | ECDH-ES+A128KW | ECDH-ES+A256KW
|
|
10208
|
+
* RSA: RSA-OAEP | RSA-OAEP-256
|
|
10209
|
+
*/
|
|
10210
|
+
type JWTKeyAlgorithm = "A128KW" | "A192KW" | "A256KW" | "dir" | "ECDH-ES" | "ECDH-ES+A128KW" | "ECDH-ES+A256KW" | "RSA-OAEP" | "RSA-OAEP-256";
|
|
10211
|
+
/** Content-encryption algorithms for JWE. */
|
|
10212
|
+
type JWTEncryptionAlgorithm = "A128CBC-HS256" | "A192CBC-HS384" | "A256CBC-HS512" | "A128GCM" | "A192GCM" | "A256GCM";
|
|
10213
|
+
/** Signed JWT mode configuration. */
|
|
10214
|
+
type JWTSignedMode = {
|
|
10215
|
+
mode: "signed";
|
|
10216
|
+
signingAlgorithm?: JWTSigningAlgorithm;
|
|
10217
|
+
};
|
|
10218
|
+
/** Encrypted JWT mode configuration. */
|
|
10219
|
+
type JWTEncryptedMode = {
|
|
10220
|
+
mode: "encrypted";
|
|
10221
|
+
keyAlgorithm?: JWTKeyAlgorithm;
|
|
10222
|
+
encryptionAlgorithm?: JWTEncryptionAlgorithm;
|
|
10223
|
+
};
|
|
10224
|
+
/** Signed and Encrypted JWT mode configuration. */
|
|
10225
|
+
type JWTSealedMode = {
|
|
10226
|
+
mode?: "sealed";
|
|
10227
|
+
signingAlgorithm?: JWTSigningAlgorithm;
|
|
10228
|
+
keyAlgorithm?: JWTKeyAlgorithm;
|
|
10229
|
+
encryptionAlgorithm?: JWTEncryptionAlgorithm;
|
|
10230
|
+
};
|
|
10231
|
+
/** Discriminated union of JWT wire format: signed JWS, encrypted JWE, or nested sealed (JWS in JWE). */
|
|
10232
|
+
type JWTConfigBase = JWTSignedMode | JWTEncryptedMode | JWTSealedMode;
|
|
10233
|
+
type ExpirationStrategy = "fixed" | "rolling" | "absolute" | "sliding";
|
|
10234
|
+
/**
|
|
10235
|
+
* How session/JWT lifetime is enforced relative to `iat`, absolute caps, and sliding windows.
|
|
10236
|
+
* @deprecated Use `ExpirationStrategy` instead. This will be removed in a future release.
|
|
10237
|
+
*/
|
|
10238
|
+
type JWTExpirationStrategy = ExpirationStrategy;
|
|
10239
|
+
type JWTConfig = Prettify<{
|
|
10240
|
+
/**
|
|
10241
|
+
* Token lifetime.
|
|
10242
|
+
* @deprecated Use `session.maxAge` instead. This will be removed in a future release.
|
|
10243
|
+
*/
|
|
10244
|
+
maxAge?: number;
|
|
10245
|
+
/**
|
|
10246
|
+
* JWT `iss` (issuer) claim. Set this to your app's canonical URL.
|
|
10247
|
+
* @example "https://auth.example.com"
|
|
10248
|
+
*/
|
|
10249
|
+
issuer?: string;
|
|
10250
|
+
/**
|
|
10251
|
+
* JWT `aud` claim. Single value or array for multi-audience tokens.
|
|
10252
|
+
* @example ["https://api.example.com", "https://app.example.com"]
|
|
10253
|
+
*/
|
|
10254
|
+
audience?: string | string[];
|
|
10255
|
+
/**
|
|
10256
|
+
* Maximum absolute session duration in seconds.
|
|
10257
|
+
* Required for "absolute" and "sliding" strategies.
|
|
10258
|
+
* Enforced via jose's maxTokenAge against the iat claim.
|
|
10259
|
+
* @deprecated Use `session.maxDuration` instead. This will be removed in a future release.
|
|
10260
|
+
*/
|
|
10261
|
+
maxExpiration?: number;
|
|
10262
|
+
/**
|
|
10263
|
+
* Policy for renewing or capping token lifetime (pairs with `maxExpiration` where applicable).
|
|
10264
|
+
* @deprecated Use `session.expirationStrategy` instead. This will be removed in a future release.
|
|
10265
|
+
*/
|
|
10266
|
+
expirationStrategy?: JWTExpirationStrategy;
|
|
10267
|
+
} & JWTConfigBase>;
|
|
10268
|
+
interface SessionStatefulConfig {
|
|
10269
|
+
/**
|
|
10270
|
+
* The session deletion strategy when a user is deleted. Defaults to "soft" (mark as deleted, keep for audit).
|
|
10271
|
+
* - "soft": The user is marked as deleted, but the row is preserved in the database.
|
|
10272
|
+
* - "hard": The user and all associated data (Accounts, Sessions, Devices, MfaCredentials) are permanently removed from the database.
|
|
10273
|
+
*/
|
|
10274
|
+
deleteStrategy?: "soft" | "hard";
|
|
10275
|
+
/**
|
|
10276
|
+
* The maximum number of concurrent sessions allowed per user. If exceeded, the oldest session(s) will be revoked.
|
|
10277
|
+
* If not set, there is no limit on concurrent sessions.
|
|
10278
|
+
*/
|
|
10279
|
+
maxSessions?: number;
|
|
10280
|
+
/**
|
|
10281
|
+
* Defines the minimum interval (in seconds) between session "touches" (updates to lastActivityAt) to reduce database writes.
|
|
10282
|
+
*/
|
|
10283
|
+
touchInterval?: number;
|
|
10284
|
+
}
|
|
10285
|
+
interface SessionConfigBase {
|
|
10286
|
+
/**
|
|
10287
|
+
* Session time to live (TTL) in seconds. Determines how long a session is valid before it expires.
|
|
10288
|
+
* If not set, the default is 15 days (60 * 60 * 24 * 15).
|
|
10289
|
+
* @default 1296000 (15 days)
|
|
10290
|
+
*/
|
|
10291
|
+
maxAge?: number;
|
|
10292
|
+
/**
|
|
10293
|
+
* Maximum absolute session duration in seconds.
|
|
10294
|
+
* Required for "absolute" and "sliding" strategies.
|
|
10295
|
+
* Enforced via jose's maxTokenAge against the iat claim.
|
|
10296
|
+
*/
|
|
10297
|
+
maxDuration?: number;
|
|
10298
|
+
/**
|
|
10299
|
+
* The session expiration strategy. Determines how the session's lifetime is calculated and enforced.
|
|
10300
|
+
* - "fixed": The session expires after a fixed duration from the time of creation.
|
|
10301
|
+
* - "rolling": The session expiration is extended on each request, up to the maximum age.
|
|
10302
|
+
* - "absolute": The session has a hard expiration time, regardless of activity.
|
|
10303
|
+
* - "sliding": The session expiration is extended on each request, but cannot exceed the maximum expiration time.
|
|
10304
|
+
*
|
|
10305
|
+
* @default "absolute"
|
|
10306
|
+
*/
|
|
10307
|
+
expirationStrategy?: ExpirationStrategy;
|
|
10308
|
+
/**
|
|
10309
|
+
* The sliding threshold percentage p for the `"sliding"` expiration strategy. Determines when the
|
|
10310
|
+
* session expiration is extended based on the remaining time.
|
|
10311
|
+
* @default 0.5 (50%)
|
|
10312
|
+
*/
|
|
10313
|
+
slidingThreshold?: number;
|
|
10314
|
+
}
|
|
10315
|
+
/**
|
|
10316
|
+
* Stateless JWT strategy.
|
|
10317
|
+
* No database required. Tokens are self-contained and cannot be revoked
|
|
10318
|
+
* before they expire — keep `jwt.maxAge` short or enable refresh tokens.
|
|
10319
|
+
*
|
|
10320
|
+
* @example
|
|
10321
|
+
* {
|
|
10322
|
+
* strategy: "jwt",
|
|
10323
|
+
* jwt: { mode: "sealed", issuer: "https://auth.example.com" },
|
|
10324
|
+
* }
|
|
10325
|
+
*/
|
|
10326
|
+
interface StatelessStrategyConfig extends SessionConfigBase {
|
|
10327
|
+
strategy?: "jwt";
|
|
10328
|
+
jwt?: JWTConfig;
|
|
10329
|
+
}
|
|
10330
|
+
/**
|
|
10331
|
+
* Stateful database strategy.
|
|
10332
|
+
* Database required. Every request hits the DB to validate the session.
|
|
10333
|
+
*
|
|
10334
|
+
* @example
|
|
10335
|
+
* {
|
|
10336
|
+
* strategy: "database",
|
|
10337
|
+
* adapter: prismaAdapter({ client: prismaClient }),
|
|
10338
|
+
* database: { deleteStrategy: "soft", maxSessions: 5 },
|
|
10339
|
+
* }
|
|
10340
|
+
*/
|
|
10341
|
+
interface StatefulStrategyConfig extends SessionConfigBase {
|
|
10342
|
+
strategy: "database";
|
|
10343
|
+
adapter: DatabaseAdapter;
|
|
10344
|
+
database?: SessionStatefulConfig;
|
|
10345
|
+
/**
|
|
10346
|
+
* @deprecated Use `database` instead. This will be removed in a future release.
|
|
10347
|
+
*/
|
|
10348
|
+
session?: SessionStatefulConfig;
|
|
10349
|
+
}
|
|
10350
|
+
/**
|
|
10351
|
+
* The session strategy. Determines which fields below are required.
|
|
10352
|
+
*
|
|
10353
|
+
* - "jwt": stateless. No database needed. JWTs are self-contained.
|
|
10354
|
+
* - "database": stateful. Every request hits the DB to validate the session.
|
|
10355
|
+
* - "hybrid": JWT transport + DB revocation. Best of both for most apps.
|
|
10356
|
+
*
|
|
10357
|
+
* @default "jwt"
|
|
10358
|
+
*/
|
|
10359
|
+
type SessionConfig = StatelessStrategyConfig | StatefulStrategyConfig;
|
|
10360
|
+
/** Result of reading a stateless (JWT) session from a request: session payload and outgoing header mutations. */
|
|
10361
|
+
interface OAuthTokenPayload {
|
|
10362
|
+
/**
|
|
10363
|
+
* The raw access token string issued by the OAuth provider.
|
|
10364
|
+
*/
|
|
10365
|
+
accessToken: string;
|
|
10366
|
+
/**
|
|
10367
|
+
* The expiration time of the access token, in seconds since the epoch (Unix time).
|
|
10368
|
+
* @deprecated
|
|
10369
|
+
*/
|
|
10370
|
+
expiresAt: number;
|
|
10371
|
+
accessTokenExpiresAt?: number;
|
|
10372
|
+
/**
|
|
10373
|
+
* The raw refresh token string issued by the OAuth provider, if applicable.
|
|
10374
|
+
*/
|
|
10375
|
+
refreshToken?: string;
|
|
10376
|
+
/**
|
|
10377
|
+
* The expiration time of the refresh token, in seconds since the epoch (Unix time).
|
|
10378
|
+
*/
|
|
10379
|
+
refreshTokenExpiresAt?: number;
|
|
10380
|
+
/**
|
|
10381
|
+
* The raw ID token string issued by the OIDC provider. Only supported by OIDC-compliant providers.
|
|
10382
|
+
*/
|
|
10383
|
+
idToken?: string;
|
|
10384
|
+
/**
|
|
10385
|
+
* The type of token issued by the OAuth provider. Typically "Bearer" for OAuth 2.0.
|
|
10386
|
+
*/
|
|
10387
|
+
tokenType: "Bearer";
|
|
10388
|
+
/**
|
|
10389
|
+
* The scopes granted to the access token, as an array of strings. These define the permissions the token has.
|
|
10390
|
+
*/
|
|
10391
|
+
scopes: string[];
|
|
10392
|
+
/**
|
|
10393
|
+
* The issuer of the token, typically the OAuth provider's URL. This is used to validate the token's authenticity.
|
|
10394
|
+
*/
|
|
10395
|
+
issuer?: string;
|
|
10396
|
+
/**
|
|
10397
|
+
* The time at which the token was issued, in seconds since the epoch (Unix time).
|
|
10398
|
+
*/
|
|
10399
|
+
issuedAt: number;
|
|
10400
|
+
}
|
|
10401
|
+
//#endregion
|
|
9836
10402
|
//#region src/oauth/github.d.ts
|
|
9837
10403
|
/**
|
|
9838
10404
|
* @see [Get the authenticated user](https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user)
|
|
@@ -10372,6 +10938,7 @@ interface AtlassianProfile {
|
|
|
10372
10938
|
created_at: string;
|
|
10373
10939
|
}
|
|
10374
10940
|
/**
|
|
10941
|
+
* @see [Atlassian - Authorizing OAuth Apps](https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/)
|
|
10375
10942
|
* @see [Atlassian - OAuth Apps](https://developer.atlassian.com/cloud/jira/platform/oauth-2-3lo-apps/)
|
|
10376
10943
|
* @see [Atlassian - My Apps](https://developer.atlassian.com/console/myapps/)
|
|
10377
10944
|
* @see [Atlassian - Retrieve Authenticated User](https://developer.atlassian.com/cloud/jira/software/oauth-2-3lo-apps/#how-do-i-retrieve-the-public-profile-of-the-authenticated-user-)
|
|
@@ -10680,132 +11247,6 @@ interface AuthentikProfile {
|
|
|
10680
11247
|
* @see [Authentik - OAuth 2.0 Provider](https://docs.goauthentik.io/add-secure-apps/providers/oauth2/)
|
|
10681
11248
|
* @see [Authentik - Create an OAuth2 Provider](https://docs.goauthentik.io/add-secure-apps/providers/oauth2/create-oauth2-provider/)
|
|
10682
11249
|
*/
|
|
10683
|
-
//#endregion
|
|
10684
|
-
//#region src/@types/session.d.ts
|
|
10685
|
-
/** Application user type, inferred from the configured identity schema (defaults to the built-in user shape). */
|
|
10686
|
-
type User = output<typeof UserIdentity>;
|
|
10687
|
-
/**
|
|
10688
|
-
* Session data returned by the session endpoint.
|
|
10689
|
-
*/
|
|
10690
|
-
interface Session<DefaultUser extends User = User> {
|
|
10691
|
-
user: DefaultUser;
|
|
10692
|
-
expires: string;
|
|
10693
|
-
}
|
|
10694
|
-
interface CryptoSecret {
|
|
10695
|
-
sign: CryptoKey | CryptoKeyPair | JWK | JsonWebKey | AsymmetricKeyPair;
|
|
10696
|
-
encrypt: CryptoKey | CryptoKeyPair | JWK | JsonWebKey | AsymmetricKeyPair;
|
|
10697
|
-
}
|
|
10698
|
-
interface AsymmetricKeyPair {
|
|
10699
|
-
publicKey: CryptoKey | JWK;
|
|
10700
|
-
privateKey: CryptoKey | JWK;
|
|
10701
|
-
}
|
|
10702
|
-
/**
|
|
10703
|
-
* A symmetric secret or asymmetric key pair used for JWT operations.
|
|
10704
|
-
*
|
|
10705
|
-
* - string / Uint8Array: used as-is for HMAC (signed) or AES (encrypted)
|
|
10706
|
-
* - CryptoKey: Web Crypto API key, for environments that support it
|
|
10707
|
-
* - CryptoKeyPair: asymmetric signing/encryption (RS256, ES256, EdDSA, RSA-OAEP, etc.)
|
|
10708
|
-
*/
|
|
10709
|
-
type SecretKey = string | Uint8Array | CryptoKey | CryptoKeyPair | CryptoSecret | JWK | AsymmetricKeyPair;
|
|
10710
|
-
/**
|
|
10711
|
-
* @todo: add key rotation support for "SecretKey | CryptoKeyPair | [SecretKey | CryptoKeyPair, ...(SecretKey | CryptoKeyPair)[]]"
|
|
10712
|
-
*/
|
|
10713
|
-
type JWTKey = SecretKey;
|
|
10714
|
-
/**
|
|
10715
|
-
* - "signed" → standard JWS (e.g. HS256, RS256, ES256).
|
|
10716
|
-
* - "encrypted" → JWE only. (e.g. A256GCM with RSA-OAEP key wrapping).
|
|
10717
|
-
* - "sealed" → JWS nested inside JWE (signed then encrypted).
|
|
10718
|
-
*/
|
|
10719
|
-
/**
|
|
10720
|
-
* Signing algorithms for "signed" and "sealed" modes.
|
|
10721
|
-
* Symmetric: HS256 | HS384 | HS512
|
|
10722
|
-
* Asymmetric: RS256 | RS384 | RS512 | ES256 | ES384 | ES512 | EdDSA | PS256
|
|
10723
|
-
*/
|
|
10724
|
-
type JWTSigningAlgorithm = "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA" | "PS256";
|
|
10725
|
-
/**
|
|
10726
|
-
* Key-wrapping algorithms for "encrypted" and "sealed" modes.
|
|
10727
|
-
* Symmetric: A128KW | A192KW | A256KW | dir (direct)
|
|
10728
|
-
* ECDH: ECDH-ES | ECDH-ES+A128KW | ECDH-ES+A256KW
|
|
10729
|
-
* RSA: RSA-OAEP | RSA-OAEP-256
|
|
10730
|
-
*/
|
|
10731
|
-
type JWTKeyAlgorithm = "A128KW" | "A192KW" | "A256KW" | "dir" | "ECDH-ES" | "ECDH-ES+A128KW" | "ECDH-ES+A256KW" | "RSA-OAEP" | "RSA-OAEP-256";
|
|
10732
|
-
/** Content-encryption algorithms for JWE. */
|
|
10733
|
-
type JWTEncryptionAlgorithm = "A128CBC-HS256" | "A192CBC-HS384" | "A256CBC-HS512" | "A128GCM" | "A192GCM" | "A256GCM";
|
|
10734
|
-
/** Signed JWT mode configuration. */
|
|
10735
|
-
type JWTSignedMode = {
|
|
10736
|
-
mode: "signed";
|
|
10737
|
-
signingAlgorithm?: JWTSigningAlgorithm;
|
|
10738
|
-
};
|
|
10739
|
-
/** Encrypted JWT mode configuration. */
|
|
10740
|
-
type JWTEncryptedMode = {
|
|
10741
|
-
mode: "encrypted";
|
|
10742
|
-
keyAlgorithm?: JWTKeyAlgorithm;
|
|
10743
|
-
encryptionAlgorithm?: JWTEncryptionAlgorithm;
|
|
10744
|
-
};
|
|
10745
|
-
/** Signed and Encrypted JWT mode configuration. */
|
|
10746
|
-
type JWTSealedMode = {
|
|
10747
|
-
mode?: "sealed";
|
|
10748
|
-
signingAlgorithm?: JWTSigningAlgorithm;
|
|
10749
|
-
keyAlgorithm?: JWTKeyAlgorithm;
|
|
10750
|
-
encryptionAlgorithm?: JWTEncryptionAlgorithm;
|
|
10751
|
-
};
|
|
10752
|
-
/** Discriminated union of JWT wire format: signed JWS, encrypted JWE, or nested sealed (JWS in JWE). */
|
|
10753
|
-
type JWTConfigBase = JWTSignedMode | JWTEncryptedMode | JWTSealedMode;
|
|
10754
|
-
/** How session/JWT lifetime is enforced relative to `iat`, absolute caps, and sliding windows. */
|
|
10755
|
-
type JWTExpirationStrategy = "fixed" | "rolling" | "absolute" | "sliding";
|
|
10756
|
-
type JWTConfig = Prettify<{
|
|
10757
|
-
/**
|
|
10758
|
-
* Token lifetime.
|
|
10759
|
-
*/
|
|
10760
|
-
maxAge?: number;
|
|
10761
|
-
/**
|
|
10762
|
-
* JWT `iss` (issuer) claim. Set this to your app's canonical URL.
|
|
10763
|
-
* @example "https://auth.example.com"
|
|
10764
|
-
*/
|
|
10765
|
-
issuer?: string;
|
|
10766
|
-
/**
|
|
10767
|
-
* JWT `aud` claim. Single value or array for multi-audience tokens.
|
|
10768
|
-
* @example ["https://api.example.com", "https://app.example.com"]
|
|
10769
|
-
*/
|
|
10770
|
-
audience?: string | string[];
|
|
10771
|
-
/**
|
|
10772
|
-
* Maximum absolute session duration in seconds.
|
|
10773
|
-
* Required for "absolute" and "sliding" strategies.
|
|
10774
|
-
* Enforced via jose's maxTokenAge against the iat claim.
|
|
10775
|
-
*/
|
|
10776
|
-
maxExpiration?: number;
|
|
10777
|
-
/**
|
|
10778
|
-
* Policy for renewing or capping token lifetime (pairs with `maxExpiration` where applicable).
|
|
10779
|
-
*/
|
|
10780
|
-
expirationStrategy?: JWTExpirationStrategy;
|
|
10781
|
-
} & JWTConfigBase>;
|
|
10782
|
-
/**
|
|
10783
|
-
* Stateless JWT strategy.
|
|
10784
|
-
* No database required. Tokens are self-contained and cannot be revoked
|
|
10785
|
-
* before they expire — keep `jwt.maxAge` short or enable refresh tokens.
|
|
10786
|
-
*
|
|
10787
|
-
* @example
|
|
10788
|
-
* {
|
|
10789
|
-
* strategy: "jwt",
|
|
10790
|
-
* jwt: { mode: "sealed", maxAge: "15m", issuer: "https://auth.example.com" },
|
|
10791
|
-
* refreshToken: { enabled: true, maxAge: "7d" },
|
|
10792
|
-
* }
|
|
10793
|
-
*/
|
|
10794
|
-
type StatelessStrategyConfig = {
|
|
10795
|
-
strategy?: "jwt";
|
|
10796
|
-
jwt?: JWTConfig;
|
|
10797
|
-
};
|
|
10798
|
-
/**
|
|
10799
|
-
* The session strategy. Determines which fields below are required.
|
|
10800
|
-
*
|
|
10801
|
-
* - "jwt": stateless. No database needed. JWTs are self-contained.
|
|
10802
|
-
* - "database": stateful. Every request hits the DB to validate the session.
|
|
10803
|
-
* - "hybrid": JWT transport + DB revocation. Best of both for most apps.
|
|
10804
|
-
*
|
|
10805
|
-
* @default "jwt"
|
|
10806
|
-
*/
|
|
10807
|
-
type SessionConfig = StatelessStrategyConfig;
|
|
10808
|
-
/** Result of reading a stateless (JWT) session from a request: session payload and outgoing header mutations. */
|
|
10809
11250
|
type OpenIDProvider<Profile extends object = Record<string, any>, DefaultUser = User, Issuer extends string = string> = {
|
|
10810
11251
|
id: string;
|
|
10811
11252
|
name: string;
|
|
@@ -10815,12 +11256,26 @@ type OpenIDProvider<Profile extends object = Record<string, any>, DefaultUser =
|
|
|
10815
11256
|
issuer: Issuer;
|
|
10816
11257
|
clientId?: string;
|
|
10817
11258
|
clientSecret?: string;
|
|
11259
|
+
/**
|
|
11260
|
+
* Refresh window in seconds before the access token expires to attempt a refresh.
|
|
11261
|
+
* Defaults to 300 seconds.
|
|
11262
|
+
*/
|
|
11263
|
+
refreshWindow?: number;
|
|
11264
|
+
/**
|
|
11265
|
+
* Revoke the access token configuration for the OAuth provider. It revokes the access token but not
|
|
11266
|
+
* invalidate the session when there are multiple access token configured for the session.
|
|
11267
|
+
*/
|
|
11268
|
+
revokeToken?: string | {
|
|
11269
|
+
url: string;
|
|
11270
|
+
headers?: Record<string, string>;
|
|
11271
|
+
params?: Record<RevokeTokenParams, RevokeTokenTokenHint>;
|
|
11272
|
+
};
|
|
10818
11273
|
/**
|
|
10819
11274
|
* Override the default OIDC scope (`openid profile email`).
|
|
10820
11275
|
*/
|
|
10821
11276
|
scope?: string;
|
|
10822
11277
|
profile?: (profile: Profile) => DefaultUser | Promise<DefaultUser>;
|
|
10823
|
-
} & GetRouteParams<`/${Issuer}
|
|
11278
|
+
} & Partial<GetRouteParams<`/${Issuer}`>>; //#endregion
|
|
10824
11279
|
//#region src/oauth/index.d.ts
|
|
10825
11280
|
declare const builtInOAuthProviders: {
|
|
10826
11281
|
readonly github: <DefaultUser extends User = {
|
|
@@ -10979,8 +11434,11 @@ type AccessTokenContext = {
|
|
|
10979
11434
|
};
|
|
10980
11435
|
/** Known query parameter names supported when building an OAuth authorization URL. */
|
|
10981
11436
|
type AuthorizeParams = LiteralUnion<"clientId" | "prompt" | "scope" | "responseMode" | "audience" | "loginHint" | "nonce" | "display">;
|
|
11437
|
+
/** Known query parameter names supported when revoking an OAuth token. */
|
|
11438
|
+
type RevokeTokenParams = LiteralUnion<"tokenHint">;
|
|
11439
|
+
type RevokeTokenTokenHint = LiteralUnion<"access_token" | "refresh_token">;
|
|
10982
11440
|
/** OAuth 2.0 `response_type` values used in authorization requests. */
|
|
10983
|
-
type ResponseType = LiteralUnion<"code" | "token" | "refresh_token" | "id_token">;
|
|
11441
|
+
type ResponseType$1 = LiteralUnion<"code" | "token" | "refresh_token" | "id_token">;
|
|
10984
11442
|
/**
|
|
10985
11443
|
* Configuration for an OAuth provider without credentials.
|
|
10986
11444
|
* Use this type when defining provider metadata and endpoints.
|
|
@@ -10996,7 +11454,7 @@ interface OAuthProviderConfig<Profile extends object = Record<string, any>, Defa
|
|
|
10996
11454
|
authorize: string | {
|
|
10997
11455
|
url: string;
|
|
10998
11456
|
params?: Partial<Record<AuthorizeParams, string> & {
|
|
10999
|
-
responseType: ResponseType;
|
|
11457
|
+
responseType: ResponseType$1;
|
|
11000
11458
|
}>;
|
|
11001
11459
|
};
|
|
11002
11460
|
accessToken: string | {
|
|
@@ -11011,6 +11469,32 @@ interface OAuthProviderConfig<Profile extends object = Record<string, any>, Defa
|
|
|
11011
11469
|
url: string;
|
|
11012
11470
|
request: (context: AccessTokenContext) => Profile | Promise<Profile>;
|
|
11013
11471
|
};
|
|
11472
|
+
/**
|
|
11473
|
+
* Refresh token configuration for the OAuth provider. This option allows refreshing access tokens
|
|
11474
|
+
* when they expire.
|
|
11475
|
+
*/
|
|
11476
|
+
refreshToken?: string | {
|
|
11477
|
+
url: string;
|
|
11478
|
+
headers?: Record<string, string>;
|
|
11479
|
+
params?: Record<string, string>;
|
|
11480
|
+
authorization?: {
|
|
11481
|
+
type: "basic" | "credentials";
|
|
11482
|
+
};
|
|
11483
|
+
};
|
|
11484
|
+
/**
|
|
11485
|
+
* Revoke the access token configuration for the OAuth provider. It revokes the access token but not
|
|
11486
|
+
* invalidate the session when there are multiple access token configured for the session.
|
|
11487
|
+
*/
|
|
11488
|
+
revokeToken?: string | {
|
|
11489
|
+
url: string;
|
|
11490
|
+
headers?: Record<string, string>;
|
|
11491
|
+
params?: Record<RevokeTokenParams, RevokeTokenTokenHint>;
|
|
11492
|
+
};
|
|
11493
|
+
/**
|
|
11494
|
+
* Refresh window in seconds before the access token expires to attempt a refresh.
|
|
11495
|
+
* Defaults to 300 seconds.
|
|
11496
|
+
*/
|
|
11497
|
+
refreshWindow?: number;
|
|
11014
11498
|
/**
|
|
11015
11499
|
* @deprecated
|
|
11016
11500
|
* use `authorize.params.scope` instead of `scope`
|
|
@@ -11020,7 +11504,7 @@ interface OAuthProviderConfig<Profile extends object = Record<string, any>, Defa
|
|
|
11020
11504
|
* @deprecated
|
|
11021
11505
|
* use `authorize.params.responseType` instead of `responseType`
|
|
11022
11506
|
*/
|
|
11023
|
-
responseType?: ResponseType;
|
|
11507
|
+
responseType?: ResponseType$1;
|
|
11024
11508
|
profile?: (profile: Profile) => DefaultUser | Promise<DefaultUser>;
|
|
11025
11509
|
}
|
|
11026
11510
|
/**
|
|
@@ -11041,16 +11525,15 @@ interface OAuthProviderCredentials<Profile extends object = Record<string, any>,
|
|
|
11041
11525
|
type AuthAPI<DefaultUser extends User = User, SignUpSchema extends SchemaTypes = ZodObject<any>> = ReturnType<typeof createAuthAPI<DefaultUser, SignUpSchema>>;
|
|
11042
11526
|
/** JWT and crypto helpers bound to the configured identity schema (sign, verify, claims). */
|
|
11043
11527
|
type JoseInstance<DefaultUser extends User = User> = ReturnType<typeof createJoseInstance<DefaultUser>>;
|
|
11044
|
-
/** Normalized internal logger with resolved level and structured log function. */
|
|
11045
11528
|
/** Payload sent to the credentials sign-in endpoint (username/password flow). */
|
|
11046
11529
|
interface CredentialsPayload {
|
|
11047
11530
|
username: string;
|
|
11048
11531
|
password: string;
|
|
11049
11532
|
}
|
|
11050
11533
|
/**
|
|
11051
|
-
*
|
|
11052
|
-
* It includes the credentials sent by the user and hashing utilities.
|
|
11534
|
+
* Interface for the credentials provider.
|
|
11053
11535
|
*/
|
|
11536
|
+
type Handlers = { [method in "GET" | "POST" | "PATCH" | "DELETE" | "ALL"]: (request: Request) => Response | Promise<Response> };
|
|
11054
11537
|
/**
|
|
11055
11538
|
* Public auth instance: programmatic {@link AuthAPI}, {@link JoseInstance}, and HTTP {@link AuthClient} handlers.
|
|
11056
11539
|
*/
|
|
@@ -11066,38 +11549,29 @@ interface AuthInstance<DefaultUser extends User = User, SignUpSchema extends Sch
|
|
|
11066
11549
|
/**
|
|
11067
11550
|
* HTTP handlers for mounting on a router or server.
|
|
11068
11551
|
*/
|
|
11069
|
-
handlers:
|
|
11070
|
-
GET: (request: Request) => Response | Promise<Response>;
|
|
11071
|
-
POST: (request: Request) => Response | Promise<Response>;
|
|
11072
|
-
PATCH: (request: Request) => Response | Promise<Response>;
|
|
11073
|
-
ALL: (request: Request) => Response | Promise<Response>;
|
|
11074
|
-
};
|
|
11552
|
+
handlers: Handlers;
|
|
11075
11553
|
}
|
|
11076
|
-
/**
|
|
11077
|
-
* Extended context used inside the library with both secure and standard cookie materializations.
|
|
11078
|
-
*/
|
|
11554
|
+
/** Minimal token issue/verify surface used by session code paths. */
|
|
11079
11555
|
//#endregion
|
|
11080
11556
|
//#region src/@types/utility.d.ts
|
|
11081
|
-
/** Expands intersection types into a single flat object type for readable editor hints. */
|
|
11082
|
-
type Prettify<T> = { [K in keyof T]: T[K] };
|
|
11083
11557
|
/**
|
|
11084
11558
|
* A string that must be one of the literals in `T`, or any other string (`U`).
|
|
11085
11559
|
* Useful for autocomplete on known keys while still allowing custom values.
|
|
11086
11560
|
*/
|
|
11087
11561
|
type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
|
|
11562
|
+
/** Merges type `B` over `A`, replacing overlapping keys with `B`. */
|
|
11563
|
+
type Merge<A, B> = Omit<A, keyof B> & B;
|
|
11088
11564
|
/**
|
|
11089
11565
|
* Transforms a Zod raw shape so nested `ZodObject` fields become editable (same structure, for config authoring).
|
|
11090
11566
|
*/
|
|
11091
|
-
type ValibotShapeToObject<S extends ObjectEntries> = Merge<InferOutput<ObjectSchema<S, undefined>>, User>;
|
|
11092
|
-
type ArktypeShapeToObject<S extends Type> = S extends Type<infer Shape> ? Wrap<Merge<Shape, User>> : never;
|
|
11093
|
-
type TypeboxShapeToObject<S> = Wrap<Merge<S, User>>;
|
|
11094
|
-
/** Merges type `B` over `A`, replacing overlapping keys with `B`. */
|
|
11095
|
-
type Merge<A, B> = Omit<A, keyof B> & B;
|
|
11096
11567
|
/**
|
|
11097
11568
|
* Infers the runtime object type from a Zod `shape` and intersects it with {@link User}
|
|
11098
11569
|
* so identity fields always include the base user contract.
|
|
11099
11570
|
*/
|
|
11100
11571
|
type ZodShapeToObject<S extends ZodRawShape = ZodRawShape> = Merge<output<ZodObject<S>>, User>;
|
|
11572
|
+
type ValibotShapeToObject<S extends ObjectEntries> = Merge<InferOutput<ObjectSchema<S, undefined>>, User>;
|
|
11573
|
+
type ArktypeShapeToObject<S extends Type> = S extends Type<infer Shape> ? Wrap<Merge<Shape, User>> : never;
|
|
11574
|
+
type TypeboxShapeToObject<S> = Wrap<Merge<S, User>>;
|
|
11101
11575
|
type FromShapeToObject<S> = S extends ZodRawShape ? ZodShapeToObject<S> : S extends ObjectEntries ? ValibotShapeToObject<S> : S extends Type ? ArktypeShapeToObject<S> : S extends TProperties ? TypeboxShapeToObject<S> : S extends User ? S : never;
|
|
11102
11576
|
/** Recursively makes every property optional. */
|
|
11103
11577
|
type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] };
|
|
@@ -11157,10 +11631,6 @@ type AuthActionAPIReturn<Body extends object, ErrorCodes = any> = (Extract<Body,
|
|
|
11157
11631
|
success: true;
|
|
11158
11632
|
}>>;
|
|
11159
11633
|
});
|
|
11160
|
-
/**
|
|
11161
|
-
* Utility to merge the internal router global context (`ctx`) with per-function options.
|
|
11162
|
-
* Used by implementation-level API functions in `src/api/*`.
|
|
11163
|
-
*/
|
|
11164
11634
|
interface APIOptionsWithRedirectTo {
|
|
11165
11635
|
/**
|
|
11166
11636
|
* Optional redirect strategy for server/programmatic API functions.
|
|
@@ -11198,7 +11668,7 @@ interface APIOptionsWithRedirectTo {
|
|
|
11198
11668
|
*/
|
|
11199
11669
|
redirectTo?: string;
|
|
11200
11670
|
}
|
|
11201
|
-
interface APIOptionsWithRequest
|
|
11671
|
+
interface APIOptionsWithRequest {
|
|
11202
11672
|
/**
|
|
11203
11673
|
* Optional `Request` object, useful for constructing the incoming URL on the server side.
|
|
11204
11674
|
* This option is required when the `redirectTo` option is defined, to ensure the `redirectTo`
|
|
@@ -11220,8 +11690,26 @@ interface APIOptionsWithSkipCSRFCheck {
|
|
|
11220
11690
|
* The CSRF token is still required and validated to preserve request integrity.
|
|
11221
11691
|
* Use this only for trusted server-side flows.
|
|
11222
11692
|
* @default `false`
|
|
11693
|
+
* @deprecated Use `doubleSubmitToken` to provide the CSRF token explicitly instead of skipping the check.
|
|
11223
11694
|
*/
|
|
11224
11695
|
skipCSRFCheck?: boolean;
|
|
11696
|
+
/**
|
|
11697
|
+
* Optional token used to perform Double-Submit Cookie validation.
|
|
11698
|
+
*
|
|
11699
|
+
* By default, server-side API functions skip the Double-Submit Cookie validation
|
|
11700
|
+
* because they execute in a trusted server environment where the CSRF token is
|
|
11701
|
+
* not directly available. Providing this value enables the same Double-Submit
|
|
11702
|
+
* Cookie validation performed by the HTTP endpoints.
|
|
11703
|
+
*
|
|
11704
|
+
* Other CSRF protections remain enabled regardless of whether this option is
|
|
11705
|
+
* provided.
|
|
11706
|
+
*
|
|
11707
|
+
* @example
|
|
11708
|
+
* api.signOut({
|
|
11709
|
+
* doubleSubmitToken: "csrf-token-value",
|
|
11710
|
+
* })
|
|
11711
|
+
*/
|
|
11712
|
+
doubleSubmitToken?: string;
|
|
11225
11713
|
}
|
|
11226
11714
|
/** Options to get the current session. */
|
|
11227
11715
|
interface GetSessionAPIOptions {
|
|
@@ -11239,25 +11727,36 @@ type GetSessionAPIReturn<DefaultUser extends User = User> = AuthActionAPIReturn<
|
|
|
11239
11727
|
/**
|
|
11240
11728
|
* Client-side options for `createAuthClient().signIn(...)`.
|
|
11241
11729
|
*/
|
|
11730
|
+
type SignInReturnData = /** redirect: true & redirectTo: string */{
|
|
11731
|
+
success: true;
|
|
11732
|
+
redirect: true;
|
|
11733
|
+
signInURL: string;
|
|
11734
|
+
} /** redirect: false & redirectTo: string */ | {
|
|
11735
|
+
success: true;
|
|
11736
|
+
redirect: false;
|
|
11737
|
+
signInURL: string;
|
|
11738
|
+
} /** redirect: false & redirectTo: null | undefined (not set) */ | {
|
|
11739
|
+
success: false;
|
|
11740
|
+
redirect: false;
|
|
11741
|
+
signInURL: null;
|
|
11742
|
+
};
|
|
11743
|
+
/**
|
|
11744
|
+
* Client-side `signIn` return type.
|
|
11745
|
+
*
|
|
11746
|
+
* - Redirect mode (`redirect: true`): returns `void` because navigation is handled by the client.
|
|
11747
|
+
* - Manual mode (`redirect: false`): returns `signInURL` for caller-controlled navigation.
|
|
11748
|
+
*/
|
|
11242
11749
|
/**
|
|
11243
11750
|
* Server/programmatic options for `signIn` API.
|
|
11244
11751
|
*/
|
|
11245
|
-
interface SignInAPIOptions extends
|
|
11752
|
+
interface SignInAPIOptions extends APIOptionsWithRequest, APIOptionsWithRedirectTo {}
|
|
11246
11753
|
/**
|
|
11247
11754
|
* Server/programmatic `signIn` result.
|
|
11248
11755
|
*
|
|
11249
11756
|
* Includes `signInURL` and response metadata to support both framework-managed redirects
|
|
11250
11757
|
* and custom response handling through `toResponse()`.
|
|
11251
11758
|
*/
|
|
11252
|
-
type SignInAPIReturn = AuthActionAPIReturn<
|
|
11253
|
-
success: true;
|
|
11254
|
-
redirect: boolean;
|
|
11255
|
-
signInURL: string;
|
|
11256
|
-
} | {
|
|
11257
|
-
success: false;
|
|
11258
|
-
redirect: false;
|
|
11259
|
-
signInURL: null;
|
|
11260
|
-
}>;
|
|
11759
|
+
type SignInAPIReturn = AuthActionAPIReturn<SignInReturnData>;
|
|
11261
11760
|
type SignInCredentialsReturnData = /** redirect: true & redirectTo: string */{
|
|
11262
11761
|
success: true;
|
|
11263
11762
|
redirect: true;
|
|
@@ -11280,7 +11779,7 @@ type SignInCredentialsReturnData = /** redirect: true & redirectTo: string */{
|
|
|
11280
11779
|
};
|
|
11281
11780
|
/** Client-side credentials sign-in return type (redirect mode or manual redirect data). */
|
|
11282
11781
|
/** Server/programmatic credentials sign-in options. */
|
|
11283
|
-
interface SignInCredentialsAPIOptions extends
|
|
11782
|
+
interface SignInCredentialsAPIOptions extends APIOptionsWithRequest, APIOptionsWithRedirectTo, APIOptionsWithSkipCSRFCheck {
|
|
11284
11783
|
/**
|
|
11285
11784
|
* Credentials payload validated by the configured `credentials.authorize` function.
|
|
11286
11785
|
* @example
|
|
@@ -11316,7 +11815,7 @@ type SignOutReturnData = /** redirect: true & redirectTo: string */{
|
|
|
11316
11815
|
};
|
|
11317
11816
|
/** Client-side sign-out return type (redirect mode or manual redirect data). */
|
|
11318
11817
|
/** Server/programmatic options for `signOut` API. */
|
|
11319
|
-
interface SignOutAPIOptions extends RequiredKeys<APIOptionsWithRequest, "headers">, APIOptionsWithSkipCSRFCheck {}
|
|
11818
|
+
interface SignOutAPIOptions extends RequiredKeys<APIOptionsWithRequest, "headers">, APIOptionsWithRedirectTo, APIOptionsWithSkipCSRFCheck {}
|
|
11320
11819
|
/** Programmatic sign-out result with redirect metadata and `toResponse()`. */
|
|
11321
11820
|
type SignOutAPIReturn = AuthActionAPIReturn<SignOutReturnData>;
|
|
11322
11821
|
/** Client-side `updateSession` options: partial session payload plus optional redirect behavior. */
|
|
@@ -11343,7 +11842,7 @@ type UpdateSessionReturnData<DefaultUser extends User = User> = /** redirect: tr
|
|
|
11343
11842
|
};
|
|
11344
11843
|
/** Client-side `updateSession` return type. */
|
|
11345
11844
|
/** Server/programmatic options for `updateSession` API. */
|
|
11346
|
-
interface UpdateSessionAPIOptions<DefaultUser extends User = User> extends RequiredKeys<APIOptionsWithRequest, "headers">, APIOptionsWithSkipCSRFCheck {
|
|
11845
|
+
interface UpdateSessionAPIOptions<DefaultUser extends User = User> extends RequiredKeys<APIOptionsWithRequest, "headers">, APIOptionsWithRedirectTo, APIOptionsWithSkipCSRFCheck {
|
|
11347
11846
|
/**
|
|
11348
11847
|
* Partial session payload used to update the current session.
|
|
11349
11848
|
* @see Session
|
|
@@ -11359,7 +11858,7 @@ interface UpdateSessionAPIOptions<DefaultUser extends User = User> extends Requi
|
|
|
11359
11858
|
}
|
|
11360
11859
|
/** Programmatic session update result with redirect metadata and `toResponse()`. */
|
|
11361
11860
|
type UpdateSessionAPIReturn<DefaultUser extends User = User> = AuthActionAPIReturn<UpdateSessionReturnData<DefaultUser>>;
|
|
11362
|
-
interface SignUpAPIOptions<Payload extends Record<string, any> = Record<string, any>> extends
|
|
11861
|
+
interface SignUpAPIOptions<Payload extends Record<string, any> = Record<string, any>> extends APIOptionsWithRequest, APIOptionsWithRedirectTo, APIOptionsWithSkipCSRFCheck {
|
|
11363
11862
|
payload: Payload;
|
|
11364
11863
|
}
|
|
11365
11864
|
type SignUpReturnData = /** redirect: true & redirectTo: string */{
|
|
@@ -11384,5 +11883,95 @@ type SignUpReturnData = /** redirect: true & redirectTo: string */{
|
|
|
11384
11883
|
};
|
|
11385
11884
|
/** Programmatic sign-up result with redirect metadata and `toResponse()`. */
|
|
11386
11885
|
type SignUpAPIReturn = AuthActionAPIReturn<SignUpReturnData>;
|
|
11886
|
+
/**
|
|
11887
|
+
* Client-side `signUp` options: payload plus optional redirect behavior.
|
|
11888
|
+
*/
|
|
11889
|
+
/**
|
|
11890
|
+
* Programmatic options for `getProviderTokens` API.
|
|
11891
|
+
*/
|
|
11892
|
+
interface GetProviderTokensAPIOptions extends Pick<APIOptionsWithRequest, "headers" | "request"> {}
|
|
11893
|
+
type GetProviderTokensData = {
|
|
11894
|
+
success: true;
|
|
11895
|
+
tokens: OAuthTokenPayload;
|
|
11896
|
+
} | {
|
|
11897
|
+
success: false;
|
|
11898
|
+
tokens: null;
|
|
11899
|
+
};
|
|
11900
|
+
/**
|
|
11901
|
+
* Programmatic result for `getProviderTokens` API with response metadata and `toResponse()`.
|
|
11902
|
+
*/
|
|
11903
|
+
type GetProviderTokensAPIReturn = AuthActionAPIReturn<GetProviderTokensData>;
|
|
11904
|
+
/**
|
|
11905
|
+
* Client-side `getProviderTokens` return type.
|
|
11906
|
+
*/
|
|
11907
|
+
/**
|
|
11908
|
+
* Programmatic options for `getAccessToken` API.
|
|
11909
|
+
*/
|
|
11910
|
+
type AccessTokenAPIOptions = GetProviderTokensAPIOptions;
|
|
11911
|
+
type AccessTokenData = {
|
|
11912
|
+
success: true;
|
|
11913
|
+
accessToken: string;
|
|
11914
|
+
} | {
|
|
11915
|
+
success: false;
|
|
11916
|
+
accessToken: null;
|
|
11917
|
+
};
|
|
11918
|
+
/**
|
|
11919
|
+
* Programmatic result for `getAccessToken` API with response metadata and `toResponse()`.
|
|
11920
|
+
*/
|
|
11921
|
+
type AccessTokenAPIReturn = AuthActionAPIReturn<AccessTokenData>;
|
|
11922
|
+
/**
|
|
11923
|
+
* Programmatic options for `refreshUserInfo` API.
|
|
11924
|
+
*/
|
|
11925
|
+
interface RefreshUserInfoAPIOptions extends APIOptionsWithRequest, APIOptionsWithSkipCSRFCheck {}
|
|
11926
|
+
type RefreshUserInfoData<DefaultUser extends User = User> = {
|
|
11927
|
+
success: true;
|
|
11928
|
+
session: Session<DefaultUser>;
|
|
11929
|
+
} | {
|
|
11930
|
+
success: false;
|
|
11931
|
+
session: null;
|
|
11932
|
+
};
|
|
11933
|
+
/**
|
|
11934
|
+
* Programmatic result for `refreshUserInfo` API with response metadata and `toResponse()`.
|
|
11935
|
+
*/
|
|
11936
|
+
type RefreshUserInfoAPIReturn<DefaultUser extends User = User> = AuthActionAPIReturn<RefreshUserInfoData<DefaultUser>>;
|
|
11937
|
+
/**
|
|
11938
|
+
* Programmatic options for `revokeToken` API.
|
|
11939
|
+
*/
|
|
11940
|
+
interface RevokeTokenAPIOptions extends APIOptionsWithRequest, APIOptionsWithSkipCSRFCheck {}
|
|
11941
|
+
type RevokeTokenData = {
|
|
11942
|
+
success: true;
|
|
11943
|
+
} | {
|
|
11944
|
+
success: false;
|
|
11945
|
+
};
|
|
11946
|
+
/**
|
|
11947
|
+
* Programmatic result for `revokeToken` API with response metadata and `toResponse()`.
|
|
11948
|
+
*/
|
|
11949
|
+
type RevokeTokenAPIReturn = AuthActionAPIReturn<RevokeTokenData>;
|
|
11950
|
+
/**
|
|
11951
|
+
* Programmatic options for `disconnectProvider` API.
|
|
11952
|
+
*/
|
|
11953
|
+
interface DisconnectProviderAPIOptions extends APIOptionsWithRequest, APIOptionsWithSkipCSRFCheck {}
|
|
11954
|
+
type DisconnectProviderData = {
|
|
11955
|
+
success: true;
|
|
11956
|
+
} | {
|
|
11957
|
+
success: false;
|
|
11958
|
+
};
|
|
11959
|
+
/**
|
|
11960
|
+
* Programmatic result for `disconnectProvider` API with response metadata and `toResponse()`.
|
|
11961
|
+
*/
|
|
11962
|
+
type DisconnectProviderAPIReturn = AuthActionAPIReturn<DisconnectProviderData>;
|
|
11963
|
+
type ProviderConnectedAPIOptions = APIOptionsWithRequest;
|
|
11964
|
+
type ProviderConnectedData = {
|
|
11965
|
+
success: true;
|
|
11966
|
+
connected: boolean;
|
|
11967
|
+
} | {
|
|
11968
|
+
success: false;
|
|
11969
|
+
connected: false;
|
|
11970
|
+
};
|
|
11971
|
+
type ProviderConnectedAPIReturn = AuthActionAPIReturn<ProviderConnectedData>; //#endregion
|
|
11972
|
+
//#region src/@types/index.d.ts
|
|
11973
|
+
/**
|
|
11974
|
+
* JWT payload structure that includes a mandatory `token` field used to verify CSRF Tokens
|
|
11975
|
+
*/
|
|
11387
11976
|
//#endregion
|
|
11388
|
-
export {
|
|
11977
|
+
export { SignUpAPIReturn as A, SignInAPIOptions as C, SignOutAPIOptions as D, SignInCredentialsAPIReturn as E, EncodeJWTOptions as F, TypedJWTPayload as I, UpdateSessionAPIReturn as M, Wrap as N, SignOutAPIReturn as O, DecodeJWTOptions as P, Session as S, SignInCredentialsAPIOptions as T, RefreshUserInfoAPIOptions as _, DeepPartial as a, RevokeTokenAPIOptions as b, FromShapeToObject as c, GetSessionAPIOptions as d, GetSessionAPIReturn as f, ProviderConnectedAPIReturn as g, ProviderConnectedAPIOptions as h, BuiltInOAuthProvider as i, UpdateSessionAPIOptions as j, SignUpAPIOptions as k, GetProviderTokensAPIOptions as l, LiteralUnion as m, AccessTokenAPIReturn as n, DisconnectProviderAPIOptions as o, Handlers as p, AuthInstance as r, DisconnectProviderAPIReturn as s, AccessTokenAPIOptions as t, GetProviderTokensAPIReturn as u, RefreshUserInfoAPIReturn as v, SignInAPIReturn as w, RevokeTokenAPIReturn as x, RemoveIndexSignature as y };
|