edmaxlabs-core 2.7.3 → 2.9.4
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/index.cjs +440 -370
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +96 -19
- package/dist/index.d.ts +96 -19
- package/dist/index.mjs +440 -370
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -34,6 +34,34 @@ declare class Timestamp implements TimestampData {
|
|
|
34
34
|
toString(): string;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Credentials.ts
|
|
39
|
+
*
|
|
40
|
+
* What changed and why:
|
|
41
|
+
*
|
|
42
|
+
* ✗ fromMap() assumed data always lived under map.data.displayInfo
|
|
43
|
+
* → The new server response is a flat safeUser object:
|
|
44
|
+
* { uid, email, displayName, photoUrl, provider, verified, disabled,
|
|
45
|
+
* createdAt, lastLogin }
|
|
46
|
+
* fromMap() now detects which shape it's dealing with and handles both,
|
|
47
|
+
* so existing persisted sessions (old nested shape in localStorage) still
|
|
48
|
+
* deserialise correctly without forcing every user to log in again.
|
|
49
|
+
*
|
|
50
|
+
* ✗ DisplayInfo was built from nested data.displayInfo only
|
|
51
|
+
* → Now also built from the flat fields (email, displayName split into
|
|
52
|
+
* firstname/lastname, photoUrl → profile) when the nested shape is absent.
|
|
53
|
+
*
|
|
54
|
+
* ✗ uid resolution: map.id ?? map.uid ?? map._id
|
|
55
|
+
* → Server now always sends uid. The fallback chain is kept for backwards
|
|
56
|
+
* compatibility with any localStorage sessions that still have _id.
|
|
57
|
+
*
|
|
58
|
+
* ✓ toMap() unchanged — still produces the nested shape used by localStorage
|
|
59
|
+
* and the authState snapshot listener, so session restore keeps working.
|
|
60
|
+
*
|
|
61
|
+
* + provider and disabled fields added — the server now returns them and
|
|
62
|
+
* they're useful for conditional UI (e.g. show "disabled" badge, show
|
|
63
|
+
* provider icon).
|
|
64
|
+
*/
|
|
37
65
|
interface DisplayInfo {
|
|
38
66
|
firstname: string;
|
|
39
67
|
lastname: string;
|
|
@@ -47,46 +75,94 @@ declare class Credentials {
|
|
|
47
75
|
displayInfo: DisplayInfo;
|
|
48
76
|
data: Record<string, any>;
|
|
49
77
|
verified: boolean;
|
|
78
|
+
disabled: boolean;
|
|
79
|
+
provider: string;
|
|
50
80
|
createdAt: Timestamp;
|
|
51
81
|
updatedAt: Timestamp;
|
|
82
|
+
lastLogin: Timestamp | null;
|
|
52
83
|
private constructor();
|
|
53
84
|
static fromMap(map: Record<string, any>): Credentials;
|
|
54
85
|
toMap(): Record<string, any>;
|
|
86
|
+
get email(): string;
|
|
87
|
+
get firstname(): string;
|
|
88
|
+
get lastname(): string;
|
|
89
|
+
get displayName(): string;
|
|
90
|
+
get photoUrl(): string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare enum HttpMethod {
|
|
94
|
+
GET = "GET",
|
|
95
|
+
POST = "POST",
|
|
96
|
+
PUT = "PUT",
|
|
97
|
+
DELETE = "DELETE"
|
|
55
98
|
}
|
|
56
99
|
|
|
57
100
|
type Listener<T = any> = (value: T) => void;
|
|
58
101
|
declare class Authentication {
|
|
59
102
|
static instance: Authentication | null;
|
|
60
|
-
private
|
|
61
|
-
private
|
|
62
|
-
private
|
|
103
|
+
private app;
|
|
104
|
+
private accessToken;
|
|
105
|
+
private eUser;
|
|
106
|
+
private isRefreshing;
|
|
107
|
+
private refreshQueue;
|
|
63
108
|
private eventListeners;
|
|
64
|
-
private eventWaiters;
|
|
65
|
-
private unsubscribers;
|
|
66
109
|
constructor();
|
|
67
|
-
private isSameCredentials;
|
|
68
|
-
private restoreSession;
|
|
69
110
|
static getInstance(): Authentication;
|
|
70
|
-
|
|
71
|
-
|
|
111
|
+
private buildProjectHeaders;
|
|
112
|
+
private buildUserHeaders;
|
|
113
|
+
/** Exposed so database/RequestHeaders.ts can read current headers */
|
|
114
|
+
getHeaders(): Record<string, string>;
|
|
115
|
+
getUserToken(): string;
|
|
116
|
+
/** Synchronous. Reads only from localStorage — no network call. */
|
|
117
|
+
private _restoreSession;
|
|
118
|
+
/**
|
|
119
|
+
* Persist the user shape and update the in-memory access token.
|
|
120
|
+
* Pass credentials=null to fully clear the session (sign out).
|
|
121
|
+
*/
|
|
122
|
+
private _saveSession;
|
|
123
|
+
/**
|
|
124
|
+
* Returns the locally cached user — no network call.
|
|
125
|
+
* Returns null if nobody is signed in.
|
|
126
|
+
*/
|
|
72
127
|
currentUser(): Credentials | null;
|
|
73
|
-
private
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
128
|
+
private _refreshAccessToken;
|
|
129
|
+
private _drainQueue;
|
|
130
|
+
/**
|
|
131
|
+
* Central request method — all auth HTTP calls go through here.
|
|
132
|
+
* Handles the access-token-expired → refresh → retry cycle automatically.
|
|
133
|
+
*/
|
|
134
|
+
makeRequest(options: {
|
|
135
|
+
method: HttpMethod;
|
|
136
|
+
endpoint: string;
|
|
137
|
+
headers?: Record<string, string>;
|
|
138
|
+
body?: Record<string, any>;
|
|
139
|
+
file?: File;
|
|
140
|
+
isRetry?: boolean;
|
|
141
|
+
isMultipart?: boolean;
|
|
142
|
+
}): Promise<any>;
|
|
143
|
+
createUserWithEmailAndPassword: (data: {
|
|
144
|
+
firstname: string;
|
|
145
|
+
lastname?: string;
|
|
80
146
|
email: string;
|
|
81
147
|
password: string;
|
|
82
148
|
}) => Promise<Credentials | null>;
|
|
83
|
-
signInWithEmailAndPassword: ({ email, password
|
|
149
|
+
signInWithEmailAndPassword: ({ email, password }: {
|
|
84
150
|
email: string;
|
|
85
151
|
password: string;
|
|
86
152
|
}) => Promise<Credentials | null>;
|
|
87
|
-
deleteUser: () => Promise<void>;
|
|
88
|
-
resetPassword: () => Promise<any>;
|
|
89
153
|
signOut: () => Promise<void>;
|
|
154
|
+
deleteUser: () => Promise<void>;
|
|
155
|
+
resetPassword: ({ email }: {
|
|
156
|
+
email: string;
|
|
157
|
+
}) => Promise<void>;
|
|
158
|
+
authState({ onChange, onSignOut, onDeleted, }: {
|
|
159
|
+
onChange: (user: Credentials | null) => void;
|
|
160
|
+
onSignOut?: () => void;
|
|
161
|
+
onDeleted?: () => void;
|
|
162
|
+
}): () => void;
|
|
163
|
+
private _emit;
|
|
164
|
+
onValue<T>(key: string, callback: Listener<T>): () => void;
|
|
165
|
+
dispose(): void;
|
|
90
166
|
}
|
|
91
167
|
|
|
92
168
|
declare class DocumentSnapshot {
|
|
@@ -381,6 +457,7 @@ declare class RealtimeBridge {
|
|
|
381
457
|
|
|
382
458
|
declare class SyncEngine {
|
|
383
459
|
private app;
|
|
460
|
+
private authentication;
|
|
384
461
|
private persistence;
|
|
385
462
|
private store;
|
|
386
463
|
private realtimeBridge;
|
package/dist/index.d.ts
CHANGED
|
@@ -34,6 +34,34 @@ declare class Timestamp implements TimestampData {
|
|
|
34
34
|
toString(): string;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Credentials.ts
|
|
39
|
+
*
|
|
40
|
+
* What changed and why:
|
|
41
|
+
*
|
|
42
|
+
* ✗ fromMap() assumed data always lived under map.data.displayInfo
|
|
43
|
+
* → The new server response is a flat safeUser object:
|
|
44
|
+
* { uid, email, displayName, photoUrl, provider, verified, disabled,
|
|
45
|
+
* createdAt, lastLogin }
|
|
46
|
+
* fromMap() now detects which shape it's dealing with and handles both,
|
|
47
|
+
* so existing persisted sessions (old nested shape in localStorage) still
|
|
48
|
+
* deserialise correctly without forcing every user to log in again.
|
|
49
|
+
*
|
|
50
|
+
* ✗ DisplayInfo was built from nested data.displayInfo only
|
|
51
|
+
* → Now also built from the flat fields (email, displayName split into
|
|
52
|
+
* firstname/lastname, photoUrl → profile) when the nested shape is absent.
|
|
53
|
+
*
|
|
54
|
+
* ✗ uid resolution: map.id ?? map.uid ?? map._id
|
|
55
|
+
* → Server now always sends uid. The fallback chain is kept for backwards
|
|
56
|
+
* compatibility with any localStorage sessions that still have _id.
|
|
57
|
+
*
|
|
58
|
+
* ✓ toMap() unchanged — still produces the nested shape used by localStorage
|
|
59
|
+
* and the authState snapshot listener, so session restore keeps working.
|
|
60
|
+
*
|
|
61
|
+
* + provider and disabled fields added — the server now returns them and
|
|
62
|
+
* they're useful for conditional UI (e.g. show "disabled" badge, show
|
|
63
|
+
* provider icon).
|
|
64
|
+
*/
|
|
37
65
|
interface DisplayInfo {
|
|
38
66
|
firstname: string;
|
|
39
67
|
lastname: string;
|
|
@@ -47,46 +75,94 @@ declare class Credentials {
|
|
|
47
75
|
displayInfo: DisplayInfo;
|
|
48
76
|
data: Record<string, any>;
|
|
49
77
|
verified: boolean;
|
|
78
|
+
disabled: boolean;
|
|
79
|
+
provider: string;
|
|
50
80
|
createdAt: Timestamp;
|
|
51
81
|
updatedAt: Timestamp;
|
|
82
|
+
lastLogin: Timestamp | null;
|
|
52
83
|
private constructor();
|
|
53
84
|
static fromMap(map: Record<string, any>): Credentials;
|
|
54
85
|
toMap(): Record<string, any>;
|
|
86
|
+
get email(): string;
|
|
87
|
+
get firstname(): string;
|
|
88
|
+
get lastname(): string;
|
|
89
|
+
get displayName(): string;
|
|
90
|
+
get photoUrl(): string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare enum HttpMethod {
|
|
94
|
+
GET = "GET",
|
|
95
|
+
POST = "POST",
|
|
96
|
+
PUT = "PUT",
|
|
97
|
+
DELETE = "DELETE"
|
|
55
98
|
}
|
|
56
99
|
|
|
57
100
|
type Listener<T = any> = (value: T) => void;
|
|
58
101
|
declare class Authentication {
|
|
59
102
|
static instance: Authentication | null;
|
|
60
|
-
private
|
|
61
|
-
private
|
|
62
|
-
private
|
|
103
|
+
private app;
|
|
104
|
+
private accessToken;
|
|
105
|
+
private eUser;
|
|
106
|
+
private isRefreshing;
|
|
107
|
+
private refreshQueue;
|
|
63
108
|
private eventListeners;
|
|
64
|
-
private eventWaiters;
|
|
65
|
-
private unsubscribers;
|
|
66
109
|
constructor();
|
|
67
|
-
private isSameCredentials;
|
|
68
|
-
private restoreSession;
|
|
69
110
|
static getInstance(): Authentication;
|
|
70
|
-
|
|
71
|
-
|
|
111
|
+
private buildProjectHeaders;
|
|
112
|
+
private buildUserHeaders;
|
|
113
|
+
/** Exposed so database/RequestHeaders.ts can read current headers */
|
|
114
|
+
getHeaders(): Record<string, string>;
|
|
115
|
+
getUserToken(): string;
|
|
116
|
+
/** Synchronous. Reads only from localStorage — no network call. */
|
|
117
|
+
private _restoreSession;
|
|
118
|
+
/**
|
|
119
|
+
* Persist the user shape and update the in-memory access token.
|
|
120
|
+
* Pass credentials=null to fully clear the session (sign out).
|
|
121
|
+
*/
|
|
122
|
+
private _saveSession;
|
|
123
|
+
/**
|
|
124
|
+
* Returns the locally cached user — no network call.
|
|
125
|
+
* Returns null if nobody is signed in.
|
|
126
|
+
*/
|
|
72
127
|
currentUser(): Credentials | null;
|
|
73
|
-
private
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
128
|
+
private _refreshAccessToken;
|
|
129
|
+
private _drainQueue;
|
|
130
|
+
/**
|
|
131
|
+
* Central request method — all auth HTTP calls go through here.
|
|
132
|
+
* Handles the access-token-expired → refresh → retry cycle automatically.
|
|
133
|
+
*/
|
|
134
|
+
makeRequest(options: {
|
|
135
|
+
method: HttpMethod;
|
|
136
|
+
endpoint: string;
|
|
137
|
+
headers?: Record<string, string>;
|
|
138
|
+
body?: Record<string, any>;
|
|
139
|
+
file?: File;
|
|
140
|
+
isRetry?: boolean;
|
|
141
|
+
isMultipart?: boolean;
|
|
142
|
+
}): Promise<any>;
|
|
143
|
+
createUserWithEmailAndPassword: (data: {
|
|
144
|
+
firstname: string;
|
|
145
|
+
lastname?: string;
|
|
80
146
|
email: string;
|
|
81
147
|
password: string;
|
|
82
148
|
}) => Promise<Credentials | null>;
|
|
83
|
-
signInWithEmailAndPassword: ({ email, password
|
|
149
|
+
signInWithEmailAndPassword: ({ email, password }: {
|
|
84
150
|
email: string;
|
|
85
151
|
password: string;
|
|
86
152
|
}) => Promise<Credentials | null>;
|
|
87
|
-
deleteUser: () => Promise<void>;
|
|
88
|
-
resetPassword: () => Promise<any>;
|
|
89
153
|
signOut: () => Promise<void>;
|
|
154
|
+
deleteUser: () => Promise<void>;
|
|
155
|
+
resetPassword: ({ email }: {
|
|
156
|
+
email: string;
|
|
157
|
+
}) => Promise<void>;
|
|
158
|
+
authState({ onChange, onSignOut, onDeleted, }: {
|
|
159
|
+
onChange: (user: Credentials | null) => void;
|
|
160
|
+
onSignOut?: () => void;
|
|
161
|
+
onDeleted?: () => void;
|
|
162
|
+
}): () => void;
|
|
163
|
+
private _emit;
|
|
164
|
+
onValue<T>(key: string, callback: Listener<T>): () => void;
|
|
165
|
+
dispose(): void;
|
|
90
166
|
}
|
|
91
167
|
|
|
92
168
|
declare class DocumentSnapshot {
|
|
@@ -381,6 +457,7 @@ declare class RealtimeBridge {
|
|
|
381
457
|
|
|
382
458
|
declare class SyncEngine {
|
|
383
459
|
private app;
|
|
460
|
+
private authentication;
|
|
384
461
|
private persistence;
|
|
385
462
|
private store;
|
|
386
463
|
private realtimeBridge;
|