@pod-os/core 0.2.0 → 0.2.1-4e1a22f.0
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/index.js +266 -105
- package/lib/index.js +265 -105
- package/package.json +3 -1
- package/types/Store.d.ts +2 -2
- package/types/authentication/index.d.ts +5 -1
- package/types/files/BinaryFile.d.ts +7 -0
- package/types/files/BrokenFile.d.ts +9 -0
- package/types/files/BrokenFile.spec.d.ts +1 -0
- package/types/files/FileFetcher.d.ts +7 -0
- package/types/files/FileFetcher.spec.d.ts +1 -0
- package/types/files/HttpStatus.d.ts +6 -0
- package/types/files/HttpStatus.spec.d.ts +1 -0
- package/types/files/SolidFile.d.ts +4 -0
- package/types/files/index.d.ts +4 -0
- package/types/index.d.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -503,26 +503,26 @@ var require_InruptError = __commonJS({
|
|
|
503
503
|
}
|
|
504
504
|
static lookupErrorIri(iri, messageParams) {
|
|
505
505
|
if (InruptError.determineIfVocabTerm(iri)) {
|
|
506
|
-
const
|
|
507
|
-
return
|
|
506
|
+
const message2 = messageParams === void 0 ? iri.message : iri.messageParams(...messageParams);
|
|
507
|
+
return message2 === void 0 ? `Looked up error message IRI [${iri.value}], but found no message value.` : message2;
|
|
508
508
|
}
|
|
509
509
|
return `Error message looked up at: [${iri.value}]${messageParams === void 0 ? "" : `, with params [${messageParams.toString()}]`}`;
|
|
510
510
|
}
|
|
511
|
-
static appendHttpResponseDetails(
|
|
511
|
+
static appendHttpResponseDetails(message2, response, append) {
|
|
512
512
|
if (append && typeof response !== "undefined") {
|
|
513
|
-
return `${
|
|
513
|
+
return `${message2} HTTP details: status code [${response.status}], status text [${response.statusText}].`;
|
|
514
514
|
}
|
|
515
|
-
return
|
|
515
|
+
return message2;
|
|
516
516
|
}
|
|
517
|
-
static appendErrorIri(
|
|
518
|
-
return append ? `${
|
|
517
|
+
static appendErrorIri(message2, iri, append) {
|
|
518
|
+
return append ? `${message2} Error IRI: [${iri.value}].` : message2;
|
|
519
519
|
}
|
|
520
|
-
static substituteParams(
|
|
521
|
-
let fullMessage =
|
|
520
|
+
static substituteParams(message2, params) {
|
|
521
|
+
let fullMessage = message2;
|
|
522
522
|
if (params !== void 0) {
|
|
523
|
-
const paramsRequired =
|
|
523
|
+
const paramsRequired = message2.split("{{").length - 1;
|
|
524
524
|
if (paramsRequired !== params.length) {
|
|
525
|
-
throw new Error(`Setting parameters on message [${
|
|
525
|
+
throw new Error(`Setting parameters on message [${message2}], but it requires [${paramsRequired}] params and we received [${params.length}].`);
|
|
526
526
|
}
|
|
527
527
|
for (let i = 0; i < params.length; i += 1) {
|
|
528
528
|
const marker = `{{${i}}}`;
|
|
@@ -953,10 +953,10 @@ var require_browser_ponyfill = __commonJS({
|
|
|
953
953
|
try {
|
|
954
954
|
new exports2.DOMException();
|
|
955
955
|
} catch (err) {
|
|
956
|
-
exports2.DOMException = function(
|
|
957
|
-
this.message =
|
|
956
|
+
exports2.DOMException = function(message2, name) {
|
|
957
|
+
this.message = message2;
|
|
958
958
|
this.name = name;
|
|
959
|
-
var error2 = Error(
|
|
959
|
+
var error2 = Error(message2);
|
|
960
960
|
this.stack = error2.stack;
|
|
961
961
|
};
|
|
962
962
|
exports2.DOMException.prototype = Object.create(Error.prototype);
|
|
@@ -1188,9 +1188,9 @@ var JOSEError, JWTClaimValidationFailed, JWTExpired, JOSEAlgNotAllowed, JOSENotS
|
|
|
1188
1188
|
var init_errors = __esm({
|
|
1189
1189
|
"../node_modules/jose/dist/browser/util/errors.js"() {
|
|
1190
1190
|
JOSEError = class extends Error {
|
|
1191
|
-
constructor(
|
|
1191
|
+
constructor(message2) {
|
|
1192
1192
|
var _a;
|
|
1193
|
-
super(
|
|
1193
|
+
super(message2);
|
|
1194
1194
|
this.code = "ERR_JOSE_GENERIC";
|
|
1195
1195
|
this.name = this.constructor.name;
|
|
1196
1196
|
(_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, this.constructor);
|
|
@@ -1200,8 +1200,8 @@ var init_errors = __esm({
|
|
|
1200
1200
|
}
|
|
1201
1201
|
};
|
|
1202
1202
|
JWTClaimValidationFailed = class extends JOSEError {
|
|
1203
|
-
constructor(
|
|
1204
|
-
super(
|
|
1203
|
+
constructor(message2, claim = "unspecified", reason = "unspecified") {
|
|
1204
|
+
super(message2);
|
|
1205
1205
|
this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
|
|
1206
1206
|
this.claim = claim;
|
|
1207
1207
|
this.reason = reason;
|
|
@@ -1211,8 +1211,8 @@ var init_errors = __esm({
|
|
|
1211
1211
|
}
|
|
1212
1212
|
};
|
|
1213
1213
|
JWTExpired = class extends JOSEError {
|
|
1214
|
-
constructor(
|
|
1215
|
-
super(
|
|
1214
|
+
constructor(message2, claim = "unspecified", reason = "unspecified") {
|
|
1215
|
+
super(message2);
|
|
1216
1216
|
this.code = "ERR_JWT_EXPIRED";
|
|
1217
1217
|
this.claim = claim;
|
|
1218
1218
|
this.reason = reason;
|
|
@@ -1394,8 +1394,9 @@ var init_check_cek_length = __esm({
|
|
|
1394
1394
|
"../node_modules/jose/dist/browser/runtime/check_cek_length.js"() {
|
|
1395
1395
|
init_errors();
|
|
1396
1396
|
checkCekLength = (cek, expected) => {
|
|
1397
|
-
|
|
1398
|
-
|
|
1397
|
+
const actual = cek.byteLength << 3;
|
|
1398
|
+
if (actual !== expected) {
|
|
1399
|
+
throw new JWEInvalid(`Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits`);
|
|
1399
1400
|
}
|
|
1400
1401
|
};
|
|
1401
1402
|
check_cek_length_default = checkCekLength;
|
|
@@ -1430,7 +1431,7 @@ var init_timing_safe_equal = __esm({
|
|
|
1430
1431
|
|
|
1431
1432
|
// ../node_modules/jose/dist/browser/runtime/env.js
|
|
1432
1433
|
function isCloudflareWorkers() {
|
|
1433
|
-
return typeof WebSocketPair === "
|
|
1434
|
+
return typeof WebSocketPair !== "undefined" || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime !== "undefined" && EdgeRuntime === "vercel";
|
|
1434
1435
|
}
|
|
1435
1436
|
var init_env = __esm({
|
|
1436
1437
|
"../node_modules/jose/dist/browser/runtime/env.js"() {
|
|
@@ -1513,6 +1514,12 @@ function checkSigCryptoKey(key, alg, ...usages) {
|
|
|
1513
1514
|
throw unusable("NODE-ED25519");
|
|
1514
1515
|
break;
|
|
1515
1516
|
}
|
|
1517
|
+
case "EdDSA": {
|
|
1518
|
+
if (key.algorithm.name !== "Ed25519" && key.algorithm.name !== "Ed448") {
|
|
1519
|
+
throw unusable("Ed25519 or Ed448");
|
|
1520
|
+
}
|
|
1521
|
+
break;
|
|
1522
|
+
}
|
|
1516
1523
|
case "ES256":
|
|
1517
1524
|
case "ES384":
|
|
1518
1525
|
case "ES512": {
|
|
@@ -1553,10 +1560,17 @@ function checkEncCryptoKey(key, alg, ...usages) {
|
|
|
1553
1560
|
throw unusable(expected, "algorithm.length");
|
|
1554
1561
|
break;
|
|
1555
1562
|
}
|
|
1556
|
-
case "ECDH":
|
|
1557
|
-
|
|
1558
|
-
|
|
1563
|
+
case "ECDH": {
|
|
1564
|
+
switch (key.algorithm.name) {
|
|
1565
|
+
case "ECDH":
|
|
1566
|
+
case "X25519":
|
|
1567
|
+
case "X448":
|
|
1568
|
+
break;
|
|
1569
|
+
default:
|
|
1570
|
+
throw unusable("ECDH, X25519, or X448");
|
|
1571
|
+
}
|
|
1559
1572
|
break;
|
|
1573
|
+
}
|
|
1560
1574
|
case "PBES2-HS256+A128KW":
|
|
1561
1575
|
case "PBES2-HS384+A192KW":
|
|
1562
1576
|
case "PBES2-HS512+A256KW":
|
|
@@ -1587,29 +1601,34 @@ var init_crypto_key = __esm({
|
|
|
1587
1601
|
});
|
|
1588
1602
|
|
|
1589
1603
|
// ../node_modules/jose/dist/browser/lib/invalid_key_input.js
|
|
1604
|
+
function message(msg2, actual, ...types2) {
|
|
1605
|
+
if (types2.length > 2) {
|
|
1606
|
+
const last = types2.pop();
|
|
1607
|
+
msg2 += `one of type ${types2.join(", ")}, or ${last}.`;
|
|
1608
|
+
} else if (types2.length === 2) {
|
|
1609
|
+
msg2 += `one of type ${types2[0]} or ${types2[1]}.`;
|
|
1610
|
+
} else {
|
|
1611
|
+
msg2 += `of type ${types2[0]}.`;
|
|
1612
|
+
}
|
|
1613
|
+
if (actual == null) {
|
|
1614
|
+
msg2 += ` Received ${actual}`;
|
|
1615
|
+
} else if (typeof actual === "function" && actual.name) {
|
|
1616
|
+
msg2 += ` Received function ${actual.name}`;
|
|
1617
|
+
} else if (typeof actual === "object" && actual != null) {
|
|
1618
|
+
if (actual.constructor && actual.constructor.name) {
|
|
1619
|
+
msg2 += ` Received an instance of ${actual.constructor.name}`;
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
return msg2;
|
|
1623
|
+
}
|
|
1624
|
+
function withAlg(alg, actual, ...types2) {
|
|
1625
|
+
return message(`Key for the ${alg} algorithm must be `, actual, ...types2);
|
|
1626
|
+
}
|
|
1590
1627
|
var invalid_key_input_default;
|
|
1591
1628
|
var init_invalid_key_input = __esm({
|
|
1592
1629
|
"../node_modules/jose/dist/browser/lib/invalid_key_input.js"() {
|
|
1593
1630
|
invalid_key_input_default = (actual, ...types2) => {
|
|
1594
|
-
|
|
1595
|
-
if (types2.length > 2) {
|
|
1596
|
-
const last = types2.pop();
|
|
1597
|
-
msg2 += `one of type ${types2.join(", ")}, or ${last}.`;
|
|
1598
|
-
} else if (types2.length === 2) {
|
|
1599
|
-
msg2 += `one of type ${types2[0]} or ${types2[1]}.`;
|
|
1600
|
-
} else {
|
|
1601
|
-
msg2 += `of type ${types2[0]}.`;
|
|
1602
|
-
}
|
|
1603
|
-
if (actual == null) {
|
|
1604
|
-
msg2 += ` Received ${actual}`;
|
|
1605
|
-
} else if (typeof actual === "function" && actual.name) {
|
|
1606
|
-
msg2 += ` Received function ${actual.name}`;
|
|
1607
|
-
} else if (typeof actual === "object" && actual != null) {
|
|
1608
|
-
if (actual.constructor && actual.constructor.name) {
|
|
1609
|
-
msg2 += ` Received an instance of ${actual.constructor.name}`;
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
return msg2;
|
|
1631
|
+
return message("Key must be ", actual, ...types2);
|
|
1613
1632
|
};
|
|
1614
1633
|
}
|
|
1615
1634
|
});
|
|
@@ -1842,10 +1861,18 @@ async function deriveKey(publicKey, privateKey, algorithm, keyLength, apu = new
|
|
|
1842
1861
|
}
|
|
1843
1862
|
checkEncCryptoKey(privateKey, "ECDH", "deriveBits");
|
|
1844
1863
|
const value = concat(lengthAndInput(encoder.encode(algorithm)), lengthAndInput(apu), lengthAndInput(apv), uint32be(keyLength));
|
|
1864
|
+
let length;
|
|
1865
|
+
if (publicKey.algorithm.name === "X25519") {
|
|
1866
|
+
length = 256;
|
|
1867
|
+
} else if (publicKey.algorithm.name === "X448") {
|
|
1868
|
+
length = 448;
|
|
1869
|
+
} else {
|
|
1870
|
+
length = Math.ceil(parseInt(publicKey.algorithm.namedCurve.substr(-3), 10) / 8) << 3;
|
|
1871
|
+
}
|
|
1845
1872
|
const sharedSecret = new Uint8Array(await webcrypto_default.subtle.deriveBits({
|
|
1846
|
-
name:
|
|
1873
|
+
name: publicKey.algorithm.name,
|
|
1847
1874
|
public: publicKey
|
|
1848
|
-
}, privateKey,
|
|
1875
|
+
}, privateKey, length));
|
|
1849
1876
|
return concatKdf(sharedSecret, keyLength, value);
|
|
1850
1877
|
}
|
|
1851
1878
|
async function generateEpk(key) {
|
|
@@ -1858,7 +1885,7 @@ function ecdhAllowed(key) {
|
|
|
1858
1885
|
if (!isCryptoKey(key)) {
|
|
1859
1886
|
throw new TypeError(invalid_key_input_default(key, ...types));
|
|
1860
1887
|
}
|
|
1861
|
-
return ["P-256", "P-384", "P-521"].includes(key.algorithm.namedCurve);
|
|
1888
|
+
return ["P-256", "P-384", "P-521"].includes(key.algorithm.namedCurve) || key.algorithm.name === "X25519" || key.algorithm.name === "X448";
|
|
1862
1889
|
}
|
|
1863
1890
|
var init_ecdhes = __esm({
|
|
1864
1891
|
"../node_modules/jose/dist/browser/runtime/ecdhes.js"() {
|
|
@@ -2107,8 +2134,14 @@ var init_asn1 = __esm({
|
|
|
2107
2134
|
return "P-384";
|
|
2108
2135
|
case findOid(keyData, [43, 129, 4, 0, 35]):
|
|
2109
2136
|
return "P-521";
|
|
2110
|
-
case
|
|
2137
|
+
case findOid(keyData, [43, 101, 110]):
|
|
2138
|
+
return "X25519";
|
|
2139
|
+
case findOid(keyData, [43, 101, 111]):
|
|
2140
|
+
return "X448";
|
|
2141
|
+
case findOid(keyData, [43, 101, 112]):
|
|
2111
2142
|
return "Ed25519";
|
|
2143
|
+
case findOid(keyData, [43, 101, 113]):
|
|
2144
|
+
return "Ed448";
|
|
2112
2145
|
default:
|
|
2113
2146
|
throw new JOSENotSupported("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
|
|
2114
2147
|
}
|
|
@@ -2157,15 +2190,22 @@ var init_asn1 = __esm({
|
|
|
2157
2190
|
case "ECDH-ES":
|
|
2158
2191
|
case "ECDH-ES+A128KW":
|
|
2159
2192
|
case "ECDH-ES+A192KW":
|
|
2160
|
-
case "ECDH-ES+A256KW":
|
|
2161
|
-
|
|
2193
|
+
case "ECDH-ES+A256KW": {
|
|
2194
|
+
const namedCurve = getNamedCurve2(keyData);
|
|
2195
|
+
algorithm = namedCurve.startsWith("P-") ? { name: "ECDH", namedCurve } : { name: namedCurve };
|
|
2162
2196
|
keyUsages = isPublic ? [] : ["deriveBits"];
|
|
2163
2197
|
break;
|
|
2164
|
-
|
|
2198
|
+
}
|
|
2199
|
+
case (isCloudflareWorkers() && "EdDSA"): {
|
|
2165
2200
|
const namedCurve = getNamedCurve2(keyData).toUpperCase();
|
|
2166
2201
|
algorithm = { name: `NODE-${namedCurve}`, namedCurve: `NODE-${namedCurve}` };
|
|
2167
2202
|
keyUsages = isPublic ? ["verify"] : ["sign"];
|
|
2168
2203
|
break;
|
|
2204
|
+
}
|
|
2205
|
+
case "EdDSA":
|
|
2206
|
+
algorithm = { name: getNamedCurve2(keyData) };
|
|
2207
|
+
keyUsages = isPublic ? ["verify"] : ["sign"];
|
|
2208
|
+
break;
|
|
2169
2209
|
default:
|
|
2170
2210
|
throw new JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
|
|
2171
2211
|
}
|
|
@@ -2288,9 +2328,27 @@ function subtleMapping(jwk) {
|
|
|
2288
2328
|
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
2289
2329
|
break;
|
|
2290
2330
|
default:
|
|
2291
|
-
throw new JOSENotSupported('Invalid or unsupported JWK "
|
|
2331
|
+
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
2292
2332
|
}
|
|
2293
2333
|
break;
|
|
2334
|
+
case "OKP": {
|
|
2335
|
+
switch (jwk.alg) {
|
|
2336
|
+
case "EdDSA":
|
|
2337
|
+
algorithm = { name: jwk.crv };
|
|
2338
|
+
keyUsages = jwk.d ? ["sign"] : ["verify"];
|
|
2339
|
+
break;
|
|
2340
|
+
case "ECDH-ES":
|
|
2341
|
+
case "ECDH-ES+A128KW":
|
|
2342
|
+
case "ECDH-ES+A192KW":
|
|
2343
|
+
case "ECDH-ES+A256KW":
|
|
2344
|
+
algorithm = { name: jwk.crv };
|
|
2345
|
+
keyUsages = jwk.d ? ["deriveBits"] : [];
|
|
2346
|
+
break;
|
|
2347
|
+
default:
|
|
2348
|
+
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
2349
|
+
}
|
|
2350
|
+
break;
|
|
2351
|
+
}
|
|
2294
2352
|
default:
|
|
2295
2353
|
throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
|
|
2296
2354
|
}
|
|
@@ -2350,18 +2408,12 @@ function parseElement(bytes) {
|
|
|
2350
2408
|
if (bytes[position] < 128) {
|
|
2351
2409
|
length = bytes[position];
|
|
2352
2410
|
position++;
|
|
2353
|
-
} else {
|
|
2354
|
-
let numberOfDigits = bytes[position] & 127;
|
|
2355
|
-
position++;
|
|
2356
|
-
length = 0;
|
|
2357
|
-
for (let i = 0; i < numberOfDigits; i++) {
|
|
2358
|
-
length = length * 256 + bytes[position];
|
|
2359
|
-
position++;
|
|
2360
|
-
}
|
|
2361
|
-
}
|
|
2362
|
-
if (length === 128) {
|
|
2411
|
+
} else if (length === 128) {
|
|
2363
2412
|
length = 0;
|
|
2364
2413
|
while (bytes[position + length] !== 0 || bytes[position + length + 1] !== 0) {
|
|
2414
|
+
if (length > bytes.byteLength) {
|
|
2415
|
+
throw new TypeError("invalid indefinite form length");
|
|
2416
|
+
}
|
|
2365
2417
|
length++;
|
|
2366
2418
|
}
|
|
2367
2419
|
const byteLength2 = position + length + 2;
|
|
@@ -2370,6 +2422,14 @@ function parseElement(bytes) {
|
|
|
2370
2422
|
contents: bytes.subarray(position, position + length),
|
|
2371
2423
|
raw: bytes.subarray(0, byteLength2)
|
|
2372
2424
|
};
|
|
2425
|
+
} else {
|
|
2426
|
+
let numberOfDigits = bytes[position] & 127;
|
|
2427
|
+
position++;
|
|
2428
|
+
length = 0;
|
|
2429
|
+
for (let i = 0; i < numberOfDigits; i++) {
|
|
2430
|
+
length = length * 256 + bytes[position];
|
|
2431
|
+
position++;
|
|
2432
|
+
}
|
|
2373
2433
|
}
|
|
2374
2434
|
const byteLength = position + length;
|
|
2375
2435
|
return {
|
|
@@ -2397,7 +2457,12 @@ async function importX509(x509, alg, options) {
|
|
|
2397
2457
|
if (typeof x509 !== "string" || x509.indexOf("-----BEGIN CERTIFICATE-----") !== 0) {
|
|
2398
2458
|
throw new TypeError('"x509" must be X.509 formatted string');
|
|
2399
2459
|
}
|
|
2400
|
-
|
|
2460
|
+
let spki;
|
|
2461
|
+
try {
|
|
2462
|
+
spki = getSPKI(x509);
|
|
2463
|
+
} catch (cause) {
|
|
2464
|
+
throw new TypeError("failed to parse the X.509 certificate", { cause });
|
|
2465
|
+
}
|
|
2401
2466
|
return fromSPKI(spki, alg, options);
|
|
2402
2467
|
}
|
|
2403
2468
|
async function importPKCS8(pkcs8, alg, options) {
|
|
@@ -2453,19 +2518,19 @@ var init_check_key_type = __esm({
|
|
|
2453
2518
|
"../node_modules/jose/dist/browser/lib/check_key_type.js"() {
|
|
2454
2519
|
init_invalid_key_input();
|
|
2455
2520
|
init_is_key_like();
|
|
2456
|
-
symmetricTypeCheck = (key) => {
|
|
2521
|
+
symmetricTypeCheck = (alg, key) => {
|
|
2457
2522
|
if (key instanceof Uint8Array)
|
|
2458
2523
|
return;
|
|
2459
2524
|
if (!is_key_like_default(key)) {
|
|
2460
|
-
throw new TypeError(
|
|
2525
|
+
throw new TypeError(withAlg(alg, key, ...types, "Uint8Array"));
|
|
2461
2526
|
}
|
|
2462
2527
|
if (key.type !== "secret") {
|
|
2463
2528
|
throw new TypeError(`${types.join(" or ")} instances for symmetric algorithms must be of type "secret"`);
|
|
2464
2529
|
}
|
|
2465
2530
|
};
|
|
2466
|
-
asymmetricTypeCheck = (key, usage) => {
|
|
2531
|
+
asymmetricTypeCheck = (alg, key, usage) => {
|
|
2467
2532
|
if (!is_key_like_default(key)) {
|
|
2468
|
-
throw new TypeError(
|
|
2533
|
+
throw new TypeError(withAlg(alg, key, ...types));
|
|
2469
2534
|
}
|
|
2470
2535
|
if (key.type === "secret") {
|
|
2471
2536
|
throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);
|
|
@@ -2486,9 +2551,9 @@ var init_check_key_type = __esm({
|
|
|
2486
2551
|
checkKeyType = (alg, key, usage) => {
|
|
2487
2552
|
const symmetric = alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(alg);
|
|
2488
2553
|
if (symmetric) {
|
|
2489
|
-
symmetricTypeCheck(key);
|
|
2554
|
+
symmetricTypeCheck(alg, key);
|
|
2490
2555
|
} else {
|
|
2491
|
-
asymmetricTypeCheck(key, usage);
|
|
2556
|
+
asymmetricTypeCheck(alg, key, usage);
|
|
2492
2557
|
}
|
|
2493
2558
|
};
|
|
2494
2559
|
check_key_type_default = checkKeyType;
|
|
@@ -2590,7 +2655,7 @@ var init_aesgcmkw = __esm({
|
|
|
2590
2655
|
});
|
|
2591
2656
|
|
|
2592
2657
|
// ../node_modules/jose/dist/browser/lib/decrypt_key_management.js
|
|
2593
|
-
async function decryptKeyManagement(alg, key, encryptedKey, joseHeader) {
|
|
2658
|
+
async function decryptKeyManagement(alg, key, encryptedKey, joseHeader, options) {
|
|
2594
2659
|
check_key_type_default(alg, key, "decrypt");
|
|
2595
2660
|
switch (alg) {
|
|
2596
2661
|
case "dir": {
|
|
@@ -2644,6 +2709,9 @@ async function decryptKeyManagement(alg, key, encryptedKey, joseHeader) {
|
|
|
2644
2709
|
throw new JWEInvalid("JWE Encrypted Key missing");
|
|
2645
2710
|
if (typeof joseHeader.p2c !== "number")
|
|
2646
2711
|
throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) missing or invalid`);
|
|
2712
|
+
const p2cLimit = (options === null || options === void 0 ? void 0 : options.maxPBES2Count) || 1e4;
|
|
2713
|
+
if (joseHeader.p2c > p2cLimit)
|
|
2714
|
+
throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds`);
|
|
2647
2715
|
if (typeof joseHeader.p2s !== "string")
|
|
2648
2716
|
throw new JWEInvalid(`JOSE Header "p2s" (PBES2 Salt) missing or invalid`);
|
|
2649
2717
|
return decrypt2(alg, key, encryptedKey, joseHeader.p2c, decode(joseHeader.p2s));
|
|
@@ -2830,9 +2898,9 @@ async function flattenedDecrypt(jwe, key, options) {
|
|
|
2830
2898
|
}
|
|
2831
2899
|
let cek;
|
|
2832
2900
|
try {
|
|
2833
|
-
cek = await decrypt_key_management_default(alg, key, encryptedKey, joseHeader);
|
|
2901
|
+
cek = await decrypt_key_management_default(alg, key, encryptedKey, joseHeader, options);
|
|
2834
2902
|
} catch (err) {
|
|
2835
|
-
if (err instanceof TypeError) {
|
|
2903
|
+
if (err instanceof TypeError || err instanceof JWEInvalid || err instanceof JOSENotSupported) {
|
|
2836
2904
|
throw err;
|
|
2837
2905
|
}
|
|
2838
2906
|
cek = cek_default(enc);
|
|
@@ -3461,6 +3529,8 @@ function subtleDsa(alg, algorithm) {
|
|
|
3461
3529
|
case (isCloudflareWorkers() && "EdDSA"):
|
|
3462
3530
|
const { namedCurve } = algorithm;
|
|
3463
3531
|
return { name: namedCurve, namedCurve };
|
|
3532
|
+
case "EdDSA":
|
|
3533
|
+
return { name: algorithm.name };
|
|
3464
3534
|
default:
|
|
3465
3535
|
throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
|
|
3466
3536
|
}
|
|
@@ -4752,7 +4822,7 @@ function getModulusLengthOption(options) {
|
|
|
4752
4822
|
return modulusLength;
|
|
4753
4823
|
}
|
|
4754
4824
|
async function generateKeyPair(alg, options) {
|
|
4755
|
-
var _a, _b;
|
|
4825
|
+
var _a, _b, _c;
|
|
4756
4826
|
let algorithm;
|
|
4757
4827
|
let keyUsages;
|
|
4758
4828
|
switch (alg) {
|
|
@@ -4813,17 +4883,44 @@ async function generateKeyPair(alg, options) {
|
|
|
4813
4883
|
throw new JOSENotSupported("Invalid or unsupported crv option provided");
|
|
4814
4884
|
}
|
|
4815
4885
|
break;
|
|
4886
|
+
case "EdDSA":
|
|
4887
|
+
keyUsages = ["sign", "verify"];
|
|
4888
|
+
const crv = (_a = options === null || options === void 0 ? void 0 : options.crv) !== null && _a !== void 0 ? _a : "Ed25519";
|
|
4889
|
+
switch (crv) {
|
|
4890
|
+
case "Ed25519":
|
|
4891
|
+
case "Ed448":
|
|
4892
|
+
algorithm = { name: crv };
|
|
4893
|
+
break;
|
|
4894
|
+
default:
|
|
4895
|
+
throw new JOSENotSupported("Invalid or unsupported crv option provided");
|
|
4896
|
+
}
|
|
4897
|
+
break;
|
|
4816
4898
|
case "ECDH-ES":
|
|
4817
4899
|
case "ECDH-ES+A128KW":
|
|
4818
4900
|
case "ECDH-ES+A192KW":
|
|
4819
|
-
case "ECDH-ES+A256KW":
|
|
4820
|
-
algorithm = { name: "ECDH", namedCurve: (_a = options === null || options === void 0 ? void 0 : options.crv) !== null && _a !== void 0 ? _a : "P-256" };
|
|
4901
|
+
case "ECDH-ES+A256KW": {
|
|
4821
4902
|
keyUsages = ["deriveKey", "deriveBits"];
|
|
4903
|
+
const crv2 = (_b = options === null || options === void 0 ? void 0 : options.crv) !== null && _b !== void 0 ? _b : "P-256";
|
|
4904
|
+
switch (crv2) {
|
|
4905
|
+
case "P-256":
|
|
4906
|
+
case "P-384":
|
|
4907
|
+
case "P-521": {
|
|
4908
|
+
algorithm = { name: "ECDH", namedCurve: crv2 };
|
|
4909
|
+
break;
|
|
4910
|
+
}
|
|
4911
|
+
case "X25519":
|
|
4912
|
+
case "X448":
|
|
4913
|
+
algorithm = { name: crv2 };
|
|
4914
|
+
break;
|
|
4915
|
+
default:
|
|
4916
|
+
throw new JOSENotSupported("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448");
|
|
4917
|
+
}
|
|
4822
4918
|
break;
|
|
4919
|
+
}
|
|
4823
4920
|
default:
|
|
4824
4921
|
throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
|
|
4825
4922
|
}
|
|
4826
|
-
return webcrypto_default.subtle.generateKey(algorithm, (
|
|
4923
|
+
return webcrypto_default.subtle.generateKey(algorithm, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages);
|
|
4827
4924
|
}
|
|
4828
4925
|
var init_generate = __esm({
|
|
4829
4926
|
"../node_modules/jose/dist/browser/runtime/generate.js"() {
|
|
@@ -5218,8 +5315,8 @@ var require_ConfigurationError = __commonJS({
|
|
|
5218
5315
|
"use strict";
|
|
5219
5316
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5220
5317
|
var ConfigurationError = class extends Error {
|
|
5221
|
-
constructor(
|
|
5222
|
-
super(
|
|
5318
|
+
constructor(message2) {
|
|
5319
|
+
super(message2);
|
|
5223
5320
|
}
|
|
5224
5321
|
};
|
|
5225
5322
|
exports.default = ConfigurationError;
|
|
@@ -5263,8 +5360,8 @@ var require_OidcProviderError = __commonJS({
|
|
|
5263
5360
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5264
5361
|
exports.OidcProviderError = void 0;
|
|
5265
5362
|
var OidcProviderError = class extends Error {
|
|
5266
|
-
constructor(
|
|
5267
|
-
super(
|
|
5363
|
+
constructor(message2, error2, errorDescription) {
|
|
5364
|
+
super(message2);
|
|
5268
5365
|
this.error = error2;
|
|
5269
5366
|
this.errorDescription = errorDescription;
|
|
5270
5367
|
}
|
|
@@ -16100,10 +16197,10 @@ var require_JsonLdError = __commonJS({
|
|
|
16100
16197
|
"../node_modules/jsonld/lib/JsonLdError.js"(exports, module2) {
|
|
16101
16198
|
"use strict";
|
|
16102
16199
|
module2.exports = class JsonLdError extends Error {
|
|
16103
|
-
constructor(
|
|
16104
|
-
super(
|
|
16200
|
+
constructor(message2 = "An unspecified JSON-LD error occurred.", name = "jsonld.Error", details = {}) {
|
|
16201
|
+
super(message2);
|
|
16105
16202
|
this.name = name;
|
|
16106
|
-
this.message =
|
|
16203
|
+
this.message = message2;
|
|
16107
16204
|
this.details = details;
|
|
16108
16205
|
}
|
|
16109
16206
|
};
|
|
@@ -22900,9 +22997,9 @@ var require_dom = __commonJS({
|
|
|
22900
22997
|
var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = (ExceptionMessage[13] = "Invalid modification", 13);
|
|
22901
22998
|
var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = (ExceptionMessage[14] = "Invalid namespace", 14);
|
|
22902
22999
|
var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = (ExceptionMessage[15] = "Invalid access", 15);
|
|
22903
|
-
function DOMException(code,
|
|
22904
|
-
if (
|
|
22905
|
-
var error2 =
|
|
23000
|
+
function DOMException(code, message2) {
|
|
23001
|
+
if (message2 instanceof Error) {
|
|
23002
|
+
var error2 = message2;
|
|
22906
23003
|
} else {
|
|
22907
23004
|
error2 = this;
|
|
22908
23005
|
Error.call(this, ExceptionMessage[code]);
|
|
@@ -22911,8 +23008,8 @@ var require_dom = __commonJS({
|
|
|
22911
23008
|
Error.captureStackTrace(this, DOMException);
|
|
22912
23009
|
}
|
|
22913
23010
|
error2.code = code;
|
|
22914
|
-
if (
|
|
22915
|
-
this.message = this.message + ": " +
|
|
23011
|
+
if (message2)
|
|
23012
|
+
this.message = this.message + ": " + message2;
|
|
22916
23013
|
return error2;
|
|
22917
23014
|
}
|
|
22918
23015
|
DOMException.prototype = Error.prototype;
|
|
@@ -24206,8 +24303,8 @@ var require_sax = __commonJS({
|
|
|
24206
24303
|
var S_ATTR_END = 5;
|
|
24207
24304
|
var S_TAG_SPACE = 6;
|
|
24208
24305
|
var S_TAG_CLOSE = 7;
|
|
24209
|
-
function ParseError(
|
|
24210
|
-
this.message =
|
|
24306
|
+
function ParseError(message2, locator) {
|
|
24307
|
+
this.message = message2;
|
|
24211
24308
|
this.locator = locator;
|
|
24212
24309
|
if (Error.captureStackTrace)
|
|
24213
24310
|
Error.captureStackTrace(this, ParseError);
|
|
@@ -25075,6 +25172,63 @@ var BrowserSession = class {
|
|
|
25075
25172
|
}
|
|
25076
25173
|
};
|
|
25077
25174
|
|
|
25175
|
+
// src/files/BinaryFile.ts
|
|
25176
|
+
var BinaryFile = class {
|
|
25177
|
+
constructor(url, data) {
|
|
25178
|
+
this.url = url;
|
|
25179
|
+
this.data = data;
|
|
25180
|
+
}
|
|
25181
|
+
blob() {
|
|
25182
|
+
return this.data;
|
|
25183
|
+
}
|
|
25184
|
+
};
|
|
25185
|
+
|
|
25186
|
+
// src/files/BrokenFile.ts
|
|
25187
|
+
var BrokenFile = class {
|
|
25188
|
+
constructor(url, status) {
|
|
25189
|
+
this.url = url;
|
|
25190
|
+
this.status = status;
|
|
25191
|
+
}
|
|
25192
|
+
toString() {
|
|
25193
|
+
return `${this.status.toString()} - ${this.url}`;
|
|
25194
|
+
}
|
|
25195
|
+
blob() {
|
|
25196
|
+
return null;
|
|
25197
|
+
}
|
|
25198
|
+
};
|
|
25199
|
+
|
|
25200
|
+
// src/files/HttpStatus.ts
|
|
25201
|
+
var HttpStatus = class {
|
|
25202
|
+
constructor(code, text) {
|
|
25203
|
+
this.code = code;
|
|
25204
|
+
this.text = text;
|
|
25205
|
+
}
|
|
25206
|
+
toString() {
|
|
25207
|
+
return this.text ? `${this.code} - ${this.text}` : this.code.toString();
|
|
25208
|
+
}
|
|
25209
|
+
};
|
|
25210
|
+
|
|
25211
|
+
// src/files/FileFetcher.ts
|
|
25212
|
+
var FileFetcher = class {
|
|
25213
|
+
constructor(session) {
|
|
25214
|
+
this.session = session;
|
|
25215
|
+
}
|
|
25216
|
+
fetchFile(url) {
|
|
25217
|
+
return __async(this, null, function* () {
|
|
25218
|
+
const response = yield this.session.authenticatedFetch(url);
|
|
25219
|
+
if (response.ok) {
|
|
25220
|
+
const blob = yield response.blob();
|
|
25221
|
+
return new BinaryFile(url, blob);
|
|
25222
|
+
} else {
|
|
25223
|
+
return new BrokenFile(
|
|
25224
|
+
url,
|
|
25225
|
+
new HttpStatus(response.status, response.statusText)
|
|
25226
|
+
);
|
|
25227
|
+
}
|
|
25228
|
+
});
|
|
25229
|
+
}
|
|
25230
|
+
};
|
|
25231
|
+
|
|
25078
25232
|
// ../node_modules/@babel/runtime/helpers/esm/createClass.js
|
|
25079
25233
|
function _defineProperties(target, props) {
|
|
25080
25234
|
for (var i = 0; i < props.length; i++) {
|
|
@@ -25490,8 +25644,8 @@ var NamedNode = /* @__PURE__ */ function(_Node) {
|
|
|
25490
25644
|
throw new Error('NamedNode IRI "' + iri + '" must be absolute.');
|
|
25491
25645
|
}
|
|
25492
25646
|
if (_this.value.includes(" ")) {
|
|
25493
|
-
var
|
|
25494
|
-
throw new Error(
|
|
25647
|
+
var message2 = 'Error: NamedNode IRI "' + iri + '" must not contain unencoded spaces.';
|
|
25648
|
+
throw new Error(message2);
|
|
25495
25649
|
}
|
|
25496
25650
|
return _this;
|
|
25497
25651
|
}
|
|
@@ -28975,8 +29129,8 @@ var N3Parser = class {
|
|
|
28975
29129
|
_emit(subject, predicate, object, graph3) {
|
|
28976
29130
|
this._callback(null, this._quad(subject, predicate, object, graph3 || this.DEFAULTGRAPH));
|
|
28977
29131
|
}
|
|
28978
|
-
_error(
|
|
28979
|
-
const err = new Error(`${
|
|
29132
|
+
_error(message2, token) {
|
|
29133
|
+
const err = new Error(`${message2} on line ${token.line}.`);
|
|
28980
29134
|
err.context = {
|
|
28981
29135
|
token,
|
|
28982
29136
|
line: token.line,
|
|
@@ -36747,13 +36901,13 @@ var Fetcher = /* @__PURE__ */ function() {
|
|
|
36747
36901
|
}
|
|
36748
36902
|
}
|
|
36749
36903
|
}, function(err) {
|
|
36750
|
-
var
|
|
36751
|
-
|
|
36752
|
-
console.log(
|
|
36904
|
+
var message2 = err.message || err.statusText;
|
|
36905
|
+
message2 = "Failed to load <" + uri + "> " + message2;
|
|
36906
|
+
console.log(message2);
|
|
36753
36907
|
if (err.response && err.response.status) {
|
|
36754
|
-
|
|
36908
|
+
message2 += " status: " + err.response.status;
|
|
36755
36909
|
}
|
|
36756
|
-
userCallback(false,
|
|
36910
|
+
userCallback(false, message2, err.response);
|
|
36757
36911
|
});
|
|
36758
36912
|
}
|
|
36759
36913
|
}, {
|
|
@@ -37247,16 +37401,16 @@ var Fetcher = /* @__PURE__ */ function() {
|
|
|
37247
37401
|
return this.redirectToProxy(proxyUri, options);
|
|
37248
37402
|
}
|
|
37249
37403
|
}
|
|
37250
|
-
var
|
|
37404
|
+
var message2;
|
|
37251
37405
|
if (response instanceof Error) {
|
|
37252
|
-
|
|
37406
|
+
message2 = "Fetch error: " + response.message;
|
|
37253
37407
|
} else {
|
|
37254
|
-
|
|
37408
|
+
message2 = response.statusText;
|
|
37255
37409
|
if (response.responseText) {
|
|
37256
|
-
|
|
37410
|
+
message2 += " ".concat(response.responseText);
|
|
37257
37411
|
}
|
|
37258
37412
|
}
|
|
37259
|
-
return this.failFetch(options,
|
|
37413
|
+
return this.failFetch(options, message2, response.status || 998, response);
|
|
37260
37414
|
}
|
|
37261
37415
|
}, {
|
|
37262
37416
|
key: "addType",
|
|
@@ -37715,6 +37869,7 @@ var PodOS = class {
|
|
|
37715
37869
|
constructor() {
|
|
37716
37870
|
this.session = new BrowserSession();
|
|
37717
37871
|
this.store = new Store(this.session);
|
|
37872
|
+
this.fileFetcher = new FileFetcher(this.session);
|
|
37718
37873
|
}
|
|
37719
37874
|
handleIncomingRedirect() {
|
|
37720
37875
|
this.session.handleIncomingRedirect();
|
|
@@ -37722,6 +37877,9 @@ var PodOS = class {
|
|
|
37722
37877
|
fetch(uri) {
|
|
37723
37878
|
return this.store.fetch(uri);
|
|
37724
37879
|
}
|
|
37880
|
+
fetchFile(url) {
|
|
37881
|
+
return this.fileFetcher.fetchFile(url);
|
|
37882
|
+
}
|
|
37725
37883
|
trackSession(callback) {
|
|
37726
37884
|
return this.session.trackSession(callback);
|
|
37727
37885
|
}
|
|
@@ -37733,7 +37891,10 @@ var PodOS = class {
|
|
|
37733
37891
|
}
|
|
37734
37892
|
};
|
|
37735
37893
|
export {
|
|
37894
|
+
BinaryFile,
|
|
37895
|
+
BrokenFile,
|
|
37736
37896
|
BrowserSession,
|
|
37897
|
+
HttpStatus,
|
|
37737
37898
|
PodOS
|
|
37738
37899
|
};
|
|
37739
37900
|
/*!
|