@fedify/fedify 2.0.1 → 2.0.2-dev.415

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 (98) hide show
  1. package/dist/{builder-CqPrSnE5.js → builder-B55ClH_D.js} +3 -3
  2. package/dist/client-BxMZiQaD.d.ts +224 -0
  3. package/dist/client-C97KOq3x.d.cts +222 -0
  4. package/dist/compat/mod.d.cts +6 -6
  5. package/dist/compat/mod.d.ts +6 -6
  6. package/dist/compat/transformers.test.js +11 -11
  7. package/dist/context-D3QkEtZd.d.cts +2494 -0
  8. package/dist/context-DZJhUmzF.d.ts +2496 -0
  9. package/dist/{deno-CIi8RNND.js → deno-D-Duks4b.js} +1 -1
  10. package/dist/{docloader-CmrEfaGw.js → docloader-Bb4MhBYJ.js} +2 -2
  11. package/dist/federation/builder.test.js +3 -3
  12. package/dist/federation/handler.test.js +19 -19
  13. package/dist/federation/idempotency.test.js +11 -11
  14. package/dist/federation/inbox.test.js +2 -2
  15. package/dist/federation/middleware.test.js +11 -11
  16. package/dist/federation/mod.cjs +4 -4
  17. package/dist/federation/mod.d.cts +6 -6
  18. package/dist/federation/mod.d.ts +6 -6
  19. package/dist/federation/mod.js +4 -4
  20. package/dist/federation/send.test.js +5 -5
  21. package/dist/federation/webfinger.test.js +11 -11
  22. package/dist/{http-CCsNu78I.js → http-C3ipH_7H.js} +1 -1
  23. package/dist/http-Cz3MlXAZ.d.cts +244 -0
  24. package/dist/{http-BjroyS-9.cjs → http-DGYGS8C8.cjs} +1 -1
  25. package/dist/http-DkHdFfrc.d.ts +246 -0
  26. package/dist/{http-Dvox_xrq.js → http-DnP0rGKj.js} +2 -2
  27. package/dist/{inbox-CiTdVhJQ.js → inbox-CbNZlhe6.js} +1 -1
  28. package/dist/{key-C7JS89OH.js → key-DChkqRrm.js} +1 -1
  29. package/dist/kv-BL4nlICN.d.cts +110 -0
  30. package/dist/kv-DXEUEP6z.d.ts +113 -0
  31. package/dist/{kv-cache-BqFnozz0.cjs → kv-cache-Bd2z9in6.cjs} +1 -1
  32. package/dist/{kv-cache-6b2ldIo-.js → kv-cache-CFQBoGCe.js} +1 -1
  33. package/dist/{ld-C8i1kViF.js → ld-CR9Xg8mN.js} +2 -2
  34. package/dist/{middleware-DqJ1cmZE.cjs → middleware-B1XHFs0D.cjs} +8 -83
  35. package/dist/{middleware-B3GuN6Gj.js → middleware-B9frafBa.js} +8 -83
  36. package/dist/middleware-Bt5MUXQg.cjs +12 -0
  37. package/dist/{middleware-0fnsG0v7.js → middleware-ByIcAfxE.js} +11 -11
  38. package/dist/{middleware-CfL_Pd6a.js → middleware-DhlkbIaH.js} +4 -4
  39. package/dist/{middleware-B4Bgz0MJ.js → middleware-OPyIzlKI.js} +14 -89
  40. package/dist/mod-CwZXZJ9d.d.ts +91 -0
  41. package/dist/mod-DPkRU3EK.d.cts +266 -0
  42. package/dist/mod-DUWcVv49.d.ts +268 -0
  43. package/dist/mod-DVwHUI_x.d.cts +80 -0
  44. package/dist/mod-DXsQakeS.d.cts +89 -0
  45. package/dist/mod-Di3W5OdP.d.cts +62 -0
  46. package/dist/mod-DnSsduJF.d.ts +64 -0
  47. package/dist/mod-DosD6NsG.d.ts +82 -0
  48. package/dist/mod.cjs +4 -4
  49. package/dist/mod.d.cts +9 -9
  50. package/dist/mod.d.ts +9 -9
  51. package/dist/mod.js +4 -4
  52. package/dist/nodeinfo/handler.test.js +11 -11
  53. package/dist/nodeinfo/mod.d.cts +1 -1
  54. package/dist/nodeinfo/mod.d.ts +1 -1
  55. package/dist/otel/mod.d.cts +145 -145
  56. package/dist/otel/mod.d.ts +145 -145
  57. package/dist/owner-1AbPBOOZ.d.cts +66 -0
  58. package/dist/{owner-BOSWh-ha.js → owner-DfXg2o90.js} +1 -1
  59. package/dist/owner-gd0Q9FuU.d.ts +68 -0
  60. package/dist/{proof-BeT_MFIx.js → proof-BTvHpR2_.js} +2 -2
  61. package/dist/{proof-D61EYfPl.js → proof-CNhYMIct.js} +1 -1
  62. package/dist/{proof-C8qvlfLD.cjs → proof-DnzISmKI.cjs} +1 -1
  63. package/dist/{send-D7lC06r9.js → send-DaEkUvnr.js} +2 -2
  64. package/dist/sig/http.test.js +3 -3
  65. package/dist/sig/key.test.js +2 -2
  66. package/dist/sig/ld.test.js +3 -3
  67. package/dist/sig/mod.cjs +2 -2
  68. package/dist/sig/mod.d.cts +3 -3
  69. package/dist/sig/mod.d.ts +3 -3
  70. package/dist/sig/mod.js +2 -2
  71. package/dist/sig/owner.test.js +3 -3
  72. package/dist/sig/proof.test.js +3 -3
  73. package/dist/testing/mod.d.ts +4 -23
  74. package/dist/utils/docloader.test.js +4 -4
  75. package/dist/utils/mod.cjs +2 -2
  76. package/dist/utils/mod.d.cts +3 -3
  77. package/dist/utils/mod.d.ts +3 -3
  78. package/dist/utils/mod.js +2 -2
  79. package/package.json +5 -5
  80. package/dist/client-CwkOPN13.d.cts +0 -222
  81. package/dist/client-a7NwzhA2.d.ts +0 -224
  82. package/dist/context-BdNW_8a3.d.cts +0 -2554
  83. package/dist/context-C-GVKcJR.d.ts +0 -2556
  84. package/dist/http-CCEu-x1_.d.cts +0 -253
  85. package/dist/http-CODSJcKx.d.ts +0 -255
  86. package/dist/kv-g9jFc34-.d.cts +0 -110
  87. package/dist/kv-jg_8SMc1.d.ts +0 -113
  88. package/dist/middleware-DILzU8Ot.cjs +0 -12
  89. package/dist/mod-5PNty1K9.d.cts +0 -80
  90. package/dist/mod-BcpEGTWV.d.cts +0 -62
  91. package/dist/mod-COO7VMcm.d.cts +0 -266
  92. package/dist/mod-CevNbUol.d.ts +0 -91
  93. package/dist/mod-CtO31FCx.d.ts +0 -64
  94. package/dist/mod-Da9fNDyC.d.ts +0 -82
  95. package/dist/mod-ErTjUJs9.d.cts +0 -89
  96. package/dist/mod-q2IR8UiH.d.ts +0 -268
  97. package/dist/owner-9yZ5Ibsb.d.cts +0 -66
  98. package/dist/owner-DQYAbVmX.d.ts +0 -68
@@ -1,113 +0,0 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
3
-
4
- //#region src/federation/kv.d.ts
5
- /**
6
- * A key for a key–value store. An array of one or more strings.
7
- *
8
- * @since 0.5.0
9
- */
10
- type KvKey = readonly [string] | readonly [string, ...string[]];
11
- /**
12
- * Additional options for setting a value in a key–value store.
13
- *
14
- * @since 0.5.0
15
- */
16
- interface KvStoreSetOptions {
17
- /**
18
- * The time-to-live (TTL) for the value.
19
- */
20
- ttl?: Temporal.Duration;
21
- }
22
- /**
23
- * An entry returned by the {@link KvStore.list} method.
24
- *
25
- * @since 1.10.0
26
- */
27
- interface KvStoreListEntry {
28
- /**
29
- * The key of the entry.
30
- */
31
- readonly key: KvKey;
32
- /**
33
- * The value of the entry.
34
- */
35
- readonly value: unknown;
36
- }
37
- /**
38
- * An abstract interface for a key–value store.
39
- *
40
- * @since 0.5.0
41
- */
42
- interface KvStore {
43
- /**
44
- * Gets the value for the given key.
45
- * @param key The key to get the value for.
46
- * @returns The value for the key, or `undefined` if the key does not exist.
47
- * @template T The type of the value to get.
48
- */
49
- get<T = unknown>(key: KvKey): Promise<T | undefined>;
50
- /**
51
- * Sets the value for the given key.
52
- * @param key The key to set the value for.
53
- * @param value The value to set.
54
- * @param options Additional options for setting the value.
55
- */
56
- set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
57
- /**
58
- * Deletes the value for the given key.
59
- * @param key The key to delete.
60
- */
61
- delete(key: KvKey): Promise<void>;
62
- /**
63
- * Compare-and-swap (CAS) operation for the key–value store.
64
- * @param key The key to perform the CAS operation on.
65
- * @param expectedValue The expected value for the key.
66
- * @param newValue The new value to set if the expected value matches.
67
- * @param options Additional options for setting the value.
68
- * @return `true` if the CAS operation was successful, `false` otherwise.
69
- * @since 1.8.0
70
- */
71
- cas?: (key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions) => Promise<boolean>;
72
- /**
73
- * Lists all entries in the store that match the given prefix.
74
- * If no prefix is given, all entries are returned.
75
- * @param prefix The prefix to filter keys by. If not specified, all entries
76
- * are returned.
77
- * @returns An async iterable of entries matching the prefix.
78
- * @since 1.10.0
79
- * @since 2.0.0 This method is now required instead of optional.
80
- */
81
- list(prefix?: KvKey): AsyncIterable<KvStoreListEntry>;
82
- }
83
- /**
84
- * A key–value store that stores values in memory.
85
- * Do not use this in production as it does not persist values.
86
- *
87
- * @since 0.5.0
88
- */
89
- declare class MemoryKvStore implements KvStore {
90
- #private;
91
- /**
92
- * {@inheritDoc KvStore.get}
93
- */
94
- get<T = unknown>(key: KvKey): Promise<T | undefined>;
95
- /**
96
- * {@inheritDoc KvStore.set}
97
- */
98
- set(key: KvKey, value: unknown, options?: KvStoreSetOptions): Promise<void>;
99
- /**
100
- * {@inheritDoc KvStore.delete}
101
- */
102
- delete(key: KvKey): Promise<void>;
103
- /**
104
- * {@inheritDoc KvStore.cas}
105
- */
106
- cas(key: KvKey, expectedValue: unknown, newValue: unknown, options?: KvStoreSetOptions): Promise<boolean>;
107
- /**
108
- * {@inheritDoc KvStore.list}
109
- */
110
- list(prefix?: KvKey): AsyncIterable<KvStoreListEntry>;
111
- }
112
- //#endregion
113
- export { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore };
@@ -1,12 +0,0 @@
1
-
2
- const { Temporal } = require("@js-temporal/polyfill");
3
- const { URLPattern } = require("urlpattern-polyfill");
4
-
5
- require('./transformers-3g8GZwkZ.cjs');
6
- require('./http-BjroyS-9.cjs');
7
- const require_middleware = require('./middleware-DqJ1cmZE.cjs');
8
- require('./proof-C8qvlfLD.cjs');
9
- require('./types-Cd_hszr_.cjs');
10
- require('./kv-cache-BqFnozz0.cjs');
11
-
12
- exports.FederationImpl = require_middleware.FederationImpl;
@@ -1,80 +0,0 @@
1
- import { ActivityTransformer, Context } from "./context-BdNW_8a3.cjs";
2
- import { Activity } from "@fedify/vocab";
3
-
4
- //#region src/compat/transformers.d.ts
5
-
6
- /**
7
- * An activity transformer that assigns a new random ID to an activity if it
8
- * does not already have one. This is useful for ensuring that activities
9
- * have an ID before they are sent to other servers.
10
- *
11
- * The generated ID is an origin URI with a fragment which contains an activity
12
- * type name with a random UUID:
13
- *
14
- * ```
15
- * https://example.com/#Follow/12345678-1234-5678-1234-567812345678
16
- * ```
17
- *
18
- * @template TContextData The type of the context data.
19
- * @param activity The activity to assign an ID to.
20
- * @param context The context of the activity.
21
- * @return The activity with an ID assigned.
22
- * @since 1.4.0
23
- */
24
- declare function autoIdAssigner<TContextData>(activity: Activity, context: Context<TContextData>): Activity;
25
- /**
26
- * An activity transformer that dehydrates the actor property of an activity
27
- * so that it only contains the actor's URI. For example, suppose we have an
28
- * activity like this:
29
- *
30
- * ```typescript
31
- * import { Follow, Person } from "@fedify/vocab";
32
- * const input = new Follow({
33
- * id: new URL("http://example.com/activities/1"),
34
- * actor: new Person({
35
- * id: new URL("http://example.com/actors/1"),
36
- * name: "Alice",
37
- * preferredUsername: "alice",
38
- * }),
39
- * object: new Person({
40
- * id: new URL("http://example.com/actors/2"),
41
- * name: "Bob",
42
- * preferredUsername: "bob",
43
- * }),
44
- * });
45
- * ```
46
- *
47
- * The result of applying this transformer would be:
48
- *
49
- * ```typescript
50
- * import { Follow, Person } from "@fedify/vocab";
51
- * const output = new Follow({
52
- * id: new URL("http://example.com/activities/1"),
53
- * actor: new URL("http://example.com/actors/1"),
54
- * object: new Person({
55
- * id: new URL("http://example.com/actors/2"),
56
- * name: "Bob",
57
- * preferredUsername: "bob",
58
- * }),
59
- * });
60
- * ```
61
- *
62
- * As some ActivityPub implementations like Threads fail to deal with inlined
63
- * actor objects, this transformer can be used to work around this issue.
64
- * @template TContextData The type of the context data.
65
- * @param activity The activity to dehydrate the actor property of.
66
- * @param context The context of the activity.
67
- * @returns The dehydrated activity.
68
- * @since 1.4.0
69
- */
70
- declare function actorDehydrator<TContextData>(activity: Activity, _context: Context<TContextData>): Activity;
71
- /**
72
- * Gets the default activity transformers that are applied to all outgoing
73
- * activities.
74
- * @template TContextData The type of the context data.
75
- * @returns The default activity transformers.
76
- * @since 1.4.0
77
- */
78
- declare function getDefaultActivityTransformers<TContextData>(): readonly ActivityTransformer<TContextData>[];
79
- //#endregion
80
- export { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers };
@@ -1,62 +0,0 @@
1
- import { ActorAliasMapper, ActorDispatcher, ActorHandleMapper, RequestContext, WebFingerLinksDispatcher } from "./context-BdNW_8a3.cjs";
2
- import { Span, Tracer } from "@opentelemetry/api";
3
-
4
- //#region src/federation/webfinger.d.ts
5
- /**
6
- * Parameters for {@link handleWebFinger}.
7
- */
8
- interface WebFingerHandlerParameters<TContextData> {
9
- /**
10
- * The request context.
11
- */
12
- context: RequestContext<TContextData>;
13
- /**
14
- * The canonical hostname of the server, if it's explicitly configured.
15
- * @since 1.5.0
16
- */
17
- host?: string;
18
- /**
19
- * The callback for dispatching the actor.
20
- */
21
- actorDispatcher?: ActorDispatcher<TContextData>;
22
- /**
23
- * The callback for mapping a WebFinger username to the corresponding actor's
24
- * internal identifier, or `null` if the username is not found.
25
- * @since 0.15.0
26
- */
27
- actorHandleMapper?: ActorHandleMapper<TContextData>;
28
- /**
29
- * The callback for mapping a WebFinger query to the corresponding actor's
30
- * internal identifier or username, or `null` if the query is not found.
31
- * @since 1.4.0
32
- */
33
- actorAliasMapper?: ActorAliasMapper<TContextData>;
34
- /**
35
- * The callback for dispatching the Links of webFinger.
36
- */
37
- webFingerLinksDispatcher?: WebFingerLinksDispatcher<TContextData>;
38
- /**
39
- * The function to call when the actor is not found.
40
- */
41
- onNotFound(request: Request): Response | Promise<Response>;
42
- /**
43
- * The OpenTelemetry tracer.
44
- * @since 1.3.0
45
- */
46
- tracer?: Tracer;
47
- /**
48
- * The span for the request.
49
- * @since 1.3.0
50
- */
51
- span?: Span;
52
- }
53
- /**
54
- * Handles a WebFinger request. You would not typically call this function
55
- * directly, but instead use {@link Federation.fetch} method.
56
- * @param request The WebFinger request to handle.
57
- * @param parameters The parameters for handling the request.
58
- * @returns The response to the request.
59
- */
60
- declare function handleWebFinger<TContextData>(request: Request, options: WebFingerHandlerParameters<TContextData>): Promise<Response>;
61
- //#endregion
62
- export { WebFingerHandlerParameters, handleWebFinger };
@@ -1,266 +0,0 @@
1
- import { KeyCache } from "./http-CCEu-x1_.cjs";
2
- import { CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1 } from "@fedify/vocab";
3
- import { DocumentLoader } from "@fedify/vocab-runtime";
4
- import { TracerProvider } from "@opentelemetry/api";
5
-
6
- //#region src/sig/ld.d.ts
7
- /**
8
- * A signature of a JSON-LD document.
9
- * @since 1.0.0
10
- */
11
- interface Signature {
12
- "@context"?: "https://w3id.org/identity/v1";
13
- type: "RsaSignature2017";
14
- id?: string;
15
- creator: string;
16
- created: string;
17
- signatureValue: string;
18
- }
19
- /**
20
- * Attaches a LD signature to the given JSON-LD document.
21
- * @param jsonLd The JSON-LD document to attach the signature to. It is not
22
- * modified.
23
- * @param signature The signature to attach.
24
- * @returns The JSON-LD document with the attached signature.
25
- * @throws {TypeError} If the input document is not a valid JSON-LD document.
26
- * @since 1.0.0
27
- */
28
- declare function attachSignature(jsonLd: unknown, signature: Signature): {
29
- signature: Signature;
30
- };
31
- /**
32
- * Options for creating Linked Data Signatures.
33
- * @since 1.0.0
34
- */
35
- interface CreateSignatureOptions {
36
- /**
37
- * The context loader for loading remote JSON-LD contexts.
38
- */
39
- contextLoader?: DocumentLoader;
40
- /**
41
- * The time when the signature was created. If not specified, the current
42
- * time will be used.
43
- */
44
- created?: Temporal.Instant;
45
- }
46
- /**
47
- * Creates a LD signature for the given JSON-LD document.
48
- * @param jsonLd The JSON-LD document to sign.
49
- * @param privateKey The private key to sign the document.
50
- * @param keyId The ID of the public key that corresponds to the private key.
51
- * @param options Additional options for creating the signature.
52
- * See also {@link CreateSignatureOptions}.
53
- * @return The created signature.
54
- * @throws {TypeError} If the private key is invalid or unsupported.
55
- * @since 1.0.0
56
- */
57
- declare function createSignature(jsonLd: unknown, privateKey: CryptoKey, keyId: URL, {
58
- contextLoader,
59
- created
60
- }?: CreateSignatureOptions): Promise<Signature>;
61
- /**
62
- * Options for signing JSON-LD documents.
63
- * @since 1.0.0
64
- */
65
- interface SignJsonLdOptions extends CreateSignatureOptions {
66
- /**
67
- * The OpenTelemetry tracer provider for tracing the signing process.
68
- * If omitted, the global tracer provider is used.
69
- * @since 1.3.0
70
- */
71
- tracerProvider?: TracerProvider;
72
- }
73
- /**
74
- * Signs the given JSON-LD document with the private key and returns the signed
75
- * JSON-LD document.
76
- * @param jsonLd The JSON-LD document to sign.
77
- * @param privateKey The private key to sign the document.
78
- * @param keyId The key ID to use in the signature. It will be used by the
79
- * verifier to fetch the corresponding public key.
80
- * @param options Additional options for signing the document.
81
- * See also {@link SignJsonLdOptions}.
82
- * @returns The signed JSON-LD document.
83
- * @throws {TypeError} If the private key is invalid or unsupported.
84
- * @since 1.0.0
85
- */
86
- declare function signJsonLd(jsonLd: unknown, privateKey: CryptoKey, keyId: URL, options: SignJsonLdOptions): Promise<{
87
- signature: Signature;
88
- }>;
89
- /**
90
- * Detaches Linked Data Signatures from the given JSON-LD document.
91
- * @param jsonLd The JSON-LD document to modify.
92
- * @returns The modified JSON-LD document. If the input document does not
93
- * contain a signature, the original document is returned.
94
- * @since 1.0.0
95
- */
96
- declare function detachSignature(jsonLd: unknown): unknown;
97
- /**
98
- * Options for verifying Linked Data Signatures.
99
- * @since 1.0.0
100
- */
101
- interface VerifySignatureOptions {
102
- /**
103
- * The document loader to use for fetching the public key.
104
- */
105
- documentLoader?: DocumentLoader;
106
- /**
107
- * The context loader to use for JSON-LD context retrieval.
108
- */
109
- contextLoader?: DocumentLoader;
110
- /**
111
- * The key cache to use for caching public keys.
112
- */
113
- keyCache?: KeyCache;
114
- /**
115
- * The OpenTelemetry tracer provider for tracing the verification process.
116
- * If omitted, the global tracer provider is used.
117
- * @since 1.3.0
118
- */
119
- tracerProvider?: TracerProvider;
120
- }
121
- /**
122
- * Verifies Linked Data Signatures of the given JSON-LD document.
123
- * @param jsonLd The JSON-LD document to verify.
124
- * @param options Options for verifying the signature.
125
- * @returns The public key that signed the document or `null` if the signature
126
- * is invalid or the key is not found.
127
- * @since 1.0.0
128
- */
129
- declare function verifySignature(jsonLd: unknown, options?: VerifySignatureOptions): Promise<CryptographicKey | null>;
130
- /**
131
- * Options for verifying JSON-LD documents.
132
- */
133
- interface VerifyJsonLdOptions extends VerifySignatureOptions {}
134
- /**
135
- * Verify the authenticity of the given JSON-LD document using Linked Data
136
- * Signatures. If the document is signed, this function verifies the signature
137
- * and checks if the document is attributed to the owner of the public key.
138
- * If the document is not signed, this function returns `false`.
139
- * @param jsonLd The JSON-LD document to verify.
140
- * @param options Options for verifying the document.
141
- * @returns `true` if the document is authentic; `false` otherwise.
142
- */
143
- declare function verifyJsonLd(jsonLd: unknown, options?: VerifyJsonLdOptions): Promise<boolean>;
144
- //#endregion
145
- //#region src/sig/proof.d.ts
146
- /**
147
- * Options for {@link createProof}.
148
- * @since 0.10.0
149
- */
150
- interface CreateProofOptions {
151
- /**
152
- * The context loader for loading remote JSON-LD contexts.
153
- */
154
- contextLoader?: DocumentLoader;
155
- /**
156
- * The JSON-LD context to use for serializing the object to sign.
157
- */
158
- context?: string | Record<string, string> | (string | Record<string, string>)[];
159
- /**
160
- * The time when the proof was created. If not specified, the current time
161
- * will be used.
162
- */
163
- created?: Temporal.Instant;
164
- }
165
- /**
166
- * Creates a proof for the given object.
167
- * @param object The object to create a proof for.
168
- * @param privateKey The private key to sign the proof with.
169
- * @param keyId The key ID to use in the proof. It will be used by the verifier.
170
- * @param options Additional options. See also {@link CreateProofOptions}.
171
- * @returns The created proof.
172
- * @throws {TypeError} If the private key is invalid or unsupported.
173
- * @since 0.10.0
174
- */
175
- declare function createProof(object: Object$1, privateKey: CryptoKey, keyId: URL, {
176
- contextLoader,
177
- context,
178
- created
179
- }?: CreateProofOptions): Promise<DataIntegrityProof>;
180
- /**
181
- * Options for {@link signObject}.
182
- * @since 0.10.0
183
- */
184
- interface SignObjectOptions extends CreateProofOptions {
185
- /**
186
- * The document loader for loading remote JSON-LD documents.
187
- */
188
- documentLoader?: DocumentLoader;
189
- /**
190
- * The OpenTelemetry tracer provider. If omitted, the global tracer provider
191
- * is used.
192
- * @since 1.3.0
193
- */
194
- tracerProvider?: TracerProvider;
195
- }
196
- /**
197
- * Signs the given object with the private key and returns the signed object.
198
- * @param object The object to create a proof for.
199
- * @param privateKey The private key to sign the proof with.
200
- * @param keyId The key ID to use in the proof. It will be used by the verifier.
201
- * @param options Additional options. See also {@link SignObjectOptions}.
202
- * @returns The signed object.
203
- * @throws {TypeError} If the private key is invalid or unsupported.
204
- * @since 0.10.0
205
- */
206
- declare function signObject<T extends Object$1>(object: T, privateKey: CryptoKey, keyId: URL, options?: SignObjectOptions): Promise<T>;
207
- /**
208
- * Options for {@link verifyProof}.
209
- * @since 0.10.0
210
- */
211
- interface VerifyProofOptions {
212
- /**
213
- * The context loader for loading remote JSON-LD contexts.
214
- */
215
- contextLoader?: DocumentLoader;
216
- /**
217
- * The document loader for loading remote JSON-LD documents.
218
- */
219
- documentLoader?: DocumentLoader;
220
- /**
221
- * The key cache to use for caching public keys.
222
- * @since 0.12.0
223
- */
224
- keyCache?: KeyCache;
225
- /**
226
- * The OpenTelemetry tracer provider. If omitted, the global tracer provider
227
- * is used.
228
- * @since 1.3.0
229
- */
230
- tracerProvider?: TracerProvider;
231
- }
232
- /**
233
- * Verifies the given proof for the object.
234
- * @param jsonLd The JSON-LD object to verify the proof for. If it contains
235
- * any proofs, they will be ignored.
236
- * @param proof The proof to verify.
237
- * @param options Additional options. See also {@link VerifyProofOptions}.
238
- * @returns The public key that was used to sign the proof, or `null` if the
239
- * proof is invalid.
240
- * @since 0.10.0
241
- */
242
- declare function verifyProof(jsonLd: unknown, proof: DataIntegrityProof, options?: VerifyProofOptions): Promise<Multikey | null>;
243
- /**
244
- * Options for {@link verifyObject}.
245
- * @since 0.10.0
246
- */
247
- interface VerifyObjectOptions extends VerifyProofOptions {}
248
- /**
249
- * Verifies the given object. It will verify all the proofs in the object,
250
- * and succeed only if all the proofs are valid and all attributions and
251
- * actors are authenticated by the proofs.
252
- * @template T The type of the object to verify.
253
- * @param cls The class of the object to verify. It must be a subclass of
254
- * the {@link Object}.
255
- * @param jsonLd The JSON-LD object to verify. It's assumed that the object
256
- * is a compacted JSON-LD representation of a `T` with `@context`.
257
- * @param options Additional options. See also {@link VerifyObjectOptions}.
258
- * @returns The object if it's verified, or `null` if it's not.
259
- * @throws {TypeError} If the object is invalid or unsupported.
260
- * @since 0.10.0
261
- */
262
- declare function verifyObject<T extends Object$1>(cls: (new (...args: any[]) => T) & {
263
- fromJsonLd(jsonLd: unknown, options: VerifyObjectOptions): Promise<T>;
264
- }, jsonLd: unknown, options?: VerifyObjectOptions): Promise<T | null>;
265
- //#endregion
266
- export { CreateProofOptions, CreateSignatureOptions, SignJsonLdOptions, SignObjectOptions, VerifyJsonLdOptions, VerifyObjectOptions, VerifyProofOptions, VerifySignatureOptions, attachSignature, createProof, createSignature, detachSignature, signJsonLd, signObject, verifyJsonLd, verifyObject, verifyProof, verifySignature };
@@ -1,91 +0,0 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
3
- import { HttpMessageSignaturesSpecDeterminer } from "./http-CODSJcKx.js";
4
- import { KvKey, KvStore } from "./kv-jg_8SMc1.js";
5
- import { TracerProvider } from "@opentelemetry/api";
6
- import { DocumentLoader, DocumentLoaderFactoryOptions } from "@fedify/vocab-runtime";
7
-
8
- //#region src/utils/docloader.d.ts
9
- /**
10
- * Options for {@link getAuthenticatedDocumentLoader}.
11
- * @see {@link getAuthenticatedDocumentLoader}
12
- * @since 1.3.0
13
- */
14
- interface GetAuthenticatedDocumentLoaderOptions extends DocumentLoaderFactoryOptions {
15
- /**
16
- * An optional spec determiner for HTTP Message Signatures.
17
- * It determines the spec to use for signing requests.
18
- * It is used for double-knocking
19
- * (see <https://swicg.github.io/activitypub-http-signature/#how-to-upgrade-supported-versions>).
20
- * @since 1.6.0
21
- */
22
- specDeterminer?: HttpMessageSignaturesSpecDeterminer;
23
- /**
24
- * The OpenTelemetry tracer provider. If omitted, the global tracer provider
25
- * is used.
26
- * @since 1.6.0
27
- */
28
- tracerProvider?: TracerProvider;
29
- }
30
- /**
31
- * Gets an authenticated {@link DocumentLoader} for the given identity.
32
- * Note that an authenticated document loader intentionally does not cache
33
- * the fetched documents.
34
- * @param identity The identity to get the document loader for.
35
- * The actor's key pair.
36
- * @param options The options for the document loader.
37
- * @returns The authenticated document loader.
38
- * @throws {TypeError} If the key is invalid or unsupported.
39
- * @since 0.4.0
40
- */
41
- declare function getAuthenticatedDocumentLoader(identity: {
42
- keyId: URL;
43
- privateKey: CryptoKey;
44
- }, {
45
- allowPrivateAddress,
46
- userAgent,
47
- specDeterminer,
48
- tracerProvider
49
- }?: GetAuthenticatedDocumentLoaderOptions): DocumentLoader;
50
- //#endregion
51
- //#region src/utils/kv-cache.d.ts
52
- /**
53
- * The parameters for {@link kvCache} function.
54
- */
55
- interface KvCacheParameters {
56
- /**
57
- * The document loader to decorate with a cache.
58
- */
59
- readonly loader: DocumentLoader;
60
- /**
61
- * The key–value store to use for backing the cache.
62
- */
63
- readonly kv: KvStore;
64
- /**
65
- * The key prefix to use for namespacing the cache.
66
- * `["_fedify", "remoteDocument"]` by default.
67
- */
68
- readonly prefix?: KvKey;
69
- /**
70
- * The per-URL cache rules in the array of `[urlPattern, duration]` pairs
71
- * where `urlPattern` is either a string, a {@link URL}, or
72
- * a {@link URLPattern} and `duration` is a {@link Temporal.DurationLike}.
73
- * The `duration` is allowed to be at most 30 days.
74
- *
75
- * By default, 5 minutes for all URLs.
76
- */
77
- readonly rules?: readonly [string | URL | URLPattern, Temporal.Duration | Temporal.DurationLike][];
78
- }
79
- /**
80
- * Decorates a {@link DocumentLoader} with a cache backed by a {@link KvStore}.
81
- * @param parameters The parameters for the cache.
82
- * @returns The decorated document loader which is cache-enabled.
83
- */
84
- declare function kvCache({
85
- loader,
86
- kv,
87
- prefix,
88
- rules
89
- }: KvCacheParameters): DocumentLoader;
90
- //#endregion
91
- export { getAuthenticatedDocumentLoader, kvCache };
@@ -1,64 +0,0 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
3
- import { ActorAliasMapper, ActorDispatcher, ActorHandleMapper, RequestContext, WebFingerLinksDispatcher } from "./context-C-GVKcJR.js";
4
- import { Span, Tracer } from "@opentelemetry/api";
5
-
6
- //#region src/federation/webfinger.d.ts
7
- /**
8
- * Parameters for {@link handleWebFinger}.
9
- */
10
- interface WebFingerHandlerParameters<TContextData> {
11
- /**
12
- * The request context.
13
- */
14
- context: RequestContext<TContextData>;
15
- /**
16
- * The canonical hostname of the server, if it's explicitly configured.
17
- * @since 1.5.0
18
- */
19
- host?: string;
20
- /**
21
- * The callback for dispatching the actor.
22
- */
23
- actorDispatcher?: ActorDispatcher<TContextData>;
24
- /**
25
- * The callback for mapping a WebFinger username to the corresponding actor's
26
- * internal identifier, or `null` if the username is not found.
27
- * @since 0.15.0
28
- */
29
- actorHandleMapper?: ActorHandleMapper<TContextData>;
30
- /**
31
- * The callback for mapping a WebFinger query to the corresponding actor's
32
- * internal identifier or username, or `null` if the query is not found.
33
- * @since 1.4.0
34
- */
35
- actorAliasMapper?: ActorAliasMapper<TContextData>;
36
- /**
37
- * The callback for dispatching the Links of webFinger.
38
- */
39
- webFingerLinksDispatcher?: WebFingerLinksDispatcher<TContextData>;
40
- /**
41
- * The function to call when the actor is not found.
42
- */
43
- onNotFound(request: Request): Response | Promise<Response>;
44
- /**
45
- * The OpenTelemetry tracer.
46
- * @since 1.3.0
47
- */
48
- tracer?: Tracer;
49
- /**
50
- * The span for the request.
51
- * @since 1.3.0
52
- */
53
- span?: Span;
54
- }
55
- /**
56
- * Handles a WebFinger request. You would not typically call this function
57
- * directly, but instead use {@link Federation.fetch} method.
58
- * @param request The WebFinger request to handle.
59
- * @param parameters The parameters for handling the request.
60
- * @returns The response to the request.
61
- */
62
- declare function handleWebFinger<TContextData>(request: Request, options: WebFingerHandlerParameters<TContextData>): Promise<Response>;
63
- //#endregion
64
- export { WebFingerHandlerParameters, handleWebFinger };