@dvmkit/sdk 0.4.0-rc.1 → 0.5.0-rc.1
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/{chunk-TXX4GOUB.js → chunk-7ZUKL4IV.js} +1 -1
- package/dist/{chunk-KXZUCCEY.js → chunk-A4YFWZ7R.js} +4 -55
- package/dist/{chunk-2VGWYG4P.js → chunk-B2IROPQF.js} +446 -81
- package/dist/{chunk-K2YX2VRA.js → chunk-EYTHFFFU.js} +14 -12
- package/dist/{chunk-74PUEZJ4.js → chunk-GFY5FRX3.js} +1 -1
- package/dist/{chunk-W2EQGDF5.js → chunk-LE74UEV7.js} +49 -8
- package/dist/chunk-OFVV37XC.js +57 -0
- package/dist/{chunk-3MHE725Z.js → chunk-PAIM66YA.js} +90 -1
- package/dist/{chunk-5LR6P7WN.js → chunk-TUA7PYH7.js} +23 -103
- package/dist/{chunk-O3QDFPKM.js → chunk-TZ2WKCDD.js} +1 -1
- package/dist/{chunk-R4DQZFAL.js → chunk-UOCZXO2Z.js} +3 -3
- package/dist/{chunk-CE7XEHYC.js → chunk-Z4KLECAC.js} +1 -1
- package/dist/{credit-menu-B8_p_vUz.d.ts → credit-menu-CAfqe8IY.d.ts} +4 -4
- package/dist/{fx-DuaYHvVn.d.ts → fx-D9nsN3n4.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +4 -3
- package/dist/internal/caller.d.ts +80 -13
- package/dist/internal/caller.js +36 -38
- package/dist/internal/index.js +1 -1
- package/dist/internal/server.d.ts +8 -8
- package/dist/internal/server.js +7 -6
- package/dist/{job-store-D6Rjj5Oi.d.ts → job-store-Bx-VFRjg.d.ts} +1 -1
- package/dist/{lightning-backend-BaeCPmx7.d.ts → lightning-backend-BAx2Y8pP.d.ts} +1 -1
- package/dist/server/index.d.ts +8 -8
- package/dist/server/index.js +6 -5
- package/dist/{step-cache-Bi43A0JN.d.ts → step-cache-QG_h5-3G.d.ts} +1 -1
- package/dist/{tempo-lifecycle-OTHV757Y.js → tempo-lifecycle-ZBBLFBMH.js} +5 -4
- package/dist/{tempo-wallet-32JWQZKQ.js → tempo-wallet-B5XXV3YH.js} +1 -1
- package/dist/testing/index.d.ts +2 -2
- package/dist/{usd-AZPVq4eU.d.ts → usd-EwRqCPF-.d.ts} +1 -1
- package/dist/{x402-CEDHGZDI.js → x402-R6HPBY5D.js} +5 -4
- package/package.json +1 -1
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
canonicaliseForSigning
|
|
3
|
+
} from "./chunk-OFVV37XC.js";
|
|
4
|
+
|
|
1
5
|
// src/sdk/types.ts
|
|
2
6
|
function isZodSchema(value) {
|
|
3
7
|
return typeof value === "object" && value !== null && "_zod" in value && "parse" in value && "safeParse" in value;
|
|
@@ -12,58 +16,6 @@ var DEFAULT_CREDIT_MAX = "$5.00";
|
|
|
12
16
|
var DEFAULT_CREDIT_TTL_SECONDS = 30 * 24 * 60 * 60;
|
|
13
17
|
var DEFAULT_JOB_RETENTION_DAYS = 90;
|
|
14
18
|
|
|
15
|
-
// src/lib/cast-auth/canonical-json.ts
|
|
16
|
-
function canonicalize(value) {
|
|
17
|
-
return JSON.stringify(sortDeep(value));
|
|
18
|
-
}
|
|
19
|
-
function canonicaliseForSigning(value) {
|
|
20
|
-
return new TextEncoder().encode(canonicalize(value));
|
|
21
|
-
}
|
|
22
|
-
function sortDeep(value) {
|
|
23
|
-
if (value === null) return null;
|
|
24
|
-
if (typeof value === "string" || typeof value === "boolean") return value;
|
|
25
|
-
if (typeof value === "number") {
|
|
26
|
-
if (!Number.isFinite(value)) {
|
|
27
|
-
throw new TypeError(`canonicalize: non-finite number is not JSON-serialisable`);
|
|
28
|
-
}
|
|
29
|
-
return value;
|
|
30
|
-
}
|
|
31
|
-
if (Array.isArray(value)) return value.map(sortDeep);
|
|
32
|
-
if (typeof value === "object") {
|
|
33
|
-
const sorted = {};
|
|
34
|
-
for (const key of Object.keys(value).sort()) {
|
|
35
|
-
const v = value[key];
|
|
36
|
-
if (v === void 0) continue;
|
|
37
|
-
sorted[key] = sortDeep(v);
|
|
38
|
-
}
|
|
39
|
-
return sorted;
|
|
40
|
-
}
|
|
41
|
-
throw new TypeError(`canonicalize: unsupported value of type ${typeof value}`);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// src/lib/cast-auth/verify.ts
|
|
45
|
-
import { schnorr } from "@noble/curves/secp256k1.js";
|
|
46
|
-
function verifyCanonicalSignedRequest(payload, signatureHex, pubkeyHex) {
|
|
47
|
-
if (!/^[0-9a-f]{64}$/i.test(pubkeyHex) || !/^[0-9a-f]{128}$/i.test(signatureHex)) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
const data = canonicaliseForSigning(payload);
|
|
51
|
-
const signature = hexToBytes(signatureHex);
|
|
52
|
-
const pubkey = hexToBytes(pubkeyHex);
|
|
53
|
-
try {
|
|
54
|
-
return schnorr.verify(signature, data, pubkey);
|
|
55
|
-
} catch {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function hexToBytes(hex) {
|
|
60
|
-
const out = new Uint8Array(hex.length / 2);
|
|
61
|
-
for (let i = 0; i < out.length; i++) {
|
|
62
|
-
out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);
|
|
63
|
-
}
|
|
64
|
-
return out;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
19
|
// src/lib/signed-request-statement.ts
|
|
68
20
|
var SIGNED_REQUEST_AUTH_ID = "secp256k1-schnorr-v2";
|
|
69
21
|
var SIGNED_REQUEST_STATEMENT_VERSION = 2;
|
|
@@ -129,9 +81,6 @@ export {
|
|
|
129
81
|
DEFAULT_CREDIT_MAX,
|
|
130
82
|
DEFAULT_CREDIT_TTL_SECONDS,
|
|
131
83
|
DEFAULT_JOB_RETENTION_DAYS,
|
|
132
|
-
canonicalize,
|
|
133
|
-
canonicaliseForSigning,
|
|
134
|
-
verifyCanonicalSignedRequest,
|
|
135
84
|
SIGNED_REQUEST_AUTH_ID,
|
|
136
85
|
SIGNED_REQUEST_STATEMENT_VERSION,
|
|
137
86
|
signedRequestStatementHeader,
|