@quatrain/auth-firebase 1.2.5 → 1.2.6
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.
|
@@ -74,4 +74,11 @@ export declare class FirebaseAuthAdapter extends AbstractAuthAdapter {
|
|
|
74
74
|
* @returns The generated token payload.
|
|
75
75
|
*/
|
|
76
76
|
refreshToken(refreshToken: string): Promise<any>;
|
|
77
|
+
/**
|
|
78
|
+
* Initiates password recovery/reset process for a user.
|
|
79
|
+
*
|
|
80
|
+
* @param email - The user email.
|
|
81
|
+
* @param redirectTo - Optional redirect destination.
|
|
82
|
+
*/
|
|
83
|
+
recoverPassword(email: string, redirectTo?: string): Promise<any>;
|
|
77
84
|
}
|
|
@@ -191,5 +191,42 @@ class FirebaseAuthAdapter extends auth_1.AbstractAuthAdapter {
|
|
|
191
191
|
return data;
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Initiates password recovery/reset process for a user.
|
|
196
|
+
*
|
|
197
|
+
* @param email - The user email.
|
|
198
|
+
* @param redirectTo - Optional redirect destination.
|
|
199
|
+
*/
|
|
200
|
+
recoverPassword(email, redirectTo) {
|
|
201
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
var _a;
|
|
203
|
+
if (!this._params.config || !this._params.config.apiKey) {
|
|
204
|
+
auth_1.Auth.warn(`Can't recover password, no API key provided in Firebase config`);
|
|
205
|
+
throw new Error('Firebase Auth API key is not configured');
|
|
206
|
+
}
|
|
207
|
+
const body = {
|
|
208
|
+
requestType: 'PASSWORD_RESET',
|
|
209
|
+
email,
|
|
210
|
+
};
|
|
211
|
+
if (redirectTo) {
|
|
212
|
+
body.actionCodeSettings = {
|
|
213
|
+
url: redirectTo,
|
|
214
|
+
handleCodeInApp: true,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
const response = yield nativeFetch.fetch(`https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${this._params.config.apiKey}`, {
|
|
218
|
+
method: 'POST',
|
|
219
|
+
body: JSON.stringify(body),
|
|
220
|
+
headers: { 'Content-Type': 'application/json' },
|
|
221
|
+
});
|
|
222
|
+
if (!response.ok) {
|
|
223
|
+
const errorData = yield response.json().catch(() => ({}));
|
|
224
|
+
const message = ((_a = errorData.error) === null || _a === void 0 ? void 0 : _a.message) || response.statusText;
|
|
225
|
+
throw new Error(message);
|
|
226
|
+
}
|
|
227
|
+
const data = yield response.json();
|
|
228
|
+
return data;
|
|
229
|
+
});
|
|
230
|
+
}
|
|
194
231
|
}
|
|
195
232
|
exports.FirebaseAuthAdapter = FirebaseAuthAdapter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quatrain/auth-firebase",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
},
|
|
20
20
|
"author": "Quatrain Développement SAS <developers@quatrain.com>",
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@quatrain/core": "^1.2.
|
|
22
|
+
"@quatrain/core": "^1.2.16"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@quatrain/api": "^1.1.
|
|
26
|
-
"@quatrain/auth": "^1.2.
|
|
27
|
-
"@quatrain/backend": "^1.2.
|
|
28
|
-
"@quatrain/core": "^1.2.
|
|
25
|
+
"@quatrain/api": "^1.1.6",
|
|
26
|
+
"@quatrain/auth": "^1.2.4",
|
|
27
|
+
"@quatrain/backend": "^1.2.13",
|
|
28
|
+
"@quatrain/core": "^1.2.16",
|
|
29
29
|
"firebase-admin": "^13.0.1",
|
|
30
30
|
"node-fetch-native": "^1.6.4"
|
|
31
31
|
},
|
|
@@ -159,4 +159,47 @@ export class FirebaseAuthAdapter extends AbstractAuthAdapter {
|
|
|
159
159
|
|
|
160
160
|
return data
|
|
161
161
|
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Initiates password recovery/reset process for a user.
|
|
165
|
+
*
|
|
166
|
+
* @param email - The user email.
|
|
167
|
+
* @param redirectTo - Optional redirect destination.
|
|
168
|
+
*/
|
|
169
|
+
async recoverPassword(email: string, redirectTo?: string): Promise<any> {
|
|
170
|
+
if (!this._params.config || !this._params.config.apiKey) {
|
|
171
|
+
Auth.warn(`Can't recover password, no API key provided in Firebase config`)
|
|
172
|
+
throw new Error('Firebase Auth API key is not configured')
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const body: any = {
|
|
176
|
+
requestType: 'PASSWORD_RESET',
|
|
177
|
+
email,
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (redirectTo) {
|
|
181
|
+
body.actionCodeSettings = {
|
|
182
|
+
url: redirectTo,
|
|
183
|
+
handleCodeInApp: true,
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const response = await nativeFetch.fetch(
|
|
188
|
+
`https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode?key=${this._params.config.apiKey}`,
|
|
189
|
+
{
|
|
190
|
+
method: 'POST',
|
|
191
|
+
body: JSON.stringify(body),
|
|
192
|
+
headers: { 'Content-Type': 'application/json' },
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
if (!response.ok) {
|
|
197
|
+
const errorData = await response.json().catch(() => ({}))
|
|
198
|
+
const message = errorData.error?.message || response.statusText
|
|
199
|
+
throw new Error(message)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const data = await response.json()
|
|
203
|
+
return data
|
|
204
|
+
}
|
|
162
205
|
}
|