@aura-stack/next 0.2.0 → 0.2.2

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/client.cjs CHANGED
@@ -1 +1 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./context.cjs`);let t=require(`@aura-stack/react`);exports.AuthProvider=e.AuthProvider,Object.defineProperty(exports,`createAuthClient`,{enumerable:!0,get:function(){return t.createAuthClient}}),Object.defineProperty(exports,`useAuthActions`,{enumerable:!0,get:function(){return t.useAuthActions}}),Object.defineProperty(exports,`useSession`,{enumerable:!0,get:function(){return t.useSession}}),Object.defineProperty(exports,`useSignIn`,{enumerable:!0,get:function(){return t.useSignIn}}),Object.defineProperty(exports,`useSignInCredentials`,{enumerable:!0,get:function(){return t.useSignInCredentials}}),Object.defineProperty(exports,`useSignOut`,{enumerable:!0,get:function(){return t.useSignOut}}),Object.defineProperty(exports,`useSignUp`,{enumerable:!0,get:function(){return t.useSignUp}}),Object.defineProperty(exports,`useUpdateSession`,{enumerable:!0,get:function(){return t.useUpdateSession}});
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./context.cjs`);let t=require(`@aura-stack/react`);exports.AuthProvider=e.AuthProvider,Object.defineProperty(exports,`createAuthClient`,{enumerable:!0,get:function(){return t.createAuthClient}}),Object.defineProperty(exports,`useAuthActions`,{enumerable:!0,get:function(){return t.useAuthActions}}),Object.defineProperty(exports,`useProviderTokens`,{enumerable:!0,get:function(){return t.useProviderTokens}}),Object.defineProperty(exports,`useSession`,{enumerable:!0,get:function(){return t.useSession}}),Object.defineProperty(exports,`useSignIn`,{enumerable:!0,get:function(){return t.useSignIn}}),Object.defineProperty(exports,`useSignInCredentials`,{enumerable:!0,get:function(){return t.useSignInCredentials}}),Object.defineProperty(exports,`useSignOut`,{enumerable:!0,get:function(){return t.useSignOut}}),Object.defineProperty(exports,`useSignUp`,{enumerable:!0,get:function(){return t.useSignUp}}),Object.defineProperty(exports,`useUpdateSession`,{enumerable:!0,get:function(){return t.useUpdateSession}});
package/dist/client.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { AuthProvider } from "./context.js";
2
- import { AuthClientOptions, AuthProviderProps, createAuthClient, useAuthActions, useSession, useSignIn, useSignInCredentials, useSignOut, useSignUp, useUpdateSession } from "@aura-stack/react";
3
- export { type AuthClientOptions, AuthProvider, type AuthProviderProps, createAuthClient, useAuthActions, useSession, useSignIn, useSignInCredentials, useSignOut, useSignUp, useUpdateSession };
2
+ import { AuthClientOptions, AuthProviderProps, createAuthClient, useAuthActions, useProviderTokens, useSession, useSignIn, useSignInCredentials, useSignOut, useSignUp, useUpdateSession } from "@aura-stack/react";
3
+ export { type AuthClientOptions, AuthProvider, type AuthProviderProps, createAuthClient, useAuthActions, useProviderTokens, useSession, useSignIn, useSignInCredentials, useSignOut, useSignUp, useUpdateSession };
package/dist/client.js CHANGED
@@ -1 +1 @@
1
- "use client";import{AuthProvider as e}from"./context.js";import{createAuthClient as t,useAuthActions as n,useSession as r,useSignIn as i,useSignInCredentials as a,useSignOut as o,useSignUp as s,useUpdateSession as c}from"@aura-stack/react";export{e as AuthProvider,t as createAuthClient,n as useAuthActions,r as useSession,i as useSignIn,a as useSignInCredentials,o as useSignOut,s as useSignUp,c as useUpdateSession};
1
+ "use client";import{AuthProvider as e}from"./context.js";import{createAuthClient as t,useAuthActions as n,useProviderTokens as r,useSession as i,useSignIn as a,useSignInCredentials as o,useSignOut as s,useSignUp as c,useUpdateSession as l}from"@aura-stack/react";export{e as AuthProvider,t as createAuthClient,n as useAuthActions,r as useProviderTokens,i as useSession,a as useSignIn,o as useSignInCredentials,s as useSignOut,c as useSignUp,l as useUpdateSession};
package/dist/context.cjs CHANGED
@@ -1 +1 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@aura-stack/react/context`),t=require(`next/navigation`),n=require(`react/jsx-runtime`);const r=({client:r,children:i,initialSession:a,redirect:o})=>{let s=(0,t.useRouter)();return(0,n.jsx)(e.AuthProvider,{client:r,initialSession:a,redirect:o??(e=>s.push(e)),children:i})};exports.AuthProvider=r;
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@aura-stack/react/context`),t=require(`next/navigation.js`),n=require(`react/jsx-runtime`);const r=({client:r,children:i,initialSession:a,redirect:o})=>{let s=(0,t.useRouter)();return(0,n.jsx)(e.AuthProvider,{client:r,initialSession:a,redirect:o??(e=>s.push(e)),children:i})};exports.AuthProvider=r;
package/dist/context.js CHANGED
@@ -1 +1 @@
1
- "use client";import{AuthProvider as e}from"@aura-stack/react/context";import{useRouter as t}from"next/navigation";import{jsx as n}from"react/jsx-runtime";const r=({client:r,children:i,initialSession:a,redirect:o})=>{let s=t();return n(e,{client:r,initialSession:a,redirect:o??(e=>s.push(e)),children:i})};export{r as AuthProvider};
1
+ "use client";import{AuthProvider as e}from"@aura-stack/react/context";import{useRouter as t}from"next/navigation.js";import{jsx as n}from"react/jsx-runtime";const r=({client:r,children:i,initialSession:a,redirect:o})=>{let s=t();return n(e,{client:r,initialSession:a,redirect:o??(e=>s.push(e)),children:i})};export{r as AuthProvider};
@@ -0,0 +1 @@
1
+ var e=require(`@aura-stack/react/identity/arktype`);Object.keys(e).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
@@ -0,0 +1 @@
1
+ export * from "@aura-stack/react/identity/arktype";
@@ -0,0 +1 @@
1
+ export*from"@aura-stack/react/identity/arktype";export{};
@@ -0,0 +1 @@
1
+ var e=require(`@aura-stack/react/identity/index`);Object.keys(e).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
@@ -0,0 +1 @@
1
+ export * from "@aura-stack/react/identity/index";
@@ -0,0 +1 @@
1
+ export*from"@aura-stack/react/identity/index";export{};
@@ -0,0 +1 @@
1
+ var e=require(`@aura-stack/react/identity/typebox`);Object.keys(e).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
@@ -0,0 +1 @@
1
+ export * from "@aura-stack/react/identity/typebox";
@@ -0,0 +1 @@
1
+ export*from"@aura-stack/react/identity/typebox";export{};
@@ -0,0 +1 @@
1
+ var e=require(`@aura-stack/react/identity/valibot`);Object.keys(e).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
@@ -0,0 +1 @@
1
+ export * from "@aura-stack/react/identity/valibot";
@@ -0,0 +1 @@
1
+ export*from"@aura-stack/react/identity/valibot";export{};
@@ -0,0 +1 @@
1
+ var e=require(`@aura-stack/react/identity/zod`);Object.keys(e).forEach(function(t){t!==`default`&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
@@ -0,0 +1 @@
1
+ export * from "@aura-stack/react/identity/zod";
@@ -0,0 +1 @@
1
+ export*from"@aura-stack/react/identity/zod";export{};
@@ -9692,7 +9692,7 @@ interface DecodeJWTOptions {
9692
9692
  decrypt?: DecryptOptions;
9693
9693
  }
9694
9694
  //#endregion
9695
- //#region ../core/dist/index-DIcbmH1M.d.ts
9695
+ //#region ../core/dist/index-tmedkhtX.d.ts
9696
9696
  //#endregion
9697
9697
  //#region src/jose.d.ts
9698
9698
  /**
@@ -9717,8 +9717,8 @@ declare const createJoseInstance: <DefaultUser extends User = User>(secret?: JWT
9717
9717
  encodeJWT: (payload: TypedJWTPayload<Partial<DefaultUser>>, options?: EncodeJWTOptions) => Promise<string>;
9718
9718
  decodeJWT: (token: string, options?: DecodeJWTOptions) => Promise<TypedJWTPayload<DefaultUser>>;
9719
9719
  }; //#endregion
9720
- //#region src/shared/identity.d.ts
9721
- declare const UserIdentity: ZodObject<{
9720
+ //#region src/identity/zod.d.ts
9721
+ declare const identitySchema$3: ZodObject<{
9722
9722
  sub: ZodString;
9723
9723
  name: ZodOptional<ZodNullable<ZodString>>;
9724
9724
  image: ZodOptional<ZodNullable<ZodString>>;
@@ -9808,6 +9808,7 @@ declare const createAuthAPI: <DefaultUser extends User = User, SignUpSchema exte
9808
9808
  * })
9809
9809
  */
9810
9810
  updateSession: (options: UpdateSessionAPIOptions<DefaultUser>) => Promise<UpdateSessionAPIReturn<DefaultUser>>;
9811
+ getProviderTokens: (oauth: LiteralUnion<BuiltInOAuthProvider>, options?: GetProviderTokensAPIOptions) => Promise<GetProviderTokensAPIReturn>;
9811
9812
  /**
9812
9813
  * Signs out the current session on the server-side. It implements CSRF Protection by default, for
9813
9814
  * server-side calls it only verifies and validates the CSRF Token, it also provides Double-Submit
@@ -9833,6 +9834,190 @@ declare const createAuthAPI: <DefaultUser extends User = User, SignUpSchema exte
9833
9834
  * Each message includes facility, severity, msgId, and default message.
9834
9835
  */
9835
9836
  //#endregion
9837
+ //#region src/@types/session.d.ts
9838
+ /** Application user type, inferred from the configured identity schema (defaults to the built-in user shape). */
9839
+ type User = output<typeof identitySchema$3>;
9840
+ /**
9841
+ * Session data returned by the session endpoint.
9842
+ */
9843
+ interface Session<DefaultUser extends User = User> {
9844
+ user: DefaultUser;
9845
+ expires: string;
9846
+ }
9847
+ interface CryptoSecret {
9848
+ sign: CryptoKey | CryptoKeyPair | JWK | JsonWebKey | AsymmetricKeyPair;
9849
+ encrypt: CryptoKey | CryptoKeyPair | JWK | JsonWebKey | AsymmetricKeyPair;
9850
+ }
9851
+ interface AsymmetricKeyPair {
9852
+ publicKey: CryptoKey | JWK;
9853
+ privateKey: CryptoKey | JWK;
9854
+ }
9855
+ /**
9856
+ * A symmetric secret or asymmetric key pair used for JWT operations.
9857
+ *
9858
+ * - string / Uint8Array: used as-is for HMAC (signed) or AES (encrypted)
9859
+ * - CryptoKey: Web Crypto API key, for environments that support it
9860
+ * - CryptoKeyPair: asymmetric signing/encryption (RS256, ES256, EdDSA, RSA-OAEP, etc.)
9861
+ */
9862
+ type SecretKey = string | Uint8Array | CryptoKey | CryptoKeyPair | CryptoSecret | JWK | AsymmetricKeyPair;
9863
+ /**
9864
+ * @todo: add key rotation support for "SecretKey | CryptoKeyPair | [SecretKey | CryptoKeyPair, ...(SecretKey | CryptoKeyPair)[]]"
9865
+ */
9866
+ type JWTKey = SecretKey;
9867
+ /**
9868
+ * - "signed" → standard JWS (e.g. HS256, RS256, ES256).
9869
+ * - "encrypted" → JWE only. (e.g. A256GCM with RSA-OAEP key wrapping).
9870
+ * - "sealed" → JWS nested inside JWE (signed then encrypted).
9871
+ */
9872
+ /**
9873
+ * Signing algorithms for "signed" and "sealed" modes.
9874
+ * Symmetric: HS256 | HS384 | HS512
9875
+ * Asymmetric: RS256 | RS384 | RS512 | ES256 | ES384 | ES512 | EdDSA | PS256
9876
+ */
9877
+ type JWTSigningAlgorithm = "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES512" | "EdDSA" | "PS256";
9878
+ /**
9879
+ * Key-wrapping algorithms for "encrypted" and "sealed" modes.
9880
+ * Symmetric: A128KW | A192KW | A256KW | dir (direct)
9881
+ * ECDH: ECDH-ES | ECDH-ES+A128KW | ECDH-ES+A256KW
9882
+ * RSA: RSA-OAEP | RSA-OAEP-256
9883
+ */
9884
+ type JWTKeyAlgorithm = "A128KW" | "A192KW" | "A256KW" | "dir" | "ECDH-ES" | "ECDH-ES+A128KW" | "ECDH-ES+A256KW" | "RSA-OAEP" | "RSA-OAEP-256";
9885
+ /** Content-encryption algorithms for JWE. */
9886
+ type JWTEncryptionAlgorithm = "A128CBC-HS256" | "A192CBC-HS384" | "A256CBC-HS512" | "A128GCM" | "A192GCM" | "A256GCM";
9887
+ /** Signed JWT mode configuration. */
9888
+ type JWTSignedMode = {
9889
+ mode: "signed";
9890
+ signingAlgorithm?: JWTSigningAlgorithm;
9891
+ };
9892
+ /** Encrypted JWT mode configuration. */
9893
+ type JWTEncryptedMode = {
9894
+ mode: "encrypted";
9895
+ keyAlgorithm?: JWTKeyAlgorithm;
9896
+ encryptionAlgorithm?: JWTEncryptionAlgorithm;
9897
+ };
9898
+ /** Signed and Encrypted JWT mode configuration. */
9899
+ type JWTSealedMode = {
9900
+ mode?: "sealed";
9901
+ signingAlgorithm?: JWTSigningAlgorithm;
9902
+ keyAlgorithm?: JWTKeyAlgorithm;
9903
+ encryptionAlgorithm?: JWTEncryptionAlgorithm;
9904
+ };
9905
+ /** Discriminated union of JWT wire format: signed JWS, encrypted JWE, or nested sealed (JWS in JWE). */
9906
+ type JWTConfigBase = JWTSignedMode | JWTEncryptedMode | JWTSealedMode;
9907
+ /** How session/JWT lifetime is enforced relative to `iat`, absolute caps, and sliding windows. */
9908
+ type JWTExpirationStrategy = "fixed" | "rolling" | "absolute" | "sliding";
9909
+ type JWTConfig = Prettify<{
9910
+ /**
9911
+ * Token lifetime.
9912
+ */
9913
+ maxAge?: number;
9914
+ /**
9915
+ * JWT `iss` (issuer) claim. Set this to your app's canonical URL.
9916
+ * @example "https://auth.example.com"
9917
+ */
9918
+ issuer?: string;
9919
+ /**
9920
+ * JWT `aud` claim. Single value or array for multi-audience tokens.
9921
+ * @example ["https://api.example.com", "https://app.example.com"]
9922
+ */
9923
+ audience?: string | string[];
9924
+ /**
9925
+ * Maximum absolute session duration in seconds.
9926
+ * Required for "absolute" and "sliding" strategies.
9927
+ * Enforced via jose's maxTokenAge against the iat claim.
9928
+ */
9929
+ maxExpiration?: number;
9930
+ /**
9931
+ * Policy for renewing or capping token lifetime (pairs with `maxExpiration` where applicable).
9932
+ */
9933
+ expirationStrategy?: JWTExpirationStrategy;
9934
+ } & JWTConfigBase>;
9935
+ /**
9936
+ * Stateless JWT strategy.
9937
+ * No database required. Tokens are self-contained and cannot be revoked
9938
+ * before they expire — keep `jwt.maxAge` short or enable refresh tokens.
9939
+ *
9940
+ * @example
9941
+ * {
9942
+ * strategy: "jwt",
9943
+ * jwt: { mode: "sealed", maxAge: "15m", issuer: "https://auth.example.com" },
9944
+ * refreshToken: { enabled: true, maxAge: "7d" },
9945
+ * }
9946
+ */
9947
+ type StatelessStrategyConfig = {
9948
+ strategy?: "jwt";
9949
+ jwt?: JWTConfig;
9950
+ };
9951
+ /**
9952
+ * The session strategy. Determines which fields below are required.
9953
+ *
9954
+ * - "jwt": stateless. No database needed. JWTs are self-contained.
9955
+ * - "database": stateful. Every request hits the DB to validate the session.
9956
+ * - "hybrid": JWT transport + DB revocation. Best of both for most apps.
9957
+ *
9958
+ * @default "jwt"
9959
+ */
9960
+ type SessionConfig = StatelessStrategyConfig;
9961
+ /** Result of reading a stateless (JWT) session from a request: session payload and outgoing header mutations. */
9962
+ interface OAuthTokenPayload {
9963
+ /**
9964
+ * The raw access token string issued by the OAuth provider.
9965
+ */
9966
+ accessToken: string;
9967
+ /**
9968
+ * The expiration time of the access token, in seconds since the epoch (Unix time).
9969
+ */
9970
+ expiresAt: number;
9971
+ /**
9972
+ * The raw refresh token string issued by the OAuth provider, if applicable.
9973
+ */
9974
+ refreshToken?: string;
9975
+ /**
9976
+ * The expiration time of the refresh token, in seconds since the epoch (Unix time).
9977
+ */
9978
+ refreshTokenExpiresAt?: number;
9979
+ /**
9980
+ * The raw ID token string issued by the OIDC provider. Only supported by OIDC-compliant providers.
9981
+ */
9982
+ idToken?: string;
9983
+ /**
9984
+ * The type of token issued by the OAuth provider. Typically "Bearer" for OAuth 2.0.
9985
+ */
9986
+ tokenType: "Bearer";
9987
+ /**
9988
+ * The scopes granted to the access token, as an array of strings. These define the permissions the token has.
9989
+ */
9990
+ scopes: string[];
9991
+ /**
9992
+ * The issuer of the token, typically the OAuth provider's URL. This is used to validate the token's authenticity.
9993
+ */
9994
+ issuer?: string;
9995
+ /**
9996
+ * The time at which the token was issued, in seconds since the epoch (Unix time).
9997
+ */
9998
+ issuedAt: number;
9999
+ } //#endregion
10000
+ //#region src/validator/registry.d.ts
10001
+ type OpenIDProvider<Profile extends object = Record<string, any>, DefaultUser = User, Issuer extends string = string> = {
10002
+ id: string;
10003
+ name: string;
10004
+ /**
10005
+ * URL to concatenating the string /.well-known/openid-configuration to the Issuer.
10006
+ */
10007
+ issuer: Issuer;
10008
+ clientId?: string;
10009
+ clientSecret?: string;
10010
+ /**
10011
+ * Refresh window in seconds before the access token expires to attempt a refresh.
10012
+ * Defaults to 300 seconds.
10013
+ */
10014
+ refreshWindow?: number;
10015
+ /**
10016
+ * Override the default OIDC scope (`openid profile email`).
10017
+ */
10018
+ scope?: string;
10019
+ profile?: (profile: Profile) => DefaultUser | Promise<DefaultUser>;
10020
+ } & GetRouteParams<`/${Issuer}`>; //#endregion
9836
10021
  //#region src/oauth/github.d.ts
9837
10022
  /**
9838
10023
  * @see [Get the authenticated user](https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#get-the-authenticated-user)
@@ -10681,146 +10866,6 @@ interface AuthentikProfile {
10681
10866
  * @see [Authentik - Create an OAuth2 Provider](https://docs.goauthentik.io/add-secure-apps/providers/oauth2/create-oauth2-provider/)
10682
10867
  */
10683
10868
  //#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
- type OpenIDProvider<Profile extends object = Record<string, any>, DefaultUser = User, Issuer extends string = string> = {
10810
- id: string;
10811
- name: string;
10812
- /**
10813
- * URL to concatenating the string /.well-known/openid-configuration to the Issuer.
10814
- */
10815
- issuer: Issuer;
10816
- clientId?: string;
10817
- clientSecret?: string;
10818
- /**
10819
- * Override the default OIDC scope (`openid profile email`).
10820
- */
10821
- scope?: string;
10822
- profile?: (profile: Profile) => DefaultUser | Promise<DefaultUser>;
10823
- } & GetRouteParams<`/${Issuer}`>; //#endregion
10824
10869
  //#region src/oauth/index.d.ts
10825
10870
  declare const builtInOAuthProviders: {
10826
10871
  readonly github: <DefaultUser extends User = {
@@ -11011,6 +11056,20 @@ interface OAuthProviderConfig<Profile extends object = Record<string, any>, Defa
11011
11056
  url: string;
11012
11057
  request: (context: AccessTokenContext) => Profile | Promise<Profile>;
11013
11058
  };
11059
+ /**
11060
+ * Refresh token configuration for the OAuth provider. This option allows refreshing access tokens
11061
+ * when they expire.
11062
+ */
11063
+ refreshToken?: string | {
11064
+ url: string;
11065
+ headers?: Record<string, string>;
11066
+ params?: Record<string, string>;
11067
+ };
11068
+ /**
11069
+ * Refresh window in seconds before the access token expires to attempt a refresh.
11070
+ * Defaults to 300 seconds.
11071
+ */
11072
+ refreshWindow?: number;
11014
11073
  /**
11015
11074
  * @deprecated
11016
11075
  * use `authorize.params.scope` instead of `scope`
@@ -11085,19 +11144,19 @@ type Prettify<T> = { [K in keyof T]: T[K] };
11085
11144
  * Useful for autocomplete on known keys while still allowing custom values.
11086
11145
  */
11087
11146
  type LiteralUnion<T extends U, U = string> = T | (U & Record<never, never>);
11147
+ /** Merges type `B` over `A`, replacing overlapping keys with `B`. */
11148
+ type Merge<A, B> = Omit<A, keyof B> & B;
11088
11149
  /**
11089
11150
  * Transforms a Zod raw shape so nested `ZodObject` fields become editable (same structure, for config authoring).
11090
11151
  */
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
11152
  /**
11097
11153
  * Infers the runtime object type from a Zod `shape` and intersects it with {@link User}
11098
11154
  * so identity fields always include the base user contract.
11099
11155
  */
11100
11156
  type ZodShapeToObject<S extends ZodRawShape = ZodRawShape> = Merge<output<ZodObject<S>>, User>;
11157
+ type ValibotShapeToObject<S extends ObjectEntries> = Merge<InferOutput<ObjectSchema<S, undefined>>, User>;
11158
+ type ArktypeShapeToObject<S extends Type> = S extends Type<infer Shape> ? Wrap<Merge<Shape, User>> : never;
11159
+ type TypeboxShapeToObject<S> = Wrap<Merge<S, User>>;
11101
11160
  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
11161
  /** Recursively makes every property optional. */
11103
11162
  type DeepPartial<T> = { [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P] };
@@ -11384,5 +11443,14 @@ type SignUpReturnData = /** redirect: true & redirectTo: string */{
11384
11443
  };
11385
11444
  /** Programmatic sign-up result with redirect metadata and `toResponse()`. */
11386
11445
  type SignUpAPIReturn = AuthActionAPIReturn<SignUpReturnData>;
11446
+ interface GetProviderTokensAPIOptions extends Pick<APIOptionsWithRequest, "headers" | "request">, APIOptionsWithSkipCSRFCheck {}
11447
+ type GetProviderTokensData = {
11448
+ success: true;
11449
+ tokens: OAuthTokenPayload;
11450
+ } | {
11451
+ success: false;
11452
+ tokens: null;
11453
+ };
11454
+ type GetProviderTokensAPIReturn = AuthActionAPIReturn<GetProviderTokensData>;
11387
11455
  //#endregion
11388
- export { UpdateSessionAPIOptions as _, GetSessionAPIReturn as a, EncodeJWTOptions as b, Session as c, SignInCredentialsAPIOptions as d, SignInCredentialsAPIReturn as f, SignUpAPIReturn as g, SignUpAPIOptions as h, GetSessionAPIOptions as i, SignInAPIOptions as l, SignOutAPIReturn as m, BuiltInOAuthProvider as n, LiteralUnion as o, SignOutAPIOptions as p, FromShapeToObject as r, Prettify as s, AuthInstance as t, SignInAPIReturn as u, UpdateSessionAPIReturn as v, TypedJWTPayload as x, DecodeJWTOptions as y };
11456
+ export { DecodeJWTOptions as C, Wrap as S, TypedJWTPayload as T, SignOutAPIReturn as _, GetProviderTokensAPIReturn as a, UpdateSessionAPIOptions as b, LiteralUnion as c, Session as d, SignInAPIOptions as f, SignOutAPIOptions as g, SignInCredentialsAPIReturn as h, GetProviderTokensAPIOptions as i, Prettify as l, SignInCredentialsAPIOptions as m, BuiltInOAuthProvider as n, GetSessionAPIOptions as o, SignInAPIReturn as p, FromShapeToObject as r, GetSessionAPIReturn as s, AuthInstance as t, RemoveIndexSignature as u, SignUpAPIOptions as v, EncodeJWTOptions as w, UpdateSessionAPIReturn as x, SignUpAPIReturn as y };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`next/navigation`),t=require(`@aura-stack/react/server`),n=require(`next/headers`),r=require(`@aura-stack/react/cookies`);const i=async e=>{let t=await(0,n.cookies)(),i=e.getSetCookie();for(let e of i){let{name:n,value:i,...a}=(0,r.parseSetCookie)(e);t.set(n,i??``,a)}},a=({api:e})=>async t=>{try{let r=await e.getSession({...t,headers:await(0,n.headers)()});return r.success?r.session:null}catch{return console.error(`[error:server] getSession - Failed to retrieve session`),null}},o=({api:t})=>async(r,i)=>{let a=await t.signIn(r,{headers:await(0,n.headers)(),...i,redirect:!!i?.redirect});return i?.redirect===!1?a:a.success&&a.signInURL?(0,e.redirect)(a.signInURL):a},s=({api:t})=>async r=>{let a=await t.signInCredentials({headers:await(0,n.headers)(),...r,redirect:!!r.redirect});return await i(a.headers),a.success&&a.redirectURL?(0,e.redirect)(a.redirectURL):a},c=({api:t})=>async r=>{let a=await t.updateSession({headers:await(0,n.headers)(),...r,redirect:!!r.redirect,session:r.session});return await i(a.headers),a.success&&a.redirectURL?(0,e.redirect)(a.redirectURL):a},l=({api:t})=>async r=>{let a=await t.signOut({headers:await(0,n.headers)(),...r,redirect:!!r?.redirect});return await i(a.headers),a.success&&a.redirectURL?(0,e.redirect)(a.redirectURL):a},u=e=>({getSession:a(e),signIn:o(e),signInCredentials:s(e),updateSession:c(e),signOut:l(e)}),d=e=>{let n=(0,t.createAuth)(e);return{core:n,api:u(n),handlers:n.handlers}};exports.createAuth=d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`next/navigation.js`),t=require(`@aura-stack/react/server`),n=require(`next/headers.js`),r=require(`@aura-stack/react/cookies`);const i=async e=>{let t=await(0,n.cookies)(),i=e.getSetCookie();for(let e of i){let{name:n,value:i,...a}=(0,r.parseSetCookie)(e);t.set(n,i??``,a)}},a=({api:e})=>async t=>{try{let r=await e.getSession({...t,headers:await(0,n.headers)()});return r.success?r.session:null}catch{return console.error(`[error:server] getSession - Failed to retrieve session`),null}},o=({api:t})=>async(r,i)=>{let a=await t.signIn(r,{headers:await(0,n.headers)(),...i,redirect:!!i?.redirect});return i?.redirect===!1?a:a.success&&a.signInURL?(0,e.redirect)(a.signInURL):a},s=({api:t})=>async r=>{let a=await t.signInCredentials({headers:await(0,n.headers)(),...r,redirect:!!r.redirect});return await i(a.headers),a.success&&a.redirectURL?(0,e.redirect)(a.redirectURL):a},c=({api:t})=>async r=>{let a=await t.updateSession({headers:await(0,n.headers)(),...r,redirect:!!r.redirect,session:r.session});return await i(a.headers),a.success&&a.redirectURL?(0,e.redirect)(a.redirectURL):a},l=({api:e})=>async(t,r)=>await e.getProviderTokens(t,{headers:await(0,n.headers)(),...r}),u=({api:t})=>async r=>{let a=await t.signOut({headers:await(0,n.headers)(),...r,redirect:!!r?.redirect});return await i(a.headers),a.success&&a.redirectURL?(0,e.redirect)(a.redirectURL):a},d=e=>({getSession:a(e),signIn:o(e),signInCredentials:s(e),updateSession:c(e),getProviderTokens:l(e),signOut:u(e)}),f=e=>{let n=(0,t.createAuth)(e);return{core:n,api:d(n),handlers:n.handlers}};exports.createAuth=f;