strapi-plugin-firebase-authentication 1.2.0 → 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.
@@ -13,7 +13,7 @@ const require$$0$8 = require("constants");
13
13
  require("node:stream");
14
14
  const admin$1 = require("firebase-admin");
15
15
  const CryptoJS = require("crypto-js");
16
- const fs$6 = require("fs/promises");
16
+ const fs$8 = require("fs/promises");
17
17
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
18
18
  function _interopNamespace(e) {
19
19
  if (e && e.__esModule) return e;
@@ -45,7 +45,7 @@ const require$$2__default$1 = /* @__PURE__ */ _interopDefault(require$$2$1);
45
45
  const require$$0__default$6 = /* @__PURE__ */ _interopDefault(require$$0$8);
46
46
  const admin__default = /* @__PURE__ */ _interopDefault(admin$1);
47
47
  const CryptoJS__default = /* @__PURE__ */ _interopDefault(CryptoJS);
48
- const fs__namespace = /* @__PURE__ */ _interopNamespace(fs$6);
48
+ const fs__namespace = /* @__PURE__ */ _interopNamespace(fs$8);
49
49
  async function migrateFirebaseUserData(strapi2, dryRun = false) {
50
50
  strapi2.log.info("=== Firebase User Data Migration ===");
51
51
  strapi2.log.info(`Mode: ${dryRun ? "DRY RUN (no changes)" : "LIVE (will modify database)"}`);
@@ -401,293 +401,6 @@ const contentTypes = {
401
401
  "firebase-authentication-configuration": { schema: firebaseAuthenticationConfiguration },
402
402
  "firebase-user-data": { schema: firebaseUserData }
403
403
  };
404
- const pluginName = "firebase-authentication";
405
- const PLUGIN_NAME = "firebase-authentication";
406
- const PLUGIN_UID = `plugin::${PLUGIN_NAME}`;
407
- const CONFIG_CONTENT_TYPE = `${PLUGIN_UID}.firebase-authentication-configuration`;
408
- const DEFAULT_PASSWORD_RESET_URL = "http://localhost:3000/reset-password";
409
- const DEFAULT_PASSWORD_REGEX = "^.{6,}$";
410
- const DEFAULT_PASSWORD_MESSAGE = "Password must be at least 6 characters long";
411
- const DEFAULT_RESET_EMAIL_SUBJECT = "Reset Your Password";
412
- const ERROR_MESSAGES = {
413
- FIREBASE_NOT_INITIALIZED: "Firebase is not initialized. Please upload Firebase service account configuration via Settings → Firebase Authentication.",
414
- INVALID_JSON: "Invalid JSON format. Please ensure you copied the entire JSON content correctly.",
415
- MISSING_DATA: "data is missing",
416
- SOMETHING_WENT_WRONG: "Something went wrong",
417
- AUTHENTICATION_FAILED: "Authentication failed",
418
- TOKEN_MISSING: "idToken is missing!",
419
- EMAIL_PASSWORD_REQUIRED: "Email and password are required",
420
- PASSWORD_REQUIRED: "Password is required",
421
- AUTHORIZATION_REQUIRED: "Authorization token is required",
422
- INVALID_TOKEN: "Invalid or expired token",
423
- USER_NOT_FOUND: "User not found",
424
- USER_NO_EMAIL: "User does not have an email address",
425
- FIREBASE_LINK_FAILED: "Failed to generate Firebase reset link",
426
- CONFIG_NOT_FOUND: "No config found",
427
- INVALID_SERVICE_ACCOUNT: "Invalid service account JSON",
428
- WEB_API_NOT_CONFIGURED: "Email/password authentication is not available. Web API Key is not configured.",
429
- RESET_URL_NOT_CONFIGURED: "Password reset URL is not configured",
430
- RESET_URL_MUST_BE_HTTPS: "Password reset URL must use HTTPS in production",
431
- RESET_URL_INVALID_FORMAT: "Password reset URL is not a valid URL format",
432
- USER_NOT_LINKED_FIREBASE: "User is not linked to Firebase authentication",
433
- OVERRIDE_USER_ID_REQUIRED: "Override user ID is required",
434
- EITHER_EMAIL_OR_PHONE_REQUIRED: "Either email or phoneNumber is required",
435
- DELETION_NO_CONFIG: "No Firebase configs exists for deletion"
436
- };
437
- const SUCCESS_MESSAGES = {
438
- FIREBASE_INITIALIZED: "Firebase successfully initialized",
439
- FIREBASE_CONFIG_DELETED: "Firebase config deleted and reinitialized",
440
- PASSWORD_RESET_EMAIL_SENT: "If an account with that email exists, a password reset link has been sent.",
441
- SERVER_RESTARTING: "SERVER IS RESTARTING"
442
- };
443
- const CONFIG_KEYS = {
444
- ENCRYPTION_KEY: `${PLUGIN_UID}.FIREBASE_JSON_ENCRYPTION_KEY`
445
- };
446
- const REQUIRED_FIELDS = {
447
- SERVICE_ACCOUNT: ["private_key", "client_email", "project_id", "type"],
448
- WEB_CONFIG: ["apiKey", "authDomain"]
449
- // These indicate wrong JSON type
450
- };
451
- const VALIDATION_MESSAGES = {
452
- INVALID_SERVICE_ACCOUNT: "Invalid Service Account JSON. Missing required fields:",
453
- WRONG_JSON_TYPE: "You uploaded a Web App Config (SDK snippet) instead of a Service Account JSON. Please go to Firebase Console → Service Accounts tab → Generate New Private Key to download the correct file.",
454
- SERVICE_ACCOUNT_HELP: "Please download the correct JSON from Firebase Console → Service Accounts → Generate New Private Key. Do NOT use the Web App Config (SDK snippet) - that is a different file!"
455
- };
456
- const firebaseController = {
457
- async validateToken(ctx) {
458
- strapi.log.debug("validateToken called");
459
- try {
460
- const { idToken, profileMetaData } = ctx.request.body || {};
461
- const populate2 = ctx.request.query.populate || [];
462
- if (!idToken) {
463
- return ctx.badRequest(ERROR_MESSAGES.TOKEN_MISSING);
464
- }
465
- const result = await strapi.plugin(pluginName).service("firebaseService").validateFirebaseToken(idToken, profileMetaData, populate2);
466
- ctx.body = result;
467
- } catch (error2) {
468
- strapi.log.error(`validateToken controller error: ${error2.message}`);
469
- if (error2.name === "ValidationError") {
470
- return ctx.badRequest(error2.message);
471
- }
472
- if (error2.name === "UnauthorizedError") {
473
- return ctx.unauthorized(error2.message);
474
- }
475
- throw error2;
476
- }
477
- },
478
- async deleteByEmail(email2) {
479
- const user = await strapi.firebase.auth().getUserByEmail(email2);
480
- await strapi.plugin(pluginName).service("firebaseService").delete(user.toJSON().uid);
481
- return user.toJSON();
482
- },
483
- async overrideAccess(ctx) {
484
- try {
485
- const { overrideUserId } = ctx.request.body || {};
486
- const populate2 = ctx.request.query.populate || [];
487
- const result = await strapi.plugin(pluginName).service("firebaseService").overrideFirebaseAccess(overrideUserId, populate2);
488
- ctx.body = result;
489
- } catch (error2) {
490
- if (error2.name === "ValidationError") {
491
- return ctx.badRequest(error2.message);
492
- }
493
- if (error2.name === "NotFoundError") {
494
- return ctx.notFound(error2.message);
495
- }
496
- throw error2;
497
- }
498
- },
499
- /**
500
- * Controller method for email/password authentication
501
- * Handles the `/api/firebase-authentication/emailLogin` endpoint
502
- *
503
- * @param ctx - Koa context object
504
- * @returns Promise that sets ctx.body with user data and JWT or error message
505
- *
506
- * @remarks
507
- * This controller acts as a proxy to Firebase's Identity Toolkit API,
508
- * allowing users to authenticate with email/password and receive a Strapi JWT.
509
- *
510
- * HTTP Status Codes:
511
- * - `400`: Validation errors (missing credentials, invalid email/password)
512
- * - `500`: Server errors (missing configuration, Firebase API issues)
513
- */
514
- async emailLogin(ctx) {
515
- strapi.log.debug("emailLogin controller");
516
- try {
517
- const { email: email2, password } = ctx.request.body || {};
518
- const populate2 = ctx.request.query.populate || [];
519
- const result = await strapi.plugin(pluginName).service("firebaseService").emailLogin(email2, password, populate2);
520
- ctx.body = result;
521
- } catch (error2) {
522
- strapi.log.error("emailLogin controller error:", error2);
523
- if (error2.name === "ValidationError") {
524
- ctx.status = 400;
525
- } else if (error2.name === "ApplicationError") {
526
- ctx.status = 500;
527
- } else {
528
- ctx.status = 500;
529
- }
530
- ctx.body = { error: error2.message };
531
- }
532
- },
533
- /**
534
- * Forgot password - sends reset email
535
- * POST /api/firebase-authentication/forgotPassword
536
- * Public endpoint - no authentication required
537
- */
538
- async forgotPassword(ctx) {
539
- strapi.log.debug("forgotPassword endpoint called");
540
- try {
541
- const { email: email2 } = ctx.request.body || {};
542
- ctx.body = await strapi.plugin(pluginName).service("firebaseService").forgotPassword(email2);
543
- } catch (error2) {
544
- strapi.log.error("forgotPassword controller error:", error2);
545
- if (error2.name === "ValidationError") {
546
- ctx.status = 400;
547
- } else if (error2.name === "NotFoundError") {
548
- ctx.status = 404;
549
- } else {
550
- ctx.status = 500;
551
- }
552
- ctx.body = { error: error2.message };
553
- }
554
- },
555
- /**
556
- * Reset password - authenticated password change
557
- * POST /api/firebase-authentication/resetPassword
558
- * Public endpoint - requires valid JWT in Authorization header
559
- * Used for admin-initiated resets or user self-service password changes
560
- * NOT used for forgot password email flow (which uses Firebase's hosted UI)
561
- */
562
- async resetPassword(ctx) {
563
- strapi.log.debug("resetPassword endpoint called");
564
- try {
565
- const { password } = ctx.request.body || {};
566
- const token = ctx.request.headers.authorization?.replace("Bearer ", "");
567
- const populate2 = ctx.request.query.populate || [];
568
- ctx.body = await strapi.plugin(pluginName).service("firebaseService").resetPassword(password, token, populate2);
569
- } catch (error2) {
570
- strapi.log.error("resetPassword controller error:", error2);
571
- if (error2.name === "ValidationError" || error2.name === "UnauthorizedError") {
572
- ctx.status = 401;
573
- } else {
574
- ctx.status = 500;
575
- }
576
- ctx.body = { error: error2.message };
577
- }
578
- },
579
- async requestMagicLink(ctx) {
580
- try {
581
- const { email: email2 } = ctx.request.body || {};
582
- const result = await strapi.plugin("firebase-authentication").service("firebaseService").requestMagicLink(email2);
583
- ctx.body = result;
584
- } catch (error2) {
585
- if (error2.name === "ValidationError" || error2.name === "ApplicationError") {
586
- throw error2;
587
- }
588
- strapi.log.error("requestMagicLink controller error:", error2);
589
- ctx.body = {
590
- success: false,
591
- message: "An error occurred while processing your request"
592
- };
593
- }
594
- },
595
- /**
596
- * Reset password using custom JWT token
597
- * POST /api/firebase-authentication/resetPasswordWithToken
598
- * Public endpoint - token provides authentication
599
- *
600
- * @param ctx - Koa context with { token, newPassword } in body
601
- * @returns { success: true, message: "Password has been reset successfully" }
602
- */
603
- async resetPasswordWithToken(ctx) {
604
- strapi.log.debug("resetPasswordWithToken endpoint called");
605
- try {
606
- const { token, newPassword } = ctx.request.body || {};
607
- if (!token) {
608
- ctx.status = 400;
609
- ctx.body = { error: "Token is required" };
610
- return;
611
- }
612
- if (!newPassword) {
613
- ctx.status = 400;
614
- ctx.body = { error: "New password is required" };
615
- return;
616
- }
617
- const result = await strapi.plugin(pluginName).service("userService").resetPasswordWithToken(token, newPassword);
618
- ctx.body = result;
619
- } catch (error2) {
620
- strapi.log.error("resetPasswordWithToken controller error:", error2);
621
- if (error2.name === "ValidationError") {
622
- ctx.status = 400;
623
- ctx.body = { error: error2.message };
624
- return;
625
- }
626
- if (error2.name === "NotFoundError") {
627
- ctx.status = 404;
628
- ctx.body = { error: error2.message };
629
- return;
630
- }
631
- ctx.status = 500;
632
- ctx.body = { error: "An error occurred while resetting your password" };
633
- }
634
- },
635
- /**
636
- * Send email verification - public endpoint
637
- * POST /api/firebase-authentication/sendVerificationEmail
638
- * Public endpoint - no authentication required
639
- */
640
- async sendVerificationEmail(ctx) {
641
- strapi.log.debug("sendVerificationEmail endpoint called");
642
- try {
643
- const { email: email2 } = ctx.request.body || {};
644
- ctx.body = await strapi.plugin(pluginName).service("firebaseService").sendVerificationEmail(email2);
645
- } catch (error2) {
646
- strapi.log.error("sendVerificationEmail controller error:", error2);
647
- if (error2.name === "ValidationError") {
648
- ctx.status = 400;
649
- } else {
650
- ctx.status = 500;
651
- }
652
- ctx.body = { error: error2.message };
653
- }
654
- },
655
- /**
656
- * Verify email using custom JWT token
657
- * POST /api/firebase-authentication/verifyEmail
658
- * Public endpoint - token provides authentication
659
- *
660
- * @param ctx - Koa context with { token } in body
661
- * @returns { success: true, message: "Email verified successfully" }
662
- */
663
- async verifyEmail(ctx) {
664
- strapi.log.debug("verifyEmail endpoint called");
665
- try {
666
- const { token } = ctx.request.body || {};
667
- if (!token) {
668
- ctx.status = 400;
669
- ctx.body = { error: "Token is required" };
670
- return;
671
- }
672
- const result = await strapi.plugin(pluginName).service("firebaseService").verifyEmail(token);
673
- ctx.body = result;
674
- } catch (error2) {
675
- strapi.log.error("verifyEmail controller error:", error2);
676
- if (error2.name === "ValidationError") {
677
- ctx.status = 400;
678
- ctx.body = { error: error2.message };
679
- return;
680
- }
681
- if (error2.name === "NotFoundError") {
682
- ctx.status = 404;
683
- ctx.body = { error: error2.message };
684
- return;
685
- }
686
- ctx.status = 500;
687
- ctx.body = { error: "An error occurred while verifying your email" };
688
- }
689
- }
690
- };
691
404
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
692
405
  function getDefaultExportFromCjs(x) {
693
406
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -702,7 +415,7 @@ var lodash = { exports: {} };
702
415
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
703
416
  */
704
417
  lodash.exports;
705
- (function(module2, exports2) {
418
+ (function(module2, exports$1) {
706
419
  (function() {
707
420
  var undefined$1;
708
421
  var VERSION = "4.17.21";
@@ -1030,7 +743,7 @@ lodash.exports;
1030
743
  var freeGlobal2 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
1031
744
  var freeSelf2 = typeof self == "object" && self && self.Object === Object && self;
1032
745
  var root2 = freeGlobal2 || freeSelf2 || Function("return this")();
1033
- var freeExports = exports2 && !exports2.nodeType && exports2;
746
+ var freeExports = exports$1 && !exports$1.nodeType && exports$1;
1034
747
  var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
1035
748
  var moduleExports = freeModule && freeModule.exports === freeExports;
1036
749
  var freeProcess = moduleExports && freeGlobal2.process;
@@ -1301,9 +1014,9 @@ lodash.exports;
1301
1014
  function hasUnicodeWord2(string2) {
1302
1015
  return reHasUnicodeWord2.test(string2);
1303
1016
  }
1304
- function iteratorToArray(iterator) {
1017
+ function iteratorToArray(iterator2) {
1305
1018
  var data, result = [];
1306
- while (!(data = iterator.next()).done) {
1019
+ while (!(data = iterator2.next()).done) {
1307
1020
  result.push(data.value);
1308
1021
  }
1309
1022
  return result;
@@ -6260,7 +5973,7 @@ var lodash_min = { exports: {} };
6260
5973
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
6261
5974
  */
6262
5975
  lodash_min.exports;
6263
- (function(module2, exports2) {
5976
+ (function(module2, exports$1) {
6264
5977
  (function() {
6265
5978
  function n(n2, t3, r2) {
6266
5979
  switch (r2.length) {
@@ -6693,7 +6406,7 @@ lodash_min.exports;
6693
6406
  "œ": "oe",
6694
6407
  "ʼn": "'n",
6695
6408
  "ſ": "s"
6696
- }, Hr = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, Jr = { "&amp;": "&", "&lt;": "<", "&gt;": ">", "&quot;": '"', "&#39;": "'" }, Yr = { "\\": "\\", "'": "'", "\n": "n", "\r": "r", "\u2028": "u2028", "\u2029": "u2029" }, Qr = parseFloat, Xr = parseInt, ne = "object" == typeof commonjsGlobal && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal, te = "object" == typeof self && self && self.Object === Object && self, re2 = ne || te || Function("return this")(), ee = exports2 && !exports2.nodeType && exports2, ue = ee && true && module2 && !module2.nodeType && module2, ie = ue && ue.exports === ee, oe = ie && ne.process, fe = function() {
6409
+ }, Hr = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" }, Jr = { "&amp;": "&", "&lt;": "<", "&gt;": ">", "&quot;": '"', "&#39;": "'" }, Yr = { "\\": "\\", "'": "'", "\n": "n", "\r": "r", "\u2028": "u2028", "\u2029": "u2029" }, Qr = parseFloat, Xr = parseInt, ne = "object" == typeof commonjsGlobal && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal, te = "object" == typeof self && self && self.Object === Object && self, re2 = ne || te || Function("return this")(), ee = exports$1 && !exports$1.nodeType && exports$1, ue = ee && true && module2 && !module2.nodeType && module2, ie = ue && ue.exports === ee, oe = ie && ne.process, fe = function() {
6697
6410
  try {
6698
6411
  var n2 = ue && ue.require && ue.require("util").types;
6699
6412
  return n2 ? n2 : oe && oe.binding && oe.binding("util");
@@ -9366,8 +9079,8 @@ lodash_min.exports;
9366
9079
  })(lodash_min, lodash_min.exports);
9367
9080
  var lodash_minExports = lodash_min.exports;
9368
9081
  var _mapping = {};
9369
- (function(exports2) {
9370
- exports2.aliasToReal = {
9082
+ (function(exports$1) {
9083
+ exports$1.aliasToReal = {
9371
9084
  // Lodash aliases.
9372
9085
  "each": "forEach",
9373
9086
  "eachRight": "forEachRight",
@@ -9432,7 +9145,7 @@ var _mapping = {};
9432
9145
  "whereEq": "isMatch",
9433
9146
  "zipObj": "zipObject"
9434
9147
  };
9435
- exports2.aryMethod = {
9148
+ exports$1.aryMethod = {
9436
9149
  "1": [
9437
9150
  "assignAll",
9438
9151
  "assignInAll",
@@ -9667,12 +9380,12 @@ var _mapping = {};
9667
9380
  "updateWith"
9668
9381
  ]
9669
9382
  };
9670
- exports2.aryRearg = {
9383
+ exports$1.aryRearg = {
9671
9384
  "2": [1, 0],
9672
9385
  "3": [2, 0, 1],
9673
9386
  "4": [3, 2, 0, 1]
9674
9387
  };
9675
- exports2.iterateeAry = {
9388
+ exports$1.iterateeAry = {
9676
9389
  "dropRightWhile": 1,
9677
9390
  "dropWhile": 1,
9678
9391
  "every": 1,
@@ -9710,11 +9423,11 @@ var _mapping = {};
9710
9423
  "times": 1,
9711
9424
  "transform": 2
9712
9425
  };
9713
- exports2.iterateeRearg = {
9426
+ exports$1.iterateeRearg = {
9714
9427
  "mapKeys": [1],
9715
9428
  "reduceRight": [1, 0]
9716
9429
  };
9717
- exports2.methodRearg = {
9430
+ exports$1.methodRearg = {
9718
9431
  "assignInAllWith": [1, 0],
9719
9432
  "assignInWith": [1, 2, 0],
9720
9433
  "assignAllWith": [1, 0],
@@ -9745,7 +9458,7 @@ var _mapping = {};
9745
9458
  "xorWith": [1, 2, 0],
9746
9459
  "zipWith": [1, 2, 0]
9747
9460
  };
9748
- exports2.methodSpread = {
9461
+ exports$1.methodSpread = {
9749
9462
  "assignAll": { "start": 0 },
9750
9463
  "assignAllWith": { "start": 0 },
9751
9464
  "assignInAll": { "start": 0 },
@@ -9761,7 +9474,7 @@ var _mapping = {};
9761
9474
  "without": { "start": 1 },
9762
9475
  "zipAll": { "start": 0 }
9763
9476
  };
9764
- exports2.mutate = {
9477
+ exports$1.mutate = {
9765
9478
  "array": {
9766
9479
  "fill": true,
9767
9480
  "pull": true,
@@ -9798,8 +9511,8 @@ var _mapping = {};
9798
9511
  "updateWith": true
9799
9512
  }
9800
9513
  };
9801
- exports2.realToAlias = function() {
9802
- var hasOwnProperty2 = Object.prototype.hasOwnProperty, object2 = exports2.aliasToReal, result = {};
9514
+ exports$1.realToAlias = function() {
9515
+ var hasOwnProperty2 = Object.prototype.hasOwnProperty, object2 = exports$1.aliasToReal, result = {};
9803
9516
  for (var key in object2) {
9804
9517
  var value = object2[key];
9805
9518
  if (hasOwnProperty2.call(result, value)) {
@@ -9810,7 +9523,7 @@ var _mapping = {};
9810
9523
  }
9811
9524
  return result;
9812
9525
  }();
9813
- exports2.remap = {
9526
+ exports$1.remap = {
9814
9527
  "assignAll": "assign",
9815
9528
  "assignAllWith": "assignWith",
9816
9529
  "assignInAll": "assignIn",
@@ -9844,7 +9557,7 @@ var _mapping = {};
9844
9557
  "trimCharsStart": "trimStart",
9845
9558
  "zipAll": "zip"
9846
9559
  };
9847
- exports2.skipFixed = {
9560
+ exports$1.skipFixed = {
9848
9561
  "castArray": true,
9849
9562
  "flow": true,
9850
9563
  "flowRight": true,
@@ -9853,7 +9566,7 @@ var _mapping = {};
9853
9566
  "rearg": true,
9854
9567
  "runInContext": true
9855
9568
  };
9856
- exports2.skipRearg = {
9569
+ exports$1.skipRearg = {
9857
9570
  "add": true,
9858
9571
  "assign": true,
9859
9572
  "assignIn": true,
@@ -9886,7 +9599,7 @@ var _mapping = {};
9886
9599
  })(_mapping);
9887
9600
  var placeholder = {};
9888
9601
  var mapping = _mapping, fallbackHolder = placeholder;
9889
- var push = Array.prototype.push;
9602
+ var push$1 = Array.prototype.push;
9890
9603
  function baseArity(func, n) {
9891
9604
  return n == 2 ? function(a, b) {
9892
9605
  return func.apply(void 0, arguments);
@@ -9921,10 +9634,10 @@ function flatSpread(func, start) {
9921
9634
  }
9922
9635
  var array2 = args[start], otherArgs = args.slice(0, start);
9923
9636
  if (array2) {
9924
- push.apply(otherArgs, array2);
9637
+ push$1.apply(otherArgs, array2);
9925
9638
  }
9926
9639
  if (start != lastIndex) {
9927
- push.apply(otherArgs, args.slice(start + 1));
9640
+ push$1.apply(otherArgs, args.slice(start + 1));
9928
9641
  }
9929
9642
  return func.apply(this, otherArgs);
9930
9643
  };
@@ -10307,13 +10020,13 @@ const traverseEntity = async (visitor2, options2, entity) => {
10307
10020
  if (fp.isNil(value) || fp.isNil(attribute)) {
10308
10021
  continue;
10309
10022
  }
10310
- parent = {
10311
- schema: schema2,
10312
- key,
10313
- attribute,
10314
- path: newPath
10315
- };
10316
10023
  if (isRelationalAttribute(attribute)) {
10024
+ parent = {
10025
+ schema: schema2,
10026
+ key,
10027
+ attribute,
10028
+ path: newPath
10029
+ };
10317
10030
  const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
10318
10031
  const method = isMorphRelation ? traverseMorphRelationTarget : traverseRelationTarget(getModel(attribute.target));
10319
10032
  if (fp.isArray(value)) {
@@ -10332,6 +10045,12 @@ const traverseEntity = async (visitor2, options2, entity) => {
10332
10045
  continue;
10333
10046
  }
10334
10047
  if (isMediaAttribute(attribute)) {
10048
+ parent = {
10049
+ schema: schema2,
10050
+ key,
10051
+ attribute,
10052
+ path: newPath
10053
+ };
10335
10054
  if (fp.isArray(value)) {
10336
10055
  const res = new Array(value.length);
10337
10056
  for (let i2 = 0; i2 < value.length; i2 += 1) {
@@ -10348,6 +10067,12 @@ const traverseEntity = async (visitor2, options2, entity) => {
10348
10067
  continue;
10349
10068
  }
10350
10069
  if (attribute.type === "component") {
10070
+ parent = {
10071
+ schema: schema2,
10072
+ key,
10073
+ attribute,
10074
+ path: newPath
10075
+ };
10351
10076
  const targetSchema = getModel(attribute.component);
10352
10077
  if (fp.isArray(value)) {
10353
10078
  const res = new Array(value.length);
@@ -10365,6 +10090,12 @@ const traverseEntity = async (visitor2, options2, entity) => {
10365
10090
  continue;
10366
10091
  }
10367
10092
  if (attribute.type === "dynamiczone" && fp.isArray(value)) {
10093
+ parent = {
10094
+ schema: schema2,
10095
+ key,
10096
+ attribute,
10097
+ path: newPath
10098
+ };
10368
10099
  const res = new Array(value.length);
10369
10100
  for (let i2 = 0; i2 < value.length; i2 += 1) {
10370
10101
  const arrayPath = {
@@ -10389,7 +10120,7 @@ const createVisitorUtils = ({ data }) => ({
10389
10120
  });
10390
10121
  fp.curry(traverseEntity);
10391
10122
  var dist = { exports: {} };
10392
- (function(module2, exports2) {
10123
+ (function(module2, exports$1) {
10393
10124
  !function(t2, n) {
10394
10125
  module2.exports = n(require$$0__default.default, crypto__default.default);
10395
10126
  }(commonjsGlobal, function(t2, n) {
@@ -11937,9 +11668,9 @@ function stubFalse() {
11937
11668
  }
11938
11669
  var stubFalse_1 = stubFalse;
11939
11670
  isBuffer$2.exports;
11940
- (function(module2, exports2) {
11671
+ (function(module2, exports$1) {
11941
11672
  var root2 = _root, stubFalse2 = stubFalse_1;
11942
- var freeExports = exports2 && !exports2.nodeType && exports2;
11673
+ var freeExports = exports$1 && !exports$1.nodeType && exports$1;
11943
11674
  var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
11944
11675
  var moduleExports = freeModule && freeModule.exports === freeExports;
11945
11676
  var Buffer2 = moduleExports ? root2.Buffer : void 0;
@@ -11966,9 +11697,9 @@ function baseUnary$1(func) {
11966
11697
  var _baseUnary = baseUnary$1;
11967
11698
  var _nodeUtil = { exports: {} };
11968
11699
  _nodeUtil.exports;
11969
- (function(module2, exports2) {
11700
+ (function(module2, exports$1) {
11970
11701
  var freeGlobal2 = _freeGlobal;
11971
- var freeExports = exports2 && !exports2.nodeType && exports2;
11702
+ var freeExports = exports$1 && !exports$1.nodeType && exports$1;
11972
11703
  var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
11973
11704
  var moduleExports = freeModule && freeModule.exports === freeExports;
11974
11705
  var freeProcess = moduleExports && freeGlobal2.process;
@@ -12514,11 +12245,11 @@ function baseGet$2(object2, path2) {
12514
12245
  }
12515
12246
  var _baseGet = baseGet$2;
12516
12247
  var baseGet$1 = _baseGet;
12517
- function get$1(object2, path2, defaultValue) {
12248
+ function get$2(object2, path2, defaultValue) {
12518
12249
  var result = object2 == null ? void 0 : baseGet$1(object2, path2);
12519
12250
  return result === void 0 ? defaultValue : result;
12520
12251
  }
12521
- var get_1 = get$1;
12252
+ var get_1 = get$2;
12522
12253
  function baseHasIn$1(object2, key) {
12523
12254
  return object2 != null && key in Object(object2);
12524
12255
  }
@@ -12528,14 +12259,14 @@ function hasIn$1(object2, path2) {
12528
12259
  return object2 != null && hasPath(object2, path2, baseHasIn);
12529
12260
  }
12530
12261
  var hasIn_1 = hasIn$1;
12531
- var baseIsEqual = _baseIsEqual, get = get_1, hasIn = hasIn_1, isKey$1 = _isKey, isStrictComparable = _isStrictComparable, matchesStrictComparable = _matchesStrictComparable, toKey$1 = _toKey;
12262
+ var baseIsEqual = _baseIsEqual, get$1 = get_1, hasIn = hasIn_1, isKey$1 = _isKey, isStrictComparable = _isStrictComparable, matchesStrictComparable = _matchesStrictComparable, toKey$1 = _toKey;
12532
12263
  var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2;
12533
12264
  function baseMatchesProperty$1(path2, srcValue) {
12534
12265
  if (isKey$1(path2) && isStrictComparable(srcValue)) {
12535
12266
  return matchesStrictComparable(toKey$1(path2), srcValue);
12536
12267
  }
12537
12268
  return function(object2) {
12538
- var objValue = get(object2, path2);
12269
+ var objValue = get$1(object2, path2);
12539
12270
  return objValue === void 0 && objValue === srcValue ? hasIn(object2, path2) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
12540
12271
  };
12541
12272
  }
@@ -12831,7 +12562,7 @@ function createValidation(config2) {
12831
12562
  validate2.OPTIONS = config2;
12832
12563
  return validate2;
12833
12564
  }
12834
- let trim = (part) => part.substr(0, part.length - 1).substr(1);
12565
+ let trim$1 = (part) => part.substr(0, part.length - 1).substr(1);
12835
12566
  function getIn(schema2, path2, value, context = value) {
12836
12567
  let parent, lastPart, lastPartDebug;
12837
12568
  if (!path2) return {
@@ -12840,7 +12571,7 @@ function getIn(schema2, path2, value, context = value) {
12840
12571
  schema: schema2
12841
12572
  };
12842
12573
  propertyExpr.forEach(path2, (_part, isBracket, isArray2) => {
12843
- let part = isBracket ? trim(_part) : _part;
12574
+ let part = isBracket ? trim$1(_part) : _part;
12844
12575
  schema2 = schema2.resolve({
12845
12576
  context,
12846
12577
  parent,
@@ -14927,7 +14658,7 @@ function toIdentifier(str2) {
14927
14658
  Object.defineProperty(func, "name", desc);
14928
14659
  }
14929
14660
  }
14930
- function populateConstructorExports(exports2, codes2, HttpError) {
14661
+ function populateConstructorExports(exports$1, codes2, HttpError) {
14931
14662
  codes2.forEach(function forEachCode(code) {
14932
14663
  var CodeError;
14933
14664
  var name = toIdentifier2(statuses$1.message[code]);
@@ -14940,8 +14671,8 @@ function toIdentifier(str2) {
14940
14671
  break;
14941
14672
  }
14942
14673
  if (CodeError) {
14943
- exports2[code] = CodeError;
14944
- exports2[name] = CodeError;
14674
+ exports$1[code] = CodeError;
14675
+ exports$1[name] = CodeError;
14945
14676
  }
14946
14677
  });
14947
14678
  }
@@ -14963,7 +14694,7 @@ const formatYupErrors = (yupError) => ({
14963
14694
  message: yupError.message
14964
14695
  });
14965
14696
  let ApplicationError$2 = class ApplicationError extends Error {
14966
- constructor(message = "An application error occured", details = {}) {
14697
+ constructor(message = "An application error occurred", details = {}) {
14967
14698
  super();
14968
14699
  this.name = "ApplicationError";
14969
14700
  this.message = message;
@@ -15227,7 +14958,7 @@ var pMap = async (iterable, mapper, {
15227
14958
  }
15228
14959
  const result = [];
15229
14960
  const errors2 = [];
15230
- const iterator = iterable[Symbol.iterator]();
14961
+ const iterator2 = iterable[Symbol.iterator]();
15231
14962
  let isRejected = false;
15232
14963
  let isIterableDone = false;
15233
14964
  let resolvingCount = 0;
@@ -15236,7 +14967,7 @@ var pMap = async (iterable, mapper, {
15236
14967
  if (isRejected) {
15237
14968
  return;
15238
14969
  }
15239
- const nextItem = iterator.next();
14970
+ const nextItem = iterator2.next();
15240
14971
  const index2 = currentIndex;
15241
14972
  currentIndex++;
15242
14973
  if (nextItem.done) {
@@ -16446,16 +16177,16 @@ var shebangCommand$1 = (string2 = "") => {
16446
16177
  }
16447
16178
  return argument ? `${binary2} ${argument}` : binary2;
16448
16179
  };
16449
- const fs$5 = require$$0__default$2.default;
16180
+ const fs$7 = require$$0__default$2.default;
16450
16181
  const shebangCommand = shebangCommand$1;
16451
16182
  function readShebang$1(command2) {
16452
16183
  const size = 150;
16453
16184
  const buffer = Buffer.alloc(size);
16454
16185
  let fd;
16455
16186
  try {
16456
- fd = fs$5.openSync(command2, "r");
16457
- fs$5.readSync(fd, buffer, 0, size, 0);
16458
- fs$5.closeSync(fd);
16187
+ fd = fs$7.openSync(command2, "r");
16188
+ fs$7.readSync(fd, buffer, 0, size, 0);
16189
+ fs$7.closeSync(fd);
16459
16190
  } catch (e) {
16460
16191
  }
16461
16192
  return shebangCommand(buffer.toString());
@@ -17466,9 +17197,9 @@ var bufferStream$1 = (options2) => {
17466
17197
  };
17467
17198
  const { constants: BufferConstants } = require$$0__default$5.default;
17468
17199
  const stream$1 = require$$0__default$4.default;
17469
- const { promisify: promisify$3 } = require$$2__default$1.default;
17200
+ const { promisify: promisify$5 } = require$$2__default$1.default;
17470
17201
  const bufferStream = bufferStream$1;
17471
- const streamPipelinePromisified = promisify$3(stream$1.pipeline);
17202
+ const streamPipelinePromisified = promisify$5(stream$1.pipeline);
17472
17203
  class MaxBufferError extends Error {
17473
17204
  constructor() {
17474
17205
  super("maxBuffer exceeded");
@@ -18004,11 +17735,11 @@ pLocate$4.exports = pLocate$3;
18004
17735
  pLocate$4.exports.default = pLocate$3;
18005
17736
  var pLocateExports = pLocate$4.exports;
18006
17737
  const path$4 = require$$0__namespace.default;
18007
- const fs$4 = require$$0__default$2.default;
18008
- const { promisify: promisify$2 } = require$$2__default$1.default;
17738
+ const fs$6 = require$$0__default$2.default;
17739
+ const { promisify: promisify$4 } = require$$2__default$1.default;
18009
17740
  const pLocate$2 = pLocateExports;
18010
- const fsStat$1 = promisify$2(fs$4.stat);
18011
- const fsLStat$1 = promisify$2(fs$4.lstat);
17741
+ const fsStat$1 = promisify$4(fs$6.stat);
17742
+ const fsLStat$1 = promisify$4(fs$6.lstat);
18012
17743
  const typeMappings$1 = {
18013
17744
  directory: "isDirectory",
18014
17745
  file: "isFile"
@@ -18046,7 +17777,7 @@ locatePath$1.exports.sync = (paths, options2) => {
18046
17777
  ...options2
18047
17778
  };
18048
17779
  checkType$1(options2);
18049
- const statFn = options2.allowSymlinks ? fs$4.statSync : fs$4.lstatSync;
17780
+ const statFn = options2.allowSymlinks ? fs$6.statSync : fs$6.lstatSync;
18050
17781
  for (const path_ of paths) {
18051
17782
  try {
18052
17783
  const stat = statFn(path$4.resolve(options2.cwd, path_));
@@ -18058,31 +17789,31 @@ locatePath$1.exports.sync = (paths, options2) => {
18058
17789
  }
18059
17790
  };
18060
17791
  var locatePathExports$1 = locatePath$1.exports;
18061
- var pathExists = { exports: {} };
18062
- const fs$3 = require$$0__default$2.default;
18063
- const { promisify: promisify$1 } = require$$2__default$1.default;
18064
- const pAccess = promisify$1(fs$3.access);
18065
- pathExists.exports = async (path2) => {
17792
+ var pathExists$2 = { exports: {} };
17793
+ const fs$5 = require$$0__default$2.default;
17794
+ const { promisify: promisify$3 } = require$$2__default$1.default;
17795
+ const pAccess$2 = promisify$3(fs$5.access);
17796
+ pathExists$2.exports = async (path2) => {
18066
17797
  try {
18067
- await pAccess(path2);
17798
+ await pAccess$2(path2);
18068
17799
  return true;
18069
17800
  } catch (_2) {
18070
17801
  return false;
18071
17802
  }
18072
17803
  };
18073
- pathExists.exports.sync = (path2) => {
17804
+ pathExists$2.exports.sync = (path2) => {
18074
17805
  try {
18075
- fs$3.accessSync(path2);
17806
+ fs$5.accessSync(path2);
18076
17807
  return true;
18077
17808
  } catch (_2) {
18078
17809
  return false;
18079
17810
  }
18080
17811
  };
18081
- var pathExistsExports = pathExists.exports;
17812
+ var pathExistsExports$1 = pathExists$2.exports;
18082
17813
  (function(module2) {
18083
17814
  const path2 = require$$0__namespace.default;
18084
17815
  const locatePath2 = locatePathExports$1;
18085
- const pathExists2 = pathExistsExports;
17816
+ const pathExists2 = pathExistsExports$1;
18086
17817
  const stop = Symbol("findUp.stop");
18087
17818
  module2.exports = async (name, options2 = {}) => {
18088
17819
  let directory = path2.resolve(options2.cwd || "");
@@ -18159,8 +17890,8 @@ pkgDir$1.exports.sync = (cwd2) => {
18159
17890
  };
18160
17891
  var pkgDirExports = pkgDir$1.exports;
18161
17892
  var utils$8 = {};
18162
- (function(exports2) {
18163
- exports2.isInteger = (num) => {
17893
+ (function(exports$1) {
17894
+ exports$1.isInteger = (num) => {
18164
17895
  if (typeof num === "number") {
18165
17896
  return Number.isInteger(num);
18166
17897
  }
@@ -18169,13 +17900,13 @@ var utils$8 = {};
18169
17900
  }
18170
17901
  return false;
18171
17902
  };
18172
- exports2.find = (node, type2) => node.nodes.find((node2) => node2.type === type2);
18173
- exports2.exceedsLimit = (min, max, step = 1, limit) => {
17903
+ exports$1.find = (node, type2) => node.nodes.find((node2) => node2.type === type2);
17904
+ exports$1.exceedsLimit = (min, max, step = 1, limit) => {
18174
17905
  if (limit === false) return false;
18175
- if (!exports2.isInteger(min) || !exports2.isInteger(max)) return false;
17906
+ if (!exports$1.isInteger(min) || !exports$1.isInteger(max)) return false;
18176
17907
  return (Number(max) - Number(min)) / Number(step) >= limit;
18177
17908
  };
18178
- exports2.escapeNode = (block, n = 0, type2) => {
17909
+ exports$1.escapeNode = (block, n = 0, type2) => {
18179
17910
  const node = block.nodes[n];
18180
17911
  if (!node) return;
18181
17912
  if (type2 && node.type === type2 || node.type === "open" || node.type === "close") {
@@ -18185,7 +17916,7 @@ var utils$8 = {};
18185
17916
  }
18186
17917
  }
18187
17918
  };
18188
- exports2.encloseBrace = (node) => {
17919
+ exports$1.encloseBrace = (node) => {
18189
17920
  if (node.type !== "brace") return false;
18190
17921
  if (node.commas >> 0 + node.ranges >> 0 === 0) {
18191
17922
  node.invalid = true;
@@ -18193,7 +17924,7 @@ var utils$8 = {};
18193
17924
  }
18194
17925
  return false;
18195
17926
  };
18196
- exports2.isInvalidBrace = (block) => {
17927
+ exports$1.isInvalidBrace = (block) => {
18197
17928
  if (block.type !== "brace") return false;
18198
17929
  if (block.invalid === true || block.dollar) return true;
18199
17930
  if (block.commas >> 0 + block.ranges >> 0 === 0) {
@@ -18206,18 +17937,18 @@ var utils$8 = {};
18206
17937
  }
18207
17938
  return false;
18208
17939
  };
18209
- exports2.isOpenOrClose = (node) => {
17940
+ exports$1.isOpenOrClose = (node) => {
18210
17941
  if (node.type === "open" || node.type === "close") {
18211
17942
  return true;
18212
17943
  }
18213
17944
  return node.open === true || node.close === true;
18214
17945
  };
18215
- exports2.reduce = (nodes) => nodes.reduce((acc, node) => {
17946
+ exports$1.reduce = (nodes) => nodes.reduce((acc, node) => {
18216
17947
  if (node.type === "text") acc.push(node.value);
18217
17948
  if (node.type === "range") node.type = "text";
18218
17949
  return acc;
18219
17950
  }, []);
18220
- exports2.flatten = (...args) => {
17951
+ exports$1.flatten = (...args) => {
18221
17952
  const result = [];
18222
17953
  const flat = (arr) => {
18223
17954
  for (let i = 0; i < arr.length; i++) {
@@ -19319,7 +19050,7 @@ var constants$5 = {
19319
19050
  return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
19320
19051
  }
19321
19052
  };
19322
- (function(exports2) {
19053
+ (function(exports$1) {
19323
19054
  const path2 = require$$0__namespace.default;
19324
19055
  const win32 = process.platform === "win32";
19325
19056
  const {
@@ -19328,36 +19059,36 @@ var constants$5 = {
19328
19059
  REGEX_SPECIAL_CHARS,
19329
19060
  REGEX_SPECIAL_CHARS_GLOBAL
19330
19061
  } = constants$5;
19331
- exports2.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
19332
- exports2.hasRegexChars = (str2) => REGEX_SPECIAL_CHARS.test(str2);
19333
- exports2.isRegexChar = (str2) => str2.length === 1 && exports2.hasRegexChars(str2);
19334
- exports2.escapeRegex = (str2) => str2.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
19335
- exports2.toPosixSlashes = (str2) => str2.replace(REGEX_BACKSLASH, "/");
19336
- exports2.removeBackslashes = (str2) => {
19062
+ exports$1.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
19063
+ exports$1.hasRegexChars = (str2) => REGEX_SPECIAL_CHARS.test(str2);
19064
+ exports$1.isRegexChar = (str2) => str2.length === 1 && exports$1.hasRegexChars(str2);
19065
+ exports$1.escapeRegex = (str2) => str2.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
19066
+ exports$1.toPosixSlashes = (str2) => str2.replace(REGEX_BACKSLASH, "/");
19067
+ exports$1.removeBackslashes = (str2) => {
19337
19068
  return str2.replace(REGEX_REMOVE_BACKSLASH, (match) => {
19338
19069
  return match === "\\" ? "" : match;
19339
19070
  });
19340
19071
  };
19341
- exports2.supportsLookbehinds = () => {
19072
+ exports$1.supportsLookbehinds = () => {
19342
19073
  const segs = process.version.slice(1).split(".").map(Number);
19343
19074
  if (segs.length === 3 && segs[0] >= 9 || segs[0] === 8 && segs[1] >= 10) {
19344
19075
  return true;
19345
19076
  }
19346
19077
  return false;
19347
19078
  };
19348
- exports2.isWindows = (options2) => {
19079
+ exports$1.isWindows = (options2) => {
19349
19080
  if (options2 && typeof options2.windows === "boolean") {
19350
19081
  return options2.windows;
19351
19082
  }
19352
19083
  return win32 === true || path2.sep === "\\";
19353
19084
  };
19354
- exports2.escapeLast = (input, char, lastIdx) => {
19085
+ exports$1.escapeLast = (input, char, lastIdx) => {
19355
19086
  const idx = input.lastIndexOf(char, lastIdx);
19356
19087
  if (idx === -1) return input;
19357
- if (input[idx - 1] === "\\") return exports2.escapeLast(input, char, idx - 1);
19088
+ if (input[idx - 1] === "\\") return exports$1.escapeLast(input, char, idx - 1);
19358
19089
  return `${input.slice(0, idx)}\\${input.slice(idx)}`;
19359
19090
  };
19360
- exports2.removePrefix = (input, state = {}) => {
19091
+ exports$1.removePrefix = (input, state = {}) => {
19361
19092
  let output = input;
19362
19093
  if (output.startsWith("./")) {
19363
19094
  output = output.slice(2);
@@ -19365,7 +19096,7 @@ var constants$5 = {
19365
19096
  }
19366
19097
  return output;
19367
19098
  };
19368
- exports2.wrapOutput = (input, state = {}, options2 = {}) => {
19099
+ exports$1.wrapOutput = (input, state = {}, options2 = {}) => {
19369
19100
  const prepend = options2.contains ? "" : "^";
19370
19101
  const append2 = options2.contains ? "" : "$";
19371
19102
  let output = `${prepend}(?:${input})${append2}`;
@@ -20836,14 +20567,14 @@ const core_1 = core$1;
20836
20567
  core_1.findWorkspaceRoot;
20837
20568
  var findUp = { exports: {} };
20838
20569
  var locatePath = { exports: {} };
20839
- class Node {
20570
+ let Node$1 = class Node {
20840
20571
  /// value;
20841
20572
  /// next;
20842
20573
  constructor(value) {
20843
20574
  this.value = value;
20844
20575
  this.next = void 0;
20845
20576
  }
20846
- }
20577
+ };
20847
20578
  let Queue$1 = class Queue {
20848
20579
  // TODO: Use private class fields when targeting Node.js 12.
20849
20580
  // #_head;
@@ -20853,7 +20584,7 @@ let Queue$1 = class Queue {
20853
20584
  this.clear();
20854
20585
  }
20855
20586
  enqueue(value) {
20856
- const node = new Node(value);
20587
+ const node = new Node$1(value);
20857
20588
  if (this._head) {
20858
20589
  this._tail.next = node;
20859
20590
  this._tail = node;
@@ -20975,11 +20706,11 @@ const pLocate$1 = async (iterable, tester, options2) => {
20975
20706
  };
20976
20707
  var pLocate_1 = pLocate$1;
20977
20708
  const path = require$$0__namespace.default;
20978
- const fs$2 = require$$0__default$2.default;
20979
- const { promisify } = require$$2__default$1.default;
20709
+ const fs$4 = require$$0__default$2.default;
20710
+ const { promisify: promisify$2 } = require$$2__default$1.default;
20980
20711
  const pLocate = pLocate_1;
20981
- const fsStat = promisify(fs$2.stat);
20982
- const fsLStat = promisify(fs$2.lstat);
20712
+ const fsStat = promisify$2(fs$4.stat);
20713
+ const fsLStat = promisify$2(fs$4.lstat);
20983
20714
  const typeMappings = {
20984
20715
  directory: "isDirectory",
20985
20716
  file: "isFile"
@@ -21017,7 +20748,7 @@ locatePath.exports.sync = (paths, options2) => {
21017
20748
  ...options2
21018
20749
  };
21019
20750
  checkType(options2);
21020
- const statFn = options2.allowSymlinks ? fs$2.statSync : fs$2.lstatSync;
20751
+ const statFn = options2.allowSymlinks ? fs$4.statSync : fs$4.lstatSync;
21021
20752
  for (const path_ of paths) {
21022
20753
  try {
21023
20754
  const stat = statFn(path.resolve(options2.cwd, path_));
@@ -21029,6 +20760,27 @@ locatePath.exports.sync = (paths, options2) => {
21029
20760
  }
21030
20761
  };
21031
20762
  var locatePathExports = locatePath.exports;
20763
+ var pathExists$1 = { exports: {} };
20764
+ const fs$3 = require$$0__default$2.default;
20765
+ const { promisify: promisify$1 } = require$$2__default$1.default;
20766
+ const pAccess$1 = promisify$1(fs$3.access);
20767
+ pathExists$1.exports = async (path2) => {
20768
+ try {
20769
+ await pAccess$1(path2);
20770
+ return true;
20771
+ } catch (_2) {
20772
+ return false;
20773
+ }
20774
+ };
20775
+ pathExists$1.exports.sync = (path2) => {
20776
+ try {
20777
+ fs$3.accessSync(path2);
20778
+ return true;
20779
+ } catch (_2) {
20780
+ return false;
20781
+ }
20782
+ };
20783
+ var pathExistsExports = pathExists$1.exports;
21032
20784
  (function(module2) {
21033
20785
  const path2 = require$$0__namespace.default;
21034
20786
  const locatePath2 = locatePathExports;
@@ -21094,6 +20846,26 @@ var locatePathExports = locatePath.exports;
21094
20846
  module2.exports.sync.exists = pathExists2.sync;
21095
20847
  module2.exports.stop = stop;
21096
20848
  })(findUp);
20849
+ var pathExists = { exports: {} };
20850
+ const fs$2 = require$$0__default$2.default;
20851
+ const { promisify } = require$$2__default$1.default;
20852
+ const pAccess = promisify(fs$2.access);
20853
+ pathExists.exports = async (path2) => {
20854
+ try {
20855
+ await pAccess(path2);
20856
+ return true;
20857
+ } catch (_2) {
20858
+ return false;
20859
+ }
20860
+ };
20861
+ pathExists.exports.sync = (path2) => {
20862
+ try {
20863
+ fs$2.accessSync(path2);
20864
+ return true;
20865
+ } catch (_2) {
20866
+ return false;
20867
+ }
20868
+ };
21097
20869
  var loadYamlFile = { exports: {} };
21098
20870
  var constants$2 = require$$0__default$6.default;
21099
20871
  var origCwd = process.cwd;
@@ -22920,6 +22692,18 @@ function charFromCodepoint(c) {
22920
22692
  (c - 65536 & 1023) + 56320
22921
22693
  );
22922
22694
  }
22695
+ function setProperty(object2, key, value) {
22696
+ if (key === "__proto__") {
22697
+ Object.defineProperty(object2, key, {
22698
+ configurable: true,
22699
+ enumerable: true,
22700
+ writable: true,
22701
+ value
22702
+ });
22703
+ } else {
22704
+ object2[key] = value;
22705
+ }
22706
+ }
22923
22707
  var simpleEscapeCheck = new Array(256);
22924
22708
  var simpleEscapeMap = new Array(256);
22925
22709
  for (var i = 0; i < 256; i++) {
@@ -23026,7 +22810,7 @@ function mergeMappings(state, destination, source, overridableKeys) {
23026
22810
  for (index2 = 0, quantity = sourceKeys.length; index2 < quantity; index2 += 1) {
23027
22811
  key = sourceKeys[index2];
23028
22812
  if (!_hasOwnProperty$1.call(destination, key)) {
23029
- destination[key] = source[key];
22813
+ setProperty(destination, key, source[key]);
23030
22814
  overridableKeys[key] = true;
23031
22815
  }
23032
22816
  }
@@ -23065,7 +22849,7 @@ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valu
23065
22849
  state.position = startPos || state.position;
23066
22850
  throwError(state, "duplicated mapping key");
23067
22851
  }
23068
- _result[keyNode] = valueNode;
22852
+ setProperty(_result, keyNode, valueNode);
23069
22853
  delete overridableKeys[keyNode];
23070
22854
  }
23071
22855
  return _result;
@@ -23909,17 +23693,17 @@ function loadDocuments(input, options2) {
23909
23693
  }
23910
23694
  return state.documents;
23911
23695
  }
23912
- function loadAll(input, iterator, options2) {
23913
- if (iterator !== null && typeof iterator === "object" && typeof options2 === "undefined") {
23914
- options2 = iterator;
23915
- iterator = null;
23696
+ function loadAll(input, iterator2, options2) {
23697
+ if (iterator2 !== null && typeof iterator2 === "object" && typeof options2 === "undefined") {
23698
+ options2 = iterator2;
23699
+ iterator2 = null;
23916
23700
  }
23917
23701
  var documents = loadDocuments(input, options2);
23918
- if (typeof iterator !== "function") {
23702
+ if (typeof iterator2 !== "function") {
23919
23703
  return documents;
23920
23704
  }
23921
23705
  for (var index2 = 0, length = documents.length; index2 < length; index2 += 1) {
23922
- iterator(documents[index2]);
23706
+ iterator2(documents[index2]);
23923
23707
  }
23924
23708
  }
23925
23709
  function load(input, options2) {
@@ -23931,12 +23715,12 @@ function load(input, options2) {
23931
23715
  }
23932
23716
  throw new YAMLException$1("expected a single document in the stream, but found more");
23933
23717
  }
23934
- function safeLoadAll(input, iterator, options2) {
23935
- if (typeof iterator === "object" && iterator !== null && typeof options2 === "undefined") {
23936
- options2 = iterator;
23937
- iterator = null;
23718
+ function safeLoadAll(input, iterator2, options2) {
23719
+ if (typeof iterator2 === "object" && iterator2 !== null && typeof options2 === "undefined") {
23720
+ options2 = iterator2;
23721
+ iterator2 = null;
23938
23722
  }
23939
- return loadAll(input, iterator, common$1.extend({ schema: DEFAULT_SAFE_SCHEMA$1 }, options2));
23723
+ return loadAll(input, iterator2, common$1.extend({ schema: DEFAULT_SAFE_SCHEMA$1 }, options2));
23940
23724
  }
23941
23725
  function safeLoad(input, options2) {
23942
23726
  return load(input, common$1.extend({ schema: DEFAULT_SAFE_SCHEMA$1 }, options2));
@@ -28968,6 +28752,250 @@ _enum([
28968
28752
  "published"
28969
28753
  ]).describe("Filter by publication status");
28970
28754
  string().describe("Search query string");
28755
+ const pluginName = "firebase-authentication";
28756
+ const PLUGIN_NAME = "firebase-authentication";
28757
+ const PLUGIN_UID = `plugin::${PLUGIN_NAME}`;
28758
+ const CONFIG_CONTENT_TYPE = `${PLUGIN_UID}.firebase-authentication-configuration`;
28759
+ const DEFAULT_PASSWORD_RESET_URL = "http://localhost:3000/reset-password";
28760
+ const DEFAULT_PASSWORD_REGEX = "^.{6,}$";
28761
+ const DEFAULT_PASSWORD_MESSAGE = "Password must be at least 6 characters long";
28762
+ const DEFAULT_RESET_EMAIL_SUBJECT = "Reset Your Password";
28763
+ const ERROR_MESSAGES = {
28764
+ FIREBASE_NOT_INITIALIZED: "Firebase is not initialized. Please upload Firebase service account configuration via Settings → Firebase Authentication.",
28765
+ INVALID_JSON: "Invalid JSON format. Please ensure you copied the entire JSON content correctly.",
28766
+ MISSING_DATA: "data is missing",
28767
+ SOMETHING_WENT_WRONG: "Something went wrong",
28768
+ AUTHENTICATION_FAILED: "Authentication failed",
28769
+ TOKEN_MISSING: "idToken is missing!",
28770
+ EMAIL_PASSWORD_REQUIRED: "Email and password are required",
28771
+ PASSWORD_REQUIRED: "Password is required",
28772
+ AUTHORIZATION_REQUIRED: "Authorization token is required",
28773
+ INVALID_TOKEN: "Invalid or expired token",
28774
+ USER_NOT_FOUND: "User not found",
28775
+ USER_NO_EMAIL: "User does not have an email address",
28776
+ FIREBASE_LINK_FAILED: "Failed to generate Firebase reset link",
28777
+ CONFIG_NOT_FOUND: "No config found",
28778
+ INVALID_SERVICE_ACCOUNT: "Invalid service account JSON",
28779
+ WEB_API_NOT_CONFIGURED: "Email/password authentication is not available. Web API Key is not configured.",
28780
+ RESET_URL_NOT_CONFIGURED: "Password reset URL is not configured",
28781
+ RESET_URL_MUST_BE_HTTPS: "Password reset URL must use HTTPS in production",
28782
+ RESET_URL_INVALID_FORMAT: "Password reset URL is not a valid URL format",
28783
+ USER_NOT_LINKED_FIREBASE: "User is not linked to Firebase authentication",
28784
+ OVERRIDE_USER_ID_REQUIRED: "Override user ID is required",
28785
+ EITHER_EMAIL_OR_PHONE_REQUIRED: "Either email or phoneNumber is required",
28786
+ DELETION_NO_CONFIG: "No Firebase configs exists for deletion"
28787
+ };
28788
+ const SUCCESS_MESSAGES = {
28789
+ FIREBASE_INITIALIZED: "Firebase successfully initialized",
28790
+ FIREBASE_CONFIG_DELETED: "Firebase config deleted and reinitialized",
28791
+ PASSWORD_RESET_EMAIL_SENT: "If an account with that email exists, a password reset link has been sent.",
28792
+ SERVER_RESTARTING: "SERVER IS RESTARTING"
28793
+ };
28794
+ const CONFIG_KEYS = {
28795
+ ENCRYPTION_KEY: `${PLUGIN_UID}.FIREBASE_JSON_ENCRYPTION_KEY`
28796
+ };
28797
+ const REQUIRED_FIELDS = {
28798
+ SERVICE_ACCOUNT: ["private_key", "client_email", "project_id", "type"],
28799
+ WEB_CONFIG: ["apiKey", "authDomain"]
28800
+ // These indicate wrong JSON type
28801
+ };
28802
+ const VALIDATION_MESSAGES = {
28803
+ INVALID_SERVICE_ACCOUNT: "Invalid Service Account JSON. Missing required fields:",
28804
+ WRONG_JSON_TYPE: "You uploaded a Web App Config (SDK snippet) instead of a Service Account JSON. Please go to Firebase Console → Service Accounts tab → Generate New Private Key to download the correct file.",
28805
+ SERVICE_ACCOUNT_HELP: "Please download the correct JSON from Firebase Console → Service Accounts → Generate New Private Key. Do NOT use the Web App Config (SDK snippet) - that is a different file!"
28806
+ };
28807
+ const firebaseController = {
28808
+ async validateToken(ctx) {
28809
+ strapi.log.debug("validateToken called");
28810
+ try {
28811
+ const { idToken, profileMetaData } = ctx.request.body || {};
28812
+ const populate2 = ctx.request.query.populate || [];
28813
+ if (!idToken) {
28814
+ return ctx.badRequest(ERROR_MESSAGES.TOKEN_MISSING);
28815
+ }
28816
+ const result = await strapi.plugin(pluginName).service("firebaseService").validateFirebaseToken(idToken, profileMetaData, populate2);
28817
+ ctx.body = result;
28818
+ } catch (error2) {
28819
+ strapi.log.error(`validateToken controller error: ${error2.message}`);
28820
+ if (error2.name === "ValidationError") {
28821
+ return ctx.badRequest(error2.message);
28822
+ }
28823
+ if (error2.name === "UnauthorizedError") {
28824
+ return ctx.unauthorized(error2.message);
28825
+ }
28826
+ throw error2;
28827
+ }
28828
+ },
28829
+ async deleteByEmail(email2) {
28830
+ try {
28831
+ const user = await strapi.firebase.auth().getUserByEmail(email2);
28832
+ await strapi.plugin(pluginName).service("firebaseService").delete(user.toJSON().uid);
28833
+ return user.toJSON();
28834
+ } catch (error2) {
28835
+ strapi.log.error("deleteByEmail error:", error2);
28836
+ throw error2;
28837
+ }
28838
+ },
28839
+ async overrideAccess(ctx) {
28840
+ try {
28841
+ const { overrideUserId } = ctx.request.body || {};
28842
+ const populate2 = ctx.request.query.populate || [];
28843
+ const result = await strapi.plugin(pluginName).service("firebaseService").overrideFirebaseAccess(overrideUserId, populate2);
28844
+ ctx.body = result;
28845
+ } catch (error2) {
28846
+ if (error2.name === "ValidationError") {
28847
+ return ctx.badRequest(error2.message);
28848
+ }
28849
+ if (error2.name === "NotFoundError") {
28850
+ return ctx.notFound(error2.message);
28851
+ }
28852
+ throw error2;
28853
+ }
28854
+ },
28855
+ /**
28856
+ * Controller method for email/password authentication
28857
+ * Handles the `/api/firebase-authentication/emailLogin` endpoint
28858
+ *
28859
+ * @param ctx - Koa context object
28860
+ * @returns Promise that sets ctx.body with user data and JWT or error message
28861
+ *
28862
+ * @remarks
28863
+ * This controller acts as a proxy to Firebase's Identity Toolkit API,
28864
+ * allowing users to authenticate with email/password and receive a Strapi JWT.
28865
+ *
28866
+ * HTTP Status Codes:
28867
+ * - `400`: Validation errors (missing credentials, invalid email/password)
28868
+ * - `500`: Server errors (missing configuration, Firebase API issues)
28869
+ */
28870
+ async emailLogin(ctx) {
28871
+ strapi.log.debug("emailLogin controller");
28872
+ try {
28873
+ const { email: email2, password } = ctx.request.body || {};
28874
+ const populate2 = ctx.request.query.populate || [];
28875
+ const result = await strapi.plugin(pluginName).service("firebaseService").emailLogin(email2, password, populate2);
28876
+ ctx.body = result;
28877
+ } catch (error2) {
28878
+ strapi.log.error("emailLogin controller error:", error2);
28879
+ throw error2;
28880
+ }
28881
+ },
28882
+ /**
28883
+ * Forgot password - sends reset email
28884
+ * POST /api/firebase-authentication/forgotPassword
28885
+ * Public endpoint - no authentication required
28886
+ */
28887
+ async forgotPassword(ctx) {
28888
+ strapi.log.debug("forgotPassword endpoint called");
28889
+ try {
28890
+ const { email: email2 } = ctx.request.body || {};
28891
+ ctx.body = await strapi.plugin(pluginName).service("firebaseService").forgotPassword(email2);
28892
+ } catch (error2) {
28893
+ strapi.log.error("forgotPassword controller error:", error2);
28894
+ throw error2;
28895
+ }
28896
+ },
28897
+ /**
28898
+ * Reset password - authenticated password change
28899
+ * POST /api/firebase-authentication/resetPassword
28900
+ * Authenticated endpoint - requires valid JWT (enforced by is-authenticated policy)
28901
+ * Used for admin-initiated resets or user self-service password changes
28902
+ * NOT used for forgot password email flow (which uses Firebase's hosted UI)
28903
+ */
28904
+ async resetPassword(ctx) {
28905
+ strapi.log.debug("resetPassword endpoint called");
28906
+ try {
28907
+ const { password } = ctx.request.body || {};
28908
+ const user = ctx.state.user;
28909
+ const populate2 = ctx.request.query.populate || [];
28910
+ ctx.body = await strapi.plugin(pluginName).service("firebaseService").resetPassword(password, user, populate2);
28911
+ } catch (error2) {
28912
+ strapi.log.error("resetPassword controller error:", error2);
28913
+ throw error2;
28914
+ }
28915
+ },
28916
+ async requestMagicLink(ctx) {
28917
+ try {
28918
+ const { email: email2 } = ctx.request.body || {};
28919
+ const result = await strapi.plugin("firebase-authentication").service("firebaseService").requestMagicLink(email2);
28920
+ ctx.body = result;
28921
+ } catch (error2) {
28922
+ if (error2.name === "ValidationError" || error2.name === "ApplicationError") {
28923
+ throw error2;
28924
+ }
28925
+ strapi.log.error("requestMagicLink controller error:", error2);
28926
+ ctx.body = {
28927
+ success: false,
28928
+ message: "An error occurred while processing your request"
28929
+ };
28930
+ }
28931
+ },
28932
+ /**
28933
+ * Reset password using custom JWT token
28934
+ * POST /api/firebase-authentication/resetPasswordWithToken
28935
+ * Public endpoint - token provides authentication
28936
+ *
28937
+ * @param ctx - Koa context with { token, newPassword } in body
28938
+ * @returns { success: true, message: "Password has been reset successfully" }
28939
+ */
28940
+ async resetPasswordWithToken(ctx) {
28941
+ strapi.log.debug("resetPasswordWithToken endpoint called");
28942
+ try {
28943
+ const { token, newPassword } = ctx.request.body || {};
28944
+ if (!token) {
28945
+ throw new ValidationError$1("Token is required");
28946
+ }
28947
+ if (!newPassword) {
28948
+ throw new ValidationError$1("New password is required");
28949
+ }
28950
+ const result = await strapi.plugin(pluginName).service("userService").resetPasswordWithToken(token, newPassword);
28951
+ ctx.body = result;
28952
+ } catch (error2) {
28953
+ strapi.log.error("resetPasswordWithToken controller error:", error2);
28954
+ throw error2;
28955
+ }
28956
+ },
28957
+ /**
28958
+ * Send email verification - public endpoint
28959
+ * POST /api/firebase-authentication/sendVerificationEmail
28960
+ * Authenticated endpoint - sends verification email to the logged-in user's email
28961
+ */
28962
+ async sendVerificationEmail(ctx) {
28963
+ strapi.log.debug("sendVerificationEmail endpoint called");
28964
+ try {
28965
+ const user = ctx.state.user;
28966
+ const email2 = user.email;
28967
+ ctx.body = await strapi.plugin(pluginName).service("firebaseService").sendVerificationEmail(email2);
28968
+ } catch (error2) {
28969
+ strapi.log.error("sendVerificationEmail controller error:", error2);
28970
+ throw error2;
28971
+ }
28972
+ },
28973
+ /**
28974
+ * Verify email using custom JWT token
28975
+ * POST /api/firebase-authentication/verifyEmail
28976
+ * Public endpoint - token provides authentication
28977
+ *
28978
+ * @param ctx - Koa context with { token } in body
28979
+ * @returns { success: true, message: "Email verified successfully" }
28980
+ */
28981
+ async verifyEmail(ctx) {
28982
+ strapi.log.debug("verifyEmail endpoint called");
28983
+ try {
28984
+ const { token } = ctx.request.body || {};
28985
+ if (!token) {
28986
+ return ctx.badRequest("Token is required");
28987
+ }
28988
+ const result = await strapi.plugin(pluginName).service("firebaseService").verifyEmail(token);
28989
+ ctx.body = result;
28990
+ } catch (error2) {
28991
+ strapi.log.error("verifyEmail controller error:", error2);
28992
+ if (error2.name === "ValidationError") {
28993
+ return ctx.badRequest(error2.message);
28994
+ }
28995
+ throw error2;
28996
+ }
28997
+ }
28998
+ };
28971
28999
  const STRAPI_DESTINATION = "strapi";
28972
29000
  const FIREBASE_DESTINATION = "firebase";
28973
29001
  const userController = {
@@ -29229,7 +29257,16 @@ const controllers = {
29229
29257
  settingsController
29230
29258
  };
29231
29259
  const middlewares = {};
29232
- const policies = {};
29260
+ const isAuthenticated = async (policyContext) => {
29261
+ const user = policyContext.state.user;
29262
+ if (!user) {
29263
+ throw new UnauthorizedError("Authentication required");
29264
+ }
29265
+ return true;
29266
+ };
29267
+ const policies = {
29268
+ "is-authenticated": isAuthenticated
29269
+ };
29233
29270
  const settingsRoute = [
29234
29271
  {
29235
29272
  method: "POST",
@@ -29379,9 +29416,7 @@ const contentApi = {
29379
29416
  path: "/resetPassword",
29380
29417
  handler: "firebaseController.resetPassword",
29381
29418
  config: {
29382
- auth: false,
29383
- // Public endpoint - authenticated password change, requires valid JWT in Authorization header
29384
- policies: []
29419
+ policies: ["plugin::firebase-authentication.is-authenticated"]
29385
29420
  }
29386
29421
  },
29387
29422
  {
@@ -29419,9 +29454,7 @@ const contentApi = {
29419
29454
  path: "/sendVerificationEmail",
29420
29455
  handler: "firebaseController.sendVerificationEmail",
29421
29456
  config: {
29422
- auth: false,
29423
- // Public endpoint - sends email verification link
29424
- policies: []
29457
+ policies: ["plugin::firebase-authentication.is-authenticated"]
29425
29458
  }
29426
29459
  },
29427
29460
  {
@@ -30930,20 +30963,17 @@ const firebaseService = ({ strapi: strapi2 }) => ({
30930
30963
  * 2. User-initiated password change (when already authenticated)
30931
30964
  *
30932
30965
  * NOT used for forgot password email flow - that now uses Firebase's hosted UI
30966
+ *
30967
+ * @param password - New password to set
30968
+ * @param user - Authenticated user from ctx.state.user (populated by is-authenticated policy)
30969
+ * @param populate - Fields to populate in response
30933
30970
  */
30934
- resetPassword: async (password, token, populate2) => {
30971
+ resetPassword: async (password, user, populate2) => {
30935
30972
  if (!password) {
30936
30973
  throw new ValidationError$1("Password is required");
30937
30974
  }
30938
- if (!token) {
30939
- throw new UnauthorizedError("Authorization token is required");
30940
- }
30941
- let decoded;
30942
- try {
30943
- const jwtService = strapi2.plugin("users-permissions").service("jwt");
30944
- decoded = await jwtService.verify(token);
30945
- } catch (error2) {
30946
- throw new UnauthorizedError("Invalid or expired token");
30975
+ if (!user || !user.id) {
30976
+ throw new UnauthorizedError("Authentication required");
30947
30977
  }
30948
30978
  const config2 = await strapi2.plugin("firebase-authentication").service("settingsService").getFirebaseConfigJson();
30949
30979
  const passwordRegex = config2?.passwordRequirementsRegex || "^.{6,}$";
@@ -30954,8 +30984,7 @@ const firebaseService = ({ strapi: strapi2 }) => ({
30954
30984
  }
30955
30985
  try {
30956
30986
  const strapiUser = await strapi2.db.query("plugin::users-permissions.user").findOne({
30957
- where: { id: decoded.id }
30958
- // Use numeric id from JWT
30987
+ where: { id: user.id }
30959
30988
  });
30960
30989
  if (!strapiUser) {
30961
30990
  throw new NotFoundError("User not found");
@@ -31158,6 +31187,22 @@ const firebaseService = ({ strapi: strapi2 }) => ({
31158
31187
  const tokenService2 = strapi2.plugin("firebase-authentication").service("tokenService");
31159
31188
  const validationResult = await tokenService2.validateVerificationToken(token);
31160
31189
  if (!validationResult.valid) {
31190
+ if (validationResult.code === "TOKEN_ALREADY_USED" && validationResult.firebaseUID) {
31191
+ try {
31192
+ const firebaseUser = await strapi2.firebase.auth().getUser(validationResult.firebaseUID);
31193
+ if (firebaseUser.emailVerified) {
31194
+ strapi2.log.info(
31195
+ `[verifyEmail] Token already used but email is verified for: ${firebaseUser.email}`
31196
+ );
31197
+ return {
31198
+ success: true,
31199
+ message: "This email has already been verified."
31200
+ };
31201
+ }
31202
+ } catch (checkError) {
31203
+ strapi2.log.warn(`[verifyEmail] Could not verify Firebase user status: ${checkError.message}`);
31204
+ }
31205
+ }
31161
31206
  strapi2.log.warn(`[verifyEmail] Token validation failed: ${validationResult.error}`);
31162
31207
  throw new ValidationError$1(validationResult.error || "Invalid verification link");
31163
31208
  }
@@ -32617,7 +32662,7 @@ var TokenExpiredError_1 = TokenExpiredError$1;
32617
32662
  var jws$3 = {};
32618
32663
  var safeBuffer = { exports: {} };
32619
32664
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
32620
- (function(module2, exports2) {
32665
+ (function(module2, exports$1) {
32621
32666
  var buffer = require$$0__default$5.default;
32622
32667
  var Buffer2 = buffer.Buffer;
32623
32668
  function copyProps(src, dst) {
@@ -32628,8 +32673,8 @@ var safeBuffer = { exports: {} };
32628
32673
  if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
32629
32674
  module2.exports = buffer;
32630
32675
  } else {
32631
- copyProps(buffer, exports2);
32632
- exports2.Buffer = SafeBuffer;
32676
+ copyProps(buffer, exports$1);
32677
+ exports$1.Buffer = SafeBuffer;
32633
32678
  }
32634
32679
  function SafeBuffer(arg, encodingOrOffset, length) {
32635
32680
  return Buffer2(arg, encodingOrOffset, length);
@@ -33144,7 +33189,12 @@ function jwsSign(opts) {
33144
33189
  return util$1.format("%s.%s", securedInput, signature);
33145
33190
  }
33146
33191
  function SignStream$1(opts) {
33147
- var secret = opts.secret || opts.privateKey || opts.key;
33192
+ var secret = opts.secret;
33193
+ secret = secret == null ? opts.privateKey : secret;
33194
+ secret = secret == null ? opts.key : secret;
33195
+ if (/^hs/i.test(opts.header.alg) === true && secret == null) {
33196
+ throw new TypeError("secret must be a string or buffer or a KeyObject");
33197
+ }
33148
33198
  var secretStream = new DataStream$1(secret);
33149
33199
  this.readable = true;
33150
33200
  this.header = opts.header;
@@ -33250,7 +33300,12 @@ function jwsDecode(jwsSig, opts) {
33250
33300
  }
33251
33301
  function VerifyStream$1(opts) {
33252
33302
  opts = opts || {};
33253
- var secretOrKey = opts.secret || opts.publicKey || opts.key;
33303
+ var secretOrKey = opts.secret;
33304
+ secretOrKey = secretOrKey == null ? opts.publicKey : secretOrKey;
33305
+ secretOrKey = secretOrKey == null ? opts.key : secretOrKey;
33306
+ if (/^hs/i.test(opts.algorithm) === true && secretOrKey == null) {
33307
+ throw new TypeError("secret must be a string or buffer or a KeyObject");
33308
+ }
33254
33309
  var secretStream = new DataStream(secretOrKey);
33255
33310
  this.readable = true;
33256
33311
  this.algorithm = opts.algorithm;
@@ -33493,19 +33548,18 @@ var constants$1 = {
33493
33548
  const debug$1 = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
33494
33549
  };
33495
33550
  var debug_1 = debug$1;
33496
- (function(module2, exports2) {
33551
+ (function(module2, exports$1) {
33497
33552
  const {
33498
33553
  MAX_SAFE_COMPONENT_LENGTH: MAX_SAFE_COMPONENT_LENGTH2,
33499
33554
  MAX_SAFE_BUILD_LENGTH: MAX_SAFE_BUILD_LENGTH2,
33500
33555
  MAX_LENGTH: MAX_LENGTH2
33501
33556
  } = constants$1;
33502
33557
  const debug2 = debug_1;
33503
- exports2 = module2.exports = {};
33504
- const re2 = exports2.re = [];
33505
- const safeRe = exports2.safeRe = [];
33506
- const src = exports2.src = [];
33507
- const safeSrc = exports2.safeSrc = [];
33508
- const t2 = exports2.t = {};
33558
+ exports$1 = module2.exports = {};
33559
+ const re2 = exports$1.re = [];
33560
+ const safeRe = exports$1.safeRe = [];
33561
+ const src = exports$1.src = [];
33562
+ const t2 = exports$1.t = {};
33509
33563
  let R = 0;
33510
33564
  const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
33511
33565
  const safeRegexReplacements = [
@@ -33525,7 +33579,6 @@ var debug_1 = debug$1;
33525
33579
  debug2(name, index2, value);
33526
33580
  t2[name] = index2;
33527
33581
  src[index2] = value;
33528
- safeSrc[index2] = safe;
33529
33582
  re2[index2] = new RegExp(value, isGlobal ? "g" : void 0);
33530
33583
  safeRe[index2] = new RegExp(safe, isGlobal ? "g" : void 0);
33531
33584
  };
@@ -33534,8 +33587,8 @@ var debug_1 = debug$1;
33534
33587
  createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
33535
33588
  createToken("MAINVERSION", `(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})`);
33536
33589
  createToken("MAINVERSIONLOOSE", `(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})`);
33537
- createToken("PRERELEASEIDENTIFIER", `(?:${src[t2.NONNUMERICIDENTIFIER]}|${src[t2.NUMERICIDENTIFIER]})`);
33538
- createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t2.NONNUMERICIDENTIFIER]}|${src[t2.NUMERICIDENTIFIERLOOSE]})`);
33590
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t2.NUMERICIDENTIFIER]}|${src[t2.NONNUMERICIDENTIFIER]})`);
33591
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t2.NUMERICIDENTIFIERLOOSE]}|${src[t2.NONNUMERICIDENTIFIER]})`);
33539
33592
  createToken("PRERELEASE", `(?:-(${src[t2.PRERELEASEIDENTIFIER]}(?:\\.${src[t2.PRERELEASEIDENTIFIER]})*))`);
33540
33593
  createToken("PRERELEASELOOSE", `(?:-?(${src[t2.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t2.PRERELEASEIDENTIFIERLOOSE]})*))`);
33541
33594
  createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
@@ -33551,25 +33604,22 @@ var debug_1 = debug$1;
33551
33604
  createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:${src[t2.PRERELEASELOOSE]})?${src[t2.BUILD]}?)?)?`);
33552
33605
  createToken("XRANGE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAIN]}$`);
33553
33606
  createToken("XRANGELOOSE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAINLOOSE]}$`);
33554
- createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH2}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?`);
33555
- createToken("COERCE", `${src[t2.COERCEPLAIN]}(?:$|[^\\d])`);
33556
- createToken("COERCEFULL", src[t2.COERCEPLAIN] + `(?:${src[t2.PRERELEASE]})?(?:${src[t2.BUILD]})?(?:$|[^\\d])`);
33607
+ createToken("COERCE", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH2}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?(?:$|[^\\d])`);
33557
33608
  createToken("COERCERTL", src[t2.COERCE], true);
33558
- createToken("COERCERTLFULL", src[t2.COERCEFULL], true);
33559
33609
  createToken("LONETILDE", "(?:~>?)");
33560
33610
  createToken("TILDETRIM", `(\\s*)${src[t2.LONETILDE]}\\s+`, true);
33561
- exports2.tildeTrimReplace = "$1~";
33611
+ exports$1.tildeTrimReplace = "$1~";
33562
33612
  createToken("TILDE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAIN]}$`);
33563
33613
  createToken("TILDELOOSE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAINLOOSE]}$`);
33564
33614
  createToken("LONECARET", "(?:\\^)");
33565
33615
  createToken("CARETTRIM", `(\\s*)${src[t2.LONECARET]}\\s+`, true);
33566
- exports2.caretTrimReplace = "$1^";
33616
+ exports$1.caretTrimReplace = "$1^";
33567
33617
  createToken("CARET", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAIN]}$`);
33568
33618
  createToken("CARETLOOSE", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAINLOOSE]}$`);
33569
33619
  createToken("COMPARATORLOOSE", `^${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]})$|^$`);
33570
33620
  createToken("COMPARATOR", `^${src[t2.GTLT]}\\s*(${src[t2.FULLPLAIN]})$|^$`);
33571
33621
  createToken("COMPARATORTRIM", `(\\s*)${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]}|${src[t2.XRANGEPLAIN]})`, true);
33572
- exports2.comparatorTrimReplace = "$1$2$3";
33622
+ exports$1.comparatorTrimReplace = "$1$2$3";
33573
33623
  createToken("HYPHENRANGE", `^\\s*(${src[t2.XRANGEPLAIN]})\\s+-\\s+(${src[t2.XRANGEPLAIN]})\\s*$`);
33574
33624
  createToken("HYPHENRANGELOOSE", `^\\s*(${src[t2.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t2.XRANGEPLAINLOOSE]})\\s*$`);
33575
33625
  createToken("STAR", "(<|>)?=?\\s*\\*");
@@ -33591,9 +33641,6 @@ const parseOptions$1 = (options2) => {
33591
33641
  var parseOptions_1 = parseOptions$1;
33592
33642
  const numeric = /^[0-9]+$/;
33593
33643
  const compareIdentifiers$1 = (a, b) => {
33594
- if (typeof a === "number" && typeof b === "number") {
33595
- return a === b ? 0 : a < b ? -1 : 1;
33596
- }
33597
33644
  const anum = numeric.test(a);
33598
33645
  const bnum = numeric.test(b);
33599
33646
  if (anum && bnum) {
@@ -33693,25 +33740,7 @@ let SemVer$d = class SemVer {
33693
33740
  if (!(other instanceof SemVer)) {
33694
33741
  other = new SemVer(other, this.options);
33695
33742
  }
33696
- if (this.major < other.major) {
33697
- return -1;
33698
- }
33699
- if (this.major > other.major) {
33700
- return 1;
33701
- }
33702
- if (this.minor < other.minor) {
33703
- return -1;
33704
- }
33705
- if (this.minor > other.minor) {
33706
- return 1;
33707
- }
33708
- if (this.patch < other.patch) {
33709
- return -1;
33710
- }
33711
- if (this.patch > other.patch) {
33712
- return 1;
33713
- }
33714
- return 0;
33743
+ return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
33715
33744
  }
33716
33745
  comparePre(other) {
33717
33746
  if (!(other instanceof SemVer)) {
@@ -33750,7 +33779,7 @@ let SemVer$d = class SemVer {
33750
33779
  do {
33751
33780
  const a = this.build[i];
33752
33781
  const b = other.build[i];
33753
- debug("build compare", i, a, b);
33782
+ debug("prerelease compare", i, a, b);
33754
33783
  if (a === void 0 && b === void 0) {
33755
33784
  return 0;
33756
33785
  } else if (b === void 0) {
@@ -33767,17 +33796,6 @@ let SemVer$d = class SemVer {
33767
33796
  // preminor will bump the version up to the next minor release, and immediately
33768
33797
  // down to pre-release. premajor and prepatch work the same way.
33769
33798
  inc(release, identifier, identifierBase) {
33770
- if (release.startsWith("pre")) {
33771
- if (!identifier && identifierBase === false) {
33772
- throw new Error("invalid increment argument: identifier is empty");
33773
- }
33774
- if (identifier) {
33775
- const match = `-${identifier}`.match(this.options.loose ? re$1[t$1.PRERELEASELOOSE] : re$1[t$1.PRERELEASE]);
33776
- if (!match || match[1] !== identifier) {
33777
- throw new Error(`invalid identifier: ${identifier}`);
33778
- }
33779
- }
33780
- }
33781
33799
  switch (release) {
33782
33800
  case "premajor":
33783
33801
  this.prerelease.length = 0;
@@ -33803,12 +33821,6 @@ let SemVer$d = class SemVer {
33803
33821
  }
33804
33822
  this.inc("pre", identifier, identifierBase);
33805
33823
  break;
33806
- case "release":
33807
- if (this.prerelease.length === 0) {
33808
- throw new Error(`version ${this.raw} is not a prerelease`);
33809
- }
33810
- this.prerelease.length = 0;
33811
- break;
33812
33824
  case "major":
33813
33825
  if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
33814
33826
  this.major++;
@@ -33832,6 +33844,9 @@ let SemVer$d = class SemVer {
33832
33844
  break;
33833
33845
  case "pre": {
33834
33846
  const base = Number(identifierBase) ? 1 : 0;
33847
+ if (!identifier && identifierBase === false) {
33848
+ throw new Error("invalid increment argument: identifier is empty");
33849
+ }
33835
33850
  if (this.prerelease.length === 0) {
33836
33851
  this.prerelease = [base];
33837
33852
  } else {
@@ -33936,12 +33951,13 @@ const diff$1 = (version1, version2) => {
33936
33951
  if (!lowVersion.patch && !lowVersion.minor) {
33937
33952
  return "major";
33938
33953
  }
33939
- if (lowVersion.compareMain(highVersion) === 0) {
33940
- if (lowVersion.minor && !lowVersion.patch) {
33941
- return "minor";
33942
- }
33954
+ if (highVersion.patch) {
33943
33955
  return "patch";
33944
33956
  }
33957
+ if (highVersion.minor) {
33958
+ return "minor";
33959
+ }
33960
+ return "major";
33945
33961
  }
33946
33962
  const prefix = highHasPre ? "pre" : "";
33947
33963
  if (v1.major !== v2.major) {
@@ -34070,66 +34086,666 @@ const coerce$1 = (version2, options2) => {
34070
34086
  options2 = options2 || {};
34071
34087
  let match = null;
34072
34088
  if (!options2.rtl) {
34073
- match = version2.match(options2.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
34089
+ match = version2.match(re[t.COERCE]);
34074
34090
  } else {
34075
- const coerceRtlRegex = options2.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
34076
34091
  let next;
34077
- while ((next = coerceRtlRegex.exec(version2)) && (!match || match.index + match[0].length !== version2.length)) {
34092
+ while ((next = re[t.COERCERTL].exec(version2)) && (!match || match.index + match[0].length !== version2.length)) {
34078
34093
  if (!match || next.index + next[0].length !== match.index + match[0].length) {
34079
34094
  match = next;
34080
34095
  }
34081
- coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
34096
+ re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
34082
34097
  }
34083
- coerceRtlRegex.lastIndex = -1;
34098
+ re[t.COERCERTL].lastIndex = -1;
34084
34099
  }
34085
34100
  if (match === null) {
34086
34101
  return null;
34087
34102
  }
34088
- const major2 = match[2];
34089
- const minor2 = match[3] || "0";
34090
- const patch2 = match[4] || "0";
34091
- const prerelease2 = options2.includePrerelease && match[5] ? `-${match[5]}` : "";
34092
- const build = options2.includePrerelease && match[6] ? `+${match[6]}` : "";
34093
- return parse$1(`${major2}.${minor2}.${patch2}${prerelease2}${build}`, options2);
34103
+ return parse$1(`${match[2]}.${match[3] || "0"}.${match[4] || "0"}`, options2);
34094
34104
  };
34095
34105
  var coerce_1 = coerce$1;
34106
+ var iterator;
34107
+ var hasRequiredIterator;
34108
+ function requireIterator() {
34109
+ if (hasRequiredIterator) return iterator;
34110
+ hasRequiredIterator = 1;
34111
+ iterator = function(Yallist2) {
34112
+ Yallist2.prototype[Symbol.iterator] = function* () {
34113
+ for (let walker = this.head; walker; walker = walker.next) {
34114
+ yield walker.value;
34115
+ }
34116
+ };
34117
+ };
34118
+ return iterator;
34119
+ }
34120
+ var yallist = Yallist$1;
34121
+ Yallist$1.Node = Node2;
34122
+ Yallist$1.create = Yallist$1;
34123
+ function Yallist$1(list) {
34124
+ var self2 = this;
34125
+ if (!(self2 instanceof Yallist$1)) {
34126
+ self2 = new Yallist$1();
34127
+ }
34128
+ self2.tail = null;
34129
+ self2.head = null;
34130
+ self2.length = 0;
34131
+ if (list && typeof list.forEach === "function") {
34132
+ list.forEach(function(item) {
34133
+ self2.push(item);
34134
+ });
34135
+ } else if (arguments.length > 0) {
34136
+ for (var i = 0, l = arguments.length; i < l; i++) {
34137
+ self2.push(arguments[i]);
34138
+ }
34139
+ }
34140
+ return self2;
34141
+ }
34142
+ Yallist$1.prototype.removeNode = function(node) {
34143
+ if (node.list !== this) {
34144
+ throw new Error("removing node which does not belong to this list");
34145
+ }
34146
+ var next = node.next;
34147
+ var prev = node.prev;
34148
+ if (next) {
34149
+ next.prev = prev;
34150
+ }
34151
+ if (prev) {
34152
+ prev.next = next;
34153
+ }
34154
+ if (node === this.head) {
34155
+ this.head = next;
34156
+ }
34157
+ if (node === this.tail) {
34158
+ this.tail = prev;
34159
+ }
34160
+ node.list.length--;
34161
+ node.next = null;
34162
+ node.prev = null;
34163
+ node.list = null;
34164
+ return next;
34165
+ };
34166
+ Yallist$1.prototype.unshiftNode = function(node) {
34167
+ if (node === this.head) {
34168
+ return;
34169
+ }
34170
+ if (node.list) {
34171
+ node.list.removeNode(node);
34172
+ }
34173
+ var head = this.head;
34174
+ node.list = this;
34175
+ node.next = head;
34176
+ if (head) {
34177
+ head.prev = node;
34178
+ }
34179
+ this.head = node;
34180
+ if (!this.tail) {
34181
+ this.tail = node;
34182
+ }
34183
+ this.length++;
34184
+ };
34185
+ Yallist$1.prototype.pushNode = function(node) {
34186
+ if (node === this.tail) {
34187
+ return;
34188
+ }
34189
+ if (node.list) {
34190
+ node.list.removeNode(node);
34191
+ }
34192
+ var tail = this.tail;
34193
+ node.list = this;
34194
+ node.prev = tail;
34195
+ if (tail) {
34196
+ tail.next = node;
34197
+ }
34198
+ this.tail = node;
34199
+ if (!this.head) {
34200
+ this.head = node;
34201
+ }
34202
+ this.length++;
34203
+ };
34204
+ Yallist$1.prototype.push = function() {
34205
+ for (var i = 0, l = arguments.length; i < l; i++) {
34206
+ push(this, arguments[i]);
34207
+ }
34208
+ return this.length;
34209
+ };
34210
+ Yallist$1.prototype.unshift = function() {
34211
+ for (var i = 0, l = arguments.length; i < l; i++) {
34212
+ unshift(this, arguments[i]);
34213
+ }
34214
+ return this.length;
34215
+ };
34216
+ Yallist$1.prototype.pop = function() {
34217
+ if (!this.tail) {
34218
+ return void 0;
34219
+ }
34220
+ var res = this.tail.value;
34221
+ this.tail = this.tail.prev;
34222
+ if (this.tail) {
34223
+ this.tail.next = null;
34224
+ } else {
34225
+ this.head = null;
34226
+ }
34227
+ this.length--;
34228
+ return res;
34229
+ };
34230
+ Yallist$1.prototype.shift = function() {
34231
+ if (!this.head) {
34232
+ return void 0;
34233
+ }
34234
+ var res = this.head.value;
34235
+ this.head = this.head.next;
34236
+ if (this.head) {
34237
+ this.head.prev = null;
34238
+ } else {
34239
+ this.tail = null;
34240
+ }
34241
+ this.length--;
34242
+ return res;
34243
+ };
34244
+ Yallist$1.prototype.forEach = function(fn, thisp) {
34245
+ thisp = thisp || this;
34246
+ for (var walker = this.head, i = 0; walker !== null; i++) {
34247
+ fn.call(thisp, walker.value, i, this);
34248
+ walker = walker.next;
34249
+ }
34250
+ };
34251
+ Yallist$1.prototype.forEachReverse = function(fn, thisp) {
34252
+ thisp = thisp || this;
34253
+ for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
34254
+ fn.call(thisp, walker.value, i, this);
34255
+ walker = walker.prev;
34256
+ }
34257
+ };
34258
+ Yallist$1.prototype.get = function(n) {
34259
+ for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
34260
+ walker = walker.next;
34261
+ }
34262
+ if (i === n && walker !== null) {
34263
+ return walker.value;
34264
+ }
34265
+ };
34266
+ Yallist$1.prototype.getReverse = function(n) {
34267
+ for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
34268
+ walker = walker.prev;
34269
+ }
34270
+ if (i === n && walker !== null) {
34271
+ return walker.value;
34272
+ }
34273
+ };
34274
+ Yallist$1.prototype.map = function(fn, thisp) {
34275
+ thisp = thisp || this;
34276
+ var res = new Yallist$1();
34277
+ for (var walker = this.head; walker !== null; ) {
34278
+ res.push(fn.call(thisp, walker.value, this));
34279
+ walker = walker.next;
34280
+ }
34281
+ return res;
34282
+ };
34283
+ Yallist$1.prototype.mapReverse = function(fn, thisp) {
34284
+ thisp = thisp || this;
34285
+ var res = new Yallist$1();
34286
+ for (var walker = this.tail; walker !== null; ) {
34287
+ res.push(fn.call(thisp, walker.value, this));
34288
+ walker = walker.prev;
34289
+ }
34290
+ return res;
34291
+ };
34292
+ Yallist$1.prototype.reduce = function(fn, initial) {
34293
+ var acc;
34294
+ var walker = this.head;
34295
+ if (arguments.length > 1) {
34296
+ acc = initial;
34297
+ } else if (this.head) {
34298
+ walker = this.head.next;
34299
+ acc = this.head.value;
34300
+ } else {
34301
+ throw new TypeError("Reduce of empty list with no initial value");
34302
+ }
34303
+ for (var i = 0; walker !== null; i++) {
34304
+ acc = fn(acc, walker.value, i);
34305
+ walker = walker.next;
34306
+ }
34307
+ return acc;
34308
+ };
34309
+ Yallist$1.prototype.reduceReverse = function(fn, initial) {
34310
+ var acc;
34311
+ var walker = this.tail;
34312
+ if (arguments.length > 1) {
34313
+ acc = initial;
34314
+ } else if (this.tail) {
34315
+ walker = this.tail.prev;
34316
+ acc = this.tail.value;
34317
+ } else {
34318
+ throw new TypeError("Reduce of empty list with no initial value");
34319
+ }
34320
+ for (var i = this.length - 1; walker !== null; i--) {
34321
+ acc = fn(acc, walker.value, i);
34322
+ walker = walker.prev;
34323
+ }
34324
+ return acc;
34325
+ };
34326
+ Yallist$1.prototype.toArray = function() {
34327
+ var arr = new Array(this.length);
34328
+ for (var i = 0, walker = this.head; walker !== null; i++) {
34329
+ arr[i] = walker.value;
34330
+ walker = walker.next;
34331
+ }
34332
+ return arr;
34333
+ };
34334
+ Yallist$1.prototype.toArrayReverse = function() {
34335
+ var arr = new Array(this.length);
34336
+ for (var i = 0, walker = this.tail; walker !== null; i++) {
34337
+ arr[i] = walker.value;
34338
+ walker = walker.prev;
34339
+ }
34340
+ return arr;
34341
+ };
34342
+ Yallist$1.prototype.slice = function(from, to) {
34343
+ to = to || this.length;
34344
+ if (to < 0) {
34345
+ to += this.length;
34346
+ }
34347
+ from = from || 0;
34348
+ if (from < 0) {
34349
+ from += this.length;
34350
+ }
34351
+ var ret = new Yallist$1();
34352
+ if (to < from || to < 0) {
34353
+ return ret;
34354
+ }
34355
+ if (from < 0) {
34356
+ from = 0;
34357
+ }
34358
+ if (to > this.length) {
34359
+ to = this.length;
34360
+ }
34361
+ for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
34362
+ walker = walker.next;
34363
+ }
34364
+ for (; walker !== null && i < to; i++, walker = walker.next) {
34365
+ ret.push(walker.value);
34366
+ }
34367
+ return ret;
34368
+ };
34369
+ Yallist$1.prototype.sliceReverse = function(from, to) {
34370
+ to = to || this.length;
34371
+ if (to < 0) {
34372
+ to += this.length;
34373
+ }
34374
+ from = from || 0;
34375
+ if (from < 0) {
34376
+ from += this.length;
34377
+ }
34378
+ var ret = new Yallist$1();
34379
+ if (to < from || to < 0) {
34380
+ return ret;
34381
+ }
34382
+ if (from < 0) {
34383
+ from = 0;
34384
+ }
34385
+ if (to > this.length) {
34386
+ to = this.length;
34387
+ }
34388
+ for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
34389
+ walker = walker.prev;
34390
+ }
34391
+ for (; walker !== null && i > from; i--, walker = walker.prev) {
34392
+ ret.push(walker.value);
34393
+ }
34394
+ return ret;
34395
+ };
34396
+ Yallist$1.prototype.splice = function(start, deleteCount, ...nodes) {
34397
+ if (start > this.length) {
34398
+ start = this.length - 1;
34399
+ }
34400
+ if (start < 0) {
34401
+ start = this.length + start;
34402
+ }
34403
+ for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
34404
+ walker = walker.next;
34405
+ }
34406
+ var ret = [];
34407
+ for (var i = 0; walker && i < deleteCount; i++) {
34408
+ ret.push(walker.value);
34409
+ walker = this.removeNode(walker);
34410
+ }
34411
+ if (walker === null) {
34412
+ walker = this.tail;
34413
+ }
34414
+ if (walker !== this.head && walker !== this.tail) {
34415
+ walker = walker.prev;
34416
+ }
34417
+ for (var i = 0; i < nodes.length; i++) {
34418
+ walker = insert(this, walker, nodes[i]);
34419
+ }
34420
+ return ret;
34421
+ };
34422
+ Yallist$1.prototype.reverse = function() {
34423
+ var head = this.head;
34424
+ var tail = this.tail;
34425
+ for (var walker = head; walker !== null; walker = walker.prev) {
34426
+ var p = walker.prev;
34427
+ walker.prev = walker.next;
34428
+ walker.next = p;
34429
+ }
34430
+ this.head = tail;
34431
+ this.tail = head;
34432
+ return this;
34433
+ };
34434
+ function insert(self2, node, value) {
34435
+ var inserted = node === self2.head ? new Node2(value, null, node, self2) : new Node2(value, node, node.next, self2);
34436
+ if (inserted.next === null) {
34437
+ self2.tail = inserted;
34438
+ }
34439
+ if (inserted.prev === null) {
34440
+ self2.head = inserted;
34441
+ }
34442
+ self2.length++;
34443
+ return inserted;
34444
+ }
34445
+ function push(self2, item) {
34446
+ self2.tail = new Node2(item, self2.tail, null, self2);
34447
+ if (!self2.head) {
34448
+ self2.head = self2.tail;
34449
+ }
34450
+ self2.length++;
34451
+ }
34452
+ function unshift(self2, item) {
34453
+ self2.head = new Node2(item, null, self2.head, self2);
34454
+ if (!self2.tail) {
34455
+ self2.tail = self2.head;
34456
+ }
34457
+ self2.length++;
34458
+ }
34459
+ function Node2(value, prev, next, list) {
34460
+ if (!(this instanceof Node2)) {
34461
+ return new Node2(value, prev, next, list);
34462
+ }
34463
+ this.list = list;
34464
+ this.value = value;
34465
+ if (prev) {
34466
+ prev.next = this;
34467
+ this.prev = prev;
34468
+ } else {
34469
+ this.prev = null;
34470
+ }
34471
+ if (next) {
34472
+ next.prev = this;
34473
+ this.next = next;
34474
+ } else {
34475
+ this.next = null;
34476
+ }
34477
+ }
34478
+ try {
34479
+ requireIterator()(Yallist$1);
34480
+ } catch (er) {
34481
+ }
34482
+ const Yallist = yallist;
34483
+ const MAX = Symbol("max");
34484
+ const LENGTH = Symbol("length");
34485
+ const LENGTH_CALCULATOR = Symbol("lengthCalculator");
34486
+ const ALLOW_STALE = Symbol("allowStale");
34487
+ const MAX_AGE = Symbol("maxAge");
34488
+ const DISPOSE = Symbol("dispose");
34489
+ const NO_DISPOSE_ON_SET = Symbol("noDisposeOnSet");
34490
+ const LRU_LIST = Symbol("lruList");
34491
+ const CACHE = Symbol("cache");
34492
+ const UPDATE_AGE_ON_GET = Symbol("updateAgeOnGet");
34493
+ const naiveLength = () => 1;
34096
34494
  class LRUCache {
34097
- constructor() {
34098
- this.max = 1e3;
34099
- this.map = /* @__PURE__ */ new Map();
34495
+ constructor(options2) {
34496
+ if (typeof options2 === "number")
34497
+ options2 = { max: options2 };
34498
+ if (!options2)
34499
+ options2 = {};
34500
+ if (options2.max && (typeof options2.max !== "number" || options2.max < 0))
34501
+ throw new TypeError("max must be a non-negative number");
34502
+ this[MAX] = options2.max || Infinity;
34503
+ const lc = options2.length || naiveLength;
34504
+ this[LENGTH_CALCULATOR] = typeof lc !== "function" ? naiveLength : lc;
34505
+ this[ALLOW_STALE] = options2.stale || false;
34506
+ if (options2.maxAge && typeof options2.maxAge !== "number")
34507
+ throw new TypeError("maxAge must be a number");
34508
+ this[MAX_AGE] = options2.maxAge || 0;
34509
+ this[DISPOSE] = options2.dispose;
34510
+ this[NO_DISPOSE_ON_SET] = options2.noDisposeOnSet || false;
34511
+ this[UPDATE_AGE_ON_GET] = options2.updateAgeOnGet || false;
34512
+ this.reset();
34513
+ }
34514
+ // resize the cache when the max changes.
34515
+ set max(mL) {
34516
+ if (typeof mL !== "number" || mL < 0)
34517
+ throw new TypeError("max must be a non-negative number");
34518
+ this[MAX] = mL || Infinity;
34519
+ trim(this);
34520
+ }
34521
+ get max() {
34522
+ return this[MAX];
34523
+ }
34524
+ set allowStale(allowStale) {
34525
+ this[ALLOW_STALE] = !!allowStale;
34526
+ }
34527
+ get allowStale() {
34528
+ return this[ALLOW_STALE];
34529
+ }
34530
+ set maxAge(mA) {
34531
+ if (typeof mA !== "number")
34532
+ throw new TypeError("maxAge must be a non-negative number");
34533
+ this[MAX_AGE] = mA;
34534
+ trim(this);
34535
+ }
34536
+ get maxAge() {
34537
+ return this[MAX_AGE];
34538
+ }
34539
+ // resize the cache when the lengthCalculator changes.
34540
+ set lengthCalculator(lC) {
34541
+ if (typeof lC !== "function")
34542
+ lC = naiveLength;
34543
+ if (lC !== this[LENGTH_CALCULATOR]) {
34544
+ this[LENGTH_CALCULATOR] = lC;
34545
+ this[LENGTH] = 0;
34546
+ this[LRU_LIST].forEach((hit) => {
34547
+ hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
34548
+ this[LENGTH] += hit.length;
34549
+ });
34550
+ }
34551
+ trim(this);
34552
+ }
34553
+ get lengthCalculator() {
34554
+ return this[LENGTH_CALCULATOR];
34555
+ }
34556
+ get length() {
34557
+ return this[LENGTH];
34558
+ }
34559
+ get itemCount() {
34560
+ return this[LRU_LIST].length;
34561
+ }
34562
+ rforEach(fn, thisp) {
34563
+ thisp = thisp || this;
34564
+ for (let walker = this[LRU_LIST].tail; walker !== null; ) {
34565
+ const prev = walker.prev;
34566
+ forEachStep(this, fn, walker, thisp);
34567
+ walker = prev;
34568
+ }
34569
+ }
34570
+ forEach(fn, thisp) {
34571
+ thisp = thisp || this;
34572
+ for (let walker = this[LRU_LIST].head; walker !== null; ) {
34573
+ const next = walker.next;
34574
+ forEachStep(this, fn, walker, thisp);
34575
+ walker = next;
34576
+ }
34577
+ }
34578
+ keys() {
34579
+ return this[LRU_LIST].toArray().map((k) => k.key);
34580
+ }
34581
+ values() {
34582
+ return this[LRU_LIST].toArray().map((k) => k.value);
34583
+ }
34584
+ reset() {
34585
+ if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
34586
+ this[LRU_LIST].forEach((hit) => this[DISPOSE](hit.key, hit.value));
34587
+ }
34588
+ this[CACHE] = /* @__PURE__ */ new Map();
34589
+ this[LRU_LIST] = new Yallist();
34590
+ this[LENGTH] = 0;
34591
+ }
34592
+ dump() {
34593
+ return this[LRU_LIST].map((hit) => isStale(this, hit) ? false : {
34594
+ k: hit.key,
34595
+ v: hit.value,
34596
+ e: hit.now + (hit.maxAge || 0)
34597
+ }).toArray().filter((h2) => h2);
34598
+ }
34599
+ dumpLru() {
34600
+ return this[LRU_LIST];
34601
+ }
34602
+ set(key, value, maxAge) {
34603
+ maxAge = maxAge || this[MAX_AGE];
34604
+ if (maxAge && typeof maxAge !== "number")
34605
+ throw new TypeError("maxAge must be a number");
34606
+ const now = maxAge ? Date.now() : 0;
34607
+ const len = this[LENGTH_CALCULATOR](value, key);
34608
+ if (this[CACHE].has(key)) {
34609
+ if (len > this[MAX]) {
34610
+ del(this, this[CACHE].get(key));
34611
+ return false;
34612
+ }
34613
+ const node = this[CACHE].get(key);
34614
+ const item = node.value;
34615
+ if (this[DISPOSE]) {
34616
+ if (!this[NO_DISPOSE_ON_SET])
34617
+ this[DISPOSE](key, item.value);
34618
+ }
34619
+ item.now = now;
34620
+ item.maxAge = maxAge;
34621
+ item.value = value;
34622
+ this[LENGTH] += len - item.length;
34623
+ item.length = len;
34624
+ this.get(key);
34625
+ trim(this);
34626
+ return true;
34627
+ }
34628
+ const hit = new Entry(key, value, len, now, maxAge);
34629
+ if (hit.length > this[MAX]) {
34630
+ if (this[DISPOSE])
34631
+ this[DISPOSE](key, value);
34632
+ return false;
34633
+ }
34634
+ this[LENGTH] += hit.length;
34635
+ this[LRU_LIST].unshift(hit);
34636
+ this[CACHE].set(key, this[LRU_LIST].head);
34637
+ trim(this);
34638
+ return true;
34639
+ }
34640
+ has(key) {
34641
+ if (!this[CACHE].has(key)) return false;
34642
+ const hit = this[CACHE].get(key).value;
34643
+ return !isStale(this, hit);
34100
34644
  }
34101
34645
  get(key) {
34102
- const value = this.map.get(key);
34103
- if (value === void 0) {
34104
- return void 0;
34105
- } else {
34106
- this.map.delete(key);
34107
- this.map.set(key, value);
34108
- return value;
34646
+ return get(this, key, true);
34647
+ }
34648
+ peek(key) {
34649
+ return get(this, key, false);
34650
+ }
34651
+ pop() {
34652
+ const node = this[LRU_LIST].tail;
34653
+ if (!node)
34654
+ return null;
34655
+ del(this, node);
34656
+ return node.value;
34657
+ }
34658
+ del(key) {
34659
+ del(this, this[CACHE].get(key));
34660
+ }
34661
+ load(arr) {
34662
+ this.reset();
34663
+ const now = Date.now();
34664
+ for (let l = arr.length - 1; l >= 0; l--) {
34665
+ const hit = arr[l];
34666
+ const expiresAt = hit.e || 0;
34667
+ if (expiresAt === 0)
34668
+ this.set(hit.k, hit.v);
34669
+ else {
34670
+ const maxAge = expiresAt - now;
34671
+ if (maxAge > 0) {
34672
+ this.set(hit.k, hit.v, maxAge);
34673
+ }
34674
+ }
34109
34675
  }
34110
34676
  }
34111
- delete(key) {
34112
- return this.map.delete(key);
34677
+ prune() {
34678
+ this[CACHE].forEach((value, key) => get(this, key, false));
34113
34679
  }
34114
- set(key, value) {
34115
- const deleted = this.delete(key);
34116
- if (!deleted && value !== void 0) {
34117
- if (this.map.size >= this.max) {
34118
- const firstKey = this.map.keys().next().value;
34119
- this.delete(firstKey);
34680
+ }
34681
+ const get = (self2, key, doUse) => {
34682
+ const node = self2[CACHE].get(key);
34683
+ if (node) {
34684
+ const hit = node.value;
34685
+ if (isStale(self2, hit)) {
34686
+ del(self2, node);
34687
+ if (!self2[ALLOW_STALE])
34688
+ return void 0;
34689
+ } else {
34690
+ if (doUse) {
34691
+ if (self2[UPDATE_AGE_ON_GET])
34692
+ node.value.now = Date.now();
34693
+ self2[LRU_LIST].unshiftNode(node);
34120
34694
  }
34121
- this.map.set(key, value);
34122
34695
  }
34123
- return this;
34696
+ return hit.value;
34697
+ }
34698
+ };
34699
+ const isStale = (self2, hit) => {
34700
+ if (!hit || !hit.maxAge && !self2[MAX_AGE])
34701
+ return false;
34702
+ const diff2 = Date.now() - hit.now;
34703
+ return hit.maxAge ? diff2 > hit.maxAge : self2[MAX_AGE] && diff2 > self2[MAX_AGE];
34704
+ };
34705
+ const trim = (self2) => {
34706
+ if (self2[LENGTH] > self2[MAX]) {
34707
+ for (let walker = self2[LRU_LIST].tail; self2[LENGTH] > self2[MAX] && walker !== null; ) {
34708
+ const prev = walker.prev;
34709
+ del(self2, walker);
34710
+ walker = prev;
34711
+ }
34712
+ }
34713
+ };
34714
+ const del = (self2, node) => {
34715
+ if (node) {
34716
+ const hit = node.value;
34717
+ if (self2[DISPOSE])
34718
+ self2[DISPOSE](hit.key, hit.value);
34719
+ self2[LENGTH] -= hit.length;
34720
+ self2[CACHE].delete(hit.key);
34721
+ self2[LRU_LIST].removeNode(node);
34722
+ }
34723
+ };
34724
+ class Entry {
34725
+ constructor(key, value, length, now, maxAge) {
34726
+ this.key = key;
34727
+ this.value = value;
34728
+ this.length = length;
34729
+ this.now = now;
34730
+ this.maxAge = maxAge || 0;
34124
34731
  }
34125
34732
  }
34126
- var lrucache = LRUCache;
34733
+ const forEachStep = (self2, fn, node, thisp) => {
34734
+ let hit = node.value;
34735
+ if (isStale(self2, hit)) {
34736
+ del(self2, node);
34737
+ if (!self2[ALLOW_STALE])
34738
+ hit = void 0;
34739
+ }
34740
+ if (hit)
34741
+ fn.call(thisp, hit.value, hit.key, self2);
34742
+ };
34743
+ var lruCache = LRUCache;
34127
34744
  var range;
34128
34745
  var hasRequiredRange;
34129
34746
  function requireRange() {
34130
34747
  if (hasRequiredRange) return range;
34131
34748
  hasRequiredRange = 1;
34132
- const SPACE_CHARACTERS = /\s+/g;
34133
34749
  class Range2 {
34134
34750
  constructor(range2, options2) {
34135
34751
  options2 = parseOptions2(options2);
@@ -34143,13 +34759,13 @@ function requireRange() {
34143
34759
  if (range2 instanceof Comparator2) {
34144
34760
  this.raw = range2.value;
34145
34761
  this.set = [[range2]];
34146
- this.formatted = void 0;
34762
+ this.format();
34147
34763
  return this;
34148
34764
  }
34149
34765
  this.options = options2;
34150
34766
  this.loose = !!options2.loose;
34151
34767
  this.includePrerelease = !!options2.includePrerelease;
34152
- this.raw = range2.trim().replace(SPACE_CHARACTERS, " ");
34768
+ this.raw = range2.trim().split(/\s+/).join(" ");
34153
34769
  this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
34154
34770
  if (!this.set.length) {
34155
34771
  throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
@@ -34168,27 +34784,10 @@ function requireRange() {
34168
34784
  }
34169
34785
  }
34170
34786
  }
34171
- this.formatted = void 0;
34172
- }
34173
- get range() {
34174
- if (this.formatted === void 0) {
34175
- this.formatted = "";
34176
- for (let i = 0; i < this.set.length; i++) {
34177
- if (i > 0) {
34178
- this.formatted += "||";
34179
- }
34180
- const comps = this.set[i];
34181
- for (let k = 0; k < comps.length; k++) {
34182
- if (k > 0) {
34183
- this.formatted += " ";
34184
- }
34185
- this.formatted += comps[k].toString().trim();
34186
- }
34187
- }
34188
- }
34189
- return this.formatted;
34787
+ this.format();
34190
34788
  }
34191
34789
  format() {
34790
+ this.range = this.set.map((comps) => comps.join(" ").trim()).join("||").trim();
34192
34791
  return this.range;
34193
34792
  }
34194
34793
  toString() {
@@ -34269,8 +34868,8 @@ function requireRange() {
34269
34868
  }
34270
34869
  }
34271
34870
  range = Range2;
34272
- const LRU = lrucache;
34273
- const cache = new LRU();
34871
+ const LRU = lruCache;
34872
+ const cache = new LRU({ max: 1e3 });
34274
34873
  const parseOptions2 = parseOptions_1;
34275
34874
  const Comparator2 = requireComparator();
34276
34875
  const debug2 = debug_1;
@@ -34298,7 +34897,6 @@ function requireRange() {
34298
34897
  return result;
34299
34898
  };
34300
34899
  const parseComparator = (comp, options2) => {
34301
- comp = comp.replace(re2[t2.BUILD], "");
34302
34900
  debug2("comp", comp, options2);
34303
34901
  comp = replaceCarets(comp, options2);
34304
34902
  debug2("caret", comp);
@@ -34449,7 +35047,7 @@ function requireRange() {
34449
35047
  debug2("replaceGTE0", comp, options2);
34450
35048
  return comp.trim().replace(re2[options2.includePrerelease ? t2.GTE0PRE : t2.GTE0], "");
34451
35049
  };
34452
- const hyphenReplace = (incPr) => ($0, from, fM, fm, fp2, fpr, fb, to, tM, tm, tp, tpr) => {
35050
+ const hyphenReplace = (incPr) => ($0, from, fM, fm, fp2, fpr, fb, to, tM, tm, tp, tpr, tb) => {
34453
35051
  if (isX(fM)) {
34454
35052
  from = "";
34455
35053
  } else if (isX(fm)) {
@@ -35772,9 +36370,10 @@ const tokenService = ({ strapi: strapi2 }) => {
35772
36370
  if (firebaseUserData2.verificationTokenHash !== tokenHash) {
35773
36371
  return {
35774
36372
  valid: false,
35775
- firebaseUserDataDocumentId: "",
35776
- firebaseUID: "",
35777
- error: "Verification link has already been used or is invalid"
36373
+ firebaseUserDataDocumentId: firebaseUserData2.documentId,
36374
+ firebaseUID: firebaseUserData2.firebaseUserID,
36375
+ error: "Verification link has already been used or is invalid",
36376
+ code: "TOKEN_ALREADY_USED"
35778
36377
  };
35779
36378
  }
35780
36379
  if (firebaseUserData2.verificationTokenExpiresAt) {