@fedify/fedify 2.2.20 → 2.2.21

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.
Files changed (102) hide show
  1. package/dist/attachment-arrays-CalAATqD.mjs +16 -0
  2. package/dist/{builder-BolQ56ab.mjs → builder-4ImvtjG4.mjs} +3 -3
  3. package/dist/callback-0KrwzutD.d.mts +2607 -0
  4. package/dist/{client-jE7oGvRh.d.ts → client-9DPcy_Yx.d.ts} +16 -0
  5. package/dist/{client-BIBzqEIp.d.cts → client-B3ruDgWg.d.cts} +16 -0
  6. package/dist/{client-DhxaVgOv.mjs → client-XYMC0Mmk.mjs} +86 -11
  7. package/dist/compat/attachment-arrays.test.d.mts +2 -0
  8. package/dist/compat/attachment-arrays.test.mjs +255 -0
  9. package/dist/compat/mod.d.cts +1 -1
  10. package/dist/compat/mod.d.ts +1 -1
  11. package/dist/compat/outgoing-jsonld.test.mjs +1 -1
  12. package/dist/compat/public-audience.test.mjs +1 -1
  13. package/dist/compat/transformers.test.mjs +1 -1
  14. package/dist/{context-CFQGaq5x.d.cts → context-CjWuov0g.d.cts} +31 -14
  15. package/dist/{context-DdbLVV_k.d.ts → context-DZqI2LJD.d.ts} +31 -14
  16. package/dist/{deno-BUj4roJc.mjs → deno-AWk3S2Ug.mjs} +1 -1
  17. package/dist/{docloader-CbtF_0cD.mjs → docloader-Bogpjg4d.mjs} +2 -2
  18. package/dist/federation/attachment-responses.test.d.mts +2 -0
  19. package/dist/federation/attachment-responses.test.mjs +182 -0
  20. package/dist/federation/builder.test.mjs +1 -1
  21. package/dist/federation/collection.test.mjs +1 -1
  22. package/dist/federation/delivery-attachments.test.d.mts +2 -0
  23. package/dist/federation/delivery-attachments.test.mjs +288 -0
  24. package/dist/federation/handler.test.mjs +208 -16
  25. package/dist/federation/idempotency.test.mjs +2 -2
  26. package/dist/federation/inbox.test.mjs +2 -2
  27. package/dist/federation/middleware.test.mjs +1184 -8
  28. package/dist/federation/mod.cjs +1 -1
  29. package/dist/federation/mod.d.cts +2 -2
  30. package/dist/federation/mod.d.ts +2 -2
  31. package/dist/federation/mod.js +1 -1
  32. package/dist/federation/negotiation.test.mjs +1 -1
  33. package/dist/federation/retry.test.mjs +1 -1
  34. package/dist/federation/send.test.mjs +283 -3
  35. package/dist/federation/temporal.test.mjs +25 -1
  36. package/dist/federation/webfinger.test.mjs +1 -1
  37. package/dist/{http-CQMVisM0.mjs → http-B3wCvgu8.mjs} +6 -4
  38. package/dist/{http-D8I7LBfx.cjs → http-BNaPJVnF.cjs} +6 -4
  39. package/dist/{http-C5g_VrA_.js → http-BpdLaGy8.js} +6 -4
  40. package/dist/{http-9IFUxdkp.d.cts → http-C8qLHs_Z.d.cts} +3 -3
  41. package/dist/{http-SbfezERn.d.ts → http-D8WmcRAF.d.ts} +3 -3
  42. package/dist/{inbox-CD8IDILN.mjs → inbox-DLy6WBXU.mjs} +1 -1
  43. package/dist/{key-C3o3DGap.mjs → key-Bhc8cQC7.mjs} +3 -2
  44. package/dist/{kv-cache-DC9LcfoC.cjs → kv-cache-Bj3CY9Jo.cjs} +1 -1
  45. package/dist/{kv-cache-CSKXXleR.js → kv-cache-CvjLUQTf.js} +1 -1
  46. package/dist/{ld-ijSr-0AB.mjs → ld-DTeykI0e.mjs} +153 -21
  47. package/dist/ld-signature-Dgz_b89j.mjs +23 -0
  48. package/dist/{middleware-DNueR0GD.cjs → middleware-BSQP4d9p.cjs} +475 -107
  49. package/dist/{middleware-DmcY2TWS.cjs → middleware-CWOzxb3o.cjs} +1 -1
  50. package/dist/{middleware-yqqfI7oJ.mjs → middleware-DkMsC5mQ.mjs} +1 -1
  51. package/dist/{middleware-sjhz30sm.js → middleware-Dx1iwFk8.js} +474 -107
  52. package/dist/{middleware-CYAaUTi5.mjs → middleware-dlGvSrXl.mjs} +386 -96
  53. package/dist/{mod-BYWp77-z.d.cts → mod-BmxqcEnU.d.ts} +30 -13
  54. package/dist/{mod-CVSKw-5H.d.cts → mod-DWEx2D4q.d.cts} +1 -1
  55. package/dist/{mod-BuRRdsfD.d.ts → mod-DnPmz3-S.d.ts} +1 -1
  56. package/dist/{mod-CM5_J_cx.d.ts → mod-INjDw-m0.d.cts} +30 -13
  57. package/dist/{mod-BRnwh2oy.d.ts → mod-REfljt0T.d.ts} +3 -3
  58. package/dist/{mod-Co7LEK9X.d.cts → mod-UvIGUHqW.d.cts} +3 -3
  59. package/dist/mod.cjs +5 -5
  60. package/dist/mod.d.cts +8 -8
  61. package/dist/mod.d.ts +8 -8
  62. package/dist/mod.js +5 -5
  63. package/dist/nodeinfo/client.test.mjs +432 -4
  64. package/dist/nodeinfo/handler.test.mjs +1 -1
  65. package/dist/nodeinfo/mod.cjs +1 -1
  66. package/dist/nodeinfo/mod.d.cts +1 -1
  67. package/dist/nodeinfo/mod.d.ts +1 -1
  68. package/dist/nodeinfo/mod.js +1 -1
  69. package/dist/nodeinfo/types.test.mjs +1 -1
  70. package/dist/{outgoing-jsonld-amccRMrV.mjs → outgoing-jsonld-DHf_DYXp.mjs} +38 -8
  71. package/dist/{owner-B8kXzD0q.mjs → owner-BsA7qMHB.mjs} +2 -2
  72. package/dist/{proof-CBQOjOgA.mjs → proof-C63Hqt9N.mjs} +40 -15
  73. package/dist/{proof-qiuGJCD7.cjs → proof-Dbz6ApNP.cjs} +1190 -1007
  74. package/dist/{proof-DKX6nASL.js → proof-QV_o5ZqS.js} +1174 -1003
  75. package/dist/{send-DRpisX_f.mjs → send-CAdpwbFX.mjs} +92 -21
  76. package/dist/sig/http.test.mjs +2 -2
  77. package/dist/sig/key-types.test.d.mts +218 -0
  78. package/dist/sig/key-types.test.mjs +8 -0
  79. package/dist/sig/key.test.mjs +2 -2
  80. package/dist/sig/ld.test.mjs +573 -8
  81. package/dist/sig/mod.cjs +2 -2
  82. package/dist/sig/mod.d.cts +3 -3
  83. package/dist/sig/mod.d.ts +3 -3
  84. package/dist/sig/mod.js +2 -2
  85. package/dist/sig/owner.test.mjs +1 -1
  86. package/dist/sig/proof.test.mjs +96 -4
  87. package/dist/{temporal-BQGEINad.mjs → temporal-B3JGkVgk.mjs} +3 -5
  88. package/dist/testing/mod.d.mts +2 -2422
  89. package/dist/{types-DOvyymM4.cjs → types-BWx7zw3Y.cjs} +85 -10
  90. package/dist/{types-B1_pRFE_.js → types-Dx_w2JSM.js} +86 -11
  91. package/dist/utils/docloader.test.mjs +2 -2
  92. package/dist/utils/mod.cjs +1 -1
  93. package/dist/utils/mod.d.cts +1 -1
  94. package/dist/utils/mod.d.ts +1 -1
  95. package/dist/utils/mod.js +1 -1
  96. package/package.json +5 -5
  97. /package/dist/{activity-listener-ell7W1s9.mjs → activity-listener-tztVvlNb.mjs} +0 -0
  98. /package/dist/{collection-D-HqUuA2.mjs → collection-CA3V5zyK.mjs} +0 -0
  99. /package/dist/{negotiation-SQvQgUqe.mjs → negotiation-VnHNB0Q5.mjs} +0 -0
  100. /package/dist/{public-audience-DpJqzPuh.mjs → public-audience-4g3_Ze4y.mjs} +0 -0
  101. /package/dist/{retry-v_sGLH1d.mjs → retry-CXg_MBI-.mjs} +0 -0
  102. /package/dist/{types-J53Kw7so.mjs → types-BFowWFTT.mjs} +0 -0
@@ -1,11 +1,12 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as version, t as name } from "./deno-BUj4roJc.mjs";
5
- import { r as fetchKey, s as validateCryptoKey } from "./key-C3o3DGap.mjs";
4
+ import { n as version, t as name } from "./deno-AWk3S2Ug.mjs";
5
+ import { r as fetchKey, s as validateCryptoKey } from "./key-Bhc8cQC7.mjs";
6
6
  import { Activity, CryptographicKey, Object as Object$1, getTypeId } from "@fedify/vocab";
7
7
  import { SpanStatusCode, trace } from "@opentelemetry/api";
8
- import { getDocumentLoader } from "@fedify/vocab-runtime";
8
+ import { getDocumentLoader, preloadedContexts } from "@fedify/vocab-runtime";
9
+ import { asCryptoKey } from "@fedify/vocab-runtime/internal";
9
10
  import { getLogger } from "@logtape/logtape";
10
11
  import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
11
12
  import { encodeHex } from "byte-encodings/hex";
@@ -298,24 +299,110 @@ function assertSafeJsonLd(jsonLd) {
298
299
  }
299
300
  }
300
301
  }
302
+ const signatureTermDefinition = { "signature": "https://w3id.org/security#signature" };
303
+ const signatureDefiningContexts = new Set(["https://w3id.org/identity/v1", "https://w3id.org/security/v1"]);
304
+ const signatureFreeContexts = getSignatureFreeContexts();
305
+ function getSignatureFreeContexts() {
306
+ const urls = /* @__PURE__ */ new Set();
307
+ for (const [url, document] of globalThis.Object.entries(preloadedContexts)) {
308
+ if (typeof document !== "object" || document == null) continue;
309
+ const context = document["@context"];
310
+ if (typeof context !== "object" || context == null || Array.isArray(context)) continue;
311
+ const record = context;
312
+ if (!globalThis.Object.prototype.hasOwnProperty.call(record, "signature")) urls.add(url);
313
+ }
314
+ return urls;
315
+ }
316
+ function getContextEntryEffect(entry) {
317
+ if (entry == null) return "resets";
318
+ if (typeof entry === "string") {
319
+ if (signatureDefiningContexts.has(entry)) return "defines";
320
+ if (signatureFreeContexts.has(entry)) return "absent";
321
+ return "unknown";
322
+ }
323
+ if (typeof entry !== "object") return "absent";
324
+ const record = entry;
325
+ if (globalThis.Object.prototype.hasOwnProperty.call(record, "signature")) {
326
+ const definition = record["signature"];
327
+ const contextProtected = record["@protected"] === true;
328
+ const imported = globalThis.Object.prototype.hasOwnProperty.call(record, "@import");
329
+ if (definition == null) {
330
+ if (contextProtected) return "defines";
331
+ return imported ? "unknown" : "resets";
332
+ }
333
+ if (typeof definition === "object" && !Array.isArray(definition)) {
334
+ const term = definition;
335
+ const protectedTerm = contextProtected || term["@protected"] === true;
336
+ if (globalThis.Object.prototype.hasOwnProperty.call(term, "@id") && term["@id"] == null) {
337
+ if (protectedTerm) return "defines";
338
+ return imported ? "unknown" : "resets";
339
+ }
340
+ }
341
+ return "defines";
342
+ }
343
+ if (globalThis.Object.prototype.hasOwnProperty.call(record, "@import")) return "unknown";
344
+ return "absent";
345
+ }
346
+ function getSignatureTermState(context) {
347
+ if (context == null) return "absent";
348
+ if (!Array.isArray(context)) {
349
+ const effect = getContextEntryEffect(context);
350
+ return effect === "defines" ? "defined" : effect === "unknown" ? "unknown" : "absent";
351
+ }
352
+ let state = "absent";
353
+ for (const entry of context) {
354
+ const effect = getContextEntryEffect(entry);
355
+ if (effect === "defines") state = "defined";
356
+ else if (effect === "resets") state = "absent";
357
+ else if (effect === "unknown" && state !== "defined") state = "unknown";
358
+ }
359
+ return state;
360
+ }
361
+ function prepareSignatureDocument(jsonLd) {
362
+ if (typeof jsonLd !== "object" || jsonLd == null || Array.isArray(jsonLd)) return jsonLd;
363
+ const document = jsonLd;
364
+ if (document["proof"] != null) return { ...document };
365
+ const context = document["@context"];
366
+ if (getSignatureTermState(context) !== "absent") return { ...document };
367
+ const definition = { ...signatureTermDefinition };
368
+ return {
369
+ ...document,
370
+ "@context": context == null ? [definition] : Array.isArray(context) ? [...context, definition] : [context, definition]
371
+ };
372
+ }
301
373
  /**
302
374
  * Attaches a LD signature to the given JSON-LD document.
375
+ *
376
+ * When the document's context does not already define the `signature`
377
+ * property, the returned document adds a minimal inline context for it.
378
+ * Without that definition, expanding the attached signature would produce a
379
+ * blank node predicate, which is not valid RDF. Documents that already carry
380
+ * a `proof` are left unchanged, since a new context definition would invalidate
381
+ * the proof. Documents whose context includes an unrecognized remote context
382
+ * are also left unchanged, since that context may already define `signature`.
303
383
  * @param jsonLd The JSON-LD document to attach the signature to. It is not
304
384
  * modified.
305
385
  * @param signature The signature to attach.
306
386
  * @returns The JSON-LD document with the attached signature.
307
387
  * @throws {TypeError} If the input document is not a valid JSON-LD document.
388
+ * Top-level arrays are rejected, since a Linked Data
389
+ * Signature is attached to a single node.
308
390
  * @since 1.0.0
309
391
  */
310
392
  function attachSignature(jsonLd, signature) {
311
- if (typeof jsonLd !== "object" || jsonLd == null) throw new TypeError("Failed to attach signature; invalid JSON-LD document.");
312
- return {
313
- ...jsonLd,
314
- signature
315
- };
393
+ if (typeof jsonLd !== "object" || jsonLd == null || Array.isArray(jsonLd)) throw new TypeError("Failed to attach signature; invalid JSON-LD document.");
394
+ const output = prepareSignatureDocument(jsonLd);
395
+ output.signature = signature;
396
+ return output;
316
397
  }
317
398
  /**
318
399
  * Creates a LD signature for the given JSON-LD document.
400
+ *
401
+ * If the document's context does not define the `signature` property, the
402
+ * signature is computed over the document with a minimal inline definition
403
+ * added. Use {@link attachSignature} to attach the signature to that exact
404
+ * document. Documents that already carry a `proof`, or whose context includes
405
+ * an unrecognized remote context, are hashed unchanged.
319
406
  * @param jsonLd The JSON-LD document to sign.
320
407
  * @param privateKey The private key to sign the document.
321
408
  * @param keyId The ID of the public key that corresponds to the private key.
@@ -329,14 +416,17 @@ async function createSignature(jsonLd, privateKey, keyId, { contextLoader, creat
329
416
  validateCryptoKey(privateKey, "private");
330
417
  if (privateKey.algorithm.name !== "RSASSA-PKCS1-v1_5") throw new TypeError("Unsupported algorithm: " + privateKey.algorithm.name);
331
418
  const options = {
332
- "@context": "https://w3id.org/identity/v1",
333
419
  creator: keyId.href,
334
420
  created: created?.toString() ?? (/* @__PURE__ */ new Date()).toISOString()
335
421
  };
336
- const message = await hashJsonLd(options, contextLoader) + await hashJsonLd(jsonLd, contextLoader);
422
+ const message = await hashJsonLd({
423
+ "@context": "https://w3id.org/identity/v1",
424
+ ...options
425
+ }, contextLoader) + await hashJsonLd(prepareSignatureDocument(jsonLd), contextLoader);
337
426
  const messageBytes = new TextEncoder().encode(message);
338
- const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", privateKey, messageBytes);
427
+ const signature = await crypto.subtle.sign("RSASSA-PKCS1-v1_5", asCryptoKey(privateKey), messageBytes);
339
428
  return {
429
+ "@context": "https://w3id.org/security/v1",
340
430
  ...options,
341
431
  type: "RsaSignature2017",
342
432
  signatureValue: encodeBase64(signature)
@@ -375,6 +465,24 @@ async function signJsonLd(jsonLd, privateKey, keyId, options) {
375
465
  }
376
466
  });
377
467
  }
468
+ /** @internal */
469
+ function hasVerifiableSignature(jsonLd) {
470
+ if (typeof jsonLd !== "object" || jsonLd == null || Array.isArray(jsonLd) || !("signature" in jsonLd)) return false;
471
+ const signature = jsonLd.signature;
472
+ if (typeof signature !== "object" || signature == null || Array.isArray(signature)) return false;
473
+ return "type" in signature && signature.type === "RsaSignature2017" && "creator" in signature && typeof signature.creator === "string" && (!("created" in signature) || typeof signature.created === "string") && "signatureValue" in signature && typeof signature.signatureValue === "string";
474
+ }
475
+ /** @internal */
476
+ function describeSignatureShape(jsonLd) {
477
+ if (typeof jsonLd !== "object" || jsonLd == null || !("signature" in jsonLd)) return null;
478
+ const signature = jsonLd.signature;
479
+ const properties = typeof signature === "object" && signature != null ? globalThis.Object.keys(signature) : [];
480
+ return {
481
+ signatureKind: signature == null ? String(signature) : Array.isArray(signature) ? "array" : typeof signature,
482
+ signatureProperties: properties.sort().slice(0, 20).map((p) => p.slice(0, 80)),
483
+ signaturePropertyCount: properties.length
484
+ };
485
+ }
378
486
  /**
379
487
  * Checks if the given JSON-LD document has a Linked Data Signature-like
380
488
  * object, without restricting it to a single suite-specific shape.
@@ -428,6 +536,9 @@ function detachSignature(jsonLd) {
428
536
  }
429
537
  /**
430
538
  * Verifies Linked Data Signatures of the given JSON-LD document.
539
+ * Unmapped properties discarded during JSON-LD processing are tolerated, but
540
+ * their values are not authenticated by the signature. Other unsafe
541
+ * canonicalization warnings, including relative IRIs, remain rejected.
431
542
  * @param jsonLd The JSON-LD document to verify.
432
543
  * @param options Options for verifying the signature.
433
544
  * @returns The public key that signed the document or `null` if the signature
@@ -435,7 +546,11 @@ function detachSignature(jsonLd) {
435
546
  * @since 1.0.0
436
547
  */
437
548
  async function verifySignature(jsonLd, options = {}) {
438
- if (!hasSignature(jsonLd)) return null;
549
+ if (!hasVerifiableSignature(jsonLd)) {
550
+ const shape = describeSignatureShape(jsonLd);
551
+ if (shape != null) logger.debug("Linked Data Signature has an unsupported shape: {signatureKind}; properties: {signatureProperties}.", shape);
552
+ return null;
553
+ }
439
554
  const sig = jsonLd.signature;
440
555
  let signature;
441
556
  try {
@@ -447,7 +562,14 @@ async function verifySignature(jsonLd, options = {}) {
447
562
  });
448
563
  return null;
449
564
  }
450
- const { key, cached } = await fetchKey(new URL(sig.creator), CryptographicKey, options);
565
+ let creator;
566
+ try {
567
+ creator = new URL(sig.creator);
568
+ } catch {
569
+ logger.debug("Failed to verify; signature creator is not a valid URL.");
570
+ return null;
571
+ }
572
+ const { key, cached } = await fetchKey(creator, CryptographicKey, options);
451
573
  if (key == null) return null;
452
574
  const sigOpts = {
453
575
  ...sig,
@@ -458,7 +580,7 @@ async function verifySignature(jsonLd, options = {}) {
458
580
  delete sigOpts.signatureValue;
459
581
  let sigOptsHash;
460
582
  try {
461
- sigOptsHash = await hashJsonLd(sigOpts, options.contextLoader);
583
+ sigOptsHash = await hashJsonLd(sigOpts, options.contextLoader, "verify");
462
584
  } catch (error) {
463
585
  logger.warn("Failed to verify; failed to hash the signature options: {signatureOptions}\n{error}", {
464
586
  signatureOptions: sigOpts,
@@ -470,7 +592,7 @@ async function verifySignature(jsonLd, options = {}) {
470
592
  delete document.signature;
471
593
  let docHash;
472
594
  try {
473
- docHash = await hashJsonLd(document, options.contextLoader);
595
+ docHash = await hashJsonLd(document, options.contextLoader, "verify");
474
596
  } catch (error) {
475
597
  logger.warn("Failed to verify; failed to hash the document: {document}\n{error}", {
476
598
  document,
@@ -487,7 +609,7 @@ async function verifySignature(jsonLd, options = {}) {
487
609
  keyId: sig.creator,
488
610
  ...sig
489
611
  });
490
- const { key } = await fetchKey(new URL(sig.creator), CryptographicKey, {
612
+ const { key } = await fetchKey(creator, CryptographicKey, {
491
613
  ...options,
492
614
  keyCache: {
493
615
  get: () => Promise.resolve(void 0),
@@ -509,6 +631,8 @@ async function verifySignature(jsonLd, options = {}) {
509
631
  * Signatures. If the document is signed, this function verifies the signature
510
632
  * and checks if the document is attributed to the owner of the public key.
511
633
  * If the document is not signed, this function returns `false`.
634
+ * Unmapped properties discarded during JSON-LD processing are not
635
+ * authenticated, even when verification succeeds.
512
636
  * @param jsonLd The JSON-LD document to verify.
513
637
  * @param options Options for verifying the document.
514
638
  * @returns `true` if the document is authentic; `false` otherwise.
@@ -523,11 +647,12 @@ async function verifyCompactJsonLd(jsonLd, options = {}) {
523
647
  async function verifyJsonLdInternal(jsonLd, options, compact) {
524
648
  return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("ld_signatures.verify", async (span) => {
525
649
  try {
526
- const verificationOptions = hasSignature(jsonLd) ? {
650
+ const hasLdSignature = hasVerifiableSignature(jsonLd);
651
+ const verificationOptions = hasLdSignature ? {
527
652
  ...options,
528
653
  contextLoader: getNormalizationContextLoader(options.contextLoader)
529
654
  } : options;
530
- const compacted = compact ? hasSignature(jsonLd) ? await compactJsonLd(jsonLd, options.contextLoader) : jsonLd : jsonLd;
655
+ const compacted = compact ? hasLdSignature ? await compactJsonLd(jsonLd, options.contextLoader) : jsonLd : jsonLd;
531
656
  const object = await Object$1.fromJsonLd(compacted, verificationOptions);
532
657
  if (object.id != null) span.setAttribute("activitypub.object.id", object.id.href);
533
658
  span.setAttribute("activitypub.object.type", getTypeId(object).href);
@@ -561,13 +686,20 @@ async function verifyJsonLdInternal(jsonLd, options, compact) {
561
686
  }
562
687
  });
563
688
  }
564
- async function hashJsonLd(jsonLd, contextLoader) {
689
+ const tolerableVerificationWarnings = new Set(["blank node predicate", "invalid property"]);
690
+ function handleVerificationEvent({ event, next }) {
691
+ if (event.level === "warning" && !tolerableVerificationWarnings.has(event.code)) throw new TypeError(`Unsafe JSON-LD canonicalization warning: ${event.code}`);
692
+ next();
693
+ }
694
+ async function hashJsonLd(jsonLd, contextLoader, mode = "sign") {
565
695
  const canon = await jsonld.canonize(jsonLd, {
566
696
  format: "application/n-quads",
567
- documentLoader: contextLoader ?? getDocumentLoader()
697
+ documentLoader: contextLoader ?? getDocumentLoader(),
698
+ safe: mode === "sign",
699
+ eventHandler: mode === "verify" ? handleVerificationEvent : void 0
568
700
  });
569
701
  const encoder = new TextEncoder();
570
702
  return encodeHex(await crypto.subtle.digest("SHA-256", encoder.encode(canon)));
571
703
  }
572
704
  //#endregion
573
- export { wrapContextLoaderForJsonLd as _, compactJsonLd as a, getNormalizationContextLoader as c, isClearlyMalformedContextReference as d, isInvalidUrlTypeError as f, verifySignature as g, verifyJsonLd as h, attachSignature as i, hasSignature as l, verifyCompactJsonLd as m, UnsafeJsonLdError as n, createSignature as o, signJsonLd as p, assertSafeJsonLd as r, detachSignature as s, InvalidContextReferenceError as t, hasSignatureLike as u };
705
+ export { verifyJsonLd as _, compactJsonLd as a, detachSignature as c, hasSignatureLike as d, hasVerifiableSignature as f, verifyCompactJsonLd as g, signJsonLd as h, attachSignature as i, getNormalizationContextLoader as l, isInvalidUrlTypeError as m, UnsafeJsonLdError as n, createSignature as o, isClearlyMalformedContextReference as p, assertSafeJsonLd as r, describeSignatureShape as s, InvalidContextReferenceError as t, hasSignature as u, verifySignature as v, wrapContextLoaderForJsonLd as y };
@@ -0,0 +1,23 @@
1
+ import "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
3
+ globalThis.addEventListener = () => {};
4
+ //#region src/testing/ld-signature.ts
5
+ const ldSignatureWithoutCreated = {
6
+ "@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
7
+ "id": "https://example.com/activities/1",
8
+ "type": "Create",
9
+ "actor": "https://example.com/person2",
10
+ "object": {
11
+ "id": "https://example.com/notes/1",
12
+ "type": "Note",
13
+ "attributedTo": "https://example.com/person2",
14
+ "content": "hi"
15
+ },
16
+ "signature": {
17
+ "type": "RsaSignature2017",
18
+ "creator": "https://example.com/person2#key3",
19
+ "signatureValue": "xUGTqQ94q+3bhvorwJx42sa7nCuR2ggtJYjwhqsueMCOLEmTEpeGGhG4mRKjFDt/ZegE9Icbxau6YL6WeQxWLMwYs7vucAE6948UlDFn1l3M+papmwgbNpOnk/baj9NMzChtqwOIQ1ka5bJAZjTo5FgG1YBmMibTHb6GN5ULzxjTlch93tcBx/LVwdPU1MyYHHz55hiMQZkw9AZ521PebCrm8eUjsXHwjijeh7/GIFWW3bmwk1dHRxJbUmmQlxBxmaLXQ8aVkFN3R00FBUjnn54Bp+nQJI/VXcKs3nFYGZ9EsMQcXlYCbOuOfPAPWiqdLSOhDZtuisIcZcvOiZ/tgA5RlXro0AXv0f3gKpkoxPBsUIIM0gBeb6+MTbSAk6IqPf0qy81V0XEjEMKSZNGDeULH+zMFodtw07EmfR/y/3i9ge3htd7vQQ0XKLLUfBddzMqS+8AAuSl4ObAlWAM2xuw/4yuQ3AIQy9RtsiEjDSO1NtUK5wRXCeXo++CkVpODDdxNtWdZD6GzfX9PAuIfHlWE+CLDaY/iH4fWxumLu15dD9vVDjlYAAS/ZNOyiPSCh4mLZ65sKIp8UkPstYRBKcjiRJhKUh1Br8TvTt/j/iC9SnFw/8uiCkLYd6yhdgXQafocPIa6eeb4m/EhF1HY0v+6qKR5JOBT6mTA/BPRmWg="
20
+ }
21
+ };
22
+ //#endregion
23
+ export { ldSignatureWithoutCreated as t };