@tern-secure/nextjs 5.2.0-canary.v20251008131428 → 5.2.0-canary.v20251019190011
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/cjs/app-router/admin/endpointRouter.js +13 -1
- package/dist/cjs/app-router/admin/endpointRouter.js.map +1 -1
- package/dist/cjs/app-router/admin/sessionHandlers.js +71 -3
- package/dist/cjs/app-router/admin/sessionHandlers.js.map +1 -1
- package/dist/cjs/app-router/admin/types.js +17 -0
- package/dist/cjs/app-router/admin/types.js.map +1 -1
- package/dist/cjs/app-router/client/TernSecureProvider.js +17 -7
- package/dist/cjs/app-router/client/TernSecureProvider.js.map +1 -1
- package/dist/cjs/app-router/server/TernSecureProvider.js +92 -0
- package/dist/cjs/app-router/server/TernSecureProvider.js.map +1 -0
- package/dist/cjs/app-router/server/auth.js +2 -16
- package/dist/cjs/app-router/server/auth.js.map +1 -1
- package/dist/cjs/app-router/server/utils.js +2 -2
- package/dist/cjs/app-router/server/utils.js.map +1 -1
- package/dist/cjs/boundary/NextOptionsCtx.js +52 -0
- package/dist/cjs/boundary/NextOptionsCtx.js.map +1 -0
- package/dist/cjs/boundary/PromiseAuthProvider.js +68 -0
- package/dist/cjs/boundary/PromiseAuthProvider.js.map +1 -0
- package/dist/cjs/boundary/components.js +10 -3
- package/dist/cjs/boundary/components.js.map +1 -1
- package/dist/cjs/index.js +9 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/server/data/getAuthDataFromRequest.js +57 -0
- package/dist/cjs/server/data/getAuthDataFromRequest.js.map +1 -0
- package/dist/cjs/server/index.js +3 -0
- package/dist/cjs/server/index.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/allNextProviderProps.js +3 -3
- package/dist/cjs/utils/allNextProviderProps.js.map +1 -1
- package/dist/esm/app-router/admin/endpointRouter.js +14 -2
- package/dist/esm/app-router/admin/endpointRouter.js.map +1 -1
- package/dist/esm/app-router/admin/sessionHandlers.js +71 -4
- package/dist/esm/app-router/admin/sessionHandlers.js.map +1 -1
- package/dist/esm/app-router/admin/types.js +16 -0
- package/dist/esm/app-router/admin/types.js.map +1 -1
- package/dist/esm/app-router/client/TernSecureProvider.js +17 -9
- package/dist/esm/app-router/client/TernSecureProvider.js.map +1 -1
- package/dist/esm/app-router/server/TernSecureProvider.js +58 -0
- package/dist/esm/app-router/server/TernSecureProvider.js.map +1 -0
- package/dist/esm/app-router/server/auth.js +2 -21
- package/dist/esm/app-router/server/auth.js.map +1 -1
- package/dist/esm/app-router/server/utils.js +2 -2
- package/dist/esm/app-router/server/utils.js.map +1 -1
- package/dist/esm/boundary/NextOptionsCtx.js +17 -0
- package/dist/esm/boundary/NextOptionsCtx.js.map +1 -0
- package/dist/esm/boundary/PromiseAuthProvider.js +33 -0
- package/dist/esm/boundary/PromiseAuthProvider.js.map +1 -0
- package/dist/esm/boundary/components.js +9 -3
- package/dist/esm/boundary/components.js.map +1 -1
- package/dist/esm/index.js +9 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/server/data/getAuthDataFromRequest.js +31 -0
- package/dist/esm/server/data/getAuthDataFromRequest.js.map +1 -0
- package/dist/esm/server/index.js +2 -0
- package/dist/esm/server/index.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/allNextProviderProps.js +3 -3
- package/dist/esm/utils/allNextProviderProps.js.map +1 -1
- package/dist/types/app-router/admin/endpointRouter.d.ts.map +1 -1
- package/dist/types/app-router/admin/sessionHandlers.d.ts +3 -1
- package/dist/types/app-router/admin/sessionHandlers.d.ts.map +1 -1
- package/dist/types/app-router/admin/types.d.ts +2 -1
- package/dist/types/app-router/admin/types.d.ts.map +1 -1
- package/dist/types/app-router/client/TernSecureProvider.d.ts +2 -24
- package/dist/types/app-router/client/TernSecureProvider.d.ts.map +1 -1
- package/dist/types/app-router/server/TernSecureProvider.d.ts +4 -0
- package/dist/types/app-router/server/TernSecureProvider.d.ts.map +1 -0
- package/dist/types/app-router/server/auth.d.ts.map +1 -1
- package/dist/types/boundary/NextOptionsCtx.d.ts +9 -0
- package/dist/types/boundary/NextOptionsCtx.d.ts.map +1 -0
- package/dist/types/boundary/PromiseAuthProvider.d.ts +8 -0
- package/dist/types/boundary/PromiseAuthProvider.d.ts.map +1 -0
- package/dist/types/boundary/components.d.ts +2 -1
- package/dist/types/boundary/components.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/server/data/getAuthDataFromRequest.d.ts +26 -0
- package/dist/types/server/data/getAuthDataFromRequest.d.ts.map +1 -0
- package/dist/types/server/index.d.ts +1 -0
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/allNextProviderProps.d.ts +1 -4
- package/dist/types/utils/allNextProviderProps.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/cjs/server/edge-session.js +0 -173
- package/dist/cjs/server/edge-session.js.map +0 -1
- package/dist/cjs/server/jwt-edge.js +0 -138
- package/dist/cjs/server/jwt-edge.js.map +0 -1
- package/dist/cjs/server/jwt.js +0 -138
- package/dist/cjs/server/jwt.js.map +0 -1
- package/dist/cjs/server/session-store.js +0 -74
- package/dist/cjs/server/session-store.js.map +0 -1
- package/dist/esm/server/edge-session.js +0 -146
- package/dist/esm/server/edge-session.js.map +0 -1
- package/dist/esm/server/jwt-edge.js +0 -114
- package/dist/esm/server/jwt-edge.js.map +0 -1
- package/dist/esm/server/jwt.js +0 -114
- package/dist/esm/server/jwt.js.map +0 -1
- package/dist/esm/server/session-store.js +0 -49
- package/dist/esm/server/session-store.js.map +0 -1
- package/dist/types/server/edge-session.d.ts +0 -16
- package/dist/types/server/edge-session.d.ts.map +0 -1
- package/dist/types/server/jwt-edge.d.ts +0 -14
- package/dist/types/server/jwt-edge.d.ts.map +0 -1
- package/dist/types/server/jwt.d.ts +0 -14
- package/dist/types/server/jwt.d.ts.map +0 -1
- package/dist/types/server/session-store.d.ts +0 -30
- package/dist/types/server/session-store.d.ts.map +0 -1
|
@@ -1,14 +1,22 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
} from "@tern-secure/react";
|
|
3
|
+
import { TernSecureProvider as TernSecureReactProvider } from "@tern-secure/react";
|
|
4
|
+
import { TernNextOptionsProvider, useTernNextOptions } from "../../boundary/NextOptionsCtx";
|
|
5
5
|
import { allNextProviderPropsWithEnv } from "../../utils/allNextProviderProps";
|
|
6
|
-
|
|
7
|
-
const { children
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const NextClientProvider = (props) => {
|
|
7
|
+
const { children } = props;
|
|
8
|
+
const isNested = Boolean(useTernNextOptions());
|
|
9
|
+
if (isNested) {
|
|
10
|
+
return props.children;
|
|
11
|
+
}
|
|
12
|
+
const providerProps = allNextProviderPropsWithEnv({ ...props });
|
|
13
|
+
return /* @__PURE__ */ jsx(TernNextOptionsProvider, { options: providerProps, children: /* @__PURE__ */ jsx(TernSecureReactProvider, { ...providerProps, children }) });
|
|
14
|
+
};
|
|
15
|
+
const ClientTernSecureProvider = (props) => {
|
|
16
|
+
const { children, ...rest } = props;
|
|
17
|
+
return /* @__PURE__ */ jsx(NextClientProvider, { ...rest, children });
|
|
18
|
+
};
|
|
11
19
|
export {
|
|
12
|
-
|
|
20
|
+
ClientTernSecureProvider
|
|
13
21
|
};
|
|
14
22
|
//# sourceMappingURL=TernSecureProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"sourcesContent":["'use client';\r\n\r\nimport { TernSecureProvider as TernSecureReactProvider } from '@tern-secure/react';\r\n\r\nimport { TernNextOptionsProvider, useTernNextOptions } from '../../boundary/NextOptionsCtx';\r\nimport type { TernSecureNextProps } from '../../types';\r\nimport { allNextProviderPropsWithEnv } from '../../utils/allNextProviderProps';\r\n\r\nconst NextClientProvider = (props: TernSecureNextProps) => {\r\n const { children } = props;\r\n\r\n const isNested = Boolean(useTernNextOptions());\r\n if (isNested) {\r\n return props.children;\r\n }\r\n\r\n const providerProps = allNextProviderPropsWithEnv({...props});\r\n return (\r\n <TernNextOptionsProvider options={providerProps}>\r\n <TernSecureReactProvider {...providerProps}>\r\n {children}\r\n </TernSecureReactProvider>\r\n </TernNextOptionsProvider>\r\n );\r\n};\r\n\r\nexport const ClientTernSecureProvider = (props: TernSecureNextProps) => {\r\n const { children, ...rest } = props;\r\n return (\r\n <NextClientProvider {...rest}>\r\n {children}\r\n </NextClientProvider>\r\n );\r\n};\r\n"],"mappings":";AAmBM;AAjBN,SAAS,sBAAsB,+BAA+B;AAE9D,SAAS,yBAAyB,0BAA0B;AAE5D,SAAS,mCAAmC;AAE5C,MAAM,qBAAqB,CAAC,UAA+B;AACzD,QAAM,EAAE,SAAS,IAAI;AAErB,QAAM,WAAW,QAAQ,mBAAmB,CAAC;AAC7C,MAAI,UAAU;AACZ,WAAO,MAAM;AAAA,EACf;AAEA,QAAM,gBAAgB,4BAA4B,EAAC,GAAG,MAAK,CAAC;AAC5D,SACE,oBAAC,2BAAwB,SAAS,eAChC,8BAAC,2BAAyB,GAAG,eAC1B,UACH,GACF;AAEJ;AAEO,MAAM,2BAA2B,CAAC,UAA+B;AACtE,QAAM,EAAE,UAAU,GAAG,KAAK,IAAI;AAC9B,SACE,oBAAC,sBAAoB,GAAG,MACrB,UACH;AAEJ;","names":[]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { PromiseAuthProvider } from "../../boundary/PromiseAuthProvider";
|
|
4
|
+
import { getTernSecureAuthData } from "../../server/data/getAuthDataFromRequest";
|
|
5
|
+
import { isNext13 } from "../../server/sdk-versions";
|
|
6
|
+
import { allNextProviderPropsWithEnv } from "../../utils/allNextProviderProps";
|
|
7
|
+
import { ClientTernSecureProvider } from "../client/TernSecureProvider";
|
|
8
|
+
import { buildRequestLike } from "./utils";
|
|
9
|
+
const getTernSecureState = React.cache(async function getTernSecureState2() {
|
|
10
|
+
const request = await buildRequestLike();
|
|
11
|
+
const data = getTernSecureAuthData(request);
|
|
12
|
+
return data;
|
|
13
|
+
});
|
|
14
|
+
async function TernSecureProvider(props) {
|
|
15
|
+
const { children, ...rest } = props;
|
|
16
|
+
const { persistence } = rest;
|
|
17
|
+
const browserCookiePersistence = persistence === "browserCookie";
|
|
18
|
+
async function generateStatePromise() {
|
|
19
|
+
if (!browserCookiePersistence) {
|
|
20
|
+
return Promise.resolve(void 0);
|
|
21
|
+
}
|
|
22
|
+
if (isNext13) {
|
|
23
|
+
return Promise.resolve(await getTernSecureState());
|
|
24
|
+
}
|
|
25
|
+
return getTernSecureState();
|
|
26
|
+
}
|
|
27
|
+
const providerProps = allNextProviderPropsWithEnv({ ...rest });
|
|
28
|
+
let output;
|
|
29
|
+
if (browserCookiePersistence) {
|
|
30
|
+
output = /* @__PURE__ */ jsx(
|
|
31
|
+
PromiseAuthProvider,
|
|
32
|
+
{
|
|
33
|
+
authPromise: generateStatePromise(),
|
|
34
|
+
children: /* @__PURE__ */ jsx(
|
|
35
|
+
ClientTernSecureProvider,
|
|
36
|
+
{
|
|
37
|
+
...providerProps,
|
|
38
|
+
initialState: await generateStatePromise(),
|
|
39
|
+
children
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
} else {
|
|
45
|
+
output = /* @__PURE__ */ jsx(
|
|
46
|
+
ClientTernSecureProvider,
|
|
47
|
+
{
|
|
48
|
+
...providerProps,
|
|
49
|
+
children
|
|
50
|
+
}
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
return output;
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
TernSecureProvider
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=TernSecureProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/app-router/server/TernSecureProvider.tsx"],"sourcesContent":["import type { TernSecureStateExtended } from '@tern-secure/types';\nimport type { ReactNode } from 'react';\nimport React from 'react';\n\nimport { PromiseAuthProvider } from '../../boundary/PromiseAuthProvider';\nimport { getTernSecureAuthData } from '../../server/data/getAuthDataFromRequest';\nimport { isNext13 } from '../../server/sdk-versions';\nimport type { TernSecureNextProps } from '../../types';\nimport { allNextProviderPropsWithEnv } from '../../utils/allNextProviderProps';\nimport { ClientTernSecureProvider } from '../client/TernSecureProvider';\nimport { buildRequestLike } from './utils';\n\nconst getTernSecureState = React.cache(async function getTernSecureState() {\n const request = await buildRequestLike();\n const data = getTernSecureAuthData(request);\n return data;\n});\n\nexport async function TernSecureProvider(props: TernSecureNextProps) {\n const { children, ...rest } = props;\n const { persistence } = rest;\n\n const browserCookiePersistence = persistence === 'browserCookie';\n\n async function generateStatePromise() {\n if (!browserCookiePersistence) {\n return Promise.resolve(undefined);\n }\n if (isNext13) {\n return Promise.resolve(await getTernSecureState());\n }\n return getTernSecureState();\n }\n\n const providerProps = allNextProviderPropsWithEnv({ ...rest });\n\n let output: ReactNode;\n\n if (browserCookiePersistence) {\n output = (\n <PromiseAuthProvider\n authPromise={generateStatePromise() as unknown as Promise<TernSecureStateExtended>}\n >\n <ClientTernSecureProvider\n {...providerProps}\n initialState={await generateStatePromise()}\n >\n {children}\n </ClientTernSecureProvider>\n </PromiseAuthProvider>\n );\n } else {\n output = (\n <ClientTernSecureProvider\n {...providerProps}\n >\n {children}\n </ClientTernSecureProvider>\n );\n }\n\n return output;\n}\n"],"mappings":"AA2CQ;AAzCR,OAAO,WAAW;AAElB,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,gBAAgB;AAEzB,SAAS,mCAAmC;AAC5C,SAAS,gCAAgC;AACzC,SAAS,wBAAwB;AAEjC,MAAM,qBAAqB,MAAM,MAAM,eAAeA,sBAAqB;AACzE,QAAM,UAAU,MAAM,iBAAiB;AACvC,QAAM,OAAO,sBAAsB,OAAO;AAC1C,SAAO;AACT,CAAC;AAED,eAAsB,mBAAmB,OAA4B;AACnE,QAAM,EAAE,UAAU,GAAG,KAAK,IAAI;AAC9B,QAAM,EAAE,YAAY,IAAI;AAExB,QAAM,2BAA2B,gBAAgB;AAEjD,iBAAe,uBAAuB;AACpC,QAAI,CAAC,0BAA0B;AAC7B,aAAO,QAAQ,QAAQ,MAAS;AAAA,IAClC;AACA,QAAI,UAAU;AACZ,aAAO,QAAQ,QAAQ,MAAM,mBAAmB,CAAC;AAAA,IACnD;AACA,WAAO,mBAAmB;AAAA,EAC5B;AAEA,QAAM,gBAAgB,4BAA4B,EAAE,GAAG,KAAK,CAAC;AAE7D,MAAI;AAEJ,MAAI,0BAA0B;AAC5B,aACE;AAAA,MAAC;AAAA;AAAA,QACC,aAAa,qBAAqB;AAAA,QAElC;AAAA,UAAC;AAAA;AAAA,YACE,GAAG;AAAA,YACJ,cAAc,MAAM,qBAAqB;AAAA,YAExC;AAAA;AAAA,QACH;AAAA;AAAA,IACF;AAAA,EAEJ,OAAO;AACL,aACE;AAAA,MAAC;AAAA;AAAA,QACE,GAAG;AAAA,QAEH;AAAA;AAAA,IACH;AAAA,EAEJ;AAEA,SAAO;AACT;","names":["getTernSecureState"]}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AuthStatus,
|
|
3
|
-
createTernSecureRequest,
|
|
4
|
-
signedInAuthObject,
|
|
5
|
-
signedOutAuthObject
|
|
6
|
-
} from "@tern-secure/backend";
|
|
7
|
-
import { ternDecodeJwt } from "@tern-secure/backend/jwt";
|
|
1
|
+
import { createTernSecureRequest } from "@tern-secure/backend";
|
|
8
2
|
import { notFound, redirect } from "next/navigation";
|
|
9
3
|
import { SIGN_IN_URL, SIGN_UP_URL } from "../../server/constant";
|
|
4
|
+
import { getAuthDataFromRequest } from "../../server/data/getAuthDataFromRequest";
|
|
10
5
|
import { getAuthKeyFromRequest } from "../../server/headers-utils";
|
|
11
6
|
import { createProtect } from "../../server/protect";
|
|
12
7
|
import { createRedirect } from "../../server/redirect";
|
|
@@ -16,20 +11,6 @@ const createAuthObject = () => {
|
|
|
16
11
|
return getAuthDataFromRequest(req);
|
|
17
12
|
};
|
|
18
13
|
};
|
|
19
|
-
function getAuthDataFromRequest(req) {
|
|
20
|
-
const authStatus = getAuthKeyFromRequest(req, "AuthStatus");
|
|
21
|
-
const authToken = getAuthKeyFromRequest(req, "AuthToken");
|
|
22
|
-
const authSignature = getAuthKeyFromRequest(req, "AuthSignature");
|
|
23
|
-
const authReason = getAuthKeyFromRequest(req, "AuthReason");
|
|
24
|
-
let authObject;
|
|
25
|
-
if (!authStatus || authStatus !== AuthStatus.SignedIn) {
|
|
26
|
-
authObject = signedOutAuthObject();
|
|
27
|
-
} else {
|
|
28
|
-
const jwt = ternDecodeJwt(authToken);
|
|
29
|
-
authObject = signedInAuthObject(jwt.raw.text, jwt.payload);
|
|
30
|
-
}
|
|
31
|
-
return authObject;
|
|
32
|
-
}
|
|
33
14
|
const auth = async () => {
|
|
34
15
|
require("server-only");
|
|
35
16
|
const request = await buildRequestLike();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/app-router/server/auth.ts"],"sourcesContent":["import type { AuthObject } from '@tern-secure/backend';\r\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/app-router/server/auth.ts"],"sourcesContent":["import type { AuthObject } from '@tern-secure/backend';\r\nimport { createTernSecureRequest } from '@tern-secure/backend';\r\nimport { notFound, redirect } from 'next/navigation';\r\n\r\nimport { SIGN_IN_URL, SIGN_UP_URL } from '../../server/constant';\r\nimport { getAuthDataFromRequest } from '../../server/data/getAuthDataFromRequest';\r\nimport { getAuthKeyFromRequest } from '../../server/headers-utils';\r\nimport { type AuthProtect, createProtect } from '../../server/protect';\r\nimport { createRedirect, type RedirectFun } from '../../server/redirect';\r\nimport type { BaseUser, RequestLike } from '../../server/types';\r\nimport { buildRequestLike } from './utils';\r\n\r\nexport interface AuthResult {\r\n user: BaseUser | null;\r\n error: Error | null;\r\n}\r\n\r\n/**\r\n * `Auth` object of the currently active user and the `redirectToSignIn()` method.\r\n */\r\ntype Auth = AuthObject & {\r\n redirectToSignIn: RedirectFun<ReturnType<typeof redirect>>;\r\n redirectToSignUp: RedirectFun<ReturnType<typeof redirect>>;\r\n};\r\n\r\nexport interface AuthFn {\r\n (): Promise<Auth>;\r\n\r\n protect: AuthProtect;\r\n}\r\n\r\nconst createAuthObject = () => {\r\n return async (req: RequestLike) => {\r\n return getAuthDataFromRequest(req);\r\n };\r\n};\r\n\r\n/**\r\n * Get the current authenticated user from the session or token\r\n */\r\nexport const auth: AuthFn = async () => {\r\n // eslint-disable-next-line @typescript-eslint/no-require-imports\r\n require('server-only');\r\n\r\n const request = await buildRequestLike();\r\n\r\n const authObject = await createAuthObject()(request);\r\n\r\n const ternUrl = getAuthKeyFromRequest(request, 'TernSecureUrl');\r\n\r\n const createRedirectForRequest = (...args: Parameters<RedirectFun<never>>) => {\r\n const { returnBackUrl } = args[0] || {};\r\n const ternSecureRequest = createTernSecureRequest(request);\r\n\r\n return [\r\n createRedirect({\r\n redirectAdapter: redirect,\r\n baseUrl: ternSecureRequest.ternUrl.toString(),\r\n signInUrl: SIGN_IN_URL,\r\n signUpUrl: SIGN_UP_URL,\r\n }),\r\n returnBackUrl === null ? '' : returnBackUrl || ternUrl?.toString(),\r\n ] as const;\r\n };\r\n\r\n const redirectToSignIn: RedirectFun<never> = (opts = {}) => {\r\n const [r, returnBackUrl] = createRedirectForRequest(opts);\r\n return r.redirectToSignIn({\r\n returnBackUrl,\r\n });\r\n };\r\n\r\n const redirectToSignUp: RedirectFun<never> = (opts = {}) => {\r\n const [r, returnBackUrl] = createRedirectForRequest(opts);\r\n return r.redirectToSignUp({\r\n returnBackUrl,\r\n });\r\n };\r\n\r\n return Object.assign(authObject, { redirectToSignIn, redirectToSignUp });\r\n};\r\n\r\nauth.protect = async (...args: any[]) => {\r\n // eslint-disable-next-line @typescript-eslint/no-require-imports\r\n require('server-only');\r\n\r\n const request = await buildRequestLike();\r\n const authObject = await auth();\r\n\r\n const protect = createProtect({\r\n request,\r\n authObject,\r\n redirectToSignIn: authObject.redirectToSignIn,\r\n notFound,\r\n redirect,\r\n });\r\n\r\n return protect(...args);\r\n};\r\n"],"mappings":"AACA,SAAS,+BAA+B;AACxC,SAAS,UAAU,gBAAgB;AAEnC,SAAS,aAAa,mBAAmB;AACzC,SAAS,8BAA8B;AACvC,SAAS,6BAA6B;AACtC,SAA2B,qBAAqB;AAChD,SAAS,sBAAwC;AAEjD,SAAS,wBAAwB;AAqBjC,MAAM,mBAAmB,MAAM;AAC7B,SAAO,OAAO,QAAqB;AACjC,WAAO,uBAAuB,GAAG;AAAA,EACnC;AACF;AAKO,MAAM,OAAe,YAAY;AAEtC,UAAQ,aAAa;AAErB,QAAM,UAAU,MAAM,iBAAiB;AAEvC,QAAM,aAAa,MAAM,iBAAiB,EAAE,OAAO;AAEnD,QAAM,UAAU,sBAAsB,SAAS,eAAe;AAE9D,QAAM,2BAA2B,IAAI,SAAyC;AAC5E,UAAM,EAAE,cAAc,IAAI,KAAK,CAAC,KAAK,CAAC;AACtC,UAAM,oBAAoB,wBAAwB,OAAO;AAEzD,WAAO;AAAA,MACL,eAAe;AAAA,QACb,iBAAiB;AAAA,QACjB,SAAS,kBAAkB,QAAQ,SAAS;AAAA,QAC5C,WAAW;AAAA,QACX,WAAW;AAAA,MACb,CAAC;AAAA,MACD,kBAAkB,OAAO,KAAK,iBAAiB,SAAS,SAAS;AAAA,IACnE;AAAA,EACF;AAEA,QAAM,mBAAuC,CAAC,OAAO,CAAC,MAAM;AAC1D,UAAM,CAAC,GAAG,aAAa,IAAI,yBAAyB,IAAI;AACxD,WAAO,EAAE,iBAAiB;AAAA,MACxB;AAAA,IACF,CAAC;AAAA,EACH;AAEA,QAAM,mBAAuC,CAAC,OAAO,CAAC,MAAM;AAC1D,UAAM,CAAC,GAAG,aAAa,IAAI,yBAAyB,IAAI;AACxD,WAAO,EAAE,iBAAiB;AAAA,MACxB;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO,OAAO,OAAO,YAAY,EAAE,kBAAkB,iBAAiB,CAAC;AACzE;AAEA,KAAK,UAAU,UAAU,SAAgB;AAEvC,UAAQ,aAAa;AAErB,QAAM,UAAU,MAAM,iBAAiB;AACvC,QAAM,aAAa,MAAM,KAAK;AAE9B,QAAM,UAAU,cAAc;AAAA,IAC5B;AAAA,IACA;AAAA,IACA,kBAAkB,WAAW;AAAA,IAC7B;AAAA,IACA;AAAA,EACF,CAAC;AAED,SAAO,QAAQ,GAAG,IAAI;AACxB;","names":[]}
|
|
@@ -20,8 +20,8 @@ async function buildRequestLike() {
|
|
|
20
20
|
throw e;
|
|
21
21
|
}
|
|
22
22
|
throw new Error(
|
|
23
|
-
`
|
|
24
|
-
|
|
23
|
+
`auth() is only supported in the App Router (/app directory).
|
|
24
|
+
/pages is not supported yet.
|
|
25
25
|
Original error: ${e}`
|
|
26
26
|
);
|
|
27
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/app-router/server/utils.ts"],"sourcesContent":["import { NextRequest } from 'next/server';\r\n\r\nexport const isPrerenderingBailout = (e: unknown) => {\r\n if (!(e instanceof Error) || !('message' in e)) {\r\n return false;\r\n }\r\n\r\n const { message } = e;\r\n\r\n const lowerCaseInput = message.toLowerCase();\r\n const dynamicServerUsage = lowerCaseInput.includes('dynamic server usage');\r\n const bailOutPrerendering = lowerCaseInput.includes('this page needs to bail out of prerendering');\r\n\r\n // note: new error message syntax introduced in next@14.1.1-canary.21\r\n // but we still want to support older versions.\r\n // https://github.com/vercel/next.js/pull/61332 (dynamic-rendering.ts:153)\r\n const routeRegex = /Route .*? needs to bail out of prerendering at this point because it used .*?./;\r\n\r\n return routeRegex.test(message) || dynamicServerUsage || bailOutPrerendering;\r\n};\r\n\r\nexport async function buildRequestLike(): Promise<NextRequest> {\r\n try {\r\n // Dynamically import next/headers, otherwise Next12 apps will break\r\n // @ts-expect-error: Cannot find module 'next/headers' or its corresponding type declarations.ts(2307)\r\n const { headers } = await import('next/headers');\r\n const resolvedHeaders = await headers();\r\n return new NextRequest('https://placeholder.com', { headers: resolvedHeaders });\r\n } catch (e: any) {\r\n // rethrow the error when react throws a prerendering bailout\r\n // https://nextjs.org/docs/messages/ppr-caught-error\r\n if (e && isPrerenderingBailout(e)) {\r\n throw e;\r\n }\r\n\r\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/app-router/server/utils.ts"],"sourcesContent":["import { NextRequest } from 'next/server';\r\n\r\nexport const isPrerenderingBailout = (e: unknown) => {\r\n if (!(e instanceof Error) || !('message' in e)) {\r\n return false;\r\n }\r\n\r\n const { message } = e;\r\n\r\n const lowerCaseInput = message.toLowerCase();\r\n const dynamicServerUsage = lowerCaseInput.includes('dynamic server usage');\r\n const bailOutPrerendering = lowerCaseInput.includes('this page needs to bail out of prerendering');\r\n\r\n // note: new error message syntax introduced in next@14.1.1-canary.21\r\n // but we still want to support older versions.\r\n // https://github.com/vercel/next.js/pull/61332 (dynamic-rendering.ts:153)\r\n const routeRegex = /Route .*? needs to bail out of prerendering at this point because it used .*?./;\r\n\r\n return routeRegex.test(message) || dynamicServerUsage || bailOutPrerendering;\r\n};\r\n\r\nexport async function buildRequestLike(): Promise<NextRequest> {\r\n try {\r\n // Dynamically import next/headers, otherwise Next12 apps will break\r\n // @ts-expect-error: Cannot find module 'next/headers' or its corresponding type declarations.ts(2307)\r\n const { headers } = await import('next/headers');\r\n const resolvedHeaders = await headers();\r\n return new NextRequest('https://placeholder.com', { headers: resolvedHeaders });\r\n } catch (e: any) {\r\n // rethrow the error when react throws a prerendering bailout\r\n // https://nextjs.org/docs/messages/ppr-caught-error\r\n if (e && isPrerenderingBailout(e)) {\r\n throw e;\r\n }\r\n\r\n throw new Error(\r\n `auth() is only supported in the App Router (/app directory).\\n/pages is not supported yet.\\nOriginal error: ${e}`,\r\n );\r\n }\r\n}\r\n\r\n// Original source: https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/get-script-nonce-from-header.tsx\r\nexport function getScriptNonceFromHeader(cspHeaderValue: string): string | undefined {\r\n const directives = cspHeaderValue\r\n // Directives are split by ';'.\r\n .split(';')\r\n .map(directive => directive.trim());\r\n\r\n // First try to find the directive for the 'script-src', otherwise try to\r\n // fallback to the 'default-src'.\r\n const directive =\r\n directives.find(dir => dir.startsWith('script-src')) || directives.find(dir => dir.startsWith('default-src'));\r\n\r\n // If no directive could be found, then we're done.\r\n if (!directive) {\r\n return;\r\n }\r\n\r\n // Extract the nonce from the directive\r\n const nonce = directive\r\n .split(' ')\r\n // Remove the 'strict-src'/'default-src' string, this can't be the nonce.\r\n .slice(1)\r\n .map(source => source.trim())\r\n // Find the first source with the 'nonce-' prefix.\r\n .find(source => source.startsWith(\"'nonce-\") && source.length > 8 && source.endsWith(\"'\"))\r\n // Grab the nonce by trimming the 'nonce-' prefix.\r\n ?.slice(7, -1);\r\n\r\n // If we couldn't find the nonce, then we're done.\r\n if (!nonce) {\r\n return;\r\n }\r\n\r\n // Don't accept the nonce value if it contains HTML escape characters.\r\n // Technically, the spec requires a base64'd value, but this is just an\r\n // extra layer.\r\n if (/[&><\\u2028\\u2029]/g.test(nonce)) {\r\n throw new Error(\r\n 'Nonce value from Content-Security-Policy contained invalid HTML escape characters, which is disallowed for security reasons. Make sure that your nonce value does not contain the following characters: `<`, `>`, `&`',\r\n );\r\n }\r\n\r\n return nonce;\r\n}\r\n"],"mappings":"AAAA,SAAS,mBAAmB;AAErB,MAAM,wBAAwB,CAAC,MAAe;AACnD,MAAI,EAAE,aAAa,UAAU,EAAE,aAAa,IAAI;AAC9C,WAAO;AAAA,EACT;AAEA,QAAM,EAAE,QAAQ,IAAI;AAEpB,QAAM,iBAAiB,QAAQ,YAAY;AAC3C,QAAM,qBAAqB,eAAe,SAAS,sBAAsB;AACzE,QAAM,sBAAsB,eAAe,SAAS,6CAA6C;AAKjG,QAAM,aAAa;AAEnB,SAAO,WAAW,KAAK,OAAO,KAAK,sBAAsB;AAC3D;AAEA,eAAsB,mBAAyC;AAC7D,MAAI;AAGF,UAAM,EAAE,QAAQ,IAAI,MAAM,OAAO,cAAc;AAC/C,UAAM,kBAAkB,MAAM,QAAQ;AACtC,WAAO,IAAI,YAAY,2BAA2B,EAAE,SAAS,gBAAgB,CAAC;AAAA,EAChF,SAAS,GAAQ;AAGf,QAAI,KAAK,sBAAsB,CAAC,GAAG;AACjC,YAAM;AAAA,IACR;AAEE,UAAM,IAAI;AAAA,MACR;AAAA;AAAA,kBAA+G,CAAC;AAAA,IAClH;AAAA,EACJ;AACF;AAGO,SAAS,yBAAyB,gBAA4C;AACnF,QAAM,aAAa,eAEhB,MAAM,GAAG,EACT,IAAI,CAAAA,eAAaA,WAAU,KAAK,CAAC;AAIpC,QAAM,YACJ,WAAW,KAAK,SAAO,IAAI,WAAW,YAAY,CAAC,KAAK,WAAW,KAAK,SAAO,IAAI,WAAW,aAAa,CAAC;AAG9G,MAAI,CAAC,WAAW;AACd;AAAA,EACF;AAGA,QAAM,QAAQ,UACX,MAAM,GAAG,EAET,MAAM,CAAC,EACP,IAAI,YAAU,OAAO,KAAK,CAAC,EAE3B,KAAK,YAAU,OAAO,WAAW,SAAS,KAAK,OAAO,SAAS,KAAK,OAAO,SAAS,GAAG,CAAC,GAEvF,MAAM,GAAG,EAAE;AAGf,MAAI,CAAC,OAAO;AACV;AAAA,EACF;AAKA,MAAI,qBAAqB,KAAK,KAAK,GAAG;AACpC,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":["directive"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
const TernNextOptionsCtx = React.createContext(void 0);
|
|
4
|
+
TernNextOptionsCtx.displayName = "TernNextOptionsCtx";
|
|
5
|
+
const useTernNextOptions = () => {
|
|
6
|
+
const ctx = React.useContext(TernNextOptionsCtx);
|
|
7
|
+
return ctx?.value;
|
|
8
|
+
};
|
|
9
|
+
const TernNextOptionsProvider = (props) => {
|
|
10
|
+
const { children, options } = props;
|
|
11
|
+
return /* @__PURE__ */ jsx(TernNextOptionsCtx.Provider, { value: { value: options }, children });
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
TernNextOptionsProvider,
|
|
15
|
+
useTernNextOptions
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=NextOptionsCtx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/boundary/NextOptionsCtx.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { TernSecureNextProps } from '../types';\n\ntype TernNextContextValue = Partial<Omit<TernSecureNextProps, 'children'>>;\n\nconst TernNextOptionsCtx = React.createContext<{ value: TernNextContextValue } | undefined>(undefined);\nTernNextOptionsCtx.displayName = 'TernNextOptionsCtx';\n\nconst useTernNextOptions = () => {\n const ctx = React.useContext(TernNextOptionsCtx) as { value: TernNextContextValue };\n return ctx?.value;\n};\n\nconst TernNextOptionsProvider = (\n props: React.PropsWithChildren<{ options: TernNextContextValue }>,\n): React.JSX.Element => {\n const { children, options } = props;\n return <TernNextOptionsCtx.Provider value={{ value: options }}>{children}</TernNextOptionsCtx.Provider>;\n};\n\nexport { TernNextOptionsProvider, useTernNextOptions };\n"],"mappings":"AAkBS;AAlBT,OAAO,WAAW;AAMlB,MAAM,qBAAqB,MAAM,cAA2D,MAAS;AACrG,mBAAmB,cAAc;AAEjC,MAAM,qBAAqB,MAAM;AAC/B,QAAM,MAAM,MAAM,WAAW,kBAAkB;AAC/C,SAAO,KAAK;AACd;AAEA,MAAM,0BAA0B,CAC9B,UACsB;AACtB,QAAM,EAAE,UAAU,QAAQ,IAAI;AAC9B,SAAO,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,EAAE,OAAO,QAAQ,GAAI,UAAS;AAC3E;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useAuth, useDeriveAuth } from "@tern-secure/react";
|
|
4
|
+
import { useRouter } from "next/compat/router";
|
|
5
|
+
import React from "react";
|
|
6
|
+
const PromiseAuthContext = React.createContext(null);
|
|
7
|
+
function PromiseAuthProvider({
|
|
8
|
+
authPromise,
|
|
9
|
+
children
|
|
10
|
+
}) {
|
|
11
|
+
return /* @__PURE__ */ jsx(PromiseAuthContext.Provider, { value: authPromise, children });
|
|
12
|
+
}
|
|
13
|
+
function usePromiseAuth() {
|
|
14
|
+
const isPagesRouter = useRouter();
|
|
15
|
+
const valueFromContext = React.useContext(PromiseAuthContext);
|
|
16
|
+
let resolvedData = valueFromContext;
|
|
17
|
+
if (valueFromContext && "then" in valueFromContext) {
|
|
18
|
+
resolvedData = React.use(valueFromContext);
|
|
19
|
+
}
|
|
20
|
+
if (typeof window === "undefined") {
|
|
21
|
+
if (isPagesRouter) {
|
|
22
|
+
return useAuth();
|
|
23
|
+
}
|
|
24
|
+
return useDeriveAuth({ ...resolvedData });
|
|
25
|
+
} else {
|
|
26
|
+
return useAuth();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
PromiseAuthProvider,
|
|
31
|
+
usePromiseAuth
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=PromiseAuthProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/boundary/PromiseAuthProvider.tsx"],"sourcesContent":["'use client';\n\nimport { useAuth, useDeriveAuth } from '@tern-secure/react';\nimport type { TernSecureStateExtended } from '@tern-secure/types';\nimport { useRouter } from 'next/compat/router';\nimport React from 'react';\n\nconst PromiseAuthContext = React.createContext<\n Promise<TernSecureStateExtended> | TernSecureStateExtended | null\n>(null);\n\nexport function PromiseAuthProvider({\n authPromise,\n children,\n}: {\n authPromise: Promise<TernSecureStateExtended> | TernSecureStateExtended;\n children: React.ReactNode;\n}) {\n return <PromiseAuthContext.Provider value={authPromise}>{children}</PromiseAuthContext.Provider>;\n}\n\nexport function usePromiseAuth() {\n const isPagesRouter = useRouter();\n const valueFromContext = React.useContext(PromiseAuthContext);\n\n let resolvedData = valueFromContext;\n if (valueFromContext && 'then' in valueFromContext) {\n resolvedData = React.use(valueFromContext);\n }\n\n if (typeof window === 'undefined') {\n // Pages router should always use useAuth as it is able to grab initial auth state from context during SSR.\n if (isPagesRouter) {\n return useAuth();\n }\n\n return useDeriveAuth({ ...resolvedData });\n } else {\n return useAuth();\n }\n}\n"],"mappings":";AAkBS;AAhBT,SAAS,SAAS,qBAAqB;AAEvC,SAAS,iBAAiB;AAC1B,OAAO,WAAW;AAElB,MAAM,qBAAqB,MAAM,cAE/B,IAAI;AAEC,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AACF,GAGG;AACD,SAAO,oBAAC,mBAAmB,UAAnB,EAA4B,OAAO,aAAc,UAAS;AACpE;AAEO,SAAS,iBAAiB;AAC/B,QAAM,gBAAgB,UAAU;AAChC,QAAM,mBAAmB,MAAM,WAAW,kBAAkB;AAE5D,MAAI,eAAe;AACnB,MAAI,oBAAoB,UAAU,kBAAkB;AAClD,mBAAe,MAAM,IAAI,gBAAgB;AAAA,EAC3C;AAEA,MAAI,OAAO,WAAW,aAAa;AAEjC,QAAI,eAAe;AACjB,aAAO,QAAQ;AAAA,IACjB;AAEA,WAAO,cAAc,EAAE,GAAG,aAAa,CAAC;AAAA,EAC1C,OAAO;AACL,WAAO,QAAQ;AAAA,EACjB;AACF;","names":[]}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
|
-
useAuth,
|
|
3
2
|
useIdToken,
|
|
4
3
|
useSession,
|
|
5
4
|
useSignIn,
|
|
5
|
+
useSignInContext,
|
|
6
|
+
useTernSecure,
|
|
7
|
+
SignInProvider,
|
|
6
8
|
signIn
|
|
7
9
|
} from "@tern-secure/react";
|
|
10
|
+
import { usePromiseAuth } from "./PromiseAuthProvider";
|
|
8
11
|
export {
|
|
12
|
+
SignInProvider,
|
|
9
13
|
signIn,
|
|
10
|
-
useAuth,
|
|
14
|
+
usePromiseAuth as useAuth,
|
|
11
15
|
useIdToken,
|
|
12
16
|
useSession,
|
|
13
|
-
useSignIn
|
|
17
|
+
useSignIn,
|
|
18
|
+
useSignInContext,
|
|
19
|
+
useTernSecure
|
|
14
20
|
};
|
|
15
21
|
//# sourceMappingURL=components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/boundary/components.ts"],"sourcesContent":["export { \n
|
|
1
|
+
{"version":3,"sources":["../../../src/boundary/components.ts"],"sourcesContent":["export { \n useIdToken,\n useSession,\n useSignIn,\n useSignInContext,\n useTernSecure,\n SignInProvider,\n signIn,\n} from '@tern-secure/react';\n\nexport { usePromiseAuth as useAuth } from './PromiseAuthProvider';"],"mappings":"AAAA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,SAA2B,sBAAe;","names":[]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { TernSecureProvider } from "./app-router/
|
|
1
|
+
import { TernSecureProvider } from "./app-router/server/TernSecureProvider";
|
|
2
2
|
import {
|
|
3
3
|
useAuth,
|
|
4
4
|
useIdToken,
|
|
5
5
|
useSession,
|
|
6
6
|
useSignIn,
|
|
7
|
-
signIn
|
|
7
|
+
signIn,
|
|
8
|
+
useSignInContext,
|
|
9
|
+
useTernSecure,
|
|
10
|
+
SignInProvider
|
|
8
11
|
} from "./boundary/components";
|
|
9
12
|
export {
|
|
13
|
+
SignInProvider,
|
|
10
14
|
TernSecureProvider,
|
|
11
15
|
signIn,
|
|
12
16
|
useAuth,
|
|
13
17
|
useIdToken,
|
|
14
18
|
useSession,
|
|
15
|
-
useSignIn
|
|
19
|
+
useSignIn,
|
|
20
|
+
useSignInContext,
|
|
21
|
+
useTernSecure
|
|
16
22
|
};
|
|
17
23
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { TernSecureProvider } from './app-router/
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { TernSecureProvider } from './app-router/server/TernSecureProvider'\r\nexport {\r\n useAuth,\r\n useIdToken,\r\n useSession,\r\n useSignIn,\r\n signIn,\r\n useSignInContext,\r\n useTernSecure,\r\n SignInProvider\r\n //SignIn,\r\n //SignOut,\r\n //SignOutButton,\r\n //SignUp,\r\n} from './boundary/components'\r\n\r\nexport type { TernSecureUser, TernSecureUserData, SignInResponse } from '@tern-secure/types'\r\n\r\nexport type {\r\n UserInfo,\r\n SessionResult\r\n} from './types'"],"mappings":"AAAA,SAAS,0BAA0B;AACnC;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKG;","names":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AuthStatus, signedInAuthObject, signedOutAuthObject } from "@tern-secure/backend";
|
|
2
|
+
import { ternDecodeJwt } from "@tern-secure/backend/jwt";
|
|
3
|
+
import { getAuthKeyFromRequest } from "../../server/headers-utils";
|
|
4
|
+
const authObjectToSerializable = (obj) => {
|
|
5
|
+
const { require: require2, ...rest } = obj;
|
|
6
|
+
return rest;
|
|
7
|
+
};
|
|
8
|
+
function getTernSecureAuthData(req, initialState = {}) {
|
|
9
|
+
const authObject = getAuthDataFromRequest(req);
|
|
10
|
+
return authObjectToSerializable({ ...initialState, ...authObject });
|
|
11
|
+
}
|
|
12
|
+
function getAuthDataFromRequest(req) {
|
|
13
|
+
const authStatus = getAuthKeyFromRequest(req, "AuthStatus");
|
|
14
|
+
const authToken = getAuthKeyFromRequest(req, "AuthToken");
|
|
15
|
+
const authSignature = getAuthKeyFromRequest(req, "AuthSignature");
|
|
16
|
+
const authReason = getAuthKeyFromRequest(req, "AuthReason");
|
|
17
|
+
let authObject;
|
|
18
|
+
if (!authStatus || authStatus !== AuthStatus.SignedIn) {
|
|
19
|
+
authObject = signedOutAuthObject();
|
|
20
|
+
} else {
|
|
21
|
+
const jwt = ternDecodeJwt(authToken);
|
|
22
|
+
authObject = signedInAuthObject(jwt.raw.text, jwt.payload);
|
|
23
|
+
}
|
|
24
|
+
return authObject;
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
authObjectToSerializable,
|
|
28
|
+
getAuthDataFromRequest,
|
|
29
|
+
getTernSecureAuthData
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=getAuthDataFromRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/server/data/getAuthDataFromRequest.ts"],"sourcesContent":["import type { AuthObject } from '@tern-secure/backend';\nimport { AuthStatus, signedInAuthObject, signedOutAuthObject } from '@tern-secure/backend';\nimport { ternDecodeJwt } from '@tern-secure/backend/jwt';\n\nimport { getAuthKeyFromRequest } from '../../server/headers-utils';\nimport type { RequestLike } from '../../server/types';\n\n\n/**\n * Auth objects moving through the server -> client boundary need to be serializable\n * as we need to ensure that they can be transferred via the network as pure strings.\n * Some frameworks like Remix or Next (/pages dir only) handle this serialization by simply\n * ignoring any non-serializable keys, however Nextjs /app directory is stricter and\n * throws an error if a non-serializable value is found.\n * @internal\n */\nexport const authObjectToSerializable = <T extends Record<string, unknown>>(obj: T): T => {\n // remove any non-serializable props from the returned object\n\n const { require, ...rest } = obj as unknown as AuthObject;\n return rest as unknown as T;\n};\n\nexport function getTernSecureAuthData(req: RequestLike, initialState = {}) {\n const authObject = getAuthDataFromRequest(req);\n return authObjectToSerializable({ ...initialState, ...authObject });\n}\n\nexport function getAuthDataFromRequest(req: RequestLike): AuthObject {\n const authStatus = getAuthKeyFromRequest(req, 'AuthStatus');\n const authToken = getAuthKeyFromRequest(req, 'AuthToken');\n const authSignature = getAuthKeyFromRequest(req, 'AuthSignature');\n const authReason = getAuthKeyFromRequest(req, 'AuthReason');\n\n let authObject;\n if (!authStatus || authStatus !== AuthStatus.SignedIn) {\n authObject = signedOutAuthObject();\n } else {\n const jwt = ternDecodeJwt(authToken as string);\n\n authObject = signedInAuthObject(jwt.raw.text, jwt.payload);\n }\n return authObject;\n}\n"],"mappings":"AACA,SAAS,YAAY,oBAAoB,2BAA2B;AACpE,SAAS,qBAAqB;AAE9B,SAAS,6BAA6B;AAY/B,MAAM,2BAA2B,CAAoC,QAAc;AAGxF,QAAM,EAAE,SAAAA,UAAS,GAAG,KAAK,IAAI;AAC7B,SAAO;AACT;AAEO,SAAS,sBAAsB,KAAkB,eAAe,CAAC,GAAG;AACzE,QAAM,aAAa,uBAAuB,GAAG;AAC7C,SAAO,yBAAyB,EAAE,GAAG,cAAc,GAAG,WAAW,CAAC;AACpE;AAEO,SAAS,uBAAuB,KAA8B;AACnE,QAAM,aAAa,sBAAsB,KAAK,YAAY;AAC1D,QAAM,YAAY,sBAAsB,KAAK,WAAW;AACxD,QAAM,gBAAgB,sBAAsB,KAAK,eAAe;AAChE,QAAM,aAAa,sBAAsB,KAAK,YAAY;AAE1D,MAAI;AACJ,MAAI,CAAC,cAAc,eAAe,WAAW,UAAU;AACrD,iBAAa,oBAAoB;AAAA,EACnC,OAAO;AACL,UAAM,MAAM,cAAc,SAAmB;AAE7C,iBAAa,mBAAmB,IAAI,IAAI,MAAM,IAAI,OAAO;AAAA,EAC3D;AACA,SAAO;AACT;","names":["require"]}
|
package/dist/esm/server/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
ternSecureMiddleware
|
|
3
3
|
} from "./ternSecureEdgeMiddleware";
|
|
4
4
|
import { createRouteMatcher } from "./routeMatcher";
|
|
5
|
+
import { ternSecureBackendClient } from "./ternsecureClient";
|
|
5
6
|
import {
|
|
6
7
|
auth
|
|
7
8
|
} from "../app-router/server/auth";
|
|
@@ -10,6 +11,7 @@ export {
|
|
|
10
11
|
NextCookieStore,
|
|
11
12
|
auth,
|
|
12
13
|
createRouteMatcher,
|
|
14
|
+
ternSecureBackendClient,
|
|
13
15
|
ternSecureMiddleware
|
|
14
16
|
};
|
|
15
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\r\n ternSecureMiddleware,\r\n} from \"./ternSecureEdgeMiddleware\";\r\nexport { createRouteMatcher } from \"./routeMatcher\";\r\nexport {\r\n auth\r\n} from \"../app-router/server/auth\";\r\nexport type { AuthResult } from \"../app-router/server/auth\";\r\nexport type { BaseUser, SessionResult } from \"./types\";\r\nexport { NextCookieStore } from \"../utils/NextCookieAdapter\";\r\n"],"mappings":"AAAA;AAAA,EACE;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,OACK;AAGP,SAAS,uBAAuB;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/server/index.ts"],"sourcesContent":["export {\r\n ternSecureMiddleware,\r\n} from \"./ternSecureEdgeMiddleware\";\r\nexport { createRouteMatcher } from \"./routeMatcher\";\r\nexport { ternSecureBackendClient } from \"./ternsecureClient\";\r\nexport {\r\n auth\r\n} from \"../app-router/server/auth\";\r\nexport type { AuthResult } from \"../app-router/server/auth\";\r\nexport type { BaseUser, SessionResult } from \"./types\";\r\nexport { NextCookieStore } from \"../utils/NextCookieAdapter\";\r\n"],"mappings":"AAAA;AAAA,EACE;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,SAAS,+BAA+B;AACxC;AAAA,EACE;AAAA,OACK;AAGP,SAAS,uBAAuB;","names":[]}
|
package/dist/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types.ts"],"sourcesContent":["import type { TernSecureProviderProps } from '@tern-secure/react'\r\n\r\nimport type { ERRORS } from './errors'\r\n\r\n\r\n/**\r\n * TernSecure User\r\n */\r\n//export type TernSecureUser = FirebaseUser\r\n\r\nexport type TernSecureUserData = {\r\n uid: string\r\n email: string | null\r\n emailVerified?: boolean\r\n displayName?: string | null\r\n}\r\n\r\n\r\n/**\r\n * TernSecure Firebase configuration interface\r\n * Extends Firebase's base configuration options\r\n */\r\n//export interface TernSecureConfig extends FirebaseOptions {\r\n// apiKey: string\r\n// authDomain: string\r\n// projectId: string\r\n// storageBucket: string\r\n// messagingSenderId: string\r\n// appId: string\r\n// measurementId?: string // Optional for analytics\r\n//}\r\n\r\n/**\r\n * TernSecure initialization options\r\n */\r\nexport interface TernSecureOptions {\r\n /** Environment setting for different configurations */\r\n environment?: 'development' | 'production'\r\n /** Geographic region for data storage */\r\n region?: string\r\n /** Custom error handler */\r\n onError?: (error: Error) => void\r\n /** Debug mode flag */\r\n debug?: boolean\r\n}\r\n\r\n/**\r\n * Firebase initialization state\r\n */\r\nexport interface FirebaseState {\r\n /** Whether Firebase has been initialized */\r\n initialized: boolean\r\n /** Any initialization errors */\r\n error: Error | null\r\n /** Timestamp of last initialization attempt */\r\n lastInitAttempt?: number\r\n}\r\n\r\n/**\r\n * Configuration validation result\r\n */\r\nexport interface ConfigValidationResult {\r\n isValid: boolean\r\n errors: string[]\r\n //config: TernSecureConfig\r\n}\r\n\r\n/**\r\n * Firebase Admin configuration interface\r\n */\r\nexport interface TernSecureAdminConfig {\r\n projectId: string\r\n clientEmail: string\r\n privateKey: string\r\n}\r\n\r\n/**\r\n * Firebase Admin configuration validation result\r\n */\r\nexport interface AdminConfigValidationResult {\r\n isValid: boolean\r\n errors: string[]\r\n config: TernSecureAdminConfig\r\n}\r\n\r\n\r\nexport interface SignInResponse {\r\n success: boolean;\r\n message?: string;\r\n error?: keyof typeof ERRORS | undefined; \r\n user?: any;\r\n}\r\n\r\nexport interface AuthError extends Error {\r\n code?: string\r\n message: string\r\n response?: SignInResponse\r\n}\r\n\r\nexport function isSignInResponse(value: any): value is SignInResponse {\r\n return typeof value === \"object\" && \"success\" in value && typeof value.success === \"boolean\"\r\n}\r\n\r\n\r\nexport interface TernSecureState {\r\n userId: string | null\r\n isLoaded: boolean\r\n error: Error | null\r\n isValid: boolean\r\n isVerified: boolean\r\n isAuthenticated: boolean\r\n token: any | null\r\n email: string | null\r\n status: \"loading\" | \"authenticated\" | \"unauthenticated\" | \"unverified\"\r\n requiresVerification: boolean\r\n}\r\n\r\nexport interface RedirectConfig {\r\n // URL to redirect to after successful authentication\r\n redirectUrl?: string\r\n // Whether this is a return visit (e.g. after sign out)\r\n isReturn?: boolean\r\n // Priority of the redirect (higher number = higher priority)\r\n priority?: number\r\n}\r\n\r\n\r\nexport interface SignInProps extends RedirectConfig {\r\n onError?: (error: Error) => void\r\n onSuccess?: () => void\r\n className?: string\r\n customStyles?: {\r\n card?: string\r\n input?: string\r\n button?: string\r\n label?: string\r\n separator?: string\r\n title?: string\r\n description?: string\r\n socialButton?: string\r\n }\r\n}\r\n\r\n\r\nexport type TernSecureNextProps = TernSecureProviderProps & {\r\n apiKey?: string\r\n requiresVerification?: boolean\r\n loadingComponent?: React.ReactNode\r\n}\r\n\r\nexport interface User {\r\n uid: string\r\n email: string | null\r\n emailVerified?: boolean\r\n authTime?: number\r\n disabled?: boolean\r\n}\r\n\r\nexport interface BaseUser {\r\n uid: string\r\n email: string | null\r\n emailVerified?: boolean\r\n tenantId: string | null\r\n authTime?: number\r\n}\r\n \r\n\r\n\r\n export interface UserInfo {\r\n uid: string\r\n email: string | null\r\n emailVerified?: boolean\r\n authTime?: number\r\n disabled?: boolean\r\n }\r\n \r\n export interface SessionUser {\r\n uid: string\r\n email: string | null\r\n emailVerified: boolean\r\n disabled?: boolean\r\n }\r\n \r\n export interface SessionResult {\r\n isAuthenticated: boolean\r\n user: UserInfo | null\r\n error?: string\r\n }\r\n\r\n\r\n"],"mappings":"AAmGO,SAAS,iBAAiB,OAAqC;AACpE,SAAO,OAAO,UAAU,YAAY,aAAa,SAAS,OAAO,MAAM,YAAY;AACrF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types.ts"],"sourcesContent":["import type { TernSecureProviderProps } from '@tern-secure/react'\r\n\r\nimport type { ERRORS } from './errors'\r\n\r\n\r\n/**\r\n * TernSecure User\r\n */\r\n//export type TernSecureUser = FirebaseUser\r\n\r\nexport type TernSecureUserData = {\r\n uid: string\r\n email: string | null\r\n emailVerified?: boolean\r\n displayName?: string | null\r\n}\r\n\r\n\r\n/**\r\n * TernSecure Firebase configuration interface\r\n * Extends Firebase's base configuration options\r\n */\r\n//export interface TernSecureConfig extends FirebaseOptions {\r\n// apiKey: string\r\n// authDomain: string\r\n// projectId: string\r\n// storageBucket: string\r\n// messagingSenderId: string\r\n// appId: string\r\n// measurementId?: string // Optional for analytics\r\n//}\r\n\r\n/**\r\n * TernSecure initialization options\r\n */\r\nexport interface TernSecureOptions {\r\n /** Environment setting for different configurations */\r\n environment?: 'development' | 'production'\r\n /** Geographic region for data storage */\r\n region?: string\r\n /** Custom error handler */\r\n onError?: (error: Error) => void\r\n /** Debug mode flag */\r\n debug?: boolean\r\n}\r\n\r\n/**\r\n * Firebase initialization state\r\n */\r\nexport interface FirebaseState {\r\n /** Whether Firebase has been initialized */\r\n initialized: boolean\r\n /** Any initialization errors */\r\n error: Error | null\r\n /** Timestamp of last initialization attempt */\r\n lastInitAttempt?: number\r\n}\r\n\r\n/**\r\n * Configuration validation result\r\n */\r\nexport interface ConfigValidationResult {\r\n isValid: boolean\r\n errors: string[]\r\n //config: TernSecureConfig\r\n}\r\n\r\n/**\r\n * Firebase Admin configuration interface\r\n */\r\nexport interface TernSecureAdminConfig {\r\n projectId: string\r\n clientEmail: string\r\n privateKey: string\r\n}\r\n\r\n/**\r\n * Firebase Admin configuration validation result\r\n */\r\nexport interface AdminConfigValidationResult {\r\n isValid: boolean\r\n errors: string[]\r\n config: TernSecureAdminConfig\r\n}\r\n\r\n\r\nexport interface SignInResponse {\r\n success: boolean;\r\n message?: string;\r\n error?: keyof typeof ERRORS | undefined; \r\n user?: any;\r\n}\r\n\r\nexport interface AuthError extends Error {\r\n code?: string\r\n message: string\r\n response?: SignInResponse\r\n}\r\n\r\nexport function isSignInResponse(value: any): value is SignInResponse {\r\n return typeof value === \"object\" && \"success\" in value && typeof value.success === \"boolean\"\r\n}\r\n\r\n\r\nexport interface TernSecureState {\r\n userId: string | null\r\n isLoaded: boolean\r\n error: Error | null\r\n isValid: boolean\r\n isVerified: boolean\r\n isAuthenticated: boolean\r\n token: any | null\r\n email: string | null\r\n status: \"loading\" | \"authenticated\" | \"unauthenticated\" | \"unverified\"\r\n requiresVerification: boolean\r\n}\r\n\r\nexport interface RedirectConfig {\r\n // URL to redirect to after successful authentication\r\n redirectUrl?: string\r\n // Whether this is a return visit (e.g. after sign out)\r\n isReturn?: boolean\r\n // Priority of the redirect (higher number = higher priority)\r\n priority?: number\r\n}\r\n\r\n\r\nexport interface SignInProps extends RedirectConfig {\r\n onError?: (error: Error) => void\r\n onSuccess?: () => void\r\n className?: string\r\n customStyles?: {\r\n card?: string\r\n input?: string\r\n button?: string\r\n label?: string\r\n separator?: string\r\n title?: string\r\n description?: string\r\n socialButton?: string\r\n }\r\n}\r\n\r\n\r\nexport type TernSecureNextProps = TernSecureProviderProps & {\r\n apiKey?: string\r\n requiresVerification?: boolean\r\n loadingComponent?: React.ReactNode\r\n}\r\n\r\nexport interface User {\r\n uid: string\r\n email: string | null\r\n emailVerified?: boolean\r\n authTime?: number\r\n disabled?: boolean\r\n}\r\n\r\nexport interface BaseUser {\r\n uid: string\r\n email: string | null\r\n emailVerified?: boolean\r\n tenantId: string | null\r\n authTime?: number\r\n}\r\n \r\n\r\n\r\n export interface UserInfo {\r\n uid: string\r\n email: string | null\r\n emailVerified?: boolean\r\n authTime?: number\r\n disabled?: boolean\r\n }\r\n \r\n export interface SessionUser {\r\n uid: string\r\n email: string | null\r\n emailVerified: boolean\r\n disabled?: boolean\r\n }\r\n \r\n export interface SessionResult {\r\n isAuthenticated: boolean\r\n user: UserInfo | null\r\n error?: string\r\n }\r\n\r\n export type NextProviderProcessedProps = Omit<TernSecureProviderProps, 'children'>;\r\n\r\n\r\n"],"mappings":"AAmGO,SAAS,iBAAiB,OAAqC;AACpE,SAAO,OAAO,UAAU,YAAY,aAAa,SAAS,OAAO,MAAM,YAAY;AACrF;","names":[]}
|
|
@@ -2,12 +2,13 @@ const allNextProviderPropsWithEnv = (nextProps) => {
|
|
|
2
2
|
const {
|
|
3
3
|
signInUrl,
|
|
4
4
|
signUpUrl,
|
|
5
|
-
apiKey: propsApiKey,
|
|
5
|
+
//apiKey: propsApiKey,
|
|
6
6
|
apiUrl: propsApiUrl,
|
|
7
7
|
requiresVerification: propsRequiresVerification,
|
|
8
8
|
isTernSecureDev: propsIsTernSecureDev,
|
|
9
9
|
enableServiceWorker: propsEnableServiceWorker,
|
|
10
10
|
loadingComponent: propsLoadingComponent,
|
|
11
|
+
persistence: propsPersistence,
|
|
11
12
|
...baseProps
|
|
12
13
|
} = nextProps;
|
|
13
14
|
const envConfig = {
|
|
@@ -36,11 +37,10 @@ const allNextProviderPropsWithEnv = (nextProps) => {
|
|
|
36
37
|
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENTID,
|
|
37
38
|
tenantId: process.env.NEXT_PUBLIC_FIREBASE_TENANT_ID || ""
|
|
38
39
|
};
|
|
39
|
-
const finalApiKey = propsApiKey ?? envConfig.apiKey;
|
|
40
40
|
const finalApiUrl = propsApiUrl ?? envConfig.apiUrl;
|
|
41
41
|
const finalSignInUrl = signInUrl ?? envConfig.signInUrl;
|
|
42
42
|
const finalSignUpUrl = signUpUrl ?? envConfig.signUpUrl;
|
|
43
|
-
const finalPersistence =
|
|
43
|
+
const finalPersistence = propsPersistence ?? envConfig.persistence;
|
|
44
44
|
const result = {
|
|
45
45
|
...baseProps,
|
|
46
46
|
// Set the Firebase configuration properties
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/allNextProviderProps.ts"],"sourcesContent":["import type { \n IsoTernSecureAuthOptions,\n TernSecureProviderProps} from \"@tern-secure/react\";\n\nimport type { TernSecureNextProps } from \"../types\";\n\n// Helper type for the return value, as children are handled by the consuming component\
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/allNextProviderProps.ts"],"sourcesContent":["import type { \n IsoTernSecureAuthOptions,\n TernSecureProviderProps} from \"@tern-secure/react\";\n\nimport type { NextProviderProcessedProps, TernSecureNextProps } from \"../types\";\n\n// Helper type for the return value, as children are handled by the consuming component\n\n\nexport const allNextProviderPropsWithEnv = (\n nextProps: Omit<TernSecureNextProps, 'children'>\n): NextProviderProcessedProps => {\n const {\n signInUrl,\n signUpUrl,\n //apiKey: propsApiKey,\n apiUrl: propsApiUrl,\n requiresVerification: propsRequiresVerification,\n isTernSecureDev: propsIsTernSecureDev,\n enableServiceWorker: propsEnableServiceWorker,\n loadingComponent: propsLoadingComponent,\n persistence: propsPersistence,\n ...baseProps \n } = nextProps;\n\n const envConfig = {\n apiKey: process.env.NEXT_PUBLIC_TERN_API_KEY,\n apiUrl: process.env.TERNSECURE_API_URL || '',\n projectId: process.env.NEXT_PUBLIC_TERN_PROJECT_ID,\n customDomain: process.env.NEXT_PUBLIC_TERN_CUSTOM_DOMAIN,\n proxyUrl: process.env.NEXT_PUBLIC_TERN_PROXY_URL,\n environment: process.env.NEXT_PUBLIC_TERN_ENVIRONMENT,\n signInUrl: process.env.NEXT_PUBLIC_SIGN_IN_URL,\n signUpUrl: process.env.NEXT_PUBLIC_SIGN_UP_URL,\n persistence: process.env.NEXT_PUBLIC_TERN_PERSISTENCE as 'local' | 'session' | 'browserCookie' | 'none',\n useEmulator: process.env.NEXT_PUBLIC_USE_FIREBASE_EMULATOR,\n projectIdAdmin: process.env.FIREBASE_PROJECT_ID,\n clientEmail: process.env.FIREBASE_CLIENT_EMAIL,\n privateKey: process.env.FIREBASE_PRIVATE_KEY,\n };\n\n const ternSecureConfig = {\n apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY || '',\n authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN || '',\n appName: process.env.NEXT_PUBLIC_FIREBASE_APP_NAME || '',\n projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID || '',\n storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET || '',\n messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID || '',\n appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID || '',\n measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENTID,\n tenantId: process.env.NEXT_PUBLIC_FIREBASE_TENANT_ID || '',\n };\n\n // Merge config values: props take precedence over environment variables\n //const finalApiKey = propsApiKey ?? envConfig.apiKey;\n const finalApiUrl = propsApiUrl ?? envConfig.apiUrl;\n const finalSignInUrl = signInUrl ?? envConfig.signInUrl;\n const finalSignUpUrl = signUpUrl ?? envConfig.signUpUrl;\n const finalPersistence = propsPersistence ?? envConfig.persistence;\n\n // Construct the result, ensuring it conforms to NextProviderProcessedProps\n // (Omit<TernSecureProviderProps, 'children'>)\n const result: NextProviderProcessedProps = {\n ...(baseProps as Omit<TernSecureProviderProps, 'children' | keyof IsoTernSecureAuthOptions | 'requiresVerification' | 'loadingComponent'>),\n\n // Set the Firebase configuration properties\n ternSecureConfig,\n \n // Set properties explicitly taken from TernSecureNextProps (props version)\n // These are part of the TernSecureProviderProps interface.\n requiresVerification: propsRequiresVerification,\n isTernSecureDev: propsIsTernSecureDev,\n enableServiceWorker: propsEnableServiceWorker,\n loadingComponent: propsLoadingComponent,\n\n //TernSecure: baseProps.Instance,\n initialState: baseProps.initialState,\n bypassApiKey: baseProps.bypassApiKey,\n signInUrl: finalSignInUrl,\n signUpUrl: finalSignUpUrl,\n mode: baseProps.mode,\n apiUrl: finalApiUrl,\n persistence: finalPersistence\n };\n\n // Clean up undefined keys that might have resulted from spreading if not present in baseProps\n // and also not set by merged values (e.g. if env var is also undefined)\n Object.keys(result).forEach(key => {\n if (result[key as keyof NextProviderProcessedProps] === undefined) {\n delete result[key as keyof NextProviderProcessedProps];\n }\n });\n\n return result;\n};"],"mappings":"AASO,MAAM,8BAA8B,CACzC,cAC+B;AAC/B,QAAM;AAAA,IACJ;AAAA,IACA;AAAA;AAAA,IAEA,QAAQ;AAAA,IACR,sBAAsB;AAAA,IACtB,iBAAiB;AAAA,IACjB,qBAAqB;AAAA,IACrB,kBAAkB;AAAA,IAClB,aAAa;AAAA,IACb,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,YAAY;AAAA,IAChB,QAAQ,QAAQ,IAAI;AAAA,IACpB,QAAQ,QAAQ,IAAI,sBAAsB;AAAA,IAC1C,WAAW,QAAQ,IAAI;AAAA,IACvB,cAAc,QAAQ,IAAI;AAAA,IAC1B,UAAU,QAAQ,IAAI;AAAA,IACtB,aAAa,QAAQ,IAAI;AAAA,IACzB,WAAW,QAAQ,IAAI;AAAA,IACvB,WAAW,QAAQ,IAAI;AAAA,IACvB,aAAa,QAAQ,IAAI;AAAA,IACzB,aAAa,QAAQ,IAAI;AAAA,IACzB,gBAAgB,QAAQ,IAAI;AAAA,IAC5B,aAAa,QAAQ,IAAI;AAAA,IACzB,YAAY,QAAQ,IAAI;AAAA,EAC1B;AAEA,QAAM,mBAAmB;AAAA,IACvB,QAAQ,QAAQ,IAAI,gCAAgC;AAAA,IACpD,YAAY,QAAQ,IAAI,oCAAoC;AAAA,IAC5D,SAAS,QAAQ,IAAI,iCAAiC;AAAA,IACtD,WAAW,QAAQ,IAAI,mCAAmC;AAAA,IAC1D,eAAe,QAAQ,IAAI,uCAAuC;AAAA,IAClE,mBAAmB,QAAQ,IAAI,4CAA4C;AAAA,IAC3E,OAAO,QAAQ,IAAI,+BAA+B;AAAA,IAClD,eAAe,QAAQ,IAAI;AAAA,IAC3B,UAAU,QAAQ,IAAI,kCAAkC;AAAA,EAC1D;AAIA,QAAM,cAAc,eAAe,UAAU;AAC7C,QAAM,iBAAiB,aAAa,UAAU;AAC9C,QAAM,iBAAiB,aAAa,UAAU;AAC9C,QAAM,mBAAmB,oBAAoB,UAAU;AAIvD,QAAM,SAAqC;AAAA,IACzC,GAAI;AAAA;AAAA,IAGJ;AAAA;AAAA;AAAA,IAIA,sBAAsB;AAAA,IACtB,iBAAiB;AAAA,IACjB,qBAAqB;AAAA,IACrB,kBAAkB;AAAA;AAAA,IAGlB,cAAc,UAAU;AAAA,IACxB,cAAc,UAAU;AAAA,IACxB,WAAW;AAAA,IACX,WAAW;AAAA,IACX,MAAM,UAAU;AAAA,IAChB,QAAQ;AAAA,IACR,aAAa;AAAA,EACf;AAIA,SAAO,KAAK,MAAM,EAAE,QAAQ,SAAO;AACjC,QAAI,OAAO,GAAuC,MAAM,QAAW;AACjE,aAAO,OAAO,GAAuC;AAAA,IACvD;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpointRouter.d.ts","sourceRoot":"","sources":["../../../../src/app-router/admin/endpointRouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAGhF,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEtE,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC;IAC3C,MAAM,CAAC,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC/F;
|
|
1
|
+
{"version":3,"file":"endpointRouter.d.ts","sourceRoot":"","sources":["../../../../src/app-router/admin/endpointRouter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAGhF,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEtE,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAAC;IAC3C,MAAM,CAAC,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC/F;AAwCD,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAI9B;WAEW,KAAK,CAChB,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,QAAQ,CAAC;IAgBpB,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAIjD,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,GAAG,IAAI;CAM7E"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type RequestProcessorContext } from './c-authenticateRequestProcessor';
|
|
2
2
|
import type { TernSecureHandlerOptions } from './types';
|
|
3
|
-
|
|
3
|
+
declare function sessionEndpointHandler(context: RequestProcessorContext, config: TernSecureHandlerOptions): Promise<Response>;
|
|
4
|
+
declare function cookieEndpointHandler(context: RequestProcessorContext, config: TernSecureHandlerOptions): Promise<Response>;
|
|
5
|
+
export { sessionEndpointHandler, cookieEndpointHandler };
|
|
4
6
|
//# sourceMappingURL=sessionHandlers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessionHandlers.d.ts","sourceRoot":"","sources":["../../../../src/app-router/admin/sessionHandlers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAIhF,OAAO,KAAK,EAAsB,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAE5E,
|
|
1
|
+
{"version":3,"file":"sessionHandlers.d.ts","sourceRoot":"","sources":["../../../../src/app-router/admin/sessionHandlers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAIhF,OAAO,KAAK,EAAsB,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAE5E,iBAAe,sBAAsB,CACnC,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,QAAQ,CAAC,CAgInB;AAED,iBAAe,qBAAqB,CAClC,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE,wBAAwB,GAC/B,OAAO,CAAC,QAAQ,CAAC,CAgFnB;AAED,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthEndpoint, CookieOpts as CookieOptions, CorsOptions, EndpointConfig, SecurityOptions, SessionEndpointConfig, SessionSubEndpoint, TernSecureHandlerOptions, TokenCookieConfig } from '@tern-secure/types';
|
|
1
|
+
import type { AuthEndpoint, CookieEndpointConfig, CookieOpts as CookieOptions, CorsOptions, EndpointConfig, SecurityOptions, SessionEndpointConfig, SessionSubEndpoint, TernSecureHandlerOptions, TokenCookieConfig } from '@tern-secure/types';
|
|
2
2
|
import { type NextResponse } from 'next/server';
|
|
3
3
|
export declare const DEFAULT_CORS_OPTIONS: CorsOptions;
|
|
4
4
|
export declare const DEFAULT_COOKIE_OPTIONS: CookieOptions;
|
|
@@ -30,6 +30,7 @@ export declare const FIXED_TOKEN_CONFIGS: {
|
|
|
30
30
|
};
|
|
31
31
|
export declare const DEFAULT_SECURITY_OPTIONS: SecurityOptions;
|
|
32
32
|
export declare const DEFAULT_ENDPOINT_CONFIG: EndpointConfig;
|
|
33
|
+
export declare const DEFAULT_COOKIE_REQUEST_CONFIG: CookieEndpointConfig;
|
|
33
34
|
export declare const DEFAULT_SESSIONS_CONFIG: SessionEndpointConfig;
|
|
34
35
|
export declare const DEFAULT_HANDLER_OPTIONS: Required<TernSecureHandlerOptions> & {
|
|
35
36
|
endpoints: Required<NonNullable<TernSecureHandlerOptions['endpoints']>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/app-router/admin/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,IAAI,aAAa,EAC3B,WAAW,EACX,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,oBAAoB,EAAE,WAMlC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,aAOpC,CAAC;AAGF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;CAyBtB,CAAC;AAEX,eAAO,MAAM,wBAAwB,EAAE,eAStC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,cAKrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,qBAqCrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,wBAAwB,CAAC,GAAG;IACzE,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,wBAAwB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/app-router/admin/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,UAAU,IAAI,aAAa,EAC3B,WAAW,EACX,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,oBAAoB,EAAE,WAMlC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,aAOpC,CAAC;AAGF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;CAyBtB,CAAC;AAEX,eAAO,MAAM,wBAAwB,EAAE,eAStC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,cAKrC,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,oBAa3C,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,qBAqCrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,wBAAwB,CAAC,GAAG;IACzE,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,wBAAwB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;CAoBzE,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,eAAe,CAAC;IAC3B,QAAQ,CAAC,EAAE;QACT,IAAI,EAAE,YAAY,CAAC;QACnB,MAAM,EAAE,cAAc,CAAC;KACxB,CAAC;IACF,WAAW,CAAC,EAAE;QACZ,IAAI,EAAE,kBAAkB,CAAC;QACzB,MAAM,EAAE,cAAc,CAAC;KACxB,CAAC;IACF,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,6BAA6B;IAC5C,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,YAAY,CAAC,EAAE,QAAQ,CAAC;IACxB,WAAW,CAAC,EAAE;QACZ,IAAI,EAAE,GAAG,CAAC;QACV,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,MAAM,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;AAE3E,qBAAa,WAAW;IACtB,MAAM,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAInE,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,MAAM;;;;;;;IAUxC,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,iBAAiB;IAYxE,MAAM,CAAC,mBAAmB,CACxB,SAAS,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,GACpC,iBAAiB;IAWpB,MAAM,CAAC,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;CAKtD;AAED,OAAO,EACL,YAAY,EACZ,aAAa,EACb,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,wBAAwB,GACzB,CAAC"}
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Root Provider for TernSecure
|
|
5
|
-
* Use this in your Next.js App Router root layout
|
|
6
|
-
* Automatically handles client/server boundary and authentication state
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* /// app/layout.tsx
|
|
10
|
-
* import { TernSecureProvider } from '@tern/secure'
|
|
11
|
-
*
|
|
12
|
-
* export default function RootLayout({ children }) {
|
|
13
|
-
* return (
|
|
14
|
-
* <html>
|
|
15
|
-
* <body>
|
|
16
|
-
* <TernSecureProvider>
|
|
17
|
-
* {children}
|
|
18
|
-
* </TernSecureProvider>
|
|
19
|
-
* </body>
|
|
20
|
-
* </html>
|
|
21
|
-
* )
|
|
22
|
-
* }
|
|
23
|
-
*/
|
|
24
|
-
export declare function TernSecureProvider(props: React.PropsWithChildren<TernSecureNextProps>): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import type { TernSecureNextProps } from '../../types';
|
|
2
|
+
export declare const ClientTernSecureProvider: (props: TernSecureNextProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
3
|
//# sourceMappingURL=TernSecureProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TernSecureProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TernSecureProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAqBvD,eAAO,MAAM,wBAAwB,GAAI,OAAO,mBAAmB,4CAOlE,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TernSecureNextProps } from '../../types';
|
|
3
|
+
export declare function TernSecureProvider(props: TernSecureNextProps): Promise<React.ReactElement<unknown, string | React.JSXElementConstructor<any>>>;
|
|
4
|
+
//# sourceMappingURL=TernSecureProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TernSecureProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/server/TernSecureProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAWvD,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,mFA4ClE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/app-router/server/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/app-router/server/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAY,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAKrD,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,oBAAoB,CAAC;AAGhE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;GAEG;AACH,KAAK,IAAI,GAAG,UAAU,GAAG;IACvB,gBAAgB,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC;IAC3D,gBAAgB,EAAE,WAAW,CAAC,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC;CAC5D,CAAC;AAEF,MAAM,WAAW,MAAM;IACrB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAElB,OAAO,EAAE,WAAW,CAAC;CACtB;AAQD;;GAEG;AACH,eAAO,MAAM,IAAI,EAAE,MAwClB,CAAC"}
|