@learncard/helpers 1.3.3 → 1.3.5
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/dist/helpers.cjs.development.cjs +7098 -490
- package/dist/helpers.cjs.development.cjs.map +4 -4
- package/dist/helpers.cjs.production.min.cjs +35 -13
- package/dist/helpers.cjs.production.min.cjs.map +4 -4
- package/dist/helpers.d.cts +77 -4
- package/dist/helpers.d.ts +77 -4
- package/dist/helpers.esm.js +319 -486
- package/dist/helpers.esm.js.map +4 -4
- package/dist/index.cjs +2 -2
- package/package.json +5 -3
package/dist/helpers.esm.js
CHANGED
|
@@ -289,6 +289,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
289
289
|
SkillTreeNodeValidator: /* @__PURE__ */ __name(() => SkillTreeNodeValidator, "SkillTreeNodeValidator"),
|
|
290
290
|
SkillValidator: /* @__PURE__ */ __name(() => SkillValidator, "SkillValidator"),
|
|
291
291
|
StatusCheckEntryValidator: /* @__PURE__ */ __name(() => StatusCheckEntryValidator, "StatusCheckEntryValidator"),
|
|
292
|
+
StoredCredentialEnvelopeValidator: /* @__PURE__ */ __name(() => StoredCredentialEnvelopeValidator, "StoredCredentialEnvelopeValidator"),
|
|
292
293
|
StringQuery: /* @__PURE__ */ __name(() => StringQuery, "StringQuery"),
|
|
293
294
|
SummaryCredentialDataValidator: /* @__PURE__ */ __name(() => SummaryCredentialDataValidator, "SummaryCredentialDataValidator"),
|
|
294
295
|
SummaryCredentialKeywordValidator: /* @__PURE__ */ __name(() => SummaryCredentialKeywordValidator, "SummaryCredentialKeywordValidator"),
|
|
@@ -309,7 +310,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
309
310
|
VerificationItemValidator: /* @__PURE__ */ __name(() => VerificationItemValidator, "VerificationItemValidator"),
|
|
310
311
|
VerificationMethodValidator: /* @__PURE__ */ __name(() => VerificationMethodValidator, "VerificationMethodValidator"),
|
|
311
312
|
VerificationStatusEnum: /* @__PURE__ */ __name(() => VerificationStatusEnum, "VerificationStatusEnum"),
|
|
312
|
-
VerificationStatusValidator: /* @__PURE__ */ __name(() => VerificationStatusValidator, "VerificationStatusValidator")
|
|
313
|
+
VerificationStatusValidator: /* @__PURE__ */ __name(() => VerificationStatusValidator, "VerificationStatusValidator"),
|
|
314
|
+
isStoredCredentialEnvelope: /* @__PURE__ */ __name(() => isStoredCredentialEnvelope2, "isStoredCredentialEnvelope")
|
|
313
315
|
});
|
|
314
316
|
module.exports = __toCommonJS(index_exports);
|
|
315
317
|
var external_exports = {};
|
|
@@ -415,14 +417,14 @@ var require_types_cjs_development = __commonJS({
|
|
|
415
417
|
cuid2: /* @__PURE__ */ __name(() => cuid22, "cuid2"),
|
|
416
418
|
custom: /* @__PURE__ */ __name(() => custom, "custom"),
|
|
417
419
|
date: /* @__PURE__ */ __name(() => date3, "date"),
|
|
418
|
-
decode: /* @__PURE__ */ __name(() =>
|
|
420
|
+
decode: /* @__PURE__ */ __name(() => decode2, "decode"),
|
|
419
421
|
decodeAsync: /* @__PURE__ */ __name(() => decodeAsync2, "decodeAsync"),
|
|
420
422
|
describe: /* @__PURE__ */ __name(() => describe2, "describe"),
|
|
421
423
|
discriminatedUnion: /* @__PURE__ */ __name(() => discriminatedUnion, "discriminatedUnion"),
|
|
422
424
|
e164: /* @__PURE__ */ __name(() => e1642, "e164"),
|
|
423
425
|
email: /* @__PURE__ */ __name(() => email2, "email"),
|
|
424
426
|
emoji: /* @__PURE__ */ __name(() => emoji2, "emoji"),
|
|
425
|
-
encode: /* @__PURE__ */ __name(() =>
|
|
427
|
+
encode: /* @__PURE__ */ __name(() => encode2, "encode"),
|
|
426
428
|
encodeAsync: /* @__PURE__ */ __name(() => encodeAsync2, "encodeAsync"),
|
|
427
429
|
endsWith: /* @__PURE__ */ __name(() => _endsWith, "endsWith"),
|
|
428
430
|
enum: /* @__PURE__ */ __name(() => _enum2, "enum"),
|
|
@@ -487,7 +489,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
487
489
|
object: /* @__PURE__ */ __name(() => object, "object"),
|
|
488
490
|
optional: /* @__PURE__ */ __name(() => optional, "optional"),
|
|
489
491
|
overwrite: /* @__PURE__ */ __name(() => _overwrite, "overwrite"),
|
|
490
|
-
parse: /* @__PURE__ */ __name(() =>
|
|
492
|
+
parse: /* @__PURE__ */ __name(() => parse2, "parse"),
|
|
491
493
|
parseAsync: /* @__PURE__ */ __name(() => parseAsync2, "parseAsync"),
|
|
492
494
|
partialRecord: /* @__PURE__ */ __name(() => partialRecord, "partialRecord"),
|
|
493
495
|
pipe: /* @__PURE__ */ __name(() => pipe, "pipe"),
|
|
@@ -781,10 +783,10 @@ var require_types_cjs_development = __commonJS({
|
|
|
781
783
|
_xid: /* @__PURE__ */ __name(() => _xid, "_xid"),
|
|
782
784
|
clone: /* @__PURE__ */ __name(() => clone, "clone"),
|
|
783
785
|
config: /* @__PURE__ */ __name(() => config, "config"),
|
|
784
|
-
decode: /* @__PURE__ */ __name(() =>
|
|
786
|
+
decode: /* @__PURE__ */ __name(() => decode, "decode"),
|
|
785
787
|
decodeAsync: /* @__PURE__ */ __name(() => decodeAsync, "decodeAsync"),
|
|
786
788
|
describe: /* @__PURE__ */ __name(() => describe, "describe"),
|
|
787
|
-
encode: /* @__PURE__ */ __name(() =>
|
|
789
|
+
encode: /* @__PURE__ */ __name(() => encode, "encode"),
|
|
788
790
|
encodeAsync: /* @__PURE__ */ __name(() => encodeAsync, "encodeAsync"),
|
|
789
791
|
flattenError: /* @__PURE__ */ __name(() => flattenError, "flattenError"),
|
|
790
792
|
formatError: /* @__PURE__ */ __name(() => formatError, "formatError"),
|
|
@@ -795,7 +797,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
795
797
|
isValidJWT: /* @__PURE__ */ __name(() => isValidJWT, "isValidJWT"),
|
|
796
798
|
locales: /* @__PURE__ */ __name(() => locales_exports, "locales"),
|
|
797
799
|
meta: /* @__PURE__ */ __name(() => meta, "meta"),
|
|
798
|
-
parse: /* @__PURE__ */ __name(() =>
|
|
800
|
+
parse: /* @__PURE__ */ __name(() => parse, "parse"),
|
|
799
801
|
parseAsync: /* @__PURE__ */ __name(() => parseAsync, "parseAsync"),
|
|
800
802
|
prettifyError: /* @__PURE__ */ __name(() => prettifyError, "prettifyError"),
|
|
801
803
|
regexes: /* @__PURE__ */ __name(() => regexes_exports, "regexes"),
|
|
@@ -959,7 +961,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
959
961
|
omit: /* @__PURE__ */ __name(() => omit, "omit"),
|
|
960
962
|
optionalKeys: /* @__PURE__ */ __name(() => optionalKeys, "optionalKeys"),
|
|
961
963
|
partial: /* @__PURE__ */ __name(() => partial, "partial"),
|
|
962
|
-
pick: /* @__PURE__ */ __name(() =>
|
|
964
|
+
pick: /* @__PURE__ */ __name(() => pick, "pick"),
|
|
963
965
|
prefixIssues: /* @__PURE__ */ __name(() => prefixIssues, "prefixIssues"),
|
|
964
966
|
primitiveTypes: /* @__PURE__ */ __name(() => primitiveTypes, "primitiveTypes"),
|
|
965
967
|
promiseAllObject: /* @__PURE__ */ __name(() => promiseAllObject, "promiseAllObject"),
|
|
@@ -1352,7 +1354,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
1352
1354
|
int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
|
|
1353
1355
|
uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
|
|
1354
1356
|
};
|
|
1355
|
-
function
|
|
1357
|
+
function pick(schema, mask) {
|
|
1356
1358
|
const currDef = schema._zod.def;
|
|
1357
1359
|
const def = mergeDefs(schema._zod.def, {
|
|
1358
1360
|
get shape() {
|
|
@@ -1372,8 +1374,8 @@ var require_types_cjs_development = __commonJS({
|
|
|
1372
1374
|
});
|
|
1373
1375
|
return clone(schema, def);
|
|
1374
1376
|
}
|
|
1375
|
-
__name(
|
|
1376
|
-
__name2(
|
|
1377
|
+
__name(pick, "pick");
|
|
1378
|
+
__name2(pick, "pick");
|
|
1377
1379
|
function omit(schema, mask) {
|
|
1378
1380
|
const currDef = schema._zod.def;
|
|
1379
1381
|
const def = mergeDefs(schema._zod.def, {
|
|
@@ -1818,7 +1820,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
1818
1820
|
}
|
|
1819
1821
|
return result.value;
|
|
1820
1822
|
}, "_parse");
|
|
1821
|
-
var
|
|
1823
|
+
var parse = /* @__PURE__ */ _parse($ZodRealError);
|
|
1822
1824
|
var _parseAsync = /* @__PURE__ */ __name2((_Err) => async (schema, value, _ctx, params) => {
|
|
1823
1825
|
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
|
|
1824
1826
|
let result = schema._zod.run({ value, issues: [] }, ctx);
|
|
@@ -1859,11 +1861,11 @@ var require_types_cjs_development = __commonJS({
|
|
|
1859
1861
|
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
1860
1862
|
return _parse(_Err)(schema, value, ctx);
|
|
1861
1863
|
}, "_encode");
|
|
1862
|
-
var
|
|
1864
|
+
var encode = /* @__PURE__ */ _encode($ZodRealError);
|
|
1863
1865
|
var _decode = /* @__PURE__ */ __name2((_Err) => (schema, value, _ctx) => {
|
|
1864
1866
|
return _parse(_Err)(schema, value, _ctx);
|
|
1865
1867
|
}, "_decode");
|
|
1866
|
-
var
|
|
1868
|
+
var decode = /* @__PURE__ */ _decode($ZodRealError);
|
|
1867
1869
|
var _encodeAsync = /* @__PURE__ */ __name2((_Err) => async (schema, value, _ctx) => {
|
|
1868
1870
|
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
1869
1871
|
return _parseAsync(_Err)(schema, value, ctx);
|
|
@@ -4408,10 +4410,10 @@ var require_types_cjs_development = __commonJS({
|
|
|
4408
4410
|
throw new Error("implement() must be called with a function");
|
|
4409
4411
|
}
|
|
4410
4412
|
return function(...args) {
|
|
4411
|
-
const parsedArgs = inst._def.input ?
|
|
4413
|
+
const parsedArgs = inst._def.input ? parse(inst._def.input, args) : args;
|
|
4412
4414
|
const result = Reflect.apply(func, this, parsedArgs);
|
|
4413
4415
|
if (inst._def.output) {
|
|
4414
|
-
return
|
|
4416
|
+
return parse(inst._def.output, result);
|
|
4415
4417
|
}
|
|
4416
4418
|
return result;
|
|
4417
4419
|
};
|
|
@@ -12452,12 +12454,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12452
12454
|
var ZodRealError = /* @__PURE__ */ $constructor("ZodError", initializer2, {
|
|
12453
12455
|
Parent: Error
|
|
12454
12456
|
});
|
|
12455
|
-
var
|
|
12457
|
+
var parse2 = /* @__PURE__ */ _parse(ZodRealError);
|
|
12456
12458
|
var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
12457
12459
|
var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
12458
12460
|
var safeParseAsync2 = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
12459
|
-
var
|
|
12460
|
-
var
|
|
12461
|
+
var encode2 = /* @__PURE__ */ _encode(ZodRealError);
|
|
12462
|
+
var decode2 = /* @__PURE__ */ _decode(ZodRealError);
|
|
12461
12463
|
var encodeAsync2 = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
12462
12464
|
var decodeAsync2 = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
12463
12465
|
var safeEncode2 = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
@@ -12483,13 +12485,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
12483
12485
|
reg.add(inst, meta3);
|
|
12484
12486
|
return inst;
|
|
12485
12487
|
});
|
|
12486
|
-
inst.parse = (data, params) =>
|
|
12488
|
+
inst.parse = (data, params) => parse2(inst, data, params, { callee: inst.parse });
|
|
12487
12489
|
inst.safeParse = (data, params) => safeParse2(inst, data, params);
|
|
12488
12490
|
inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
|
|
12489
12491
|
inst.safeParseAsync = async (data, params) => safeParseAsync2(inst, data, params);
|
|
12490
12492
|
inst.spa = inst.safeParseAsync;
|
|
12491
|
-
inst.encode = (data, params) =>
|
|
12492
|
-
inst.decode = (data, params) =>
|
|
12493
|
+
inst.encode = (data, params) => encode2(inst, data, params);
|
|
12494
|
+
inst.decode = (data, params) => decode2(inst, data, params);
|
|
12493
12495
|
inst.encodeAsync = async (data, params) => encodeAsync2(inst, data, params);
|
|
12494
12496
|
inst.decodeAsync = async (data, params) => decodeAsync2(inst, data, params);
|
|
12495
12497
|
inst.safeEncode = (data, params) => safeEncode2(inst, data, params);
|
|
@@ -14127,6 +14129,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14127
14129
|
"vc+sd-jwt",
|
|
14128
14130
|
"mso_mdoc"
|
|
14129
14131
|
]);
|
|
14132
|
+
var StoredCredentialEnvelopeValidator = external_exports.object({
|
|
14133
|
+
format: CredentialFormatValidator,
|
|
14134
|
+
data: external_exports.string()
|
|
14135
|
+
}).passthrough();
|
|
14136
|
+
var isStoredCredentialEnvelope2 = /* @__PURE__ */ __name2((value) => {
|
|
14137
|
+
if (!value || typeof value !== "object") return false;
|
|
14138
|
+
const candidate = value;
|
|
14139
|
+
if (typeof candidate.format !== "string") return false;
|
|
14140
|
+
if (!CredentialFormatValidator.safeParse(candidate.format).success) return false;
|
|
14141
|
+
return typeof candidate.data === "string" || candidate.data instanceof Uint8Array;
|
|
14142
|
+
}, "isStoredCredentialEnvelope");
|
|
14130
14143
|
var StatusCheckEntryValidator = external_exports.object({
|
|
14131
14144
|
/**
|
|
14132
14145
|
* The `credentialStatus.type` as it appeared on the credential.
|
|
@@ -14213,6 +14226,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14213
14226
|
if (!match) throw new Error("Invalid RegExp string format");
|
|
14214
14227
|
return { pattern: match[1], flags: match[2] };
|
|
14215
14228
|
}, "parseRegexString");
|
|
14229
|
+
var withStringOverride = /* @__PURE__ */ __name2((schema) => {
|
|
14230
|
+
const metaSchema = schema;
|
|
14231
|
+
if (typeof metaSchema.meta === "function") {
|
|
14232
|
+
return metaSchema.meta({ override: { type: "string" } });
|
|
14233
|
+
}
|
|
14234
|
+
return schema;
|
|
14235
|
+
}, "withStringOverride");
|
|
14216
14236
|
var RegExpStringValidator = external_exports.string().refine(
|
|
14217
14237
|
(str) => {
|
|
14218
14238
|
try {
|
|
@@ -14232,9 +14252,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14232
14252
|
} catch (error46) {
|
|
14233
14253
|
throw new Error(`Invalid RegExp: ${error46.message}`);
|
|
14234
14254
|
}
|
|
14235
|
-
})
|
|
14236
|
-
var RegExpValidator = external_exports.instanceof(RegExp).
|
|
14237
|
-
var BaseStringQuery = external_exports.string().or(external_exports.object({ $in: external_exports.string().array() })).or(external_exports.object({ $regex: RegExpValidator
|
|
14255
|
+
});
|
|
14256
|
+
var RegExpValidator = withStringOverride(external_exports.instanceof(RegExp).or(RegExpStringValidator));
|
|
14257
|
+
var BaseStringQuery = external_exports.string().or(external_exports.object({ $in: external_exports.string().array() })).or(external_exports.object({ $regex: RegExpValidator }));
|
|
14238
14258
|
var StringQuery = external_exports.union([
|
|
14239
14259
|
BaseStringQuery,
|
|
14240
14260
|
external_exports.object({
|
|
@@ -14458,7 +14478,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14458
14478
|
to: LCNVisibleProfileValidator,
|
|
14459
14479
|
from: external_exports.string(),
|
|
14460
14480
|
received: external_exports.string().optional(),
|
|
14461
|
-
uri: external_exports.string().optional()
|
|
14481
|
+
uri: external_exports.string().optional(),
|
|
14482
|
+
status: external_exports.enum(["active", "revoked", "suspended"]).optional()
|
|
14462
14483
|
});
|
|
14463
14484
|
var PaginatedBoostRecipientsValidator = PaginationResponseValidator.extend({
|
|
14464
14485
|
records: BoostRecipientValidator.array()
|
|
@@ -14468,7 +14489,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14468
14489
|
from: external_exports.string(),
|
|
14469
14490
|
received: external_exports.string().optional(),
|
|
14470
14491
|
boostUris: external_exports.array(external_exports.string()),
|
|
14471
|
-
credentialUris: external_exports.array(external_exports.string()).optional()
|
|
14492
|
+
credentialUris: external_exports.array(external_exports.string()).optional(),
|
|
14493
|
+
status: external_exports.enum(["active", "revoked", "suspended"]).optional()
|
|
14472
14494
|
});
|
|
14473
14495
|
var PaginatedBoostRecipientsWithChildrenValidator = PaginationResponseValidator.extend({
|
|
14474
14496
|
records: BoostRecipientWithChildrenValidator.array()
|
|
@@ -15554,7 +15576,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15554
15576
|
inboxCredentialId: external_exports.string().optional(),
|
|
15555
15577
|
integrationId: external_exports.string().optional(),
|
|
15556
15578
|
source: CredentialActivitySourceTypeValidator,
|
|
15557
|
-
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
15579
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
15580
|
+
status: external_exports.enum(["active", "revoked", "suspended"]).optional()
|
|
15558
15581
|
});
|
|
15559
15582
|
var CredentialActivityWithDetailsValidator = CredentialActivityValidator.extend({
|
|
15560
15583
|
boost: external_exports.object({
|
|
@@ -15631,7 +15654,7 @@ var require_dist = __commonJS({
|
|
|
15631
15654
|
});
|
|
15632
15655
|
|
|
15633
15656
|
// src/index.ts
|
|
15634
|
-
var
|
|
15657
|
+
var import_types2 = __toESM(require_dist());
|
|
15635
15658
|
|
|
15636
15659
|
// src/images/filestack.helpers.ts
|
|
15637
15660
|
var filestack_helpers_exports = {};
|
|
@@ -15727,457 +15750,32 @@ __export(unsplash_helpers_exports, {
|
|
|
15727
15750
|
resizeUrl: () => resizeUrl2
|
|
15728
15751
|
});
|
|
15729
15752
|
|
|
15730
|
-
//
|
|
15731
|
-
var
|
|
15732
|
-
|
|
15733
|
-
|
|
15734
|
-
|
|
15735
|
-
|
|
15736
|
-
|
|
15737
|
-
|
|
15738
|
-
|
|
15739
|
-
|
|
15740
|
-
});
|
|
15741
|
-
import decodeComponent from "decode-uri-component";
|
|
15742
|
-
import { includeKeys } from "filter-obj";
|
|
15743
|
-
import splitOnFirst from "split-on-first";
|
|
15744
|
-
var isNullOrUndefined = /* @__PURE__ */ __name((value) => value === null || value === void 0, "isNullOrUndefined");
|
|
15745
|
-
var strictUriEncode = /* @__PURE__ */ __name((string) => encodeURIComponent(string).replaceAll(/[!'()*]/g, (x) => `%${x.charCodeAt(0).toString(16).toUpperCase()}`), "strictUriEncode");
|
|
15746
|
-
var encodeFragmentIdentifier = /* @__PURE__ */ Symbol("encodeFragmentIdentifier");
|
|
15747
|
-
function encoderForArrayFormat(options) {
|
|
15748
|
-
switch (options.arrayFormat) {
|
|
15749
|
-
case "index": {
|
|
15750
|
-
return (key) => (result, value) => {
|
|
15751
|
-
const index = result.length;
|
|
15752
|
-
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
15753
|
-
return result;
|
|
15754
|
-
}
|
|
15755
|
-
if (value === null) {
|
|
15756
|
-
return [
|
|
15757
|
-
...result,
|
|
15758
|
-
[encode(key, options), "[", index, "]"].join("")
|
|
15759
|
-
];
|
|
15760
|
-
}
|
|
15761
|
-
return [
|
|
15762
|
-
...result,
|
|
15763
|
-
[encode(key, options), "[", encode(index, options), "]=", encode(value, options)].join("")
|
|
15764
|
-
];
|
|
15765
|
-
};
|
|
15766
|
-
}
|
|
15767
|
-
case "bracket": {
|
|
15768
|
-
return (key) => (result, value) => {
|
|
15769
|
-
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
15770
|
-
return result;
|
|
15771
|
-
}
|
|
15772
|
-
if (value === null) {
|
|
15773
|
-
return [
|
|
15774
|
-
...result,
|
|
15775
|
-
[encode(key, options), "[]"].join("")
|
|
15776
|
-
];
|
|
15777
|
-
}
|
|
15778
|
-
return [
|
|
15779
|
-
...result,
|
|
15780
|
-
[encode(key, options), "[]=", encode(value, options)].join("")
|
|
15781
|
-
];
|
|
15782
|
-
};
|
|
15783
|
-
}
|
|
15784
|
-
case "colon-list-separator": {
|
|
15785
|
-
return (key) => (result, value) => {
|
|
15786
|
-
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
15787
|
-
return result;
|
|
15788
|
-
}
|
|
15789
|
-
if (value === null) {
|
|
15790
|
-
return [
|
|
15791
|
-
...result,
|
|
15792
|
-
[encode(key, options), ":list="].join("")
|
|
15793
|
-
];
|
|
15794
|
-
}
|
|
15795
|
-
return [
|
|
15796
|
-
...result,
|
|
15797
|
-
[encode(key, options), ":list=", encode(value, options)].join("")
|
|
15798
|
-
];
|
|
15799
|
-
};
|
|
15800
|
-
}
|
|
15801
|
-
case "comma":
|
|
15802
|
-
case "separator":
|
|
15803
|
-
case "bracket-separator": {
|
|
15804
|
-
const keyValueSeparator = options.arrayFormat === "bracket-separator" ? "[]=" : "=";
|
|
15805
|
-
return (key) => (result, value) => {
|
|
15806
|
-
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
15807
|
-
return result;
|
|
15808
|
-
}
|
|
15809
|
-
value = value === null ? "" : value;
|
|
15810
|
-
if (result.length === 0) {
|
|
15811
|
-
return [[encode(key, options), keyValueSeparator, encode(value, options)].join("")];
|
|
15812
|
-
}
|
|
15813
|
-
return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
|
|
15814
|
-
};
|
|
15815
|
-
}
|
|
15816
|
-
default: {
|
|
15817
|
-
return (key) => (result, value) => {
|
|
15818
|
-
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
15819
|
-
return result;
|
|
15820
|
-
}
|
|
15821
|
-
if (value === null) {
|
|
15822
|
-
return [
|
|
15823
|
-
...result,
|
|
15824
|
-
encode(key, options)
|
|
15825
|
-
];
|
|
15826
|
-
}
|
|
15827
|
-
return [
|
|
15828
|
-
...result,
|
|
15829
|
-
[encode(key, options), "=", encode(value, options)].join("")
|
|
15830
|
-
];
|
|
15831
|
-
};
|
|
15832
|
-
}
|
|
15833
|
-
}
|
|
15834
|
-
}
|
|
15835
|
-
__name(encoderForArrayFormat, "encoderForArrayFormat");
|
|
15836
|
-
function parserForArrayFormat(options) {
|
|
15837
|
-
let result;
|
|
15838
|
-
switch (options.arrayFormat) {
|
|
15839
|
-
case "index": {
|
|
15840
|
-
return (key, value, accumulator) => {
|
|
15841
|
-
result = /\[(\d*)]$/.exec(key);
|
|
15842
|
-
key = key.replace(/\[\d*]$/, "");
|
|
15843
|
-
if (!result) {
|
|
15844
|
-
accumulator[key] = value;
|
|
15845
|
-
return;
|
|
15846
|
-
}
|
|
15847
|
-
if (accumulator[key] === void 0) {
|
|
15848
|
-
accumulator[key] = {};
|
|
15849
|
-
}
|
|
15850
|
-
accumulator[key][result[1]] = value;
|
|
15851
|
-
};
|
|
15852
|
-
}
|
|
15853
|
-
case "bracket": {
|
|
15854
|
-
return (key, value, accumulator) => {
|
|
15855
|
-
result = /(\[])$/.exec(key);
|
|
15856
|
-
key = key.replace(/\[]$/, "");
|
|
15857
|
-
if (!result) {
|
|
15858
|
-
accumulator[key] = value;
|
|
15859
|
-
return;
|
|
15860
|
-
}
|
|
15861
|
-
if (accumulator[key] === void 0) {
|
|
15862
|
-
accumulator[key] = [value];
|
|
15863
|
-
return;
|
|
15864
|
-
}
|
|
15865
|
-
accumulator[key] = [...accumulator[key], value];
|
|
15866
|
-
};
|
|
15867
|
-
}
|
|
15868
|
-
case "colon-list-separator": {
|
|
15869
|
-
return (key, value, accumulator) => {
|
|
15870
|
-
result = /(:list)$/.exec(key);
|
|
15871
|
-
key = key.replace(/:list$/, "");
|
|
15872
|
-
if (!result) {
|
|
15873
|
-
accumulator[key] = value;
|
|
15874
|
-
return;
|
|
15875
|
-
}
|
|
15876
|
-
if (accumulator[key] === void 0) {
|
|
15877
|
-
accumulator[key] = [value];
|
|
15878
|
-
return;
|
|
15879
|
-
}
|
|
15880
|
-
accumulator[key] = [...accumulator[key], value];
|
|
15881
|
-
};
|
|
15882
|
-
}
|
|
15883
|
-
case "comma":
|
|
15884
|
-
case "separator": {
|
|
15885
|
-
return (key, value, accumulator) => {
|
|
15886
|
-
const isArray = typeof value === "string" && value.includes(options.arrayFormatSeparator);
|
|
15887
|
-
const newValue = isArray ? value.split(options.arrayFormatSeparator).map((item) => decode(item, options)) : value === null ? value : decode(value, options);
|
|
15888
|
-
accumulator[key] = newValue;
|
|
15889
|
-
};
|
|
15890
|
-
}
|
|
15891
|
-
case "bracket-separator": {
|
|
15892
|
-
return (key, value, accumulator) => {
|
|
15893
|
-
const isArray = /(\[])$/.test(key);
|
|
15894
|
-
key = key.replace(/\[]$/, "");
|
|
15895
|
-
if (!isArray) {
|
|
15896
|
-
accumulator[key] = value ? decode(value, options) : value;
|
|
15897
|
-
return;
|
|
15898
|
-
}
|
|
15899
|
-
const arrayValue = value === null ? [] : decode(value, options).split(options.arrayFormatSeparator);
|
|
15900
|
-
if (accumulator[key] === void 0) {
|
|
15901
|
-
accumulator[key] = arrayValue;
|
|
15902
|
-
return;
|
|
15903
|
-
}
|
|
15904
|
-
accumulator[key] = [...accumulator[key], ...arrayValue];
|
|
15905
|
-
};
|
|
15906
|
-
}
|
|
15907
|
-
default: {
|
|
15908
|
-
return (key, value, accumulator) => {
|
|
15909
|
-
if (accumulator[key] === void 0) {
|
|
15910
|
-
accumulator[key] = value;
|
|
15911
|
-
return;
|
|
15912
|
-
}
|
|
15913
|
-
accumulator[key] = [...[accumulator[key]].flat(), value];
|
|
15914
|
-
};
|
|
15915
|
-
}
|
|
15916
|
-
}
|
|
15917
|
-
}
|
|
15918
|
-
__name(parserForArrayFormat, "parserForArrayFormat");
|
|
15919
|
-
function validateArrayFormatSeparator(value) {
|
|
15920
|
-
if (typeof value !== "string" || value.length !== 1) {
|
|
15921
|
-
throw new TypeError("arrayFormatSeparator must be single character string");
|
|
15922
|
-
}
|
|
15923
|
-
}
|
|
15924
|
-
__name(validateArrayFormatSeparator, "validateArrayFormatSeparator");
|
|
15925
|
-
function encode(value, options) {
|
|
15926
|
-
if (options.encode) {
|
|
15927
|
-
return options.strict ? strictUriEncode(value) : encodeURIComponent(value);
|
|
15928
|
-
}
|
|
15929
|
-
return value;
|
|
15930
|
-
}
|
|
15931
|
-
__name(encode, "encode");
|
|
15932
|
-
function decode(value, options) {
|
|
15933
|
-
if (options.decode) {
|
|
15934
|
-
return decodeComponent(value);
|
|
15935
|
-
}
|
|
15936
|
-
return value;
|
|
15937
|
-
}
|
|
15938
|
-
__name(decode, "decode");
|
|
15939
|
-
function keysSorter(input) {
|
|
15940
|
-
if (Array.isArray(input)) {
|
|
15941
|
-
return input.sort();
|
|
15942
|
-
}
|
|
15943
|
-
if (typeof input === "object") {
|
|
15944
|
-
return keysSorter(Object.keys(input)).sort((a, b) => Number(a) - Number(b)).map((key) => input[key]);
|
|
15945
|
-
}
|
|
15946
|
-
return input;
|
|
15947
|
-
}
|
|
15948
|
-
__name(keysSorter, "keysSorter");
|
|
15949
|
-
function removeHash(input) {
|
|
15950
|
-
const hashStart = input.indexOf("#");
|
|
15951
|
-
if (hashStart !== -1) {
|
|
15952
|
-
input = input.slice(0, hashStart);
|
|
15953
|
-
}
|
|
15954
|
-
return input;
|
|
15955
|
-
}
|
|
15956
|
-
__name(removeHash, "removeHash");
|
|
15957
|
-
function getHash(url) {
|
|
15958
|
-
let hash = "";
|
|
15959
|
-
const hashStart = url.indexOf("#");
|
|
15960
|
-
if (hashStart !== -1) {
|
|
15961
|
-
hash = url.slice(hashStart);
|
|
15962
|
-
}
|
|
15963
|
-
return hash;
|
|
15964
|
-
}
|
|
15965
|
-
__name(getHash, "getHash");
|
|
15966
|
-
function parseValue(value, options, type) {
|
|
15967
|
-
if (type === "string" && typeof value === "string") {
|
|
15968
|
-
return value;
|
|
15969
|
-
}
|
|
15970
|
-
if (typeof type === "function" && typeof value === "string") {
|
|
15971
|
-
return type(value);
|
|
15972
|
-
}
|
|
15973
|
-
if (type === "boolean" && value === null) {
|
|
15974
|
-
return true;
|
|
15975
|
-
}
|
|
15976
|
-
if (type === "boolean" && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) {
|
|
15977
|
-
return value.toLowerCase() === "true";
|
|
15978
|
-
}
|
|
15979
|
-
if (type === "boolean" && value !== null && (value.toLowerCase() === "1" || value.toLowerCase() === "0")) {
|
|
15980
|
-
return value.toLowerCase() === "1";
|
|
15981
|
-
}
|
|
15982
|
-
if (type === "string[]" && options.arrayFormat !== "none" && typeof value === "string") {
|
|
15983
|
-
return [value];
|
|
15984
|
-
}
|
|
15985
|
-
if (type === "number[]" && options.arrayFormat !== "none" && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) {
|
|
15986
|
-
return [Number(value)];
|
|
15987
|
-
}
|
|
15988
|
-
if (type === "number" && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) {
|
|
15989
|
-
return Number(value);
|
|
15990
|
-
}
|
|
15991
|
-
if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) {
|
|
15992
|
-
return value.toLowerCase() === "true";
|
|
15993
|
-
}
|
|
15994
|
-
if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) {
|
|
15995
|
-
return Number(value);
|
|
15996
|
-
}
|
|
15997
|
-
return value;
|
|
15998
|
-
}
|
|
15999
|
-
__name(parseValue, "parseValue");
|
|
16000
|
-
function extract(input) {
|
|
16001
|
-
input = removeHash(input);
|
|
16002
|
-
const queryStart = input.indexOf("?");
|
|
16003
|
-
if (queryStart === -1) {
|
|
16004
|
-
return "";
|
|
16005
|
-
}
|
|
16006
|
-
return input.slice(queryStart + 1);
|
|
16007
|
-
}
|
|
16008
|
-
__name(extract, "extract");
|
|
16009
|
-
function parse(query, options) {
|
|
16010
|
-
options = {
|
|
16011
|
-
decode: true,
|
|
16012
|
-
sort: true,
|
|
16013
|
-
arrayFormat: "none",
|
|
16014
|
-
arrayFormatSeparator: ",",
|
|
16015
|
-
parseNumbers: false,
|
|
16016
|
-
parseBooleans: false,
|
|
16017
|
-
types: /* @__PURE__ */ Object.create(null),
|
|
16018
|
-
...options
|
|
16019
|
-
};
|
|
16020
|
-
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
16021
|
-
const formatter = parserForArrayFormat(options);
|
|
16022
|
-
const returnValue = /* @__PURE__ */ Object.create(null);
|
|
16023
|
-
if (typeof query !== "string") {
|
|
16024
|
-
return returnValue;
|
|
16025
|
-
}
|
|
16026
|
-
query = query.trim().replace(/^[?#&]/, "");
|
|
16027
|
-
if (!query) {
|
|
16028
|
-
return returnValue;
|
|
16029
|
-
}
|
|
16030
|
-
for (const parameter of query.split("&")) {
|
|
16031
|
-
if (parameter === "") {
|
|
16032
|
-
continue;
|
|
16033
|
-
}
|
|
16034
|
-
const parameter_ = options.decode ? parameter.replaceAll("+", " ") : parameter;
|
|
16035
|
-
let [key, value] = splitOnFirst(parameter_, "=");
|
|
16036
|
-
if (key === void 0) {
|
|
16037
|
-
key = parameter_;
|
|
16038
|
-
}
|
|
16039
|
-
value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode(value, options);
|
|
16040
|
-
formatter(decode(key, options), value, returnValue);
|
|
16041
|
-
}
|
|
16042
|
-
for (const [key, value] of Object.entries(returnValue)) {
|
|
16043
|
-
if (typeof value === "object" && value !== null && options.types[key] !== "string") {
|
|
16044
|
-
for (const [key2, value2] of Object.entries(value)) {
|
|
16045
|
-
const typeOption = options.types[key];
|
|
16046
|
-
const type = typeof typeOption === "function" ? typeOption : typeOption ? typeOption.replace("[]", "") : void 0;
|
|
16047
|
-
value[key2] = parseValue(value2, options, type);
|
|
16048
|
-
}
|
|
16049
|
-
} else if (typeof value === "object" && value !== null && options.types[key] === "string") {
|
|
16050
|
-
returnValue[key] = Object.values(value).join(options.arrayFormatSeparator);
|
|
16051
|
-
} else {
|
|
16052
|
-
returnValue[key] = parseValue(value, options, options.types[key]);
|
|
16053
|
-
}
|
|
16054
|
-
}
|
|
16055
|
-
if (options.sort === false) {
|
|
16056
|
-
return returnValue;
|
|
16057
|
-
}
|
|
16058
|
-
return (options.sort === true ? Object.keys(returnValue).sort() : Object.keys(returnValue).sort(options.sort)).reduce((result, key) => {
|
|
16059
|
-
const value = returnValue[key];
|
|
16060
|
-
result[key] = Boolean(value) && typeof value === "object" && !Array.isArray(value) ? keysSorter(value) : value;
|
|
16061
|
-
return result;
|
|
16062
|
-
}, /* @__PURE__ */ Object.create(null));
|
|
16063
|
-
}
|
|
16064
|
-
__name(parse, "parse");
|
|
16065
|
-
function stringify(object, options) {
|
|
16066
|
-
if (!object) {
|
|
16067
|
-
return "";
|
|
16068
|
-
}
|
|
16069
|
-
options = {
|
|
16070
|
-
encode: true,
|
|
16071
|
-
strict: true,
|
|
16072
|
-
arrayFormat: "none",
|
|
16073
|
-
arrayFormatSeparator: ",",
|
|
16074
|
-
...options
|
|
16075
|
-
};
|
|
16076
|
-
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
16077
|
-
const shouldFilter = /* @__PURE__ */ __name((key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === "", "shouldFilter");
|
|
16078
|
-
const formatter = encoderForArrayFormat(options);
|
|
16079
|
-
const objectCopy = {};
|
|
16080
|
-
for (const [key, value] of Object.entries(object)) {
|
|
16081
|
-
if (!shouldFilter(key)) {
|
|
16082
|
-
objectCopy[key] = value;
|
|
16083
|
-
}
|
|
16084
|
-
}
|
|
16085
|
-
const keys = Object.keys(objectCopy);
|
|
16086
|
-
if (options.sort !== false) {
|
|
16087
|
-
keys.sort(options.sort);
|
|
16088
|
-
}
|
|
16089
|
-
return keys.map((key) => {
|
|
16090
|
-
let value = object[key];
|
|
16091
|
-
if (options.replacer) {
|
|
16092
|
-
value = options.replacer(key, value);
|
|
16093
|
-
if (value === void 0) {
|
|
16094
|
-
return "";
|
|
16095
|
-
}
|
|
16096
|
-
}
|
|
16097
|
-
if (value === void 0) {
|
|
16098
|
-
return "";
|
|
16099
|
-
}
|
|
16100
|
-
if (value === null) {
|
|
16101
|
-
return encode(key, options);
|
|
16102
|
-
}
|
|
16103
|
-
if (Array.isArray(value)) {
|
|
16104
|
-
if (value.length === 0 && options.arrayFormat === "bracket-separator") {
|
|
16105
|
-
return encode(key, options) + "[]";
|
|
16106
|
-
}
|
|
16107
|
-
let processedArray = value;
|
|
16108
|
-
if (options.replacer) {
|
|
16109
|
-
processedArray = value.map(
|
|
16110
|
-
(item, index) => options.replacer(`${key}[${index}]`, item)
|
|
16111
|
-
).filter((item) => item !== void 0);
|
|
16112
|
-
}
|
|
16113
|
-
return processedArray.reduce(formatter(key), []).join("&");
|
|
16114
|
-
}
|
|
16115
|
-
return encode(key, options) + "=" + encode(value, options);
|
|
16116
|
-
}).filter((x) => x.length > 0).join("&");
|
|
16117
|
-
}
|
|
16118
|
-
__name(stringify, "stringify");
|
|
16119
|
-
function parseUrl(url, options) {
|
|
16120
|
-
options = {
|
|
16121
|
-
decode: true,
|
|
16122
|
-
...options
|
|
16123
|
-
};
|
|
16124
|
-
let [url_, hash] = splitOnFirst(url, "#");
|
|
16125
|
-
if (url_ === void 0) {
|
|
16126
|
-
url_ = url;
|
|
16127
|
-
}
|
|
15753
|
+
// src/images/url.helpers.ts
|
|
15754
|
+
var parseUrl = /* @__PURE__ */ __name((input) => {
|
|
15755
|
+
const hashIndex = input.indexOf("#");
|
|
15756
|
+
const fragmentIdentifier = hashIndex === -1 ? void 0 : input.slice(hashIndex + 1);
|
|
15757
|
+
const withoutFragment = hashIndex === -1 ? input : input.slice(0, hashIndex);
|
|
15758
|
+
const queryIndex = withoutFragment.indexOf("?");
|
|
15759
|
+
const url = queryIndex === -1 ? withoutFragment : withoutFragment.slice(0, queryIndex);
|
|
15760
|
+
const search = queryIndex === -1 ? "" : withoutFragment.slice(queryIndex + 1);
|
|
15761
|
+
const query = {};
|
|
15762
|
+
for (const [key, value] of new URLSearchParams(search)) query[key] = value;
|
|
16128
15763
|
return {
|
|
16129
|
-
url
|
|
16130
|
-
query
|
|
16131
|
-
...
|
|
16132
|
-
};
|
|
16133
|
-
}
|
|
16134
|
-
__name(parseUrl, "parseUrl");
|
|
16135
|
-
function stringifyUrl(object, options) {
|
|
16136
|
-
options = {
|
|
16137
|
-
encode: true,
|
|
16138
|
-
strict: true,
|
|
16139
|
-
[encodeFragmentIdentifier]: true,
|
|
16140
|
-
...options
|
|
16141
|
-
};
|
|
16142
|
-
const url = removeHash(object.url).split("?")[0] || "";
|
|
16143
|
-
const queryFromUrl = extract(object.url);
|
|
16144
|
-
const query = {
|
|
16145
|
-
...parse(queryFromUrl, { sort: false, ...options }),
|
|
16146
|
-
...object.query
|
|
15764
|
+
url,
|
|
15765
|
+
query,
|
|
15766
|
+
...fragmentIdentifier !== void 0 ? { fragmentIdentifier } : {}
|
|
16147
15767
|
};
|
|
16148
|
-
|
|
16149
|
-
|
|
16150
|
-
|
|
16151
|
-
|
|
16152
|
-
|
|
16153
|
-
|
|
16154
|
-
hash = options[encodeFragmentIdentifier] ? urlObjectForFragmentEncode.hash : `#${object.fragmentIdentifier}`;
|
|
15768
|
+
}, "parseUrl");
|
|
15769
|
+
var stringifyUrl = /* @__PURE__ */ __name((parsed) => {
|
|
15770
|
+
const params = new URLSearchParams();
|
|
15771
|
+
for (const [key, value] of Object.entries(parsed.query)) {
|
|
15772
|
+
if (value === void 0 || value === null) continue;
|
|
15773
|
+
params.append(key, String(value));
|
|
16155
15774
|
}
|
|
16156
|
-
|
|
16157
|
-
}
|
|
16158
|
-
|
|
16159
|
-
|
|
16160
|
-
options = {
|
|
16161
|
-
parseFragmentIdentifier: true,
|
|
16162
|
-
[encodeFragmentIdentifier]: false,
|
|
16163
|
-
...options
|
|
16164
|
-
};
|
|
16165
|
-
const { url, query, fragmentIdentifier } = parseUrl(input, options);
|
|
16166
|
-
return stringifyUrl({
|
|
16167
|
-
url,
|
|
16168
|
-
query: includeKeys(query, filter),
|
|
16169
|
-
fragmentIdentifier
|
|
16170
|
-
}, options);
|
|
16171
|
-
}
|
|
16172
|
-
__name(pick, "pick");
|
|
16173
|
-
function exclude(input, filter, options) {
|
|
16174
|
-
const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value);
|
|
16175
|
-
return pick(input, exclusionFilter, options);
|
|
16176
|
-
}
|
|
16177
|
-
__name(exclude, "exclude");
|
|
16178
|
-
|
|
16179
|
-
// ../../node_modules/.pnpm/query-string@9.3.1/node_modules/query-string/index.js
|
|
16180
|
-
var query_string_default = base_exports;
|
|
15775
|
+
const search = params.toString().replace(/\+/g, "%20");
|
|
15776
|
+
const fragment = parsed.fragmentIdentifier ? `#${parsed.fragmentIdentifier}` : "";
|
|
15777
|
+
return `${parsed.url}${search ? `?${search}` : ""}${fragment}`;
|
|
15778
|
+
}, "stringifyUrl");
|
|
16181
15779
|
|
|
16182
15780
|
// src/images/unsplash.helpers.ts
|
|
16183
15781
|
var fixSrcSetString2 = /* @__PURE__ */ __name((srcSetString, _mimetype, _webp = false) => {
|
|
@@ -16186,19 +15784,19 @@ var fixSrcSetString2 = /* @__PURE__ */ __name((srcSetString, _mimetype, _webp =
|
|
|
16186
15784
|
}, "fixSrcSetString");
|
|
16187
15785
|
var fixUrl2 = /* @__PURE__ */ __name((url, _mimetype, _webp = false) => {
|
|
16188
15786
|
if (url.split(" ").length > 1) return fixSrcSetString2(url);
|
|
16189
|
-
const parsedUrl =
|
|
15787
|
+
const parsedUrl = parseUrl(url);
|
|
16190
15788
|
parsedUrl.query.auto = "format";
|
|
16191
|
-
return
|
|
15789
|
+
return stringifyUrl(parsedUrl);
|
|
16192
15790
|
}, "fixUrl");
|
|
16193
15791
|
var resizeUrl2 = /* @__PURE__ */ __name((url, size) => {
|
|
16194
|
-
const parsedUrl =
|
|
15792
|
+
const parsedUrl = parseUrl(url);
|
|
16195
15793
|
parsedUrl.query.w = size.toString();
|
|
16196
|
-
return
|
|
15794
|
+
return stringifyUrl(parsedUrl);
|
|
16197
15795
|
}, "resizeUrl");
|
|
16198
15796
|
var changeQuality2 = /* @__PURE__ */ __name((url, quality) => {
|
|
16199
|
-
const parsedUrl =
|
|
15797
|
+
const parsedUrl = parseUrl(url);
|
|
16200
15798
|
parsedUrl.query.q = quality.toString();
|
|
16201
|
-
return
|
|
15799
|
+
return stringifyUrl(parsedUrl);
|
|
16202
15800
|
}, "changeQuality");
|
|
16203
15801
|
var resizeAndChangeQuality2 = /* @__PURE__ */ __name((url, size, quality, { fix = false } = {}) => {
|
|
16204
15802
|
const updatedUrl = changeQuality2(resizeUrl2(url, size), quality);
|
|
@@ -16247,9 +15845,9 @@ var fixUrl3 = /* @__PURE__ */ __name((url, _mimetype, _webp = false) => {
|
|
|
16247
15845
|
}, "fixUrl");
|
|
16248
15846
|
var VALID_DISCORD_SIZES = [20, 32, 40, 60, 64, 80, 100, 128, 256, 512, 1024, 2048, 4096];
|
|
16249
15847
|
var resizeUrl3 = /* @__PURE__ */ __name((url, size) => {
|
|
16250
|
-
const parsedUrl =
|
|
15848
|
+
const parsedUrl = parseUrl(url);
|
|
16251
15849
|
parsedUrl.query.size = quantizeValue(size, VALID_DISCORD_SIZES).toString();
|
|
16252
|
-
return
|
|
15850
|
+
return stringifyUrl(parsedUrl);
|
|
16253
15851
|
}, "resizeUrl");
|
|
16254
15852
|
var changeQuality3 = /* @__PURE__ */ __name((url, _quality) => {
|
|
16255
15853
|
return url;
|
|
@@ -16569,6 +16167,31 @@ var calculateAgeFromDob = /* @__PURE__ */ __name((dob) => {
|
|
|
16569
16167
|
}, "calculateAgeFromDob");
|
|
16570
16168
|
|
|
16571
16169
|
// src/credential-format.ts
|
|
16170
|
+
var import_types = __toESM(require_dist());
|
|
16171
|
+
import { sha256 } from "@noble/hashes/sha2";
|
|
16172
|
+
import { decodeSdJwtSync, getClaimsSync } from "@sd-jwt/decode";
|
|
16173
|
+
var SD_JWT_RESERVED_CLAIMS = /* @__PURE__ */ new Set([
|
|
16174
|
+
"iss",
|
|
16175
|
+
"iat",
|
|
16176
|
+
"exp",
|
|
16177
|
+
"nbf",
|
|
16178
|
+
"sub",
|
|
16179
|
+
"vct",
|
|
16180
|
+
"cnf",
|
|
16181
|
+
"_sd_alg",
|
|
16182
|
+
"_sd",
|
|
16183
|
+
"...",
|
|
16184
|
+
"status"
|
|
16185
|
+
]);
|
|
16186
|
+
var SD_JWT_FALLBACK_ISSUED_AT_ISO = "1970-01-01T00:00:00.000Z";
|
|
16187
|
+
var SUPPORTED_SD_JWT_HASH_ALGS = /* @__PURE__ */ new Set(["sha-256", "SHA-256", "sha256"]);
|
|
16188
|
+
var sha256HasherSync = /* @__PURE__ */ __name((data, alg) => {
|
|
16189
|
+
if (!SUPPORTED_SD_JWT_HASH_ALGS.has(alg)) {
|
|
16190
|
+
throw new Error(`Unsupported hash algorithm: "${alg}". Only sha-256 is supported.`);
|
|
16191
|
+
}
|
|
16192
|
+
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : new Uint8Array(data);
|
|
16193
|
+
return sha256(bytes);
|
|
16194
|
+
}, "sha256HasherSync");
|
|
16572
16195
|
var toStoredCredential = /* @__PURE__ */ __name((record) => {
|
|
16573
16196
|
if (record.format) {
|
|
16574
16197
|
if (record.format === "dc+sd-jwt" || record.format === "vc+sd-jwt" || record.format === "jwt-vc-json" || record.format === "mso_mdoc") {
|
|
@@ -16630,6 +16253,208 @@ var asWireFormProof = /* @__PURE__ */ __name((proof) => proof && typeof proof ==
|
|
|
16630
16253
|
var isUsableWireFormProof = /* @__PURE__ */ __name((proof, requireSupportedType) => typeof proof.jwt === "string" && proof.jwt.length > 0 && (!requireSupportedType || proof.type === "SdJwtCompactProof" || proof.type === "JwtProof2020"), "isUsableWireFormProof");
|
|
16631
16254
|
var getWireFormFromProof = /* @__PURE__ */ __name((proof) => typeof proof?.jwt === "string" && proof.jwt.length > 0 ? proof.jwt : void 0, "getWireFormFromProof");
|
|
16632
16255
|
var extractWireFormFromVc = /* @__PURE__ */ __name((vc) => getWireFormFromProof(getWireFormProof(vc)), "extractWireFormFromVc");
|
|
16256
|
+
var extractVctSegment = /* @__PURE__ */ __name((vct) => {
|
|
16257
|
+
let segment;
|
|
16258
|
+
try {
|
|
16259
|
+
const url = new URL(vct);
|
|
16260
|
+
if (url.protocol === "http:" || url.protocol === "https:") {
|
|
16261
|
+
const parts = url.pathname.split("/").filter(Boolean);
|
|
16262
|
+
if (parts.length > 0) segment = parts[parts.length - 1];
|
|
16263
|
+
}
|
|
16264
|
+
} catch {
|
|
16265
|
+
}
|
|
16266
|
+
if (segment === void 0) {
|
|
16267
|
+
if (vct.includes(":")) {
|
|
16268
|
+
const parts = vct.split(":").filter(Boolean);
|
|
16269
|
+
const last = parts[parts.length - 1];
|
|
16270
|
+
if (last && !/^\d+$/.test(last)) {
|
|
16271
|
+
segment = last;
|
|
16272
|
+
} else if (parts.length >= 2) {
|
|
16273
|
+
segment = parts[parts.length - 2];
|
|
16274
|
+
}
|
|
16275
|
+
} else {
|
|
16276
|
+
segment = vct;
|
|
16277
|
+
}
|
|
16278
|
+
}
|
|
16279
|
+
return segment && segment.length > 0 ? segment : void 0;
|
|
16280
|
+
}, "extractVctSegment");
|
|
16281
|
+
var deriveTypeFromVct = /* @__PURE__ */ __name((vct) => {
|
|
16282
|
+
if (!vct || typeof vct !== "string") return void 0;
|
|
16283
|
+
const segment = extractVctSegment(vct);
|
|
16284
|
+
if (!segment) return void 0;
|
|
16285
|
+
const normalized = segment.replace(/[-_.]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim();
|
|
16286
|
+
const words = normalized.split(/\s+/).filter(Boolean);
|
|
16287
|
+
if (words.length === 0) return void 0;
|
|
16288
|
+
if (words.length === 1 && words[0].length <= 4 && words[0] === words[0].toLowerCase()) {
|
|
16289
|
+
return words[0].toUpperCase();
|
|
16290
|
+
}
|
|
16291
|
+
return words.map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("");
|
|
16292
|
+
}, "deriveTypeFromVct");
|
|
16293
|
+
var deriveNameFromVct = /* @__PURE__ */ __name((vct) => {
|
|
16294
|
+
if (!vct || typeof vct !== "string") return void 0;
|
|
16295
|
+
const segment = extractVctSegment(vct);
|
|
16296
|
+
if (!segment) return void 0;
|
|
16297
|
+
const normalized = segment.replace(/[-_.]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim();
|
|
16298
|
+
const words = normalized.split(/\s+/).filter(Boolean);
|
|
16299
|
+
if (words.length === 0) return void 0;
|
|
16300
|
+
if (words.length === 1 && words[0].length <= 4 && words[0] === words[0].toLowerCase()) {
|
|
16301
|
+
return words[0].toUpperCase();
|
|
16302
|
+
}
|
|
16303
|
+
return words.map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
16304
|
+
}, "deriveNameFromVct");
|
|
16305
|
+
var stripSdJwtReservedClaims = /* @__PURE__ */ __name((claims) => {
|
|
16306
|
+
const out = {};
|
|
16307
|
+
for (const [key, value] of Object.entries(claims)) {
|
|
16308
|
+
if (!SD_JWT_RESERVED_CLAIMS.has(key)) out[key] = value;
|
|
16309
|
+
}
|
|
16310
|
+
return out;
|
|
16311
|
+
}, "stripSdJwtReservedClaims");
|
|
16312
|
+
var PRIVATE_JWK_FIELDS = /* @__PURE__ */ new Set(["d", "dp", "dq", "p", "q", "qi", "oth", "k"]);
|
|
16313
|
+
var bytesToBase64Url = /* @__PURE__ */ __name((bytes) => {
|
|
16314
|
+
let binary = "";
|
|
16315
|
+
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
16316
|
+
const base64 = typeof btoa === "function" ? btoa(binary) : Buffer.from(binary, "binary").toString("base64");
|
|
16317
|
+
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
16318
|
+
}, "bytesToBase64Url");
|
|
16319
|
+
var synthesizeDidJwk = /* @__PURE__ */ __name((jwk) => {
|
|
16320
|
+
if (typeof jwk.kty !== "string") return void 0;
|
|
16321
|
+
const publicOnly = {};
|
|
16322
|
+
for (const [key, value] of Object.entries(jwk)) {
|
|
16323
|
+
if (!PRIVATE_JWK_FIELDS.has(key)) publicOnly[key] = value;
|
|
16324
|
+
}
|
|
16325
|
+
try {
|
|
16326
|
+
const sortedKeys = Object.keys(publicOnly).sort();
|
|
16327
|
+
const canonical = {};
|
|
16328
|
+
for (const key of sortedKeys) canonical[key] = publicOnly[key];
|
|
16329
|
+
return `did:jwk:${bytesToBase64Url(new TextEncoder().encode(JSON.stringify(canonical)))}`;
|
|
16330
|
+
} catch {
|
|
16331
|
+
return void 0;
|
|
16332
|
+
}
|
|
16333
|
+
}, "synthesizeDidJwk");
|
|
16334
|
+
var deriveSdJwtIssuedAtIso = /* @__PURE__ */ __name((options) => {
|
|
16335
|
+
if (options.issuedAt) return options.issuedAt.toISOString();
|
|
16336
|
+
if (options.notBefore) return options.notBefore.toISOString();
|
|
16337
|
+
if (typeof options.iat === "number") return new Date(options.iat * 1e3).toISOString();
|
|
16338
|
+
if (typeof options.nbf === "number") return new Date(options.nbf * 1e3).toISOString();
|
|
16339
|
+
return SD_JWT_FALLBACK_ISSUED_AT_ISO;
|
|
16340
|
+
}, "deriveSdJwtIssuedAtIso");
|
|
16341
|
+
var deriveVerificationMethodFromIssuer = /* @__PURE__ */ __name((options) => {
|
|
16342
|
+
if (!options.issuer.startsWith("did:") || typeof options.headerKid !== "string") {
|
|
16343
|
+
return void 0;
|
|
16344
|
+
}
|
|
16345
|
+
return options.headerKid.startsWith("#") ? `${options.issuer}${options.headerKid}` : options.headerKid;
|
|
16346
|
+
}, "deriveVerificationMethodFromIssuer");
|
|
16347
|
+
var projectEnvelopeToDisplayVc = /* @__PURE__ */ __name((envelope) => {
|
|
16348
|
+
if (envelope.format === "mso_mdoc") return void 0;
|
|
16349
|
+
const data = envelope.data;
|
|
16350
|
+
if (typeof data !== "string" || data.length === 0) return void 0;
|
|
16351
|
+
if (envelope.format === "dc+sd-jwt" || envelope.format === "vc+sd-jwt") {
|
|
16352
|
+
return projectSdJwtCompactToVc(data);
|
|
16353
|
+
}
|
|
16354
|
+
if (envelope.format === "jwt-vc-json") {
|
|
16355
|
+
return projectJwtVcCompactToVc(data);
|
|
16356
|
+
}
|
|
16357
|
+
return void 0;
|
|
16358
|
+
}, "projectEnvelopeToDisplayVc");
|
|
16359
|
+
var decodeJwsPayload = /* @__PURE__ */ __name((compact) => {
|
|
16360
|
+
const firstTilde = compact.indexOf("~");
|
|
16361
|
+
const jws = firstTilde >= 0 ? compact.slice(0, firstTilde) : compact;
|
|
16362
|
+
const parts = jws.split(".");
|
|
16363
|
+
if (parts.length !== 3) return void 0;
|
|
16364
|
+
try {
|
|
16365
|
+
const payloadJson = base64UrlDecodeToString(parts[1]);
|
|
16366
|
+
const parsed = JSON.parse(payloadJson);
|
|
16367
|
+
return parsed && typeof parsed === "object" ? parsed : void 0;
|
|
16368
|
+
} catch {
|
|
16369
|
+
return void 0;
|
|
16370
|
+
}
|
|
16371
|
+
}, "decodeJwsPayload");
|
|
16372
|
+
var base64UrlDecodeToString = /* @__PURE__ */ __name((b64url) => {
|
|
16373
|
+
const b64 = b64url.replace(/-/g, "+").replace(/_/g, "/");
|
|
16374
|
+
const padded = b64 + "=".repeat((4 - b64.length % 4) % 4);
|
|
16375
|
+
if (typeof atob === "function") return decodeURIComponent(escape(atob(padded)));
|
|
16376
|
+
return Buffer.from(padded, "base64").toString("utf-8");
|
|
16377
|
+
}, "base64UrlDecodeToString");
|
|
16378
|
+
var projectSdJwtCompactToVc = /* @__PURE__ */ __name((compact) => {
|
|
16379
|
+
let decoded;
|
|
16380
|
+
try {
|
|
16381
|
+
decoded = decodeSdJwtSync(compact, sha256HasherSync);
|
|
16382
|
+
} catch {
|
|
16383
|
+
return void 0;
|
|
16384
|
+
}
|
|
16385
|
+
const payload = decoded.jwt?.payload;
|
|
16386
|
+
if (!payload || typeof payload !== "object") return void 0;
|
|
16387
|
+
const issuer = typeof payload.iss === "string" ? payload.iss : "unknown";
|
|
16388
|
+
const issuedAtIso = deriveSdJwtIssuedAtIso({
|
|
16389
|
+
iat: typeof payload.iat === "number" ? payload.iat : void 0,
|
|
16390
|
+
nbf: typeof payload.nbf === "number" ? payload.nbf : void 0
|
|
16391
|
+
});
|
|
16392
|
+
const expiresAtSec = typeof payload.exp === "number" ? payload.exp : void 0;
|
|
16393
|
+
let reconstructedClaims = payload;
|
|
16394
|
+
try {
|
|
16395
|
+
reconstructedClaims = getClaimsSync(
|
|
16396
|
+
payload,
|
|
16397
|
+
decoded.disclosures ?? [],
|
|
16398
|
+
sha256HasherSync
|
|
16399
|
+
);
|
|
16400
|
+
} catch {
|
|
16401
|
+
}
|
|
16402
|
+
const credentialSubject = stripSdJwtReservedClaims(reconstructedClaims);
|
|
16403
|
+
const cnf = payload.cnf;
|
|
16404
|
+
const holderPublicKey = cnf && typeof cnf === "object" && "jwk" in cnf && cnf.jwk && typeof cnf.jwk === "object" ? cnf.jwk : void 0;
|
|
16405
|
+
const holderDid = holderPublicKey ? synthesizeDidJwk(holderPublicKey) : void 0;
|
|
16406
|
+
if (holderDid) credentialSubject.id = holderDid;
|
|
16407
|
+
const vct = typeof payload.vct === "string" ? payload.vct : void 0;
|
|
16408
|
+
const derivedType = deriveTypeFromVct(vct);
|
|
16409
|
+
const derivedName = deriveNameFromVct(vct);
|
|
16410
|
+
const typeArray = ["VerifiableCredential", "SdJwtVcCredential"];
|
|
16411
|
+
if (derivedType && derivedType !== "SdJwtVcCredential") typeArray.push(derivedType);
|
|
16412
|
+
const verificationMethod = deriveVerificationMethodFromIssuer({
|
|
16413
|
+
issuer,
|
|
16414
|
+
headerKid: decoded.jwt?.header?.kid
|
|
16415
|
+
});
|
|
16416
|
+
const proof = {
|
|
16417
|
+
type: "SdJwtCompactProof",
|
|
16418
|
+
created: issuedAtIso,
|
|
16419
|
+
proofPurpose: "assertionMethod",
|
|
16420
|
+
jwt: compact
|
|
16421
|
+
};
|
|
16422
|
+
if (verificationMethod) proof.verificationMethod = verificationMethod;
|
|
16423
|
+
const vc = {
|
|
16424
|
+
"@context": ["https://www.w3.org/ns/credentials/v2"],
|
|
16425
|
+
type: typeArray,
|
|
16426
|
+
issuer,
|
|
16427
|
+
validFrom: issuedAtIso,
|
|
16428
|
+
credentialSubject,
|
|
16429
|
+
proof
|
|
16430
|
+
};
|
|
16431
|
+
if (vct) vc.sdJwtVct = vct;
|
|
16432
|
+
if (derivedName) vc.name = derivedName;
|
|
16433
|
+
if (expiresAtSec) {
|
|
16434
|
+
vc.validUntil = new Date(expiresAtSec * 1e3).toISOString();
|
|
16435
|
+
}
|
|
16436
|
+
return vc;
|
|
16437
|
+
}, "projectSdJwtCompactToVc");
|
|
16438
|
+
var projectJwtVcCompactToVc = /* @__PURE__ */ __name((compact) => {
|
|
16439
|
+
const payload = decodeJwsPayload(compact);
|
|
16440
|
+
if (!payload) return void 0;
|
|
16441
|
+
const vcClaim = payload.vc;
|
|
16442
|
+
if (!vcClaim || typeof vcClaim !== "object") return void 0;
|
|
16443
|
+
const vc = { ...vcClaim };
|
|
16444
|
+
if (!vc.proof) {
|
|
16445
|
+
vc.proof = {
|
|
16446
|
+
type: "JwtProof2020",
|
|
16447
|
+
jwt: compact
|
|
16448
|
+
};
|
|
16449
|
+
}
|
|
16450
|
+
return vc;
|
|
16451
|
+
}, "projectJwtVcCompactToVc");
|
|
16452
|
+
var resolveStorageReadResult = /* @__PURE__ */ __name((value) => {
|
|
16453
|
+
if (!value) return value;
|
|
16454
|
+
if (!(0, import_types.isStoredCredentialEnvelope)(value)) return value;
|
|
16455
|
+
const projected = projectEnvelopeToDisplayVc(value);
|
|
16456
|
+
return projected ?? value;
|
|
16457
|
+
}, "resolveStorageReadResult");
|
|
16633
16458
|
var inferW3cVersionFromContext = /* @__PURE__ */ __name((vc) => {
|
|
16634
16459
|
if (!vc || typeof vc !== "object") return "w3c-vc-1.1";
|
|
16635
16460
|
const contextRaw = vc["@context"];
|
|
@@ -16643,7 +16468,7 @@ var inferW3cVersionFromContext = /* @__PURE__ */ __name((vc) => {
|
|
|
16643
16468
|
// src/index.ts
|
|
16644
16469
|
var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
|
|
16645
16470
|
var isEncrypted = /* @__PURE__ */ __name((item) => {
|
|
16646
|
-
return
|
|
16471
|
+
return import_types2.JWEValidator.safeParse(item).success;
|
|
16647
16472
|
}, "isEncrypted");
|
|
16648
16473
|
var RegExpTransformer = {
|
|
16649
16474
|
serialize(object) {
|
|
@@ -16705,6 +16530,10 @@ export {
|
|
|
16705
16530
|
curriedInnerReactOuterImmer,
|
|
16706
16531
|
curriedInnerReactOuterReact,
|
|
16707
16532
|
curriedStateSlice,
|
|
16533
|
+
deriveNameFromVct,
|
|
16534
|
+
deriveSdJwtIssuedAtIso,
|
|
16535
|
+
deriveTypeFromVct,
|
|
16536
|
+
extractVctSegment,
|
|
16708
16537
|
filterMaybes,
|
|
16709
16538
|
filterUndefined,
|
|
16710
16539
|
fixUrl4 as fixUrl,
|
|
@@ -16728,9 +16557,13 @@ export {
|
|
|
16728
16557
|
isNotMaybe,
|
|
16729
16558
|
isNotUndefined,
|
|
16730
16559
|
isVC2Format,
|
|
16560
|
+
projectEnvelopeToDisplayVc,
|
|
16731
16561
|
quantizeValue,
|
|
16732
16562
|
resizeAndChangeQuality4 as resizeAndChangeQuality,
|
|
16563
|
+
resolveStorageReadResult,
|
|
16733
16564
|
setBitstringStatusListBit,
|
|
16565
|
+
stripSdJwtReservedClaims,
|
|
16566
|
+
synthesizeDidJwk,
|
|
16734
16567
|
toStoredCredential,
|
|
16735
16568
|
unwrapBoostCredential
|
|
16736
16569
|
};
|