@vorim/sdk 3.19.0 → 3.22.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.
- package/CHANGELOG.md +49 -0
- package/README.md +73 -1
- package/dist/index.cjs +261 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +140 -3
- package/dist/index.d.ts +140 -3
- package/dist/index.js +253 -9
- package/dist/index.js.map +1 -1
- package/dist/integrations/anthropic.d.cts +2 -1
- package/dist/integrations/anthropic.d.ts +2 -1
- package/dist/integrations/ap2.d.cts +2 -1
- package/dist/integrations/ap2.d.ts +2 -1
- package/dist/integrations/aws-iam.d.cts +2 -1
- package/dist/integrations/aws-iam.d.ts +2 -1
- package/dist/integrations/bank-rails.d.cts +2 -1
- package/dist/integrations/bank-rails.d.ts +2 -1
- package/dist/integrations/circle.d.cts +2 -1
- package/dist/integrations/circle.d.ts +2 -1
- package/dist/integrations/cloudflare.d.cts +2 -1
- package/dist/integrations/cloudflare.d.ts +2 -1
- package/dist/integrations/coinbase-cdp.d.cts +2 -1
- package/dist/integrations/coinbase-cdp.d.ts +2 -1
- package/dist/integrations/commerce-agents.cjs +467 -0
- package/dist/integrations/commerce-agents.cjs.map +1 -0
- package/dist/integrations/commerce-agents.d.cts +200 -0
- package/dist/integrations/commerce-agents.d.ts +200 -0
- package/dist/integrations/commerce-agents.js +429 -0
- package/dist/integrations/commerce-agents.js.map +1 -0
- package/dist/integrations/crewai.d.cts +2 -1
- package/dist/integrations/crewai.d.ts +2 -1
- package/dist/integrations/entra.d.cts +2 -1
- package/dist/integrations/entra.d.ts +2 -1
- package/dist/integrations/fhir.d.cts +2 -1
- package/dist/integrations/fhir.d.ts +2 -1
- package/dist/integrations/grok.d.cts +2 -1
- package/dist/integrations/grok.d.ts +2 -1
- package/dist/integrations/guidewire.d.cts +2 -1
- package/dist/integrations/guidewire.d.ts +2 -1
- package/dist/integrations/hermes.d.cts +2 -1
- package/dist/integrations/hermes.d.ts +2 -1
- package/dist/integrations/jira.d.cts +2 -1
- package/dist/integrations/jira.d.ts +2 -1
- package/dist/integrations/langchain.d.cts +2 -1
- package/dist/integrations/langchain.d.ts +2 -1
- package/dist/integrations/langgraph.d.cts +2 -1
- package/dist/integrations/langgraph.d.ts +2 -1
- package/dist/integrations/legal.d.cts +2 -1
- package/dist/integrations/legal.d.ts +2 -1
- package/dist/integrations/life-sciences.d.cts +2 -1
- package/dist/integrations/life-sciences.d.ts +2 -1
- package/dist/integrations/linear.d.cts +2 -1
- package/dist/integrations/linear.d.ts +2 -1
- package/dist/integrations/lithic.d.cts +2 -1
- package/dist/integrations/lithic.d.ts +2 -1
- package/dist/integrations/llamaindex.d.cts +2 -1
- package/dist/integrations/llamaindex.d.ts +2 -1
- package/dist/integrations/marqeta.d.cts +2 -1
- package/dist/integrations/marqeta.d.ts +2 -1
- package/dist/integrations/modern-treasury.d.cts +2 -1
- package/dist/integrations/modern-treasury.d.ts +2 -1
- package/dist/integrations/muse.cjs +437 -0
- package/dist/integrations/muse.cjs.map +1 -0
- package/dist/integrations/muse.d.cts +72 -0
- package/dist/integrations/muse.d.ts +72 -0
- package/dist/integrations/muse.js +394 -0
- package/dist/integrations/muse.js.map +1 -0
- package/dist/integrations/nekuda.d.cts +2 -1
- package/dist/integrations/nekuda.d.ts +2 -1
- package/dist/integrations/okta.d.cts +2 -1
- package/dist/integrations/okta.d.ts +2 -1
- package/dist/integrations/openai.d.cts +2 -1
- package/dist/integrations/openai.d.ts +2 -1
- package/dist/integrations/openrouter.d.cts +2 -1
- package/dist/integrations/openrouter.d.ts +2 -1
- package/dist/integrations/paypal-agent.d.cts +2 -1
- package/dist/integrations/paypal-agent.d.ts +2 -1
- package/dist/integrations/perplexity.d.cts +2 -1
- package/dist/integrations/perplexity.d.ts +2 -1
- package/dist/integrations/plaid.d.cts +2 -1
- package/dist/integrations/plaid.d.ts +2 -1
- package/dist/integrations/ramp.d.cts +2 -1
- package/dist/integrations/ramp.d.ts +2 -1
- package/dist/integrations/shopify.d.cts +2 -1
- package/dist/integrations/shopify.d.ts +2 -1
- package/dist/integrations/siem.d.cts +1 -1
- package/dist/integrations/siem.d.ts +1 -1
- package/dist/integrations/skyfire.d.cts +2 -1
- package/dist/integrations/skyfire.d.ts +2 -1
- package/dist/integrations/stripe-acp.d.cts +2 -1
- package/dist/integrations/stripe-acp.d.ts +2 -1
- package/dist/integrations/stripe-issuing.d.cts +2 -1
- package/dist/integrations/stripe-issuing.d.ts +2 -1
- package/dist/integrations/truanon.d.cts +2 -1
- package/dist/integrations/truanon.d.ts +2 -1
- package/dist/integrations/typesafe.cjs +268 -0
- package/dist/integrations/typesafe.cjs.map +1 -0
- package/dist/integrations/typesafe.d.cts +145 -0
- package/dist/integrations/typesafe.d.ts +145 -0
- package/dist/integrations/typesafe.js +221 -0
- package/dist/integrations/typesafe.js.map +1 -0
- package/dist/integrations/ucp.d.cts +2 -1
- package/dist/integrations/ucp.d.ts +2 -1
- package/dist/integrations/vercel-ai.d.cts +2 -1
- package/dist/integrations/vercel-ai.d.ts +2 -1
- package/dist/integrations/x402.d.cts +2 -1
- package/dist/integrations/x402.d.ts +2 -1
- package/dist/{types-BmeluKHI.d.cts → types-BrDQAJdl.d.cts} +36 -1
- package/dist/{types-BmeluKHI.d.ts → types-BrDQAJdl.d.ts} +36 -1
- package/package.json +31 -1
package/dist/index.js
CHANGED
|
@@ -74,8 +74,122 @@ async function prepareReplayContext(inputs) {
|
|
|
74
74
|
return ctx;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
// ../shared-types/src/index.ts
|
|
78
|
+
function jcsCanonicalise2(value) {
|
|
79
|
+
if (value === null) return "null";
|
|
80
|
+
if (value === true) return "true";
|
|
81
|
+
if (value === false) return "false";
|
|
82
|
+
if (typeof value === "number") {
|
|
83
|
+
if (!Number.isFinite(value)) {
|
|
84
|
+
throw new Error("jcsCanonicalise: NaN and Infinity are not JCS-valid");
|
|
85
|
+
}
|
|
86
|
+
const abs = Math.abs(value);
|
|
87
|
+
if (value !== 0 && (abs >= 1e21 || abs < 1e-4 || Number.isInteger(value) && abs > 2 ** 53)) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`jcsCanonicalise: numbers in the ranges where JS and Python formatting diverge (|x| >= 1e21, |x| < 1e-4, or integer |x| > 2^53) are not supported in signed metadata. Use a string instead of ${value}.`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return value.toString();
|
|
93
|
+
}
|
|
94
|
+
if (typeof value === "string") {
|
|
95
|
+
return JSON.stringify(value);
|
|
96
|
+
}
|
|
97
|
+
if (Array.isArray(value)) {
|
|
98
|
+
return "[" + value.map(jcsCanonicalise2).join(",") + "]";
|
|
99
|
+
}
|
|
100
|
+
if (typeof value === "object") {
|
|
101
|
+
const obj = value;
|
|
102
|
+
const keys = Object.keys(obj).filter((k) => obj[k] !== void 0).sort();
|
|
103
|
+
const parts = keys.map((k) => JSON.stringify(k) + ":" + jcsCanonicalise2(obj[k]));
|
|
104
|
+
return "{" + parts.join(",") + "}";
|
|
105
|
+
}
|
|
106
|
+
throw new Error(`jcsCanonicalise: unsupported value type: ${typeof value}`);
|
|
107
|
+
}
|
|
108
|
+
function portableReceiptCanonicalBytes(receipt) {
|
|
109
|
+
return jcsCanonicalise2({
|
|
110
|
+
version: receipt.version,
|
|
111
|
+
org_id: receipt.org_id,
|
|
112
|
+
issued_at: receipt.issued_at,
|
|
113
|
+
canonical_form: receipt.canonical_form,
|
|
114
|
+
decision: {
|
|
115
|
+
decision_id: receipt.decision.decision_id,
|
|
116
|
+
verdict: receipt.decision.verdict,
|
|
117
|
+
agent_id: receipt.decision.agent_id,
|
|
118
|
+
required_scope: receipt.decision.required_scope,
|
|
119
|
+
action_type: receipt.decision.action_type,
|
|
120
|
+
action_target: receipt.decision.action_target,
|
|
121
|
+
policy_version: receipt.decision.policy_version,
|
|
122
|
+
decision_rule_id: receipt.decision.decision_rule_id,
|
|
123
|
+
requested_at: receipt.decision.requested_at,
|
|
124
|
+
expires_at: receipt.decision.expires_at
|
|
125
|
+
},
|
|
126
|
+
binding: {
|
|
127
|
+
original_intent_hash: receipt.binding.original_intent_hash,
|
|
128
|
+
effective_intent_hash: receipt.binding.effective_intent_hash,
|
|
129
|
+
policy_modified: receipt.binding.policy_modified
|
|
130
|
+
},
|
|
131
|
+
approval: receipt.approval === null ? null : {
|
|
132
|
+
resolution: receipt.approval.resolution,
|
|
133
|
+
resolved_at: receipt.approval.resolved_at,
|
|
134
|
+
approver_ref: receipt.approval.approver_ref,
|
|
135
|
+
alg: receipt.approval.alg,
|
|
136
|
+
kid: receipt.approval.kid,
|
|
137
|
+
signature: receipt.approval.signature
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// src/commit.ts
|
|
143
|
+
var HMAC_SHA256_PREFIX = "hmac-sha256:";
|
|
144
|
+
var SHA256_PREFIX = "sha256:";
|
|
145
|
+
function toBytes(v) {
|
|
146
|
+
return typeof v === "string" ? new TextEncoder().encode(v) : v;
|
|
147
|
+
}
|
|
148
|
+
function toHex(buf) {
|
|
149
|
+
return Array.from(buf instanceof Uint8Array ? buf : new Uint8Array(buf)).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
150
|
+
}
|
|
151
|
+
async function hashPayload(content) {
|
|
152
|
+
const bytes = toBytes(content);
|
|
153
|
+
const subtle = globalThis.crypto?.subtle;
|
|
154
|
+
if (subtle) {
|
|
155
|
+
return SHA256_PREFIX + toHex(await subtle.digest("SHA-256", bytes));
|
|
156
|
+
}
|
|
157
|
+
const nodeCrypto = await import("crypto");
|
|
158
|
+
return SHA256_PREFIX + nodeCrypto.createHash("sha256").update(bytes).digest("hex");
|
|
159
|
+
}
|
|
160
|
+
async function commitPayload(content, key) {
|
|
161
|
+
const keyBytes = toBytes(key);
|
|
162
|
+
if (keyBytes.length === 0) {
|
|
163
|
+
throw new Error(
|
|
164
|
+
"commitPayload: key must not be empty. An empty key makes the commitment no stronger than hashPayload while labelling it as keyed."
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
const bytes = toBytes(content);
|
|
168
|
+
const subtle = globalThis.crypto?.subtle;
|
|
169
|
+
if (subtle) {
|
|
170
|
+
const cryptoKey = await subtle.importKey(
|
|
171
|
+
"raw",
|
|
172
|
+
keyBytes,
|
|
173
|
+
{ name: "HMAC", hash: "SHA-256" },
|
|
174
|
+
false,
|
|
175
|
+
["sign"]
|
|
176
|
+
);
|
|
177
|
+
const sig = await subtle.sign("HMAC", cryptoKey, bytes);
|
|
178
|
+
return HMAC_SHA256_PREFIX + toHex(sig);
|
|
179
|
+
}
|
|
180
|
+
const nodeCrypto = await import("crypto");
|
|
181
|
+
return HMAC_SHA256_PREFIX + nodeCrypto.createHmac("sha256", keyBytes).update(bytes).digest("hex");
|
|
182
|
+
}
|
|
183
|
+
function isKeyedCommitment(digest) {
|
|
184
|
+
return typeof digest === "string" && digest.startsWith(HMAC_SHA256_PREFIX);
|
|
185
|
+
}
|
|
186
|
+
var DIGEST_RE = /^(?:sha256|hmac-sha256):[0-9a-f]{64}$/;
|
|
187
|
+
function isDigest(digest) {
|
|
188
|
+
return typeof digest === "string" && DIGEST_RE.test(digest);
|
|
189
|
+
}
|
|
190
|
+
|
|
77
191
|
// src/index.ts
|
|
78
|
-
var SDK_VERSION = true ? "3.
|
|
192
|
+
var SDK_VERSION = true ? "3.22.0" : "0.0.0";
|
|
79
193
|
var USER_AGENT = `vorim-sdk/${SDK_VERSION}`;
|
|
80
194
|
function sleep(ms) {
|
|
81
195
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -94,6 +208,30 @@ function canonicalPayloadV1(event) {
|
|
|
94
208
|
const { signature: _sig, canonical_form: _cf, ...rest } = event;
|
|
95
209
|
return jcsCanonicalise(rest);
|
|
96
210
|
}
|
|
211
|
+
async function eventDigest(event) {
|
|
212
|
+
const form = event.canonical_form ?? "v0";
|
|
213
|
+
const bytes = form === "v1" ? canonicalPayloadV1(event) : canonicalPayloadV0(event);
|
|
214
|
+
return hashPreviousEvent(bytes);
|
|
215
|
+
}
|
|
216
|
+
function idempotencyHeader(key) {
|
|
217
|
+
return key ? { "Idempotency-Key": key } : void 0;
|
|
218
|
+
}
|
|
219
|
+
function toApprovalAttestation(raw) {
|
|
220
|
+
if (!raw || typeof raw !== "object") return null;
|
|
221
|
+
if (raw.resolution !== "approved") return null;
|
|
222
|
+
if (raw.alg !== "Ed25519") return null;
|
|
223
|
+
if (typeof raw.kid !== "string" || !raw.kid) return null;
|
|
224
|
+
if (typeof raw.signature !== "string" || !raw.signature.startsWith("ed25519:")) return null;
|
|
225
|
+
if (typeof raw.resolved_at !== "string" || Number.isNaN(Date.parse(raw.resolved_at))) return null;
|
|
226
|
+
return {
|
|
227
|
+
resolution: "approved",
|
|
228
|
+
resolvedAt: raw.resolved_at,
|
|
229
|
+
approverRef: typeof raw.approver_ref === "string" ? raw.approver_ref : null,
|
|
230
|
+
alg: "Ed25519",
|
|
231
|
+
kid: raw.kid,
|
|
232
|
+
signature: raw.signature
|
|
233
|
+
};
|
|
234
|
+
}
|
|
97
235
|
var VorimSDK = class _VorimSDK {
|
|
98
236
|
apiKey;
|
|
99
237
|
baseUrl;
|
|
@@ -102,6 +240,8 @@ var VorimSDK = class _VorimSDK {
|
|
|
102
240
|
canonicalForm;
|
|
103
241
|
chainEvents;
|
|
104
242
|
runtimeFailOpen;
|
|
243
|
+
noPayload;
|
|
244
|
+
maxMetadataChars;
|
|
105
245
|
/**
|
|
106
246
|
* In-memory keyring mapping agent_id -> PEM-encoded Ed25519 private key.
|
|
107
247
|
* Populated automatically by register() and registerEphemeral(), or
|
|
@@ -148,6 +288,8 @@ var VorimSDK = class _VorimSDK {
|
|
|
148
288
|
}
|
|
149
289
|
this.chainEvents = config.chainEvents ?? false;
|
|
150
290
|
this.runtimeFailOpen = config.runtimeFailOpen ?? true;
|
|
291
|
+
this.noPayload = config.noPayload !== void 0 && config.noPayload !== false;
|
|
292
|
+
this.maxMetadataChars = typeof config.noPayload === "object" && typeof config.noPayload.maxMetadataChars === "number" ? config.noPayload.maxMetadataChars : 256;
|
|
151
293
|
}
|
|
152
294
|
/**
|
|
153
295
|
* Register a previously-issued agent keypair so this SDK instance can
|
|
@@ -659,7 +801,8 @@ var VorimSDK = class _VorimSDK {
|
|
|
659
801
|
latencyMs: 0,
|
|
660
802
|
isFallback: true,
|
|
661
803
|
policyVersion: 0,
|
|
662
|
-
escalationResolution: null
|
|
804
|
+
escalationResolution: null,
|
|
805
|
+
approval: null
|
|
663
806
|
};
|
|
664
807
|
}
|
|
665
808
|
throw err;
|
|
@@ -732,6 +875,35 @@ var VorimSDK = class _VorimSDK {
|
|
|
732
875
|
{ decisionId }
|
|
733
876
|
);
|
|
734
877
|
}
|
|
878
|
+
/**
|
|
879
|
+
* Mint a portable signed receipt for a decision: a self-contained,
|
|
880
|
+
* offline-verifiable statement that Vorim authorised this action.
|
|
881
|
+
*
|
|
882
|
+
* Use it when something OUTSIDE Vorim has to be convinced — a settlement
|
|
883
|
+
* layer, a downstream anchor, a counterparty's auditor. Verification needs
|
|
884
|
+
* the receipt and the public key from `GET /trust/keys`: no call back to
|
|
885
|
+
* Vorim, no chain, no network.
|
|
886
|
+
*
|
|
887
|
+
* Reproduce the signed bytes with `portableReceiptCanonicalBytes` from
|
|
888
|
+
* `@vorim/shared-types` (also re-exported here), then check `signature`
|
|
889
|
+
* against the key matching `kid`. Never re-derive those bytes by hand: the
|
|
890
|
+
* canonical form is defined once precisely so two implementations cannot
|
|
891
|
+
* drift into signatures that do not verify.
|
|
892
|
+
*
|
|
893
|
+
* Throws 409 when the decision is not an authorisation — a denial, a
|
|
894
|
+
* fail-open fallback, an unresolved escalation, or one a human refused.
|
|
895
|
+
* A receipt only ever means yes, so there is nothing to return for a no.
|
|
896
|
+
*
|
|
897
|
+
* @example
|
|
898
|
+
* const d = await vorim.beforeAction({ ... });
|
|
899
|
+
* if (d.decision === 'allow') {
|
|
900
|
+
* const receipt = await vorim.mintPortableSignedReceipt(d.decisionId);
|
|
901
|
+
* await settleWith(receipt); // the counterparty verifies it alone
|
|
902
|
+
* }
|
|
903
|
+
*/
|
|
904
|
+
async mintPortableSignedReceipt(decisionId) {
|
|
905
|
+
return this.get(`/runtime/decisions/${decisionId}/receipt`);
|
|
906
|
+
}
|
|
735
907
|
/**
|
|
736
908
|
* Map a snake_case decision row (from POST or GET) to the camelCase
|
|
737
909
|
* {@link RuntimeDecision}. The SDK has no generic camelizer, so the
|
|
@@ -770,7 +942,8 @@ var VorimSDK = class _VorimSDK {
|
|
|
770
942
|
latencyMs: raw?.latency_ms ?? 0,
|
|
771
943
|
isFallback: raw?.is_fallback ?? !hasVerdict,
|
|
772
944
|
policyVersion: raw?.policy_version ?? 0,
|
|
773
|
-
escalationResolution: resolution
|
|
945
|
+
escalationResolution: resolution,
|
|
946
|
+
approval: toApprovalAttestation(raw?.approval)
|
|
774
947
|
};
|
|
775
948
|
}
|
|
776
949
|
// ─── Audit ────────────────────────────────────────────────────────
|
|
@@ -787,7 +960,11 @@ var VorimSDK = class _VorimSDK {
|
|
|
787
960
|
*/
|
|
788
961
|
async emit(event, options) {
|
|
789
962
|
const prepared = await this.prepareEvent(event, options?.sign);
|
|
790
|
-
const result = await this.post(
|
|
963
|
+
const result = await this.post(
|
|
964
|
+
"/audit/events",
|
|
965
|
+
{ events: [prepared] },
|
|
966
|
+
idempotencyHeader(options?.idempotencyKey)
|
|
967
|
+
);
|
|
791
968
|
this.warnOnPartialIngest(1, result?.ingested ?? 0);
|
|
792
969
|
return result;
|
|
793
970
|
}
|
|
@@ -803,7 +980,11 @@ var VorimSDK = class _VorimSDK {
|
|
|
803
980
|
*/
|
|
804
981
|
async emitBatch(events, options) {
|
|
805
982
|
const prepared = await Promise.all(events.map((e) => this.prepareEvent(e, options?.sign)));
|
|
806
|
-
const result = await this.post(
|
|
983
|
+
const result = await this.post(
|
|
984
|
+
"/audit/events",
|
|
985
|
+
{ events: prepared },
|
|
986
|
+
idempotencyHeader(options?.idempotencyKey)
|
|
987
|
+
);
|
|
807
988
|
this.warnOnPartialIngest(events.length, result?.ingested ?? 0);
|
|
808
989
|
return result;
|
|
809
990
|
}
|
|
@@ -840,7 +1021,61 @@ var VorimSDK = class _VorimSDK {
|
|
|
840
1021
|
* - Chain ops are serialised per-agent via `chainLocks` so
|
|
841
1022
|
* concurrent emits to the same agent build a deterministic chain.
|
|
842
1023
|
*/
|
|
1024
|
+
/**
|
|
1025
|
+
* Fail closed when `noPayload` is on and an event would carry content.
|
|
1026
|
+
*
|
|
1027
|
+
* Runs before signing and before any network call, so a rejected event is
|
|
1028
|
+
* one Vorim never saw. Throwing rather than stripping is deliberate: a
|
|
1029
|
+
* silent strip would leave the caller believing they had logged something
|
|
1030
|
+
* they had not, and would change the bytes after they were signed.
|
|
1031
|
+
*/
|
|
1032
|
+
assertNoPayload(event) {
|
|
1033
|
+
if (!this.noPayload) return;
|
|
1034
|
+
for (const field of ["input_hash", "output_hash", "system_prompt_hash", "tool_catalogue_hash"]) {
|
|
1035
|
+
const value = event[field];
|
|
1036
|
+
if (value === void 0 || value === null) continue;
|
|
1037
|
+
if (!isDigest(value)) {
|
|
1038
|
+
throw new VorimError(
|
|
1039
|
+
0,
|
|
1040
|
+
"PAYLOAD_BLOCKED",
|
|
1041
|
+
`noPayload: ${field} must be a sha256: or hmac-sha256: digest, got ${typeof value === "string" ? `${value.length} chars` : typeof value}. Hash it locally first \u2014 commitPayload() for anything a human or a model wrote, hashPayload() only for content that is already high-entropy.`,
|
|
1042
|
+
{ field }
|
|
1043
|
+
);
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
const metadata = event.metadata;
|
|
1047
|
+
if (metadata === void 0 || metadata === null) return;
|
|
1048
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
1049
|
+
if (value === null) continue;
|
|
1050
|
+
const t = typeof value;
|
|
1051
|
+
if (t === "object") {
|
|
1052
|
+
throw new VorimError(
|
|
1053
|
+
0,
|
|
1054
|
+
"PAYLOAD_BLOCKED",
|
|
1055
|
+
`noPayload: metadata.${key} is ${Array.isArray(value) ? "an array" : "an object"}. Nested values can carry arbitrary content, so only string, number, boolean and null are allowed. Summarise it, or commit to it with commitPayload() and send the digest.`,
|
|
1056
|
+
{ field: `metadata.${key}` }
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
if (t !== "string" && t !== "number" && t !== "boolean") {
|
|
1060
|
+
throw new VorimError(
|
|
1061
|
+
0,
|
|
1062
|
+
"PAYLOAD_BLOCKED",
|
|
1063
|
+
`noPayload: metadata.${key} is ${t}, which is not a permitted metadata type.`,
|
|
1064
|
+
{ field: `metadata.${key}` }
|
|
1065
|
+
);
|
|
1066
|
+
}
|
|
1067
|
+
if (t === "string" && value.length > this.maxMetadataChars) {
|
|
1068
|
+
throw new VorimError(
|
|
1069
|
+
0,
|
|
1070
|
+
"PAYLOAD_BLOCKED",
|
|
1071
|
+
`noPayload: metadata.${key} is ${value.length} chars, over the ${this.maxMetadataChars} limit. A value this long is content, not a label. Raise the limit with noPayload: { maxMetadataChars } if this really is a label.`,
|
|
1072
|
+
{ field: `metadata.${key}`, length: value.length }
|
|
1073
|
+
);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
843
1077
|
async prepareEvent(event, signOverride) {
|
|
1078
|
+
this.assertNoPayload(event);
|
|
844
1079
|
const shouldSign = signOverride ?? this.autoSign;
|
|
845
1080
|
if (!shouldSign && !this.chainEvents) return event;
|
|
846
1081
|
if (this.chainEvents) {
|
|
@@ -1045,8 +1280,8 @@ var VorimSDK = class _VorimSDK {
|
|
|
1045
1280
|
async get(path) {
|
|
1046
1281
|
return this.request("GET", path);
|
|
1047
1282
|
}
|
|
1048
|
-
async post(path, body) {
|
|
1049
|
-
return this.request("POST", path, body);
|
|
1283
|
+
async post(path, body, headers) {
|
|
1284
|
+
return this.request("POST", path, body, true, headers);
|
|
1050
1285
|
}
|
|
1051
1286
|
async patch(path, body) {
|
|
1052
1287
|
return this.request("PATCH", path, body);
|
|
@@ -1062,7 +1297,7 @@ var VorimSDK = class _VorimSDK {
|
|
|
1062
1297
|
async requestEnvelope(method, path, body) {
|
|
1063
1298
|
return this.request(method, path, body, false);
|
|
1064
1299
|
}
|
|
1065
|
-
async request(method, path, body, unwrap = true) {
|
|
1300
|
+
async request(method, path, body, unwrap = true, extraHeaders) {
|
|
1066
1301
|
const controller = new AbortController();
|
|
1067
1302
|
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
1068
1303
|
try {
|
|
@@ -1071,7 +1306,8 @@ var VorimSDK = class _VorimSDK {
|
|
|
1071
1306
|
headers: {
|
|
1072
1307
|
"Authorization": `Bearer ${this.apiKey}`,
|
|
1073
1308
|
"Content-Type": "application/json",
|
|
1074
|
-
"User-Agent": USER_AGENT
|
|
1309
|
+
"User-Agent": USER_AGENT,
|
|
1310
|
+
...extraHeaders
|
|
1075
1311
|
},
|
|
1076
1312
|
body: body ? JSON.stringify(body) : void 0,
|
|
1077
1313
|
signal: controller.signal
|
|
@@ -1199,18 +1435,26 @@ async function deviceLogin(opts) {
|
|
|
1199
1435
|
}
|
|
1200
1436
|
export {
|
|
1201
1437
|
CANONICAL_TOOL_CATALOGUE_VERSION,
|
|
1438
|
+
HMAC_SHA256_PREFIX,
|
|
1439
|
+
SHA256_PREFIX,
|
|
1202
1440
|
VorimDeniedError,
|
|
1203
1441
|
VorimError,
|
|
1204
1442
|
VorimSDK,
|
|
1205
1443
|
canonicalPayloadV0,
|
|
1206
1444
|
canonicalPayloadV1,
|
|
1445
|
+
commitPayload,
|
|
1207
1446
|
createVorim as default,
|
|
1208
1447
|
deviceLogin,
|
|
1448
|
+
eventDigest,
|
|
1449
|
+
hashPayload,
|
|
1209
1450
|
hashPreviousEvent,
|
|
1210
1451
|
hashSystemPrompt,
|
|
1211
1452
|
hashTool,
|
|
1212
1453
|
hashToolCatalogue,
|
|
1454
|
+
isDigest,
|
|
1455
|
+
isKeyedCommitment,
|
|
1213
1456
|
jcsCanonicalise,
|
|
1457
|
+
portableReceiptCanonicalBytes,
|
|
1214
1458
|
prepareReplayContext
|
|
1215
1459
|
};
|
|
1216
1460
|
//# sourceMappingURL=index.js.map
|