@forgezero/providers 0.1.33 → 0.1.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billing.js +1 -1
- package/dist/database.js +1 -1
- package/dist/email.js +1 -1
- package/dist/git.js +1 -1
- package/dist/http.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/pool.js +1 -1
- package/dist/realtime.d.ts +7 -1
- package/dist/realtime.js +4 -2
- package/dist/storage.js +1 -1
- package/dist/translation.js +1 -1
- package/package.json +5 -2
package/dist/billing.js
CHANGED
package/dist/database.js
CHANGED
package/dist/email.js
CHANGED
package/dist/git.js
CHANGED
package/dist/http.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/pool.js
CHANGED
package/dist/realtime.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { type RealtimeBatch } from '@forgezero/runtime/realtime';
|
|
2
|
+
import { type NodeKeyPair } from '@forgezero/runtime/identity';
|
|
2
3
|
export interface RealtimeProviderOptions {
|
|
3
4
|
endpoint: string;
|
|
4
|
-
|
|
5
|
+
/** Legacy v2 compatibility credential. Removed after every edge reports v3. */
|
|
6
|
+
secret?: string;
|
|
7
|
+
identity?: Readonly<{
|
|
8
|
+
nodeKey: string;
|
|
9
|
+
keys: NodeKeyPair;
|
|
10
|
+
}>;
|
|
5
11
|
producer: string;
|
|
6
12
|
requestTimeoutMs?: number;
|
|
7
13
|
fetcher?: typeof fetch;
|
package/dist/realtime.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/realtime.ts
|
|
2
2
|
import { realtimeBatchBytes, realtimeHmac, validateRealtimeBatch } from "@forgezero/runtime/realtime";
|
|
3
|
+
import { encodeSignatureHeader, signRequest } from "@forgezero/runtime/identity";
|
|
3
4
|
|
|
4
5
|
class RealtimeProviderError extends Error {
|
|
5
6
|
code;
|
|
@@ -12,7 +13,7 @@ class RealtimeProviderError extends Error {
|
|
|
12
13
|
var producerPattern = /^[A-Za-z0-9][A-Za-z0-9_.:@/-]{0,127}$/;
|
|
13
14
|
function cloudflareRealtime(options) {
|
|
14
15
|
const endpoint = new URL(options.endpoint);
|
|
15
|
-
if (endpoint.protocol !== "https:" || endpoint.username || endpoint.password || endpoint.search || endpoint.hash || !producerPattern.test(options.producer) || new TextEncoder().encode(options.secret).byteLength < 32) {
|
|
16
|
+
if (endpoint.protocol !== "https:" || endpoint.username || endpoint.password || endpoint.search || endpoint.hash || !producerPattern.test(options.producer) || !options.identity && new TextEncoder().encode(options.secret ?? "").byteLength < 32 || options.identity && options.identity.nodeKey !== options.producer) {
|
|
16
17
|
throw new RealtimeProviderError("INVALID_CONFIG", "Realtime endpoint, producer, or secret is invalid.");
|
|
17
18
|
}
|
|
18
19
|
endpoint.pathname = "/__fz/realtime/publish";
|
|
@@ -26,7 +27,7 @@ function cloudflareRealtime(options) {
|
|
|
26
27
|
const batch = validateRealtimeBatch(input);
|
|
27
28
|
const body = realtimeBatchBytes(batch);
|
|
28
29
|
const timestamp = Math.floor(Date.now() / 1000).toString();
|
|
29
|
-
const signature = await realtimeHmac(options.secret, `publish
|
|
30
|
+
const signature = options.identity ? encodeSignatureHeader(signRequest(options.identity.keys, options.identity.nodeKey, { method: "POST", path: endpoint.pathname, query: "", body })) : await realtimeHmac(options.secret, `publish
|
|
30
31
|
${options.producer}
|
|
31
32
|
${timestamp}
|
|
32
33
|
${body}`);
|
|
@@ -42,6 +43,7 @@ ${body}`);
|
|
|
42
43
|
"x-fz-realtime-producer": options.producer,
|
|
43
44
|
"x-fz-realtime-timestamp": timestamp,
|
|
44
45
|
"x-fz-realtime-signature": signature,
|
|
46
|
+
...options.identity ? { "x-fz-node-key": options.identity.nodeKey } : {},
|
|
45
47
|
"idempotency-key": batch.batchId
|
|
46
48
|
}
|
|
47
49
|
});
|
package/dist/storage.js
CHANGED
package/dist/translation.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgezero/providers",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -85,6 +85,9 @@
|
|
|
85
85
|
"LICENSE"
|
|
86
86
|
],
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@forgezero/runtime": "^0.1.
|
|
88
|
+
"@forgezero/runtime": "^0.1.26",
|
|
89
|
+
"@noble/curves": "2.2.0",
|
|
90
|
+
"@noble/hashes": "2.2.0",
|
|
91
|
+
"@noble/post-quantum": "0.6.1"
|
|
89
92
|
}
|
|
90
93
|
}
|