@tern-secure/shared 1.3.0-canary.v20251020032343 → 1.3.0-canary.v20251023005301
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/errors.js +1 -0
- package/dist/errors.js.map +1 -1
- package/dist/errors.mjs +1 -0
- package/dist/errors.mjs.map +1 -1
- package/dist/globs.d.mts +5 -0
- package/dist/globs.d.ts +5 -0
- package/dist/globs.js +54 -0
- package/dist/globs.js.map +1 -0
- package/dist/globs.mjs +19 -0
- package/dist/globs.mjs.map +1 -0
- package/dist/object.d.mts +6 -0
- package/dist/object.d.ts +6 -0
- package/dist/object.js +67 -0
- package/dist/object.js.map +1 -0
- package/dist/object.mjs +39 -0
- package/dist/object.mjs.map +1 -0
- package/package.json +4 -2
package/dist/errors.js
CHANGED
|
@@ -59,6 +59,7 @@ function handleFirebaseAuthError(error) {
|
|
|
59
59
|
return null;
|
|
60
60
|
}
|
|
61
61
|
const ERROR_MESSAGES = {
|
|
62
|
+
"argument-error": { message: "Method called with incorrect arguments", code: "INCORRECT_ARGUMENT" },
|
|
62
63
|
"invalid-email": { message: "Invalid email format", code: "INVALID_EMAIL" },
|
|
63
64
|
"invalid-tenant-id": { message: "Invalid tenant ID", code: "INVALID_ARGUMENT" },
|
|
64
65
|
"invalid-credential": { message: "Invalid email or password", code: "INVALID_CREDENTIALS" },
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["import type { AuthErrorResponse, ErrorCode } from \"@tern-secure/types\";\n\n\nexport class TernSecureError extends Error {\n code: ErrorCode\n\n constructor(code: ErrorCode, message?: string) {\n super(message || code)\n this.name = \"TernSecureError\"\n this.code = code\n }\n}\n\n\n/**\n * Handles Firebase authentication errors with multiple fallback mechanisms\n */\nexport function handleFirebaseAuthError(error: unknown): AuthErrorResponse {\n function extractErrorInfo(input: unknown): { code: string; message: string } | null {\n // Case 1: String input (direct Firebase error message)\n if (typeof input === 'string') {\n const match = input.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\n if (match) {\n return { code: match[1], message: input };\n }\n }\n\n // Case 2: Error object\n if (input && typeof input === 'object') {\n const err = input as { code?: string; message?: string };\n \n // Check for bundled message format first\n if (err.message) {\n const match = err.message.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\n if (match) {\n return { code: match[1], message: err.message };\n }\n }\n\n // Check for direct code\n if (err.code) {\n return {\n code: err.code.replace('auth/', ''),\n message: err.message || ''\n };\n }\n }\n\n return null;\n }\n\n // Map error codes to user-friendly messages\n const ERROR_MESSAGES: Record<string, { message: string; code: ErrorCode }> = {\n 'invalid-email': { message: 'Invalid email format', code: 'INVALID_EMAIL' },\n 'invalid-tenant-id': { message: 'Invalid tenant ID', code: 'INVALID_ARGUMENT' },\n 'invalid-credential': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'invalid-login-credentials': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'wrong-password': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'user-not-found': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'user-disabled': { message: 'This account has been disabled', code: 'USER_DISABLED' },\n 'too-many-requests': { message: 'Too many attempts. Please try again later', code: 'TOO_MANY_ATTEMPTS' },\n 'network-request-failed': { message: 'Network error. Please check your connection', code: 'NETWORK_ERROR' },\n 'email-already-in-use': { message: 'This email is already in use', code: 'EMAIL_EXISTS' },\n 'weak-password': { message: 'Password is too weak', code: 'WEAK_PASSWORD' },\n 'operation-not-allowed': { message: 'This login method is not enabled', code: 'OPERATION_NOT_ALLOWED' },\n 'popup-blocked': { message: 'Login popup was blocked. Please enable popups', code: 'POPUP_BLOCKED' },\n 'expired-action-code': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' },\n 'user-token-expired': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' },\n 'tenant-not-found': { message: 'There is no tenant corresponding to the provided identifier.', code: 'INVALID_ARGUMENT' },\n };\n\n try {\n // Extract error information\n const errorInfo = extractErrorInfo(error);\n \n if (errorInfo) {\n const mappedError = ERROR_MESSAGES[errorInfo.code];\n if (mappedError) {\n return {\n success: false,\n message: mappedError.message,\n code: mappedError.code\n };\n }\n }\n\n // If we couldn't extract or map the error, try one last time with string conversion\n const errorString = String(error);\n const lastMatch = errorString.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\n if (lastMatch && ERROR_MESSAGES[lastMatch[1]]) {\n return {\n success: false,\n ...ERROR_MESSAGES[lastMatch[1]]\n };\n }\n\n } catch (e) {\n // Silent catch - we'll return the default error\n }\n\n // Default fallback\n return {\n success: false,\n message: 'An unexpected error occurred. Please try again later',\n code: 'INTERNAL_ERROR'\n };\n}\n\n/**\n * Type guard to check if a response is an AuthErrorResponse\n */\nexport function isAuthErrorResponse(response: unknown): response is AuthErrorResponse {\n return (\n typeof response === \"object\" &&\n response !== null &&\n \"success\" in response &&\n (response as { success: boolean }).success === false &&\n \"code\" in response &&\n \"message\" in response\n )\n}\n\nexport function getErrorAlertVariant(error: any | undefined) {\n if (!error) return \"destructive\"\n\n switch (error.error) {\n case \"AUTHENTICATED\":\n return \"default\"\n case \"EMAIL_EXISTS\":\n case \"UNAUTHENTICATED\":\n case \"UNVERIFIED\":\n case \"REQUIRES_VERIFICATION\":\n case \"INVALID_EMAIL\":\n case \"INVALID_TOKEN\":\n case \"INTERNAL_ERROR\":\n case \"USER_DISABLED\":\n case \"TOO_MANY_ATTEMPTS\":\n case \"NETWORK_ERROR\":\n case \"SESSION_EXPIRED\":\n case \"EXPIRED_TOKEN\":\n case \"INVALID_CREDENTIALS\":\n default:\n return \"destructive\"\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAGzC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;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["import type { AuthErrorResponse, ErrorCode } from \"@tern-secure/types\";\n\n\nexport class TernSecureError extends Error {\n code: ErrorCode\n\n constructor(code: ErrorCode, message?: string) {\n super(message || code)\n this.name = \"TernSecureError\"\n this.code = code\n }\n}\n\n\n/**\n * Handles Firebase authentication errors with multiple fallback mechanisms\n */\nexport function handleFirebaseAuthError(error: unknown): AuthErrorResponse {\n function extractErrorInfo(input: unknown): { code: string; message: string } | null {\n // Case 1: String input (direct Firebase error message)\n if (typeof input === 'string') {\n const match = input.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\n if (match) {\n return { code: match[1], message: input };\n }\n }\n\n // Case 2: Error object\n if (input && typeof input === 'object') {\n const err = input as { code?: string; message?: string };\n \n // Check for bundled message format first\n if (err.message) {\n const match = err.message.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\n if (match) {\n return { code: match[1], message: err.message };\n }\n }\n\n // Check for direct code\n if (err.code) {\n return {\n code: err.code.replace('auth/', ''),\n message: err.message || ''\n };\n }\n }\n\n return null;\n }\n\n // Map error codes to user-friendly messages\n const ERROR_MESSAGES: Record<string, { message: string; code: ErrorCode }> = {\n 'argument-error': { message: 'Method called with incorrect arguments', code: 'INCORRECT_ARGUMENT' },\n 'invalid-email': { message: 'Invalid email format', code: 'INVALID_EMAIL' },\n 'invalid-tenant-id': { message: 'Invalid tenant ID', code: 'INVALID_ARGUMENT' },\n 'invalid-credential': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'invalid-login-credentials': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'wrong-password': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'user-not-found': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'user-disabled': { message: 'This account has been disabled', code: 'USER_DISABLED' },\n 'too-many-requests': { message: 'Too many attempts. Please try again later', code: 'TOO_MANY_ATTEMPTS' },\n 'network-request-failed': { message: 'Network error. Please check your connection', code: 'NETWORK_ERROR' },\n 'email-already-in-use': { message: 'This email is already in use', code: 'EMAIL_EXISTS' },\n 'weak-password': { message: 'Password is too weak', code: 'WEAK_PASSWORD' },\n 'operation-not-allowed': { message: 'This login method is not enabled', code: 'OPERATION_NOT_ALLOWED' },\n 'popup-blocked': { message: 'Login popup was blocked. Please enable popups', code: 'POPUP_BLOCKED' },\n 'expired-action-code': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' },\n 'user-token-expired': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' },\n 'tenant-not-found': { message: 'There is no tenant corresponding to the provided identifier.', code: 'INVALID_ARGUMENT' },\n };\n\n try {\n // Extract error information\n const errorInfo = extractErrorInfo(error);\n \n if (errorInfo) {\n const mappedError = ERROR_MESSAGES[errorInfo.code];\n if (mappedError) {\n return {\n success: false,\n message: mappedError.message,\n code: mappedError.code\n };\n }\n }\n\n // If we couldn't extract or map the error, try one last time with string conversion\n const errorString = String(error);\n const lastMatch = errorString.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\n if (lastMatch && ERROR_MESSAGES[lastMatch[1]]) {\n return {\n success: false,\n ...ERROR_MESSAGES[lastMatch[1]]\n };\n }\n\n } catch (e) {\n // Silent catch - we'll return the default error\n }\n\n // Default fallback\n return {\n success: false,\n message: 'An unexpected error occurred. Please try again later',\n code: 'INTERNAL_ERROR'\n };\n}\n\n/**\n * Type guard to check if a response is an AuthErrorResponse\n */\nexport function isAuthErrorResponse(response: unknown): response is AuthErrorResponse {\n return (\n typeof response === \"object\" &&\n response !== null &&\n \"success\" in response &&\n (response as { success: boolean }).success === false &&\n \"code\" in response &&\n \"message\" in response\n )\n}\n\nexport function getErrorAlertVariant(error: any | undefined) {\n if (!error) return \"destructive\"\n\n switch (error.error) {\n case \"AUTHENTICATED\":\n return \"default\"\n case \"EMAIL_EXISTS\":\n case \"UNAUTHENTICATED\":\n case \"UNVERIFIED\":\n case \"REQUIRES_VERIFICATION\":\n case \"INVALID_EMAIL\":\n case \"INVALID_TOKEN\":\n case \"INTERNAL_ERROR\":\n case \"USER_DISABLED\":\n case \"TOO_MANY_ATTEMPTS\":\n case \"NETWORK_ERROR\":\n case \"SESSION_EXPIRED\":\n case \"EXPIRED_TOKEN\":\n case \"INVALID_CREDENTIALS\":\n default:\n return \"destructive\"\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAGzC,YAAY,MAAiB,SAAkB;AAC7C,UAAM,WAAW,IAAI;AACrB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;AAMO,SAAS,wBAAwB,OAAmC;AACzE,WAAS,iBAAiB,OAA0D;AAElF,QAAI,OAAO,UAAU,UAAU;AAC7B,YAAM,QAAQ,MAAM,MAAM,uCAAuC;AACjE,UAAI,OAAO;AACT,eAAO,EAAE,MAAM,MAAM,CAAC,GAAG,SAAS,MAAM;AAAA,MAC1C;AAAA,IACF;AAGA,QAAI,SAAS,OAAO,UAAU,UAAU;AACtC,YAAM,MAAM;AAGZ,UAAI,IAAI,SAAS;AACf,cAAM,QAAQ,IAAI,QAAQ,MAAM,uCAAuC;AACvE,YAAI,OAAO;AACT,iBAAO,EAAE,MAAM,MAAM,CAAC,GAAG,SAAS,IAAI,QAAQ;AAAA,QAChD;AAAA,MACF;AAGA,UAAI,IAAI,MAAM;AACZ,eAAO;AAAA,UACL,MAAM,IAAI,KAAK,Q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A,UACT,SAAS,YAAY;AAAA,UACrB,MAAM,YAAY;AAAA,QACpB;AAAA,MACF;AAAA,IACF;AAGA,UAAM,cAAc,OAAO,KAAK;AAChC,UAAM,YAAY,YAAY,MAAM,uCAAuC;AAC3E,QAAI,aAAa,eAAe,UAAU,CAAC,CAAC,GAAG;AAC7C,aAAO;AAAA,QACL,SAAS;AAAA,QACT,GAAG,eAAe,UAAU,CAAC,CAAC;AAAA,MAChC;AAAA,IACF;AAAA,EAEF,SAAS,GAAG;AAAA,EAEZ;AAGA,SAAO;AAAA,IACL,SAAS;AAAA,IACT,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AACF;AAKO,SAAS,oBAAoB,UAAkD;AACpF,SACE,OAAO,aAAa,YACpB,aAAa,QACb,aAAa,YACZ,SAAkC,YAAY,SAC/C,UAAU,YACV,aAAa;AAEjB;AAEO,SAAS,qBAAqB,OAAwB;AAC5D,MAAI,CAAC,MAAO,QAAO;AAElB,UAAQ,MAAM,OAAO;AAAA,IACnB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
package/dist/errors.mjs
CHANGED
|
@@ -32,6 +32,7 @@ function handleFirebaseAuthError(error) {
|
|
|
32
32
|
return null;
|
|
33
33
|
}
|
|
34
34
|
const ERROR_MESSAGES = {
|
|
35
|
+
"argument-error": { message: "Method called with incorrect arguments", code: "INCORRECT_ARGUMENT" },
|
|
35
36
|
"invalid-email": { message: "Invalid email format", code: "INVALID_EMAIL" },
|
|
36
37
|
"invalid-tenant-id": { message: "Invalid tenant ID", code: "INVALID_ARGUMENT" },
|
|
37
38
|
"invalid-credential": { message: "Invalid email or password", code: "INVALID_CREDENTIALS" },
|
package/dist/errors.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["import type { AuthErrorResponse, ErrorCode } from \"@tern-secure/types\";\n\n\nexport class TernSecureError extends Error {\n code: ErrorCode\n\n constructor(code: ErrorCode, message?: string) {\n super(message || code)\n this.name = \"TernSecureError\"\n this.code = code\n }\n}\n\n\n/**\n * Handles Firebase authentication errors with multiple fallback mechanisms\n */\nexport function handleFirebaseAuthError(error: unknown): AuthErrorResponse {\n function extractErrorInfo(input: unknown): { code: string; message: string } | null {\n // Case 1: String input (direct Firebase error message)\n if (typeof input === 'string') {\n const match = input.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\n if (match) {\n return { code: match[1], message: input };\n }\n }\n\n // Case 2: Error object\n if (input && typeof input === 'object') {\n const err = input as { code?: string; message?: string };\n \n // Check for bundled message format first\n if (err.message) {\n const match = err.message.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\n if (match) {\n return { code: match[1], message: err.message };\n }\n }\n\n // Check for direct code\n if (err.code) {\n return {\n code: err.code.replace('auth/', ''),\n message: err.message || ''\n };\n }\n }\n\n return null;\n }\n\n // Map error codes to user-friendly messages\n const ERROR_MESSAGES: Record<string, { message: string; code: ErrorCode }> = {\n 'invalid-email': { message: 'Invalid email format', code: 'INVALID_EMAIL' },\n 'invalid-tenant-id': { message: 'Invalid tenant ID', code: 'INVALID_ARGUMENT' },\n 'invalid-credential': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'invalid-login-credentials': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'wrong-password': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'user-not-found': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'user-disabled': { message: 'This account has been disabled', code: 'USER_DISABLED' },\n 'too-many-requests': { message: 'Too many attempts. Please try again later', code: 'TOO_MANY_ATTEMPTS' },\n 'network-request-failed': { message: 'Network error. Please check your connection', code: 'NETWORK_ERROR' },\n 'email-already-in-use': { message: 'This email is already in use', code: 'EMAIL_EXISTS' },\n 'weak-password': { message: 'Password is too weak', code: 'WEAK_PASSWORD' },\n 'operation-not-allowed': { message: 'This login method is not enabled', code: 'OPERATION_NOT_ALLOWED' },\n 'popup-blocked': { message: 'Login popup was blocked. Please enable popups', code: 'POPUP_BLOCKED' },\n 'expired-action-code': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' },\n 'user-token-expired': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' },\n 'tenant-not-found': { message: 'There is no tenant corresponding to the provided identifier.', code: 'INVALID_ARGUMENT' },\n };\n\n try {\n // Extract error information\n const errorInfo = extractErrorInfo(error);\n \n if (errorInfo) {\n const mappedError = ERROR_MESSAGES[errorInfo.code];\n if (mappedError) {\n return {\n success: false,\n message: mappedError.message,\n code: mappedError.code\n };\n }\n }\n\n // If we couldn't extract or map the error, try one last time with string conversion\n const errorString = String(error);\n const lastMatch = errorString.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\n if (lastMatch && ERROR_MESSAGES[lastMatch[1]]) {\n return {\n success: false,\n ...ERROR_MESSAGES[lastMatch[1]]\n };\n }\n\n } catch (e) {\n // Silent catch - we'll return the default error\n }\n\n // Default fallback\n return {\n success: false,\n message: 'An unexpected error occurred. Please try again later',\n code: 'INTERNAL_ERROR'\n };\n}\n\n/**\n * Type guard to check if a response is an AuthErrorResponse\n */\nexport function isAuthErrorResponse(response: unknown): response is AuthErrorResponse {\n return (\n typeof response === \"object\" &&\n response !== null &&\n \"success\" in response &&\n (response as { success: boolean }).success === false &&\n \"code\" in response &&\n \"message\" in response\n )\n}\n\nexport function getErrorAlertVariant(error: any | undefined) {\n if (!error) return \"destructive\"\n\n switch (error.error) {\n case \"AUTHENTICATED\":\n return \"default\"\n case \"EMAIL_EXISTS\":\n case \"UNAUTHENTICATED\":\n case \"UNVERIFIED\":\n case \"REQUIRES_VERIFICATION\":\n case \"INVALID_EMAIL\":\n case \"INVALID_TOKEN\":\n case \"INTERNAL_ERROR\":\n case \"USER_DISABLED\":\n case \"TOO_MANY_ATTEMPTS\":\n case \"NETWORK_ERROR\":\n case \"SESSION_EXPIRED\":\n case \"EXPIRED_TOKEN\":\n case \"INVALID_CREDENTIALS\":\n default:\n return \"destructive\"\n }\n}"],"mappings":";AAGO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAGzC,YAAY,MAAiB,SAAkB;AAC7C,UAAM,WAAW,IAAI;AACrB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;AAMO,SAAS,wBAAwB,OAAmC;AACzE,WAAS,iBAAiB,OAA0D;AAElF,QAAI,OAAO,UAAU,UAAU;AAC7B,YAAM,QAAQ,MAAM,MAAM,uCAAuC;AACjE,UAAI,OAAO;AACT,eAAO,EAAE,MAAM,MAAM,CAAC,GAAG,SAAS,MAAM;AAAA,MAC1C;AAAA,IACF;AAGA,QAAI,SAAS,OAAO,UAAU,UAAU;AACtC,YAAM,MAAM;AAGZ,UAAI,IAAI,SAAS;AACf,cAAM,QAAQ,IAAI,QAAQ,MAAM,uCAAuC;AACvE,YAAI,OAAO;AACT,iBAAO,EAAE,MAAM,MAAM,CAAC,GAAG,SAAS,IAAI,QAAQ;AAAA,QAChD;AAAA,MACF;AAGA,UAAI,IAAI,MAAM;AACZ,eAAO;AAAA,UACL,MAAM,IAAI,KAAK,QAAQ,SAAS,EAAE;AAAA,UAClC,SAAS,IAAI,WAAW;AAAA,QAC1B;AAAA,MACF;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAGA,QAAM,iBAAuE;AAAA,IAC3E,iBAAiB,EAAE,SAAS,wBAAwB,MAAM,gBAAgB;AAAA,IAC1E,qBAAqB,EAAE,SAAS,qBAAqB,MAAM,mBAAmB;AAAA,IAC9E,sBAAsB,EAAE,SAA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AAGA,SAAO;AAAA,IACL,SAAS;AAAA,IACT,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AACF;AAKO,SAAS,oBAAoB,UAAkD;AACpF,SACE,OAAO,aAAa,YACpB,aAAa,QACb,aAAa,YACZ,SAAkC,YAAY,SAC/C,UAAU,YACV,aAAa;AAEjB;AAEO,SAAS,qBAAqB,OAAwB;AAC5D,MAAI,CAAC,MAAO,QAAO;AAElB,UAAQ,MAAM,OAAO;AAAA,IACnB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EACX;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"sourcesContent":["import type { AuthErrorResponse, ErrorCode } from \"@tern-secure/types\";\n\n\nexport class TernSecureError extends Error {\n code: ErrorCode\n\n constructor(code: ErrorCode, message?: string) {\n super(message || code)\n this.name = \"TernSecureError\"\n this.code = code\n }\n}\n\n\n/**\n * Handles Firebase authentication errors with multiple fallback mechanisms\n */\nexport function handleFirebaseAuthError(error: unknown): AuthErrorResponse {\n function extractErrorInfo(input: unknown): { code: string; message: string } | null {\n // Case 1: String input (direct Firebase error message)\n if (typeof input === 'string') {\n const match = input.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\n if (match) {\n return { code: match[1], message: input };\n }\n }\n\n // Case 2: Error object\n if (input && typeof input === 'object') {\n const err = input as { code?: string; message?: string };\n \n // Check for bundled message format first\n if (err.message) {\n const match = err.message.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\n if (match) {\n return { code: match[1], message: err.message };\n }\n }\n\n // Check for direct code\n if (err.code) {\n return {\n code: err.code.replace('auth/', ''),\n message: err.message || ''\n };\n }\n }\n\n return null;\n }\n\n // Map error codes to user-friendly messages\n const ERROR_MESSAGES: Record<string, { message: string; code: ErrorCode }> = {\n 'argument-error': { message: 'Method called with incorrect arguments', code: 'INCORRECT_ARGUMENT' },\n 'invalid-email': { message: 'Invalid email format', code: 'INVALID_EMAIL' },\n 'invalid-tenant-id': { message: 'Invalid tenant ID', code: 'INVALID_ARGUMENT' },\n 'invalid-credential': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'invalid-login-credentials': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'wrong-password': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'user-not-found': { message: 'Invalid email or password', code: 'INVALID_CREDENTIALS' },\n 'user-disabled': { message: 'This account has been disabled', code: 'USER_DISABLED' },\n 'too-many-requests': { message: 'Too many attempts. Please try again later', code: 'TOO_MANY_ATTEMPTS' },\n 'network-request-failed': { message: 'Network error. Please check your connection', code: 'NETWORK_ERROR' },\n 'email-already-in-use': { message: 'This email is already in use', code: 'EMAIL_EXISTS' },\n 'weak-password': { message: 'Password is too weak', code: 'WEAK_PASSWORD' },\n 'operation-not-allowed': { message: 'This login method is not enabled', code: 'OPERATION_NOT_ALLOWED' },\n 'popup-blocked': { message: 'Login popup was blocked. Please enable popups', code: 'POPUP_BLOCKED' },\n 'expired-action-code': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' },\n 'user-token-expired': { message: 'Your session has expired. Please login again', code: 'EXPIRED_TOKEN' },\n 'tenant-not-found': { message: 'There is no tenant corresponding to the provided identifier.', code: 'INVALID_ARGUMENT' },\n };\n\n try {\n // Extract error information\n const errorInfo = extractErrorInfo(error);\n \n if (errorInfo) {\n const mappedError = ERROR_MESSAGES[errorInfo.code];\n if (mappedError) {\n return {\n success: false,\n message: mappedError.message,\n code: mappedError.code\n };\n }\n }\n\n // If we couldn't extract or map the error, try one last time with string conversion\n const errorString = String(error);\n const lastMatch = errorString.match(/Firebase:\\s*Error\\s*\\(auth\\/([^)]+)\\)/);\n if (lastMatch && ERROR_MESSAGES[lastMatch[1]]) {\n return {\n success: false,\n ...ERROR_MESSAGES[lastMatch[1]]\n };\n }\n\n } catch (e) {\n // Silent catch - we'll return the default error\n }\n\n // Default fallback\n return {\n success: false,\n message: 'An unexpected error occurred. Please try again later',\n code: 'INTERNAL_ERROR'\n };\n}\n\n/**\n * Type guard to check if a response is an AuthErrorResponse\n */\nexport function isAuthErrorResponse(response: unknown): response is AuthErrorResponse {\n return (\n typeof response === \"object\" &&\n response !== null &&\n \"success\" in response &&\n (response as { success: boolean }).success === false &&\n \"code\" in response &&\n \"message\" in response\n )\n}\n\nexport function getErrorAlertVariant(error: any | undefined) {\n if (!error) return \"destructive\"\n\n switch (error.error) {\n case \"AUTHENTICATED\":\n return \"default\"\n case \"EMAIL_EXISTS\":\n case \"UNAUTHENTICATED\":\n case \"UNVERIFIED\":\n case \"REQUIRES_VERIFICATION\":\n case \"INVALID_EMAIL\":\n case \"INVALID_TOKEN\":\n case \"INTERNAL_ERROR\":\n case \"USER_DISABLED\":\n case \"TOO_MANY_ATTEMPTS\":\n case \"NETWORK_ERROR\":\n case \"SESSION_EXPIRED\":\n case \"EXPIRED_TOKEN\":\n case \"INVALID_CREDENTIALS\":\n default:\n return \"destructive\"\n }\n}"],"mappings":";AAGO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAGzC,YAAY,MAAiB,SAAkB;AAC7C,UAAM,WAAW,IAAI;AACrB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;AAMO,SAAS,wBAAwB,OAAmC;AACzE,WAAS,iBAAiB,OAA0D;AAElF,QAAI,OAAO,UAAU,UAAU;AAC7B,YAAM,QAAQ,MAAM,MAAM,uCAAuC;AACjE,UAAI,OAAO;AACT,eAAO,EAAE,MAAM,MAAM,CAAC,GAAG,SAAS,MAAM;AAAA,MAC1C;AAAA,IACF;AAGA,QAAI,SAAS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ist/globs.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/globs.ts
|
|
31
|
+
var globs_exports = {};
|
|
32
|
+
__export(globs_exports, {
|
|
33
|
+
globs: () => globs
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(globs_exports);
|
|
36
|
+
var import_glob_to_regexp = __toESM(require("glob-to-regexp"));
|
|
37
|
+
var globs = {
|
|
38
|
+
toRegexp: (pattern) => {
|
|
39
|
+
try {
|
|
40
|
+
return (0, import_glob_to_regexp.default)(pattern);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`Invalid pattern: ${pattern}.
|
|
44
|
+
Consult the documentation of glob-to-regexp here: https://www.npmjs.com/package/glob-to-regexp.
|
|
45
|
+
${e.message}`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
51
|
+
0 && (module.exports = {
|
|
52
|
+
globs
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=globs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/globs.ts"],"sourcesContent":["import globToRegexp from 'glob-to-regexp';\n\nexport const globs = {\n toRegexp: (pattern: string): RegExp => {\n try {\n return globToRegexp(pattern);\n } catch (e: any) {\n throw new Error(\n `Invalid pattern: ${pattern}.\\nConsult the documentation of glob-to-regexp here: https://www.npmjs.com/package/glob-to-regexp.\\n${e.message}`,\n );\n }\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAyB;AAElB,IAAM,QAAQ;AAAA,EACnB,UAAU,CAAC,YAA4B;AACrC,QAAI;AACF,iBAAO,sBAAAA,SAAa,OAAO;AAAA,IAC7B,SAAS,GAAQ;AACf,YAAM,IAAI;AAAA,QACR,oBAAoB,OAAO;AAAA;AAAA,EAAuG,EAAE,OAAO;AAAA,MAC7I;AAAA,IACF;AAAA,EACF;AACF;","names":["globToRegexp"]}
|
package/dist/globs.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/globs.ts
|
|
2
|
+
import globToRegexp from "glob-to-regexp";
|
|
3
|
+
var globs = {
|
|
4
|
+
toRegexp: (pattern) => {
|
|
5
|
+
try {
|
|
6
|
+
return globToRegexp(pattern);
|
|
7
|
+
} catch (e) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
`Invalid pattern: ${pattern}.
|
|
10
|
+
Consult the documentation of glob-to-regexp here: https://www.npmjs.com/package/glob-to-regexp.
|
|
11
|
+
${e.message}`
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
globs
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=globs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/globs.ts"],"sourcesContent":["import globToRegexp from 'glob-to-regexp';\n\nexport const globs = {\n toRegexp: (pattern: string): RegExp => {\n try {\n return globToRegexp(pattern);\n } catch (e: any) {\n throw new Error(\n `Invalid pattern: ${pattern}.\\nConsult the documentation of glob-to-regexp here: https://www.npmjs.com/package/glob-to-regexp.\\n${e.message}`,\n );\n }\n },\n};\n"],"mappings":";AAAA,OAAO,kBAAkB;AAElB,IAAM,QAAQ;AAAA,EACnB,UAAU,CAAC,YAA4B;AACrC,QAAI;AACF,aAAO,aAAa,OAAO;AAAA,IAC7B,SAAS,GAAQ;AACf,YAAM,IAAI;AAAA,QACR,oBAAoB,OAAO;AAAA;AAAA,EAAuG,EAAE,OAAO;AAAA,MAC7I;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const without: <T extends object, P extends keyof T>(obj: T, ...props: P[]) => Omit<T, P>;
|
|
2
|
+
declare const removeUndefined: <T extends object>(obj: T) => Partial<T>;
|
|
3
|
+
declare const applyFunctionToObj: <T extends Record<string, any>, R>(obj: T, fn: (val: any, key: string) => R) => Record<string, R>;
|
|
4
|
+
declare const filterProps: <T extends Record<string, any>>(obj: T, filter: (a: any) => boolean) => T;
|
|
5
|
+
|
|
6
|
+
export { applyFunctionToObj, filterProps, removeUndefined, without };
|
package/dist/object.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const without: <T extends object, P extends keyof T>(obj: T, ...props: P[]) => Omit<T, P>;
|
|
2
|
+
declare const removeUndefined: <T extends object>(obj: T) => Partial<T>;
|
|
3
|
+
declare const applyFunctionToObj: <T extends Record<string, any>, R>(obj: T, fn: (val: any, key: string) => R) => Record<string, R>;
|
|
4
|
+
declare const filterProps: <T extends Record<string, any>>(obj: T, filter: (a: any) => boolean) => T;
|
|
5
|
+
|
|
6
|
+
export { applyFunctionToObj, filterProps, removeUndefined, without };
|
package/dist/object.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
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/object.ts
|
|
21
|
+
var object_exports = {};
|
|
22
|
+
__export(object_exports, {
|
|
23
|
+
applyFunctionToObj: () => applyFunctionToObj,
|
|
24
|
+
filterProps: () => filterProps,
|
|
25
|
+
removeUndefined: () => removeUndefined,
|
|
26
|
+
without: () => without
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(object_exports);
|
|
29
|
+
var without = (obj, ...props) => {
|
|
30
|
+
const copy = { ...obj };
|
|
31
|
+
for (const prop of props) {
|
|
32
|
+
delete copy[prop];
|
|
33
|
+
}
|
|
34
|
+
return copy;
|
|
35
|
+
};
|
|
36
|
+
var removeUndefined = (obj) => {
|
|
37
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
38
|
+
if (value !== void 0 && value !== null) {
|
|
39
|
+
acc[key] = value;
|
|
40
|
+
}
|
|
41
|
+
return acc;
|
|
42
|
+
}, {});
|
|
43
|
+
};
|
|
44
|
+
var applyFunctionToObj = (obj, fn) => {
|
|
45
|
+
const result = {};
|
|
46
|
+
for (const key in obj) {
|
|
47
|
+
result[key] = fn(obj[key], key);
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
var filterProps = (obj, filter) => {
|
|
52
|
+
const result = {};
|
|
53
|
+
for (const key in obj) {
|
|
54
|
+
if (obj[key] && filter(obj[key])) {
|
|
55
|
+
result[key] = obj[key];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
applyFunctionToObj,
|
|
63
|
+
filterProps,
|
|
64
|
+
removeUndefined,
|
|
65
|
+
without
|
|
66
|
+
});
|
|
67
|
+
//# sourceMappingURL=object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/object.ts"],"sourcesContent":["export const without = <T extends object, P extends keyof T>(obj: T, ...props: P[]): Omit<T, P> => {\n const copy = { ...obj };\n for (const prop of props) {\n delete copy[prop];\n }\n return copy;\n};\n\nexport const removeUndefined = <T extends object>(obj: T): Partial<T> => {\n return Object.entries(obj).reduce((acc, [key, value]) => {\n if (value !== undefined && value !== null) {\n acc[key as keyof T] = value;\n }\n return acc;\n }, {} as Partial<T>);\n};\n\nexport const applyFunctionToObj = <T extends Record<string, any>, R>(\n obj: T,\n fn: (val: any, key: string) => R,\n): Record<string, R> => {\n const result = {} as Record<string, R>;\n for (const key in obj) {\n result[key] = fn(obj[key], key);\n }\n return result;\n};\n\nexport const filterProps = <T extends Record<string, any>>(obj: T, filter: (a: any) => boolean): T => {\n const result = {} as T;\n for (const key in obj) {\n if (obj[key] && filter(obj[key])) {\n result[key] = obj[key];\n }\n }\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,UAAU,CAAsC,QAAW,UAA2B;AACjG,QAAM,OAAO,EAAE,GAAG,IAAI;AACtB,aAAW,QAAQ,OAAO;AACxB,WAAO,KAAK,IAAI;AAAA,EAClB;AACA,SAAO;AACT;AAEO,IAAM,kBAAkB,CAAmB,QAAuB;AACvE,SAAO,OAAO,QAAQ,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM;AACvD,QAAI,UAAU,UAAa,UAAU,MAAM;AACzC,UAAI,GAAc,IAAI;AAAA,IACxB;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAe;AACrB;AAEO,IAAM,qBAAqB,CAChC,KACA,OACsB;AACtB,QAAM,SAAS,CAAC;AAChB,aAAW,OAAO,KAAK;AACrB,WAAO,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG;AAAA,EAChC;AACA,SAAO;AACT;AAEO,IAAM,cAAc,CAAgC,KAAQ,WAAmC;AACpG,QAAM,SAAS,CAAC;AAChB,aAAW,OAAO,KAAK;AACrB,QAAI,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,CAAC,GAAG;AAChC,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
package/dist/object.mjs
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/object.ts
|
|
2
|
+
var without = (obj, ...props) => {
|
|
3
|
+
const copy = { ...obj };
|
|
4
|
+
for (const prop of props) {
|
|
5
|
+
delete copy[prop];
|
|
6
|
+
}
|
|
7
|
+
return copy;
|
|
8
|
+
};
|
|
9
|
+
var removeUndefined = (obj) => {
|
|
10
|
+
return Object.entries(obj).reduce((acc, [key, value]) => {
|
|
11
|
+
if (value !== void 0 && value !== null) {
|
|
12
|
+
acc[key] = value;
|
|
13
|
+
}
|
|
14
|
+
return acc;
|
|
15
|
+
}, {});
|
|
16
|
+
};
|
|
17
|
+
var applyFunctionToObj = (obj, fn) => {
|
|
18
|
+
const result = {};
|
|
19
|
+
for (const key in obj) {
|
|
20
|
+
result[key] = fn(obj[key], key);
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
};
|
|
24
|
+
var filterProps = (obj, filter) => {
|
|
25
|
+
const result = {};
|
|
26
|
+
for (const key in obj) {
|
|
27
|
+
if (obj[key] && filter(obj[key])) {
|
|
28
|
+
result[key] = obj[key];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
applyFunctionToObj,
|
|
35
|
+
filterProps,
|
|
36
|
+
removeUndefined,
|
|
37
|
+
without
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=object.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/object.ts"],"sourcesContent":["export const without = <T extends object, P extends keyof T>(obj: T, ...props: P[]): Omit<T, P> => {\n const copy = { ...obj };\n for (const prop of props) {\n delete copy[prop];\n }\n return copy;\n};\n\nexport const removeUndefined = <T extends object>(obj: T): Partial<T> => {\n return Object.entries(obj).reduce((acc, [key, value]) => {\n if (value !== undefined && value !== null) {\n acc[key as keyof T] = value;\n }\n return acc;\n }, {} as Partial<T>);\n};\n\nexport const applyFunctionToObj = <T extends Record<string, any>, R>(\n obj: T,\n fn: (val: any, key: string) => R,\n): Record<string, R> => {\n const result = {} as Record<string, R>;\n for (const key in obj) {\n result[key] = fn(obj[key], key);\n }\n return result;\n};\n\nexport const filterProps = <T extends Record<string, any>>(obj: T, filter: (a: any) => boolean): T => {\n const result = {} as T;\n for (const key in obj) {\n if (obj[key] && filter(obj[key])) {\n result[key] = obj[key];\n }\n }\n return result;\n};\n"],"mappings":";AAAO,IAAM,UAAU,CAAsC,QAAW,UAA2B;AACjG,QAAM,OAAO,EAAE,GAAG,IAAI;AACtB,aAAW,QAAQ,OAAO;AACxB,WAAO,KAAK,IAAI;AAAA,EAClB;AACA,SAAO;AACT;AAEO,IAAM,kBAAkB,CAAmB,QAAuB;AACvE,SAAO,OAAO,QAAQ,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,MAAM;AACvD,QAAI,UAAU,UAAa,UAAU,MAAM;AACzC,UAAI,GAAc,IAAI;AAAA,IACxB;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAe;AACrB;AAEO,IAAM,qBAAqB,CAChC,KACA,OACsB;AACtB,QAAM,SAAS,CAAC;AAChB,aAAW,OAAO,KAAK;AACrB,WAAO,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG;AAAA,EAChC;AACA,SAAO;AACT;AAEO,IAAM,cAAc,CAAgC,KAAQ,WAAmC;AACpG,QAAM,SAAS,CAAC;AAChB,aAAW,OAAO,KAAK;AACrB,QAAI,IAAI,GAAG,KAAK,OAAO,IAAI,GAAG,CAAC,GAAG;AAChC,aAAO,GAAG,IAAI,IAAI,GAAG;AAAA,IACvB;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tern-secure/shared",
|
|
3
|
-
"version": "1.3.0-canary.
|
|
3
|
+
"version": "1.3.0-canary.v20251023005301",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/TernSecure/auth.git",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
},
|
|
73
73
|
"main": "./dist/index.js",
|
|
74
74
|
"devDependencies": {
|
|
75
|
+
"@types/glob-to-regexp": "0.4.4",
|
|
75
76
|
"@types/js-cookie": "^3.0.6",
|
|
76
77
|
"prettier": "^3.3.3",
|
|
77
78
|
"rimraf": "^6.0.1",
|
|
@@ -79,9 +80,10 @@
|
|
|
79
80
|
"typescript": "^5.7.2"
|
|
80
81
|
},
|
|
81
82
|
"dependencies": {
|
|
83
|
+
"glob-to-regexp": "0.4.1",
|
|
82
84
|
"js-cookie": "^3.0.5",
|
|
83
85
|
"tslib": "2.4.1",
|
|
84
|
-
"@tern-secure/types": "1.1.0-canary.
|
|
86
|
+
"@tern-secure/types": "1.1.0-canary.v20251023005301"
|
|
85
87
|
},
|
|
86
88
|
"peerDependencies": {
|
|
87
89
|
"react": "^19",
|