@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
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './services/auth/auth.service';
|
|
2
|
+
export { sendEmailLink, verifyEmailLink, safeSendEmailLink as safeSendEmailLinkDirect, safeVerifyEmailLink as safeVerifyEmailLinkDirect, checkUserExistsAndCreate as checkEmailUserExistsAndCreate, isEmailSignInLink, isEmailSignInLinkSync, getStoredEmail, storeEmail, clearStoredEmail } from './services/auth/email-link';
|
|
3
|
+
export { sendPhoneCode, verifyPhoneCode, safeSendPhoneCode as safeSendPhoneCodeDirect, safeVerifyPhoneCode as safeVerifyPhoneCodeDirect, checkUserExistsAndCreate as checkPhoneUserExistsAndCreate } from './services/auth/phone-auth';
|
|
4
|
+
export { ensureUserExists as ensureServiceUserExists } from './services/auth/user-creation';
|
|
5
|
+
export * from './services/token/token.service';
|
|
6
|
+
export * from './stores/auth.service';
|
|
7
|
+
export * from './stores/auth.store';
|
|
8
|
+
export * from './stores/token.store';
|
|
9
|
+
export * from './stores/user-creation';
|
|
10
|
+
export * from './utils/auth-guard';
|
|
11
|
+
export * from './utils/signout';
|
|
12
|
+
export * from './utils/tokens';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,8BAA8B,CAAC;AAG7C,OAAO,EACL,aAAa,EACb,eAAe,EACf,iBAAiB,IAAI,uBAAuB,EAC5C,mBAAmB,IAAI,yBAAyB,EAChD,wBAAwB,IAAI,6BAA6B,EACzD,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,UAAU,EACV,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,aAAa,EACb,eAAe,EACf,iBAAiB,IAAI,uBAAuB,EAC5C,mBAAmB,IAAI,yBAAyB,EAChD,wBAAwB,IAAI,6BAA6B,EAC1D,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,gBAAgB,IAAI,uBAAuB,EAC5C,MAAM,+BAA+B,CAAC;AAEvC,cAAc,gCAAgC,CAAC;AAG/C,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Firebase auth package barrel exports
|
|
2
|
+
// Services - auth.service exports the canonical safe* wrappers
|
|
3
|
+
export * from './services/auth/auth.service';
|
|
4
|
+
// Services - email-link (exclude duplicates already in auth.service)
|
|
5
|
+
export { sendEmailLink, verifyEmailLink, safeSendEmailLink as safeSendEmailLinkDirect, safeVerifyEmailLink as safeVerifyEmailLinkDirect, checkUserExistsAndCreate as checkEmailUserExistsAndCreate, isEmailSignInLink, isEmailSignInLinkSync, getStoredEmail, storeEmail, clearStoredEmail } from './services/auth/email-link';
|
|
6
|
+
// Services - phone-auth (exclude duplicates already in auth.service)
|
|
7
|
+
export { sendPhoneCode, verifyPhoneCode, safeSendPhoneCode as safeSendPhoneCodeDirect, safeVerifyPhoneCode as safeVerifyPhoneCodeDirect, checkUserExistsAndCreate as checkPhoneUserExistsAndCreate } from './services/auth/phone-auth';
|
|
8
|
+
// Services - user-creation
|
|
9
|
+
export { ensureUserExists as ensureServiceUserExists } from './services/auth/user-creation';
|
|
10
|
+
export * from './services/token/token.service';
|
|
11
|
+
// Stores
|
|
12
|
+
export * from './stores/auth.service';
|
|
13
|
+
export * from './stores/auth.store';
|
|
14
|
+
export * from './stores/token.store';
|
|
15
|
+
export * from './stores/user-creation';
|
|
16
|
+
// Utils
|
|
17
|
+
export * from './utils/auth-guard';
|
|
18
|
+
export * from './utils/signout';
|
|
19
|
+
export * from './utils/tokens';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AAEvC,+DAA+D;AAC/D,cAAc,8BAA8B,CAAC;AAE7C,qEAAqE;AACrE,OAAO,EACL,aAAa,EACb,eAAe,EACf,iBAAiB,IAAI,uBAAuB,EAC5C,mBAAmB,IAAI,yBAAyB,EAChD,wBAAwB,IAAI,6BAA6B,EACzD,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,UAAU,EACV,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AAEpC,qEAAqE;AACrE,OAAO,EACL,aAAa,EACb,eAAe,EACf,iBAAiB,IAAI,uBAAuB,EAC5C,mBAAmB,IAAI,yBAAyB,EAChD,wBAAwB,IAAI,6BAA6B,EAC1D,MAAM,4BAA4B,CAAC;AAEpC,2BAA2B;AAC3B,OAAO,EACL,gBAAgB,IAAI,uBAAuB,EAC5C,MAAM,+BAA+B,CAAC;AAEvC,cAAc,gCAAgC,CAAC;AAE/C,SAAS;AACT,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AAEvC,QAAQ;AACR,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/lib/services/auth/auth.service.ts
|
|
3
|
+
* Authentication Service
|
|
4
|
+
*
|
|
5
|
+
* Core service for managing authentication state and operations:
|
|
6
|
+
* - Initializing and managing auth state
|
|
7
|
+
* - Integrating with Firebase Auth
|
|
8
|
+
* - Connecting email link and phone authentication methods
|
|
9
|
+
* - Integrating with token service
|
|
10
|
+
* - Emitting auth-related events
|
|
11
|
+
*/
|
|
12
|
+
import { AppError } from '@xbg.solutions/bpsk-core';
|
|
13
|
+
import type { EmailLinkVerifyOptions, AuthResult } from '@xbg.solutions/bpsk-core';
|
|
14
|
+
/**
|
|
15
|
+
* Creates an auth service instance
|
|
16
|
+
* @returns Auth service instance
|
|
17
|
+
*/
|
|
18
|
+
export declare function createAuthService(): {
|
|
19
|
+
initialize: () => Promise<void>;
|
|
20
|
+
sendEmailLink: (email: string, options?: {}) => Promise<AuthResult>;
|
|
21
|
+
verifyEmailLink: (options?: EmailLinkVerifyOptions) => Promise<AuthResult>;
|
|
22
|
+
sendPhoneCode: (phoneNumber: string, recaptchaVerifier: any) => Promise<any>;
|
|
23
|
+
verifyPhoneCode: (verificationCode: string, verificationId: string) => Promise<any>;
|
|
24
|
+
logout: () => Promise<void>;
|
|
25
|
+
isAuthenticated: () => boolean;
|
|
26
|
+
getCurrentUser: () => import("@firebase/auth").User | null;
|
|
27
|
+
getUserClaims: () => import("@xbg.solutions/bpsk-core").FirebaseUserClaims | null;
|
|
28
|
+
userHasRole: (role: string) => boolean;
|
|
29
|
+
userHasAnyRole: (roles: string[]) => boolean;
|
|
30
|
+
destroy: () => void;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Create a singleton instance of the auth service
|
|
34
|
+
*/
|
|
35
|
+
export declare const authService: {
|
|
36
|
+
initialize: () => Promise<void>;
|
|
37
|
+
sendEmailLink: (email: string, options?: {}) => Promise<AuthResult>;
|
|
38
|
+
verifyEmailLink: (options?: EmailLinkVerifyOptions) => Promise<AuthResult>;
|
|
39
|
+
sendPhoneCode: (phoneNumber: string, recaptchaVerifier: any) => Promise<any>;
|
|
40
|
+
verifyPhoneCode: (verificationCode: string, verificationId: string) => Promise<any>;
|
|
41
|
+
logout: () => Promise<void>;
|
|
42
|
+
isAuthenticated: () => boolean;
|
|
43
|
+
getCurrentUser: () => import("@firebase/auth").User | null;
|
|
44
|
+
getUserClaims: () => import("@xbg.solutions/bpsk-core").FirebaseUserClaims | null;
|
|
45
|
+
userHasRole: (role: string) => boolean;
|
|
46
|
+
userHasAnyRole: (roles: string[]) => boolean;
|
|
47
|
+
destroy: () => void;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Safe version of sending email link with error handling
|
|
51
|
+
*/
|
|
52
|
+
export declare const safeSendEmailLink: (email: string, options?: any) => Promise<{
|
|
53
|
+
success: boolean;
|
|
54
|
+
data?: AuthResult | undefined;
|
|
55
|
+
error?: AppError;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Safe version of verifying email link with error handling
|
|
59
|
+
*/
|
|
60
|
+
export declare const safeVerifyEmailLink: (options?: EmailLinkVerifyOptions | undefined) => Promise<{
|
|
61
|
+
success: boolean;
|
|
62
|
+
data?: AuthResult | undefined;
|
|
63
|
+
error?: AppError;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Safe version of sending phone code with error handling
|
|
67
|
+
*/
|
|
68
|
+
export declare const safeSendPhoneCode: (phoneNumber: string, recaptchaVerifier: any) => Promise<{
|
|
69
|
+
success: boolean;
|
|
70
|
+
data?: any;
|
|
71
|
+
error?: AppError;
|
|
72
|
+
}>;
|
|
73
|
+
/**
|
|
74
|
+
* Safe version of verifying phone code with error handling
|
|
75
|
+
*/
|
|
76
|
+
export declare const safeVerifyPhoneCode: (verificationCode: string, verificationId: string) => Promise<{
|
|
77
|
+
success: boolean;
|
|
78
|
+
data?: any;
|
|
79
|
+
error?: AppError;
|
|
80
|
+
}>;
|
|
81
|
+
/**
|
|
82
|
+
* Safe version of logout with error handling
|
|
83
|
+
*/
|
|
84
|
+
export declare const safeLogout: () => Promise<{
|
|
85
|
+
success: boolean;
|
|
86
|
+
data?: void | undefined;
|
|
87
|
+
error?: AppError;
|
|
88
|
+
}>;
|
|
89
|
+
//# sourceMappingURL=auth.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.service.d.ts","sourceRoot":"","sources":["../../../src/services/auth/auth.service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAaH,OAAO,EAAE,QAAQ,EAAqC,MAAM,0BAA0B,CAAC;AAWvF,OAAO,KAAK,EAAoB,sBAAsB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAKrG;;;GAGG;AACH,wBAAgB,iBAAiB;sBAWF,OAAO,CAAC,IAAI,CAAC;2BAgUN,MAAM,mBAAiB,OAAO,CAAC,UAAU,CAAC;gCA2BtC,sBAAsB,KAAQ,OAAO,CAAC,UAAU,CAAC;iCA8F/C,MAAM,qBAAqB,GAAG,KAAG,OAAO,CAAC,GAAG,CAAC;wCA2BtC,MAAM,kBAAkB,MAAM,KAAG,OAAO,CAAC,GAAG,CAAC;kBAoCrE,OAAO,CAAC,IAAI,CAAC;2BAqEV,OAAO;;;wBAyBR,MAAM,KAAG,OAAO;4BAcZ,MAAM,EAAE,KAAG,OAAO;mBAQ7B,IAAI;EA4BzB;AAED;;GAEG;AACH,eAAO,MAAM,WAAW;sBA7oBO,OAAO,CAAC,IAAI,CAAC;2BAgUN,MAAM,mBAAiB,OAAO,CAAC,UAAU,CAAC;gCA2BtC,sBAAsB,KAAQ,OAAO,CAAC,UAAU,CAAC;iCA8F/C,MAAM,qBAAqB,GAAG,KAAG,OAAO,CAAC,GAAG,CAAC;wCA2BtC,MAAM,kBAAkB,MAAM,KAAG,OAAO,CAAC,GAAG,CAAC;kBAoCrE,OAAO,CAAC,IAAI,CAAC;2BAqEV,OAAO;;;wBAyBR,MAAM,KAAG,OAAO;4BAcZ,MAAM,EAAE,KAAG,OAAO;mBAQ7B,IAAI;CAiCoB,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;EAE7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;EAE/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;EAG7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;EAG/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU;;;;EAEtB,CAAC"}
|