@aura-stack/next 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +128 -0
- package/dist/@types/index.cjs +0 -0
- package/dist/@types/index.d.ts +3 -0
- package/dist/@types/index.js +1 -0
- package/dist/_core/cookies.cjs +1 -0
- package/dist/_core/cookies.d.ts +1 -0
- package/dist/_core/cookies.js +1 -0
- package/dist/_core/crypto.cjs +1 -0
- package/dist/_core/crypto.d.ts +1 -0
- package/dist/_core/crypto.js +1 -0
- package/dist/_core/identity.cjs +1 -0
- package/dist/_core/identity.d.ts +1 -0
- package/dist/_core/identity.js +1 -0
- package/dist/_core/shared.cjs +1 -0
- package/dist/_core/shared.d.ts +1 -0
- package/dist/_core/shared.js +1 -0
- package/dist/client.cjs +1 -0
- package/dist/client.d.ts +24 -0
- package/dist/client.js +1 -0
- package/dist/core-BDwHYePg.d.ts +3 -0
- package/dist/index-B0R6c-K9.d.ts +45 -0
- package/dist/index-eKek4f4_.d.ts +10973 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.js +1 -0
- package/dist/oauth/atlassian.cjs +1 -0
- package/dist/oauth/atlassian.d.ts +1 -0
- package/dist/oauth/atlassian.js +1 -0
- package/dist/oauth/bitbucket.cjs +1 -0
- package/dist/oauth/bitbucket.d.ts +1 -0
- package/dist/oauth/bitbucket.js +1 -0
- package/dist/oauth/click-up.cjs +1 -0
- package/dist/oauth/click-up.d.ts +1 -0
- package/dist/oauth/click-up.js +1 -0
- package/dist/oauth/discord.cjs +1 -0
- package/dist/oauth/discord.d.ts +1 -0
- package/dist/oauth/discord.js +1 -0
- package/dist/oauth/dribbble.cjs +1 -0
- package/dist/oauth/dribbble.d.ts +1 -0
- package/dist/oauth/dribbble.js +1 -0
- package/dist/oauth/dropbox.cjs +1 -0
- package/dist/oauth/dropbox.d.ts +1 -0
- package/dist/oauth/dropbox.js +1 -0
- package/dist/oauth/figma.cjs +1 -0
- package/dist/oauth/figma.d.ts +1 -0
- package/dist/oauth/figma.js +1 -0
- package/dist/oauth/github.cjs +1 -0
- package/dist/oauth/github.d.ts +1 -0
- package/dist/oauth/github.js +1 -0
- package/dist/oauth/gitlab.cjs +1 -0
- package/dist/oauth/gitlab.d.ts +1 -0
- package/dist/oauth/gitlab.js +1 -0
- package/dist/oauth/index.cjs +1 -0
- package/dist/oauth/index.d.ts +1 -0
- package/dist/oauth/index.js +1 -0
- package/dist/oauth/mailchimp.cjs +1 -0
- package/dist/oauth/mailchimp.d.ts +1 -0
- package/dist/oauth/mailchimp.js +1 -0
- package/dist/oauth/notion.cjs +1 -0
- package/dist/oauth/notion.d.ts +1 -0
- package/dist/oauth/notion.js +1 -0
- package/dist/oauth/pinterest.cjs +1 -0
- package/dist/oauth/pinterest.d.ts +1 -0
- package/dist/oauth/pinterest.js +1 -0
- package/dist/oauth/spotify.cjs +1 -0
- package/dist/oauth/spotify.d.ts +1 -0
- package/dist/oauth/spotify.js +1 -0
- package/dist/oauth/strava.cjs +1 -0
- package/dist/oauth/strava.d.ts +1 -0
- package/dist/oauth/strava.js +1 -0
- package/dist/oauth/twitch.cjs +1 -0
- package/dist/oauth/twitch.d.ts +1 -0
- package/dist/oauth/twitch.js +1 -0
- package/dist/oauth/x.cjs +1 -0
- package/dist/oauth/x.d.ts +1 -0
- package/dist/oauth/x.js +1 -0
- package/dist/pages/index.cjs +1 -0
- package/dist/pages/index.d.ts +346 -0
- package/dist/pages/index.js +1 -0
- package/package.json +143 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +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;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { t as core_d_exports } from "./core-BDwHYePg.js";
|
|
2
|
+
import { a as NextUpdateSessionReturn, n as NextSignInReturn, r as NextSignOutReturn, t as NextSignInCredentials } from "./index-B0R6c-K9.js";
|
|
3
|
+
import { c as Session$1, d as SignInCredentialsAPIOptions$1, h as UpdateSessionAPIOptions$1, i as GetSessionAPIOptions, l as SignInAPIOptions$1, n as BuiltInOAuthProvider, o as LiteralUnion, p as SignOutAPIOptions$1, s as Prettify$1, t as AuthInstance$1 } from "./index-eKek4f4_.js";
|
|
4
|
+
import { AuthConfig as AuthConfig$1 } from "@aura-stack/react";
|
|
5
|
+
import { Identities } from "@aura-stack/react/identity";
|
|
6
|
+
import { FromShapeToObject } from "@aura-stack/react/types";
|
|
7
|
+
|
|
8
|
+
//#region src/createAuth.d.ts
|
|
9
|
+
declare const createAuth: <Identity extends Identities>(config: AuthConfig$1<Identity>) => {
|
|
10
|
+
/**
|
|
11
|
+
* The core auth instance. It can be used to advanced use cases, such as creating custom behaviors.
|
|
12
|
+
* For most use cases, the `api` property should be sufficient, as it provides a higher-level API for common authentication tasks.
|
|
13
|
+
*/
|
|
14
|
+
core: AuthInstance$1<FromShapeToObject<Identity>>;
|
|
15
|
+
/**
|
|
16
|
+
* Built-in API functions for server-side operations related to the auth flows.
|
|
17
|
+
*/
|
|
18
|
+
api: {
|
|
19
|
+
getSession: (options?: GetSessionAPIOptions) => Promise<Session$1<FromShapeToObject<Identity>> | null>;
|
|
20
|
+
signIn: <Options extends SignInAPIOptions$1>(provider: LiteralUnion<BuiltInOAuthProvider>, options?: Options | undefined) => Promise<NextSignInReturn<Options>>;
|
|
21
|
+
signInCredentials: <Options extends SignInCredentialsAPIOptions$1>(options: Options) => Promise<NextSignInCredentials<Options>>;
|
|
22
|
+
updateSession: <Options extends Prettify$1<Omit<UpdateSessionAPIOptions$1<FromShapeToObject<Identity>>, "headers"> & {
|
|
23
|
+
headers?: HeadersInit;
|
|
24
|
+
}>>(options: Options) => Promise<NextUpdateSessionReturn<Options, FromShapeToObject<Identity>>>;
|
|
25
|
+
signOut: <Options extends SignOutAPIOptions$1>(options?: Partial<Options> | undefined) => Promise<NextSignOutReturn<Options>>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The handlers object contains the HTTP request handlers.
|
|
29
|
+
*/
|
|
30
|
+
handlers: {
|
|
31
|
+
GET: (request: Request) => Response | Promise<Response>;
|
|
32
|
+
POST: (request: Request) => Response | Promise<Response>;
|
|
33
|
+
PATCH: (request: Request) => Response | Promise<Response>;
|
|
34
|
+
ALL: (request: Request) => Response | Promise<Response>;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
type AuthConfig = core_d_exports.AuthConfig;
|
|
38
|
+
type AuthInstance = core_d_exports.AuthInstance;
|
|
39
|
+
type Session = core_d_exports.Session;
|
|
40
|
+
type User = core_d_exports.User;
|
|
41
|
+
export { type AuthConfig, type AuthInstance, type Session, type User, createAuth };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{redirect as e}from"next/navigation";import{createAuth as t}from"@aura-stack/react/server";import{cookies as n,headers as r}from"next/headers";import{parseSetCookie as i}from"@aura-stack/react/cookies";const a=async e=>{let t=await n(),r=e.getSetCookie();for(let e of r){let{name:n,value:r,...a}=i(e);t.set(n,r??``,a)}},o=({api:e})=>async t=>{try{let n=await e.getSession({...t,headers:await r()});return n.success?n.session:null}catch{return console.error(`[error:server] getSession - Failed to retrieve session`),null}},s=({api:t})=>async(n,i)=>{let a=await t.signIn(n,{headers:await r(),...i,redirect:!!i?.redirect});return i?.redirect===!1?a:a.success&&a.signInURL?e(a.signInURL):a},c=({api:t})=>async n=>{let i=await t.signInCredentials({headers:await r(),...n,redirect:!!n.redirect});return await a(i.headers),i.success&&i.redirectURL?e(i.redirectURL):i},l=({api:t})=>async n=>{let i=await t.updateSession({headers:await r(),...n,redirect:!!n.redirect,session:n.session});return await a(i.headers),i.success&&i.redirectURL?e(i.redirectURL):i},u=({api:t})=>async n=>{let i=await t.signOut({headers:await r(),...n,redirect:!!n?.redirect});return await a(i.headers),i.success&&i.redirectURL?e(i.redirectURL):i},d=e=>({getSession:o(e),signIn:s(e),signInCredentials:c(e),updateSession:l(e),signOut:u(e)}),f=e=>{let n=t(e);return{core:n,api:d(n),handlers:n.handlers}};export{f as createAuth};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/atlassian`);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/oauth/atlassian";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/atlassian";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/bitbucket`);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/oauth/bitbucket";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/bitbucket";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/click-up`);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/oauth/click-up";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/click-up";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/discord`);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/oauth/discord";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/discord";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/dribbble`);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/oauth/dribbble";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/dribbble";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/dropbox`);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/oauth/dropbox";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/dropbox";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/figma`);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/oauth/figma";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/figma";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/github`);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/oauth/github";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/github";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/gitlab`);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/oauth/gitlab";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/gitlab";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/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/oauth/index";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/index";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/mailchimp`);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/oauth/mailchimp";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/mailchimp";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/notion`);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/oauth/notion";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/notion";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/pinterest`);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/oauth/pinterest";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/pinterest";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/spotify`);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/oauth/spotify";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/spotify";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/strava`);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/oauth/strava";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/strava";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/twitch`);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/oauth/twitch";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/twitch";export{};
|
package/dist/oauth/x.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=require(`@aura-stack/react/oauth/x`);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/oauth/x";
|
package/dist/oauth/x.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export*from"@aura-stack/react/oauth/x";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`@aura-stack/react/context`),t=require(`react/jsx-runtime`),n=require(`@aura-stack/react/server`),r=require(`next/router.js`);const i=e=>`${e.headers[`x-forwarded-proto`]??`http`}://${e.headers[`x-forwarded-host`]??e.headers.host}`,a=(e,t)=>{for(let[n,r]of t.entries())n.toLowerCase()===`set-cookie`?e.setHeader(`Set-Cookie`,t.getSetCookie()):e.setHeader(n,r)},o=e=>async(t,n)=>{let r=t.method??`GET`,o=e[r];if(!o)return n.status(405).json({error:`Method ${r} Not Allowed`});let s=new URL(t.url,i(t)),c=new Request(s,{method:r,headers:new Headers(t.headers),body:r!==`GET`&&r!==`HEAD`?t.body:void 0});try{let e=await o(c);e.status>=300&&e.status<400&&!t.url?.includes(`/auth/signIn/`)&&!t.url?.includes(`/auth/callback/`)&&e.headers.delete(`Location`),a(n,e.headers);let r=await e.json();return n.status(e.status).json(r)}catch{return n.status(500).json({error:`Internal Server Error`})}},s=e=>{let t=(0,n.createAuth)(e);return{...t,toHandler:o(t.handlers)}},c=({client:n,children:i,initialSession:a,redirect:o})=>{let s=(0,r.useRouter)();return(0,t.jsx)(e.AuthProvider,{client:n,initialSession:a,redirect:o??(e=>s.push(e)),children:i})};exports.AuthProvider=c,exports.createAuth=s;
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { t as core_d_exports } from "../core-BDwHYePg.js";
|
|
2
|
+
import { _ as DecodeJWTOptions, a as GetSessionAPIReturn, d as SignInCredentialsAPIOptions, f as SignInCredentialsAPIReturn, g as UpdateSessionAPIReturn, h as UpdateSessionAPIOptions, i as GetSessionAPIOptions, l as SignInAPIOptions, m as SignOutAPIReturn, n as BuiltInOAuthProvider, o as LiteralUnion, p as SignOutAPIOptions, r as FromShapeToObject, u as SignInAPIReturn, v as EncodeJWTOptions, y as TypedJWTPayload } from "../index-eKek4f4_.js";
|
|
3
|
+
import { AuthConfig as AuthConfig$1 } from "@aura-stack/react";
|
|
4
|
+
import { AuthProviderProps } from "@aura-stack/react/context";
|
|
5
|
+
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
|
+
import { Identities } from "@aura-stack/react/identity";
|
|
7
|
+
import * as _$next from "next";
|
|
8
|
+
|
|
9
|
+
//#region ../../node_modules/.deno/jose@6.2.2/node_modules/jose/dist/types/types.d.ts
|
|
10
|
+
/** Generic JSON Web Key Parameters. */
|
|
11
|
+
interface JWKParameters {
|
|
12
|
+
/** JWK "kty" (Key Type) Parameter */
|
|
13
|
+
kty?: string;
|
|
14
|
+
/**
|
|
15
|
+
* JWK "alg" (Algorithm) Parameter
|
|
16
|
+
*
|
|
17
|
+
* @see {@link https://github.com/panva/jose/issues/210 Algorithm Key Requirements}
|
|
18
|
+
*/
|
|
19
|
+
alg?: string;
|
|
20
|
+
/** JWK "key_ops" (Key Operations) Parameter */
|
|
21
|
+
key_ops?: string[];
|
|
22
|
+
/** JWK "ext" (Extractable) Parameter */
|
|
23
|
+
ext?: boolean;
|
|
24
|
+
/** JWK "use" (Public Key Use) Parameter */
|
|
25
|
+
use?: string;
|
|
26
|
+
/** JWK "x5c" (X.509 Certificate Chain) Parameter */
|
|
27
|
+
x5c?: string[];
|
|
28
|
+
/** JWK "x5t" (X.509 Certificate SHA-1 Thumbprint) Parameter */
|
|
29
|
+
x5t?: string;
|
|
30
|
+
/** JWK "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Parameter */
|
|
31
|
+
'x5t#S256'?: string;
|
|
32
|
+
/** JWK "x5u" (X.509 URL) Parameter */
|
|
33
|
+
x5u?: string;
|
|
34
|
+
/** JWK "kid" (Key ID) Parameter */
|
|
35
|
+
kid?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* JSON Web Key ({@link https://www.rfc-editor.org/rfc/rfc7517 JWK}). "RSA", "EC", "OKP", "AKP", and
|
|
39
|
+
* "oct" key types are supported.
|
|
40
|
+
*
|
|
41
|
+
* @see {@link JWK_AKP_Public}
|
|
42
|
+
* @see {@link JWK_AKP_Private}
|
|
43
|
+
* @see {@link JWK_OKP_Public}
|
|
44
|
+
* @see {@link JWK_OKP_Private}
|
|
45
|
+
* @see {@link JWK_EC_Public}
|
|
46
|
+
* @see {@link JWK_EC_Private}
|
|
47
|
+
* @see {@link JWK_RSA_Public}
|
|
48
|
+
* @see {@link JWK_RSA_Private}
|
|
49
|
+
* @see {@link JWK_oct}
|
|
50
|
+
*/
|
|
51
|
+
interface JWK extends JWKParameters {
|
|
52
|
+
/**
|
|
53
|
+
* - EC JWK "crv" (Curve) Parameter
|
|
54
|
+
* - OKP JWK "crv" (The Subtype of Key Pair) Parameter
|
|
55
|
+
*/
|
|
56
|
+
crv?: string;
|
|
57
|
+
/**
|
|
58
|
+
* - Private RSA JWK "d" (Private Exponent) Parameter
|
|
59
|
+
* - Private EC JWK "d" (ECC Private Key) Parameter
|
|
60
|
+
* - Private OKP JWK "d" (The Private Key) Parameter
|
|
61
|
+
*/
|
|
62
|
+
d?: string;
|
|
63
|
+
/** Private RSA JWK "dp" (First Factor CRT Exponent) Parameter */
|
|
64
|
+
dp?: string;
|
|
65
|
+
/** Private RSA JWK "dq" (Second Factor CRT Exponent) Parameter */
|
|
66
|
+
dq?: string;
|
|
67
|
+
/** RSA JWK "e" (Exponent) Parameter */
|
|
68
|
+
e?: string;
|
|
69
|
+
/** Oct JWK "k" (Key Value) Parameter */
|
|
70
|
+
k?: string;
|
|
71
|
+
/** RSA JWK "n" (Modulus) Parameter */
|
|
72
|
+
n?: string;
|
|
73
|
+
/** Private RSA JWK "p" (First Prime Factor) Parameter */
|
|
74
|
+
p?: string;
|
|
75
|
+
/** Private RSA JWK "q" (Second Prime Factor) Parameter */
|
|
76
|
+
q?: string;
|
|
77
|
+
/** Private RSA JWK "qi" (First CRT Coefficient) Parameter */
|
|
78
|
+
qi?: string;
|
|
79
|
+
/**
|
|
80
|
+
* - EC JWK "x" (X Coordinate) Parameter
|
|
81
|
+
* - OKP JWK "x" (The public key) Parameter
|
|
82
|
+
*/
|
|
83
|
+
x?: string;
|
|
84
|
+
/** EC JWK "y" (Y Coordinate) Parameter */
|
|
85
|
+
y?: string;
|
|
86
|
+
/** AKP JWK "pub" (Public Key) Parameter */
|
|
87
|
+
pub?: string;
|
|
88
|
+
/** AKP JWK "priv" (Private key) Parameter */
|
|
89
|
+
priv?: string;
|
|
90
|
+
}
|
|
91
|
+
/** Header Parameters common to JWE and JWS */
|
|
92
|
+
interface JoseHeaderParameters {
|
|
93
|
+
/** "kid" (Key ID) Header Parameter */
|
|
94
|
+
kid?: string;
|
|
95
|
+
/** "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter */
|
|
96
|
+
x5t?: string;
|
|
97
|
+
/** "x5c" (X.509 Certificate Chain) Header Parameter */
|
|
98
|
+
x5c?: string[];
|
|
99
|
+
/** "x5u" (X.509 URL) Header Parameter */
|
|
100
|
+
x5u?: string;
|
|
101
|
+
/** "jku" (JWK Set URL) Header Parameter */
|
|
102
|
+
jku?: string;
|
|
103
|
+
/** "jwk" (JSON Web Key) Header Parameter */
|
|
104
|
+
jwk?: Pick<JWK, 'kty' | 'crv' | 'x' | 'y' | 'e' | 'n' | 'alg' | 'pub'>;
|
|
105
|
+
/** "typ" (Type) Header Parameter */
|
|
106
|
+
typ?: string;
|
|
107
|
+
/** "cty" (Content Type) Header Parameter */
|
|
108
|
+
cty?: string;
|
|
109
|
+
}
|
|
110
|
+
/** Recognized JWS Header Parameters, any other Header Members may also be present. */
|
|
111
|
+
interface JWSHeaderParameters extends JoseHeaderParameters {
|
|
112
|
+
/**
|
|
113
|
+
* JWS "alg" (Algorithm) Header Parameter
|
|
114
|
+
*
|
|
115
|
+
* @see {@link https://github.com/panva/jose/issues/210#jws-alg Algorithm Key Requirements}
|
|
116
|
+
*/
|
|
117
|
+
alg?: string;
|
|
118
|
+
/**
|
|
119
|
+
* This JWS Extension Header Parameter modifies the JWS Payload representation and the JWS Signing
|
|
120
|
+
* Input computation as per {@link https://www.rfc-editor.org/rfc/rfc7797 RFC7797}.
|
|
121
|
+
*/
|
|
122
|
+
b64?: boolean;
|
|
123
|
+
/** JWS "crit" (Critical) Header Parameter */
|
|
124
|
+
crit?: string[];
|
|
125
|
+
/** Any other JWS Header member. */
|
|
126
|
+
[propName: string]: unknown;
|
|
127
|
+
}
|
|
128
|
+
/** Recognized JWE Header Parameters, any other Header members may also be present. */
|
|
129
|
+
interface JWEHeaderParameters extends JoseHeaderParameters {
|
|
130
|
+
/**
|
|
131
|
+
* JWE "alg" (Algorithm) Header Parameter
|
|
132
|
+
*
|
|
133
|
+
* @see {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}
|
|
134
|
+
*/
|
|
135
|
+
alg?: string;
|
|
136
|
+
/**
|
|
137
|
+
* JWE "enc" (Encryption Algorithm) Header Parameter
|
|
138
|
+
*
|
|
139
|
+
* @see {@link https://github.com/panva/jose/issues/210#jwe-alg Algorithm Key Requirements}
|
|
140
|
+
*/
|
|
141
|
+
enc?: string;
|
|
142
|
+
/** JWE "crit" (Critical) Header Parameter */
|
|
143
|
+
crit?: string[];
|
|
144
|
+
/**
|
|
145
|
+
* JWE "zip" (Compression Algorithm) Header Parameter.
|
|
146
|
+
*
|
|
147
|
+
* The only supported value is `"DEF"` (DEFLATE). Requires the `CompressionStream` /
|
|
148
|
+
* `DecompressionStream` APIs to be available in the runtime.
|
|
149
|
+
*
|
|
150
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc7516#section-4.1.3 JWE "zip" Header Parameter}
|
|
151
|
+
*/
|
|
152
|
+
zip?: string;
|
|
153
|
+
/** Any other JWE Header member. */
|
|
154
|
+
[propName: string]: unknown;
|
|
155
|
+
}
|
|
156
|
+
/** Shared Interface with a "crit" property for all sign, verify, encrypt and decrypt operations. */
|
|
157
|
+
interface CritOption {
|
|
158
|
+
/**
|
|
159
|
+
* An object with keys representing recognized "crit" (Critical) Header Parameter names. The value
|
|
160
|
+
* for those is either `true` or `false`. `true` when the Header Parameter MUST be integrity
|
|
161
|
+
* protected, `false` when it's irrelevant.
|
|
162
|
+
*
|
|
163
|
+
* This makes the "Extension Header Parameter "..." is not recognized" error go away.
|
|
164
|
+
*
|
|
165
|
+
* Use this when a given JWS/JWT/JWE profile requires the use of proprietary non-registered "crit"
|
|
166
|
+
* (Critical) Header Parameters. This will only make sure the Header Parameter is syntactically
|
|
167
|
+
* correct when provided and that it is optionally integrity protected. It will not process the
|
|
168
|
+
* Header Parameter in any way or reject the operation if it is missing. You MUST still verify the
|
|
169
|
+
* Header Parameter was present and process it according to the profile's validation steps after
|
|
170
|
+
* the operation succeeds.
|
|
171
|
+
*
|
|
172
|
+
* The JWS extension Header Parameter `b64` is always recognized and processed properly. No other
|
|
173
|
+
* registered Header Parameters that need this kind of default built-in treatment are currently
|
|
174
|
+
* available.
|
|
175
|
+
*/
|
|
176
|
+
crit?: {
|
|
177
|
+
[propName: string]: boolean;
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/** JWE Decryption options. */
|
|
181
|
+
interface DecryptOptions extends CritOption {
|
|
182
|
+
/**
|
|
183
|
+
* A list of accepted JWE "alg" (Algorithm) Header Parameter values. By default all "alg"
|
|
184
|
+
* (Algorithm) Header Parameter values applicable for the used key/secret are allowed except for
|
|
185
|
+
* all PBES2 Key Management Algorithms, these need to be explicitly allowed using this option.
|
|
186
|
+
*/
|
|
187
|
+
keyManagementAlgorithms?: string[];
|
|
188
|
+
/**
|
|
189
|
+
* A list of accepted JWE "enc" (Encryption Algorithm) Header Parameter values. By default all
|
|
190
|
+
* "enc" (Encryption Algorithm) values applicable for the used key/secret are allowed.
|
|
191
|
+
*/
|
|
192
|
+
contentEncryptionAlgorithms?: string[];
|
|
193
|
+
/**
|
|
194
|
+
* (PBES2 Key Management Algorithms only) Maximum allowed "p2c" (PBES2 Count) Header Parameter
|
|
195
|
+
* value. The PBKDF2 iteration count defines the algorithm's computational expense. By default
|
|
196
|
+
* this value is set to 10000.
|
|
197
|
+
*/
|
|
198
|
+
maxPBES2Count?: number;
|
|
199
|
+
/**
|
|
200
|
+
* Maximum allowed size (in bytes) of the decompressed plaintext when the JWE `"zip"` (Compression
|
|
201
|
+
* Algorithm) Header Parameter is present. By default this value is set to 250000 (250 KB). The
|
|
202
|
+
* value must be `0`, a positive safe integer, or `Infinity`.
|
|
203
|
+
*
|
|
204
|
+
* Set to `0` to reject all compressed JWEs during decryption.
|
|
205
|
+
*
|
|
206
|
+
* Set to `Infinity` to disable the decompressed size limit.
|
|
207
|
+
*/
|
|
208
|
+
maxDecompressedLength?: number;
|
|
209
|
+
}
|
|
210
|
+
/** JWT Claims Set verification options. */
|
|
211
|
+
interface JWTClaimVerificationOptions {
|
|
212
|
+
/**
|
|
213
|
+
* Expected JWT "aud" (Audience) Claim value(s).
|
|
214
|
+
*
|
|
215
|
+
* This option makes the JWT "aud" (Audience) Claim presence required.
|
|
216
|
+
*/
|
|
217
|
+
audience?: string | string[];
|
|
218
|
+
/**
|
|
219
|
+
* Clock skew tolerance
|
|
220
|
+
*
|
|
221
|
+
* - In seconds when number (e.g. 5)
|
|
222
|
+
* - Resolved into a number of seconds when a string (e.g. "5 seconds", "10 minutes", "2 hours").
|
|
223
|
+
*
|
|
224
|
+
* Used when validating the JWT "nbf" (Not Before) and "exp" (Expiration Time) claims, and when
|
|
225
|
+
* validating the "iat" (Issued At) claim if the {@link maxTokenAge `maxTokenAge` option} is set.
|
|
226
|
+
*/
|
|
227
|
+
clockTolerance?: string | number;
|
|
228
|
+
/**
|
|
229
|
+
* Expected JWT "iss" (Issuer) Claim value(s).
|
|
230
|
+
*
|
|
231
|
+
* This option makes the JWT "iss" (Issuer) Claim presence required.
|
|
232
|
+
*/
|
|
233
|
+
issuer?: string | string[];
|
|
234
|
+
/**
|
|
235
|
+
* Maximum time elapsed (in seconds) from the JWT "iat" (Issued At) Claim value.
|
|
236
|
+
*
|
|
237
|
+
* - In seconds when number (e.g. 5)
|
|
238
|
+
* - Resolved into a number of seconds when a string (e.g. "5 seconds", "10 minutes", "2 hours").
|
|
239
|
+
*
|
|
240
|
+
* This option makes the JWT "iat" (Issued At) Claim presence required.
|
|
241
|
+
*/
|
|
242
|
+
maxTokenAge?: string | number;
|
|
243
|
+
/**
|
|
244
|
+
* Expected JWT "sub" (Subject) Claim value.
|
|
245
|
+
*
|
|
246
|
+
* This option makes the JWT "sub" (Subject) Claim presence required.
|
|
247
|
+
*/
|
|
248
|
+
subject?: string;
|
|
249
|
+
/**
|
|
250
|
+
* Expected JWT "typ" (Type) Header Parameter value.
|
|
251
|
+
*
|
|
252
|
+
* This option makes the JWT "typ" (Type) Header Parameter presence required.
|
|
253
|
+
*/
|
|
254
|
+
typ?: string;
|
|
255
|
+
/** Date to use when comparing NumericDate claims, defaults to `new Date()`. */
|
|
256
|
+
currentDate?: Date;
|
|
257
|
+
/**
|
|
258
|
+
* Array of required Claim Names that must be present in the JWT Claims Set. Default is that: if
|
|
259
|
+
* the {@link issuer `issuer` option} is set, then JWT "iss" (Issuer) Claim must be present; if the
|
|
260
|
+
* {@link audience `audience` option} is set, then JWT "aud" (Audience) Claim must be present; if
|
|
261
|
+
* the {@link subject `subject` option} is set, then JWT "sub" (Subject) Claim must be present; if
|
|
262
|
+
* the {@link maxTokenAge `maxTokenAge` option} is set, then JWT "iat" (Issued At) Claim must be
|
|
263
|
+
* present.
|
|
264
|
+
*/
|
|
265
|
+
requiredClaims?: string[];
|
|
266
|
+
}
|
|
267
|
+
/** JWS Verification options. */
|
|
268
|
+
interface VerifyOptions extends CritOption {
|
|
269
|
+
/**
|
|
270
|
+
* A list of accepted JWS "alg" (Algorithm) Header Parameter values. By default all "alg"
|
|
271
|
+
* (Algorithm) values applicable for the used key/secret are allowed.
|
|
272
|
+
*
|
|
273
|
+
* > [!NOTE]\
|
|
274
|
+
* > Unsecured JWTs (`{ "alg": "none" }`) are never accepted by this API.
|
|
275
|
+
*/
|
|
276
|
+
algorithms?: string[];
|
|
277
|
+
}
|
|
278
|
+
/** Recognized Compact JWS Header Parameters, any other Header Members may also be present. */
|
|
279
|
+
interface CompactJWSHeaderParameters extends JWSHeaderParameters {
|
|
280
|
+
alg: string;
|
|
281
|
+
}
|
|
282
|
+
/** Recognized Signed JWT Header Parameters, any other Header Members may also be present. */
|
|
283
|
+
interface JWTHeaderParameters extends CompactJWSHeaderParameters {
|
|
284
|
+
b64?: true;
|
|
285
|
+
}
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region ../../node_modules/.deno/jose@6.2.2/node_modules/jose/dist/types/jwt/verify.d.ts
|
|
288
|
+
/** Combination of JWS Verification options and JWT Claims Set verification options. */
|
|
289
|
+
interface JWTVerifyOptions extends VerifyOptions, JWTClaimVerificationOptions {}
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region ../../node_modules/.deno/jose@6.2.2/node_modules/jose/dist/types/jwt/decrypt.d.ts
|
|
292
|
+
/** Combination of JWE Decryption options and JWT Claims Set verification options. */
|
|
293
|
+
interface JWTDecryptOptions extends DecryptOptions, JWTClaimVerificationOptions {}
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/pages/createAuth.d.ts
|
|
296
|
+
declare const createAuth: <Identity extends Identities>(config: AuthConfig$1<Identity>) => {
|
|
297
|
+
/**
|
|
298
|
+
* The handlers object contains the HTTP request handlers.
|
|
299
|
+
*/
|
|
300
|
+
toHandler: (req: _$next.NextApiRequest, res: _$next.NextApiResponse) => Promise<void>;
|
|
301
|
+
api: {
|
|
302
|
+
getSession: (options: GetSessionAPIOptions) => Promise<GetSessionAPIReturn<FromShapeToObject<Identity>>>;
|
|
303
|
+
signIn: (oauth: LiteralUnion<BuiltInOAuthProvider>, options?: SignInAPIOptions) => Promise<SignInAPIReturn>;
|
|
304
|
+
signInCredentials: (options: SignInCredentialsAPIOptions) => Promise<SignInCredentialsAPIReturn>;
|
|
305
|
+
updateSession: (options: UpdateSessionAPIOptions<FromShapeToObject<Identity>>) => Promise<UpdateSessionAPIReturn<FromShapeToObject<Identity>>>;
|
|
306
|
+
signOut: (options: SignOutAPIOptions) => Promise<SignOutAPIReturn>;
|
|
307
|
+
};
|
|
308
|
+
jose: {
|
|
309
|
+
signJWS: (payload: TypedJWTPayload<Partial<FromShapeToObject<Identity>>>, options?: JWTHeaderParameters) => Promise<string>;
|
|
310
|
+
verifyJWS: (token: string, options?: JWTVerifyOptions) => Promise<TypedJWTPayload<FromShapeToObject<Identity>>>;
|
|
311
|
+
encryptJWE: (payload: TypedJWTPayload<Partial<FromShapeToObject<Identity>>>, options?: JWEHeaderParameters) => Promise<string>;
|
|
312
|
+
decryptJWE: (token: string, options?: JWTDecryptOptions) => Promise<TypedJWTPayload<FromShapeToObject<Identity>>>;
|
|
313
|
+
encodeJWT: (payload: TypedJWTPayload<Partial<FromShapeToObject<Identity>>>, options?: EncodeJWTOptions) => Promise<string>;
|
|
314
|
+
decodeJWT: (token: string, options?: DecodeJWTOptions) => Promise<TypedJWTPayload<FromShapeToObject<Identity>>>;
|
|
315
|
+
};
|
|
316
|
+
handlers: {
|
|
317
|
+
GET: (request: Request) => Response | Promise<Response>;
|
|
318
|
+
POST: (request: Request) => Response | Promise<Response>;
|
|
319
|
+
PATCH: (request: Request) => Response | Promise<Response>;
|
|
320
|
+
ALL: (request: Request) => Response | Promise<Response>;
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region src/pages/context.d.ts
|
|
325
|
+
/**
|
|
326
|
+
* Wrapper component that provides authentication context for Next.js Pages Router applications.
|
|
327
|
+
* Falls back to `router.push` from `next/router` when no custom `redirect` prop is supplied.
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* const client = createAuthClient({ baseURL: "http://localhost:3000" })
|
|
331
|
+
*
|
|
332
|
+
* <AuthProvider client={client}>
|
|
333
|
+
* <App />
|
|
334
|
+
* </AuthProvider>
|
|
335
|
+
*/
|
|
336
|
+
declare const AuthProvider: ({
|
|
337
|
+
client,
|
|
338
|
+
children,
|
|
339
|
+
initialSession,
|
|
340
|
+
redirect
|
|
341
|
+
}: AuthProviderProps) => _$react_jsx_runtime0.JSX.Element;
|
|
342
|
+
type AuthConfig = core_d_exports.AuthConfig;
|
|
343
|
+
type AuthInstance = core_d_exports.AuthInstance;
|
|
344
|
+
type Session = core_d_exports.Session;
|
|
345
|
+
type User = core_d_exports.User;
|
|
346
|
+
export { type AuthConfig, type AuthInstance, AuthProvider, type AuthProviderProps, type Session, type User, createAuth };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AuthProvider as e}from"@aura-stack/react/context";import{jsx as t}from"react/jsx-runtime";import{createAuth as n}from"@aura-stack/react/server";import{useRouter as r}from"next/router.js";const i=e=>`${e.headers[`x-forwarded-proto`]??`http`}://${e.headers[`x-forwarded-host`]??e.headers.host}`,a=(e,t)=>{for(let[n,r]of t.entries())n.toLowerCase()===`set-cookie`?e.setHeader(`Set-Cookie`,t.getSetCookie()):e.setHeader(n,r)},o=e=>async(t,n)=>{let r=t.method??`GET`,o=e[r];if(!o)return n.status(405).json({error:`Method ${r} Not Allowed`});let s=new URL(t.url,i(t)),c=new Request(s,{method:r,headers:new Headers(t.headers),body:r!==`GET`&&r!==`HEAD`?t.body:void 0});try{let e=await o(c);e.status>=300&&e.status<400&&!t.url?.includes(`/auth/signIn/`)&&!t.url?.includes(`/auth/callback/`)&&e.headers.delete(`Location`),a(n,e.headers);let r=await e.json();return n.status(e.status).json(r)}catch{return n.status(500).json({error:`Internal Server Error`})}},s=e=>{let t=n(e);return{...t,toHandler:o(t.handlers)}},c=({client:n,children:i,initialSession:a,redirect:o})=>{let s=r();return t(e,{client:n,initialSession:a,redirect:o??(e=>s.push(e)),children:i})};export{c as AuthProvider,s as createAuth};
|