@xbg.solutions/bpsk-utils-firebase-auth 1.2.3
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/lib/index.d.ts +13 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +20 -0
- package/lib/index.js.map +1 -0
- package/lib/services/auth/auth.service.d.ts +89 -0
- package/lib/services/auth/auth.service.d.ts.map +1 -0
- package/lib/services/auth/auth.service.js +615 -0
- package/lib/services/auth/auth.service.js.map +1 -0
- package/lib/services/auth/email-link.d.ts +99 -0
- package/lib/services/auth/email-link.d.ts.map +1 -0
- package/lib/services/auth/email-link.js +715 -0
- package/lib/services/auth/email-link.js.map +1 -0
- package/lib/services/auth/index.d.ts +15 -0
- package/lib/services/auth/index.d.ts.map +1 -0
- package/lib/services/auth/index.js +18 -0
- package/lib/services/auth/index.js.map +1 -0
- package/lib/services/auth/phone-auth.d.ts +65 -0
- package/lib/services/auth/phone-auth.d.ts.map +1 -0
- package/lib/services/auth/phone-auth.js +150 -0
- package/lib/services/auth/phone-auth.js.map +1 -0
- package/lib/services/auth/user-creation.d.ts +17 -0
- package/lib/services/auth/user-creation.d.ts.map +1 -0
- package/lib/services/auth/user-creation.js +39 -0
- package/lib/services/auth/user-creation.js.map +1 -0
- package/lib/services/token/index.d.ts +29 -0
- package/lib/services/token/index.d.ts.map +1 -0
- package/lib/services/token/index.js +20 -0
- package/lib/services/token/index.js.map +1 -0
- package/lib/services/token/token.service.d.ts +57 -0
- package/lib/services/token/token.service.d.ts.map +1 -0
- package/lib/services/token/token.service.js +554 -0
- package/lib/services/token/token.service.js.map +1 -0
- package/lib/stores/auth.service.d.ts +6 -0
- package/lib/stores/auth.service.d.ts.map +1 -0
- package/lib/stores/auth.service.js +6 -0
- package/lib/stores/auth.service.js.map +1 -0
- package/lib/stores/auth.store.d.ts +56 -0
- package/lib/stores/auth.store.d.ts.map +1 -0
- package/lib/stores/auth.store.js +64 -0
- package/lib/stores/auth.store.js.map +1 -0
- package/lib/stores/token.store.d.ts +41 -0
- package/lib/stores/token.store.d.ts.map +1 -0
- package/lib/stores/token.store.js +36 -0
- package/lib/stores/token.store.js.map +1 -0
- package/lib/stores/user-creation.d.ts +8 -0
- package/lib/stores/user-creation.d.ts.map +1 -0
- package/lib/stores/user-creation.js +11 -0
- package/lib/stores/user-creation.js.map +1 -0
- package/lib/utils/auth-guard.d.ts +58 -0
- package/lib/utils/auth-guard.d.ts.map +1 -0
- package/lib/utils/auth-guard.js +109 -0
- package/lib/utils/auth-guard.js.map +1 -0
- package/lib/utils/signout.d.ts +82 -0
- package/lib/utils/signout.d.ts.map +1 -0
- package/lib/utils/signout.js +168 -0
- package/lib/utils/signout.js.map +1 -0
- package/lib/utils/tokens.d.ts +136 -0
- package/lib/utils/tokens.d.ts.map +1 -0
- package/lib/utils/tokens.js +479 -0
- package/lib/utils/tokens.js.map +1 -0
- package/package.json +31 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/lib/services/auth/email-link.ts
|
|
3
|
+
* Email Link Authentication service
|
|
4
|
+
*
|
|
5
|
+
* Provides functionality for Firebase Email Link authentication:
|
|
6
|
+
* - Sending authentication links
|
|
7
|
+
* - Verifying links
|
|
8
|
+
* - Managing email persistence
|
|
9
|
+
* - Error handling specific to email link flow
|
|
10
|
+
*/
|
|
11
|
+
import { AppError } from '@xbg.solutions/bpsk-core';
|
|
12
|
+
import type { EmailLinkOptions, EmailLinkVerifyOptions, AuthResult } from '@xbg.solutions/bpsk-core';
|
|
13
|
+
/**
|
|
14
|
+
* Sends an email authentication link
|
|
15
|
+
*
|
|
16
|
+
* @param options Email link configuration options
|
|
17
|
+
* @returns Promise resolving to success status
|
|
18
|
+
*/
|
|
19
|
+
export declare function checkUserExistsAndCreate(email: string): Promise<boolean>;
|
|
20
|
+
export declare function sendEmailLink(options: EmailLinkOptions): Promise<AuthResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Verifies an email authentication link and signs in the user
|
|
23
|
+
*
|
|
24
|
+
* @param options Email link verification options
|
|
25
|
+
* @returns Promise resolving to authentication result
|
|
26
|
+
*/
|
|
27
|
+
export declare function verifyEmailLink(options?: EmailLinkVerifyOptions): Promise<AuthResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Safely sends an email authentication link with error handling
|
|
30
|
+
*/
|
|
31
|
+
export declare const safeSendEmailLink: (options: EmailLinkOptions) => Promise<{
|
|
32
|
+
success: boolean;
|
|
33
|
+
data?: AuthResult | undefined;
|
|
34
|
+
error?: AppError;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Safely verifies an email authentication link with error handling
|
|
38
|
+
*/
|
|
39
|
+
export declare const safeVerifyEmailLink: (options?: EmailLinkVerifyOptions | undefined) => Promise<{
|
|
40
|
+
success: boolean;
|
|
41
|
+
data?: AuthResult | undefined;
|
|
42
|
+
error?: AppError;
|
|
43
|
+
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Checks if the current URL is an email sign-in link
|
|
46
|
+
*
|
|
47
|
+
* @returns Promise resolving to whether the URL is an email sign-in link
|
|
48
|
+
*/
|
|
49
|
+
export declare function isEmailSignInLink(): Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* Synchronous version that can be used in places where async isn't supported
|
|
52
|
+
* This uses the current auth instance if available, otherwise returns false
|
|
53
|
+
*/
|
|
54
|
+
export declare function isEmailSignInLinkSync(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Gets the stored email for sign-in
|
|
57
|
+
*
|
|
58
|
+
* @returns The stored email or null if not found
|
|
59
|
+
*/
|
|
60
|
+
export declare function getStoredEmail(): string | null;
|
|
61
|
+
/**
|
|
62
|
+
* Stores an email for sign-in
|
|
63
|
+
*
|
|
64
|
+
* IMPORTANT: We use localStorage WITHOUT encryption to ensure cross-tab compatibility.
|
|
65
|
+
* This is a necessary security trade-off for email link authentication which requires
|
|
66
|
+
* the email to be available in any tab where the user opens the verification link.
|
|
67
|
+
*
|
|
68
|
+
* @param email Email to store
|
|
69
|
+
* @returns Whether storage was successful
|
|
70
|
+
*/
|
|
71
|
+
export declare function storeEmail(email: string): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Clears the stored email for sign-in
|
|
74
|
+
*
|
|
75
|
+
* @returns Whether removal was successful
|
|
76
|
+
*/
|
|
77
|
+
export declare function clearStoredEmail(): boolean;
|
|
78
|
+
declare const _default: {
|
|
79
|
+
sendEmailLink: typeof sendEmailLink;
|
|
80
|
+
verifyEmailLink: typeof verifyEmailLink;
|
|
81
|
+
safeSendEmailLink: (options: EmailLinkOptions) => Promise<{
|
|
82
|
+
success: boolean;
|
|
83
|
+
data?: AuthResult | undefined;
|
|
84
|
+
error?: AppError;
|
|
85
|
+
}>;
|
|
86
|
+
safeVerifyEmailLink: (options?: EmailLinkVerifyOptions | undefined) => Promise<{
|
|
87
|
+
success: boolean;
|
|
88
|
+
data?: AuthResult | undefined;
|
|
89
|
+
error?: AppError;
|
|
90
|
+
}>;
|
|
91
|
+
isEmailSignInLink: typeof isEmailSignInLink;
|
|
92
|
+
isEmailSignInLinkSync: typeof isEmailSignInLinkSync;
|
|
93
|
+
getStoredEmail: typeof getStoredEmail;
|
|
94
|
+
storeEmail: typeof storeEmail;
|
|
95
|
+
clearStoredEmail: typeof clearStoredEmail;
|
|
96
|
+
checkUserExistsAndCreate: typeof checkUserExistsAndCreate;
|
|
97
|
+
};
|
|
98
|
+
export default _default;
|
|
99
|
+
//# sourceMappingURL=email-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"email-link.d.ts","sourceRoot":"","sources":["../../../src/services/auth/email-link.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAYH,OAAO,EAAE,QAAQ,EAAkD,MAAM,0BAA0B,CAAC;AAGpG,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAgFrG;;;;;GAKG;AAEH,wBAAsB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAI9E;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,CAgFlF;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,UAAU,CAAC,CA4Q/F;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;EAAmC,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;EAAqC,CAAC;AAEtE;;;;GAIG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAmB1D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAqB/C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAqH9C;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAkEjD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CA6E1C;;;;;;;;;;;;;;;;;;;;;AAED,wBAWE"}
|