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 @@ import require$$0$8 from "constants";
13
13
  import "node:stream";
14
14
  import admin$1 from "firebase-admin";
15
15
  import CryptoJS from "crypto-js";
16
- import * as fs$6 from "fs/promises";
16
+ import * as fs$8 from "fs/promises";
17
17
  async function migrateFirebaseUserData(strapi2, dryRun = false) {
18
18
  strapi2.log.info("=== Firebase User Data Migration ===");
19
19
  strapi2.log.info(`Mode: ${dryRun ? "DRY RUN (no changes)" : "LIVE (will modify database)"}`);
@@ -369,293 +369,6 @@ const contentTypes = {
369
369
  "firebase-authentication-configuration": { schema: firebaseAuthenticationConfiguration },
370
370
  "firebase-user-data": { schema: firebaseUserData }
371
371
  };
372
- const pluginName = "firebase-authentication";
373
- const PLUGIN_NAME = "firebase-authentication";
374
- const PLUGIN_UID = `plugin::${PLUGIN_NAME}`;
375
- const CONFIG_CONTENT_TYPE = `${PLUGIN_UID}.firebase-authentication-configuration`;
376
- const DEFAULT_PASSWORD_RESET_URL = "http://localhost:3000/reset-password";
377
- const DEFAULT_PASSWORD_REGEX = "^.{6,}$";
378
- const DEFAULT_PASSWORD_MESSAGE = "Password must be at least 6 characters long";
379
- const DEFAULT_RESET_EMAIL_SUBJECT = "Reset Your Password";
380
- const ERROR_MESSAGES = {
381
- FIREBASE_NOT_INITIALIZED: "Firebase is not initialized. Please upload Firebase service account configuration via Settings → Firebase Authentication.",
382
- INVALID_JSON: "Invalid JSON format. Please ensure you copied the entire JSON content correctly.",
383
- MISSING_DATA: "data is missing",
384
- SOMETHING_WENT_WRONG: "Something went wrong",
385
- AUTHENTICATION_FAILED: "Authentication failed",
386
- TOKEN_MISSING: "idToken is missing!",
387
- EMAIL_PASSWORD_REQUIRED: "Email and password are required",
388
- PASSWORD_REQUIRED: "Password is required",
389
- AUTHORIZATION_REQUIRED: "Authorization token is required",
390
- INVALID_TOKEN: "Invalid or expired token",
391
- USER_NOT_FOUND: "User not found",
392
- USER_NO_EMAIL: "User does not have an email address",
393
- FIREBASE_LINK_FAILED: "Failed to generate Firebase reset link",
394
- CONFIG_NOT_FOUND: "No config found",
395
- INVALID_SERVICE_ACCOUNT: "Invalid service account JSON",
396
- WEB_API_NOT_CONFIGURED: "Email/password authentication is not available. Web API Key is not configured.",
397
- RESET_URL_NOT_CONFIGURED: "Password reset URL is not configured",
398
- RESET_URL_MUST_BE_HTTPS: "Password reset URL must use HTTPS in production",
399
- RESET_URL_INVALID_FORMAT: "Password reset URL is not a valid URL format",
400
- USER_NOT_LINKED_FIREBASE: "User is not linked to Firebase authentication",
401
- OVERRIDE_USER_ID_REQUIRED: "Override user ID is required",
402
- EITHER_EMAIL_OR_PHONE_REQUIRED: "Either email or phoneNumber is required",
403
- DELETION_NO_CONFIG: "No Firebase configs exists for deletion"
404
- };
405
- const SUCCESS_MESSAGES = {
406
- FIREBASE_INITIALIZED: "Firebase successfully initialized",
407
- FIREBASE_CONFIG_DELETED: "Firebase config deleted and reinitialized",
408
- PASSWORD_RESET_EMAIL_SENT: "If an account with that email exists, a password reset link has been sent.",
409
- SERVER_RESTARTING: "SERVER IS RESTARTING"
410
- };
411
- const CONFIG_KEYS = {
412
- ENCRYPTION_KEY: `${PLUGIN_UID}.FIREBASE_JSON_ENCRYPTION_KEY`
413
- };
414
- const REQUIRED_FIELDS = {
415
- SERVICE_ACCOUNT: ["private_key", "client_email", "project_id", "type"],
416
- WEB_CONFIG: ["apiKey", "authDomain"]
417
- // These indicate wrong JSON type
418
- };
419
- const VALIDATION_MESSAGES = {
420
- INVALID_SERVICE_ACCOUNT: "Invalid Service Account JSON. Missing required fields:",
421
- 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.",
422
- 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!"
423
- };
424
- const firebaseController = {
425
- async validateToken(ctx) {
426
- strapi.log.debug("validateToken called");
427
- try {
428
- const { idToken, profileMetaData } = ctx.request.body || {};
429
- const populate2 = ctx.request.query.populate || [];
430
- if (!idToken) {
431
- return ctx.badRequest(ERROR_MESSAGES.TOKEN_MISSING);
432
- }
433
- const result = await strapi.plugin(pluginName).service("firebaseService").validateFirebaseToken(idToken, profileMetaData, populate2);
434
- ctx.body = result;
435
- } catch (error2) {
436
- strapi.log.error(`validateToken controller error: ${error2.message}`);
437
- if (error2.name === "ValidationError") {
438
- return ctx.badRequest(error2.message);
439
- }
440
- if (error2.name === "UnauthorizedError") {
441
- return ctx.unauthorized(error2.message);
442
- }
443
- throw error2;
444
- }
445
- },
446
- async deleteByEmail(email2) {
447
- const user = await strapi.firebase.auth().getUserByEmail(email2);
448
- await strapi.plugin(pluginName).service("firebaseService").delete(user.toJSON().uid);
449
- return user.toJSON();
450
- },
451
- async overrideAccess(ctx) {
452
- try {
453
- const { overrideUserId } = ctx.request.body || {};
454
- const populate2 = ctx.request.query.populate || [];
455
- const result = await strapi.plugin(pluginName).service("firebaseService").overrideFirebaseAccess(overrideUserId, populate2);
456
- ctx.body = result;
457
- } catch (error2) {
458
- if (error2.name === "ValidationError") {
459
- return ctx.badRequest(error2.message);
460
- }
461
- if (error2.name === "NotFoundError") {
462
- return ctx.notFound(error2.message);
463
- }
464
- throw error2;
465
- }
466
- },
467
- /**
468
- * Controller method for email/password authentication
469
- * Handles the `/api/firebase-authentication/emailLogin` endpoint
470
- *
471
- * @param ctx - Koa context object
472
- * @returns Promise that sets ctx.body with user data and JWT or error message
473
- *
474
- * @remarks
475
- * This controller acts as a proxy to Firebase's Identity Toolkit API,
476
- * allowing users to authenticate with email/password and receive a Strapi JWT.
477
- *
478
- * HTTP Status Codes:
479
- * - `400`: Validation errors (missing credentials, invalid email/password)
480
- * - `500`: Server errors (missing configuration, Firebase API issues)
481
- */
482
- async emailLogin(ctx) {
483
- strapi.log.debug("emailLogin controller");
484
- try {
485
- const { email: email2, password } = ctx.request.body || {};
486
- const populate2 = ctx.request.query.populate || [];
487
- const result = await strapi.plugin(pluginName).service("firebaseService").emailLogin(email2, password, populate2);
488
- ctx.body = result;
489
- } catch (error2) {
490
- strapi.log.error("emailLogin controller error:", error2);
491
- if (error2.name === "ValidationError") {
492
- ctx.status = 400;
493
- } else if (error2.name === "ApplicationError") {
494
- ctx.status = 500;
495
- } else {
496
- ctx.status = 500;
497
- }
498
- ctx.body = { error: error2.message };
499
- }
500
- },
501
- /**
502
- * Forgot password - sends reset email
503
- * POST /api/firebase-authentication/forgotPassword
504
- * Public endpoint - no authentication required
505
- */
506
- async forgotPassword(ctx) {
507
- strapi.log.debug("forgotPassword endpoint called");
508
- try {
509
- const { email: email2 } = ctx.request.body || {};
510
- ctx.body = await strapi.plugin(pluginName).service("firebaseService").forgotPassword(email2);
511
- } catch (error2) {
512
- strapi.log.error("forgotPassword controller error:", error2);
513
- if (error2.name === "ValidationError") {
514
- ctx.status = 400;
515
- } else if (error2.name === "NotFoundError") {
516
- ctx.status = 404;
517
- } else {
518
- ctx.status = 500;
519
- }
520
- ctx.body = { error: error2.message };
521
- }
522
- },
523
- /**
524
- * Reset password - authenticated password change
525
- * POST /api/firebase-authentication/resetPassword
526
- * Public endpoint - requires valid JWT in Authorization header
527
- * Used for admin-initiated resets or user self-service password changes
528
- * NOT used for forgot password email flow (which uses Firebase's hosted UI)
529
- */
530
- async resetPassword(ctx) {
531
- strapi.log.debug("resetPassword endpoint called");
532
- try {
533
- const { password } = ctx.request.body || {};
534
- const token = ctx.request.headers.authorization?.replace("Bearer ", "");
535
- const populate2 = ctx.request.query.populate || [];
536
- ctx.body = await strapi.plugin(pluginName).service("firebaseService").resetPassword(password, token, populate2);
537
- } catch (error2) {
538
- strapi.log.error("resetPassword controller error:", error2);
539
- if (error2.name === "ValidationError" || error2.name === "UnauthorizedError") {
540
- ctx.status = 401;
541
- } else {
542
- ctx.status = 500;
543
- }
544
- ctx.body = { error: error2.message };
545
- }
546
- },
547
- async requestMagicLink(ctx) {
548
- try {
549
- const { email: email2 } = ctx.request.body || {};
550
- const result = await strapi.plugin("firebase-authentication").service("firebaseService").requestMagicLink(email2);
551
- ctx.body = result;
552
- } catch (error2) {
553
- if (error2.name === "ValidationError" || error2.name === "ApplicationError") {
554
- throw error2;
555
- }
556
- strapi.log.error("requestMagicLink controller error:", error2);
557
- ctx.body = {
558
- success: false,
559
- message: "An error occurred while processing your request"
560
- };
561
- }
562
- },
563
- /**
564
- * Reset password using custom JWT token
565
- * POST /api/firebase-authentication/resetPasswordWithToken
566
- * Public endpoint - token provides authentication
567
- *
568
- * @param ctx - Koa context with { token, newPassword } in body
569
- * @returns { success: true, message: "Password has been reset successfully" }
570
- */
571
- async resetPasswordWithToken(ctx) {
572
- strapi.log.debug("resetPasswordWithToken endpoint called");
573
- try {
574
- const { token, newPassword } = ctx.request.body || {};
575
- if (!token) {
576
- ctx.status = 400;
577
- ctx.body = { error: "Token is required" };
578
- return;
579
- }
580
- if (!newPassword) {
581
- ctx.status = 400;
582
- ctx.body = { error: "New password is required" };
583
- return;
584
- }
585
- const result = await strapi.plugin(pluginName).service("userService").resetPasswordWithToken(token, newPassword);
586
- ctx.body = result;
587
- } catch (error2) {
588
- strapi.log.error("resetPasswordWithToken controller error:", error2);
589
- if (error2.name === "ValidationError") {
590
- ctx.status = 400;
591
- ctx.body = { error: error2.message };
592
- return;
593
- }
594
- if (error2.name === "NotFoundError") {
595
- ctx.status = 404;
596
- ctx.body = { error: error2.message };
597
- return;
598
- }
599
- ctx.status = 500;
600
- ctx.body = { error: "An error occurred while resetting your password" };
601
- }
602
- },
603
- /**
604
- * Send email verification - public endpoint
605
- * POST /api/firebase-authentication/sendVerificationEmail
606
- * Public endpoint - no authentication required
607
- */
608
- async sendVerificationEmail(ctx) {
609
- strapi.log.debug("sendVerificationEmail endpoint called");
610
- try {
611
- const { email: email2 } = ctx.request.body || {};
612
- ctx.body = await strapi.plugin(pluginName).service("firebaseService").sendVerificationEmail(email2);
613
- } catch (error2) {
614
- strapi.log.error("sendVerificationEmail controller error:", error2);
615
- if (error2.name === "ValidationError") {
616
- ctx.status = 400;
617
- } else {
618
- ctx.status = 500;
619
- }
620
- ctx.body = { error: error2.message };
621
- }
622
- },
623
- /**
624
- * Verify email using custom JWT token
625
- * POST /api/firebase-authentication/verifyEmail
626
- * Public endpoint - token provides authentication
627
- *
628
- * @param ctx - Koa context with { token } in body
629
- * @returns { success: true, message: "Email verified successfully" }
630
- */
631
- async verifyEmail(ctx) {
632
- strapi.log.debug("verifyEmail endpoint called");
633
- try {
634
- const { token } = ctx.request.body || {};
635
- if (!token) {
636
- ctx.status = 400;
637
- ctx.body = { error: "Token is required" };
638
- return;
639
- }
640
- const result = await strapi.plugin(pluginName).service("firebaseService").verifyEmail(token);
641
- ctx.body = result;
642
- } catch (error2) {
643
- strapi.log.error("verifyEmail controller error:", error2);
644
- if (error2.name === "ValidationError") {
645
- ctx.status = 400;
646
- ctx.body = { error: error2.message };
647
- return;
648
- }
649
- if (error2.name === "NotFoundError") {
650
- ctx.status = 404;
651
- ctx.body = { error: error2.message };
652
- return;
653
- }
654
- ctx.status = 500;
655
- ctx.body = { error: "An error occurred while verifying your email" };
656
- }
657
- }
658
- };
659
372
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
660
373
  function getDefaultExportFromCjs(x) {
661
374
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
@@ -670,7 +383,7 @@ var lodash = { exports: {} };
670
383
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
671
384
  */
672
385
  lodash.exports;
673
- (function(module, exports) {
386
+ (function(module, exports$1) {
674
387
  (function() {
675
388
  var undefined$1;
676
389
  var VERSION = "4.17.21";
@@ -998,7 +711,7 @@ lodash.exports;
998
711
  var freeGlobal2 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
999
712
  var freeSelf2 = typeof self == "object" && self && self.Object === Object && self;
1000
713
  var root2 = freeGlobal2 || freeSelf2 || Function("return this")();
1001
- var freeExports = exports && !exports.nodeType && exports;
714
+ var freeExports = exports$1 && !exports$1.nodeType && exports$1;
1002
715
  var freeModule = freeExports && true && module && !module.nodeType && module;
1003
716
  var moduleExports = freeModule && freeModule.exports === freeExports;
1004
717
  var freeProcess = moduleExports && freeGlobal2.process;
@@ -1269,9 +982,9 @@ lodash.exports;
1269
982
  function hasUnicodeWord2(string2) {
1270
983
  return reHasUnicodeWord2.test(string2);
1271
984
  }
1272
- function iteratorToArray(iterator) {
985
+ function iteratorToArray(iterator2) {
1273
986
  var data, result = [];
1274
- while (!(data = iterator.next()).done) {
987
+ while (!(data = iterator2.next()).done) {
1275
988
  result.push(data.value);
1276
989
  }
1277
990
  return result;
@@ -6228,7 +5941,7 @@ var lodash_min = { exports: {} };
6228
5941
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
6229
5942
  */
6230
5943
  lodash_min.exports;
6231
- (function(module, exports) {
5944
+ (function(module, exports$1) {
6232
5945
  (function() {
6233
5946
  function n(n2, t3, r2) {
6234
5947
  switch (r2.length) {
@@ -6661,7 +6374,7 @@ lodash_min.exports;
6661
6374
  "œ": "oe",
6662
6375
  "ʼn": "'n",
6663
6376
  "ſ": "s"
6664
- }, 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 && !exports.nodeType && exports, ue = ee && true && module && !module.nodeType && module, ie = ue && ue.exports === ee, oe = ie && ne.process, fe = function() {
6377
+ }, 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 && module && !module.nodeType && module, ie = ue && ue.exports === ee, oe = ie && ne.process, fe = function() {
6665
6378
  try {
6666
6379
  var n2 = ue && ue.require && ue.require("util").types;
6667
6380
  return n2 ? n2 : oe && oe.binding && oe.binding("util");
@@ -9334,8 +9047,8 @@ lodash_min.exports;
9334
9047
  })(lodash_min, lodash_min.exports);
9335
9048
  var lodash_minExports = lodash_min.exports;
9336
9049
  var _mapping = {};
9337
- (function(exports) {
9338
- exports.aliasToReal = {
9050
+ (function(exports$1) {
9051
+ exports$1.aliasToReal = {
9339
9052
  // Lodash aliases.
9340
9053
  "each": "forEach",
9341
9054
  "eachRight": "forEachRight",
@@ -9400,7 +9113,7 @@ var _mapping = {};
9400
9113
  "whereEq": "isMatch",
9401
9114
  "zipObj": "zipObject"
9402
9115
  };
9403
- exports.aryMethod = {
9116
+ exports$1.aryMethod = {
9404
9117
  "1": [
9405
9118
  "assignAll",
9406
9119
  "assignInAll",
@@ -9635,12 +9348,12 @@ var _mapping = {};
9635
9348
  "updateWith"
9636
9349
  ]
9637
9350
  };
9638
- exports.aryRearg = {
9351
+ exports$1.aryRearg = {
9639
9352
  "2": [1, 0],
9640
9353
  "3": [2, 0, 1],
9641
9354
  "4": [3, 2, 0, 1]
9642
9355
  };
9643
- exports.iterateeAry = {
9356
+ exports$1.iterateeAry = {
9644
9357
  "dropRightWhile": 1,
9645
9358
  "dropWhile": 1,
9646
9359
  "every": 1,
@@ -9678,11 +9391,11 @@ var _mapping = {};
9678
9391
  "times": 1,
9679
9392
  "transform": 2
9680
9393
  };
9681
- exports.iterateeRearg = {
9394
+ exports$1.iterateeRearg = {
9682
9395
  "mapKeys": [1],
9683
9396
  "reduceRight": [1, 0]
9684
9397
  };
9685
- exports.methodRearg = {
9398
+ exports$1.methodRearg = {
9686
9399
  "assignInAllWith": [1, 0],
9687
9400
  "assignInWith": [1, 2, 0],
9688
9401
  "assignAllWith": [1, 0],
@@ -9713,7 +9426,7 @@ var _mapping = {};
9713
9426
  "xorWith": [1, 2, 0],
9714
9427
  "zipWith": [1, 2, 0]
9715
9428
  };
9716
- exports.methodSpread = {
9429
+ exports$1.methodSpread = {
9717
9430
  "assignAll": { "start": 0 },
9718
9431
  "assignAllWith": { "start": 0 },
9719
9432
  "assignInAll": { "start": 0 },
@@ -9729,7 +9442,7 @@ var _mapping = {};
9729
9442
  "without": { "start": 1 },
9730
9443
  "zipAll": { "start": 0 }
9731
9444
  };
9732
- exports.mutate = {
9445
+ exports$1.mutate = {
9733
9446
  "array": {
9734
9447
  "fill": true,
9735
9448
  "pull": true,
@@ -9766,8 +9479,8 @@ var _mapping = {};
9766
9479
  "updateWith": true
9767
9480
  }
9768
9481
  };
9769
- exports.realToAlias = function() {
9770
- var hasOwnProperty2 = Object.prototype.hasOwnProperty, object2 = exports.aliasToReal, result = {};
9482
+ exports$1.realToAlias = function() {
9483
+ var hasOwnProperty2 = Object.prototype.hasOwnProperty, object2 = exports$1.aliasToReal, result = {};
9771
9484
  for (var key in object2) {
9772
9485
  var value = object2[key];
9773
9486
  if (hasOwnProperty2.call(result, value)) {
@@ -9778,7 +9491,7 @@ var _mapping = {};
9778
9491
  }
9779
9492
  return result;
9780
9493
  }();
9781
- exports.remap = {
9494
+ exports$1.remap = {
9782
9495
  "assignAll": "assign",
9783
9496
  "assignAllWith": "assignWith",
9784
9497
  "assignInAll": "assignIn",
@@ -9812,7 +9525,7 @@ var _mapping = {};
9812
9525
  "trimCharsStart": "trimStart",
9813
9526
  "zipAll": "zip"
9814
9527
  };
9815
- exports.skipFixed = {
9528
+ exports$1.skipFixed = {
9816
9529
  "castArray": true,
9817
9530
  "flow": true,
9818
9531
  "flowRight": true,
@@ -9821,7 +9534,7 @@ var _mapping = {};
9821
9534
  "rearg": true,
9822
9535
  "runInContext": true
9823
9536
  };
9824
- exports.skipRearg = {
9537
+ exports$1.skipRearg = {
9825
9538
  "add": true,
9826
9539
  "assign": true,
9827
9540
  "assignIn": true,
@@ -9854,7 +9567,7 @@ var _mapping = {};
9854
9567
  })(_mapping);
9855
9568
  var placeholder = {};
9856
9569
  var mapping = _mapping, fallbackHolder = placeholder;
9857
- var push = Array.prototype.push;
9570
+ var push$1 = Array.prototype.push;
9858
9571
  function baseArity(func, n) {
9859
9572
  return n == 2 ? function(a, b) {
9860
9573
  return func.apply(void 0, arguments);
@@ -9889,10 +9602,10 @@ function flatSpread(func, start) {
9889
9602
  }
9890
9603
  var array2 = args[start], otherArgs = args.slice(0, start);
9891
9604
  if (array2) {
9892
- push.apply(otherArgs, array2);
9605
+ push$1.apply(otherArgs, array2);
9893
9606
  }
9894
9607
  if (start != lastIndex) {
9895
- push.apply(otherArgs, args.slice(start + 1));
9608
+ push$1.apply(otherArgs, args.slice(start + 1));
9896
9609
  }
9897
9610
  return func.apply(this, otherArgs);
9898
9611
  };
@@ -10275,13 +9988,13 @@ const traverseEntity = async (visitor2, options2, entity) => {
10275
9988
  if (fp.isNil(value) || fp.isNil(attribute)) {
10276
9989
  continue;
10277
9990
  }
10278
- parent = {
10279
- schema: schema2,
10280
- key,
10281
- attribute,
10282
- path: newPath
10283
- };
10284
9991
  if (isRelationalAttribute(attribute)) {
9992
+ parent = {
9993
+ schema: schema2,
9994
+ key,
9995
+ attribute,
9996
+ path: newPath
9997
+ };
10285
9998
  const isMorphRelation = attribute.relation.toLowerCase().startsWith("morph");
10286
9999
  const method = isMorphRelation ? traverseMorphRelationTarget : traverseRelationTarget(getModel(attribute.target));
10287
10000
  if (fp.isArray(value)) {
@@ -10300,6 +10013,12 @@ const traverseEntity = async (visitor2, options2, entity) => {
10300
10013
  continue;
10301
10014
  }
10302
10015
  if (isMediaAttribute(attribute)) {
10016
+ parent = {
10017
+ schema: schema2,
10018
+ key,
10019
+ attribute,
10020
+ path: newPath
10021
+ };
10303
10022
  if (fp.isArray(value)) {
10304
10023
  const res = new Array(value.length);
10305
10024
  for (let i2 = 0; i2 < value.length; i2 += 1) {
@@ -10316,6 +10035,12 @@ const traverseEntity = async (visitor2, options2, entity) => {
10316
10035
  continue;
10317
10036
  }
10318
10037
  if (attribute.type === "component") {
10038
+ parent = {
10039
+ schema: schema2,
10040
+ key,
10041
+ attribute,
10042
+ path: newPath
10043
+ };
10319
10044
  const targetSchema = getModel(attribute.component);
10320
10045
  if (fp.isArray(value)) {
10321
10046
  const res = new Array(value.length);
@@ -10333,6 +10058,12 @@ const traverseEntity = async (visitor2, options2, entity) => {
10333
10058
  continue;
10334
10059
  }
10335
10060
  if (attribute.type === "dynamiczone" && fp.isArray(value)) {
10061
+ parent = {
10062
+ schema: schema2,
10063
+ key,
10064
+ attribute,
10065
+ path: newPath
10066
+ };
10336
10067
  const res = new Array(value.length);
10337
10068
  for (let i2 = 0; i2 < value.length; i2 += 1) {
10338
10069
  const arrayPath = {
@@ -10357,7 +10088,7 @@ const createVisitorUtils = ({ data }) => ({
10357
10088
  });
10358
10089
  fp.curry(traverseEntity);
10359
10090
  var dist = { exports: {} };
10360
- (function(module, exports) {
10091
+ (function(module, exports$1) {
10361
10092
  !function(t2, n) {
10362
10093
  module.exports = n(require$$0$2, crypto$1);
10363
10094
  }(commonjsGlobal, function(t2, n) {
@@ -11905,9 +11636,9 @@ function stubFalse() {
11905
11636
  }
11906
11637
  var stubFalse_1 = stubFalse;
11907
11638
  isBuffer$2.exports;
11908
- (function(module, exports) {
11639
+ (function(module, exports$1) {
11909
11640
  var root2 = _root, stubFalse2 = stubFalse_1;
11910
- var freeExports = exports && !exports.nodeType && exports;
11641
+ var freeExports = exports$1 && !exports$1.nodeType && exports$1;
11911
11642
  var freeModule = freeExports && true && module && !module.nodeType && module;
11912
11643
  var moduleExports = freeModule && freeModule.exports === freeExports;
11913
11644
  var Buffer2 = moduleExports ? root2.Buffer : void 0;
@@ -11934,9 +11665,9 @@ function baseUnary$1(func) {
11934
11665
  var _baseUnary = baseUnary$1;
11935
11666
  var _nodeUtil = { exports: {} };
11936
11667
  _nodeUtil.exports;
11937
- (function(module, exports) {
11668
+ (function(module, exports$1) {
11938
11669
  var freeGlobal2 = _freeGlobal;
11939
- var freeExports = exports && !exports.nodeType && exports;
11670
+ var freeExports = exports$1 && !exports$1.nodeType && exports$1;
11940
11671
  var freeModule = freeExports && true && module && !module.nodeType && module;
11941
11672
  var moduleExports = freeModule && freeModule.exports === freeExports;
11942
11673
  var freeProcess = moduleExports && freeGlobal2.process;
@@ -12482,11 +12213,11 @@ function baseGet$2(object2, path2) {
12482
12213
  }
12483
12214
  var _baseGet = baseGet$2;
12484
12215
  var baseGet$1 = _baseGet;
12485
- function get$1(object2, path2, defaultValue) {
12216
+ function get$2(object2, path2, defaultValue) {
12486
12217
  var result = object2 == null ? void 0 : baseGet$1(object2, path2);
12487
12218
  return result === void 0 ? defaultValue : result;
12488
12219
  }
12489
- var get_1 = get$1;
12220
+ var get_1 = get$2;
12490
12221
  function baseHasIn$1(object2, key) {
12491
12222
  return object2 != null && key in Object(object2);
12492
12223
  }
@@ -12496,14 +12227,14 @@ function hasIn$1(object2, path2) {
12496
12227
  return object2 != null && hasPath(object2, path2, baseHasIn);
12497
12228
  }
12498
12229
  var hasIn_1 = hasIn$1;
12499
- var baseIsEqual = _baseIsEqual, get = get_1, hasIn = hasIn_1, isKey$1 = _isKey, isStrictComparable = _isStrictComparable, matchesStrictComparable = _matchesStrictComparable, toKey$1 = _toKey;
12230
+ var baseIsEqual = _baseIsEqual, get$1 = get_1, hasIn = hasIn_1, isKey$1 = _isKey, isStrictComparable = _isStrictComparable, matchesStrictComparable = _matchesStrictComparable, toKey$1 = _toKey;
12500
12231
  var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2;
12501
12232
  function baseMatchesProperty$1(path2, srcValue) {
12502
12233
  if (isKey$1(path2) && isStrictComparable(srcValue)) {
12503
12234
  return matchesStrictComparable(toKey$1(path2), srcValue);
12504
12235
  }
12505
12236
  return function(object2) {
12506
- var objValue = get(object2, path2);
12237
+ var objValue = get$1(object2, path2);
12507
12238
  return objValue === void 0 && objValue === srcValue ? hasIn(object2, path2) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
12508
12239
  };
12509
12240
  }
@@ -12799,7 +12530,7 @@ function createValidation(config2) {
12799
12530
  validate2.OPTIONS = config2;
12800
12531
  return validate2;
12801
12532
  }
12802
- let trim = (part) => part.substr(0, part.length - 1).substr(1);
12533
+ let trim$1 = (part) => part.substr(0, part.length - 1).substr(1);
12803
12534
  function getIn(schema2, path2, value, context = value) {
12804
12535
  let parent, lastPart, lastPartDebug;
12805
12536
  if (!path2) return {
@@ -12808,7 +12539,7 @@ function getIn(schema2, path2, value, context = value) {
12808
12539
  schema: schema2
12809
12540
  };
12810
12541
  propertyExpr.forEach(path2, (_part, isBracket, isArray2) => {
12811
- let part = isBracket ? trim(_part) : _part;
12542
+ let part = isBracket ? trim$1(_part) : _part;
12812
12543
  schema2 = schema2.resolve({
12813
12544
  context,
12814
12545
  parent,
@@ -14895,7 +14626,7 @@ function toIdentifier(str2) {
14895
14626
  Object.defineProperty(func, "name", desc);
14896
14627
  }
14897
14628
  }
14898
- function populateConstructorExports(exports, codes2, HttpError) {
14629
+ function populateConstructorExports(exports$1, codes2, HttpError) {
14899
14630
  codes2.forEach(function forEachCode(code) {
14900
14631
  var CodeError;
14901
14632
  var name = toIdentifier2(statuses$1.message[code]);
@@ -14908,8 +14639,8 @@ function toIdentifier(str2) {
14908
14639
  break;
14909
14640
  }
14910
14641
  if (CodeError) {
14911
- exports[code] = CodeError;
14912
- exports[name] = CodeError;
14642
+ exports$1[code] = CodeError;
14643
+ exports$1[name] = CodeError;
14913
14644
  }
14914
14645
  });
14915
14646
  }
@@ -14931,7 +14662,7 @@ const formatYupErrors = (yupError) => ({
14931
14662
  message: yupError.message
14932
14663
  });
14933
14664
  let ApplicationError$2 = class ApplicationError extends Error {
14934
- constructor(message = "An application error occured", details = {}) {
14665
+ constructor(message = "An application error occurred", details = {}) {
14935
14666
  super();
14936
14667
  this.name = "ApplicationError";
14937
14668
  this.message = message;
@@ -15195,7 +14926,7 @@ var pMap = async (iterable, mapper, {
15195
14926
  }
15196
14927
  const result = [];
15197
14928
  const errors2 = [];
15198
- const iterator = iterable[Symbol.iterator]();
14929
+ const iterator2 = iterable[Symbol.iterator]();
15199
14930
  let isRejected = false;
15200
14931
  let isIterableDone = false;
15201
14932
  let resolvingCount = 0;
@@ -15204,7 +14935,7 @@ var pMap = async (iterable, mapper, {
15204
14935
  if (isRejected) {
15205
14936
  return;
15206
14937
  }
15207
- const nextItem = iterator.next();
14938
+ const nextItem = iterator2.next();
15208
14939
  const index2 = currentIndex;
15209
14940
  currentIndex++;
15210
14941
  if (nextItem.done) {
@@ -16414,16 +16145,16 @@ var shebangCommand$1 = (string2 = "") => {
16414
16145
  }
16415
16146
  return argument ? `${binary2} ${argument}` : binary2;
16416
16147
  };
16417
- const fs$5 = require$$0$4;
16148
+ const fs$7 = require$$0$4;
16418
16149
  const shebangCommand = shebangCommand$1;
16419
16150
  function readShebang$1(command2) {
16420
16151
  const size = 150;
16421
16152
  const buffer = Buffer.alloc(size);
16422
16153
  let fd;
16423
16154
  try {
16424
- fd = fs$5.openSync(command2, "r");
16425
- fs$5.readSync(fd, buffer, 0, size, 0);
16426
- fs$5.closeSync(fd);
16155
+ fd = fs$7.openSync(command2, "r");
16156
+ fs$7.readSync(fd, buffer, 0, size, 0);
16157
+ fs$7.closeSync(fd);
16427
16158
  } catch (e) {
16428
16159
  }
16429
16160
  return shebangCommand(buffer.toString());
@@ -17434,9 +17165,9 @@ var bufferStream$1 = (options2) => {
17434
17165
  };
17435
17166
  const { constants: BufferConstants } = require$$0$7;
17436
17167
  const stream$1 = require$$0$6;
17437
- const { promisify: promisify$3 } = require$$2$1;
17168
+ const { promisify: promisify$5 } = require$$2$1;
17438
17169
  const bufferStream = bufferStream$1;
17439
- const streamPipelinePromisified = promisify$3(stream$1.pipeline);
17170
+ const streamPipelinePromisified = promisify$5(stream$1.pipeline);
17440
17171
  class MaxBufferError extends Error {
17441
17172
  constructor() {
17442
17173
  super("maxBuffer exceeded");
@@ -17972,11 +17703,11 @@ pLocate$4.exports = pLocate$3;
17972
17703
  pLocate$4.exports.default = pLocate$3;
17973
17704
  var pLocateExports = pLocate$4.exports;
17974
17705
  const path$4 = require$$0__default;
17975
- const fs$4 = require$$0$4;
17976
- const { promisify: promisify$2 } = require$$2$1;
17706
+ const fs$6 = require$$0$4;
17707
+ const { promisify: promisify$4 } = require$$2$1;
17977
17708
  const pLocate$2 = pLocateExports;
17978
- const fsStat$1 = promisify$2(fs$4.stat);
17979
- const fsLStat$1 = promisify$2(fs$4.lstat);
17709
+ const fsStat$1 = promisify$4(fs$6.stat);
17710
+ const fsLStat$1 = promisify$4(fs$6.lstat);
17980
17711
  const typeMappings$1 = {
17981
17712
  directory: "isDirectory",
17982
17713
  file: "isFile"
@@ -18014,7 +17745,7 @@ locatePath$1.exports.sync = (paths, options2) => {
18014
17745
  ...options2
18015
17746
  };
18016
17747
  checkType$1(options2);
18017
- const statFn = options2.allowSymlinks ? fs$4.statSync : fs$4.lstatSync;
17748
+ const statFn = options2.allowSymlinks ? fs$6.statSync : fs$6.lstatSync;
18018
17749
  for (const path_ of paths) {
18019
17750
  try {
18020
17751
  const stat = statFn(path$4.resolve(options2.cwd, path_));
@@ -18026,31 +17757,31 @@ locatePath$1.exports.sync = (paths, options2) => {
18026
17757
  }
18027
17758
  };
18028
17759
  var locatePathExports$1 = locatePath$1.exports;
18029
- var pathExists = { exports: {} };
18030
- const fs$3 = require$$0$4;
18031
- const { promisify: promisify$1 } = require$$2$1;
18032
- const pAccess = promisify$1(fs$3.access);
18033
- pathExists.exports = async (path2) => {
17760
+ var pathExists$2 = { exports: {} };
17761
+ const fs$5 = require$$0$4;
17762
+ const { promisify: promisify$3 } = require$$2$1;
17763
+ const pAccess$2 = promisify$3(fs$5.access);
17764
+ pathExists$2.exports = async (path2) => {
18034
17765
  try {
18035
- await pAccess(path2);
17766
+ await pAccess$2(path2);
18036
17767
  return true;
18037
17768
  } catch (_2) {
18038
17769
  return false;
18039
17770
  }
18040
17771
  };
18041
- pathExists.exports.sync = (path2) => {
17772
+ pathExists$2.exports.sync = (path2) => {
18042
17773
  try {
18043
- fs$3.accessSync(path2);
17774
+ fs$5.accessSync(path2);
18044
17775
  return true;
18045
17776
  } catch (_2) {
18046
17777
  return false;
18047
17778
  }
18048
17779
  };
18049
- var pathExistsExports = pathExists.exports;
17780
+ var pathExistsExports$1 = pathExists$2.exports;
18050
17781
  (function(module) {
18051
17782
  const path2 = require$$0__default;
18052
17783
  const locatePath2 = locatePathExports$1;
18053
- const pathExists2 = pathExistsExports;
17784
+ const pathExists2 = pathExistsExports$1;
18054
17785
  const stop = Symbol("findUp.stop");
18055
17786
  module.exports = async (name, options2 = {}) => {
18056
17787
  let directory = path2.resolve(options2.cwd || "");
@@ -18127,8 +17858,8 @@ pkgDir$1.exports.sync = (cwd2) => {
18127
17858
  };
18128
17859
  var pkgDirExports = pkgDir$1.exports;
18129
17860
  var utils$8 = {};
18130
- (function(exports) {
18131
- exports.isInteger = (num) => {
17861
+ (function(exports$1) {
17862
+ exports$1.isInteger = (num) => {
18132
17863
  if (typeof num === "number") {
18133
17864
  return Number.isInteger(num);
18134
17865
  }
@@ -18137,13 +17868,13 @@ var utils$8 = {};
18137
17868
  }
18138
17869
  return false;
18139
17870
  };
18140
- exports.find = (node, type2) => node.nodes.find((node2) => node2.type === type2);
18141
- exports.exceedsLimit = (min, max, step = 1, limit) => {
17871
+ exports$1.find = (node, type2) => node.nodes.find((node2) => node2.type === type2);
17872
+ exports$1.exceedsLimit = (min, max, step = 1, limit) => {
18142
17873
  if (limit === false) return false;
18143
- if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
17874
+ if (!exports$1.isInteger(min) || !exports$1.isInteger(max)) return false;
18144
17875
  return (Number(max) - Number(min)) / Number(step) >= limit;
18145
17876
  };
18146
- exports.escapeNode = (block, n = 0, type2) => {
17877
+ exports$1.escapeNode = (block, n = 0, type2) => {
18147
17878
  const node = block.nodes[n];
18148
17879
  if (!node) return;
18149
17880
  if (type2 && node.type === type2 || node.type === "open" || node.type === "close") {
@@ -18153,7 +17884,7 @@ var utils$8 = {};
18153
17884
  }
18154
17885
  }
18155
17886
  };
18156
- exports.encloseBrace = (node) => {
17887
+ exports$1.encloseBrace = (node) => {
18157
17888
  if (node.type !== "brace") return false;
18158
17889
  if (node.commas >> 0 + node.ranges >> 0 === 0) {
18159
17890
  node.invalid = true;
@@ -18161,7 +17892,7 @@ var utils$8 = {};
18161
17892
  }
18162
17893
  return false;
18163
17894
  };
18164
- exports.isInvalidBrace = (block) => {
17895
+ exports$1.isInvalidBrace = (block) => {
18165
17896
  if (block.type !== "brace") return false;
18166
17897
  if (block.invalid === true || block.dollar) return true;
18167
17898
  if (block.commas >> 0 + block.ranges >> 0 === 0) {
@@ -18174,18 +17905,18 @@ var utils$8 = {};
18174
17905
  }
18175
17906
  return false;
18176
17907
  };
18177
- exports.isOpenOrClose = (node) => {
17908
+ exports$1.isOpenOrClose = (node) => {
18178
17909
  if (node.type === "open" || node.type === "close") {
18179
17910
  return true;
18180
17911
  }
18181
17912
  return node.open === true || node.close === true;
18182
17913
  };
18183
- exports.reduce = (nodes) => nodes.reduce((acc, node) => {
17914
+ exports$1.reduce = (nodes) => nodes.reduce((acc, node) => {
18184
17915
  if (node.type === "text") acc.push(node.value);
18185
17916
  if (node.type === "range") node.type = "text";
18186
17917
  return acc;
18187
17918
  }, []);
18188
- exports.flatten = (...args) => {
17919
+ exports$1.flatten = (...args) => {
18189
17920
  const result = [];
18190
17921
  const flat = (arr) => {
18191
17922
  for (let i = 0; i < arr.length; i++) {
@@ -19287,7 +19018,7 @@ var constants$5 = {
19287
19018
  return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
19288
19019
  }
19289
19020
  };
19290
- (function(exports) {
19021
+ (function(exports$1) {
19291
19022
  const path2 = require$$0__default;
19292
19023
  const win32 = process.platform === "win32";
19293
19024
  const {
@@ -19296,36 +19027,36 @@ var constants$5 = {
19296
19027
  REGEX_SPECIAL_CHARS,
19297
19028
  REGEX_SPECIAL_CHARS_GLOBAL
19298
19029
  } = constants$5;
19299
- exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
19300
- exports.hasRegexChars = (str2) => REGEX_SPECIAL_CHARS.test(str2);
19301
- exports.isRegexChar = (str2) => str2.length === 1 && exports.hasRegexChars(str2);
19302
- exports.escapeRegex = (str2) => str2.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
19303
- exports.toPosixSlashes = (str2) => str2.replace(REGEX_BACKSLASH, "/");
19304
- exports.removeBackslashes = (str2) => {
19030
+ exports$1.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
19031
+ exports$1.hasRegexChars = (str2) => REGEX_SPECIAL_CHARS.test(str2);
19032
+ exports$1.isRegexChar = (str2) => str2.length === 1 && exports$1.hasRegexChars(str2);
19033
+ exports$1.escapeRegex = (str2) => str2.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
19034
+ exports$1.toPosixSlashes = (str2) => str2.replace(REGEX_BACKSLASH, "/");
19035
+ exports$1.removeBackslashes = (str2) => {
19305
19036
  return str2.replace(REGEX_REMOVE_BACKSLASH, (match) => {
19306
19037
  return match === "\\" ? "" : match;
19307
19038
  });
19308
19039
  };
19309
- exports.supportsLookbehinds = () => {
19040
+ exports$1.supportsLookbehinds = () => {
19310
19041
  const segs = process.version.slice(1).split(".").map(Number);
19311
19042
  if (segs.length === 3 && segs[0] >= 9 || segs[0] === 8 && segs[1] >= 10) {
19312
19043
  return true;
19313
19044
  }
19314
19045
  return false;
19315
19046
  };
19316
- exports.isWindows = (options2) => {
19047
+ exports$1.isWindows = (options2) => {
19317
19048
  if (options2 && typeof options2.windows === "boolean") {
19318
19049
  return options2.windows;
19319
19050
  }
19320
19051
  return win32 === true || path2.sep === "\\";
19321
19052
  };
19322
- exports.escapeLast = (input, char, lastIdx) => {
19053
+ exports$1.escapeLast = (input, char, lastIdx) => {
19323
19054
  const idx = input.lastIndexOf(char, lastIdx);
19324
19055
  if (idx === -1) return input;
19325
- if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
19056
+ if (input[idx - 1] === "\\") return exports$1.escapeLast(input, char, idx - 1);
19326
19057
  return `${input.slice(0, idx)}\\${input.slice(idx)}`;
19327
19058
  };
19328
- exports.removePrefix = (input, state = {}) => {
19059
+ exports$1.removePrefix = (input, state = {}) => {
19329
19060
  let output = input;
19330
19061
  if (output.startsWith("./")) {
19331
19062
  output = output.slice(2);
@@ -19333,7 +19064,7 @@ var constants$5 = {
19333
19064
  }
19334
19065
  return output;
19335
19066
  };
19336
- exports.wrapOutput = (input, state = {}, options2 = {}) => {
19067
+ exports$1.wrapOutput = (input, state = {}, options2 = {}) => {
19337
19068
  const prepend = options2.contains ? "" : "^";
19338
19069
  const append2 = options2.contains ? "" : "$";
19339
19070
  let output = `${prepend}(?:${input})${append2}`;
@@ -20804,14 +20535,14 @@ const core_1 = core$1;
20804
20535
  core_1.findWorkspaceRoot;
20805
20536
  var findUp = { exports: {} };
20806
20537
  var locatePath = { exports: {} };
20807
- class Node {
20538
+ let Node$1 = class Node {
20808
20539
  /// value;
20809
20540
  /// next;
20810
20541
  constructor(value) {
20811
20542
  this.value = value;
20812
20543
  this.next = void 0;
20813
20544
  }
20814
- }
20545
+ };
20815
20546
  let Queue$1 = class Queue {
20816
20547
  // TODO: Use private class fields when targeting Node.js 12.
20817
20548
  // #_head;
@@ -20821,7 +20552,7 @@ let Queue$1 = class Queue {
20821
20552
  this.clear();
20822
20553
  }
20823
20554
  enqueue(value) {
20824
- const node = new Node(value);
20555
+ const node = new Node$1(value);
20825
20556
  if (this._head) {
20826
20557
  this._tail.next = node;
20827
20558
  this._tail = node;
@@ -20943,11 +20674,11 @@ const pLocate$1 = async (iterable, tester, options2) => {
20943
20674
  };
20944
20675
  var pLocate_1 = pLocate$1;
20945
20676
  const path = require$$0__default;
20946
- const fs$2 = require$$0$4;
20947
- const { promisify } = require$$2$1;
20677
+ const fs$4 = require$$0$4;
20678
+ const { promisify: promisify$2 } = require$$2$1;
20948
20679
  const pLocate = pLocate_1;
20949
- const fsStat = promisify(fs$2.stat);
20950
- const fsLStat = promisify(fs$2.lstat);
20680
+ const fsStat = promisify$2(fs$4.stat);
20681
+ const fsLStat = promisify$2(fs$4.lstat);
20951
20682
  const typeMappings = {
20952
20683
  directory: "isDirectory",
20953
20684
  file: "isFile"
@@ -20985,7 +20716,7 @@ locatePath.exports.sync = (paths, options2) => {
20985
20716
  ...options2
20986
20717
  };
20987
20718
  checkType(options2);
20988
- const statFn = options2.allowSymlinks ? fs$2.statSync : fs$2.lstatSync;
20719
+ const statFn = options2.allowSymlinks ? fs$4.statSync : fs$4.lstatSync;
20989
20720
  for (const path_ of paths) {
20990
20721
  try {
20991
20722
  const stat = statFn(path.resolve(options2.cwd, path_));
@@ -20997,6 +20728,27 @@ locatePath.exports.sync = (paths, options2) => {
20997
20728
  }
20998
20729
  };
20999
20730
  var locatePathExports = locatePath.exports;
20731
+ var pathExists$1 = { exports: {} };
20732
+ const fs$3 = require$$0$4;
20733
+ const { promisify: promisify$1 } = require$$2$1;
20734
+ const pAccess$1 = promisify$1(fs$3.access);
20735
+ pathExists$1.exports = async (path2) => {
20736
+ try {
20737
+ await pAccess$1(path2);
20738
+ return true;
20739
+ } catch (_2) {
20740
+ return false;
20741
+ }
20742
+ };
20743
+ pathExists$1.exports.sync = (path2) => {
20744
+ try {
20745
+ fs$3.accessSync(path2);
20746
+ return true;
20747
+ } catch (_2) {
20748
+ return false;
20749
+ }
20750
+ };
20751
+ var pathExistsExports = pathExists$1.exports;
21000
20752
  (function(module) {
21001
20753
  const path2 = require$$0__default;
21002
20754
  const locatePath2 = locatePathExports;
@@ -21062,6 +20814,26 @@ var locatePathExports = locatePath.exports;
21062
20814
  module.exports.sync.exists = pathExists2.sync;
21063
20815
  module.exports.stop = stop;
21064
20816
  })(findUp);
20817
+ var pathExists = { exports: {} };
20818
+ const fs$2 = require$$0$4;
20819
+ const { promisify } = require$$2$1;
20820
+ const pAccess = promisify(fs$2.access);
20821
+ pathExists.exports = async (path2) => {
20822
+ try {
20823
+ await pAccess(path2);
20824
+ return true;
20825
+ } catch (_2) {
20826
+ return false;
20827
+ }
20828
+ };
20829
+ pathExists.exports.sync = (path2) => {
20830
+ try {
20831
+ fs$2.accessSync(path2);
20832
+ return true;
20833
+ } catch (_2) {
20834
+ return false;
20835
+ }
20836
+ };
21065
20837
  var loadYamlFile = { exports: {} };
21066
20838
  var constants$2 = require$$0$8;
21067
20839
  var origCwd = process.cwd;
@@ -22888,6 +22660,18 @@ function charFromCodepoint(c) {
22888
22660
  (c - 65536 & 1023) + 56320
22889
22661
  );
22890
22662
  }
22663
+ function setProperty(object2, key, value) {
22664
+ if (key === "__proto__") {
22665
+ Object.defineProperty(object2, key, {
22666
+ configurable: true,
22667
+ enumerable: true,
22668
+ writable: true,
22669
+ value
22670
+ });
22671
+ } else {
22672
+ object2[key] = value;
22673
+ }
22674
+ }
22891
22675
  var simpleEscapeCheck = new Array(256);
22892
22676
  var simpleEscapeMap = new Array(256);
22893
22677
  for (var i = 0; i < 256; i++) {
@@ -22994,7 +22778,7 @@ function mergeMappings(state, destination, source, overridableKeys) {
22994
22778
  for (index2 = 0, quantity = sourceKeys.length; index2 < quantity; index2 += 1) {
22995
22779
  key = sourceKeys[index2];
22996
22780
  if (!_hasOwnProperty$1.call(destination, key)) {
22997
- destination[key] = source[key];
22781
+ setProperty(destination, key, source[key]);
22998
22782
  overridableKeys[key] = true;
22999
22783
  }
23000
22784
  }
@@ -23033,7 +22817,7 @@ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valu
23033
22817
  state.position = startPos || state.position;
23034
22818
  throwError(state, "duplicated mapping key");
23035
22819
  }
23036
- _result[keyNode] = valueNode;
22820
+ setProperty(_result, keyNode, valueNode);
23037
22821
  delete overridableKeys[keyNode];
23038
22822
  }
23039
22823
  return _result;
@@ -23877,17 +23661,17 @@ function loadDocuments(input, options2) {
23877
23661
  }
23878
23662
  return state.documents;
23879
23663
  }
23880
- function loadAll(input, iterator, options2) {
23881
- if (iterator !== null && typeof iterator === "object" && typeof options2 === "undefined") {
23882
- options2 = iterator;
23883
- iterator = null;
23664
+ function loadAll(input, iterator2, options2) {
23665
+ if (iterator2 !== null && typeof iterator2 === "object" && typeof options2 === "undefined") {
23666
+ options2 = iterator2;
23667
+ iterator2 = null;
23884
23668
  }
23885
23669
  var documents = loadDocuments(input, options2);
23886
- if (typeof iterator !== "function") {
23670
+ if (typeof iterator2 !== "function") {
23887
23671
  return documents;
23888
23672
  }
23889
23673
  for (var index2 = 0, length = documents.length; index2 < length; index2 += 1) {
23890
- iterator(documents[index2]);
23674
+ iterator2(documents[index2]);
23891
23675
  }
23892
23676
  }
23893
23677
  function load(input, options2) {
@@ -23899,12 +23683,12 @@ function load(input, options2) {
23899
23683
  }
23900
23684
  throw new YAMLException$1("expected a single document in the stream, but found more");
23901
23685
  }
23902
- function safeLoadAll(input, iterator, options2) {
23903
- if (typeof iterator === "object" && iterator !== null && typeof options2 === "undefined") {
23904
- options2 = iterator;
23905
- iterator = null;
23686
+ function safeLoadAll(input, iterator2, options2) {
23687
+ if (typeof iterator2 === "object" && iterator2 !== null && typeof options2 === "undefined") {
23688
+ options2 = iterator2;
23689
+ iterator2 = null;
23906
23690
  }
23907
- return loadAll(input, iterator, common$1.extend({ schema: DEFAULT_SAFE_SCHEMA$1 }, options2));
23691
+ return loadAll(input, iterator2, common$1.extend({ schema: DEFAULT_SAFE_SCHEMA$1 }, options2));
23908
23692
  }
23909
23693
  function safeLoad(input, options2) {
23910
23694
  return load(input, common$1.extend({ schema: DEFAULT_SAFE_SCHEMA$1 }, options2));
@@ -28936,6 +28720,250 @@ _enum([
28936
28720
  "published"
28937
28721
  ]).describe("Filter by publication status");
28938
28722
  string().describe("Search query string");
28723
+ const pluginName = "firebase-authentication";
28724
+ const PLUGIN_NAME = "firebase-authentication";
28725
+ const PLUGIN_UID = `plugin::${PLUGIN_NAME}`;
28726
+ const CONFIG_CONTENT_TYPE = `${PLUGIN_UID}.firebase-authentication-configuration`;
28727
+ const DEFAULT_PASSWORD_RESET_URL = "http://localhost:3000/reset-password";
28728
+ const DEFAULT_PASSWORD_REGEX = "^.{6,}$";
28729
+ const DEFAULT_PASSWORD_MESSAGE = "Password must be at least 6 characters long";
28730
+ const DEFAULT_RESET_EMAIL_SUBJECT = "Reset Your Password";
28731
+ const ERROR_MESSAGES = {
28732
+ FIREBASE_NOT_INITIALIZED: "Firebase is not initialized. Please upload Firebase service account configuration via Settings → Firebase Authentication.",
28733
+ INVALID_JSON: "Invalid JSON format. Please ensure you copied the entire JSON content correctly.",
28734
+ MISSING_DATA: "data is missing",
28735
+ SOMETHING_WENT_WRONG: "Something went wrong",
28736
+ AUTHENTICATION_FAILED: "Authentication failed",
28737
+ TOKEN_MISSING: "idToken is missing!",
28738
+ EMAIL_PASSWORD_REQUIRED: "Email and password are required",
28739
+ PASSWORD_REQUIRED: "Password is required",
28740
+ AUTHORIZATION_REQUIRED: "Authorization token is required",
28741
+ INVALID_TOKEN: "Invalid or expired token",
28742
+ USER_NOT_FOUND: "User not found",
28743
+ USER_NO_EMAIL: "User does not have an email address",
28744
+ FIREBASE_LINK_FAILED: "Failed to generate Firebase reset link",
28745
+ CONFIG_NOT_FOUND: "No config found",
28746
+ INVALID_SERVICE_ACCOUNT: "Invalid service account JSON",
28747
+ WEB_API_NOT_CONFIGURED: "Email/password authentication is not available. Web API Key is not configured.",
28748
+ RESET_URL_NOT_CONFIGURED: "Password reset URL is not configured",
28749
+ RESET_URL_MUST_BE_HTTPS: "Password reset URL must use HTTPS in production",
28750
+ RESET_URL_INVALID_FORMAT: "Password reset URL is not a valid URL format",
28751
+ USER_NOT_LINKED_FIREBASE: "User is not linked to Firebase authentication",
28752
+ OVERRIDE_USER_ID_REQUIRED: "Override user ID is required",
28753
+ EITHER_EMAIL_OR_PHONE_REQUIRED: "Either email or phoneNumber is required",
28754
+ DELETION_NO_CONFIG: "No Firebase configs exists for deletion"
28755
+ };
28756
+ const SUCCESS_MESSAGES = {
28757
+ FIREBASE_INITIALIZED: "Firebase successfully initialized",
28758
+ FIREBASE_CONFIG_DELETED: "Firebase config deleted and reinitialized",
28759
+ PASSWORD_RESET_EMAIL_SENT: "If an account with that email exists, a password reset link has been sent.",
28760
+ SERVER_RESTARTING: "SERVER IS RESTARTING"
28761
+ };
28762
+ const CONFIG_KEYS = {
28763
+ ENCRYPTION_KEY: `${PLUGIN_UID}.FIREBASE_JSON_ENCRYPTION_KEY`
28764
+ };
28765
+ const REQUIRED_FIELDS = {
28766
+ SERVICE_ACCOUNT: ["private_key", "client_email", "project_id", "type"],
28767
+ WEB_CONFIG: ["apiKey", "authDomain"]
28768
+ // These indicate wrong JSON type
28769
+ };
28770
+ const VALIDATION_MESSAGES = {
28771
+ INVALID_SERVICE_ACCOUNT: "Invalid Service Account JSON. Missing required fields:",
28772
+ 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.",
28773
+ 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!"
28774
+ };
28775
+ const firebaseController = {
28776
+ async validateToken(ctx) {
28777
+ strapi.log.debug("validateToken called");
28778
+ try {
28779
+ const { idToken, profileMetaData } = ctx.request.body || {};
28780
+ const populate2 = ctx.request.query.populate || [];
28781
+ if (!idToken) {
28782
+ return ctx.badRequest(ERROR_MESSAGES.TOKEN_MISSING);
28783
+ }
28784
+ const result = await strapi.plugin(pluginName).service("firebaseService").validateFirebaseToken(idToken, profileMetaData, populate2);
28785
+ ctx.body = result;
28786
+ } catch (error2) {
28787
+ strapi.log.error(`validateToken controller error: ${error2.message}`);
28788
+ if (error2.name === "ValidationError") {
28789
+ return ctx.badRequest(error2.message);
28790
+ }
28791
+ if (error2.name === "UnauthorizedError") {
28792
+ return ctx.unauthorized(error2.message);
28793
+ }
28794
+ throw error2;
28795
+ }
28796
+ },
28797
+ async deleteByEmail(email2) {
28798
+ try {
28799
+ const user = await strapi.firebase.auth().getUserByEmail(email2);
28800
+ await strapi.plugin(pluginName).service("firebaseService").delete(user.toJSON().uid);
28801
+ return user.toJSON();
28802
+ } catch (error2) {
28803
+ strapi.log.error("deleteByEmail error:", error2);
28804
+ throw error2;
28805
+ }
28806
+ },
28807
+ async overrideAccess(ctx) {
28808
+ try {
28809
+ const { overrideUserId } = ctx.request.body || {};
28810
+ const populate2 = ctx.request.query.populate || [];
28811
+ const result = await strapi.plugin(pluginName).service("firebaseService").overrideFirebaseAccess(overrideUserId, populate2);
28812
+ ctx.body = result;
28813
+ } catch (error2) {
28814
+ if (error2.name === "ValidationError") {
28815
+ return ctx.badRequest(error2.message);
28816
+ }
28817
+ if (error2.name === "NotFoundError") {
28818
+ return ctx.notFound(error2.message);
28819
+ }
28820
+ throw error2;
28821
+ }
28822
+ },
28823
+ /**
28824
+ * Controller method for email/password authentication
28825
+ * Handles the `/api/firebase-authentication/emailLogin` endpoint
28826
+ *
28827
+ * @param ctx - Koa context object
28828
+ * @returns Promise that sets ctx.body with user data and JWT or error message
28829
+ *
28830
+ * @remarks
28831
+ * This controller acts as a proxy to Firebase's Identity Toolkit API,
28832
+ * allowing users to authenticate with email/password and receive a Strapi JWT.
28833
+ *
28834
+ * HTTP Status Codes:
28835
+ * - `400`: Validation errors (missing credentials, invalid email/password)
28836
+ * - `500`: Server errors (missing configuration, Firebase API issues)
28837
+ */
28838
+ async emailLogin(ctx) {
28839
+ strapi.log.debug("emailLogin controller");
28840
+ try {
28841
+ const { email: email2, password } = ctx.request.body || {};
28842
+ const populate2 = ctx.request.query.populate || [];
28843
+ const result = await strapi.plugin(pluginName).service("firebaseService").emailLogin(email2, password, populate2);
28844
+ ctx.body = result;
28845
+ } catch (error2) {
28846
+ strapi.log.error("emailLogin controller error:", error2);
28847
+ throw error2;
28848
+ }
28849
+ },
28850
+ /**
28851
+ * Forgot password - sends reset email
28852
+ * POST /api/firebase-authentication/forgotPassword
28853
+ * Public endpoint - no authentication required
28854
+ */
28855
+ async forgotPassword(ctx) {
28856
+ strapi.log.debug("forgotPassword endpoint called");
28857
+ try {
28858
+ const { email: email2 } = ctx.request.body || {};
28859
+ ctx.body = await strapi.plugin(pluginName).service("firebaseService").forgotPassword(email2);
28860
+ } catch (error2) {
28861
+ strapi.log.error("forgotPassword controller error:", error2);
28862
+ throw error2;
28863
+ }
28864
+ },
28865
+ /**
28866
+ * Reset password - authenticated password change
28867
+ * POST /api/firebase-authentication/resetPassword
28868
+ * Authenticated endpoint - requires valid JWT (enforced by is-authenticated policy)
28869
+ * Used for admin-initiated resets or user self-service password changes
28870
+ * NOT used for forgot password email flow (which uses Firebase's hosted UI)
28871
+ */
28872
+ async resetPassword(ctx) {
28873
+ strapi.log.debug("resetPassword endpoint called");
28874
+ try {
28875
+ const { password } = ctx.request.body || {};
28876
+ const user = ctx.state.user;
28877
+ const populate2 = ctx.request.query.populate || [];
28878
+ ctx.body = await strapi.plugin(pluginName).service("firebaseService").resetPassword(password, user, populate2);
28879
+ } catch (error2) {
28880
+ strapi.log.error("resetPassword controller error:", error2);
28881
+ throw error2;
28882
+ }
28883
+ },
28884
+ async requestMagicLink(ctx) {
28885
+ try {
28886
+ const { email: email2 } = ctx.request.body || {};
28887
+ const result = await strapi.plugin("firebase-authentication").service("firebaseService").requestMagicLink(email2);
28888
+ ctx.body = result;
28889
+ } catch (error2) {
28890
+ if (error2.name === "ValidationError" || error2.name === "ApplicationError") {
28891
+ throw error2;
28892
+ }
28893
+ strapi.log.error("requestMagicLink controller error:", error2);
28894
+ ctx.body = {
28895
+ success: false,
28896
+ message: "An error occurred while processing your request"
28897
+ };
28898
+ }
28899
+ },
28900
+ /**
28901
+ * Reset password using custom JWT token
28902
+ * POST /api/firebase-authentication/resetPasswordWithToken
28903
+ * Public endpoint - token provides authentication
28904
+ *
28905
+ * @param ctx - Koa context with { token, newPassword } in body
28906
+ * @returns { success: true, message: "Password has been reset successfully" }
28907
+ */
28908
+ async resetPasswordWithToken(ctx) {
28909
+ strapi.log.debug("resetPasswordWithToken endpoint called");
28910
+ try {
28911
+ const { token, newPassword } = ctx.request.body || {};
28912
+ if (!token) {
28913
+ throw new ValidationError$1("Token is required");
28914
+ }
28915
+ if (!newPassword) {
28916
+ throw new ValidationError$1("New password is required");
28917
+ }
28918
+ const result = await strapi.plugin(pluginName).service("userService").resetPasswordWithToken(token, newPassword);
28919
+ ctx.body = result;
28920
+ } catch (error2) {
28921
+ strapi.log.error("resetPasswordWithToken controller error:", error2);
28922
+ throw error2;
28923
+ }
28924
+ },
28925
+ /**
28926
+ * Send email verification - public endpoint
28927
+ * POST /api/firebase-authentication/sendVerificationEmail
28928
+ * Authenticated endpoint - sends verification email to the logged-in user's email
28929
+ */
28930
+ async sendVerificationEmail(ctx) {
28931
+ strapi.log.debug("sendVerificationEmail endpoint called");
28932
+ try {
28933
+ const user = ctx.state.user;
28934
+ const email2 = user.email;
28935
+ ctx.body = await strapi.plugin(pluginName).service("firebaseService").sendVerificationEmail(email2);
28936
+ } catch (error2) {
28937
+ strapi.log.error("sendVerificationEmail controller error:", error2);
28938
+ throw error2;
28939
+ }
28940
+ },
28941
+ /**
28942
+ * Verify email using custom JWT token
28943
+ * POST /api/firebase-authentication/verifyEmail
28944
+ * Public endpoint - token provides authentication
28945
+ *
28946
+ * @param ctx - Koa context with { token } in body
28947
+ * @returns { success: true, message: "Email verified successfully" }
28948
+ */
28949
+ async verifyEmail(ctx) {
28950
+ strapi.log.debug("verifyEmail endpoint called");
28951
+ try {
28952
+ const { token } = ctx.request.body || {};
28953
+ if (!token) {
28954
+ return ctx.badRequest("Token is required");
28955
+ }
28956
+ const result = await strapi.plugin(pluginName).service("firebaseService").verifyEmail(token);
28957
+ ctx.body = result;
28958
+ } catch (error2) {
28959
+ strapi.log.error("verifyEmail controller error:", error2);
28960
+ if (error2.name === "ValidationError") {
28961
+ return ctx.badRequest(error2.message);
28962
+ }
28963
+ throw error2;
28964
+ }
28965
+ }
28966
+ };
28939
28967
  const STRAPI_DESTINATION = "strapi";
28940
28968
  const FIREBASE_DESTINATION = "firebase";
28941
28969
  const userController = {
@@ -29197,7 +29225,16 @@ const controllers = {
29197
29225
  settingsController
29198
29226
  };
29199
29227
  const middlewares = {};
29200
- const policies = {};
29228
+ const isAuthenticated = async (policyContext) => {
29229
+ const user = policyContext.state.user;
29230
+ if (!user) {
29231
+ throw new UnauthorizedError("Authentication required");
29232
+ }
29233
+ return true;
29234
+ };
29235
+ const policies = {
29236
+ "is-authenticated": isAuthenticated
29237
+ };
29201
29238
  const settingsRoute = [
29202
29239
  {
29203
29240
  method: "POST",
@@ -29347,9 +29384,7 @@ const contentApi = {
29347
29384
  path: "/resetPassword",
29348
29385
  handler: "firebaseController.resetPassword",
29349
29386
  config: {
29350
- auth: false,
29351
- // Public endpoint - authenticated password change, requires valid JWT in Authorization header
29352
- policies: []
29387
+ policies: ["plugin::firebase-authentication.is-authenticated"]
29353
29388
  }
29354
29389
  },
29355
29390
  {
@@ -29387,9 +29422,7 @@ const contentApi = {
29387
29422
  path: "/sendVerificationEmail",
29388
29423
  handler: "firebaseController.sendVerificationEmail",
29389
29424
  config: {
29390
- auth: false,
29391
- // Public endpoint - sends email verification link
29392
- policies: []
29425
+ policies: ["plugin::firebase-authentication.is-authenticated"]
29393
29426
  }
29394
29427
  },
29395
29428
  {
@@ -30898,20 +30931,17 @@ const firebaseService = ({ strapi: strapi2 }) => ({
30898
30931
  * 2. User-initiated password change (when already authenticated)
30899
30932
  *
30900
30933
  * NOT used for forgot password email flow - that now uses Firebase's hosted UI
30934
+ *
30935
+ * @param password - New password to set
30936
+ * @param user - Authenticated user from ctx.state.user (populated by is-authenticated policy)
30937
+ * @param populate - Fields to populate in response
30901
30938
  */
30902
- resetPassword: async (password, token, populate2) => {
30939
+ resetPassword: async (password, user, populate2) => {
30903
30940
  if (!password) {
30904
30941
  throw new ValidationError$1("Password is required");
30905
30942
  }
30906
- if (!token) {
30907
- throw new UnauthorizedError("Authorization token is required");
30908
- }
30909
- let decoded;
30910
- try {
30911
- const jwtService = strapi2.plugin("users-permissions").service("jwt");
30912
- decoded = await jwtService.verify(token);
30913
- } catch (error2) {
30914
- throw new UnauthorizedError("Invalid or expired token");
30943
+ if (!user || !user.id) {
30944
+ throw new UnauthorizedError("Authentication required");
30915
30945
  }
30916
30946
  const config2 = await strapi2.plugin("firebase-authentication").service("settingsService").getFirebaseConfigJson();
30917
30947
  const passwordRegex = config2?.passwordRequirementsRegex || "^.{6,}$";
@@ -30922,8 +30952,7 @@ const firebaseService = ({ strapi: strapi2 }) => ({
30922
30952
  }
30923
30953
  try {
30924
30954
  const strapiUser = await strapi2.db.query("plugin::users-permissions.user").findOne({
30925
- where: { id: decoded.id }
30926
- // Use numeric id from JWT
30955
+ where: { id: user.id }
30927
30956
  });
30928
30957
  if (!strapiUser) {
30929
30958
  throw new NotFoundError("User not found");
@@ -31126,6 +31155,22 @@ const firebaseService = ({ strapi: strapi2 }) => ({
31126
31155
  const tokenService2 = strapi2.plugin("firebase-authentication").service("tokenService");
31127
31156
  const validationResult = await tokenService2.validateVerificationToken(token);
31128
31157
  if (!validationResult.valid) {
31158
+ if (validationResult.code === "TOKEN_ALREADY_USED" && validationResult.firebaseUID) {
31159
+ try {
31160
+ const firebaseUser = await strapi2.firebase.auth().getUser(validationResult.firebaseUID);
31161
+ if (firebaseUser.emailVerified) {
31162
+ strapi2.log.info(
31163
+ `[verifyEmail] Token already used but email is verified for: ${firebaseUser.email}`
31164
+ );
31165
+ return {
31166
+ success: true,
31167
+ message: "This email has already been verified."
31168
+ };
31169
+ }
31170
+ } catch (checkError) {
31171
+ strapi2.log.warn(`[verifyEmail] Could not verify Firebase user status: ${checkError.message}`);
31172
+ }
31173
+ }
31129
31174
  strapi2.log.warn(`[verifyEmail] Token validation failed: ${validationResult.error}`);
31130
31175
  throw new ValidationError$1(validationResult.error || "Invalid verification link");
31131
31176
  }
@@ -31724,7 +31769,7 @@ class TemplateService {
31724
31769
  if (userTemplate.htmlFile) {
31725
31770
  try {
31726
31771
  const htmlPath = require$$0$1.resolve(userTemplate.htmlFile);
31727
- mergedTemplate.html = await fs$6.readFile(htmlPath, "utf-8");
31772
+ mergedTemplate.html = await fs$8.readFile(htmlPath, "utf-8");
31728
31773
  } catch (error2) {
31729
31774
  strapi.log.warn(
31730
31775
  `Failed to load HTML template from ${userTemplate.htmlFile}: ${error2.message}. Using default template.`
@@ -31736,7 +31781,7 @@ class TemplateService {
31736
31781
  if (userTemplate.textFile) {
31737
31782
  try {
31738
31783
  const textPath = require$$0$1.resolve(userTemplate.textFile);
31739
- mergedTemplate.text = await fs$6.readFile(textPath, "utf-8");
31784
+ mergedTemplate.text = await fs$8.readFile(textPath, "utf-8");
31740
31785
  } catch (error2) {
31741
31786
  strapi.log.warn(
31742
31787
  `Failed to load text template from ${userTemplate.textFile}: ${error2.message}. Using default template.`
@@ -32585,7 +32630,7 @@ var TokenExpiredError_1 = TokenExpiredError$1;
32585
32630
  var jws$3 = {};
32586
32631
  var safeBuffer = { exports: {} };
32587
32632
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
32588
- (function(module, exports) {
32633
+ (function(module, exports$1) {
32589
32634
  var buffer = require$$0$7;
32590
32635
  var Buffer2 = buffer.Buffer;
32591
32636
  function copyProps(src, dst) {
@@ -32596,8 +32641,8 @@ var safeBuffer = { exports: {} };
32596
32641
  if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
32597
32642
  module.exports = buffer;
32598
32643
  } else {
32599
- copyProps(buffer, exports);
32600
- exports.Buffer = SafeBuffer;
32644
+ copyProps(buffer, exports$1);
32645
+ exports$1.Buffer = SafeBuffer;
32601
32646
  }
32602
32647
  function SafeBuffer(arg, encodingOrOffset, length) {
32603
32648
  return Buffer2(arg, encodingOrOffset, length);
@@ -33112,7 +33157,12 @@ function jwsSign(opts) {
33112
33157
  return util$1.format("%s.%s", securedInput, signature);
33113
33158
  }
33114
33159
  function SignStream$1(opts) {
33115
- var secret = opts.secret || opts.privateKey || opts.key;
33160
+ var secret = opts.secret;
33161
+ secret = secret == null ? opts.privateKey : secret;
33162
+ secret = secret == null ? opts.key : secret;
33163
+ if (/^hs/i.test(opts.header.alg) === true && secret == null) {
33164
+ throw new TypeError("secret must be a string or buffer or a KeyObject");
33165
+ }
33116
33166
  var secretStream = new DataStream$1(secret);
33117
33167
  this.readable = true;
33118
33168
  this.header = opts.header;
@@ -33218,7 +33268,12 @@ function jwsDecode(jwsSig, opts) {
33218
33268
  }
33219
33269
  function VerifyStream$1(opts) {
33220
33270
  opts = opts || {};
33221
- var secretOrKey = opts.secret || opts.publicKey || opts.key;
33271
+ var secretOrKey = opts.secret;
33272
+ secretOrKey = secretOrKey == null ? opts.publicKey : secretOrKey;
33273
+ secretOrKey = secretOrKey == null ? opts.key : secretOrKey;
33274
+ if (/^hs/i.test(opts.algorithm) === true && secretOrKey == null) {
33275
+ throw new TypeError("secret must be a string or buffer or a KeyObject");
33276
+ }
33222
33277
  var secretStream = new DataStream(secretOrKey);
33223
33278
  this.readable = true;
33224
33279
  this.algorithm = opts.algorithm;
@@ -33461,19 +33516,18 @@ var constants$1 = {
33461
33516
  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) : () => {
33462
33517
  };
33463
33518
  var debug_1 = debug$1;
33464
- (function(module, exports) {
33519
+ (function(module, exports$1) {
33465
33520
  const {
33466
33521
  MAX_SAFE_COMPONENT_LENGTH: MAX_SAFE_COMPONENT_LENGTH2,
33467
33522
  MAX_SAFE_BUILD_LENGTH: MAX_SAFE_BUILD_LENGTH2,
33468
33523
  MAX_LENGTH: MAX_LENGTH2
33469
33524
  } = constants$1;
33470
33525
  const debug2 = debug_1;
33471
- exports = module.exports = {};
33472
- const re2 = exports.re = [];
33473
- const safeRe = exports.safeRe = [];
33474
- const src = exports.src = [];
33475
- const safeSrc = exports.safeSrc = [];
33476
- const t2 = exports.t = {};
33526
+ exports$1 = module.exports = {};
33527
+ const re2 = exports$1.re = [];
33528
+ const safeRe = exports$1.safeRe = [];
33529
+ const src = exports$1.src = [];
33530
+ const t2 = exports$1.t = {};
33477
33531
  let R = 0;
33478
33532
  const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
33479
33533
  const safeRegexReplacements = [
@@ -33493,7 +33547,6 @@ var debug_1 = debug$1;
33493
33547
  debug2(name, index2, value);
33494
33548
  t2[name] = index2;
33495
33549
  src[index2] = value;
33496
- safeSrc[index2] = safe;
33497
33550
  re2[index2] = new RegExp(value, isGlobal ? "g" : void 0);
33498
33551
  safeRe[index2] = new RegExp(safe, isGlobal ? "g" : void 0);
33499
33552
  };
@@ -33502,8 +33555,8 @@ var debug_1 = debug$1;
33502
33555
  createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
33503
33556
  createToken("MAINVERSION", `(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})\\.(${src[t2.NUMERICIDENTIFIER]})`);
33504
33557
  createToken("MAINVERSIONLOOSE", `(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})\\.(${src[t2.NUMERICIDENTIFIERLOOSE]})`);
33505
- createToken("PRERELEASEIDENTIFIER", `(?:${src[t2.NONNUMERICIDENTIFIER]}|${src[t2.NUMERICIDENTIFIER]})`);
33506
- createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t2.NONNUMERICIDENTIFIER]}|${src[t2.NUMERICIDENTIFIERLOOSE]})`);
33558
+ createToken("PRERELEASEIDENTIFIER", `(?:${src[t2.NUMERICIDENTIFIER]}|${src[t2.NONNUMERICIDENTIFIER]})`);
33559
+ createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t2.NUMERICIDENTIFIERLOOSE]}|${src[t2.NONNUMERICIDENTIFIER]})`);
33507
33560
  createToken("PRERELEASE", `(?:-(${src[t2.PRERELEASEIDENTIFIER]}(?:\\.${src[t2.PRERELEASEIDENTIFIER]})*))`);
33508
33561
  createToken("PRERELEASELOOSE", `(?:-?(${src[t2.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t2.PRERELEASEIDENTIFIERLOOSE]})*))`);
33509
33562
  createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
@@ -33519,25 +33572,22 @@ var debug_1 = debug$1;
33519
33572
  createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t2.XRANGEIDENTIFIERLOOSE]})(?:${src[t2.PRERELEASELOOSE]})?${src[t2.BUILD]}?)?)?`);
33520
33573
  createToken("XRANGE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAIN]}$`);
33521
33574
  createToken("XRANGELOOSE", `^${src[t2.GTLT]}\\s*${src[t2.XRANGEPLAINLOOSE]}$`);
33522
- createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH2}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?`);
33523
- createToken("COERCE", `${src[t2.COERCEPLAIN]}(?:$|[^\\d])`);
33524
- createToken("COERCEFULL", src[t2.COERCEPLAIN] + `(?:${src[t2.PRERELEASE]})?(?:${src[t2.BUILD]})?(?:$|[^\\d])`);
33575
+ createToken("COERCE", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH2}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH2}}))?(?:$|[^\\d])`);
33525
33576
  createToken("COERCERTL", src[t2.COERCE], true);
33526
- createToken("COERCERTLFULL", src[t2.COERCEFULL], true);
33527
33577
  createToken("LONETILDE", "(?:~>?)");
33528
33578
  createToken("TILDETRIM", `(\\s*)${src[t2.LONETILDE]}\\s+`, true);
33529
- exports.tildeTrimReplace = "$1~";
33579
+ exports$1.tildeTrimReplace = "$1~";
33530
33580
  createToken("TILDE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAIN]}$`);
33531
33581
  createToken("TILDELOOSE", `^${src[t2.LONETILDE]}${src[t2.XRANGEPLAINLOOSE]}$`);
33532
33582
  createToken("LONECARET", "(?:\\^)");
33533
33583
  createToken("CARETTRIM", `(\\s*)${src[t2.LONECARET]}\\s+`, true);
33534
- exports.caretTrimReplace = "$1^";
33584
+ exports$1.caretTrimReplace = "$1^";
33535
33585
  createToken("CARET", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAIN]}$`);
33536
33586
  createToken("CARETLOOSE", `^${src[t2.LONECARET]}${src[t2.XRANGEPLAINLOOSE]}$`);
33537
33587
  createToken("COMPARATORLOOSE", `^${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]})$|^$`);
33538
33588
  createToken("COMPARATOR", `^${src[t2.GTLT]}\\s*(${src[t2.FULLPLAIN]})$|^$`);
33539
33589
  createToken("COMPARATORTRIM", `(\\s*)${src[t2.GTLT]}\\s*(${src[t2.LOOSEPLAIN]}|${src[t2.XRANGEPLAIN]})`, true);
33540
- exports.comparatorTrimReplace = "$1$2$3";
33590
+ exports$1.comparatorTrimReplace = "$1$2$3";
33541
33591
  createToken("HYPHENRANGE", `^\\s*(${src[t2.XRANGEPLAIN]})\\s+-\\s+(${src[t2.XRANGEPLAIN]})\\s*$`);
33542
33592
  createToken("HYPHENRANGELOOSE", `^\\s*(${src[t2.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t2.XRANGEPLAINLOOSE]})\\s*$`);
33543
33593
  createToken("STAR", "(<|>)?=?\\s*\\*");
@@ -33559,9 +33609,6 @@ const parseOptions$1 = (options2) => {
33559
33609
  var parseOptions_1 = parseOptions$1;
33560
33610
  const numeric = /^[0-9]+$/;
33561
33611
  const compareIdentifiers$1 = (a, b) => {
33562
- if (typeof a === "number" && typeof b === "number") {
33563
- return a === b ? 0 : a < b ? -1 : 1;
33564
- }
33565
33612
  const anum = numeric.test(a);
33566
33613
  const bnum = numeric.test(b);
33567
33614
  if (anum && bnum) {
@@ -33661,25 +33708,7 @@ let SemVer$d = class SemVer {
33661
33708
  if (!(other instanceof SemVer)) {
33662
33709
  other = new SemVer(other, this.options);
33663
33710
  }
33664
- if (this.major < other.major) {
33665
- return -1;
33666
- }
33667
- if (this.major > other.major) {
33668
- return 1;
33669
- }
33670
- if (this.minor < other.minor) {
33671
- return -1;
33672
- }
33673
- if (this.minor > other.minor) {
33674
- return 1;
33675
- }
33676
- if (this.patch < other.patch) {
33677
- return -1;
33678
- }
33679
- if (this.patch > other.patch) {
33680
- return 1;
33681
- }
33682
- return 0;
33711
+ return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
33683
33712
  }
33684
33713
  comparePre(other) {
33685
33714
  if (!(other instanceof SemVer)) {
@@ -33718,7 +33747,7 @@ let SemVer$d = class SemVer {
33718
33747
  do {
33719
33748
  const a = this.build[i];
33720
33749
  const b = other.build[i];
33721
- debug("build compare", i, a, b);
33750
+ debug("prerelease compare", i, a, b);
33722
33751
  if (a === void 0 && b === void 0) {
33723
33752
  return 0;
33724
33753
  } else if (b === void 0) {
@@ -33735,17 +33764,6 @@ let SemVer$d = class SemVer {
33735
33764
  // preminor will bump the version up to the next minor release, and immediately
33736
33765
  // down to pre-release. premajor and prepatch work the same way.
33737
33766
  inc(release, identifier, identifierBase) {
33738
- if (release.startsWith("pre")) {
33739
- if (!identifier && identifierBase === false) {
33740
- throw new Error("invalid increment argument: identifier is empty");
33741
- }
33742
- if (identifier) {
33743
- const match = `-${identifier}`.match(this.options.loose ? re$1[t$1.PRERELEASELOOSE] : re$1[t$1.PRERELEASE]);
33744
- if (!match || match[1] !== identifier) {
33745
- throw new Error(`invalid identifier: ${identifier}`);
33746
- }
33747
- }
33748
- }
33749
33767
  switch (release) {
33750
33768
  case "premajor":
33751
33769
  this.prerelease.length = 0;
@@ -33771,12 +33789,6 @@ let SemVer$d = class SemVer {
33771
33789
  }
33772
33790
  this.inc("pre", identifier, identifierBase);
33773
33791
  break;
33774
- case "release":
33775
- if (this.prerelease.length === 0) {
33776
- throw new Error(`version ${this.raw} is not a prerelease`);
33777
- }
33778
- this.prerelease.length = 0;
33779
- break;
33780
33792
  case "major":
33781
33793
  if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
33782
33794
  this.major++;
@@ -33800,6 +33812,9 @@ let SemVer$d = class SemVer {
33800
33812
  break;
33801
33813
  case "pre": {
33802
33814
  const base = Number(identifierBase) ? 1 : 0;
33815
+ if (!identifier && identifierBase === false) {
33816
+ throw new Error("invalid increment argument: identifier is empty");
33817
+ }
33803
33818
  if (this.prerelease.length === 0) {
33804
33819
  this.prerelease = [base];
33805
33820
  } else {
@@ -33904,12 +33919,13 @@ const diff$1 = (version1, version2) => {
33904
33919
  if (!lowVersion.patch && !lowVersion.minor) {
33905
33920
  return "major";
33906
33921
  }
33907
- if (lowVersion.compareMain(highVersion) === 0) {
33908
- if (lowVersion.minor && !lowVersion.patch) {
33909
- return "minor";
33910
- }
33922
+ if (highVersion.patch) {
33911
33923
  return "patch";
33912
33924
  }
33925
+ if (highVersion.minor) {
33926
+ return "minor";
33927
+ }
33928
+ return "major";
33913
33929
  }
33914
33930
  const prefix = highHasPre ? "pre" : "";
33915
33931
  if (v1.major !== v2.major) {
@@ -34038,66 +34054,666 @@ const coerce$1 = (version2, options2) => {
34038
34054
  options2 = options2 || {};
34039
34055
  let match = null;
34040
34056
  if (!options2.rtl) {
34041
- match = version2.match(options2.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
34057
+ match = version2.match(re[t.COERCE]);
34042
34058
  } else {
34043
- const coerceRtlRegex = options2.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
34044
34059
  let next;
34045
- while ((next = coerceRtlRegex.exec(version2)) && (!match || match.index + match[0].length !== version2.length)) {
34060
+ while ((next = re[t.COERCERTL].exec(version2)) && (!match || match.index + match[0].length !== version2.length)) {
34046
34061
  if (!match || next.index + next[0].length !== match.index + match[0].length) {
34047
34062
  match = next;
34048
34063
  }
34049
- coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
34064
+ re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
34050
34065
  }
34051
- coerceRtlRegex.lastIndex = -1;
34066
+ re[t.COERCERTL].lastIndex = -1;
34052
34067
  }
34053
34068
  if (match === null) {
34054
34069
  return null;
34055
34070
  }
34056
- const major2 = match[2];
34057
- const minor2 = match[3] || "0";
34058
- const patch2 = match[4] || "0";
34059
- const prerelease2 = options2.includePrerelease && match[5] ? `-${match[5]}` : "";
34060
- const build = options2.includePrerelease && match[6] ? `+${match[6]}` : "";
34061
- return parse$1(`${major2}.${minor2}.${patch2}${prerelease2}${build}`, options2);
34071
+ return parse$1(`${match[2]}.${match[3] || "0"}.${match[4] || "0"}`, options2);
34062
34072
  };
34063
34073
  var coerce_1 = coerce$1;
34074
+ var iterator;
34075
+ var hasRequiredIterator;
34076
+ function requireIterator() {
34077
+ if (hasRequiredIterator) return iterator;
34078
+ hasRequiredIterator = 1;
34079
+ iterator = function(Yallist2) {
34080
+ Yallist2.prototype[Symbol.iterator] = function* () {
34081
+ for (let walker = this.head; walker; walker = walker.next) {
34082
+ yield walker.value;
34083
+ }
34084
+ };
34085
+ };
34086
+ return iterator;
34087
+ }
34088
+ var yallist = Yallist$1;
34089
+ Yallist$1.Node = Node2;
34090
+ Yallist$1.create = Yallist$1;
34091
+ function Yallist$1(list) {
34092
+ var self2 = this;
34093
+ if (!(self2 instanceof Yallist$1)) {
34094
+ self2 = new Yallist$1();
34095
+ }
34096
+ self2.tail = null;
34097
+ self2.head = null;
34098
+ self2.length = 0;
34099
+ if (list && typeof list.forEach === "function") {
34100
+ list.forEach(function(item) {
34101
+ self2.push(item);
34102
+ });
34103
+ } else if (arguments.length > 0) {
34104
+ for (var i = 0, l = arguments.length; i < l; i++) {
34105
+ self2.push(arguments[i]);
34106
+ }
34107
+ }
34108
+ return self2;
34109
+ }
34110
+ Yallist$1.prototype.removeNode = function(node) {
34111
+ if (node.list !== this) {
34112
+ throw new Error("removing node which does not belong to this list");
34113
+ }
34114
+ var next = node.next;
34115
+ var prev = node.prev;
34116
+ if (next) {
34117
+ next.prev = prev;
34118
+ }
34119
+ if (prev) {
34120
+ prev.next = next;
34121
+ }
34122
+ if (node === this.head) {
34123
+ this.head = next;
34124
+ }
34125
+ if (node === this.tail) {
34126
+ this.tail = prev;
34127
+ }
34128
+ node.list.length--;
34129
+ node.next = null;
34130
+ node.prev = null;
34131
+ node.list = null;
34132
+ return next;
34133
+ };
34134
+ Yallist$1.prototype.unshiftNode = function(node) {
34135
+ if (node === this.head) {
34136
+ return;
34137
+ }
34138
+ if (node.list) {
34139
+ node.list.removeNode(node);
34140
+ }
34141
+ var head = this.head;
34142
+ node.list = this;
34143
+ node.next = head;
34144
+ if (head) {
34145
+ head.prev = node;
34146
+ }
34147
+ this.head = node;
34148
+ if (!this.tail) {
34149
+ this.tail = node;
34150
+ }
34151
+ this.length++;
34152
+ };
34153
+ Yallist$1.prototype.pushNode = function(node) {
34154
+ if (node === this.tail) {
34155
+ return;
34156
+ }
34157
+ if (node.list) {
34158
+ node.list.removeNode(node);
34159
+ }
34160
+ var tail = this.tail;
34161
+ node.list = this;
34162
+ node.prev = tail;
34163
+ if (tail) {
34164
+ tail.next = node;
34165
+ }
34166
+ this.tail = node;
34167
+ if (!this.head) {
34168
+ this.head = node;
34169
+ }
34170
+ this.length++;
34171
+ };
34172
+ Yallist$1.prototype.push = function() {
34173
+ for (var i = 0, l = arguments.length; i < l; i++) {
34174
+ push(this, arguments[i]);
34175
+ }
34176
+ return this.length;
34177
+ };
34178
+ Yallist$1.prototype.unshift = function() {
34179
+ for (var i = 0, l = arguments.length; i < l; i++) {
34180
+ unshift(this, arguments[i]);
34181
+ }
34182
+ return this.length;
34183
+ };
34184
+ Yallist$1.prototype.pop = function() {
34185
+ if (!this.tail) {
34186
+ return void 0;
34187
+ }
34188
+ var res = this.tail.value;
34189
+ this.tail = this.tail.prev;
34190
+ if (this.tail) {
34191
+ this.tail.next = null;
34192
+ } else {
34193
+ this.head = null;
34194
+ }
34195
+ this.length--;
34196
+ return res;
34197
+ };
34198
+ Yallist$1.prototype.shift = function() {
34199
+ if (!this.head) {
34200
+ return void 0;
34201
+ }
34202
+ var res = this.head.value;
34203
+ this.head = this.head.next;
34204
+ if (this.head) {
34205
+ this.head.prev = null;
34206
+ } else {
34207
+ this.tail = null;
34208
+ }
34209
+ this.length--;
34210
+ return res;
34211
+ };
34212
+ Yallist$1.prototype.forEach = function(fn, thisp) {
34213
+ thisp = thisp || this;
34214
+ for (var walker = this.head, i = 0; walker !== null; i++) {
34215
+ fn.call(thisp, walker.value, i, this);
34216
+ walker = walker.next;
34217
+ }
34218
+ };
34219
+ Yallist$1.prototype.forEachReverse = function(fn, thisp) {
34220
+ thisp = thisp || this;
34221
+ for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
34222
+ fn.call(thisp, walker.value, i, this);
34223
+ walker = walker.prev;
34224
+ }
34225
+ };
34226
+ Yallist$1.prototype.get = function(n) {
34227
+ for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
34228
+ walker = walker.next;
34229
+ }
34230
+ if (i === n && walker !== null) {
34231
+ return walker.value;
34232
+ }
34233
+ };
34234
+ Yallist$1.prototype.getReverse = function(n) {
34235
+ for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
34236
+ walker = walker.prev;
34237
+ }
34238
+ if (i === n && walker !== null) {
34239
+ return walker.value;
34240
+ }
34241
+ };
34242
+ Yallist$1.prototype.map = function(fn, thisp) {
34243
+ thisp = thisp || this;
34244
+ var res = new Yallist$1();
34245
+ for (var walker = this.head; walker !== null; ) {
34246
+ res.push(fn.call(thisp, walker.value, this));
34247
+ walker = walker.next;
34248
+ }
34249
+ return res;
34250
+ };
34251
+ Yallist$1.prototype.mapReverse = function(fn, thisp) {
34252
+ thisp = thisp || this;
34253
+ var res = new Yallist$1();
34254
+ for (var walker = this.tail; walker !== null; ) {
34255
+ res.push(fn.call(thisp, walker.value, this));
34256
+ walker = walker.prev;
34257
+ }
34258
+ return res;
34259
+ };
34260
+ Yallist$1.prototype.reduce = function(fn, initial) {
34261
+ var acc;
34262
+ var walker = this.head;
34263
+ if (arguments.length > 1) {
34264
+ acc = initial;
34265
+ } else if (this.head) {
34266
+ walker = this.head.next;
34267
+ acc = this.head.value;
34268
+ } else {
34269
+ throw new TypeError("Reduce of empty list with no initial value");
34270
+ }
34271
+ for (var i = 0; walker !== null; i++) {
34272
+ acc = fn(acc, walker.value, i);
34273
+ walker = walker.next;
34274
+ }
34275
+ return acc;
34276
+ };
34277
+ Yallist$1.prototype.reduceReverse = function(fn, initial) {
34278
+ var acc;
34279
+ var walker = this.tail;
34280
+ if (arguments.length > 1) {
34281
+ acc = initial;
34282
+ } else if (this.tail) {
34283
+ walker = this.tail.prev;
34284
+ acc = this.tail.value;
34285
+ } else {
34286
+ throw new TypeError("Reduce of empty list with no initial value");
34287
+ }
34288
+ for (var i = this.length - 1; walker !== null; i--) {
34289
+ acc = fn(acc, walker.value, i);
34290
+ walker = walker.prev;
34291
+ }
34292
+ return acc;
34293
+ };
34294
+ Yallist$1.prototype.toArray = function() {
34295
+ var arr = new Array(this.length);
34296
+ for (var i = 0, walker = this.head; walker !== null; i++) {
34297
+ arr[i] = walker.value;
34298
+ walker = walker.next;
34299
+ }
34300
+ return arr;
34301
+ };
34302
+ Yallist$1.prototype.toArrayReverse = function() {
34303
+ var arr = new Array(this.length);
34304
+ for (var i = 0, walker = this.tail; walker !== null; i++) {
34305
+ arr[i] = walker.value;
34306
+ walker = walker.prev;
34307
+ }
34308
+ return arr;
34309
+ };
34310
+ Yallist$1.prototype.slice = function(from, to) {
34311
+ to = to || this.length;
34312
+ if (to < 0) {
34313
+ to += this.length;
34314
+ }
34315
+ from = from || 0;
34316
+ if (from < 0) {
34317
+ from += this.length;
34318
+ }
34319
+ var ret = new Yallist$1();
34320
+ if (to < from || to < 0) {
34321
+ return ret;
34322
+ }
34323
+ if (from < 0) {
34324
+ from = 0;
34325
+ }
34326
+ if (to > this.length) {
34327
+ to = this.length;
34328
+ }
34329
+ for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
34330
+ walker = walker.next;
34331
+ }
34332
+ for (; walker !== null && i < to; i++, walker = walker.next) {
34333
+ ret.push(walker.value);
34334
+ }
34335
+ return ret;
34336
+ };
34337
+ Yallist$1.prototype.sliceReverse = function(from, to) {
34338
+ to = to || this.length;
34339
+ if (to < 0) {
34340
+ to += this.length;
34341
+ }
34342
+ from = from || 0;
34343
+ if (from < 0) {
34344
+ from += this.length;
34345
+ }
34346
+ var ret = new Yallist$1();
34347
+ if (to < from || to < 0) {
34348
+ return ret;
34349
+ }
34350
+ if (from < 0) {
34351
+ from = 0;
34352
+ }
34353
+ if (to > this.length) {
34354
+ to = this.length;
34355
+ }
34356
+ for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
34357
+ walker = walker.prev;
34358
+ }
34359
+ for (; walker !== null && i > from; i--, walker = walker.prev) {
34360
+ ret.push(walker.value);
34361
+ }
34362
+ return ret;
34363
+ };
34364
+ Yallist$1.prototype.splice = function(start, deleteCount, ...nodes) {
34365
+ if (start > this.length) {
34366
+ start = this.length - 1;
34367
+ }
34368
+ if (start < 0) {
34369
+ start = this.length + start;
34370
+ }
34371
+ for (var i = 0, walker = this.head; walker !== null && i < start; i++) {
34372
+ walker = walker.next;
34373
+ }
34374
+ var ret = [];
34375
+ for (var i = 0; walker && i < deleteCount; i++) {
34376
+ ret.push(walker.value);
34377
+ walker = this.removeNode(walker);
34378
+ }
34379
+ if (walker === null) {
34380
+ walker = this.tail;
34381
+ }
34382
+ if (walker !== this.head && walker !== this.tail) {
34383
+ walker = walker.prev;
34384
+ }
34385
+ for (var i = 0; i < nodes.length; i++) {
34386
+ walker = insert(this, walker, nodes[i]);
34387
+ }
34388
+ return ret;
34389
+ };
34390
+ Yallist$1.prototype.reverse = function() {
34391
+ var head = this.head;
34392
+ var tail = this.tail;
34393
+ for (var walker = head; walker !== null; walker = walker.prev) {
34394
+ var p = walker.prev;
34395
+ walker.prev = walker.next;
34396
+ walker.next = p;
34397
+ }
34398
+ this.head = tail;
34399
+ this.tail = head;
34400
+ return this;
34401
+ };
34402
+ function insert(self2, node, value) {
34403
+ var inserted = node === self2.head ? new Node2(value, null, node, self2) : new Node2(value, node, node.next, self2);
34404
+ if (inserted.next === null) {
34405
+ self2.tail = inserted;
34406
+ }
34407
+ if (inserted.prev === null) {
34408
+ self2.head = inserted;
34409
+ }
34410
+ self2.length++;
34411
+ return inserted;
34412
+ }
34413
+ function push(self2, item) {
34414
+ self2.tail = new Node2(item, self2.tail, null, self2);
34415
+ if (!self2.head) {
34416
+ self2.head = self2.tail;
34417
+ }
34418
+ self2.length++;
34419
+ }
34420
+ function unshift(self2, item) {
34421
+ self2.head = new Node2(item, null, self2.head, self2);
34422
+ if (!self2.tail) {
34423
+ self2.tail = self2.head;
34424
+ }
34425
+ self2.length++;
34426
+ }
34427
+ function Node2(value, prev, next, list) {
34428
+ if (!(this instanceof Node2)) {
34429
+ return new Node2(value, prev, next, list);
34430
+ }
34431
+ this.list = list;
34432
+ this.value = value;
34433
+ if (prev) {
34434
+ prev.next = this;
34435
+ this.prev = prev;
34436
+ } else {
34437
+ this.prev = null;
34438
+ }
34439
+ if (next) {
34440
+ next.prev = this;
34441
+ this.next = next;
34442
+ } else {
34443
+ this.next = null;
34444
+ }
34445
+ }
34446
+ try {
34447
+ requireIterator()(Yallist$1);
34448
+ } catch (er) {
34449
+ }
34450
+ const Yallist = yallist;
34451
+ const MAX = Symbol("max");
34452
+ const LENGTH = Symbol("length");
34453
+ const LENGTH_CALCULATOR = Symbol("lengthCalculator");
34454
+ const ALLOW_STALE = Symbol("allowStale");
34455
+ const MAX_AGE = Symbol("maxAge");
34456
+ const DISPOSE = Symbol("dispose");
34457
+ const NO_DISPOSE_ON_SET = Symbol("noDisposeOnSet");
34458
+ const LRU_LIST = Symbol("lruList");
34459
+ const CACHE = Symbol("cache");
34460
+ const UPDATE_AGE_ON_GET = Symbol("updateAgeOnGet");
34461
+ const naiveLength = () => 1;
34064
34462
  class LRUCache {
34065
- constructor() {
34066
- this.max = 1e3;
34067
- this.map = /* @__PURE__ */ new Map();
34463
+ constructor(options2) {
34464
+ if (typeof options2 === "number")
34465
+ options2 = { max: options2 };
34466
+ if (!options2)
34467
+ options2 = {};
34468
+ if (options2.max && (typeof options2.max !== "number" || options2.max < 0))
34469
+ throw new TypeError("max must be a non-negative number");
34470
+ this[MAX] = options2.max || Infinity;
34471
+ const lc = options2.length || naiveLength;
34472
+ this[LENGTH_CALCULATOR] = typeof lc !== "function" ? naiveLength : lc;
34473
+ this[ALLOW_STALE] = options2.stale || false;
34474
+ if (options2.maxAge && typeof options2.maxAge !== "number")
34475
+ throw new TypeError("maxAge must be a number");
34476
+ this[MAX_AGE] = options2.maxAge || 0;
34477
+ this[DISPOSE] = options2.dispose;
34478
+ this[NO_DISPOSE_ON_SET] = options2.noDisposeOnSet || false;
34479
+ this[UPDATE_AGE_ON_GET] = options2.updateAgeOnGet || false;
34480
+ this.reset();
34481
+ }
34482
+ // resize the cache when the max changes.
34483
+ set max(mL) {
34484
+ if (typeof mL !== "number" || mL < 0)
34485
+ throw new TypeError("max must be a non-negative number");
34486
+ this[MAX] = mL || Infinity;
34487
+ trim(this);
34488
+ }
34489
+ get max() {
34490
+ return this[MAX];
34491
+ }
34492
+ set allowStale(allowStale) {
34493
+ this[ALLOW_STALE] = !!allowStale;
34494
+ }
34495
+ get allowStale() {
34496
+ return this[ALLOW_STALE];
34497
+ }
34498
+ set maxAge(mA) {
34499
+ if (typeof mA !== "number")
34500
+ throw new TypeError("maxAge must be a non-negative number");
34501
+ this[MAX_AGE] = mA;
34502
+ trim(this);
34503
+ }
34504
+ get maxAge() {
34505
+ return this[MAX_AGE];
34506
+ }
34507
+ // resize the cache when the lengthCalculator changes.
34508
+ set lengthCalculator(lC) {
34509
+ if (typeof lC !== "function")
34510
+ lC = naiveLength;
34511
+ if (lC !== this[LENGTH_CALCULATOR]) {
34512
+ this[LENGTH_CALCULATOR] = lC;
34513
+ this[LENGTH] = 0;
34514
+ this[LRU_LIST].forEach((hit) => {
34515
+ hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
34516
+ this[LENGTH] += hit.length;
34517
+ });
34518
+ }
34519
+ trim(this);
34520
+ }
34521
+ get lengthCalculator() {
34522
+ return this[LENGTH_CALCULATOR];
34523
+ }
34524
+ get length() {
34525
+ return this[LENGTH];
34526
+ }
34527
+ get itemCount() {
34528
+ return this[LRU_LIST].length;
34529
+ }
34530
+ rforEach(fn, thisp) {
34531
+ thisp = thisp || this;
34532
+ for (let walker = this[LRU_LIST].tail; walker !== null; ) {
34533
+ const prev = walker.prev;
34534
+ forEachStep(this, fn, walker, thisp);
34535
+ walker = prev;
34536
+ }
34537
+ }
34538
+ forEach(fn, thisp) {
34539
+ thisp = thisp || this;
34540
+ for (let walker = this[LRU_LIST].head; walker !== null; ) {
34541
+ const next = walker.next;
34542
+ forEachStep(this, fn, walker, thisp);
34543
+ walker = next;
34544
+ }
34545
+ }
34546
+ keys() {
34547
+ return this[LRU_LIST].toArray().map((k) => k.key);
34548
+ }
34549
+ values() {
34550
+ return this[LRU_LIST].toArray().map((k) => k.value);
34551
+ }
34552
+ reset() {
34553
+ if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
34554
+ this[LRU_LIST].forEach((hit) => this[DISPOSE](hit.key, hit.value));
34555
+ }
34556
+ this[CACHE] = /* @__PURE__ */ new Map();
34557
+ this[LRU_LIST] = new Yallist();
34558
+ this[LENGTH] = 0;
34559
+ }
34560
+ dump() {
34561
+ return this[LRU_LIST].map((hit) => isStale(this, hit) ? false : {
34562
+ k: hit.key,
34563
+ v: hit.value,
34564
+ e: hit.now + (hit.maxAge || 0)
34565
+ }).toArray().filter((h2) => h2);
34566
+ }
34567
+ dumpLru() {
34568
+ return this[LRU_LIST];
34569
+ }
34570
+ set(key, value, maxAge) {
34571
+ maxAge = maxAge || this[MAX_AGE];
34572
+ if (maxAge && typeof maxAge !== "number")
34573
+ throw new TypeError("maxAge must be a number");
34574
+ const now = maxAge ? Date.now() : 0;
34575
+ const len = this[LENGTH_CALCULATOR](value, key);
34576
+ if (this[CACHE].has(key)) {
34577
+ if (len > this[MAX]) {
34578
+ del(this, this[CACHE].get(key));
34579
+ return false;
34580
+ }
34581
+ const node = this[CACHE].get(key);
34582
+ const item = node.value;
34583
+ if (this[DISPOSE]) {
34584
+ if (!this[NO_DISPOSE_ON_SET])
34585
+ this[DISPOSE](key, item.value);
34586
+ }
34587
+ item.now = now;
34588
+ item.maxAge = maxAge;
34589
+ item.value = value;
34590
+ this[LENGTH] += len - item.length;
34591
+ item.length = len;
34592
+ this.get(key);
34593
+ trim(this);
34594
+ return true;
34595
+ }
34596
+ const hit = new Entry(key, value, len, now, maxAge);
34597
+ if (hit.length > this[MAX]) {
34598
+ if (this[DISPOSE])
34599
+ this[DISPOSE](key, value);
34600
+ return false;
34601
+ }
34602
+ this[LENGTH] += hit.length;
34603
+ this[LRU_LIST].unshift(hit);
34604
+ this[CACHE].set(key, this[LRU_LIST].head);
34605
+ trim(this);
34606
+ return true;
34607
+ }
34608
+ has(key) {
34609
+ if (!this[CACHE].has(key)) return false;
34610
+ const hit = this[CACHE].get(key).value;
34611
+ return !isStale(this, hit);
34068
34612
  }
34069
34613
  get(key) {
34070
- const value = this.map.get(key);
34071
- if (value === void 0) {
34072
- return void 0;
34073
- } else {
34074
- this.map.delete(key);
34075
- this.map.set(key, value);
34076
- return value;
34614
+ return get(this, key, true);
34615
+ }
34616
+ peek(key) {
34617
+ return get(this, key, false);
34618
+ }
34619
+ pop() {
34620
+ const node = this[LRU_LIST].tail;
34621
+ if (!node)
34622
+ return null;
34623
+ del(this, node);
34624
+ return node.value;
34625
+ }
34626
+ del(key) {
34627
+ del(this, this[CACHE].get(key));
34628
+ }
34629
+ load(arr) {
34630
+ this.reset();
34631
+ const now = Date.now();
34632
+ for (let l = arr.length - 1; l >= 0; l--) {
34633
+ const hit = arr[l];
34634
+ const expiresAt = hit.e || 0;
34635
+ if (expiresAt === 0)
34636
+ this.set(hit.k, hit.v);
34637
+ else {
34638
+ const maxAge = expiresAt - now;
34639
+ if (maxAge > 0) {
34640
+ this.set(hit.k, hit.v, maxAge);
34641
+ }
34642
+ }
34077
34643
  }
34078
34644
  }
34079
- delete(key) {
34080
- return this.map.delete(key);
34645
+ prune() {
34646
+ this[CACHE].forEach((value, key) => get(this, key, false));
34081
34647
  }
34082
- set(key, value) {
34083
- const deleted = this.delete(key);
34084
- if (!deleted && value !== void 0) {
34085
- if (this.map.size >= this.max) {
34086
- const firstKey = this.map.keys().next().value;
34087
- this.delete(firstKey);
34648
+ }
34649
+ const get = (self2, key, doUse) => {
34650
+ const node = self2[CACHE].get(key);
34651
+ if (node) {
34652
+ const hit = node.value;
34653
+ if (isStale(self2, hit)) {
34654
+ del(self2, node);
34655
+ if (!self2[ALLOW_STALE])
34656
+ return void 0;
34657
+ } else {
34658
+ if (doUse) {
34659
+ if (self2[UPDATE_AGE_ON_GET])
34660
+ node.value.now = Date.now();
34661
+ self2[LRU_LIST].unshiftNode(node);
34088
34662
  }
34089
- this.map.set(key, value);
34090
34663
  }
34091
- return this;
34664
+ return hit.value;
34665
+ }
34666
+ };
34667
+ const isStale = (self2, hit) => {
34668
+ if (!hit || !hit.maxAge && !self2[MAX_AGE])
34669
+ return false;
34670
+ const diff2 = Date.now() - hit.now;
34671
+ return hit.maxAge ? diff2 > hit.maxAge : self2[MAX_AGE] && diff2 > self2[MAX_AGE];
34672
+ };
34673
+ const trim = (self2) => {
34674
+ if (self2[LENGTH] > self2[MAX]) {
34675
+ for (let walker = self2[LRU_LIST].tail; self2[LENGTH] > self2[MAX] && walker !== null; ) {
34676
+ const prev = walker.prev;
34677
+ del(self2, walker);
34678
+ walker = prev;
34679
+ }
34680
+ }
34681
+ };
34682
+ const del = (self2, node) => {
34683
+ if (node) {
34684
+ const hit = node.value;
34685
+ if (self2[DISPOSE])
34686
+ self2[DISPOSE](hit.key, hit.value);
34687
+ self2[LENGTH] -= hit.length;
34688
+ self2[CACHE].delete(hit.key);
34689
+ self2[LRU_LIST].removeNode(node);
34690
+ }
34691
+ };
34692
+ class Entry {
34693
+ constructor(key, value, length, now, maxAge) {
34694
+ this.key = key;
34695
+ this.value = value;
34696
+ this.length = length;
34697
+ this.now = now;
34698
+ this.maxAge = maxAge || 0;
34092
34699
  }
34093
34700
  }
34094
- var lrucache = LRUCache;
34701
+ const forEachStep = (self2, fn, node, thisp) => {
34702
+ let hit = node.value;
34703
+ if (isStale(self2, hit)) {
34704
+ del(self2, node);
34705
+ if (!self2[ALLOW_STALE])
34706
+ hit = void 0;
34707
+ }
34708
+ if (hit)
34709
+ fn.call(thisp, hit.value, hit.key, self2);
34710
+ };
34711
+ var lruCache = LRUCache;
34095
34712
  var range;
34096
34713
  var hasRequiredRange;
34097
34714
  function requireRange() {
34098
34715
  if (hasRequiredRange) return range;
34099
34716
  hasRequiredRange = 1;
34100
- const SPACE_CHARACTERS = /\s+/g;
34101
34717
  class Range2 {
34102
34718
  constructor(range2, options2) {
34103
34719
  options2 = parseOptions2(options2);
@@ -34111,13 +34727,13 @@ function requireRange() {
34111
34727
  if (range2 instanceof Comparator2) {
34112
34728
  this.raw = range2.value;
34113
34729
  this.set = [[range2]];
34114
- this.formatted = void 0;
34730
+ this.format();
34115
34731
  return this;
34116
34732
  }
34117
34733
  this.options = options2;
34118
34734
  this.loose = !!options2.loose;
34119
34735
  this.includePrerelease = !!options2.includePrerelease;
34120
- this.raw = range2.trim().replace(SPACE_CHARACTERS, " ");
34736
+ this.raw = range2.trim().split(/\s+/).join(" ");
34121
34737
  this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
34122
34738
  if (!this.set.length) {
34123
34739
  throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
@@ -34136,27 +34752,10 @@ function requireRange() {
34136
34752
  }
34137
34753
  }
34138
34754
  }
34139
- this.formatted = void 0;
34140
- }
34141
- get range() {
34142
- if (this.formatted === void 0) {
34143
- this.formatted = "";
34144
- for (let i = 0; i < this.set.length; i++) {
34145
- if (i > 0) {
34146
- this.formatted += "||";
34147
- }
34148
- const comps = this.set[i];
34149
- for (let k = 0; k < comps.length; k++) {
34150
- if (k > 0) {
34151
- this.formatted += " ";
34152
- }
34153
- this.formatted += comps[k].toString().trim();
34154
- }
34155
- }
34156
- }
34157
- return this.formatted;
34755
+ this.format();
34158
34756
  }
34159
34757
  format() {
34758
+ this.range = this.set.map((comps) => comps.join(" ").trim()).join("||").trim();
34160
34759
  return this.range;
34161
34760
  }
34162
34761
  toString() {
@@ -34237,8 +34836,8 @@ function requireRange() {
34237
34836
  }
34238
34837
  }
34239
34838
  range = Range2;
34240
- const LRU = lrucache;
34241
- const cache = new LRU();
34839
+ const LRU = lruCache;
34840
+ const cache = new LRU({ max: 1e3 });
34242
34841
  const parseOptions2 = parseOptions_1;
34243
34842
  const Comparator2 = requireComparator();
34244
34843
  const debug2 = debug_1;
@@ -34266,7 +34865,6 @@ function requireRange() {
34266
34865
  return result;
34267
34866
  };
34268
34867
  const parseComparator = (comp, options2) => {
34269
- comp = comp.replace(re2[t2.BUILD], "");
34270
34868
  debug2("comp", comp, options2);
34271
34869
  comp = replaceCarets(comp, options2);
34272
34870
  debug2("caret", comp);
@@ -34417,7 +35015,7 @@ function requireRange() {
34417
35015
  debug2("replaceGTE0", comp, options2);
34418
35016
  return comp.trim().replace(re2[options2.includePrerelease ? t2.GTE0PRE : t2.GTE0], "");
34419
35017
  };
34420
- const hyphenReplace = (incPr) => ($0, from, fM, fm, fp2, fpr, fb, to, tM, tm, tp, tpr) => {
35018
+ const hyphenReplace = (incPr) => ($0, from, fM, fm, fp2, fpr, fb, to, tM, tm, tp, tpr, tb) => {
34421
35019
  if (isX(fM)) {
34422
35020
  from = "";
34423
35021
  } else if (isX(fm)) {
@@ -35740,9 +36338,10 @@ const tokenService = ({ strapi: strapi2 }) => {
35740
36338
  if (firebaseUserData2.verificationTokenHash !== tokenHash) {
35741
36339
  return {
35742
36340
  valid: false,
35743
- firebaseUserDataDocumentId: "",
35744
- firebaseUID: "",
35745
- error: "Verification link has already been used or is invalid"
36341
+ firebaseUserDataDocumentId: firebaseUserData2.documentId,
36342
+ firebaseUID: firebaseUserData2.firebaseUserID,
36343
+ error: "Verification link has already been used or is invalid",
36344
+ code: "TOKEN_ALREADY_USED"
35746
36345
  };
35747
36346
  }
35748
36347
  if (firebaseUserData2.verificationTokenExpiresAt) {