@learncard/helpers 1.3.3 → 1.3.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/dist/helpers.cjs.development.cjs +7084 -487
- 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 +309 -483
- 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.
|
|
@@ -14458,7 +14471,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14458
14471
|
to: LCNVisibleProfileValidator,
|
|
14459
14472
|
from: external_exports.string(),
|
|
14460
14473
|
received: external_exports.string().optional(),
|
|
14461
|
-
uri: external_exports.string().optional()
|
|
14474
|
+
uri: external_exports.string().optional(),
|
|
14475
|
+
status: external_exports.enum(["active", "revoked", "suspended"]).optional()
|
|
14462
14476
|
});
|
|
14463
14477
|
var PaginatedBoostRecipientsValidator = PaginationResponseValidator.extend({
|
|
14464
14478
|
records: BoostRecipientValidator.array()
|
|
@@ -14468,7 +14482,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14468
14482
|
from: external_exports.string(),
|
|
14469
14483
|
received: external_exports.string().optional(),
|
|
14470
14484
|
boostUris: external_exports.array(external_exports.string()),
|
|
14471
|
-
credentialUris: external_exports.array(external_exports.string()).optional()
|
|
14485
|
+
credentialUris: external_exports.array(external_exports.string()).optional(),
|
|
14486
|
+
status: external_exports.enum(["active", "revoked", "suspended"]).optional()
|
|
14472
14487
|
});
|
|
14473
14488
|
var PaginatedBoostRecipientsWithChildrenValidator = PaginationResponseValidator.extend({
|
|
14474
14489
|
records: BoostRecipientWithChildrenValidator.array()
|
|
@@ -15554,7 +15569,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15554
15569
|
inboxCredentialId: external_exports.string().optional(),
|
|
15555
15570
|
integrationId: external_exports.string().optional(),
|
|
15556
15571
|
source: CredentialActivitySourceTypeValidator,
|
|
15557
|
-
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
15572
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
15573
|
+
status: external_exports.enum(["active", "revoked", "suspended"]).optional()
|
|
15558
15574
|
});
|
|
15559
15575
|
var CredentialActivityWithDetailsValidator = CredentialActivityValidator.extend({
|
|
15560
15576
|
boost: external_exports.object({
|
|
@@ -15631,7 +15647,7 @@ var require_dist = __commonJS({
|
|
|
15631
15647
|
});
|
|
15632
15648
|
|
|
15633
15649
|
// src/index.ts
|
|
15634
|
-
var
|
|
15650
|
+
var import_types2 = __toESM(require_dist());
|
|
15635
15651
|
|
|
15636
15652
|
// src/images/filestack.helpers.ts
|
|
15637
15653
|
var filestack_helpers_exports = {};
|
|
@@ -15727,457 +15743,32 @@ __export(unsplash_helpers_exports, {
|
|
|
15727
15743
|
resizeUrl: () => resizeUrl2
|
|
15728
15744
|
});
|
|
15729
15745
|
|
|
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
|
-
}
|
|
15746
|
+
// src/images/url.helpers.ts
|
|
15747
|
+
var parseUrl = /* @__PURE__ */ __name((input) => {
|
|
15748
|
+
const hashIndex = input.indexOf("#");
|
|
15749
|
+
const fragmentIdentifier = hashIndex === -1 ? void 0 : input.slice(hashIndex + 1);
|
|
15750
|
+
const withoutFragment = hashIndex === -1 ? input : input.slice(0, hashIndex);
|
|
15751
|
+
const queryIndex = withoutFragment.indexOf("?");
|
|
15752
|
+
const url = queryIndex === -1 ? withoutFragment : withoutFragment.slice(0, queryIndex);
|
|
15753
|
+
const search = queryIndex === -1 ? "" : withoutFragment.slice(queryIndex + 1);
|
|
15754
|
+
const query = {};
|
|
15755
|
+
for (const [key, value] of new URLSearchParams(search)) query[key] = value;
|
|
16128
15756
|
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
|
|
15757
|
+
url,
|
|
15758
|
+
query,
|
|
15759
|
+
...fragmentIdentifier !== void 0 ? { fragmentIdentifier } : {}
|
|
16147
15760
|
};
|
|
16148
|
-
|
|
16149
|
-
|
|
16150
|
-
|
|
16151
|
-
|
|
16152
|
-
|
|
16153
|
-
|
|
16154
|
-
hash = options[encodeFragmentIdentifier] ? urlObjectForFragmentEncode.hash : `#${object.fragmentIdentifier}`;
|
|
15761
|
+
}, "parseUrl");
|
|
15762
|
+
var stringifyUrl = /* @__PURE__ */ __name((parsed) => {
|
|
15763
|
+
const params = new URLSearchParams();
|
|
15764
|
+
for (const [key, value] of Object.entries(parsed.query)) {
|
|
15765
|
+
if (value === void 0 || value === null) continue;
|
|
15766
|
+
params.append(key, String(value));
|
|
16155
15767
|
}
|
|
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;
|
|
15768
|
+
const search = params.toString().replace(/\+/g, "%20");
|
|
15769
|
+
const fragment = parsed.fragmentIdentifier ? `#${parsed.fragmentIdentifier}` : "";
|
|
15770
|
+
return `${parsed.url}${search ? `?${search}` : ""}${fragment}`;
|
|
15771
|
+
}, "stringifyUrl");
|
|
16181
15772
|
|
|
16182
15773
|
// src/images/unsplash.helpers.ts
|
|
16183
15774
|
var fixSrcSetString2 = /* @__PURE__ */ __name((srcSetString, _mimetype, _webp = false) => {
|
|
@@ -16186,19 +15777,19 @@ var fixSrcSetString2 = /* @__PURE__ */ __name((srcSetString, _mimetype, _webp =
|
|
|
16186
15777
|
}, "fixSrcSetString");
|
|
16187
15778
|
var fixUrl2 = /* @__PURE__ */ __name((url, _mimetype, _webp = false) => {
|
|
16188
15779
|
if (url.split(" ").length > 1) return fixSrcSetString2(url);
|
|
16189
|
-
const parsedUrl =
|
|
15780
|
+
const parsedUrl = parseUrl(url);
|
|
16190
15781
|
parsedUrl.query.auto = "format";
|
|
16191
|
-
return
|
|
15782
|
+
return stringifyUrl(parsedUrl);
|
|
16192
15783
|
}, "fixUrl");
|
|
16193
15784
|
var resizeUrl2 = /* @__PURE__ */ __name((url, size) => {
|
|
16194
|
-
const parsedUrl =
|
|
15785
|
+
const parsedUrl = parseUrl(url);
|
|
16195
15786
|
parsedUrl.query.w = size.toString();
|
|
16196
|
-
return
|
|
15787
|
+
return stringifyUrl(parsedUrl);
|
|
16197
15788
|
}, "resizeUrl");
|
|
16198
15789
|
var changeQuality2 = /* @__PURE__ */ __name((url, quality) => {
|
|
16199
|
-
const parsedUrl =
|
|
15790
|
+
const parsedUrl = parseUrl(url);
|
|
16200
15791
|
parsedUrl.query.q = quality.toString();
|
|
16201
|
-
return
|
|
15792
|
+
return stringifyUrl(parsedUrl);
|
|
16202
15793
|
}, "changeQuality");
|
|
16203
15794
|
var resizeAndChangeQuality2 = /* @__PURE__ */ __name((url, size, quality, { fix = false } = {}) => {
|
|
16204
15795
|
const updatedUrl = changeQuality2(resizeUrl2(url, size), quality);
|
|
@@ -16247,9 +15838,9 @@ var fixUrl3 = /* @__PURE__ */ __name((url, _mimetype, _webp = false) => {
|
|
|
16247
15838
|
}, "fixUrl");
|
|
16248
15839
|
var VALID_DISCORD_SIZES = [20, 32, 40, 60, 64, 80, 100, 128, 256, 512, 1024, 2048, 4096];
|
|
16249
15840
|
var resizeUrl3 = /* @__PURE__ */ __name((url, size) => {
|
|
16250
|
-
const parsedUrl =
|
|
15841
|
+
const parsedUrl = parseUrl(url);
|
|
16251
15842
|
parsedUrl.query.size = quantizeValue(size, VALID_DISCORD_SIZES).toString();
|
|
16252
|
-
return
|
|
15843
|
+
return stringifyUrl(parsedUrl);
|
|
16253
15844
|
}, "resizeUrl");
|
|
16254
15845
|
var changeQuality3 = /* @__PURE__ */ __name((url, _quality) => {
|
|
16255
15846
|
return url;
|
|
@@ -16569,6 +16160,31 @@ var calculateAgeFromDob = /* @__PURE__ */ __name((dob) => {
|
|
|
16569
16160
|
}, "calculateAgeFromDob");
|
|
16570
16161
|
|
|
16571
16162
|
// src/credential-format.ts
|
|
16163
|
+
var import_types = __toESM(require_dist());
|
|
16164
|
+
import { sha256 } from "@noble/hashes/sha2";
|
|
16165
|
+
import { decodeSdJwtSync, getClaimsSync } from "@sd-jwt/decode";
|
|
16166
|
+
var SD_JWT_RESERVED_CLAIMS = /* @__PURE__ */ new Set([
|
|
16167
|
+
"iss",
|
|
16168
|
+
"iat",
|
|
16169
|
+
"exp",
|
|
16170
|
+
"nbf",
|
|
16171
|
+
"sub",
|
|
16172
|
+
"vct",
|
|
16173
|
+
"cnf",
|
|
16174
|
+
"_sd_alg",
|
|
16175
|
+
"_sd",
|
|
16176
|
+
"...",
|
|
16177
|
+
"status"
|
|
16178
|
+
]);
|
|
16179
|
+
var SD_JWT_FALLBACK_ISSUED_AT_ISO = "1970-01-01T00:00:00.000Z";
|
|
16180
|
+
var SUPPORTED_SD_JWT_HASH_ALGS = /* @__PURE__ */ new Set(["sha-256", "SHA-256", "sha256"]);
|
|
16181
|
+
var sha256HasherSync = /* @__PURE__ */ __name((data, alg) => {
|
|
16182
|
+
if (!SUPPORTED_SD_JWT_HASH_ALGS.has(alg)) {
|
|
16183
|
+
throw new Error(`Unsupported hash algorithm: "${alg}". Only sha-256 is supported.`);
|
|
16184
|
+
}
|
|
16185
|
+
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : new Uint8Array(data);
|
|
16186
|
+
return sha256(bytes);
|
|
16187
|
+
}, "sha256HasherSync");
|
|
16572
16188
|
var toStoredCredential = /* @__PURE__ */ __name((record) => {
|
|
16573
16189
|
if (record.format) {
|
|
16574
16190
|
if (record.format === "dc+sd-jwt" || record.format === "vc+sd-jwt" || record.format === "jwt-vc-json" || record.format === "mso_mdoc") {
|
|
@@ -16630,6 +16246,208 @@ var asWireFormProof = /* @__PURE__ */ __name((proof) => proof && typeof proof ==
|
|
|
16630
16246
|
var isUsableWireFormProof = /* @__PURE__ */ __name((proof, requireSupportedType) => typeof proof.jwt === "string" && proof.jwt.length > 0 && (!requireSupportedType || proof.type === "SdJwtCompactProof" || proof.type === "JwtProof2020"), "isUsableWireFormProof");
|
|
16631
16247
|
var getWireFormFromProof = /* @__PURE__ */ __name((proof) => typeof proof?.jwt === "string" && proof.jwt.length > 0 ? proof.jwt : void 0, "getWireFormFromProof");
|
|
16632
16248
|
var extractWireFormFromVc = /* @__PURE__ */ __name((vc) => getWireFormFromProof(getWireFormProof(vc)), "extractWireFormFromVc");
|
|
16249
|
+
var extractVctSegment = /* @__PURE__ */ __name((vct) => {
|
|
16250
|
+
let segment;
|
|
16251
|
+
try {
|
|
16252
|
+
const url = new URL(vct);
|
|
16253
|
+
if (url.protocol === "http:" || url.protocol === "https:") {
|
|
16254
|
+
const parts = url.pathname.split("/").filter(Boolean);
|
|
16255
|
+
if (parts.length > 0) segment = parts[parts.length - 1];
|
|
16256
|
+
}
|
|
16257
|
+
} catch {
|
|
16258
|
+
}
|
|
16259
|
+
if (segment === void 0) {
|
|
16260
|
+
if (vct.includes(":")) {
|
|
16261
|
+
const parts = vct.split(":").filter(Boolean);
|
|
16262
|
+
const last = parts[parts.length - 1];
|
|
16263
|
+
if (last && !/^\d+$/.test(last)) {
|
|
16264
|
+
segment = last;
|
|
16265
|
+
} else if (parts.length >= 2) {
|
|
16266
|
+
segment = parts[parts.length - 2];
|
|
16267
|
+
}
|
|
16268
|
+
} else {
|
|
16269
|
+
segment = vct;
|
|
16270
|
+
}
|
|
16271
|
+
}
|
|
16272
|
+
return segment && segment.length > 0 ? segment : void 0;
|
|
16273
|
+
}, "extractVctSegment");
|
|
16274
|
+
var deriveTypeFromVct = /* @__PURE__ */ __name((vct) => {
|
|
16275
|
+
if (!vct || typeof vct !== "string") return void 0;
|
|
16276
|
+
const segment = extractVctSegment(vct);
|
|
16277
|
+
if (!segment) return void 0;
|
|
16278
|
+
const normalized = segment.replace(/[-_.]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim();
|
|
16279
|
+
const words = normalized.split(/\s+/).filter(Boolean);
|
|
16280
|
+
if (words.length === 0) return void 0;
|
|
16281
|
+
if (words.length === 1 && words[0].length <= 4 && words[0] === words[0].toLowerCase()) {
|
|
16282
|
+
return words[0].toUpperCase();
|
|
16283
|
+
}
|
|
16284
|
+
return words.map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("");
|
|
16285
|
+
}, "deriveTypeFromVct");
|
|
16286
|
+
var deriveNameFromVct = /* @__PURE__ */ __name((vct) => {
|
|
16287
|
+
if (!vct || typeof vct !== "string") return void 0;
|
|
16288
|
+
const segment = extractVctSegment(vct);
|
|
16289
|
+
if (!segment) return void 0;
|
|
16290
|
+
const normalized = segment.replace(/[-_.]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim();
|
|
16291
|
+
const words = normalized.split(/\s+/).filter(Boolean);
|
|
16292
|
+
if (words.length === 0) return void 0;
|
|
16293
|
+
if (words.length === 1 && words[0].length <= 4 && words[0] === words[0].toLowerCase()) {
|
|
16294
|
+
return words[0].toUpperCase();
|
|
16295
|
+
}
|
|
16296
|
+
return words.map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
|
|
16297
|
+
}, "deriveNameFromVct");
|
|
16298
|
+
var stripSdJwtReservedClaims = /* @__PURE__ */ __name((claims) => {
|
|
16299
|
+
const out = {};
|
|
16300
|
+
for (const [key, value] of Object.entries(claims)) {
|
|
16301
|
+
if (!SD_JWT_RESERVED_CLAIMS.has(key)) out[key] = value;
|
|
16302
|
+
}
|
|
16303
|
+
return out;
|
|
16304
|
+
}, "stripSdJwtReservedClaims");
|
|
16305
|
+
var PRIVATE_JWK_FIELDS = /* @__PURE__ */ new Set(["d", "dp", "dq", "p", "q", "qi", "oth", "k"]);
|
|
16306
|
+
var bytesToBase64Url = /* @__PURE__ */ __name((bytes) => {
|
|
16307
|
+
let binary = "";
|
|
16308
|
+
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
16309
|
+
const base64 = typeof btoa === "function" ? btoa(binary) : Buffer.from(binary, "binary").toString("base64");
|
|
16310
|
+
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
16311
|
+
}, "bytesToBase64Url");
|
|
16312
|
+
var synthesizeDidJwk = /* @__PURE__ */ __name((jwk) => {
|
|
16313
|
+
if (typeof jwk.kty !== "string") return void 0;
|
|
16314
|
+
const publicOnly = {};
|
|
16315
|
+
for (const [key, value] of Object.entries(jwk)) {
|
|
16316
|
+
if (!PRIVATE_JWK_FIELDS.has(key)) publicOnly[key] = value;
|
|
16317
|
+
}
|
|
16318
|
+
try {
|
|
16319
|
+
const sortedKeys = Object.keys(publicOnly).sort();
|
|
16320
|
+
const canonical = {};
|
|
16321
|
+
for (const key of sortedKeys) canonical[key] = publicOnly[key];
|
|
16322
|
+
return `did:jwk:${bytesToBase64Url(new TextEncoder().encode(JSON.stringify(canonical)))}`;
|
|
16323
|
+
} catch {
|
|
16324
|
+
return void 0;
|
|
16325
|
+
}
|
|
16326
|
+
}, "synthesizeDidJwk");
|
|
16327
|
+
var deriveSdJwtIssuedAtIso = /* @__PURE__ */ __name((options) => {
|
|
16328
|
+
if (options.issuedAt) return options.issuedAt.toISOString();
|
|
16329
|
+
if (options.notBefore) return options.notBefore.toISOString();
|
|
16330
|
+
if (typeof options.iat === "number") return new Date(options.iat * 1e3).toISOString();
|
|
16331
|
+
if (typeof options.nbf === "number") return new Date(options.nbf * 1e3).toISOString();
|
|
16332
|
+
return SD_JWT_FALLBACK_ISSUED_AT_ISO;
|
|
16333
|
+
}, "deriveSdJwtIssuedAtIso");
|
|
16334
|
+
var deriveVerificationMethodFromIssuer = /* @__PURE__ */ __name((options) => {
|
|
16335
|
+
if (!options.issuer.startsWith("did:") || typeof options.headerKid !== "string") {
|
|
16336
|
+
return void 0;
|
|
16337
|
+
}
|
|
16338
|
+
return options.headerKid.startsWith("#") ? `${options.issuer}${options.headerKid}` : options.headerKid;
|
|
16339
|
+
}, "deriveVerificationMethodFromIssuer");
|
|
16340
|
+
var projectEnvelopeToDisplayVc = /* @__PURE__ */ __name((envelope) => {
|
|
16341
|
+
if (envelope.format === "mso_mdoc") return void 0;
|
|
16342
|
+
const data = envelope.data;
|
|
16343
|
+
if (typeof data !== "string" || data.length === 0) return void 0;
|
|
16344
|
+
if (envelope.format === "dc+sd-jwt" || envelope.format === "vc+sd-jwt") {
|
|
16345
|
+
return projectSdJwtCompactToVc(data);
|
|
16346
|
+
}
|
|
16347
|
+
if (envelope.format === "jwt-vc-json") {
|
|
16348
|
+
return projectJwtVcCompactToVc(data);
|
|
16349
|
+
}
|
|
16350
|
+
return void 0;
|
|
16351
|
+
}, "projectEnvelopeToDisplayVc");
|
|
16352
|
+
var decodeJwsPayload = /* @__PURE__ */ __name((compact) => {
|
|
16353
|
+
const firstTilde = compact.indexOf("~");
|
|
16354
|
+
const jws = firstTilde >= 0 ? compact.slice(0, firstTilde) : compact;
|
|
16355
|
+
const parts = jws.split(".");
|
|
16356
|
+
if (parts.length !== 3) return void 0;
|
|
16357
|
+
try {
|
|
16358
|
+
const payloadJson = base64UrlDecodeToString(parts[1]);
|
|
16359
|
+
const parsed = JSON.parse(payloadJson);
|
|
16360
|
+
return parsed && typeof parsed === "object" ? parsed : void 0;
|
|
16361
|
+
} catch {
|
|
16362
|
+
return void 0;
|
|
16363
|
+
}
|
|
16364
|
+
}, "decodeJwsPayload");
|
|
16365
|
+
var base64UrlDecodeToString = /* @__PURE__ */ __name((b64url) => {
|
|
16366
|
+
const b64 = b64url.replace(/-/g, "+").replace(/_/g, "/");
|
|
16367
|
+
const padded = b64 + "=".repeat((4 - b64.length % 4) % 4);
|
|
16368
|
+
if (typeof atob === "function") return decodeURIComponent(escape(atob(padded)));
|
|
16369
|
+
return Buffer.from(padded, "base64").toString("utf-8");
|
|
16370
|
+
}, "base64UrlDecodeToString");
|
|
16371
|
+
var projectSdJwtCompactToVc = /* @__PURE__ */ __name((compact) => {
|
|
16372
|
+
let decoded;
|
|
16373
|
+
try {
|
|
16374
|
+
decoded = decodeSdJwtSync(compact, sha256HasherSync);
|
|
16375
|
+
} catch {
|
|
16376
|
+
return void 0;
|
|
16377
|
+
}
|
|
16378
|
+
const payload = decoded.jwt?.payload;
|
|
16379
|
+
if (!payload || typeof payload !== "object") return void 0;
|
|
16380
|
+
const issuer = typeof payload.iss === "string" ? payload.iss : "unknown";
|
|
16381
|
+
const issuedAtIso = deriveSdJwtIssuedAtIso({
|
|
16382
|
+
iat: typeof payload.iat === "number" ? payload.iat : void 0,
|
|
16383
|
+
nbf: typeof payload.nbf === "number" ? payload.nbf : void 0
|
|
16384
|
+
});
|
|
16385
|
+
const expiresAtSec = typeof payload.exp === "number" ? payload.exp : void 0;
|
|
16386
|
+
let reconstructedClaims = payload;
|
|
16387
|
+
try {
|
|
16388
|
+
reconstructedClaims = getClaimsSync(
|
|
16389
|
+
payload,
|
|
16390
|
+
decoded.disclosures ?? [],
|
|
16391
|
+
sha256HasherSync
|
|
16392
|
+
);
|
|
16393
|
+
} catch {
|
|
16394
|
+
}
|
|
16395
|
+
const credentialSubject = stripSdJwtReservedClaims(reconstructedClaims);
|
|
16396
|
+
const cnf = payload.cnf;
|
|
16397
|
+
const holderPublicKey = cnf && typeof cnf === "object" && "jwk" in cnf && cnf.jwk && typeof cnf.jwk === "object" ? cnf.jwk : void 0;
|
|
16398
|
+
const holderDid = holderPublicKey ? synthesizeDidJwk(holderPublicKey) : void 0;
|
|
16399
|
+
if (holderDid) credentialSubject.id = holderDid;
|
|
16400
|
+
const vct = typeof payload.vct === "string" ? payload.vct : void 0;
|
|
16401
|
+
const derivedType = deriveTypeFromVct(vct);
|
|
16402
|
+
const derivedName = deriveNameFromVct(vct);
|
|
16403
|
+
const typeArray = ["VerifiableCredential", "SdJwtVcCredential"];
|
|
16404
|
+
if (derivedType && derivedType !== "SdJwtVcCredential") typeArray.push(derivedType);
|
|
16405
|
+
const verificationMethod = deriveVerificationMethodFromIssuer({
|
|
16406
|
+
issuer,
|
|
16407
|
+
headerKid: decoded.jwt?.header?.kid
|
|
16408
|
+
});
|
|
16409
|
+
const proof = {
|
|
16410
|
+
type: "SdJwtCompactProof",
|
|
16411
|
+
created: issuedAtIso,
|
|
16412
|
+
proofPurpose: "assertionMethod",
|
|
16413
|
+
jwt: compact
|
|
16414
|
+
};
|
|
16415
|
+
if (verificationMethod) proof.verificationMethod = verificationMethod;
|
|
16416
|
+
const vc = {
|
|
16417
|
+
"@context": ["https://www.w3.org/ns/credentials/v2"],
|
|
16418
|
+
type: typeArray,
|
|
16419
|
+
issuer,
|
|
16420
|
+
validFrom: issuedAtIso,
|
|
16421
|
+
credentialSubject,
|
|
16422
|
+
proof
|
|
16423
|
+
};
|
|
16424
|
+
if (vct) vc.sdJwtVct = vct;
|
|
16425
|
+
if (derivedName) vc.name = derivedName;
|
|
16426
|
+
if (expiresAtSec) {
|
|
16427
|
+
vc.validUntil = new Date(expiresAtSec * 1e3).toISOString();
|
|
16428
|
+
}
|
|
16429
|
+
return vc;
|
|
16430
|
+
}, "projectSdJwtCompactToVc");
|
|
16431
|
+
var projectJwtVcCompactToVc = /* @__PURE__ */ __name((compact) => {
|
|
16432
|
+
const payload = decodeJwsPayload(compact);
|
|
16433
|
+
if (!payload) return void 0;
|
|
16434
|
+
const vcClaim = payload.vc;
|
|
16435
|
+
if (!vcClaim || typeof vcClaim !== "object") return void 0;
|
|
16436
|
+
const vc = { ...vcClaim };
|
|
16437
|
+
if (!vc.proof) {
|
|
16438
|
+
vc.proof = {
|
|
16439
|
+
type: "JwtProof2020",
|
|
16440
|
+
jwt: compact
|
|
16441
|
+
};
|
|
16442
|
+
}
|
|
16443
|
+
return vc;
|
|
16444
|
+
}, "projectJwtVcCompactToVc");
|
|
16445
|
+
var resolveStorageReadResult = /* @__PURE__ */ __name((value) => {
|
|
16446
|
+
if (!value) return value;
|
|
16447
|
+
if (!(0, import_types.isStoredCredentialEnvelope)(value)) return value;
|
|
16448
|
+
const projected = projectEnvelopeToDisplayVc(value);
|
|
16449
|
+
return projected ?? value;
|
|
16450
|
+
}, "resolveStorageReadResult");
|
|
16633
16451
|
var inferW3cVersionFromContext = /* @__PURE__ */ __name((vc) => {
|
|
16634
16452
|
if (!vc || typeof vc !== "object") return "w3c-vc-1.1";
|
|
16635
16453
|
const contextRaw = vc["@context"];
|
|
@@ -16643,7 +16461,7 @@ var inferW3cVersionFromContext = /* @__PURE__ */ __name((vc) => {
|
|
|
16643
16461
|
// src/index.ts
|
|
16644
16462
|
var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
|
|
16645
16463
|
var isEncrypted = /* @__PURE__ */ __name((item) => {
|
|
16646
|
-
return
|
|
16464
|
+
return import_types2.JWEValidator.safeParse(item).success;
|
|
16647
16465
|
}, "isEncrypted");
|
|
16648
16466
|
var RegExpTransformer = {
|
|
16649
16467
|
serialize(object) {
|
|
@@ -16705,6 +16523,10 @@ export {
|
|
|
16705
16523
|
curriedInnerReactOuterImmer,
|
|
16706
16524
|
curriedInnerReactOuterReact,
|
|
16707
16525
|
curriedStateSlice,
|
|
16526
|
+
deriveNameFromVct,
|
|
16527
|
+
deriveSdJwtIssuedAtIso,
|
|
16528
|
+
deriveTypeFromVct,
|
|
16529
|
+
extractVctSegment,
|
|
16708
16530
|
filterMaybes,
|
|
16709
16531
|
filterUndefined,
|
|
16710
16532
|
fixUrl4 as fixUrl,
|
|
@@ -16728,9 +16550,13 @@ export {
|
|
|
16728
16550
|
isNotMaybe,
|
|
16729
16551
|
isNotUndefined,
|
|
16730
16552
|
isVC2Format,
|
|
16553
|
+
projectEnvelopeToDisplayVc,
|
|
16731
16554
|
quantizeValue,
|
|
16732
16555
|
resizeAndChangeQuality4 as resizeAndChangeQuality,
|
|
16556
|
+
resolveStorageReadResult,
|
|
16733
16557
|
setBitstringStatusListBit,
|
|
16558
|
+
stripSdJwtReservedClaims,
|
|
16559
|
+
synthesizeDidJwk,
|
|
16734
16560
|
toStoredCredential,
|
|
16735
16561
|
unwrapBoostCredential
|
|
16736
16562
|
};
|