@forgerock/login-widget 1.2.0-beta.2 → 1.2.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1041,6 +1041,7 @@ declare abstract class ZodType<Output = any, Def extends ZodTypeDef = ZodTypeDef
1041
1041
  _refinement(refinement: RefinementEffect<Output>["refinement"]): ZodEffects<this, Output, Input>;
1042
1042
  superRefine<RefinedOutput extends Output>(refinement: (arg: Output, ctx: RefinementCtx) => arg is RefinedOutput): ZodEffects<this, RefinedOutput, Input>;
1043
1043
  superRefine(refinement: (arg: Output, ctx: RefinementCtx) => void): ZodEffects<this, Output, Input>;
1044
+ superRefine(refinement: (arg: Output, ctx: RefinementCtx) => Promise<void>): ZodEffects<this, Output, Input>;
1044
1045
  constructor(def: Def);
1045
1046
  optional(): ZodOptional<this>;
1046
1047
  nullable(): ZodNullable<this>;
@@ -1060,6 +1061,7 @@ declare abstract class ZodType<Output = any, Def extends ZodTypeDef = ZodTypeDef
1060
1061
  }) => Output): ZodCatch<this>;
1061
1062
  describe(description: string): this;
1062
1063
  pipe<T extends ZodTypeAny>(target: T): ZodPipeline<this, T>;
1064
+ readonly(): ZodReadonly<this>;
1063
1065
  isOptional(): boolean;
1064
1066
  isNullable(): boolean;
1065
1067
  }
@@ -1515,7 +1517,7 @@ declare type TransformEffect<T> = {
1515
1517
  };
1516
1518
  declare type PreprocessEffect<T> = {
1517
1519
  type: "preprocess";
1518
- transform: (arg: T) => any;
1520
+ transform: (arg: T, ctx: RefinementCtx) => any;
1519
1521
  };
1520
1522
  declare type Effect<T> = RefinementEffect<T> | TransformEffect<T> | PreprocessEffect<T>;
1521
1523
  interface ZodEffectsDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
@@ -1528,7 +1530,7 @@ declare class ZodEffects<T extends ZodTypeAny, Output = output<T>, Input = input
1528
1530
  sourceType(): T;
1529
1531
  _parse(input: ParseInput): ParseReturnType<this["_output"]>;
1530
1532
  static create: <I extends ZodTypeAny>(schema: I, effect: Effect<I["_output"]>, params?: RawCreateParams) => ZodEffects<I, I["_output"], input<I>>;
1531
- static createWithPreprocess: <I extends ZodTypeAny>(preprocess: (arg: unknown) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], unknown>;
1533
+ static createWithPreprocess: <I extends ZodTypeAny>(preprocess: (arg: unknown, ctx: RefinementCtx) => unknown, schema: I, params?: RawCreateParams) => ZodEffects<I, I["_output"], unknown>;
1532
1534
  }
1533
1535
 
1534
1536
  interface ZodOptionalDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
@@ -1609,6 +1611,18 @@ declare class ZodPipeline<A extends ZodTypeAny, B extends ZodTypeAny> extends Zo
1609
1611
  _parse(input: ParseInput): ParseReturnType<any>;
1610
1612
  static create<A extends ZodTypeAny, B extends ZodTypeAny>(a: A, b: B): ZodPipeline<A, B>;
1611
1613
  }
1614
+ declare type BuiltIn = (((...args: any[]) => any) | (new (...args: any[]) => any)) | {
1615
+ readonly [Symbol.toStringTag]: string;
1616
+ } | Date | Error | Generator | Promise<unknown> | RegExp;
1617
+ declare type MakeReadonly<T> = T extends Map<infer K, infer V> ? ReadonlyMap<K, V> : T extends Set<infer V> ? ReadonlySet<V> : T extends [infer Head, ...infer Tail] ? readonly [Head, ...Tail] : T extends Array<infer V> ? ReadonlyArray<V> : T extends BuiltIn ? T : Readonly<T>;
1618
+ interface ZodReadonlyDef<T extends ZodTypeAny = ZodTypeAny> extends ZodTypeDef {
1619
+ innerType: T;
1620
+ typeName: ZodFirstPartyTypeKind.ZodReadonly;
1621
+ }
1622
+ declare class ZodReadonly<T extends ZodTypeAny> extends ZodType<MakeReadonly<T["_output"]>, ZodReadonlyDef<T>, T["_input"]> {
1623
+ _parse(input: ParseInput): ParseReturnType<this["_output"]>;
1624
+ static create: <T_1 extends ZodTypeAny>(type: T_1, params?: RawCreateParams) => ZodReadonly<T_1>;
1625
+ }
1612
1626
  declare enum ZodFirstPartyTypeKind {
1613
1627
  ZodString = "ZodString",
1614
1628
  ZodNumber = "ZodNumber",
@@ -1644,7 +1658,8 @@ declare enum ZodFirstPartyTypeKind {
1644
1658
  ZodCatch = "ZodCatch",
1645
1659
  ZodPromise = "ZodPromise",
1646
1660
  ZodBranded = "ZodBranded",
1647
- ZodPipeline = "ZodPipeline"
1661
+ ZodPipeline = "ZodPipeline",
1662
+ ZodReadonly = "ZodReadonly"
1648
1663
  }
1649
1664
 
1650
1665
  declare const partialConfigSchema: ZodObject<{
package/index.js CHANGED
@@ -5532,7 +5532,8 @@ class ParseStatus {
5532
5532
  status.dirty();
5533
5533
  if (value.status === "dirty")
5534
5534
  status.dirty();
5535
- if (typeof value.value !== "undefined" || pair.alwaysSet) {
5535
+ if (key.value !== "__proto__" &&
5536
+ (typeof value.value !== "undefined" || pair.alwaysSet)) {
5536
5537
  finalObject[key.value] = value.value;
5537
5538
  }
5538
5539
  }
@@ -5640,6 +5641,7 @@ class ZodType {
5640
5641
  this.catch = this.catch.bind(this);
5641
5642
  this.describe = this.describe.bind(this);
5642
5643
  this.pipe = this.pipe.bind(this);
5644
+ this.readonly = this.readonly.bind(this);
5643
5645
  this.isNullable = this.isNullable.bind(this);
5644
5646
  this.isOptional = this.isOptional.bind(this);
5645
5647
  }
@@ -5856,6 +5858,9 @@ class ZodType {
5856
5858
  pipe(target) {
5857
5859
  return ZodPipeline.create(this, target);
5858
5860
  }
5861
+ readonly() {
5862
+ return ZodReadonly.create(this);
5863
+ }
5859
5864
  isOptional() {
5860
5865
  return this.safeParse(undefined).success;
5861
5866
  }
@@ -5866,14 +5871,24 @@ class ZodType {
5866
5871
  const cuidRegex = /^c[^\s-]{8,}$/i;
5867
5872
  const cuid2Regex = /^[a-z][a-z0-9]*$/;
5868
5873
  const ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/;
5869
- const uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
5874
+ // const uuidRegex =
5875
+ // /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
5876
+ const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
5870
5877
  // from https://stackoverflow.com/a/46181/1550155
5871
5878
  // old version: too slow, didn't support unicode
5872
5879
  // const emailRegex = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
5873
5880
  //old email regex
5874
5881
  // const emailRegex = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@((?!-)([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{1,})[^-<>()[\].,;:\s@"]$/i;
5875
5882
  // eslint-disable-next-line
5876
- const emailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/;
5883
+ // const emailRegex =
5884
+ // /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\])|(\[IPv6:(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/;
5885
+ // const emailRegex =
5886
+ // /^[a-zA-Z0-9\.\!\#\$\%\&\'\*\+\/\=\?\^\_\`\{\|\}\~\-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
5887
+ // const emailRegex =
5888
+ // /^(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/i;
5889
+ const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
5890
+ // const emailRegex =
5891
+ // /^[a-z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-z0-9-]+(?:\.[a-z0-9\-]+)*$/i;
5877
5892
  // from https://thekevinscott.com/emojis-in-javascript/#writing-a-regular-expression
5878
5893
  const emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u;
5879
5894
  const ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;
@@ -7984,6 +7999,12 @@ class ZodRecord extends ZodType {
7984
7999
  }
7985
8000
  }
7986
8001
  class ZodMap extends ZodType {
8002
+ get keySchema() {
8003
+ return this._def.keyType;
8004
+ }
8005
+ get valueSchema() {
8006
+ return this._def.valueType;
8007
+ }
7987
8008
  _parse(input) {
7988
8009
  const { status, ctx } = this._processInputParams(input);
7989
8010
  if (ctx.parsedType !== ZodParsedType.map) {
@@ -8180,16 +8201,20 @@ class ZodFunction extends ZodType {
8180
8201
  const params = { errorMap: ctx.common.contextualErrorMap };
8181
8202
  const fn = ctx.data;
8182
8203
  if (this._def.returns instanceof ZodPromise) {
8183
- return OK(async (...args) => {
8204
+ // Would love a way to avoid disabling this rule, but we need
8205
+ // an alias (using an arrow function was what caused 2651).
8206
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
8207
+ const me = this;
8208
+ return OK(async function (...args) {
8184
8209
  const error = new ZodError([]);
8185
- const parsedArgs = await this._def.args
8210
+ const parsedArgs = await me._def.args
8186
8211
  .parseAsync(args, params)
8187
8212
  .catch((e) => {
8188
8213
  error.addIssue(makeArgsIssue(args, e));
8189
8214
  throw error;
8190
8215
  });
8191
- const result = await fn(...parsedArgs);
8192
- const parsedReturns = await this._def.returns._def.type
8216
+ const result = await Reflect.apply(fn, this, parsedArgs);
8217
+ const parsedReturns = await me._def.returns._def.type
8193
8218
  .parseAsync(result, params)
8194
8219
  .catch((e) => {
8195
8220
  error.addIssue(makeReturnsIssue(result, e));
@@ -8199,13 +8224,17 @@ class ZodFunction extends ZodType {
8199
8224
  });
8200
8225
  }
8201
8226
  else {
8202
- return OK((...args) => {
8203
- const parsedArgs = this._def.args.safeParse(args, params);
8227
+ // Would love a way to avoid disabling this rule, but we need
8228
+ // an alias (using an arrow function was what caused 2651).
8229
+ // eslint-disable-next-line @typescript-eslint/no-this-alias
8230
+ const me = this;
8231
+ return OK(function (...args) {
8232
+ const parsedArgs = me._def.args.safeParse(args, params);
8204
8233
  if (!parsedArgs.success) {
8205
8234
  throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
8206
8235
  }
8207
- const result = fn(...parsedArgs.data);
8208
- const parsedReturns = this._def.returns.safeParse(result, params);
8236
+ const result = Reflect.apply(fn, this, parsedArgs.data);
8237
+ const parsedReturns = me._def.returns.safeParse(result, params);
8209
8238
  if (!parsedReturns.success) {
8210
8239
  throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
8211
8240
  }
@@ -8293,7 +8322,7 @@ ZodLiteral.create = (value, params) => {
8293
8322
  };
8294
8323
  function createZodEnum(values, params) {
8295
8324
  return new ZodEnum({
8296
- values: values,
8325
+ values,
8297
8326
  typeName: ZodFirstPartyTypeKind.ZodEnum,
8298
8327
  ...processCreateParams(params),
8299
8328
  });
@@ -8435,8 +8464,29 @@ class ZodEffects extends ZodType {
8435
8464
  _parse(input) {
8436
8465
  const { status, ctx } = this._processInputParams(input);
8437
8466
  const effect = this._def.effect || null;
8467
+ const checkCtx = {
8468
+ addIssue: (arg) => {
8469
+ addIssueToContext(ctx, arg);
8470
+ if (arg.fatal) {
8471
+ status.abort();
8472
+ }
8473
+ else {
8474
+ status.dirty();
8475
+ }
8476
+ },
8477
+ get path() {
8478
+ return ctx.path;
8479
+ },
8480
+ };
8481
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
8438
8482
  if (effect.type === "preprocess") {
8439
- const processed = effect.transform(ctx.data);
8483
+ const processed = effect.transform(ctx.data, checkCtx);
8484
+ if (ctx.common.issues.length) {
8485
+ return {
8486
+ status: "dirty",
8487
+ value: ctx.data,
8488
+ };
8489
+ }
8440
8490
  if (ctx.common.async) {
8441
8491
  return Promise.resolve(processed).then((processed) => {
8442
8492
  return this._def.schema._parseAsync({
@@ -8454,21 +8504,6 @@ class ZodEffects extends ZodType {
8454
8504
  });
8455
8505
  }
8456
8506
  }
8457
- const checkCtx = {
8458
- addIssue: (arg) => {
8459
- addIssueToContext(ctx, arg);
8460
- if (arg.fatal) {
8461
- status.abort();
8462
- }
8463
- else {
8464
- status.dirty();
8465
- }
8466
- },
8467
- get path() {
8468
- return ctx.path;
8469
- },
8470
- };
8471
- checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
8472
8507
  if (effect.type === "refinement") {
8473
8508
  const executeRefinement = (acc
8474
8509
  // effect: RefinementEffect<any>
@@ -8772,6 +8807,22 @@ class ZodPipeline extends ZodType {
8772
8807
  });
8773
8808
  }
8774
8809
  }
8810
+ class ZodReadonly extends ZodType {
8811
+ _parse(input) {
8812
+ const result = this._def.innerType._parse(input);
8813
+ if (isValid(result)) {
8814
+ result.value = Object.freeze(result.value);
8815
+ }
8816
+ return result;
8817
+ }
8818
+ }
8819
+ ZodReadonly.create = (type, params) => {
8820
+ return new ZodReadonly({
8821
+ innerType: type,
8822
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
8823
+ ...processCreateParams(params),
8824
+ });
8825
+ };
8775
8826
  const custom = (check, params = {},
8776
8827
  /*
8777
8828
  * @deprecated
@@ -8840,6 +8891,7 @@ var ZodFirstPartyTypeKind;
8840
8891
  ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
8841
8892
  ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
8842
8893
  ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
8894
+ ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
8843
8895
  })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
8844
8896
  const instanceOfType = (
8845
8897
  // const instanceOfType = <T extends new (...args: any[]) => any>(
@@ -8953,6 +9005,7 @@ var z = /*#__PURE__*/Object.freeze({
8953
9005
  BRAND: BRAND,
8954
9006
  ZodBranded: ZodBranded,
8955
9007
  ZodPipeline: ZodPipeline,
9008
+ ZodReadonly: ZodReadonly,
8956
9009
  custom: custom,
8957
9010
  Schema: ZodType,
8958
9011
  ZodSchema: ZodType,
@@ -12327,8 +12380,8 @@ function widgetApiFactory(componentApi) {
12327
12380
  if (!journeyStore || !oauthStore || !userStore) {
12328
12381
  logErrorAndThrow('missingStores');
12329
12382
  }
12330
- const requestsOauth = options?.oauth || true;
12331
- const requestsUser = options?.user || true;
12383
+ const requestsOauth = options?.oauth ?? true;
12384
+ const requestsUser = options?.user ?? true;
12332
12385
  const { subscribe, } = derived([journeyStore, oauthStore, userStore], ([$journeyStore, $oauthStore, $userStore], set) => {
12333
12386
  set({
12334
12387
  journey: $journeyStore,