@tern-secure/nextjs 4.0.0 → 4.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/dist/cjs/app-router/client/TernSecureProvider.js +17 -2
- package/dist/cjs/app-router/client/TernSecureProvider.js.map +1 -1
- package/dist/cjs/app-router/client/actions.js +49 -49
- package/dist/cjs/app-router/client/actions.js.map +1 -1
- package/dist/cjs/app-router/route-handler/internal-route.js +17 -2
- package/dist/cjs/app-router/route-handler/internal-route.js.map +1 -1
- package/dist/cjs/boundary/TernSecureClientProvider.js +163 -40
- package/dist/cjs/boundary/TernSecureClientProvider.js.map +1 -1
- package/dist/cjs/boundary/TernSecureCtx.js.map +1 -1
- package/dist/cjs/boundary/hooks/useAuth.js +7 -8
- package/dist/cjs/boundary/hooks/useAuth.js.map +1 -1
- package/dist/cjs/components/sign-in.js +136 -45
- package/dist/cjs/components/sign-in.js.map +1 -1
- package/dist/cjs/components/sign-out-button.js +10 -1
- package/dist/cjs/components/sign-out-button.js.map +1 -1
- package/dist/cjs/components/sign-out.js +12 -3
- package/dist/cjs/components/sign-out.js.map +1 -1
- package/dist/cjs/components/sign-up.js +10 -5
- package/dist/cjs/components/sign-up.js.map +1 -1
- package/dist/cjs/errors.js +232 -5
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/index.js +0 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types.js +14 -0
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/construct.js +50 -18
- package/dist/cjs/utils/construct.js.map +1 -1
- package/dist/cjs/utils/redirect.js +57 -0
- package/dist/cjs/utils/redirect.js.map +1 -0
- package/dist/esm/app-router/client/TernSecureProvider.js +17 -2
- package/dist/esm/app-router/client/TernSecureProvider.js.map +1 -1
- package/dist/esm/app-router/client/actions.js +59 -51
- package/dist/esm/app-router/client/actions.js.map +1 -1
- package/dist/esm/app-router/route-handler/internal-route.js +13 -1
- package/dist/esm/app-router/route-handler/internal-route.js.map +1 -1
- package/dist/esm/boundary/TernSecureClientProvider.js +164 -41
- package/dist/esm/boundary/TernSecureClientProvider.js.map +1 -1
- package/dist/esm/boundary/TernSecureCtx.js.map +1 -1
- package/dist/esm/boundary/hooks/useAuth.js +7 -8
- package/dist/esm/boundary/hooks/useAuth.js.map +1 -1
- package/dist/esm/components/sign-in.js +137 -46
- package/dist/esm/components/sign-in.js.map +1 -1
- package/dist/esm/components/sign-out-button.js +11 -2
- package/dist/esm/components/sign-out-button.js.map +1 -1
- package/dist/esm/components/sign-out.js +13 -4
- package/dist/esm/components/sign-out.js.map +1 -1
- package/dist/esm/components/sign-up.js +10 -5
- package/dist/esm/components/sign-up.js.map +1 -1
- package/dist/esm/errors.js +228 -4
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types.js +6 -0
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/construct.js +46 -17
- package/dist/esm/utils/construct.js.map +1 -1
- package/dist/esm/utils/redirect.js +32 -0
- package/dist/esm/utils/redirect.js.map +1 -0
- package/dist/types/app-router/client/TernSecureProvider.d.ts +14 -3
- package/dist/types/app-router/client/TernSecureProvider.d.ts.map +1 -1
- package/dist/types/app-router/client/actions.d.ts +23 -21
- package/dist/types/app-router/client/actions.d.ts.map +1 -1
- package/dist/types/app-router/route-handler/internal-route.d.ts +3 -0
- package/dist/types/app-router/route-handler/internal-route.d.ts.map +1 -1
- package/dist/types/boundary/TernSecureClientProvider.d.ts +17 -1
- package/dist/types/boundary/TernSecureClientProvider.d.ts.map +1 -1
- package/dist/types/boundary/TernSecureCtx.d.ts +3 -1
- package/dist/types/boundary/TernSecureCtx.d.ts.map +1 -1
- package/dist/types/boundary/hooks/useAuth.d.ts +4 -1
- package/dist/types/boundary/hooks/useAuth.d.ts.map +1 -1
- package/dist/types/components/sign-in.d.ts +1 -2
- package/dist/types/components/sign-in.d.ts.map +1 -1
- package/dist/types/components/sign-out-button.d.ts +2 -1
- package/dist/types/components/sign-out-button.d.ts.map +1 -1
- package/dist/types/components/sign-out.d.ts +2 -1
- package/dist/types/components/sign-out.d.ts.map +1 -1
- package/dist/types/components/sign-up.d.ts.map +1 -1
- package/dist/types/components/ui/alert.d.ts +1 -1
- package/dist/types/components/ui/button.d.ts +1 -1
- package/dist/types/errors.d.ts +36 -2
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types.d.ts +35 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/construct.d.ts +20 -4
- package/dist/types/utils/construct.d.ts.map +1 -1
- package/dist/types/utils/redirect.d.ts +9 -0
- package/dist/types/utils/redirect.d.ts.map +1 -0
- package/package.json +6 -6
- package/dist/cjs/boundary/hooks/useUser.js +0 -44
- package/dist/cjs/boundary/hooks/useUser.js.map +0 -1
- package/dist/esm/boundary/hooks/useUser.js +0 -20
- package/dist/esm/boundary/hooks/useUser.js.map +0 -1
- package/dist/types/boundary/hooks/useUser.d.ts +0 -7
- package/dist/types/boundary/hooks/useUser.d.ts.map +0 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { headers } from "next/headers";
|
|
2
|
+
async function validateRedirectUrl(url) {
|
|
3
|
+
if (!url) return "/";
|
|
4
|
+
try {
|
|
5
|
+
if (url.startsWith("/")) {
|
|
6
|
+
const validPaths = ["/"];
|
|
7
|
+
return validPaths.includes(url) ? url : "/";
|
|
8
|
+
}
|
|
9
|
+
const headersList = await headers();
|
|
10
|
+
const currentHost = headersList.get("host");
|
|
11
|
+
const urlObj = new URL(url);
|
|
12
|
+
if (urlObj.host === currentHost) {
|
|
13
|
+
return urlObj.pathname;
|
|
14
|
+
}
|
|
15
|
+
} catch {
|
|
16
|
+
}
|
|
17
|
+
return "/";
|
|
18
|
+
}
|
|
19
|
+
async function getCurrentPath() {
|
|
20
|
+
try {
|
|
21
|
+
const headersList = await headers();
|
|
22
|
+
const pathname = headersList.get("x-pathname") || "/";
|
|
23
|
+
return pathname;
|
|
24
|
+
} catch {
|
|
25
|
+
return "/";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
getCurrentPath,
|
|
30
|
+
validateRedirectUrl
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=redirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/redirect.ts"],"sourcesContent":["import { headers } from \"next/headers\"\n\n/**\n * Validates and sanitizes redirect URLs\n */\nexport async function validateRedirectUrl(url: string | null): Promise<string> {\n if (!url) return \"/\"\n\n try {\n // Check if it's a relative path\n if (url.startsWith(\"/\")) {\n // Basic validation to ensure the path exists in your app\n // Add more paths as needed\n const validPaths = [\"/\"]\n return validPaths.includes(url) ? url : \"/\"\n }\n\n // If it's an absolute URL, ensure it's from your domain\n const headersList = await headers()\n const currentHost = headersList.get(\"host\")\n const urlObj = new URL(url)\n if (urlObj.host === currentHost) {\n return urlObj.pathname\n }\n } catch {\n // Invalid URL format\n }\n\n return \"/\"\n}\n\n/**\n * Gets the current path for redirect purposes\n */\nexport async function getCurrentPath(): Promise<string> {\n try {\n const headersList = await headers()\n const pathname = headersList.get(\"x-pathname\") || \"/\"\n return pathname\n } catch {\n return \"/\"\n }\n}\n\n"],"mappings":"AAAA,SAAS,eAAe;AAKxB,eAAsB,oBAAoB,KAAqC;AAC7E,MAAI,CAAC,IAAK,QAAO;AAEjB,MAAI;AAEF,QAAI,IAAI,WAAW,GAAG,GAAG;AAGvB,YAAM,aAAa,CAAC,GAAG;AACvB,aAAO,WAAW,SAAS,GAAG,IAAI,MAAM;AAAA,IAC1C;AAGC,UAAM,cAAc,MAAM,QAAQ;AACnC,UAAM,cAAc,YAAY,IAAI,MAAM;AAC1C,UAAM,SAAS,IAAI,IAAI,GAAG;AAC1B,QAAI,OAAO,SAAS,aAAa;AAC/B,aAAO,OAAO;AAAA,IAChB;AAAA,EACF,QAAQ;AAAA,EAER;AAEA,SAAO;AACT;AAKA,eAAsB,iBAAkC;AACtD,MAAI;AACF,UAAM,cAAc,MAAM,QAAQ;AAClC,UAAM,WAAW,YAAY,IAAI,YAAY,KAAK;AAClD,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for TernSecure authentication
|
|
4
|
+
*/
|
|
5
|
+
export interface TernSecureConfig {
|
|
6
|
+
/** Whether email verification is required (defaults to true) */
|
|
7
|
+
requiresVerification?: boolean;
|
|
8
|
+
/** Custom path for login page (defaults to /sign-in) */
|
|
9
|
+
loginPath?: string;
|
|
10
|
+
/** Custom path for signup page (defaults to /sign-up) */
|
|
11
|
+
signUpPath?: string;
|
|
12
|
+
/** Custom loading component */
|
|
13
|
+
loadingComponent?: React.ReactNode;
|
|
14
|
+
}
|
|
2
15
|
/**
|
|
3
16
|
* Root Provider for TernSecure
|
|
4
17
|
* Use this in your Next.js App Router root layout
|
|
@@ -20,7 +33,5 @@ import React from "react";
|
|
|
20
33
|
* )
|
|
21
34
|
* }
|
|
22
35
|
*/
|
|
23
|
-
export declare function TernSecureProvider({ children }:
|
|
24
|
-
children: React.ReactNode;
|
|
25
|
-
}): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
36
|
+
export declare function TernSecureProvider({ children, requiresVerification, loginPath, signUpPath, loadingComponent, }: React.PropsWithChildren<TernSecureConfig>): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
26
37
|
//# sourceMappingURL=TernSecureProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TernSecureProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"TernSecureProvider.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/TernSecureProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,+BAA+B;IAC/B,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACnC;AAUD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,QAAQ,EACR,oBAA2B,EAC3B,SAAS,EACT,UAAU,EACV,gBAAgB,GAChB,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,oDAW5C"}
|
|
@@ -1,53 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
success: boolean;
|
|
4
|
-
message?: string;
|
|
5
|
-
error?: typeof ERRORS[keyof typeof ERRORS];
|
|
6
|
-
user?: any;
|
|
7
|
-
}
|
|
8
|
-
export declare function createUser(email: string, password: string): Promise<{
|
|
9
|
-
success: boolean;
|
|
10
|
-
message: string;
|
|
11
|
-
user: import("firebase/auth").User;
|
|
12
|
-
}>;
|
|
1
|
+
import type { SignInResponse } from '../../types';
|
|
2
|
+
export declare function createUser(email: string, password: string): Promise<SignInResponse>;
|
|
13
3
|
export declare function signInWithEmail(email: string, password: string): Promise<SignInResponse>;
|
|
14
4
|
export declare function signInWithRedirectGoogle(): Promise<{
|
|
15
5
|
success: boolean;
|
|
16
6
|
message: string;
|
|
17
7
|
error?: undefined;
|
|
8
|
+
user?: undefined;
|
|
18
9
|
} | {
|
|
19
10
|
success: boolean;
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
message: string;
|
|
12
|
+
error: "AUTHENTICATED" | "UNAUTHENTICATED" | "UNVERIFIED" | "EMAIL_NOT_VERIFIED" | "INVALID_CREDENTIALS" | "USER_DISABLED" | "TOO_MANY_ATTEMPTS" | "NETWORK_ERROR" | "INVALID_EMAIL" | "WEAK_PASSWORD" | "EMAIL_EXISTS" | "POPUP_BLOCKED" | "OPERATION_NOT_ALLOWED" | "EXPIRED_TOKEN" | "INVALID_TOKEN" | "SESSION_EXPIRED" | "INTERNAL_ERROR" | "SERVER_SIDE_INITIALIZATION" | "REQUIRES_VERIFICATION" | "NOT_INITIALIZED" | "HOOK_CONTEXT";
|
|
13
|
+
user: null;
|
|
22
14
|
}>;
|
|
23
15
|
export declare function signInWithMicrosoft(): Promise<{
|
|
24
16
|
success: boolean;
|
|
25
17
|
message: string;
|
|
26
18
|
error?: undefined;
|
|
19
|
+
user?: undefined;
|
|
27
20
|
} | {
|
|
28
21
|
success: boolean;
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
message: string;
|
|
23
|
+
error: "AUTHENTICATED" | "UNAUTHENTICATED" | "UNVERIFIED" | "EMAIL_NOT_VERIFIED" | "INVALID_CREDENTIALS" | "USER_DISABLED" | "TOO_MANY_ATTEMPTS" | "NETWORK_ERROR" | "INVALID_EMAIL" | "WEAK_PASSWORD" | "EMAIL_EXISTS" | "POPUP_BLOCKED" | "OPERATION_NOT_ALLOWED" | "EXPIRED_TOKEN" | "INVALID_TOKEN" | "SESSION_EXPIRED" | "INTERNAL_ERROR" | "SERVER_SIDE_INITIALIZATION" | "REQUIRES_VERIFICATION" | "NOT_INITIALIZED" | "HOOK_CONTEXT";
|
|
24
|
+
user: null;
|
|
31
25
|
}>;
|
|
32
26
|
export declare function handleAuthRedirectResult(): Promise<{
|
|
33
27
|
success: boolean;
|
|
34
28
|
user: import("firebase/auth").User;
|
|
35
29
|
error?: undefined;
|
|
36
|
-
|
|
30
|
+
message?: undefined;
|
|
37
31
|
} | {
|
|
38
32
|
success: boolean;
|
|
39
33
|
error: string;
|
|
40
34
|
user?: undefined;
|
|
41
|
-
|
|
35
|
+
message?: undefined;
|
|
42
36
|
} | {
|
|
43
37
|
success: boolean;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
user
|
|
38
|
+
message: string;
|
|
39
|
+
error: "AUTHENTICATED" | "UNAUTHENTICATED" | "UNVERIFIED" | "EMAIL_NOT_VERIFIED" | "INVALID_CREDENTIALS" | "USER_DISABLED" | "TOO_MANY_ATTEMPTS" | "NETWORK_ERROR" | "INVALID_EMAIL" | "WEAK_PASSWORD" | "EMAIL_EXISTS" | "POPUP_BLOCKED" | "OPERATION_NOT_ALLOWED" | "EXPIRED_TOKEN" | "INVALID_TOKEN" | "SESSION_EXPIRED" | "INTERNAL_ERROR" | "SERVER_SIDE_INITIALIZATION" | "REQUIRES_VERIFICATION" | "NOT_INITIALIZED" | "HOOK_CONTEXT";
|
|
40
|
+
user: null;
|
|
47
41
|
}>;
|
|
48
42
|
export declare function resendEmailVerification(): Promise<{
|
|
49
43
|
success: boolean;
|
|
50
44
|
message: string;
|
|
51
45
|
isVerified: boolean;
|
|
46
|
+
error?: undefined;
|
|
47
|
+
user?: undefined;
|
|
48
|
+
} | {
|
|
49
|
+
success: boolean;
|
|
50
|
+
message: string;
|
|
51
|
+
error: "AUTHENTICATED" | "UNAUTHENTICATED" | "UNVERIFIED" | "EMAIL_NOT_VERIFIED" | "INVALID_CREDENTIALS" | "USER_DISABLED" | "TOO_MANY_ATTEMPTS" | "NETWORK_ERROR" | "INVALID_EMAIL" | "WEAK_PASSWORD" | "EMAIL_EXISTS" | "POPUP_BLOCKED" | "OPERATION_NOT_ALLOWED" | "EXPIRED_TOKEN" | "INVALID_TOKEN" | "SESSION_EXPIRED" | "INTERNAL_ERROR" | "SERVER_SIDE_INITIALIZATION" | "REQUIRES_VERIFICATION" | "NOT_INITIALIZED" | "HOOK_CONTEXT";
|
|
52
|
+
user: null;
|
|
53
|
+
isVerified?: undefined;
|
|
52
54
|
}>;
|
|
53
55
|
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/actions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../src/app-router/client/actions.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAIjD,wBAAsB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CA4BzF;AAGD,wBAAsB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAsB9F;AAED,wBAAsB,wBAAwB;;;;;;;;;;GAoB7C;AAGD,wBAAsB,mBAAmB;;;;;;;;;;GAmBxC;AAGD,wBAAsB,wBAAwB;;;;;;;;;;;;;;;GAmB7C;AAGD,wBAAsB,uBAAuB;;;;;;;;;;;;GAsC5C"}
|
|
@@ -9,5 +9,8 @@ export declare const internalRoutes: {
|
|
|
9
9
|
component: typeof Verify;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
+
export declare function isInternalRoute(pathname: string): boolean;
|
|
13
|
+
export declare function isAuthRoute(pathname: string): boolean;
|
|
14
|
+
export declare function isBaseAuthRoute(pathname: string): boolean;
|
|
12
15
|
export declare function handleInternalRoute(pathname: string): typeof Verify | null;
|
|
13
16
|
//# sourceMappingURL=internal-route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-route.d.ts","sourceRoot":"","sources":["../../../../src/app-router/route-handler/internal-route.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAGhD,eAAO,MAAM,cAAc;;;;;;;;;CAS1B,CAAA;AAGD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,wBAOnD"}
|
|
1
|
+
{"version":3,"file":"internal-route.d.ts","sourceRoot":"","sources":["../../../../src/app-router/route-handler/internal-route.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAGhD,eAAO,MAAM,cAAc;;;;;;;;;CAS1B,CAAA;AAGD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzD;AAGD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAErD;AAGD,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzD;AAGD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,wBAOnD"}
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { User } from "firebase/auth";
|
|
3
|
+
/**
|
|
4
|
+
* @internal
|
|
5
|
+
* Internal provider props - not meant for direct usage
|
|
6
|
+
*/
|
|
3
7
|
interface TernSecureClientProviderProps {
|
|
4
8
|
children: React.ReactNode;
|
|
9
|
+
/** Callback when user state changes */
|
|
5
10
|
onUserChanged?: (user: User | null) => Promise<void>;
|
|
11
|
+
/** Login page path */
|
|
6
12
|
loginPath?: string;
|
|
13
|
+
/** Signup page path */
|
|
14
|
+
signUpPath?: string;
|
|
15
|
+
/** Custom loading component */
|
|
7
16
|
loadingComponent?: React.ReactNode;
|
|
17
|
+
/** Whether email verification is required */
|
|
18
|
+
requiresVerification: boolean;
|
|
8
19
|
}
|
|
9
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
* Internal provider component that handles authentication state
|
|
23
|
+
* This is wrapped by the public TernSecureProvider
|
|
24
|
+
*/
|
|
25
|
+
export declare function TernSecureClientProvider({ children, loginPath, signUpPath, loadingComponent, requiresVerification, }: TernSecureClientProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
10
26
|
export {};
|
|
11
27
|
//# sourceMappingURL=TernSecureClientProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TernSecureClientProvider.d.ts","sourceRoot":"","sources":["../../../src/boundary/TernSecureClientProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAExE,OAAO,EAAsB,IAAI,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"TernSecureClientProvider.d.ts","sourceRoot":"","sources":["../../../src/boundary/TernSecureClientProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAExE,OAAO,EAAsB,IAAI,EAAE,MAAM,eAAe,CAAA;AAUxD;;;GAGG;AACH,UAAU,6BAA6B;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,uCAAuC;IACvC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IACpD,sBAAsB;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,uBAAuB;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,+BAA+B;IAC/B,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAClC,6CAA6C;IAC7C,oBAAoB,EAAE,OAAO,CAAA;CAC9B;AAED;;;;GAIG;AAEH,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,EACR,SAA8D,EAC9D,UAA+D,EAC/D,gBAAgB,EAChB,oBAAoB,GACrB,EAAE,6BAA6B,2CAqP/B"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { User } from 'firebase/auth';
|
|
2
|
-
import {
|
|
2
|
+
import type { TernSecureState, SignInResponse } from '../types';
|
|
3
3
|
export declare const TernSecureUser: () => User | null;
|
|
4
4
|
export interface TernSecureCtxValue extends TernSecureState {
|
|
5
5
|
signOut: () => Promise<void>;
|
|
6
6
|
setEmail: (email: string) => void;
|
|
7
|
+
getAuthError: () => SignInResponse;
|
|
8
|
+
redirectToLogin: () => void;
|
|
7
9
|
}
|
|
8
10
|
export declare const TernSecureCtx: import("react").Context<TernSecureCtxValue | null>;
|
|
9
11
|
export declare const useTernSecure: (hookName: string) => TernSecureCtxValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TernSecureCtx.d.ts","sourceRoot":"","sources":["../../../src/boundary/TernSecureCtx.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"TernSecureCtx.d.ts","sourceRoot":"","sources":["../../../src/boundary/TernSecureCtx.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAEhE,eAAO,MAAM,cAAc,QAAO,IAAI,GAAG,IAExC,CAAA;AAED,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IAC1D,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5B,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,YAAY,EAAE,MAAM,cAAc,CAAA;IAClC,eAAe,EAAE,MAAM,IAAI,CAAA;CAC3B;AAED,eAAO,MAAM,aAAa,oDAAiD,CAAA;AAI3E,eAAO,MAAM,aAAa,aAAc,MAAM,uBAU7C,CAAA"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { User } from 'firebase/auth';
|
|
2
|
+
import type { SignInResponse } from '../../types';
|
|
2
3
|
export declare function useAuth(): {
|
|
3
4
|
user: User | null;
|
|
4
5
|
userId: string | null;
|
|
5
6
|
isLoaded: boolean;
|
|
6
|
-
error:
|
|
7
|
+
error: SignInResponse | null;
|
|
7
8
|
isValid: boolean;
|
|
8
9
|
isVerified: boolean;
|
|
9
10
|
isAuthenticated: boolean;
|
|
10
11
|
token: any;
|
|
12
|
+
status: "loading" | "authenticated" | "unauthenticated" | "unverified";
|
|
13
|
+
requiresVerification: boolean;
|
|
11
14
|
signOut: () => Promise<void>;
|
|
12
15
|
};
|
|
13
16
|
//# sourceMappingURL=useAuth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../../src/boundary/hooks/useAuth.ts"],"names":[],"mappings":"AAGA,OAAO,EAAG,IAAI,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"useAuth.d.ts","sourceRoot":"","sources":["../../../../src/boundary/hooks/useAuth.ts"],"names":[],"mappings":"AAGA,OAAO,EAAG,IAAI,EAAE,MAAM,eAAe,CAAA;AAErC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGjD,wBAAgB,OAAO;;;;;;;;;;;;EAgCtB"}
|
|
@@ -2,7 +2,6 @@ export interface SignInProps {
|
|
|
2
2
|
redirectUrl?: string;
|
|
3
3
|
onError?: (error: Error) => void;
|
|
4
4
|
onSuccess?: () => void;
|
|
5
|
-
requiresVerification?: boolean;
|
|
6
5
|
className?: string;
|
|
7
6
|
customStyles?: {
|
|
8
7
|
card?: string;
|
|
@@ -15,5 +14,5 @@ export interface SignInProps {
|
|
|
15
14
|
socialButton?: string;
|
|
16
15
|
};
|
|
17
16
|
}
|
|
18
|
-
export declare function SignIn({ redirectUrl, onError, onSuccess,
|
|
17
|
+
export declare function SignIn({ redirectUrl, onError, onSuccess, className, customStyles }: SignInProps): import("react/jsx-runtime").JSX.Element;
|
|
19
18
|
//# sourceMappingURL=sign-in.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign-in.d.ts","sourceRoot":"","sources":["../../../src/components/sign-in.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sign-in.d.ts","sourceRoot":"","sources":["../../../src/components/sign-in.tsx"],"names":[],"mappings":"AA6BA,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,YAAY,CAAC,EAAE,MAAM,CAAA;KACtB,CAAA;CACF;AAGD,wBAAgB,MAAM,CAAC,EACrB,WAAW,EACX,OAAO,EACP,SAAS,EACT,SAAS,EACT,YAAiB,EAClB,EAAE,WAAW,2CAgWb"}
|
|
@@ -3,11 +3,12 @@ type SignOutCustomProps = {
|
|
|
3
3
|
children?: React.ReactNode;
|
|
4
4
|
onError?: (error: Error) => void;
|
|
5
5
|
onSignOutSuccess?: () => void;
|
|
6
|
+
redirectPath?: string;
|
|
6
7
|
className?: string;
|
|
7
8
|
variant?: ButtonProps['variant'];
|
|
8
9
|
size?: ButtonProps['size'];
|
|
9
10
|
};
|
|
10
11
|
type SignOutProps = Omit<ButtonProps, 'onClick'> & SignOutCustomProps;
|
|
11
|
-
export declare function SignOutButton({ children, onError, onSignOutSuccess, className, variant, size, ...buttonProps }: SignOutProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function SignOutButton({ children, onError, onSignOutSuccess, redirectPath, className, variant, size, ...buttonProps }: SignOutProps): import("react/jsx-runtime").JSX.Element;
|
|
12
13
|
export {};
|
|
13
14
|
//# sourceMappingURL=sign-out-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign-out-button.d.ts","sourceRoot":"","sources":["../../../src/components/sign-out-button.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"sign-out-button.d.ts","sourceRoot":"","sources":["../../../src/components/sign-out-button.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAU,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAOtD,KAAK,kBAAkB,GAAG;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAA;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;IAChC,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAC3B,CAAA;AAED,KAAK,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,kBAAkB,CAAA;AAErE,wBAAgB,aAAa,CAAC,EAC5B,QAAqB,EACrB,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,OAAmB,EACnB,IAAgB,EAChB,GAAG,WAAW,EACf,EAAE,YAAY,2CA8Cd"}
|
|
@@ -5,7 +5,8 @@ interface SignOutLinkProps {
|
|
|
5
5
|
className?: string;
|
|
6
6
|
activeClassName?: string;
|
|
7
7
|
disabled?: boolean;
|
|
8
|
+
redirectPath?: string;
|
|
8
9
|
}
|
|
9
|
-
export declare function SignOut({ children, onError, onSignOutSuccess, className, activeClassName, disabled, }: SignOutLinkProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function SignOut({ children, onError, onSignOutSuccess, className, activeClassName, disabled, redirectPath, }: SignOutLinkProps): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
11
12
|
//# sourceMappingURL=sign-out.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign-out.d.ts","sourceRoot":"","sources":["../../../src/components/sign-out.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sign-out.d.ts","sourceRoot":"","sources":["../../../src/components/sign-out.tsx"],"names":[],"mappings":"AAYA,UAAU,gBAAgB;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAA;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,wBAAgB,OAAO,CAAC,EACtB,QAAqB,EACrB,OAAO,EACP,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,QAAgB,EAChB,YAAY,GACb,EAAE,gBAAgB,2CAsDlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sign-up.d.ts","sourceRoot":"","sources":["../../../src/components/sign-up.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sign-up.d.ts","sourceRoot":"","sources":["../../../src/components/sign-up.tsx"],"names":[],"mappings":"AAoBA,MAAM,WAAW,WAAW;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACzB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,OAAO,CAAA;CACnB;AAGD,wBAAgB,MAAM,CAAC,EACnB,WAAW,EACX,OAAO,EACP,SAAS,GACX,EAAE,WAAW,2CA8Rd"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const Alert: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & VariantProps<(props?: ({
|
|
4
|
-
variant?: "
|
|
4
|
+
variant?: "destructive" | "default" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLDivElement>>;
|
|
6
6
|
declare const AlertTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLHeadingElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
7
7
|
declare const AlertDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
3
|
declare const buttonVariants: (props?: ({
|
|
4
|
-
variant?: "
|
|
4
|
+
variant?: "destructive" | "default" | "outline" | "secondary" | "ghost" | "link" | null | undefined;
|
|
5
5
|
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
6
6
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
7
7
|
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -1,10 +1,44 @@
|
|
|
1
|
+
import { SignInResponse } from "./types";
|
|
2
|
+
export type ErrorCode = keyof typeof ERRORS;
|
|
3
|
+
export interface AuthErrorResponse {
|
|
4
|
+
success: false;
|
|
5
|
+
message: string;
|
|
6
|
+
code: ErrorCode;
|
|
7
|
+
}
|
|
1
8
|
export declare const ERRORS: {
|
|
2
9
|
readonly SERVER_SIDE_INITIALIZATION: "TernSecure must be initialized on the client side";
|
|
3
10
|
readonly REQUIRES_VERIFICATION: "AUTH_REQUIRES_VERIFICATION";
|
|
11
|
+
readonly AUTHENTICATED: "AUTHENTICATED";
|
|
12
|
+
readonly UNAUTHENTICATED: "UNAUTHENTICATED";
|
|
13
|
+
readonly UNVERIFIED: "UNVERIFIED";
|
|
4
14
|
readonly NOT_INITIALIZED: "TernSecure services are not initialized. Call initializeTernSecure() first";
|
|
5
|
-
readonly HOOK_CONTEXT:
|
|
15
|
+
readonly HOOK_CONTEXT: "Hook must be used within TernSecureProvider";
|
|
16
|
+
readonly EMAIL_NOT_VERIFIED: "EMAIL_NOT_VERIFIED";
|
|
17
|
+
readonly INVALID_CREDENTIALS: "INVALID_CREDENTIALS";
|
|
18
|
+
readonly USER_DISABLED: "USER_DISABLED";
|
|
19
|
+
readonly TOO_MANY_ATTEMPTS: "TOO_MANY_ATTEMPTS";
|
|
20
|
+
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
21
|
+
readonly INVALID_EMAIL: "INVALID_EMAIL";
|
|
22
|
+
readonly WEAK_PASSWORD: "WEAK_PASSWORD";
|
|
23
|
+
readonly EMAIL_EXISTS: "EMAIL_EXISTS";
|
|
24
|
+
readonly POPUP_BLOCKED: "POPUP_BLOCKED";
|
|
25
|
+
readonly OPERATION_NOT_ALLOWED: "OPERATION_NOT_ALLOWED";
|
|
26
|
+
readonly EXPIRED_TOKEN: "EXPIRED_TOKEN";
|
|
27
|
+
readonly INVALID_TOKEN: "INVALID_TOKEN";
|
|
28
|
+
readonly SESSION_EXPIRED: "SESSION_EXPIRED";
|
|
29
|
+
readonly INTERNAL_ERROR: "INTERNAL_ERROR";
|
|
6
30
|
};
|
|
7
31
|
export declare class TernSecureError extends Error {
|
|
8
|
-
|
|
32
|
+
code: ErrorCode;
|
|
33
|
+
constructor(code: ErrorCode, message?: string);
|
|
9
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Handles Firebase authentication errors with multiple fallback mechanisms
|
|
37
|
+
*/
|
|
38
|
+
export declare function handleFirebaseAuthError(error: unknown): AuthErrorResponse;
|
|
39
|
+
/**
|
|
40
|
+
* Type guard to check if a response is an AuthErrorResponse
|
|
41
|
+
*/
|
|
42
|
+
export declare function isAuthErrorResponse(response: unknown): response is AuthErrorResponse;
|
|
43
|
+
export declare function getErrorAlertVariant(error: SignInResponse | undefined): "destructive" | "default";
|
|
10
44
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAExC,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,MAAM,CAAA;AAE3C,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,KAAK,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,SAAS,CAAA;CAChB;AAED,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;CAsBT,CAAA;AAmBV,qBAAa,eAAgB,SAAQ,KAAK;IACxC,IAAI,EAAE,SAAS,CAAA;gBAEH,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,MAAM;CAK9C;AAiJD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAwFzE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,iBAAiB,CASpF;AAID,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,SAAS,6BAsBrE"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export { loadFireConfig, validateConfig } from './utils/config';
|
|
|
3
3
|
export { signInWithEmail } from './app-router/client/actions';
|
|
4
4
|
export { TernSecureProvider } from './app-router/client/TernSecureProvider';
|
|
5
5
|
export { useAuth } from './boundary/hooks/useAuth';
|
|
6
|
-
export { useUser } from './boundary/hooks/useUser';
|
|
7
6
|
export { SignIn } from './components/sign-in';
|
|
8
7
|
export { SignOutButton } from './components/sign-out-button';
|
|
9
8
|
export { SignOut } from './components/sign-out';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAG7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAA;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACzF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAG7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAA;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { FirebaseOptions } from 'firebase/app';
|
|
2
|
+
import { ERRORS } from './errors';
|
|
2
3
|
/**
|
|
3
4
|
* TernSecure Firebase configuration interface
|
|
4
5
|
* Extends Firebase's base configuration options
|
|
@@ -60,6 +61,18 @@ export interface AdminConfigValidationResult {
|
|
|
60
61
|
errors: string[];
|
|
61
62
|
config: TernSecureAdminConfig;
|
|
62
63
|
}
|
|
64
|
+
export interface SignInResponse {
|
|
65
|
+
success: boolean;
|
|
66
|
+
message?: string;
|
|
67
|
+
error?: keyof typeof ERRORS | undefined;
|
|
68
|
+
user?: any;
|
|
69
|
+
}
|
|
70
|
+
export interface AuthError extends Error {
|
|
71
|
+
code?: string;
|
|
72
|
+
message: string;
|
|
73
|
+
response?: SignInResponse;
|
|
74
|
+
}
|
|
75
|
+
export declare function isSignInResponse(value: any): value is SignInResponse;
|
|
63
76
|
export interface TernSecureState {
|
|
64
77
|
userId: string | null;
|
|
65
78
|
isLoaded: boolean;
|
|
@@ -69,5 +82,27 @@ export interface TernSecureState {
|
|
|
69
82
|
isAuthenticated: boolean;
|
|
70
83
|
token: any | null;
|
|
71
84
|
email: string | null;
|
|
85
|
+
status: "loading" | "authenticated" | "unauthenticated" | "unverified";
|
|
86
|
+
requiresVerification: boolean;
|
|
87
|
+
}
|
|
88
|
+
export interface RedirectConfig {
|
|
89
|
+
redirectUrl?: string;
|
|
90
|
+
isReturn?: boolean;
|
|
91
|
+
priority?: number;
|
|
92
|
+
}
|
|
93
|
+
export interface SignInProps extends RedirectConfig {
|
|
94
|
+
onError?: (error: Error) => void;
|
|
95
|
+
onSuccess?: () => void;
|
|
96
|
+
className?: string;
|
|
97
|
+
customStyles?: {
|
|
98
|
+
card?: string;
|
|
99
|
+
input?: string;
|
|
100
|
+
button?: string;
|
|
101
|
+
label?: string;
|
|
102
|
+
separator?: string;
|
|
103
|
+
title?: string;
|
|
104
|
+
description?: string;
|
|
105
|
+
socialButton?: string;
|
|
106
|
+
};
|
|
72
107
|
}
|
|
73
108
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -5,18 +5,34 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const constructFullUrl: (path: string) => string;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Checks if the current URL has a redirect loop
|
|
9
|
+
* @param currentPath - The current pathname
|
|
10
|
+
* @param redirectPath - The path we're trying to redirect to
|
|
11
|
+
* @returns boolean indicating if there's a redirect loop
|
|
12
|
+
*/
|
|
13
|
+
export declare const hasRedirectLoop: (currentPath: string, redirectPath: string) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Constructs a URL with redirect parameters while preventing loops
|
|
9
16
|
* @param path - The base path (usually login path)
|
|
10
17
|
* @param redirectUrl - The URL to redirect to after action completes
|
|
11
18
|
* @param loginPath - The login path to check against
|
|
19
|
+
* @param signUpPath - The sign up path to check against
|
|
12
20
|
* @returns The full URL with redirect parameters
|
|
13
21
|
*/
|
|
14
|
-
export declare const constructUrlWithRedirect: (path: string, redirectUrl: string
|
|
22
|
+
export declare const constructUrlWithRedirect: (path: string, redirectUrl: string | undefined) => string;
|
|
23
|
+
/**
|
|
24
|
+
* Stores the current path before signing out
|
|
25
|
+
*/
|
|
26
|
+
export declare const storePreviousPath: (path: string) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the stored previous path
|
|
29
|
+
*/
|
|
30
|
+
export declare const getPreviousPath: () => string | null;
|
|
15
31
|
/**
|
|
16
32
|
* Gets a validated redirect URL ensuring it's from the same origin
|
|
17
33
|
* @param redirectUrl - The URL to validate
|
|
18
|
-
* @param searchParams - The search parameters to check for
|
|
34
|
+
* @param searchParams - The search parameters to check for redirect
|
|
19
35
|
* @returns A validated redirect URL
|
|
20
36
|
*/
|
|
21
|
-
export declare const getValidRedirectUrl: (
|
|
37
|
+
export declare const getValidRedirectUrl: (searchParams: URLSearchParams, configuredRedirect?: string) => string;
|
|
22
38
|
//# sourceMappingURL=construct.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../../src/utils/construct.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"construct.d.ts","sourceRoot":"","sources":["../../../src/utils/construct.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,SAAU,MAAM,WAO1C,CAAA;AAGH;;;;;GAKG;AACH,eAAO,MAAM,eAAe,gBAAiB,MAAM,gBAAgB,MAAM,KAAG,OAQ3E,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,SAC7B,MAAM,eACC,MAAM,GAAG,SAAS,KAC9B,MAQF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,SAAU,MAAM,KAAG,IAIhD,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,QAAO,MAAM,GAAG,IAK3C,CAAA;AAID;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,iBAChB,eAAe,uBACR,MAAM,KAC1B,MAcF,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates and sanitizes redirect URLs
|
|
3
|
+
*/
|
|
4
|
+
export declare function validateRedirectUrl(url: string | null): Promise<string>;
|
|
5
|
+
/**
|
|
6
|
+
* Gets the current path for redirect purposes
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCurrentPath(): Promise<string>;
|
|
9
|
+
//# sourceMappingURL=redirect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect.d.ts","sourceRoot":"","sources":["../../../src/utils/redirect.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAsB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAwB7E;AAED;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAQtD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tern-secure/nextjs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"packageManager": "npm@11.0.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"@eslint/js": "^9.15.0",
|
|
33
33
|
"@types/node": "^22.9.3",
|
|
34
34
|
"@types/react": "^18.3.12",
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
36
|
-
"@typescript-eslint/parser": "^8.
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^8.22.0",
|
|
36
|
+
"@typescript-eslint/parser": "^8.22.0",
|
|
37
37
|
"eslint": "^9.15.0",
|
|
38
38
|
"eslint-plugin-react": "^7.37.2",
|
|
39
39
|
"prettier": "^3.3.3",
|
|
40
40
|
"rimraf": "^6.0.1",
|
|
41
41
|
"tsup": "^8.3.5",
|
|
42
|
-
"turbo": "^2.
|
|
42
|
+
"turbo": "^2.4.0",
|
|
43
43
|
"typescript": "^5.7.2"
|
|
44
44
|
},
|
|
45
45
|
"types": "./dist/types/index.d.ts",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
],
|
|
49
49
|
"sideEffects": false,
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"firebase": "^
|
|
52
|
-
"firebase-admin": "^12.
|
|
51
|
+
"firebase": "^11.2.0",
|
|
52
|
+
"firebase-admin": "^12.7.0",
|
|
53
53
|
"next": "^13.0.0 || ^14.0.0 || ^15.0.0",
|
|
54
54
|
"react": "^18 || ^19.0.0-0",
|
|
55
55
|
"react-dom": "^18 || ^19.0.0-0"
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
"use client";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var useUser_exports = {};
|
|
21
|
-
__export(useUser_exports, {
|
|
22
|
-
useUser: () => useUser
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(useUser_exports);
|
|
25
|
-
var import_auth = require("firebase/auth");
|
|
26
|
-
var import_react = require("react");
|
|
27
|
-
var import_client_init = require("../../utils/client-init");
|
|
28
|
-
function useUser() {
|
|
29
|
-
const [user, setUser] = (0, import_react.useState)(null);
|
|
30
|
-
const [loading, setLoading] = (0, import_react.useState)(true);
|
|
31
|
-
(0, import_react.useEffect)(() => {
|
|
32
|
-
const unsubscribe = (0, import_auth.onAuthStateChanged)(import_client_init.ternSecureAuth, (authUser) => {
|
|
33
|
-
setUser(authUser);
|
|
34
|
-
setLoading(false);
|
|
35
|
-
});
|
|
36
|
-
return () => unsubscribe();
|
|
37
|
-
}, []);
|
|
38
|
-
return { user, loading };
|
|
39
|
-
}
|
|
40
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
-
0 && (module.exports = {
|
|
42
|
-
useUser
|
|
43
|
-
});
|
|
44
|
-
//# sourceMappingURL=useUser.js.map
|