@tern-secure/types 1.0.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/all.d.ts +105 -0
- package/dist/all.d.ts.map +1 -0
- package/dist/auth.d.ts +36 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/errors.d.ts +66 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/esm/index.js +173 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/index.d.mts +717 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +207 -0
- package/dist/index.js.map +1 -0
- package/dist/instanceTree.d.ts +116 -0
- package/dist/instanceTree.d.ts.map +1 -0
- package/dist/redirect.d.ts +8 -0
- package/dist/redirect.d.ts.map +1 -0
- package/dist/session.d.ts +76 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/signIn.d.ts +51 -0
- package/dist/signIn.d.ts.map +1 -0
- package/dist/signUp.d.ts +20 -0
- package/dist/signUp.d.ts.map +1 -0
- package/dist/ternsecure.d.ts +123 -0
- package/dist/ternsecure.d.ts.map +1 -0
- package/dist/theme.d.ts +133 -0
- package/dist/theme.d.ts.map +1 -0
- package/package.json +28 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './all';
|
|
2
|
+
export * from './errors';
|
|
3
|
+
export * from './ternsecure';
|
|
4
|
+
export * from './theme';
|
|
5
|
+
export * from './instanceTree';
|
|
6
|
+
export * from './auth';
|
|
7
|
+
export * from './signIn';
|
|
8
|
+
export * from './signUp';
|
|
9
|
+
export * from './session';
|
|
10
|
+
export * from './redirect';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA;AAC5B,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,QAAQ,CAAA;AACtB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
DEFAULT_TERN_SECURE_STATE: () => DEFAULT_TERN_SECURE_STATE,
|
|
24
|
+
ERRORS: () => ERRORS,
|
|
25
|
+
TernSecureError: () => TernSecureError,
|
|
26
|
+
getErrorAlertVariant: () => getErrorAlertVariant,
|
|
27
|
+
handleFirebaseAuthError: () => handleFirebaseAuthError,
|
|
28
|
+
isAuthErrorResponse: () => isAuthErrorResponse,
|
|
29
|
+
isSignInResponse: () => isSignInResponse,
|
|
30
|
+
isSignInResponseTree: () => isSignInResponseTree
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
33
|
+
|
|
34
|
+
// src/errors.ts
|
|
35
|
+
var ERRORS = {
|
|
36
|
+
SERVER_SIDE_INITIALIZATION: "TernSecure must be initialized on the client side",
|
|
37
|
+
REQUIRES_VERIFICATION: "AUTH_REQUIRES_VERIFICATION",
|
|
38
|
+
AUTHENTICATED: "AUTHENTICATED",
|
|
39
|
+
UNAUTHENTICATED: "UNAUTHENTICATED",
|
|
40
|
+
UNVERIFIED: "UNVERIFIED",
|
|
41
|
+
NOT_INITIALIZED: "TernSecure services are not initialized. Call initializeTernSecure() first",
|
|
42
|
+
HOOK_CONTEXT: "Hook must be used within TernSecureProvider",
|
|
43
|
+
EMAIL_NOT_VERIFIED: "EMAIL_NOT_VERIFIED",
|
|
44
|
+
INVALID_CREDENTIALS: "INVALID_CREDENTIALS",
|
|
45
|
+
USER_DISABLED: "USER_DISABLED",
|
|
46
|
+
TOO_MANY_ATTEMPTS: "TOO_MANY_ATTEMPTS",
|
|
47
|
+
NETWORK_ERROR: "NETWORK_ERROR",
|
|
48
|
+
INVALID_EMAIL: "INVALID_EMAIL",
|
|
49
|
+
WEAK_PASSWORD: "WEAK_PASSWORD",
|
|
50
|
+
EMAIL_EXISTS: "EMAIL_EXISTS",
|
|
51
|
+
POPUP_BLOCKED: "POPUP_BLOCKED",
|
|
52
|
+
OPERATION_NOT_ALLOWED: "OPERATION_NOT_ALLOWED",
|
|
53
|
+
EXPIRED_TOKEN: "EXPIRED_TOKEN",
|
|
54
|
+
INVALID_TOKEN: "INVALID_TOKEN",
|
|
55
|
+
SESSION_EXPIRED: "SESSION_EXPIRED",
|
|
56
|
+
INTERNAL_ERROR: "INTERNAL_ERROR",
|
|
57
|
+
UNKNOWN_ERROR: "An unknown error occurred.",
|
|
58
|
+
INVALID_ARGUMENT: "Invalid argument provided.",
|
|
59
|
+
USER_NOT_FOUND: "auth/user-not-found",
|
|
60
|
+
WRONG_PASSWORD: "auth/wrong-password",
|
|
61
|
+
EMAIL_ALREADY_IN_USE: "auth/email-already-in-use",
|
|
62
|
+
REQUIRES_RECENT_LOGIN: "auth/requires-recent-login",
|
|
63
|
+
NO_SESSION_COOKIE: "No session cookie found.",
|
|
64
|
+
INVALID_SESSION_COOKIE: "Invalid session cookie.",
|
|
65
|
+
NO_ID_TOKEN: "No ID token found.",
|
|
66
|
+
INVALID_ID_TOKEN: "Invalid ID token.",
|
|
67
|
+
REDIRECT_LOOP: "Redirect loop detected."
|
|
68
|
+
};
|
|
69
|
+
var TernSecureError = class extends Error {
|
|
70
|
+
code;
|
|
71
|
+
constructor(code, message) {
|
|
72
|
+
super(message || code);
|
|
73
|
+
this.name = "TernSecureError";
|
|
74
|
+
this.code = code;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function handleFirebaseAuthError(error) {
|
|
78
|
+
function extractErrorInfo(input) {
|
|
79
|
+
if (typeof input === "string") {
|
|
80
|
+
const match = input.match(/Firebase:\s*Error\s*\(auth\/([^)]+)\)/);
|
|
81
|
+
if (match) {
|
|
82
|
+
return { code: match[1], message: input };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (input && typeof input === "object") {
|
|
86
|
+
const err = input;
|
|
87
|
+
if (err.message) {
|
|
88
|
+
const match = err.message.match(/Firebase:\s*Error\s*\(auth\/([^)]+)\)/);
|
|
89
|
+
if (match) {
|
|
90
|
+
return { code: match[1], message: err.message };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (err.code) {
|
|
94
|
+
return {
|
|
95
|
+
code: err.code.replace("auth/", ""),
|
|
96
|
+
message: err.message || ""
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const ERROR_MESSAGES = {
|
|
103
|
+
"invalid-email": { message: "Invalid email format", code: "INVALID_EMAIL" },
|
|
104
|
+
"invalid-credential": { message: "Invalid email or password", code: "INVALID_CREDENTIALS" },
|
|
105
|
+
"invalid-login-credentials": { message: "Invalid email or password", code: "INVALID_CREDENTIALS" },
|
|
106
|
+
"wrong-password": { message: "Invalid email or password", code: "INVALID_CREDENTIALS" },
|
|
107
|
+
"user-not-found": { message: "Invalid email or password", code: "INVALID_CREDENTIALS" },
|
|
108
|
+
"user-disabled": { message: "This account has been disabled", code: "USER_DISABLED" },
|
|
109
|
+
"too-many-requests": { message: "Too many attempts. Please try again later", code: "TOO_MANY_ATTEMPTS" },
|
|
110
|
+
"network-request-failed": { message: "Network error. Please check your connection", code: "NETWORK_ERROR" },
|
|
111
|
+
"email-already-in-use": { message: "This email is already in use", code: "EMAIL_EXISTS" },
|
|
112
|
+
"weak-password": { message: "Password is too weak", code: "WEAK_PASSWORD" },
|
|
113
|
+
"operation-not-allowed": { message: "This login method is not enabled", code: "OPERATION_NOT_ALLOWED" },
|
|
114
|
+
"popup-blocked": { message: "Login popup was blocked. Please enable popups", code: "POPUP_BLOCKED" },
|
|
115
|
+
"expired-action-code": { message: "Your session has expired. Please login again", code: "EXPIRED_TOKEN" },
|
|
116
|
+
"user-token-expired": { message: "Your session has expired. Please login again", code: "EXPIRED_TOKEN" }
|
|
117
|
+
};
|
|
118
|
+
try {
|
|
119
|
+
const errorInfo = extractErrorInfo(error);
|
|
120
|
+
if (errorInfo) {
|
|
121
|
+
const mappedError = ERROR_MESSAGES[errorInfo.code];
|
|
122
|
+
if (mappedError) {
|
|
123
|
+
return {
|
|
124
|
+
success: false,
|
|
125
|
+
message: mappedError.message,
|
|
126
|
+
code: mappedError.code
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const errorString = String(error);
|
|
131
|
+
const lastMatch = errorString.match(/Firebase:\s*Error\s*\(auth\/([^)]+)\)/);
|
|
132
|
+
if (lastMatch && ERROR_MESSAGES[lastMatch[1]]) {
|
|
133
|
+
return {
|
|
134
|
+
success: false,
|
|
135
|
+
...ERROR_MESSAGES[lastMatch[1]]
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
} catch (e) {
|
|
139
|
+
}
|
|
140
|
+
return {
|
|
141
|
+
success: false,
|
|
142
|
+
message: "An unexpected error occurred. Please try again later",
|
|
143
|
+
code: "INTERNAL_ERROR"
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function isAuthErrorResponse(response) {
|
|
147
|
+
return typeof response === "object" && response !== null && "success" in response && response.success === false && "code" in response && "message" in response;
|
|
148
|
+
}
|
|
149
|
+
function getErrorAlertVariant(error) {
|
|
150
|
+
if (!error) return "destructive";
|
|
151
|
+
switch (error.error) {
|
|
152
|
+
case "AUTHENTICATED":
|
|
153
|
+
return "default";
|
|
154
|
+
case "EMAIL_EXISTS":
|
|
155
|
+
case "UNAUTHENTICATED":
|
|
156
|
+
case "UNVERIFIED":
|
|
157
|
+
case "REQUIRES_VERIFICATION":
|
|
158
|
+
case "INVALID_EMAIL":
|
|
159
|
+
case "INVALID_TOKEN":
|
|
160
|
+
case "INTERNAL_ERROR":
|
|
161
|
+
case "USER_DISABLED":
|
|
162
|
+
case "TOO_MANY_ATTEMPTS":
|
|
163
|
+
case "NETWORK_ERROR":
|
|
164
|
+
case "SESSION_EXPIRED":
|
|
165
|
+
case "EXPIRED_TOKEN":
|
|
166
|
+
case "INVALID_CREDENTIALS":
|
|
167
|
+
default:
|
|
168
|
+
return "destructive";
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/ternsecure.ts
|
|
173
|
+
function isSignInResponse(value) {
|
|
174
|
+
return typeof value === "object" && "success" in value && typeof value.success === "boolean";
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// src/auth.ts
|
|
178
|
+
var DEFAULT_TERN_SECURE_STATE = {
|
|
179
|
+
userId: null,
|
|
180
|
+
isLoaded: false,
|
|
181
|
+
error: null,
|
|
182
|
+
isValid: false,
|
|
183
|
+
isVerified: false,
|
|
184
|
+
isAuthenticated: false,
|
|
185
|
+
token: null,
|
|
186
|
+
email: null,
|
|
187
|
+
status: "loading",
|
|
188
|
+
requiresVerification: false,
|
|
189
|
+
user: null
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// src/signIn.ts
|
|
193
|
+
function isSignInResponseTree(value) {
|
|
194
|
+
return typeof value === "object" && "success" in value && typeof value.success === "boolean";
|
|
195
|
+
}
|
|
196
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
197
|
+
0 && (module.exports = {
|
|
198
|
+
DEFAULT_TERN_SECURE_STATE,
|
|
199
|
+
ERRORS,
|
|
200
|
+
TernSecureError,
|
|
201
|
+
getErrorAlertVariant,
|
|
202
|
+
handleFirebaseAuthError,
|
|
203
|
+
isAuthErrorResponse,
|
|
204
|
+
isSignInResponse,
|
|
205
|
+
isSignInResponseTree
|
|
206
|
+
});
|
|
207
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/ternsecure.ts","../src/auth.ts","../src/signIn.ts"],"sourcesContent":["export * from './all'\nexport * from './errors'\nexport * from './ternsecure'\nexport * from './theme'\nexport * from './instanceTree'\nexport * from './auth'\nexport * from './signIn'\nexport * from './signUp'\nexport * from './session'\nexport * from './redirect'","export type ErrorCode = keyof typeof ERRORS\r\n\r\nexport interface AuthErrorResponse {\r\n success: false\r\n message: string\r\n code: ErrorCode\r\n}\r\n\r\nexport interface AuthErrorTree extends Error {\r\n code?: any | string;\r\n message: string;\r\n response?: any | string;\r\n}\r\n\r\nexport interface SignInResponseTree {\r\n success: boolean;\r\n message?: string;\r\n error?: any | undefined;\r\n user?: any;\r\n}\r\n\r\nexport const ERRORS = {\r\n SERVER_SIDE_INITIALIZATION: \"TernSecure must be initialized on the client side\",\r\n REQUIRES_VERIFICATION: \"AUTH_REQUIRES_VERIFICATION\",\r\n AUTHENTICATED: \"AUTHENTICATED\",\r\n UNAUTHENTICATED: \"UNAUTHENTICATED\",\r\n UNVERIFIED: \"UNVERIFIED\",\r\n NOT_INITIALIZED: \"TernSecure services are not initialized. Call initializeTernSecure() first\",\r\n HOOK_CONTEXT: \"Hook must be used within TernSecureProvider\",\r\n EMAIL_NOT_VERIFIED: \"EMAIL_NOT_VERIFIED\",\r\n INVALID_CREDENTIALS: \"INVALID_CREDENTIALS\",\r\n USER_DISABLED: \"USER_DISABLED\",\r\n TOO_MANY_ATTEMPTS: \"TOO_MANY_ATTEMPTS\",\r\n NETWORK_ERROR: \"NETWORK_ERROR\",\r\n INVALID_EMAIL: \"INVALID_EMAIL\",\r\n WEAK_PASSWORD: \"WEAK_PASSWORD\",\r\n EMAIL_EXISTS: \"EMAIL_EXISTS\",\r\n POPUP_BLOCKED: \"POPUP_BLOCKED\",\r\n OPERATION_NOT_ALLOWED: \"OPERATION_NOT_ALLOWED\",\r\n EXPIRED_TOKEN: \"EXPIRED_TOKEN\",\r\n INVALID_TOKEN: \"INVALID_TOKEN\",\r\n SESSION_EXPIRED: \"SESSION_EXPIRED\",\r\n INTERNAL_ERROR: \"INTERNAL_ERROR\",\r\n UNKNOWN_ERROR: \"An unknown error occurred.\",\r\n INVALID_ARGUMENT: \"Invalid argument provided.\",\r\n USER_NOT_FOUND: \"auth/user-not-found\",\r\n WRONG_PASSWORD: \"auth/wrong-password\",\r\n EMAIL_ALREADY_IN_USE: \"auth/email-already-in-use\",\r\n REQUIRES_RECENT_LOGIN: \"auth/requires-recent-login\",\r\n NO_SESSION_COOKIE: \"No session cookie found.\",\r\n INVALID_SESSION_COOKIE: \"Invalid session cookie.\",\r\n NO_ID_TOKEN: \"No ID token found.\",\r\n INVALID_ID_TOKEN: \"Invalid ID token.\",\r\n REDIRECT_LOOP: \"Redirect loop detected.\",\r\n} as const\r\n\r\nexport type AuthErrorCode = keyof typeof ERRORS\r\n\r\n// Firebase Auth Error Code patterns\r\nconst ERROR_PATTERNS = {\r\n INVALID_EMAIL: /auth.*invalid.*email|invalid.*email.*auth|Firebase:.*Error.*auth\\/invalid-email/i,\r\n INVALID_CREDENTIALS:\r\n /auth.*invalid.*credential|invalid.*password|wrong.*password|Firebase:.*Error.*auth\\/(invalid-credential|wrong-password|user-not-found)/i,\r\n USER_DISABLED: /user.*disabled|disabled.*user|Firebase:.*Error.*auth\\/user-disabled/i,\r\n TOO_MANY_ATTEMPTS: /too.*many.*attempts|too.*many.*requests|Firebase:.*Error.*auth\\/too-many-requests/i,\r\n NETWORK_ERROR: /network.*request.*failed|failed.*network|Firebase:.*Error.*auth\\/network-request-failed/i,\r\n OPERATION_NOT_ALLOWED: /operation.*not.*allowed|method.*not.*allowed|Firebase:.*Error.*auth\\/operation-not-allowed/i,\r\n POPUP_BLOCKED: /popup.*blocked|blocked.*popup|Firebase:.*Error.*auth\\/popup-blocked/i,\r\n EMAIL_EXISTS: /email.*exists|email.*already.*use|Firebase:.*Error.*auth\\/email-already-in-use/i,\r\n EXPIRED_TOKEN: /token.*expired|expired.*token|Firebase:.*Error.*auth\\/expired-token/i,\r\n INVALID_TOKEN: /invalid.*token|token.*invalid|Firebase:.*Error.*auth\\/invalid-token/i,\r\n SESSION_EXPIRED: /session.*expired|expired.*session|Firebase:.*Error.*auth\\/session-expired/i,\r\n WEAK_PASSWORD: /weak.*password|password.*weak|Firebase:.*Error.*auth\\/weak-password/i,\r\n} as const\r\n\r\nexport class TernSecureError extends Error {\r\n code: ErrorCode\r\n\r\n constructor(code: ErrorCode, message?: string) {\r\n super(message || code)\r\n this.name = \"TernSecureError\"\r\n this.code = code\r\n }\r\n}\r\n\r\ninterface SerializedFirebaseError {\r\n name?: string\r\n code?: string\r\n message?: string\r\n stack?: string\r\n}\r\n\r\n/**\r\n * Determines if an object matches the shape of a Firebase Error\r\n */\r\nfunction isFirebaseErrorLike(error: unknown): error is SerializedFirebaseError {\r\n if (!error || typeof error !== \"object\") return false\r\n\r\n const err = error as SerializedFirebaseError\r\n\r\n // Check for bundled Firebase error format: \"Firebase: Error (auth/error-code)\"\r\n if (typeof err.message === \"string\") {\r\n const bundledErrorMatch = err.message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n // Add the extracted code to the error object\r\n err.code = `auth/${bundledErrorMatch[1]}`\r\n return true\r\n }\r\n }\r\n\r\n return (\r\n (typeof err.code === \"string\" && err.code.startsWith(\"auth/\")) ||\r\n (typeof err.name === \"string\" && err.name.includes(\"FirebaseError\"))\r\n )\r\n}\r\n\r\n/**\r\n * Extracts the error code from a Firebase-like error object\r\n */\r\nfunction extractFirebaseErrorCode(error: SerializedFirebaseError): string {\r\n // First try to extract from bundled error message format\r\n if (typeof error.message === \"string\") {\r\n const bundledErrorMatch = error.message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n return bundledErrorMatch[1]\r\n }\r\n }\r\n\r\n // Then try the standard code property\r\n if (error.code) {\r\n return error.code.replace(\"auth/\", \"\")\r\n }\r\n\r\n // Finally try to extract from error message if it contains an error code\r\n if (typeof error.message === \"string\") {\r\n const messageCodeMatch = error.message.match(/auth\\/([a-z-]+)/)\r\n if (messageCodeMatch) {\r\n return messageCodeMatch[1]\r\n }\r\n }\r\n\r\n return \"\"\r\n}\r\n\r\n/**\r\n * Maps a Firebase error code to our internal error code\r\n */\r\nfunction mapFirebaseErrorCode(code: string): ErrorCode {\r\n // Direct mapping for known error codes\r\n const directMappings: Record<string, ErrorCode> = {\r\n \"invalid-email\": \"INVALID_EMAIL\",\r\n \"user-disabled\": \"USER_DISABLED\",\r\n \"too-many-requests\": \"TOO_MANY_ATTEMPTS\",\r\n \"network-request-failed\": \"NETWORK_ERROR\",\r\n \"operation-not-allowed\": \"OPERATION_NOT_ALLOWED\",\r\n \"popup-blocked\": \"POPUP_BLOCKED\",\r\n \"email-already-in-use\": \"EMAIL_EXISTS\",\r\n \"weak-password\": \"WEAK_PASSWORD\",\r\n \"invalid-credential\": \"INVALID_CREDENTIALS\",\r\n \"wrong-password\": \"INVALID_CREDENTIALS\",\r\n \"user-not-found\": \"INVALID_CREDENTIALS\",\r\n \"invalid-password\": \"INVALID_CREDENTIALS\",\r\n \"user-token-expired\": \"EXPIRED_TOKEN\",\r\n \"invalid-id-token\": \"INVALID_TOKEN\",\r\n }\r\n\r\n return directMappings[code] || \"INTERNAL_ERROR\"\r\n}\r\n\r\n/**\r\n * Determines error type based on error message pattern matching\r\n */\r\nfunction determineErrorTypeFromMessage(message: string): ErrorCode {\r\n // First check for bundled Firebase error format\r\n const bundledErrorMatch = message.match(/Firebase:\\s*Error\\s*$$auth\\/([^)]+)$$/)\r\n if (bundledErrorMatch) {\r\n const errorCode = bundledErrorMatch[1]\r\n const mappedCode = mapFirebaseErrorCode(errorCode)\r\n if (mappedCode) {\r\n return mappedCode\r\n }\r\n }\r\n\r\n // Then check standard patterns\r\n for (const [errorType, pattern] of Object.entries(ERROR_PATTERNS)) {\r\n if (pattern.test(message)) {\r\n return errorType as ErrorCode\r\n }\r\n }\r\n\r\n return \"INTERNAL_ERROR\"\r\n}\r\n\r\n/**\r\n * Creates a standardized error response\r\n */\r\nfunction createErrorResponse(code: ErrorCode, message: string): AuthErrorResponse {\r\n const defaultMessages: Record<ErrorCode, string> = {\r\n INVALID_EMAIL: \"Invalid email format\",\r\n INVALID_CREDENTIALS: \"Invalid email or password\",\r\n USER_DISABLED: \"This account has been disabled\",\r\n TOO_MANY_ATTEMPTS: \"Too many attempts. Please try again later\",\r\n NETWORK_ERROR: \"Network error. Please check your connection\",\r\n OPERATION_NOT_ALLOWED: \"This login method is not enabled\",\r\n POPUP_BLOCKED: \"Login popup was blocked. Please enable popups\",\r\n EMAIL_EXISTS: \"This email is already in use\",\r\n EXPIRED_TOKEN: \"Your session has expired. Please login again\",\r\n INVALID_TOKEN: \"Invalid authentication token\",\r\n SESSION_EXPIRED: \"Your session has expired\",\r\n WEAK_PASSWORD: \"Password is too weak\",\r\n EMAIL_NOT_VERIFIED: \"Email verification required\",\r\n INTERNAL_ERROR: \"An internal error occurred. Please try again\",\r\n SERVER_SIDE_INITIALIZATION: \"TernSecure must be initialized on the client side\",\r\n REQUIRES_VERIFICATION: \"Email verification required\",\r\n AUTHENTICATED: \"Already authenticated\",\r\n UNAUTHENTICATED: \"Authentication required\",\r\n UNVERIFIED: \"Email verification required\",\r\n NOT_INITIALIZED: \"TernSecure services are not initialized\",\r\n HOOK_CONTEXT: \"Hook must be used within TernSecureProvider\",\r\n UNKNOWN_ERROR: \"An unknown error occurred.\",\r\n INVALID_ARGUMENT: \"Invalid argument provided.\",\r\n USER_NOT_FOUND: \"User not found.\",\r\n WRONG_PASSWORD: \"Wrong password.\",\r\n EMAIL_ALREADY_IN_USE: \"Email already in use.\",\r\n REQUIRES_RECENT_LOGIN: \"Requires recent login.\",\r\n NO_SESSION_COOKIE: \"No session cookie found.\",\r\n INVALID_SESSION_COOKIE: \"Invalid session cookie.\",\r\n NO_ID_TOKEN: \"No ID token found.\",\r\n INVALID_ID_TOKEN: \"Invalid ID token.\",\r\n REDIRECT_LOOP: \"Redirect loop detected.\",\r\n }\r\n\r\n return {\r\n success: false,\r\n message: message || defaultMessages[code],\r\n code,\r\n }\r\n}\r\n\r\n/**\r\n * Handles Firebase authentication errors with multiple fallback mechanisms\r\n */\r\nexport function handleFirebaseAuthError(error: unknown): AuthErrorResponse {\r\n // Helper to extract clean error code from bundled format\r\n function extractErrorInfo(input: unknown): { code: string; message: string } | null {\r\n // Case 1: String input (direct Firebase error message)\r\n if (typeof input === 'string') {\r\n const match = input.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (match) {\r\n return { code: match[1], message: input };\r\n }\r\n }\r\n\r\n // Case 2: Error object\r\n if (input && typeof input === 'object') {\r\n const err = input as { code?: string; message?: string };\r\n \r\n // Check for bundled message format first\r\n if (err.message) {\r\n const match = err.message.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (match) {\r\n return { code: match[1], message: err.message };\r\n }\r\n }\r\n\r\n // Check for direct code\r\n if (err.code) {\r\n return {\r\n code: err.code.replace('auth/', ''),\r\n message: err.message || ''\r\n };\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n // Map error codes to user-friendly messages\r\n const ERROR_MESSAGES: Record<string, { message: string; code: ErrorCode }> = {\r\n 'invalid-email': { message: 'Invalid email format', code: 'INVALID_EMAIL' },\r\n 'invalid-credential': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'invalid-login-credentials': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'wrong-password': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'user-not-found': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\r\n 'user-disabled': { message: 'This account has been disabled', code: 'USER_DISABLED' },\r\n 'too-many-requests': { message: 'Too many attempts. Please try again later', code: 'TOO_MANY_ATTEMPTS' },\r\n 'network-request-failed': { message: 'Network error. Please check your connection', code: 'NETWORK_ERROR' },\r\n 'email-already-in-use': { message: 'This email is already in use', code: 'EMAIL_EXISTS' },\r\n 'weak-password': { message: 'Password is too weak', code: 'WEAK_PASSWORD' },\r\n 'operation-not-allowed': { message: 'This login method is not enabled', code: 'OPERATION_NOT_ALLOWED' },\r\n 'popup-blocked': { message: 'Login popup was blocked. Please enable popups', code: 'POPUP_BLOCKED' },\r\n 'expired-action-code': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' },\r\n 'user-token-expired': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' }\r\n };\r\n\r\n try {\r\n // Extract error information\r\n const errorInfo = extractErrorInfo(error);\r\n \r\n if (errorInfo) {\r\n const mappedError = ERROR_MESSAGES[errorInfo.code];\r\n if (mappedError) {\r\n return {\r\n success: false,\r\n message: mappedError.message,\r\n code: mappedError.code\r\n };\r\n }\r\n }\r\n\r\n // If we couldn't extract or map the error, try one last time with string conversion\r\n const errorString = String(error);\r\n const lastMatch = errorString.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\r\n if (lastMatch && ERROR_MESSAGES[lastMatch[1]]) {\r\n return {\r\n success: false,\r\n ...ERROR_MESSAGES[lastMatch[1]]\r\n };\r\n }\r\n\r\n } catch (e) {\r\n // Silent catch - we'll return the default error\r\n }\r\n\r\n // Default fallback\r\n return {\r\n success: false,\r\n message: 'An unexpected error occurred. Please try again later',\r\n code: 'INTERNAL_ERROR'\r\n };\r\n}\r\n\r\n/**\r\n * Type guard to check if a response is an AuthErrorResponse\r\n */\r\nexport function isAuthErrorResponse(response: unknown): response is AuthErrorResponse {\r\n return (\r\n typeof response === \"object\" &&\r\n response !== null &&\r\n \"success\" in response &&\r\n (response as { success: boolean }).success === false &&\r\n \"code\" in response &&\r\n \"message\" in response\r\n )\r\n}\r\n\r\nexport function getErrorAlertVariant(error: any | undefined) {\r\n if (!error) return \"destructive\"\r\n\r\n switch (error.error) {\r\n case \"AUTHENTICATED\":\r\n return \"default\"\r\n case \"EMAIL_EXISTS\":\r\n case \"UNAUTHENTICATED\":\r\n case \"UNVERIFIED\":\r\n case \"REQUIRES_VERIFICATION\":\r\n case \"INVALID_EMAIL\":\r\n case \"INVALID_TOKEN\":\r\n case \"INTERNAL_ERROR\":\r\n case \"USER_DISABLED\":\r\n case \"TOO_MANY_ATTEMPTS\":\r\n case \"NETWORK_ERROR\":\r\n case \"SESSION_EXPIRED\":\r\n case \"EXPIRED_TOKEN\":\r\n case \"INVALID_CREDENTIALS\":\r\n default:\r\n return \"destructive\"\r\n }\r\n}","import { \n TernSecureUser \n} from './all';\nimport { Appearance } from './theme';\n\nexport interface TernSecureSession {\n token: string | null;\n expiresAt?: number;\n}\n\ntype SignInFormValues = {\n email: string;\n password: string;\n phoneNumber?: string;\n}\n\nexport type SignInInitialValue = Partial<SignInFormValues>;\n\n\ntype SignUpFormValues = {\n email: string;\n password: string;\n confirmPassword?: string;\n displayName?: string;\n};\n\n\nexport type SignUpInitialValue = Partial<SignUpFormValues>;\n\nexport interface SignInResponse {\n success: boolean;\n message?: string;\n error?: any | undefined;\n user?: any;\n}\n\nexport interface AuthError extends Error {\n code?: any | string \n message: string\n response?: SignInResponse\n}\n\nexport function isSignInResponse(value: any): value is SignInResponse {\n return typeof value === \"object\" && \"success\" in value && typeof value.success === \"boolean\"\n}\n\nexport interface AuthActions {\n signInWithEmail: (email: string, password: string) => Promise<SignInResponse>;\n signInWithGoogle: () => Promise<void>;\n signInWithMicrosoft: () => Promise<void>;\n signOut: () => Promise<void>;\n getRedirectResult: () => Promise<any>;\n getIdToken: () => Promise<string | null>;\n createUserWithEmailAndPassword?: (email: string, password: string) => Promise<SignInResponse>;\n sendEmailVerification?: (user: TernSecureUser) => Promise<void>;\n}\n\nexport interface RedirectConfig {\n // URL to redirect to after successful authentication\n redirectUrl?: string\n // Whether this is a return visit (e.g. after sign out)\n isReturn?: boolean\n // Priority of the redirect (higher number = higher priority)\n priority?: number\n}\n\n\nexport interface SignInProps extends RedirectConfig {\n initialValue?: SignInInitialValue;\n logo?: string\n appName?: string\n appearance?: Appearance;\n onError?: (error: AuthError) => void;\n onSuccess?: (user: TernSecureUser | null) => void;\n}\n\n\n/**\n * SignUpProps interface defines the properties for the sign-up component.\n * It extends RedirectConfig to include redirect-related properties.\n */\nexport interface SignUpProps extends RedirectConfig {\n initialValue?: SignUpInitialValue;\n logo?: string\n appName?: string\n appearance?: Appearance;\n onError?: (error: AuthError) => void;\n onSuccess?: (user: TernSecureUser | null) => void;\n}\n\n/**\n * Defines the contract for a TernSecure instance.\n * This instance provides authentication state, user information, and methods\n * for managing the authentication lifecycle. It is designed to be used by\n * UI packages like tern-ui, which act as \"dumb\" renderers.\n */\nexport interface TernSecureInstance {\n /** Indicates if the user is currently signed in. */\n isSignedIn: () => boolean;\n\n /** The current authenticated user object, or null if not signed in. */\n user: TernSecureUser | null;\n\n /** The current user session information, or null if not signed in. */\n session: TernSecureSession | null;\n\n /** Initiates the sign-out process for the current user. */\n signOut: () => Promise<void>;\n\n /**\n * Prepares or signals to mount the sign-in interface.\n * @param options Optional configuration or initial state for the sign-in UI, conforming to SignInProps.\n */\n mountSignIn: (options?: SignInProps) => void;\n\n /** Cleans up or signals to unmount the sign-in interface. */\n unmountSignIn: () => void;\n\n /**\n * Prepares or signals to mount the sign-up interface.\n * @param options Optional configuration or initial state for the sign-up UI, conforming to SignUpProps.\n */\n mountSignUp: (options?: SignUpProps) => void;\n\n /** Cleans up or signals to unmount the sign-up interface. */\n unmountSignUp: () => void;\n\n /**\n * Determines if a redirect is necessary based on the current authentication\n * state and the given path.\n * @param currentPath The current URL path.\n * @returns True if a redirect is needed, false otherwise, or a string path to redirect to.\n */\n shouldRedirect: (currentPath: string) => boolean | string;\n\n /**\n * Constructs a URL, appending necessary redirect parameters.\n * Useful for redirecting back to the original page after authentication.\n * @param baseUrl The base URL to which redirect parameters should be added.\n * @returns The new URL string with redirect parameters.\n */\n constructUrlWithRedirect: (baseUrl: string) => string;\n\n /**\n * Redirects the user to the configured login page.\n * @param redirectUrl Optional URL to redirect to after successful login.\n */\n redirectToLogin: (redirectUrl?: string) => void;\n\n /** Indicates if an authentication operation is currently in progress. */\n isLoading: boolean;\n\n /** Holds any error that occurred during an authentication operation, or null otherwise. */\n error: Error | null;\n \n /** Indicates if the user has verified their email address. */\n sendVerificationEmail: () => Promise<void>;\n}","import { SignedInSession } from 'session';\nimport type { \n TernSecureUser,\n TernSecureConfig\n} from './all';\nimport type { \n SignInResource\n} from './signIn';\nimport { SignUpResource } from 'signUp';\n\nexport interface TernSecureState {\n userId: string | null\n isLoaded: boolean\n error: Error | null\n isValid: boolean\n isVerified: boolean\n isAuthenticated: boolean\n token: any | null\n email: string | null\n status: \"loading\" | \"authenticated\" | \"unauthenticated\" | \"unverified\"\n requiresVerification?: boolean\n user?: TernSecureUser | null\n}\n\n\nexport type AuthProviderStatus = 'idle' | 'pending' | 'error' | 'success';\n\nexport const DEFAULT_TERN_SECURE_STATE: TernSecureState = {\n userId: null,\n isLoaded: false,\n error: null,\n isValid: false,\n isVerified: false,\n isAuthenticated: false,\n token: null,\n email: null,\n status: \"loading\",\n requiresVerification: false,\n user: null\n};\n\n\nexport interface TernSecureAuthProvider {\n /** Current auth state */\n internalAuthState: TernSecureState;\n\n /** Current user*/\n ternSecureUser(): TernSecureUser | null;\n\n /** Current session */\n currentSession: SignedInSession | null;\n\n /** Sign in resource for authentication operations */\n signIn: SignInResource;\n\n /** SignUp resource for authentication operations */\n signUp: SignUpResource;\n\n /** The Firebase configuration used by this TernAuth instance. */\n ternSecureConfig?: TernSecureConfig;\n\n /** Sign out the current user */\n signOut(): Promise<void>;\n}","import type { \n SignInResponseTree\n} from './errors';\n\nexport type SignInStatus =\n | 'idle'\n | 'pending_email_password'\n | 'pending_social'\n | 'pending_mfa'\n | 'redirecting'\n | 'success'\n | 'error';\n\n\n\nexport type SignInFormValuesTree = {\n email: string;\n password: string;\n phoneNumber?: string;\n};\n\n\nexport type SignInInitialValueTree = Partial<SignInFormValuesTree>;\n\n\nexport interface ResendEmailVerification extends SignInResponseTree {\n isVerified?: boolean;\n}\n\nexport function isSignInResponseTree(value: any): value is SignInResponseTree {\n return (\n typeof value === 'object' &&\n 'success' in value &&\n typeof value.success === 'boolean'\n );\n}\n\n\n\nexport interface SignInResource {\n /**\n * The current status of the sign-in process.\n */\n status?: SignInStatus;\n /**\n * Signs in a user with their email and password.\n * @param params - The sign-in form values.\n * @returns A promise that resolves with the sign-in response.\n */\n withEmailAndPassword: (params: SignInFormValuesTree) => Promise<SignInResponseTree>;\n /**\n * @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').\n * @param options - Optional configuration for the social sign-in flow.\n * @returns A promise that resolves with the sign-in response or void if redirecting.\n */\n withSocialProvider: (provider: string, options?: { mode?: 'popup' | 'redirect' }) => Promise<SignInResponseTree | void>;\n /**\n * Completes an MFA (Multi-Factor Authentication) step after a primary authentication attempt.\n * @param mfaToken - The MFA token or code submitted by the user.\n * @param mfaContext - Optional context or session data from the MFA initiation step.\n * @returns A promise that resolves with the sign-in response upon successful MFA verification.\n */\n completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponseTree>;\n /**\n * Sends a password reset email to the given email address.\n * @param email - The user's email address.\n * @returns A promise that resolves when the email is sent.\n */\n sendPasswordResetEmail: (email: string) => Promise<void>;\n /**\n * Resends the email verification link to the user's email address.\n * @returns A promise that resolves with the sign-in response.\n */\n resendEmailVerification: () => Promise<ResendEmailVerification>;\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACqBO,IAAM,SAAS;AAAA,EACpB,4BAA4B;AAAA,EAC5B,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe;AAAA,EACf,uBAAuB;AAAA,EACvB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,mBAAmB;AAAA,EACnB,wBAAwB;AAAA,EACxB,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,eAAe;AACjB;AAqBO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EAEA,YAAY,MAAiB,SAAkB;AAC7C,UAAM,WAAW,IAAI;AACrB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;AA+JO,SAAS,wBAAwB,OAAmC;AAEzE,WAAS,iBAAiB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E,SAAO,OAAO,UAAU,YAAY,aAAa,SAAS,OAAO,MAAM,YAAY;AACrF;;;ACjBO,IAAM,4BAA6C;AAAA,EACxD,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,sBAAsB;AAAA,EACtB,MAAM;AACR;;;ACVO,SAAS,qBAAqB,OAAyC;AAC5E,SACE,OAAO,UAAU,YACjB,aAAa,SACb,OAAO,MAAM,YAAY;AAE7B;","names":[]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { Appearance, SignInUIConfig, SignUpUIConfig } from './theme';
|
|
2
|
+
import type { TernSecureConfig, TernSecureUser } from './all';
|
|
3
|
+
import type { TernSecureAuthProvider, TernSecureState } from 'auth';
|
|
4
|
+
import type { TernSecureSessionTree, SignedInSession } from './session';
|
|
5
|
+
import type { AuthErrorTree } from './errors';
|
|
6
|
+
import type { RedirectOptions, SignInRedirectUrl, SignUpRedirectUrl } from './redirect';
|
|
7
|
+
import type { SignInInitialValueTree } from './signIn';
|
|
8
|
+
type Mode = 'browser' | 'server';
|
|
9
|
+
export type TernSecureInstanceTreeOptions = {
|
|
10
|
+
initialSession?: TernSecureSessionTree | null;
|
|
11
|
+
defaultAppearance?: Appearance;
|
|
12
|
+
signInUrl?: string;
|
|
13
|
+
signUpUrl?: string;
|
|
14
|
+
mode?: Mode;
|
|
15
|
+
onAuthStateChanged?: (user: TernSecureUser | null) => void;
|
|
16
|
+
onError?: (error: AuthErrorTree) => void;
|
|
17
|
+
environment?: string | undefined;
|
|
18
|
+
requireverification?: boolean;
|
|
19
|
+
ternSecureConfig?: TernSecureConfig;
|
|
20
|
+
} & SignInRedirectUrl & SignUpRedirectUrl;
|
|
21
|
+
export type TernSecureInstanceTreeStatus = 'error' | 'loading' | 'ready';
|
|
22
|
+
/**
|
|
23
|
+
* Instance interface for managing auth UI state
|
|
24
|
+
*/
|
|
25
|
+
export interface TernSecureInstanceTree {
|
|
26
|
+
customDomain?: string;
|
|
27
|
+
proxyUrl?: string;
|
|
28
|
+
apiKey?: string;
|
|
29
|
+
projectId?: string;
|
|
30
|
+
environment?: string | undefined;
|
|
31
|
+
mode?: Mode;
|
|
32
|
+
isReady: boolean;
|
|
33
|
+
status: TernSecureInstanceTreeStatus;
|
|
34
|
+
isVisible: boolean;
|
|
35
|
+
currentView: 'signIn' | 'signUp' | 'verify' | null;
|
|
36
|
+
isLoading: boolean;
|
|
37
|
+
error: Error | null;
|
|
38
|
+
/** Authentication State */
|
|
39
|
+
auth: {
|
|
40
|
+
/** Current authenticated user */
|
|
41
|
+
user: TernSecureUser | null;
|
|
42
|
+
/** Current session information */
|
|
43
|
+
session: SignedInSession | null;
|
|
44
|
+
};
|
|
45
|
+
/** Core Authentication Methods */
|
|
46
|
+
ternAuth: TernSecureAuthProvider | undefined;
|
|
47
|
+
showSignIn: (targetNode: HTMLDivElement, config?: SignInPropsTree) => void;
|
|
48
|
+
hideSignIn: (targetNode: HTMLDivElement) => void;
|
|
49
|
+
showSignUp: (targetNode: HTMLDivElement, config?: SignUpPropsTree) => void;
|
|
50
|
+
hideSignUp: (targetNode: HTMLDivElement) => void;
|
|
51
|
+
showUserButton: (targetNode: HTMLDivElement) => void;
|
|
52
|
+
hideUserButton: (targetNode: HTMLDivElement) => void;
|
|
53
|
+
clearError: () => void;
|
|
54
|
+
setLoading: (isLoading: boolean) => void;
|
|
55
|
+
/** Get redirect result from OAuth flows */
|
|
56
|
+
getRedirectResult: () => Promise<any>;
|
|
57
|
+
/** Check if redirect is needed */
|
|
58
|
+
shouldRedirect: (currentPath: string) => boolean | string;
|
|
59
|
+
/** Construct URL with redirect parameters */
|
|
60
|
+
constructUrlWithRedirect: (to: string) => string;
|
|
61
|
+
/** Navigate to SignIn page */
|
|
62
|
+
redirectToSignIn(options?: SignInRedirectOptions): Promise<unknown>;
|
|
63
|
+
/** Navigate to SignUp page */
|
|
64
|
+
redirectToSignUp(options?: SignUpRedirectOptions): Promise<unknown>;
|
|
65
|
+
redirectAfterSignIn: () => void;
|
|
66
|
+
redirectAfterSignUp: () => void;
|
|
67
|
+
/** Error and Event Handling */
|
|
68
|
+
events: {
|
|
69
|
+
/** Subscribe to auth state changes */
|
|
70
|
+
onAuthStateChanged: (callback: (authState: TernSecureState) => void) => () => void;
|
|
71
|
+
/** Subscribe to error events */
|
|
72
|
+
onError: (callback: (error: AuthErrorTree) => void) => () => void;
|
|
73
|
+
/** Status */
|
|
74
|
+
onStatusChanged: (callback: (status: TernSecureInstanceTreeStatus) => void) => () => void;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export type SignUpFormValuesTree = {
|
|
78
|
+
email: string;
|
|
79
|
+
password: string;
|
|
80
|
+
confirmPassword?: string;
|
|
81
|
+
displayName?: string;
|
|
82
|
+
};
|
|
83
|
+
export type SignUpInitialValueTree = Partial<SignUpFormValuesTree>;
|
|
84
|
+
/**
|
|
85
|
+
* Props for SignIn component focusing on UI concerns
|
|
86
|
+
*/
|
|
87
|
+
export type SignInPropsTree = {
|
|
88
|
+
/** URL to navigate to after successfully sign-in */
|
|
89
|
+
forceRedirectUrl?: string | null;
|
|
90
|
+
/** Initial form values */
|
|
91
|
+
initialValue?: SignInInitialValueTree;
|
|
92
|
+
/** UI configuration */
|
|
93
|
+
ui?: SignInUIConfig;
|
|
94
|
+
/** Callbacks */
|
|
95
|
+
onError?: (error: AuthErrorTree) => void;
|
|
96
|
+
onSuccess?: (user: TernSecureUser | null) => void;
|
|
97
|
+
} & SignUpRedirectUrl;
|
|
98
|
+
/**
|
|
99
|
+
* Props for SignUp component focusing on UI concerns
|
|
100
|
+
*/
|
|
101
|
+
export type SignUpPropsTree = {
|
|
102
|
+
/** URL to navigate to after successfully sign-up */
|
|
103
|
+
forceRedirectUrl?: string | null;
|
|
104
|
+
/** Initial form values */
|
|
105
|
+
initialValue?: SignUpInitialValueTree;
|
|
106
|
+
/** UI configuration */
|
|
107
|
+
ui?: SignUpUIConfig;
|
|
108
|
+
/** Callbacks */
|
|
109
|
+
onSubmit?: (values: SignUpFormValuesTree) => Promise<void>;
|
|
110
|
+
onError?: (error: AuthErrorTree) => void;
|
|
111
|
+
onSuccess?: (user: TernSecureUser | null) => void;
|
|
112
|
+
} & SignInRedirectUrl;
|
|
113
|
+
export type SignInRedirectOptions = RedirectOptions;
|
|
114
|
+
export type SignUpRedirectOptions = RedirectOptions;
|
|
115
|
+
export {};
|
|
116
|
+
//# sourceMappingURL=instanceTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instanceTree.d.ts","sourceRoot":"","sources":["../src/instanceTree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,MAAM,SAAS,CAAC;AAClB,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EAChB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EACV,qBAAqB,EACrB,eAAe,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,aAAa,EACd,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,sBAAsB,EACvB,MAAM,UAAU,CAAC;AAIlB,KAAK,IAAI,GAAG,SAAS,GAAG,QAAQ,CAAC;AAGjC,MAAM,MAAM,6BAA6B,GAAG;IAC1C,cAAc,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC9C,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,IAAI,CAA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AAG,eAAe,CAAA;AACnD,MAAM,MAAM,qBAAqB,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type SignInRedirectUrl = {
|
|
2
|
+
signInForceRedirectUrl?: string | null;
|
|
3
|
+
};
|
|
4
|
+
export type SignUpRedirectUrl = {
|
|
5
|
+
signUpForceRedirectUrl?: string | null;
|
|
6
|
+
};
|
|
7
|
+
export type RedirectOptions = SignInRedirectUrl | SignUpRedirectUrl;
|
|
8
|
+
//# sourceMappingURL=redirect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redirect.d.ts","sourceRoot":"","sources":["../src/redirect.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC5B,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC5B,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export type SessionStatus = 'active' | 'expired' | 'revoked' | 'pending';
|
|
2
|
+
/**
|
|
3
|
+
* parsed can be replaced with
|
|
4
|
+
*/
|
|
5
|
+
export declare interface ParsedToken {
|
|
6
|
+
/** Expiration time of the token. */
|
|
7
|
+
'exp'?: string;
|
|
8
|
+
/** UID of the user. */
|
|
9
|
+
'sub'?: string;
|
|
10
|
+
/** Time at which authentication was performed. */
|
|
11
|
+
'auth_time'?: string;
|
|
12
|
+
/** Issuance time of the token. */
|
|
13
|
+
'iat'?: string;
|
|
14
|
+
/** Firebase specific claims, containing the provider(s) used to authenticate the user. */
|
|
15
|
+
'firebase'?: {
|
|
16
|
+
'sign_in_provider'?: string;
|
|
17
|
+
'sign_in_second_factor'?: string;
|
|
18
|
+
'identities'?: Record<string, string>;
|
|
19
|
+
};
|
|
20
|
+
/** Map of any additional custom claims. */
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Core properties for any session that is or was authenticated.
|
|
25
|
+
* These properties are guaranteed to exist for active, expired, or revoked sessions.
|
|
26
|
+
*/
|
|
27
|
+
interface AuthenticatedSessionBase {
|
|
28
|
+
/** The Firebase Auth ID token JWT string. */
|
|
29
|
+
token: string;
|
|
30
|
+
/** The ID token expiration time (e.g., UTC string or Unix timestamp). */
|
|
31
|
+
expirationTime: string;
|
|
32
|
+
/** The ID token issuance time. */
|
|
33
|
+
issuedAtTime: string;
|
|
34
|
+
/** Time at which authentication was performed (from token claims). */
|
|
35
|
+
authTime: string;
|
|
36
|
+
/**
|
|
37
|
+
* The entire payload claims of the ID token including the standard reserved claims
|
|
38
|
+
* as well as custom claims.
|
|
39
|
+
*/
|
|
40
|
+
claims: ParsedToken;
|
|
41
|
+
/**
|
|
42
|
+
* Time the user last signed in.
|
|
43
|
+
* This could be from Firebase User metadata or persisted by TernSecure.
|
|
44
|
+
*/
|
|
45
|
+
lastSignedAt?: number;
|
|
46
|
+
/** signInProvider */
|
|
47
|
+
signInProvider: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Represents a session when the user is authenticated and the token is considered active.
|
|
51
|
+
*/
|
|
52
|
+
export interface ActiveSession extends AuthenticatedSessionBase {
|
|
53
|
+
status: 'active';
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Represents a session when the user was authenticated, but the token has expired.
|
|
57
|
+
*/
|
|
58
|
+
export interface ExpiredSession extends AuthenticatedSessionBase {
|
|
59
|
+
status: 'expired';
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Represents a session that is awaiting some action.
|
|
63
|
+
*/
|
|
64
|
+
export interface PendingSession extends AuthenticatedSessionBase {
|
|
65
|
+
status: 'pending';
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Defines the possible states of a user's session within TernSecure.
|
|
69
|
+
* This is a discriminated union based on the `status` property.
|
|
70
|
+
* The actual `TernSecureUser` (Firebase User object) is typically stored separately,
|
|
71
|
+
* for example, in `TernSecureInstanceTree.auth.user`.
|
|
72
|
+
*/
|
|
73
|
+
export type TernSecureSessionTree = ActiveSession | ExpiredSession;
|
|
74
|
+
export type SignedInSession = ActiveSession | PendingSession | ExpiredSession;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAGzE;;GAEG;AAGH,MAAM,CAAC,OAAO,WAAW,WAAW;IAChC,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0FAA0F;IAC1F,UAAU,CAAC,EAAE;QACT,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAC5B,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KACzC,CAAC;IACF,2CAA2C;IAC3C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,UAAU,wBAAwB;IAChC,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,cAAc,EAAE,MAAM,CAAC;IACvB,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;IACjB;;;MAGE;IACF,MAAM,EAAE,WAAW,CAAC;IACnB;;;MAGE;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qBAAqB;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAGD;;GAEG;AACH,MAAM,WAAW,aAAc,SAAQ,wBAAwB;IAC7D,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,wBAAwB;IAC9D,MAAM,EAAE,SAAS,CAAC;CACnB;AAGD;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,wBAAwB;IAC9D,MAAM,EAAE,SAAS,CAAC;CACnB;AAGD;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG,cAAc,CAAC;AAGnE,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,cAAc,GAAG,cAAc,CAAC"}
|
package/dist/signIn.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { SignInResponseTree } from './errors';
|
|
2
|
+
export type SignInStatus = 'idle' | 'pending_email_password' | 'pending_social' | 'pending_mfa' | 'redirecting' | 'success' | 'error';
|
|
3
|
+
export type SignInFormValuesTree = {
|
|
4
|
+
email: string;
|
|
5
|
+
password: string;
|
|
6
|
+
phoneNumber?: string;
|
|
7
|
+
};
|
|
8
|
+
export type SignInInitialValueTree = Partial<SignInFormValuesTree>;
|
|
9
|
+
export interface ResendEmailVerification extends SignInResponseTree {
|
|
10
|
+
isVerified?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function isSignInResponseTree(value: any): value is SignInResponseTree;
|
|
13
|
+
export interface SignInResource {
|
|
14
|
+
/**
|
|
15
|
+
* The current status of the sign-in process.
|
|
16
|
+
*/
|
|
17
|
+
status?: SignInStatus;
|
|
18
|
+
/**
|
|
19
|
+
* Signs in a user with their email and password.
|
|
20
|
+
* @param params - The sign-in form values.
|
|
21
|
+
* @returns A promise that resolves with the sign-in response.
|
|
22
|
+
*/
|
|
23
|
+
withEmailAndPassword: (params: SignInFormValuesTree) => Promise<SignInResponseTree>;
|
|
24
|
+
/**
|
|
25
|
+
* @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').
|
|
26
|
+
* @param options - Optional configuration for the social sign-in flow.
|
|
27
|
+
* @returns A promise that resolves with the sign-in response or void if redirecting.
|
|
28
|
+
*/
|
|
29
|
+
withSocialProvider: (provider: string, options?: {
|
|
30
|
+
mode?: 'popup' | 'redirect';
|
|
31
|
+
}) => Promise<SignInResponseTree | void>;
|
|
32
|
+
/**
|
|
33
|
+
* Completes an MFA (Multi-Factor Authentication) step after a primary authentication attempt.
|
|
34
|
+
* @param mfaToken - The MFA token or code submitted by the user.
|
|
35
|
+
* @param mfaContext - Optional context or session data from the MFA initiation step.
|
|
36
|
+
* @returns A promise that resolves with the sign-in response upon successful MFA verification.
|
|
37
|
+
*/
|
|
38
|
+
completeMfaSignIn: (mfaToken: string, mfaContext?: any) => Promise<SignInResponseTree>;
|
|
39
|
+
/**
|
|
40
|
+
* Sends a password reset email to the given email address.
|
|
41
|
+
* @param email - The user's email address.
|
|
42
|
+
* @returns A promise that resolves when the email is sent.
|
|
43
|
+
*/
|
|
44
|
+
sendPasswordResetEmail: (email: string) => Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Resends the email verification link to the user's email address.
|
|
47
|
+
* @returns A promise that resolves with the sign-in response.
|
|
48
|
+
*/
|
|
49
|
+
resendEmailVerification: () => Promise<ResendEmailVerification>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=signIn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signIn.d.ts","sourceRoot":"","sources":["../src/signIn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,wBAAwB,GACxB,gBAAgB,GAChB,aAAa,GACb,aAAa,GACb,SAAS,GACT,OAAO,CAAC;AAIZ,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAGF,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;AAGnE,MAAM,WAAW,uBAAwB,SAAQ,kBAAkB;IACjE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,kBAAkB,CAM5E;AAID,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB;;;;OAIG;IACH,oBAAoB,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACpF;;;;OAIG;IACH,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,CAAA;KAAE,KAAK,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;IACxH;;;;;OAKG;IACH,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,GAAG,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACvF;;;;OAIG;IACH,sBAAsB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD;;;OAGG;IACH,uBAAuB,EAAE,MAAM,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACjE"}
|
package/dist/signUp.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SignInResponseTree } from './errors';
|
|
2
|
+
export interface SignUpResource {
|
|
3
|
+
status?: SignUpStatus | null;
|
|
4
|
+
username?: string | null;
|
|
5
|
+
firstName?: string | null;
|
|
6
|
+
lastName?: string | null;
|
|
7
|
+
displayName?: string | null;
|
|
8
|
+
email: string | null;
|
|
9
|
+
phoneNumber?: string | null;
|
|
10
|
+
/**
|
|
11
|
+
* @param provider - The identifier of the social provider (e.g., 'google', 'microsoft', 'github').
|
|
12
|
+
* @param options - Optional configuration for the social sign-in flow.
|
|
13
|
+
* @returns A promise that resolves with the sign-in response or void if redirecting.
|
|
14
|
+
*/
|
|
15
|
+
withSocialProvider: (provider: string, options?: {
|
|
16
|
+
mode?: 'popup' | 'redirect';
|
|
17
|
+
}) => Promise<SignInResponseTree | void>;
|
|
18
|
+
}
|
|
19
|
+
export type SignUpStatus = 'missing_requirements' | 'complete' | 'abandoned';
|
|
20
|
+
//# sourceMappingURL=signUp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signUp.d.ts","sourceRoot":"","sources":["../src/signUp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,kBAAkB,EACrB,MAAM,UAAU,CAAC;AAGlB,MAAM,WAAW,cAAc;IAC3B,MAAM,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;;OAIG;IACH,kBAAkB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,CAAA;KAAE,KAAK,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;CAC1H;AAED,MAAM,MAAM,YAAY,GAAG,sBAAsB,GAAG,UAAU,GAAG,WAAW,CAAC"}
|