@pod-os/elements 0.1.2-da0e5dd.0 → 0.2.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.
@@ -19049,26 +19049,26 @@ var require_InruptError = __commonJS({
19049
19049
  }
19050
19050
  static lookupErrorIri(iri, messageParams) {
19051
19051
  if (InruptError.determineIfVocabTerm(iri)) {
19052
- const message = messageParams === void 0 ? iri.message : iri.messageParams(...messageParams);
19053
- return message === void 0 ? `Looked up error message IRI [${iri.value}], but found no message value.` : message;
19052
+ const message2 = messageParams === void 0 ? iri.message : iri.messageParams(...messageParams);
19053
+ return message2 === void 0 ? `Looked up error message IRI [${iri.value}], but found no message value.` : message2;
19054
19054
  }
19055
19055
  return `Error message looked up at: [${iri.value}]${messageParams === void 0 ? "" : `, with params [${messageParams.toString()}]`}`;
19056
19056
  }
19057
- static appendHttpResponseDetails(message, response, append) {
19057
+ static appendHttpResponseDetails(message2, response, append) {
19058
19058
  if (append && typeof response !== "undefined") {
19059
- return `${message} HTTP details: status code [${response.status}], status text [${response.statusText}].`;
19059
+ return `${message2} HTTP details: status code [${response.status}], status text [${response.statusText}].`;
19060
19060
  }
19061
- return message;
19061
+ return message2;
19062
19062
  }
19063
- static appendErrorIri(message, iri, append) {
19064
- return append ? `${message} Error IRI: [${iri.value}].` : message;
19063
+ static appendErrorIri(message2, iri, append) {
19064
+ return append ? `${message2} Error IRI: [${iri.value}].` : message2;
19065
19065
  }
19066
- static substituteParams(message, params) {
19067
- let fullMessage = message;
19066
+ static substituteParams(message2, params) {
19067
+ let fullMessage = message2;
19068
19068
  if (params !== void 0) {
19069
- const paramsRequired = message.split("{{").length - 1;
19069
+ const paramsRequired = message2.split("{{").length - 1;
19070
19070
  if (paramsRequired !== params.length) {
19071
- throw new Error(`Setting parameters on message [${message}], but it requires [${paramsRequired}] params and we received [${params.length}].`);
19071
+ throw new Error(`Setting parameters on message [${message2}], but it requires [${paramsRequired}] params and we received [${params.length}].`);
19072
19072
  }
19073
19073
  for (let i = 0; i < params.length; i += 1) {
19074
19074
  const marker = `{{${i}}}`;
@@ -19498,10 +19498,10 @@ var require_browser_ponyfill = __commonJS({
19498
19498
  try {
19499
19499
  new exports2.DOMException();
19500
19500
  } catch (err) {
19501
- exports2.DOMException = function(message, name) {
19502
- this.message = message;
19501
+ exports2.DOMException = function(message2, name) {
19502
+ this.message = message2;
19503
19503
  this.name = name;
19504
- var error2 = Error(message);
19504
+ var error2 = Error(message2);
19505
19505
  this.stack = error2.stack;
19506
19506
  };
19507
19507
  exports2.DOMException.prototype = Object.create(Error.prototype);
@@ -19733,9 +19733,9 @@ var JOSEError, JWTClaimValidationFailed, JWTExpired, JOSEAlgNotAllowed, JOSENotS
19733
19733
  var init_errors = __esm({
19734
19734
  "../node_modules/jose/dist/browser/util/errors.js"() {
19735
19735
  JOSEError = class extends Error {
19736
- constructor(message) {
19736
+ constructor(message2) {
19737
19737
  var _a;
19738
- super(message);
19738
+ super(message2);
19739
19739
  this.code = "ERR_JOSE_GENERIC";
19740
19740
  this.name = this.constructor.name;
19741
19741
  (_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, this, this.constructor);
@@ -19745,8 +19745,8 @@ var init_errors = __esm({
19745
19745
  }
19746
19746
  };
19747
19747
  JWTClaimValidationFailed = class extends JOSEError {
19748
- constructor(message, claim = "unspecified", reason = "unspecified") {
19749
- super(message);
19748
+ constructor(message2, claim = "unspecified", reason = "unspecified") {
19749
+ super(message2);
19750
19750
  this.code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
19751
19751
  this.claim = claim;
19752
19752
  this.reason = reason;
@@ -19756,8 +19756,8 @@ var init_errors = __esm({
19756
19756
  }
19757
19757
  };
19758
19758
  JWTExpired = class extends JOSEError {
19759
- constructor(message, claim = "unspecified", reason = "unspecified") {
19760
- super(message);
19759
+ constructor(message2, claim = "unspecified", reason = "unspecified") {
19760
+ super(message2);
19761
19761
  this.code = "ERR_JWT_EXPIRED";
19762
19762
  this.claim = claim;
19763
19763
  this.reason = reason;
@@ -19939,8 +19939,9 @@ var init_check_cek_length = __esm({
19939
19939
  "../node_modules/jose/dist/browser/runtime/check_cek_length.js"() {
19940
19940
  init_errors();
19941
19941
  checkCekLength = (cek, expected) => {
19942
- if (cek.length << 3 !== expected) {
19943
- throw new JWEInvalid("Invalid Content Encryption Key length");
19942
+ const actual = cek.byteLength << 3;
19943
+ if (actual !== expected) {
19944
+ throw new JWEInvalid(`Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits`);
19944
19945
  }
19945
19946
  };
19946
19947
  check_cek_length_default = checkCekLength;
@@ -19975,7 +19976,7 @@ var init_timing_safe_equal = __esm({
19975
19976
 
19976
19977
  // ../node_modules/jose/dist/browser/runtime/env.js
19977
19978
  function isCloudflareWorkers() {
19978
- return typeof WebSocketPair === "function";
19979
+ return typeof WebSocketPair !== "undefined" || typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime !== "undefined" && EdgeRuntime === "vercel";
19979
19980
  }
19980
19981
  var init_env = __esm({
19981
19982
  "../node_modules/jose/dist/browser/runtime/env.js"() {
@@ -20058,6 +20059,12 @@ function checkSigCryptoKey(key, alg, ...usages) {
20058
20059
  throw unusable("NODE-ED25519");
20059
20060
  break;
20060
20061
  }
20062
+ case "EdDSA": {
20063
+ if (key.algorithm.name !== "Ed25519" && key.algorithm.name !== "Ed448") {
20064
+ throw unusable("Ed25519 or Ed448");
20065
+ }
20066
+ break;
20067
+ }
20061
20068
  case "ES256":
20062
20069
  case "ES384":
20063
20070
  case "ES512": {
@@ -20098,10 +20105,17 @@ function checkEncCryptoKey(key, alg, ...usages) {
20098
20105
  throw unusable(expected, "algorithm.length");
20099
20106
  break;
20100
20107
  }
20101
- case "ECDH":
20102
- if (!isAlgorithm(key.algorithm, "ECDH"))
20103
- throw unusable("ECDH");
20108
+ case "ECDH": {
20109
+ switch (key.algorithm.name) {
20110
+ case "ECDH":
20111
+ case "X25519":
20112
+ case "X448":
20113
+ break;
20114
+ default:
20115
+ throw unusable("ECDH, X25519, or X448");
20116
+ }
20104
20117
  break;
20118
+ }
20105
20119
  case "PBES2-HS256+A128KW":
20106
20120
  case "PBES2-HS384+A192KW":
20107
20121
  case "PBES2-HS512+A256KW":
@@ -20132,29 +20146,34 @@ var init_crypto_key = __esm({
20132
20146
  });
20133
20147
 
20134
20148
  // ../node_modules/jose/dist/browser/lib/invalid_key_input.js
20149
+ function message(msg2, actual, ...types2) {
20150
+ if (types2.length > 2) {
20151
+ const last = types2.pop();
20152
+ msg2 += `one of type ${types2.join(", ")}, or ${last}.`;
20153
+ } else if (types2.length === 2) {
20154
+ msg2 += `one of type ${types2[0]} or ${types2[1]}.`;
20155
+ } else {
20156
+ msg2 += `of type ${types2[0]}.`;
20157
+ }
20158
+ if (actual == null) {
20159
+ msg2 += ` Received ${actual}`;
20160
+ } else if (typeof actual === "function" && actual.name) {
20161
+ msg2 += ` Received function ${actual.name}`;
20162
+ } else if (typeof actual === "object" && actual != null) {
20163
+ if (actual.constructor && actual.constructor.name) {
20164
+ msg2 += ` Received an instance of ${actual.constructor.name}`;
20165
+ }
20166
+ }
20167
+ return msg2;
20168
+ }
20169
+ function withAlg(alg, actual, ...types2) {
20170
+ return message(`Key for the ${alg} algorithm must be `, actual, ...types2);
20171
+ }
20135
20172
  var invalid_key_input_default;
20136
20173
  var init_invalid_key_input = __esm({
20137
20174
  "../node_modules/jose/dist/browser/lib/invalid_key_input.js"() {
20138
20175
  invalid_key_input_default = (actual, ...types2) => {
20139
- let msg2 = "Key must be ";
20140
- if (types2.length > 2) {
20141
- const last = types2.pop();
20142
- msg2 += `one of type ${types2.join(", ")}, or ${last}.`;
20143
- } else if (types2.length === 2) {
20144
- msg2 += `one of type ${types2[0]} or ${types2[1]}.`;
20145
- } else {
20146
- msg2 += `of type ${types2[0]}.`;
20147
- }
20148
- if (actual == null) {
20149
- msg2 += ` Received ${actual}`;
20150
- } else if (typeof actual === "function" && actual.name) {
20151
- msg2 += ` Received function ${actual.name}`;
20152
- } else if (typeof actual === "object" && actual != null) {
20153
- if (actual.constructor && actual.constructor.name) {
20154
- msg2 += ` Received an instance of ${actual.constructor.name}`;
20155
- }
20156
- }
20157
- return msg2;
20176
+ return message("Key must be ", actual, ...types2);
20158
20177
  };
20159
20178
  }
20160
20179
  });
@@ -20387,10 +20406,18 @@ async function deriveKey(publicKey, privateKey, algorithm, keyLength, apu = new
20387
20406
  }
20388
20407
  checkEncCryptoKey(privateKey, "ECDH", "deriveBits");
20389
20408
  const value = concat(lengthAndInput(encoder.encode(algorithm)), lengthAndInput(apu), lengthAndInput(apv), uint32be(keyLength));
20409
+ let length;
20410
+ if (publicKey.algorithm.name === "X25519") {
20411
+ length = 256;
20412
+ } else if (publicKey.algorithm.name === "X448") {
20413
+ length = 448;
20414
+ } else {
20415
+ length = Math.ceil(parseInt(publicKey.algorithm.namedCurve.substr(-3), 10) / 8) << 3;
20416
+ }
20390
20417
  const sharedSecret = new Uint8Array(await webcrypto_default.subtle.deriveBits({
20391
- name: "ECDH",
20418
+ name: publicKey.algorithm.name,
20392
20419
  public: publicKey
20393
- }, privateKey, Math.ceil(parseInt(privateKey.algorithm.namedCurve.slice(-3), 10) / 8) << 3));
20420
+ }, privateKey, length));
20394
20421
  return concatKdf(sharedSecret, keyLength, value);
20395
20422
  }
20396
20423
  async function generateEpk(key) {
@@ -20403,7 +20430,7 @@ function ecdhAllowed(key) {
20403
20430
  if (!isCryptoKey(key)) {
20404
20431
  throw new TypeError(invalid_key_input_default(key, ...types));
20405
20432
  }
20406
- return ["P-256", "P-384", "P-521"].includes(key.algorithm.namedCurve);
20433
+ return ["P-256", "P-384", "P-521"].includes(key.algorithm.namedCurve) || key.algorithm.name === "X25519" || key.algorithm.name === "X448";
20407
20434
  }
20408
20435
  var init_ecdhes = __esm({
20409
20436
  "../node_modules/jose/dist/browser/runtime/ecdhes.js"() {
@@ -20652,8 +20679,14 @@ var init_asn1 = __esm({
20652
20679
  return "P-384";
20653
20680
  case findOid(keyData, [43, 129, 4, 0, 35]):
20654
20681
  return "P-521";
20655
- case (isCloudflareWorkers() && findOid(keyData, [43, 101, 112])):
20682
+ case findOid(keyData, [43, 101, 110]):
20683
+ return "X25519";
20684
+ case findOid(keyData, [43, 101, 111]):
20685
+ return "X448";
20686
+ case findOid(keyData, [43, 101, 112]):
20656
20687
  return "Ed25519";
20688
+ case findOid(keyData, [43, 101, 113]):
20689
+ return "Ed448";
20657
20690
  default:
20658
20691
  throw new JOSENotSupported("Invalid or unsupported EC Key Curve or OKP Key Sub Type");
20659
20692
  }
@@ -20702,15 +20735,22 @@ var init_asn1 = __esm({
20702
20735
  case "ECDH-ES":
20703
20736
  case "ECDH-ES+A128KW":
20704
20737
  case "ECDH-ES+A192KW":
20705
- case "ECDH-ES+A256KW":
20706
- algorithm = { name: "ECDH", namedCurve: getNamedCurve2(keyData) };
20738
+ case "ECDH-ES+A256KW": {
20739
+ const namedCurve = getNamedCurve2(keyData);
20740
+ algorithm = namedCurve.startsWith("P-") ? { name: "ECDH", namedCurve } : { name: namedCurve };
20707
20741
  keyUsages = isPublic ? [] : ["deriveBits"];
20708
20742
  break;
20709
- case (isCloudflareWorkers() && "EdDSA"):
20743
+ }
20744
+ case (isCloudflareWorkers() && "EdDSA"): {
20710
20745
  const namedCurve = getNamedCurve2(keyData).toUpperCase();
20711
20746
  algorithm = { name: `NODE-${namedCurve}`, namedCurve: `NODE-${namedCurve}` };
20712
20747
  keyUsages = isPublic ? ["verify"] : ["sign"];
20713
20748
  break;
20749
+ }
20750
+ case "EdDSA":
20751
+ algorithm = { name: getNamedCurve2(keyData) };
20752
+ keyUsages = isPublic ? ["verify"] : ["sign"];
20753
+ break;
20714
20754
  default:
20715
20755
  throw new JOSENotSupported('Invalid or unsupported "alg" (Algorithm) value');
20716
20756
  }
@@ -20833,9 +20873,27 @@ function subtleMapping(jwk) {
20833
20873
  keyUsages = jwk.d ? ["sign"] : ["verify"];
20834
20874
  break;
20835
20875
  default:
20836
- throw new JOSENotSupported('Invalid or unsupported JWK "crv" (Subtype of Key Pair) Parameter value');
20876
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
20877
+ }
20878
+ break;
20879
+ case "OKP": {
20880
+ switch (jwk.alg) {
20881
+ case "EdDSA":
20882
+ algorithm = { name: jwk.crv };
20883
+ keyUsages = jwk.d ? ["sign"] : ["verify"];
20884
+ break;
20885
+ case "ECDH-ES":
20886
+ case "ECDH-ES+A128KW":
20887
+ case "ECDH-ES+A192KW":
20888
+ case "ECDH-ES+A256KW":
20889
+ algorithm = { name: jwk.crv };
20890
+ keyUsages = jwk.d ? ["deriveBits"] : [];
20891
+ break;
20892
+ default:
20893
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
20837
20894
  }
20838
20895
  break;
20896
+ }
20839
20897
  default:
20840
20898
  throw new JOSENotSupported('Invalid or unsupported JWK "kty" (Key Type) Parameter value');
20841
20899
  }
@@ -20895,18 +20953,12 @@ function parseElement(bytes) {
20895
20953
  if (bytes[position] < 128) {
20896
20954
  length = bytes[position];
20897
20955
  position++;
20898
- } else {
20899
- let numberOfDigits = bytes[position] & 127;
20900
- position++;
20901
- length = 0;
20902
- for (let i = 0; i < numberOfDigits; i++) {
20903
- length = length * 256 + bytes[position];
20904
- position++;
20905
- }
20906
- }
20907
- if (length === 128) {
20956
+ } else if (length === 128) {
20908
20957
  length = 0;
20909
20958
  while (bytes[position + length] !== 0 || bytes[position + length + 1] !== 0) {
20959
+ if (length > bytes.byteLength) {
20960
+ throw new TypeError("invalid indefinite form length");
20961
+ }
20910
20962
  length++;
20911
20963
  }
20912
20964
  const byteLength2 = position + length + 2;
@@ -20915,6 +20967,14 @@ function parseElement(bytes) {
20915
20967
  contents: bytes.subarray(position, position + length),
20916
20968
  raw: bytes.subarray(0, byteLength2)
20917
20969
  };
20970
+ } else {
20971
+ let numberOfDigits = bytes[position] & 127;
20972
+ position++;
20973
+ length = 0;
20974
+ for (let i = 0; i < numberOfDigits; i++) {
20975
+ length = length * 256 + bytes[position];
20976
+ position++;
20977
+ }
20918
20978
  }
20919
20979
  const byteLength = position + length;
20920
20980
  return {
@@ -20942,7 +21002,12 @@ async function importX509(x509, alg, options) {
20942
21002
  if (typeof x509 !== "string" || x509.indexOf("-----BEGIN CERTIFICATE-----") !== 0) {
20943
21003
  throw new TypeError('"x509" must be X.509 formatted string');
20944
21004
  }
20945
- const spki = getSPKI(x509);
21005
+ let spki;
21006
+ try {
21007
+ spki = getSPKI(x509);
21008
+ } catch (cause) {
21009
+ throw new TypeError("failed to parse the X.509 certificate", { cause });
21010
+ }
20946
21011
  return fromSPKI(spki, alg, options);
20947
21012
  }
20948
21013
  async function importPKCS8(pkcs8, alg, options) {
@@ -20998,19 +21063,19 @@ var init_check_key_type = __esm({
20998
21063
  "../node_modules/jose/dist/browser/lib/check_key_type.js"() {
20999
21064
  init_invalid_key_input();
21000
21065
  init_is_key_like();
21001
- symmetricTypeCheck = (key) => {
21066
+ symmetricTypeCheck = (alg, key) => {
21002
21067
  if (key instanceof Uint8Array)
21003
21068
  return;
21004
21069
  if (!is_key_like_default(key)) {
21005
- throw new TypeError(invalid_key_input_default(key, ...types, "Uint8Array"));
21070
+ throw new TypeError(withAlg(alg, key, ...types, "Uint8Array"));
21006
21071
  }
21007
21072
  if (key.type !== "secret") {
21008
21073
  throw new TypeError(`${types.join(" or ")} instances for symmetric algorithms must be of type "secret"`);
21009
21074
  }
21010
21075
  };
21011
- asymmetricTypeCheck = (key, usage) => {
21076
+ asymmetricTypeCheck = (alg, key, usage) => {
21012
21077
  if (!is_key_like_default(key)) {
21013
- throw new TypeError(invalid_key_input_default(key, ...types));
21078
+ throw new TypeError(withAlg(alg, key, ...types));
21014
21079
  }
21015
21080
  if (key.type === "secret") {
21016
21081
  throw new TypeError(`${types.join(" or ")} instances for asymmetric algorithms must not be of type "secret"`);
@@ -21031,9 +21096,9 @@ var init_check_key_type = __esm({
21031
21096
  checkKeyType = (alg, key, usage) => {
21032
21097
  const symmetric = alg.startsWith("HS") || alg === "dir" || alg.startsWith("PBES2") || /^A\d{3}(?:GCM)?KW$/.test(alg);
21033
21098
  if (symmetric) {
21034
- symmetricTypeCheck(key);
21099
+ symmetricTypeCheck(alg, key);
21035
21100
  } else {
21036
- asymmetricTypeCheck(key, usage);
21101
+ asymmetricTypeCheck(alg, key, usage);
21037
21102
  }
21038
21103
  };
21039
21104
  check_key_type_default = checkKeyType;
@@ -21135,7 +21200,7 @@ var init_aesgcmkw = __esm({
21135
21200
  });
21136
21201
 
21137
21202
  // ../node_modules/jose/dist/browser/lib/decrypt_key_management.js
21138
- async function decryptKeyManagement(alg, key, encryptedKey, joseHeader) {
21203
+ async function decryptKeyManagement(alg, key, encryptedKey, joseHeader, options) {
21139
21204
  check_key_type_default(alg, key, "decrypt");
21140
21205
  switch (alg) {
21141
21206
  case "dir": {
@@ -21189,6 +21254,9 @@ async function decryptKeyManagement(alg, key, encryptedKey, joseHeader) {
21189
21254
  throw new JWEInvalid("JWE Encrypted Key missing");
21190
21255
  if (typeof joseHeader.p2c !== "number")
21191
21256
  throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) missing or invalid`);
21257
+ const p2cLimit = (options === null || options === void 0 ? void 0 : options.maxPBES2Count) || 1e4;
21258
+ if (joseHeader.p2c > p2cLimit)
21259
+ throw new JWEInvalid(`JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds`);
21192
21260
  if (typeof joseHeader.p2s !== "string")
21193
21261
  throw new JWEInvalid(`JOSE Header "p2s" (PBES2 Salt) missing or invalid`);
21194
21262
  return decrypt2(alg, key, encryptedKey, joseHeader.p2c, decode(joseHeader.p2s));
@@ -21375,9 +21443,9 @@ async function flattenedDecrypt(jwe, key, options) {
21375
21443
  }
21376
21444
  let cek;
21377
21445
  try {
21378
- cek = await decrypt_key_management_default(alg, key, encryptedKey, joseHeader);
21446
+ cek = await decrypt_key_management_default(alg, key, encryptedKey, joseHeader, options);
21379
21447
  } catch (err) {
21380
- if (err instanceof TypeError) {
21448
+ if (err instanceof TypeError || err instanceof JWEInvalid || err instanceof JOSENotSupported) {
21381
21449
  throw err;
21382
21450
  }
21383
21451
  cek = cek_default(enc);
@@ -22005,6 +22073,8 @@ function subtleDsa(alg, algorithm) {
22005
22073
  case (isCloudflareWorkers() && "EdDSA"):
22006
22074
  const { namedCurve } = algorithm;
22007
22075
  return { name: namedCurve, namedCurve };
22076
+ case "EdDSA":
22077
+ return { name: algorithm.name };
22008
22078
  default:
22009
22079
  throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
22010
22080
  }
@@ -23295,7 +23365,7 @@ function getModulusLengthOption(options) {
23295
23365
  return modulusLength;
23296
23366
  }
23297
23367
  async function generateKeyPair(alg, options) {
23298
- var _a, _b;
23368
+ var _a, _b, _c;
23299
23369
  let algorithm;
23300
23370
  let keyUsages;
23301
23371
  switch (alg) {
@@ -23356,17 +23426,44 @@ async function generateKeyPair(alg, options) {
23356
23426
  throw new JOSENotSupported("Invalid or unsupported crv option provided");
23357
23427
  }
23358
23428
  break;
23429
+ case "EdDSA":
23430
+ keyUsages = ["sign", "verify"];
23431
+ const crv = (_a = options === null || options === void 0 ? void 0 : options.crv) !== null && _a !== void 0 ? _a : "Ed25519";
23432
+ switch (crv) {
23433
+ case "Ed25519":
23434
+ case "Ed448":
23435
+ algorithm = { name: crv };
23436
+ break;
23437
+ default:
23438
+ throw new JOSENotSupported("Invalid or unsupported crv option provided");
23439
+ }
23440
+ break;
23359
23441
  case "ECDH-ES":
23360
23442
  case "ECDH-ES+A128KW":
23361
23443
  case "ECDH-ES+A192KW":
23362
- case "ECDH-ES+A256KW":
23363
- algorithm = { name: "ECDH", namedCurve: (_a = options === null || options === void 0 ? void 0 : options.crv) !== null && _a !== void 0 ? _a : "P-256" };
23444
+ case "ECDH-ES+A256KW": {
23364
23445
  keyUsages = ["deriveKey", "deriveBits"];
23446
+ const crv2 = (_b = options === null || options === void 0 ? void 0 : options.crv) !== null && _b !== void 0 ? _b : "P-256";
23447
+ switch (crv2) {
23448
+ case "P-256":
23449
+ case "P-384":
23450
+ case "P-521": {
23451
+ algorithm = { name: "ECDH", namedCurve: crv2 };
23452
+ break;
23453
+ }
23454
+ case "X25519":
23455
+ case "X448":
23456
+ algorithm = { name: crv2 };
23457
+ break;
23458
+ default:
23459
+ throw new JOSENotSupported("Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448");
23460
+ }
23365
23461
  break;
23462
+ }
23366
23463
  default:
23367
23464
  throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
23368
23465
  }
23369
- return webcrypto_default.subtle.generateKey(algorithm, (_b = options === null || options === void 0 ? void 0 : options.extractable) !== null && _b !== void 0 ? _b : false, keyUsages);
23466
+ return webcrypto_default.subtle.generateKey(algorithm, (_c = options === null || options === void 0 ? void 0 : options.extractable) !== null && _c !== void 0 ? _c : false, keyUsages);
23370
23467
  }
23371
23468
  var init_generate = __esm({
23372
23469
  "../node_modules/jose/dist/browser/runtime/generate.js"() {
@@ -23754,8 +23851,8 @@ var require_ConfigurationError = __commonJS({
23754
23851
  "../node_modules/@inrupt/solid-client-authn-core/dist/errors/ConfigurationError.js"(exports) {
23755
23852
  Object.defineProperty(exports, "__esModule", { value: true });
23756
23853
  var ConfigurationError = class extends Error {
23757
- constructor(message) {
23758
- super(message);
23854
+ constructor(message2) {
23855
+ super(message2);
23759
23856
  }
23760
23857
  };
23761
23858
  exports.default = ConfigurationError;
@@ -23796,8 +23893,8 @@ var require_OidcProviderError = __commonJS({
23796
23893
  Object.defineProperty(exports, "__esModule", { value: true });
23797
23894
  exports.OidcProviderError = void 0;
23798
23895
  var OidcProviderError = class extends Error {
23799
- constructor(message, error2, errorDescription) {
23800
- super(message);
23896
+ constructor(message2, error2, errorDescription) {
23897
+ super(message2);
23801
23898
  this.error = error2;
23802
23899
  this.errorDescription = errorDescription;
23803
23900
  }
@@ -34526,10 +34623,10 @@ var require_graphTypes = __commonJS({
34526
34623
  var require_JsonLdError = __commonJS({
34527
34624
  "../node_modules/jsonld/lib/JsonLdError.js"(exports, module2) {
34528
34625
  module2.exports = class JsonLdError extends Error {
34529
- constructor(message = "An unspecified JSON-LD error occurred.", name = "jsonld.Error", details = {}) {
34530
- super(message);
34626
+ constructor(message2 = "An unspecified JSON-LD error occurred.", name = "jsonld.Error", details = {}) {
34627
+ super(message2);
34531
34628
  this.name = name;
34532
- this.message = message;
34629
+ this.message = message2;
34533
34630
  this.details = details;
34534
34631
  }
34535
34632
  };
@@ -41296,9 +41393,9 @@ var require_dom = __commonJS({
41296
41393
  ExceptionCode.INVALID_MODIFICATION_ERR = (ExceptionMessage[13] = "Invalid modification", 13);
41297
41394
  ExceptionCode.NAMESPACE_ERR = (ExceptionMessage[14] = "Invalid namespace", 14);
41298
41395
  ExceptionCode.INVALID_ACCESS_ERR = (ExceptionMessage[15] = "Invalid access", 15);
41299
- function DOMException(code, message) {
41300
- if (message instanceof Error) {
41301
- var error2 = message;
41396
+ function DOMException(code, message2) {
41397
+ if (message2 instanceof Error) {
41398
+ var error2 = message2;
41302
41399
  } else {
41303
41400
  error2 = this;
41304
41401
  Error.call(this, ExceptionMessage[code]);
@@ -41307,8 +41404,8 @@ var require_dom = __commonJS({
41307
41404
  Error.captureStackTrace(this, DOMException);
41308
41405
  }
41309
41406
  error2.code = code;
41310
- if (message)
41311
- this.message = this.message + ": " + message;
41407
+ if (message2)
41408
+ this.message = this.message + ": " + message2;
41312
41409
  return error2;
41313
41410
  }
41314
41411
  DOMException.prototype = Error.prototype;
@@ -42599,8 +42696,8 @@ var require_sax = __commonJS({
42599
42696
  var S_ATTR_END = 5;
42600
42697
  var S_TAG_SPACE = 6;
42601
42698
  var S_TAG_CLOSE = 7;
42602
- function ParseError(message, locator) {
42603
- this.message = message;
42699
+ function ParseError(message2, locator) {
42700
+ this.message = message2;
42604
42701
  this.locator = locator;
42605
42702
  if (Error.captureStackTrace)
42606
42703
  Error.captureStackTrace(this, ParseError);
@@ -43464,19 +43561,59 @@ var BrowserSession = class {
43464
43561
  }
43465
43562
  };
43466
43563
 
43564
+ // src/files/BinaryFile.ts
43565
+ var BinaryFile = class {
43566
+ constructor(url, data) {
43567
+ this.url = url;
43568
+ this.data = data;
43569
+ }
43570
+ blob() {
43571
+ return this.data;
43572
+ }
43573
+ };
43574
+
43575
+ // src/files/BrokenFile.ts
43576
+ var BrokenFile = class {
43577
+ constructor(url, status) {
43578
+ this.url = url;
43579
+ this.status = status;
43580
+ }
43581
+ toString() {
43582
+ return `${this.status.toString()} - ${this.url}`;
43583
+ }
43584
+ blob() {
43585
+ return null;
43586
+ }
43587
+ };
43588
+
43589
+ // src/files/HttpStatus.ts
43590
+ var HttpStatus = class {
43591
+ constructor(code, text) {
43592
+ this.code = code;
43593
+ this.text = text;
43594
+ }
43595
+ toString() {
43596
+ return this.text ? `${this.code} - ${this.text}` : this.code.toString();
43597
+ }
43598
+ };
43599
+
43467
43600
  // src/files/FileFetcher.ts
43468
43601
  var FileFetcher = class {
43469
43602
  constructor(session) {
43470
43603
  this.session = session;
43471
43604
  }
43472
- fetchBlob(url) {
43605
+ fetchFile(url) {
43473
43606
  return __async(this, null, function* () {
43474
- return this.session.authenticatedFetch(url).then((response) => {
43475
- if (!response.ok) {
43476
- throw new Error(`${response.status} - ${response.statusText}`);
43477
- }
43478
- return response.blob();
43479
- });
43607
+ const response = yield this.session.authenticatedFetch(url);
43608
+ if (response.ok) {
43609
+ const blob = yield response.blob();
43610
+ return new BinaryFile(url, blob);
43611
+ } else {
43612
+ return new BrokenFile(
43613
+ url,
43614
+ new HttpStatus(response.status, response.statusText)
43615
+ );
43616
+ }
43480
43617
  });
43481
43618
  }
43482
43619
  };
@@ -43896,8 +44033,8 @@ var NamedNode = /* @__PURE__ */ function(_Node) {
43896
44033
  throw new Error('NamedNode IRI "' + iri + '" must be absolute.');
43897
44034
  }
43898
44035
  if (_this.value.includes(" ")) {
43899
- var message = 'Error: NamedNode IRI "' + iri + '" must not contain unencoded spaces.';
43900
- throw new Error(message);
44036
+ var message2 = 'Error: NamedNode IRI "' + iri + '" must not contain unencoded spaces.';
44037
+ throw new Error(message2);
43901
44038
  }
43902
44039
  return _this;
43903
44040
  }
@@ -47381,8 +47518,8 @@ var N3Parser = class {
47381
47518
  _emit(subject, predicate, object, graph3) {
47382
47519
  this._callback(null, this._quad(subject, predicate, object, graph3 || this.DEFAULTGRAPH));
47383
47520
  }
47384
- _error(message, token) {
47385
- const err = new Error(`${message} on line ${token.line}.`);
47521
+ _error(message2, token) {
47522
+ const err = new Error(`${message2} on line ${token.line}.`);
47386
47523
  err.context = {
47387
47524
  token,
47388
47525
  line: token.line,
@@ -55085,13 +55222,13 @@ var Fetcher = /* @__PURE__ */ function() {
55085
55222
  }
55086
55223
  }
55087
55224
  }, function(err) {
55088
- var message = err.message || err.statusText;
55089
- message = "Failed to load <" + uri + "> " + message;
55090
- console.log(message);
55225
+ var message2 = err.message || err.statusText;
55226
+ message2 = "Failed to load <" + uri + "> " + message2;
55227
+ console.log(message2);
55091
55228
  if (err.response && err.response.status) {
55092
- message += " status: " + err.response.status;
55229
+ message2 += " status: " + err.response.status;
55093
55230
  }
55094
- userCallback(false, message, err.response);
55231
+ userCallback(false, message2, err.response);
55095
55232
  });
55096
55233
  }
55097
55234
  }, {
@@ -55583,16 +55720,16 @@ var Fetcher = /* @__PURE__ */ function() {
55583
55720
  return this.redirectToProxy(proxyUri, options);
55584
55721
  }
55585
55722
  }
55586
- var message;
55723
+ var message2;
55587
55724
  if (response instanceof Error) {
55588
- message = "Fetch error: " + response.message;
55725
+ message2 = "Fetch error: " + response.message;
55589
55726
  } else {
55590
- message = response.statusText;
55727
+ message2 = response.statusText;
55591
55728
  if (response.responseText) {
55592
- message += " ".concat(response.responseText);
55729
+ message2 += " ".concat(response.responseText);
55593
55730
  }
55594
55731
  }
55595
- return this.failFetch(options, message, response.status || 998, response);
55732
+ return this.failFetch(options, message2, response.status || 998, response);
55596
55733
  }
55597
55734
  }, {
55598
55735
  key: "addType",
@@ -56047,8 +56184,8 @@ var PodOS = class {
56047
56184
  fetch(uri) {
56048
56185
  return this.store.fetch(uri);
56049
56186
  }
56050
- fetchBlob(url) {
56051
- return this.fileFetcher.fetchBlob(url);
56187
+ fetchFile(url) {
56188
+ return this.fileFetcher.fetchFile(url);
56052
56189
  }
56053
56190
  trackSession(callback) {
56054
56191
  return this.session.trackSession(callback);
@@ -56184,7 +56321,28 @@ const PosDescription$1 = class extends HTMLElement$1 {
56184
56321
  }
56185
56322
  };
56186
56323
 
56187
- const posImageCss = ":host{--width:300px;--height:300px;--border-radius:0}img,ion-skeleton-text{border-radius:var(--border-radius);width:var(--width);height:var(--height)}";
56324
+ const BrokenImage = ({ file }) => {
56325
+ const iconName = iconForStatus(file.status);
56326
+ return (h("div", null,
56327
+ h("a", { class: "error", href: file.url },
56328
+ h("div", null,
56329
+ h("ion-icon", { name: iconName })),
56330
+ h("div", { class: "code" }, file.status.code),
56331
+ h("div", { class: "text" }, file.status.text))));
56332
+ };
56333
+ function iconForStatus(status) {
56334
+ switch (status.code) {
56335
+ case 401:
56336
+ case 403:
56337
+ return 'lock-closed-outline';
56338
+ case 404:
56339
+ return 'help-circle-outline';
56340
+ default:
56341
+ return 'alert-circle-outline';
56342
+ }
56343
+ }
56344
+
56345
+ const posImageCss = ":host{--width:300px;--height:300px;--border-radius:0}img,ion-skeleton-text,div.error{border-radius:var(--border-radius);width:var(--width);height:var(--height)}.error{display:flex;opacity:0.8;background:repeating-linear-gradient( -45deg, rgba(150, 0, 0, 0.1), rgba(150, 0, 0, 0.1) 10px, #fff 5px, #fff 25px );flex-direction:column;border:1px solid red;color:black;align-items:center;justify-content:center;word-break:break-all;padding:1rem;box-sizing:border-box}.error ion-icon{color:#282828;--ionicon-stroke-width:calc(var(--width) / 5);font-size:calc(var(--width) / 2)}a{text-decoration:none;width:var(--width);height:var(--height)}.code{font-weight:bold;font-size:calc(var(--width) / 8)}.text{font-size:calc(var(--width) / 20)}";
56188
56346
 
56189
56347
  const PosImage$1 = class extends HTMLElement$1 {
56190
56348
  constructor() {
@@ -56204,9 +56362,14 @@ const PosImage$1 = class extends HTMLElement$1 {
56204
56362
  async fetchBlob() {
56205
56363
  try {
56206
56364
  this.loading = true;
56207
- const blob = await this.os.fetchBlob(this.src);
56208
- this.dataUri = URL.createObjectURL(blob);
56209
- this.error = null;
56365
+ const file = await this.os.fetchFile(this.src);
56366
+ if (file.blob()) {
56367
+ this.dataUri = URL.createObjectURL(file.blob());
56368
+ this.error = null;
56369
+ }
56370
+ else {
56371
+ this.brokenFile = file;
56372
+ }
56210
56373
  }
56211
56374
  catch (err) {
56212
56375
  this.error = err;
@@ -56222,6 +56385,9 @@ const PosImage$1 = class extends HTMLElement$1 {
56222
56385
  if (this.error) {
56223
56386
  return h("div", { class: "error" }, this.error.message);
56224
56387
  }
56388
+ if (this.brokenFile) {
56389
+ return h(BrokenImage, { file: this.brokenFile });
56390
+ }
56225
56391
  return h("img", { src: this.dataUri });
56226
56392
  }
56227
56393
  static get watchers() { return {
@@ -56812,6 +56978,10 @@ const PosRouter$1 = class extends HTMLElement$1 {
56812
56978
  }
56813
56979
  };
56814
56980
 
56981
+ const TestComponent$1 = class extends HTMLElement$1 {
56982
+ static get is() { return "test-component"; }
56983
+ };
56984
+
56815
56985
  globalScripts();
56816
56986
  const IonActionSheet = /*@__PURE__*/proxyCustomElement(ActionSheet, [34,"ion-action-sheet",{"overlayIndex":[2,"overlay-index"],"keyboardClose":[4,"keyboard-close"],"enterAnimation":[16],"leaveAnimation":[16],"buttons":[16],"cssClass":[1,"css-class"],"backdropDismiss":[4,"backdrop-dismiss"],"header":[1],"subHeader":[1,"sub-header"],"translucent":[4],"animated":[4],"htmlAttributes":[16]}]);
56817
56987
  const IonAlert = /*@__PURE__*/proxyCustomElement(Alert, [34,"ion-alert",{"overlayIndex":[2,"overlay-index"],"keyboardClose":[4,"keyboard-close"],"enterAnimation":[16],"leaveAnimation":[16],"cssClass":[1,"css-class"],"header":[1],"subHeader":[1,"sub-header"],"message":[1],"buttons":[16],"inputs":[1040],"backdropDismiss":[4,"backdrop-dismiss"],"translucent":[4],"animated":[4],"htmlAttributes":[16]},[[4,"keydown","onKeydown"]]]);
@@ -56905,7 +57075,7 @@ const PosApp = /*@__PURE__*/proxyCustomElement(PosApp$1, [4,"pos-app",{"os":[32]
56905
57075
  const PosAppGeneric = /*@__PURE__*/proxyCustomElement(PosAppGeneric$1, [0,"pos-app-generic"]);
56906
57076
  const PosDemoApp = /*@__PURE__*/proxyCustomElement(PosDemoApp$1, [0,"pos-demo-app"]);
56907
57077
  const PosDescription = /*@__PURE__*/proxyCustomElement(PosDescription$1, [1,"pos-description",{"resource":[32]}]);
56908
- const PosImage = /*@__PURE__*/proxyCustomElement(PosImage$1, [1,"pos-image",{"src":[1],"os":[32],"dataUri":[32],"error":[32],"loading":[32]}]);
57078
+ const PosImage = /*@__PURE__*/proxyCustomElement(PosImage$1, [1,"pos-image",{"src":[1],"os":[32],"dataUri":[32],"brokenFile":[32],"error":[32],"loading":[32]}]);
56909
57079
  const PosLabel = /*@__PURE__*/proxyCustomElement(PosLabel$1, [1,"pos-label",{"resource":[32]}]);
56910
57080
  const PosLiterals = /*@__PURE__*/proxyCustomElement(PosLiterals$1, [1,"pos-literals",{"data":[32]}]);
56911
57081
  const PosLogin = /*@__PURE__*/proxyCustomElement(PosLogin$1, [0,"pos-login",{"os":[32]}]);
@@ -57017,7 +57187,8 @@ const defineCustomElements = (opts) => {
57017
57187
  PosResource,
57018
57188
  PosReverseRelations,
57019
57189
  PosRichLink,
57020
- PosRouter
57190
+ PosRouter,
57191
+ TestComponent
57021
57192
  ].forEach(cmp => {
57022
57193
  if (!customElements.get(cmp.is)) {
57023
57194
  customElements.define(cmp.is, cmp, opts);
@@ -57026,4 +57197,4 @@ const defineCustomElements = (opts) => {
57026
57197
  }
57027
57198
  };
57028
57199
 
57029
- export { IonActionSheet, IonAlert, IonApp, IonAvatar, IonBackButton, IonBackdrop, IonBadge, IonButton, IonButtons, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonCheckbox, IonChip, IonCol, IonContent, IonDatetime, IonFab, IonFabButton, IonFabList, IonFooter, IonGrid, IonHeader, IonIcon, IonImg, IonInfiniteScroll, IonInfiniteScrollContent, IonInput, IonItem, IonItemDivider, IonItemGroup, IonItemOption, IonItemOptions, IonItemSliding, IonLabel, IonList, IonListHeader, IonLoading, IonMenu, IonMenuButton, IonMenuToggle, IonModal, IonNav, IonNavLink, IonNote, IonPicker, IonPickerColumn, IonPopover, IonProgressBar, IonRadio, IonRadioGroup, IonRange, IonRefresher, IonRefresherContent, IonReorder, IonReorderGroup, IonRippleEffect, IonRoute, IonRouteRedirect, IonRouter, IonRouterLink, IonRouterOutlet, IonRow, IonSearchbar, IonSegment, IonSegmentButton, IonSelect, IonSelectOption, IonSelectPopover, IonSkeletonText, IonSlide, IonSlides, IonSpinner, IonSplitPane, IonTab, IonTabBar, IonTabButton, IonTabs, IonText, IonTextarea, IonThumbnail, IonTitle, IonToast, IonToggle, IonToolbar, IonVirtualScroll, PosApp, PosAppGeneric, PosDemoApp, PosDescription, PosImage, PosLabel, PosLiterals, PosLogin, PosRelations, PosResource, PosReverseRelations, PosRichLink, PosRouter, addEventListener as a, raf as b, componentOnReady as c, createGesture as d, defineCustomElements, clamp as e, createAnimation as f, getIonPageElement as g, now as n, pointerCoord as p, removeEventListener as r };
57200
+ export { IonActionSheet, IonAlert, IonApp, IonAvatar, IonBackButton, IonBackdrop, IonBadge, IonButton, IonButtons, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonCheckbox, IonChip, IonCol, IonContent, IonDatetime, IonFab, IonFabButton, IonFabList, IonFooter, IonGrid, IonHeader, IonIcon, IonImg, IonInfiniteScroll, IonInfiniteScrollContent, IonInput, IonItem, IonItemDivider, IonItemGroup, IonItemOption, IonItemOptions, IonItemSliding, IonLabel, IonList, IonListHeader, IonLoading, IonMenu, IonMenuButton, IonMenuToggle, IonModal, IonNav, IonNavLink, IonNote, IonPicker, IonPickerColumn, IonPopover, IonProgressBar, IonRadio, IonRadioGroup, IonRange, IonRefresher, IonRefresherContent, IonReorder, IonReorderGroup, IonRippleEffect, IonRoute, IonRouteRedirect, IonRouter, IonRouterLink, IonRouterOutlet, IonRow, IonSearchbar, IonSegment, IonSegmentButton, IonSelect, IonSelectOption, IonSelectPopover, IonSkeletonText, IonSlide, IonSlides, IonSpinner, IonSplitPane, IonTab, IonTabBar, IonTabButton, IonTabs, IonText, IonTextarea, IonThumbnail, IonTitle, IonToast, IonToggle, IonToolbar, IonVirtualScroll, PosApp, PosAppGeneric, PosDemoApp, PosDescription, PosImage, PosLabel, PosLiterals, PosLogin, PosRelations, PosResource, PosReverseRelations, PosRichLink, PosRouter, TestComponent$1 as TestComponent, addEventListener as a, raf as b, componentOnReady as c, createGesture as d, defineCustomElements, clamp as e, createAnimation as f, getIonPageElement as g, now as n, pointerCoord as p, removeEventListener as r };