cloudfire-auth 0.2.0 → 0.3.1
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/README.md +50 -16
- package/dist/CloudFireAuth.d.ts +304 -1
- package/dist/CloudFireAuth.js +345 -0
- package/dist/rest-api/create-custom-token.d.ts +18 -0
- package/dist/rest-api/create-custom-token.js +20 -0
- package/dist/rest-api/create-provider-config.d.ts +16 -0
- package/dist/rest-api/create-provider-config.js +17 -0
- package/dist/rest-api/create-session-cookie.d.ts +18 -0
- package/dist/rest-api/create-session-cookie.js +19 -0
- package/dist/rest-api/delete-provider-config.d.ts +16 -0
- package/dist/rest-api/delete-provider-config.js +18 -0
- package/dist/rest-api/generate-email-verification-link.d.ts +18 -0
- package/dist/rest-api/generate-email-verification-link.js +19 -0
- package/dist/rest-api/generate-password-reset-link.d.ts +18 -0
- package/dist/rest-api/generate-password-reset-link.js +19 -0
- package/dist/rest-api/generate-sign-in-with-email-link.d.ts +18 -0
- package/dist/rest-api/generate-sign-in-with-email-link.js +19 -0
- package/dist/rest-api/generate-verify-and-change-email-link.d.ts +20 -0
- package/dist/rest-api/generate-verify-and-change-email-link.js +21 -0
- package/dist/rest-api/get-provider-config.d.ts +17 -0
- package/dist/rest-api/get-provider-config.js +18 -0
- package/dist/rest-api/import-users.d.ts +18 -0
- package/dist/rest-api/import-users.js +19 -0
- package/dist/rest-api/list-provider-configs.d.ts +17 -0
- package/dist/rest-api/list-provider-configs.js +18 -0
- package/dist/rest-api/update-provider-config.d.ts +18 -0
- package/dist/rest-api/update-provider-config.js +19 -0
- package/dist/types/firebase-admin/action-code-settings.d.ts +102 -0
- package/dist/types/firebase-admin/action-code-settings.js +17 -0
- package/dist/types/firebase-admin/auth-config.d.ts +39 -33
- package/dist/types/firebase-admin/auth-config.js +16 -0
- package/dist/types/firebase-admin/identifier.d.ts +6 -0
- package/dist/types/firebase-admin/identifier.js +16 -0
- package/dist/types/firebase-admin/index.d.ts +11 -2
- package/dist/types/firebase-admin/index.js +16 -0
- package/dist/types/firebase-admin/token-verifier.d.ts +6 -0
- package/dist/types/firebase-admin/token-verifier.js +16 -0
- package/dist/types/firebase-admin/user-import.d.ts +226 -0
- package/dist/types/firebase-admin/user-import.js +17 -0
- package/dist/types/firebase-admin/user-record.d.ts +6 -0
- package/dist/types/firebase-admin/user-record.js +17 -0
- package/dist/types.d.ts +2 -2
- package/package.json +2 -2
package/dist/CloudFireAuth.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
// Rest API
|
|
18
|
+
import { createCustomTokenHandler } from "./rest-api/create-custom-token.js";
|
|
18
19
|
import { verifyIdTokenHandler } from "./rest-api/verify-id-token.js";
|
|
19
20
|
import { getUserHandler } from "./rest-api/get-user.js";
|
|
20
21
|
import { getUserByEmailHandler } from "./rest-api/get-user-by-email.js";
|
|
@@ -29,6 +30,17 @@ import { updateUserHandler } from "./rest-api/update-user.js";
|
|
|
29
30
|
import { setCustomUserClaimsHandler } from "./rest-api/set-custom-user-claims.js";
|
|
30
31
|
import { revokeRefreshTokensHandler } from "./rest-api/revoke-refresh-tokens.js";
|
|
31
32
|
import { verifySessionCookieHandler } from "./rest-api/verify-session-cookie.js";
|
|
33
|
+
import { importUsersHandler } from "./rest-api/import-users.js";
|
|
34
|
+
import { createSessionCookieHandler } from "./rest-api/create-session-cookie.js";
|
|
35
|
+
import { generatePasswordResetLinkHandler } from "./rest-api/generate-password-reset-link.js";
|
|
36
|
+
import { generateEmailVerificationLinkHandler } from "./rest-api/generate-email-verification-link.js";
|
|
37
|
+
import { generateVerifyAndChangeEmailLinkHandler } from "./rest-api/generate-verify-and-change-email-link.js";
|
|
38
|
+
import { generateSignInWithEmailLinkHandler } from "./rest-api/generate-sign-in-with-email-link.js";
|
|
39
|
+
import { listProviderConfigsHandler } from "./rest-api/list-provider-configs.js";
|
|
40
|
+
import { getProviderConfigHandler } from "./rest-api/get-provider-config.js";
|
|
41
|
+
import { deleteProviderConfigHandler } from "./rest-api/delete-provider-config.js";
|
|
42
|
+
import { updateProviderConfigHandler } from "./rest-api/update-provider-config.js";
|
|
43
|
+
import { createProviderConfigHandler } from "./rest-api/create-provider-config.js";
|
|
32
44
|
// Google Auth
|
|
33
45
|
import { getOauth2AccessTokenHandler } from "./google-auth/get-oauth-2-token.js";
|
|
34
46
|
export class CloudFireAuth {
|
|
@@ -41,6 +53,26 @@ export class CloudFireAuth {
|
|
|
41
53
|
this.serviceAccountKey = serviceAccountKey;
|
|
42
54
|
this.kvNamespace = kvNamespace;
|
|
43
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Creates a new Firebase custom token (JWT) that can be sent back to a client
|
|
58
|
+
* device to use to sign in with the client SDKs' `signInWithCustomToken()`
|
|
59
|
+
* methods. (Tenant-aware instances will also embed the tenant ID in the
|
|
60
|
+
* token.)
|
|
61
|
+
*
|
|
62
|
+
* See {@link https://firebase.google.com/docs/auth/admin/create-custom-tokens | Create Custom Tokens}
|
|
63
|
+
* for code samples and detailed documentation.
|
|
64
|
+
*
|
|
65
|
+
* @param uid - The `uid` to use as the custom token's subject.
|
|
66
|
+
* @param developerClaims - Optional additional claims to include
|
|
67
|
+
* in the custom token's payload.
|
|
68
|
+
*
|
|
69
|
+
* @returns A promise fulfilled with a custom token for the
|
|
70
|
+
* provided `uid` and payload.
|
|
71
|
+
*/
|
|
72
|
+
async createCustomToken(uid, developerClaims) {
|
|
73
|
+
const oauth2Token = await this.getOauth2AccessToken();
|
|
74
|
+
return await createCustomTokenHandler(uid, developerClaims, oauth2Token);
|
|
75
|
+
}
|
|
44
76
|
/**
|
|
45
77
|
* Verifies a Firebase ID token (JWT). If the token is valid, the promise is
|
|
46
78
|
* fulfilled with the token's decoded claims; otherwise, the promise is
|
|
@@ -289,6 +321,48 @@ export class CloudFireAuth {
|
|
|
289
321
|
const oauth2Token = await this.getOauth2AccessToken();
|
|
290
322
|
return await revokeRefreshTokensHandler(uid, oauth2Token);
|
|
291
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Imports the provided list of users into Firebase Auth.
|
|
326
|
+
* A maximum of 1000 users are allowed to be imported one at a time.
|
|
327
|
+
* When importing users with passwords,
|
|
328
|
+
* {@link UserImportOptions} are required to be
|
|
329
|
+
* specified.
|
|
330
|
+
* This operation is optimized for bulk imports and will ignore checks on `uid`,
|
|
331
|
+
* `email` and other identifier uniqueness which could result in duplications.
|
|
332
|
+
*
|
|
333
|
+
* @param users - The list of user records to import to Firebase Auth.
|
|
334
|
+
* @param options - The user import options, required when the users provided include
|
|
335
|
+
* password credentials.
|
|
336
|
+
* @returns A promise that resolves when
|
|
337
|
+
* the operation completes with the result of the import. This includes the
|
|
338
|
+
* number of successful imports, the number of failed imports and their
|
|
339
|
+
* corresponding errors.
|
|
340
|
+
*/
|
|
341
|
+
async importUsers(users, options) {
|
|
342
|
+
const oauth2Token = await this.getOauth2AccessToken();
|
|
343
|
+
return await importUsersHandler(users, options, oauth2Token);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Creates a new Firebase session cookie with the specified options. The created
|
|
347
|
+
* JWT string can be set as a server-side session cookie with a custom cookie
|
|
348
|
+
* policy, and be used for session management. The session cookie JWT will have
|
|
349
|
+
* the same payload claims as the provided ID token.
|
|
350
|
+
*
|
|
351
|
+
* See {@link https://firebase.google.com/docs/auth/admin/manage-cookies | Manage Session Cookies}
|
|
352
|
+
* for code samples and detailed documentation.
|
|
353
|
+
*
|
|
354
|
+
* @param idToken - The Firebase ID token to exchange for a session
|
|
355
|
+
* cookie.
|
|
356
|
+
* @param sessionCookieOptions - The session
|
|
357
|
+
* cookie options which includes custom session duration.
|
|
358
|
+
*
|
|
359
|
+
* @returns A promise that resolves on success with the
|
|
360
|
+
* created session cookie.
|
|
361
|
+
*/
|
|
362
|
+
async createSessionCookie(idToken, sessionCookieOptions) {
|
|
363
|
+
const oauth2Token = await this.getOauth2AccessToken();
|
|
364
|
+
return await createSessionCookieHandler(idToken, sessionCookieOptions, oauth2Token);
|
|
365
|
+
}
|
|
292
366
|
/**
|
|
293
367
|
* Verifies a Firebase session cookie. Returns a Promise with the cookie claims.
|
|
294
368
|
* Rejects the promise if the cookie could not be verified.
|
|
@@ -317,6 +391,277 @@ export class CloudFireAuth {
|
|
|
317
391
|
async verifySessionCookie(sessionCookie, checkRevoked) {
|
|
318
392
|
return await verifySessionCookieHandler(sessionCookie, checkRevoked);
|
|
319
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* Generates the out of band email action link to reset a user's password.
|
|
396
|
+
* The link is generated for the user with the specified email address. The
|
|
397
|
+
* optional {@link ActionCodeSettings} object
|
|
398
|
+
* defines whether the link is to be handled by a mobile app or browser and the
|
|
399
|
+
* additional state information to be passed in the deep link, etc.
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* ```javascript
|
|
403
|
+
* var actionCodeSettings = {
|
|
404
|
+
* url: 'https://www.example.com/?email=user@example.com',
|
|
405
|
+
* iOS: {
|
|
406
|
+
* bundleId: 'com.example.ios'
|
|
407
|
+
* },
|
|
408
|
+
* android: {
|
|
409
|
+
* packageName: 'com.example.android',
|
|
410
|
+
* installApp: true,
|
|
411
|
+
* minimumVersion: '12'
|
|
412
|
+
* },
|
|
413
|
+
* handleCodeInApp: true,
|
|
414
|
+
* linkDomain: 'project-id.firebaseapp.com'
|
|
415
|
+
* };
|
|
416
|
+
* admin.auth()
|
|
417
|
+
* .generatePasswordResetLink('user@example.com', actionCodeSettings)
|
|
418
|
+
* .then(function(link) {
|
|
419
|
+
* // The link was successfully generated.
|
|
420
|
+
* })
|
|
421
|
+
* .catch(function(error) {
|
|
422
|
+
* // Some error occurred, you can inspect the code: error.code
|
|
423
|
+
* });
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* @param email - The email address of the user whose password is to be
|
|
427
|
+
* reset.
|
|
428
|
+
* @param actionCodeSettings - The action
|
|
429
|
+
* code settings. If specified, the state/continue URL is set as the
|
|
430
|
+
* "continueUrl" parameter in the password reset link. The default password
|
|
431
|
+
* reset landing page will use this to display a link to go back to the app
|
|
432
|
+
* if it is installed.
|
|
433
|
+
* If the actionCodeSettings is not specified, no URL is appended to the
|
|
434
|
+
* action URL.
|
|
435
|
+
* The state URL provided must belong to a domain that is whitelisted by the
|
|
436
|
+
* developer in the console. Otherwise an error is thrown.
|
|
437
|
+
* Mobile app redirects are only applicable if the developer configures
|
|
438
|
+
* and accepts the Firebase Dynamic Links terms of service.
|
|
439
|
+
* The Android package name and iOS bundle ID are respected only if they
|
|
440
|
+
* are configured in the same Firebase Auth project.
|
|
441
|
+
* @returns A promise that resolves with the generated link.
|
|
442
|
+
*/
|
|
443
|
+
async generatePasswordResetLink(email, actionCodeSettings) {
|
|
444
|
+
const oauth2Token = await this.getOauth2AccessToken();
|
|
445
|
+
return await generatePasswordResetLinkHandler(email, actionCodeSettings, oauth2Token);
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Generates the out of band email action link to verify the user's ownership
|
|
449
|
+
* of the specified email. The {@link ActionCodeSettings} object provided
|
|
450
|
+
* as an argument to this method defines whether the link is to be handled by a
|
|
451
|
+
* mobile app or browser along with additional state information to be passed in
|
|
452
|
+
* the deep link, etc.
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```javascript
|
|
456
|
+
* var actionCodeSettings = {
|
|
457
|
+
* url: 'https://www.example.com/cart?email=user@example.com&cartId=123',
|
|
458
|
+
* iOS: {
|
|
459
|
+
* bundleId: 'com.example.ios'
|
|
460
|
+
* },
|
|
461
|
+
* android: {
|
|
462
|
+
* packageName: 'com.example.android',
|
|
463
|
+
* installApp: true,
|
|
464
|
+
* minimumVersion: '12'
|
|
465
|
+
* },
|
|
466
|
+
* handleCodeInApp: true,
|
|
467
|
+
* linkDomain: 'project-id.firebaseapp.com'
|
|
468
|
+
* };
|
|
469
|
+
* admin.auth()
|
|
470
|
+
* .generateEmailVerificationLink('user@example.com', actionCodeSettings)
|
|
471
|
+
* .then(function(link) {
|
|
472
|
+
* // The link was successfully generated.
|
|
473
|
+
* })
|
|
474
|
+
* .catch(function(error) {
|
|
475
|
+
* // Some error occurred, you can inspect the code: error.code
|
|
476
|
+
* });
|
|
477
|
+
* ```
|
|
478
|
+
*
|
|
479
|
+
* @param email - The email account to verify.
|
|
480
|
+
* @param actionCodeSettings - The action
|
|
481
|
+
* code settings. If specified, the state/continue URL is set as the
|
|
482
|
+
* "continueUrl" parameter in the email verification link. The default email
|
|
483
|
+
* verification landing page will use this to display a link to go back to
|
|
484
|
+
* the app if it is installed.
|
|
485
|
+
* If the actionCodeSettings is not specified, no URL is appended to the
|
|
486
|
+
* action URL.
|
|
487
|
+
* The state URL provided must belong to a domain that is whitelisted by the
|
|
488
|
+
* developer in the console. Otherwise an error is thrown.
|
|
489
|
+
* Mobile app redirects are only applicable if the developer configures
|
|
490
|
+
* and accepts the Firebase Dynamic Links terms of service.
|
|
491
|
+
* The Android package name and iOS bundle ID are respected only if they
|
|
492
|
+
* are configured in the same Firebase Auth project.
|
|
493
|
+
* @returns A promise that resolves with the generated link.
|
|
494
|
+
*/
|
|
495
|
+
async generateEmailVerificationLink(email, actionCodeSettings) {
|
|
496
|
+
const oauth2Token = await this.getOauth2AccessToken();
|
|
497
|
+
return await generateEmailVerificationLinkHandler(email, actionCodeSettings, oauth2Token);
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Generates an out-of-band email action link to verify the user's ownership
|
|
501
|
+
* of the specified email. The {@link ActionCodeSettings} object provided
|
|
502
|
+
* as an argument to this method defines whether the link is to be handled by a
|
|
503
|
+
* mobile app or browser along with additional state information to be passed in
|
|
504
|
+
* the deep link, etc.
|
|
505
|
+
*
|
|
506
|
+
* @param email - The current email account.
|
|
507
|
+
* @param newEmail - The email address the account is being updated to.
|
|
508
|
+
* @param actionCodeSettings - The action
|
|
509
|
+
* code settings. If specified, the state/continue URL is set as the
|
|
510
|
+
* "continueUrl" parameter in the email verification link. The default email
|
|
511
|
+
* verification landing page will use this to display a link to go back to
|
|
512
|
+
* the app if it is installed.
|
|
513
|
+
* If the actionCodeSettings is not specified, no URL is appended to the
|
|
514
|
+
* action URL.
|
|
515
|
+
* The state URL provided must belong to a domain that is authorized
|
|
516
|
+
* in the console, or an error will be thrown.
|
|
517
|
+
* Mobile app redirects are only applicable if the developer configures
|
|
518
|
+
* and accepts the Firebase Dynamic Links terms of service.
|
|
519
|
+
* The Android package name and iOS bundle ID are respected only if they
|
|
520
|
+
* are configured in the same Firebase Auth project.
|
|
521
|
+
* @returns A promise that resolves with the generated link.
|
|
522
|
+
*/
|
|
523
|
+
async generateVerifyAndChangeEmailLink(email, newEmail, actionCodeSettings) {
|
|
524
|
+
const oauth2Token = await this.getOauth2AccessToken();
|
|
525
|
+
return await generateVerifyAndChangeEmailLinkHandler(email, newEmail, actionCodeSettings, oauth2Token);
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Generates the out of band email action link to verify the user's ownership
|
|
529
|
+
* of the specified email. The {@link ActionCodeSettings} object provided
|
|
530
|
+
* as an argument to this method defines whether the link is to be handled by a
|
|
531
|
+
* mobile app or browser along with additional state information to be passed in
|
|
532
|
+
* the deep link, etc.
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
* ```javascript
|
|
536
|
+
* var actionCodeSettings = {
|
|
537
|
+
* url: 'https://www.example.com/cart?email=user@example.com&cartId=123',
|
|
538
|
+
* iOS: {
|
|
539
|
+
* bundleId: 'com.example.ios'
|
|
540
|
+
* },
|
|
541
|
+
* android: {
|
|
542
|
+
* packageName: 'com.example.android',
|
|
543
|
+
* installApp: true,
|
|
544
|
+
* minimumVersion: '12'
|
|
545
|
+
* },
|
|
546
|
+
* handleCodeInApp: true,
|
|
547
|
+
* linkDomain: 'project-id.firebaseapp.com'
|
|
548
|
+
* };
|
|
549
|
+
* admin.auth()
|
|
550
|
+
* .generateEmailVerificationLink('user@example.com', actionCodeSettings)
|
|
551
|
+
* .then(function(link) {
|
|
552
|
+
* // The link was successfully generated.
|
|
553
|
+
* })
|
|
554
|
+
* .catch(function(error) {
|
|
555
|
+
* // Some error occurred, you can inspect the code: error.code
|
|
556
|
+
* });
|
|
557
|
+
* ```
|
|
558
|
+
*
|
|
559
|
+
* @param email - The email account to verify.
|
|
560
|
+
* @param actionCodeSettings - The action
|
|
561
|
+
* code settings. If specified, the state/continue URL is set as the
|
|
562
|
+
* "continueUrl" parameter in the email verification link. The default email
|
|
563
|
+
* verification landing page will use this to display a link to go back to
|
|
564
|
+
* the app if it is installed.
|
|
565
|
+
* If the actionCodeSettings is not specified, no URL is appended to the
|
|
566
|
+
* action URL.
|
|
567
|
+
* The state URL provided must belong to a domain that is whitelisted by the
|
|
568
|
+
* developer in the console. Otherwise an error is thrown.
|
|
569
|
+
* Mobile app redirects are only applicable if the developer configures
|
|
570
|
+
* and accepts the Firebase Dynamic Links terms of service.
|
|
571
|
+
* The Android package name and iOS bundle ID are respected only if they
|
|
572
|
+
* are configured in the same Firebase Auth project.
|
|
573
|
+
* @returns A promise that resolves with the generated link.
|
|
574
|
+
*/
|
|
575
|
+
async generateSignInWithEmailLink(email, actionCodeSettings) {
|
|
576
|
+
const oauth2Token = await this.getOauth2AccessToken();
|
|
577
|
+
return await generateSignInWithEmailLinkHandler(email, actionCodeSettings, oauth2Token);
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Returns the list of existing provider configurations matching the filter
|
|
581
|
+
* provided. At most, 100 provider configs can be listed at a time.
|
|
582
|
+
*
|
|
583
|
+
* SAML and OIDC provider support requires Google Cloud's Identity Platform
|
|
584
|
+
* (GCIP). To learn more about GCIP, including pricing and features,
|
|
585
|
+
* see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
|
|
586
|
+
*
|
|
587
|
+
* @param options - The provider config filter to apply.
|
|
588
|
+
* @returns A promise that resolves with the list of provider configs meeting the
|
|
589
|
+
* filter requirements.
|
|
590
|
+
*/
|
|
591
|
+
async listProviderConfigs(options) {
|
|
592
|
+
const oauth2Token = await this.getOauth2AccessToken();
|
|
593
|
+
return await listProviderConfigsHandler(options, oauth2Token);
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Looks up an Auth provider configuration by the provided ID.
|
|
597
|
+
* Returns a promise that resolves with the provider configuration
|
|
598
|
+
* corresponding to the provider ID specified. If the specified ID does not
|
|
599
|
+
* exist, an `auth/configuration-not-found` error is thrown.
|
|
600
|
+
*
|
|
601
|
+
* SAML and OIDC provider support requires Google Cloud's Identity Platform
|
|
602
|
+
* (GCIP). To learn more about GCIP, including pricing and features,
|
|
603
|
+
* see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
|
|
604
|
+
*
|
|
605
|
+
* @param providerId - The provider ID corresponding to the provider
|
|
606
|
+
* config to return.
|
|
607
|
+
* @returns A promise that resolves
|
|
608
|
+
* with the configuration corresponding to the provided ID.
|
|
609
|
+
*/
|
|
610
|
+
async getProviderConfig(providerId) {
|
|
611
|
+
const oauth2Token = await this.getOauth2AccessToken();
|
|
612
|
+
return await getProviderConfigHandler(providerId, oauth2Token);
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Deletes the provider configuration corresponding to the provider ID passed.
|
|
616
|
+
* If the specified ID does not exist, an `auth/configuration-not-found` error
|
|
617
|
+
* is thrown.
|
|
618
|
+
*
|
|
619
|
+
* SAML and OIDC provider support requires Google Cloud's Identity Platform
|
|
620
|
+
* (GCIP). To learn more about GCIP, including pricing and features,
|
|
621
|
+
* see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
|
|
622
|
+
*
|
|
623
|
+
* @param providerId - The provider ID corresponding to the provider
|
|
624
|
+
* config to delete.
|
|
625
|
+
* @returns A promise that resolves on completion.
|
|
626
|
+
*/
|
|
627
|
+
async deleteProviderConfig(providerId) {
|
|
628
|
+
const oauth2Token = await this.getOauth2AccessToken();
|
|
629
|
+
await deleteProviderConfigHandler(providerId, oauth2Token);
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Returns a promise that resolves with the updated `AuthProviderConfig`
|
|
633
|
+
* corresponding to the provider ID specified.
|
|
634
|
+
* If the specified ID does not exist, an `auth/configuration-not-found` error
|
|
635
|
+
* is thrown.
|
|
636
|
+
*
|
|
637
|
+
* SAML and OIDC provider support requires Google Cloud's Identity Platform
|
|
638
|
+
* (GCIP). To learn more about GCIP, including pricing and features,
|
|
639
|
+
* see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
|
|
640
|
+
*
|
|
641
|
+
* @param providerId - The provider ID corresponding to the provider
|
|
642
|
+
* config to update.
|
|
643
|
+
* @param updatedConfig - The updated configuration.
|
|
644
|
+
* @returns A promise that resolves with the updated provider configuration.
|
|
645
|
+
*/
|
|
646
|
+
async updateProviderConfig(providerId, updatedConfig) {
|
|
647
|
+
const oauth2Token = await this.getOauth2AccessToken();
|
|
648
|
+
return await updateProviderConfigHandler(providerId, updatedConfig, oauth2Token);
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* Returns a promise that resolves with the newly created `AuthProviderConfig`
|
|
652
|
+
* when the new provider configuration is created.
|
|
653
|
+
*
|
|
654
|
+
* SAML and OIDC provider support requires Google Cloud's Identity Platform
|
|
655
|
+
* (GCIP). To learn more about GCIP, including pricing and features,
|
|
656
|
+
* see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
|
|
657
|
+
*
|
|
658
|
+
* @param config - The provider configuration to create.
|
|
659
|
+
* @returns A promise that resolves with the created provider configuration.
|
|
660
|
+
*/
|
|
661
|
+
async createProviderConfig(config) {
|
|
662
|
+
const oauth2Token = await this.getOauth2AccessToken();
|
|
663
|
+
return await createProviderConfigHandler(config, oauth2Token);
|
|
664
|
+
}
|
|
320
665
|
/**
|
|
321
666
|
* Gets an OAuth2 access token from Google's OAuth2 server. This token is
|
|
322
667
|
* required for accessing the Firebase Auth REST API via fetch requests.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new Firebase custom token (JWT) for the specified user ID.
|
|
3
|
+
*
|
|
4
|
+
* This function creates a custom JWT that can be used with Firebase client SDKs
|
|
5
|
+
* to sign in users via the signInWithCustomToken() method. The token is signed
|
|
6
|
+
* with the service account's private key and includes optional developer claims.
|
|
7
|
+
*
|
|
8
|
+
* @param uid - The user ID to create the token for
|
|
9
|
+
* @param developerClaims - Optional additional claims to include in the token
|
|
10
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
11
|
+
* @returns Promise that resolves to the custom token string
|
|
12
|
+
*
|
|
13
|
+
* @throws {Error} Not yet implemented
|
|
14
|
+
*
|
|
15
|
+
* @package
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare function createCustomTokenHandler(uid: string, developerClaims: object | undefined, oauth2AccessToken: string): Promise<string>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new Firebase custom token (JWT) for the specified user ID.
|
|
3
|
+
*
|
|
4
|
+
* This function creates a custom JWT that can be used with Firebase client SDKs
|
|
5
|
+
* to sign in users via the signInWithCustomToken() method. The token is signed
|
|
6
|
+
* with the service account's private key and includes optional developer claims.
|
|
7
|
+
*
|
|
8
|
+
* @param uid - The user ID to create the token for
|
|
9
|
+
* @param developerClaims - Optional additional claims to include in the token
|
|
10
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
11
|
+
* @returns Promise that resolves to the custom token string
|
|
12
|
+
*
|
|
13
|
+
* @throws {Error} Not yet implemented
|
|
14
|
+
*
|
|
15
|
+
* @package
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export async function createCustomTokenHandler(uid, developerClaims, oauth2AccessToken) {
|
|
19
|
+
throw new Error("Not implemented");
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AuthProviderConfig } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new Auth provider configuration.
|
|
4
|
+
*
|
|
5
|
+
* Creates a new SAML or OIDC provider configuration with the specified settings.
|
|
6
|
+
*
|
|
7
|
+
* @param config - The provider configuration to create
|
|
8
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
9
|
+
* @returns Promise that resolves to the created provider configuration
|
|
10
|
+
*
|
|
11
|
+
* @throws {Error} Not yet implemented
|
|
12
|
+
*
|
|
13
|
+
* @package
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function createProviderConfigHandler(config: AuthProviderConfig, oauth2AccessToken: string): Promise<AuthProviderConfig>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new Auth provider configuration.
|
|
3
|
+
*
|
|
4
|
+
* Creates a new SAML or OIDC provider configuration with the specified settings.
|
|
5
|
+
*
|
|
6
|
+
* @param config - The provider configuration to create
|
|
7
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
8
|
+
* @returns Promise that resolves to the created provider configuration
|
|
9
|
+
*
|
|
10
|
+
* @throws {Error} Not yet implemented
|
|
11
|
+
*
|
|
12
|
+
* @package
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export async function createProviderConfigHandler(config, oauth2AccessToken) {
|
|
16
|
+
throw new Error("Not implemented");
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SessionCookieOptions } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new Firebase session cookie from an ID token.
|
|
4
|
+
*
|
|
5
|
+
* The session cookie can be used for server-side session management. It has the same
|
|
6
|
+
* payload claims as the provided ID token.
|
|
7
|
+
*
|
|
8
|
+
* @param idToken - The Firebase ID token to exchange for a session cookie
|
|
9
|
+
* @param sessionCookieOptions - Options including custom session duration
|
|
10
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
11
|
+
* @returns Promise that resolves to the session cookie string
|
|
12
|
+
*
|
|
13
|
+
* @throws {Error} Not yet implemented
|
|
14
|
+
*
|
|
15
|
+
* @package
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare function createSessionCookieHandler(idToken: string, sessionCookieOptions: SessionCookieOptions, oauth2AccessToken: string): Promise<string>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new Firebase session cookie from an ID token.
|
|
3
|
+
*
|
|
4
|
+
* The session cookie can be used for server-side session management. It has the same
|
|
5
|
+
* payload claims as the provided ID token.
|
|
6
|
+
*
|
|
7
|
+
* @param idToken - The Firebase ID token to exchange for a session cookie
|
|
8
|
+
* @param sessionCookieOptions - Options including custom session duration
|
|
9
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
10
|
+
* @returns Promise that resolves to the session cookie string
|
|
11
|
+
*
|
|
12
|
+
* @throws {Error} Not yet implemented
|
|
13
|
+
*
|
|
14
|
+
* @package
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export async function createSessionCookieHandler(idToken, sessionCookieOptions, oauth2AccessToken) {
|
|
18
|
+
throw new Error("Not implemented");
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deletes the provider configuration for the specified provider ID.
|
|
3
|
+
*
|
|
4
|
+
* Removes the provider configuration from Firebase Auth. Throws an error if
|
|
5
|
+
* the configuration does not exist.
|
|
6
|
+
*
|
|
7
|
+
* @param providerId - The provider ID corresponding to the provider config to delete
|
|
8
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
9
|
+
* @returns Promise that resolves when the operation completes
|
|
10
|
+
*
|
|
11
|
+
* @throws {Error} Not yet implemented
|
|
12
|
+
*
|
|
13
|
+
* @package
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export declare function deleteProviderConfigHandler(providerId: string, oauth2AccessToken: string): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deletes the provider configuration for the specified provider ID.
|
|
3
|
+
*
|
|
4
|
+
* Removes the provider configuration from Firebase Auth. Throws an error if
|
|
5
|
+
* the configuration does not exist.
|
|
6
|
+
*
|
|
7
|
+
* @param providerId - The provider ID corresponding to the provider config to delete
|
|
8
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
9
|
+
* @returns Promise that resolves when the operation completes
|
|
10
|
+
*
|
|
11
|
+
* @throws {Error} Not yet implemented
|
|
12
|
+
*
|
|
13
|
+
* @package
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export async function deleteProviderConfigHandler(providerId, oauth2AccessToken) {
|
|
17
|
+
throw new Error("Not implemented");
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ActionCodeSettings } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generates an out-of-band email action link to verify a user's email ownership.
|
|
4
|
+
*
|
|
5
|
+
* The link can be sent to users to verify their email address. The optional
|
|
6
|
+
* ActionCodeSettings object defines mobile app handling and additional state.
|
|
7
|
+
*
|
|
8
|
+
* @param email - The email account to verify
|
|
9
|
+
* @param actionCodeSettings - Optional action code settings
|
|
10
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
11
|
+
* @returns Promise that resolves to the generated link
|
|
12
|
+
*
|
|
13
|
+
* @throws {Error} Not yet implemented
|
|
14
|
+
*
|
|
15
|
+
* @package
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateEmailVerificationLinkHandler(email: string, actionCodeSettings: ActionCodeSettings | undefined, oauth2AccessToken: string): Promise<string>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an out-of-band email action link to verify a user's email ownership.
|
|
3
|
+
*
|
|
4
|
+
* The link can be sent to users to verify their email address. The optional
|
|
5
|
+
* ActionCodeSettings object defines mobile app handling and additional state.
|
|
6
|
+
*
|
|
7
|
+
* @param email - The email account to verify
|
|
8
|
+
* @param actionCodeSettings - Optional action code settings
|
|
9
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
10
|
+
* @returns Promise that resolves to the generated link
|
|
11
|
+
*
|
|
12
|
+
* @throws {Error} Not yet implemented
|
|
13
|
+
*
|
|
14
|
+
* @package
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export async function generateEmailVerificationLinkHandler(email, actionCodeSettings, oauth2AccessToken) {
|
|
18
|
+
throw new Error("Not implemented");
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ActionCodeSettings } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generates an out-of-band email action link to reset a user's password.
|
|
4
|
+
*
|
|
5
|
+
* The link can be sent to users to allow them to reset their password. The optional
|
|
6
|
+
* ActionCodeSettings object defines mobile app handling and additional state.
|
|
7
|
+
*
|
|
8
|
+
* @param email - The email address of the user whose password is to be reset
|
|
9
|
+
* @param actionCodeSettings - Optional action code settings
|
|
10
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
11
|
+
* @returns Promise that resolves to the generated link
|
|
12
|
+
*
|
|
13
|
+
* @throws {Error} Not yet implemented
|
|
14
|
+
*
|
|
15
|
+
* @package
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare function generatePasswordResetLinkHandler(email: string, actionCodeSettings: ActionCodeSettings | undefined, oauth2AccessToken: string): Promise<string>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates an out-of-band email action link to reset a user's password.
|
|
3
|
+
*
|
|
4
|
+
* The link can be sent to users to allow them to reset their password. The optional
|
|
5
|
+
* ActionCodeSettings object defines mobile app handling and additional state.
|
|
6
|
+
*
|
|
7
|
+
* @param email - The email address of the user whose password is to be reset
|
|
8
|
+
* @param actionCodeSettings - Optional action code settings
|
|
9
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
10
|
+
* @returns Promise that resolves to the generated link
|
|
11
|
+
*
|
|
12
|
+
* @throws {Error} Not yet implemented
|
|
13
|
+
*
|
|
14
|
+
* @package
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export async function generatePasswordResetLinkHandler(email, actionCodeSettings, oauth2AccessToken) {
|
|
18
|
+
throw new Error("Not implemented");
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ActionCodeSettings } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generates a sign-in with email link for the specified email address.
|
|
4
|
+
*
|
|
5
|
+
* This link allows users to sign in via email link without a password. The
|
|
6
|
+
* ActionCodeSettings object is required to specify where the link should redirect.
|
|
7
|
+
*
|
|
8
|
+
* @param email - The email account to generate the sign-in link for
|
|
9
|
+
* @param actionCodeSettings - Action code settings (required)
|
|
10
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
11
|
+
* @returns Promise that resolves to the generated link
|
|
12
|
+
*
|
|
13
|
+
* @throws {Error} Not yet implemented
|
|
14
|
+
*
|
|
15
|
+
* @package
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateSignInWithEmailLinkHandler(email: string, actionCodeSettings: ActionCodeSettings, oauth2AccessToken: string): Promise<string>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a sign-in with email link for the specified email address.
|
|
3
|
+
*
|
|
4
|
+
* This link allows users to sign in via email link without a password. The
|
|
5
|
+
* ActionCodeSettings object is required to specify where the link should redirect.
|
|
6
|
+
*
|
|
7
|
+
* @param email - The email account to generate the sign-in link for
|
|
8
|
+
* @param actionCodeSettings - Action code settings (required)
|
|
9
|
+
* @param oauth2AccessToken - OAuth2 access token for Firebase Admin API
|
|
10
|
+
* @returns Promise that resolves to the generated link
|
|
11
|
+
*
|
|
12
|
+
* @throws {Error} Not yet implemented
|
|
13
|
+
*
|
|
14
|
+
* @package
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export async function generateSignInWithEmailLinkHandler(email, actionCodeSettings, oauth2AccessToken) {
|
|
18
|
+
throw new Error("Not implemented");
|
|
19
|
+
}
|