@vorim/sdk 3.20.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.
Files changed (103) hide show
  1. package/dist/index.cjs +117 -3
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +31 -2
  4. package/dist/index.d.ts +31 -2
  5. package/dist/index.js +116 -3
  6. package/dist/index.js.map +1 -1
  7. package/dist/integrations/anthropic.d.cts +2 -1
  8. package/dist/integrations/anthropic.d.ts +2 -1
  9. package/dist/integrations/ap2.d.cts +2 -1
  10. package/dist/integrations/ap2.d.ts +2 -1
  11. package/dist/integrations/aws-iam.d.cts +2 -1
  12. package/dist/integrations/aws-iam.d.ts +2 -1
  13. package/dist/integrations/bank-rails.d.cts +2 -1
  14. package/dist/integrations/bank-rails.d.ts +2 -1
  15. package/dist/integrations/circle.d.cts +2 -1
  16. package/dist/integrations/circle.d.ts +2 -1
  17. package/dist/integrations/cloudflare.d.cts +2 -1
  18. package/dist/integrations/cloudflare.d.ts +2 -1
  19. package/dist/integrations/coinbase-cdp.d.cts +2 -1
  20. package/dist/integrations/coinbase-cdp.d.ts +2 -1
  21. package/dist/integrations/commerce-agents.d.cts +2 -1
  22. package/dist/integrations/commerce-agents.d.ts +2 -1
  23. package/dist/integrations/crewai.d.cts +2 -1
  24. package/dist/integrations/crewai.d.ts +2 -1
  25. package/dist/integrations/entra.d.cts +2 -1
  26. package/dist/integrations/entra.d.ts +2 -1
  27. package/dist/integrations/fhir.d.cts +2 -1
  28. package/dist/integrations/fhir.d.ts +2 -1
  29. package/dist/integrations/grok.d.cts +2 -1
  30. package/dist/integrations/grok.d.ts +2 -1
  31. package/dist/integrations/guidewire.d.cts +2 -1
  32. package/dist/integrations/guidewire.d.ts +2 -1
  33. package/dist/integrations/hermes.d.cts +2 -1
  34. package/dist/integrations/hermes.d.ts +2 -1
  35. package/dist/integrations/jira.d.cts +2 -1
  36. package/dist/integrations/jira.d.ts +2 -1
  37. package/dist/integrations/langchain.d.cts +2 -1
  38. package/dist/integrations/langchain.d.ts +2 -1
  39. package/dist/integrations/langgraph.d.cts +2 -1
  40. package/dist/integrations/langgraph.d.ts +2 -1
  41. package/dist/integrations/legal.d.cts +2 -1
  42. package/dist/integrations/legal.d.ts +2 -1
  43. package/dist/integrations/life-sciences.d.cts +2 -1
  44. package/dist/integrations/life-sciences.d.ts +2 -1
  45. package/dist/integrations/linear.d.cts +2 -1
  46. package/dist/integrations/linear.d.ts +2 -1
  47. package/dist/integrations/lithic.d.cts +2 -1
  48. package/dist/integrations/lithic.d.ts +2 -1
  49. package/dist/integrations/llamaindex.d.cts +2 -1
  50. package/dist/integrations/llamaindex.d.ts +2 -1
  51. package/dist/integrations/marqeta.d.cts +2 -1
  52. package/dist/integrations/marqeta.d.ts +2 -1
  53. package/dist/integrations/modern-treasury.d.cts +2 -1
  54. package/dist/integrations/modern-treasury.d.ts +2 -1
  55. package/dist/integrations/muse.cjs +437 -0
  56. package/dist/integrations/muse.cjs.map +1 -0
  57. package/dist/integrations/muse.d.cts +72 -0
  58. package/dist/integrations/muse.d.ts +72 -0
  59. package/dist/integrations/muse.js +394 -0
  60. package/dist/integrations/muse.js.map +1 -0
  61. package/dist/integrations/nekuda.d.cts +2 -1
  62. package/dist/integrations/nekuda.d.ts +2 -1
  63. package/dist/integrations/okta.d.cts +2 -1
  64. package/dist/integrations/okta.d.ts +2 -1
  65. package/dist/integrations/openai.d.cts +2 -1
  66. package/dist/integrations/openai.d.ts +2 -1
  67. package/dist/integrations/openrouter.d.cts +2 -1
  68. package/dist/integrations/openrouter.d.ts +2 -1
  69. package/dist/integrations/paypal-agent.d.cts +2 -1
  70. package/dist/integrations/paypal-agent.d.ts +2 -1
  71. package/dist/integrations/perplexity.d.cts +2 -1
  72. package/dist/integrations/perplexity.d.ts +2 -1
  73. package/dist/integrations/plaid.d.cts +2 -1
  74. package/dist/integrations/plaid.d.ts +2 -1
  75. package/dist/integrations/ramp.d.cts +2 -1
  76. package/dist/integrations/ramp.d.ts +2 -1
  77. package/dist/integrations/shopify.d.cts +2 -1
  78. package/dist/integrations/shopify.d.ts +2 -1
  79. package/dist/integrations/siem.d.cts +1 -1
  80. package/dist/integrations/siem.d.ts +1 -1
  81. package/dist/integrations/skyfire.d.cts +2 -1
  82. package/dist/integrations/skyfire.d.ts +2 -1
  83. package/dist/integrations/stripe-acp.d.cts +2 -1
  84. package/dist/integrations/stripe-acp.d.ts +2 -1
  85. package/dist/integrations/stripe-issuing.d.cts +2 -1
  86. package/dist/integrations/stripe-issuing.d.ts +2 -1
  87. package/dist/integrations/truanon.d.cts +2 -1
  88. package/dist/integrations/truanon.d.ts +2 -1
  89. package/dist/integrations/typesafe.cjs +268 -0
  90. package/dist/integrations/typesafe.cjs.map +1 -0
  91. package/dist/integrations/typesafe.d.cts +145 -0
  92. package/dist/integrations/typesafe.d.ts +145 -0
  93. package/dist/integrations/typesafe.js +221 -0
  94. package/dist/integrations/typesafe.js.map +1 -0
  95. package/dist/integrations/ucp.d.cts +2 -1
  96. package/dist/integrations/ucp.d.ts +2 -1
  97. package/dist/integrations/vercel-ai.d.cts +2 -1
  98. package/dist/integrations/vercel-ai.d.ts +2 -1
  99. package/dist/integrations/x402.d.cts +2 -1
  100. package/dist/integrations/x402.d.ts +2 -1
  101. package/dist/{types-BmeluKHI.d.cts → types-BrDQAJdl.d.cts} +36 -1
  102. package/dist/{types-BmeluKHI.d.ts → types-BrDQAJdl.d.ts} +36 -1
  103. package/package.json +21 -1
package/dist/index.cjs CHANGED
@@ -50,6 +50,7 @@ __export(index_exports, {
50
50
  isDigest: () => isDigest,
51
51
  isKeyedCommitment: () => isKeyedCommitment,
52
52
  jcsCanonicalise: () => jcsCanonicalise,
53
+ portableReceiptCanonicalBytes: () => portableReceiptCanonicalBytes,
53
54
  prepareReplayContext: () => prepareReplayContext
54
55
  });
55
56
  module.exports = __toCommonJS(index_exports);
@@ -130,6 +131,71 @@ async function prepareReplayContext(inputs) {
130
131
  return ctx;
131
132
  }
132
133
 
134
+ // ../shared-types/src/index.ts
135
+ function jcsCanonicalise2(value) {
136
+ if (value === null) return "null";
137
+ if (value === true) return "true";
138
+ if (value === false) return "false";
139
+ if (typeof value === "number") {
140
+ if (!Number.isFinite(value)) {
141
+ throw new Error("jcsCanonicalise: NaN and Infinity are not JCS-valid");
142
+ }
143
+ const abs = Math.abs(value);
144
+ if (value !== 0 && (abs >= 1e21 || abs < 1e-4 || Number.isInteger(value) && abs > 2 ** 53)) {
145
+ throw new Error(
146
+ `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}.`
147
+ );
148
+ }
149
+ return value.toString();
150
+ }
151
+ if (typeof value === "string") {
152
+ return JSON.stringify(value);
153
+ }
154
+ if (Array.isArray(value)) {
155
+ return "[" + value.map(jcsCanonicalise2).join(",") + "]";
156
+ }
157
+ if (typeof value === "object") {
158
+ const obj = value;
159
+ const keys = Object.keys(obj).filter((k) => obj[k] !== void 0).sort();
160
+ const parts = keys.map((k) => JSON.stringify(k) + ":" + jcsCanonicalise2(obj[k]));
161
+ return "{" + parts.join(",") + "}";
162
+ }
163
+ throw new Error(`jcsCanonicalise: unsupported value type: ${typeof value}`);
164
+ }
165
+ function portableReceiptCanonicalBytes(receipt) {
166
+ return jcsCanonicalise2({
167
+ version: receipt.version,
168
+ org_id: receipt.org_id,
169
+ issued_at: receipt.issued_at,
170
+ canonical_form: receipt.canonical_form,
171
+ decision: {
172
+ decision_id: receipt.decision.decision_id,
173
+ verdict: receipt.decision.verdict,
174
+ agent_id: receipt.decision.agent_id,
175
+ required_scope: receipt.decision.required_scope,
176
+ action_type: receipt.decision.action_type,
177
+ action_target: receipt.decision.action_target,
178
+ policy_version: receipt.decision.policy_version,
179
+ decision_rule_id: receipt.decision.decision_rule_id,
180
+ requested_at: receipt.decision.requested_at,
181
+ expires_at: receipt.decision.expires_at
182
+ },
183
+ binding: {
184
+ original_intent_hash: receipt.binding.original_intent_hash,
185
+ effective_intent_hash: receipt.binding.effective_intent_hash,
186
+ policy_modified: receipt.binding.policy_modified
187
+ },
188
+ approval: receipt.approval === null ? null : {
189
+ resolution: receipt.approval.resolution,
190
+ resolved_at: receipt.approval.resolved_at,
191
+ approver_ref: receipt.approval.approver_ref,
192
+ alg: receipt.approval.alg,
193
+ kid: receipt.approval.kid,
194
+ signature: receipt.approval.signature
195
+ }
196
+ });
197
+ }
198
+
133
199
  // src/commit.ts
134
200
  var HMAC_SHA256_PREFIX = "hmac-sha256:";
135
201
  var SHA256_PREFIX = "sha256:";
@@ -180,7 +246,7 @@ function isDigest(digest) {
180
246
  }
181
247
 
182
248
  // src/index.ts
183
- var SDK_VERSION = true ? "3.20.0" : "0.0.0";
249
+ var SDK_VERSION = true ? "3.22.0" : "0.0.0";
184
250
  var USER_AGENT = `vorim-sdk/${SDK_VERSION}`;
185
251
  function sleep(ms) {
186
252
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -207,6 +273,22 @@ async function eventDigest(event) {
207
273
  function idempotencyHeader(key) {
208
274
  return key ? { "Idempotency-Key": key } : void 0;
209
275
  }
276
+ function toApprovalAttestation(raw) {
277
+ if (!raw || typeof raw !== "object") return null;
278
+ if (raw.resolution !== "approved") return null;
279
+ if (raw.alg !== "Ed25519") return null;
280
+ if (typeof raw.kid !== "string" || !raw.kid) return null;
281
+ if (typeof raw.signature !== "string" || !raw.signature.startsWith("ed25519:")) return null;
282
+ if (typeof raw.resolved_at !== "string" || Number.isNaN(Date.parse(raw.resolved_at))) return null;
283
+ return {
284
+ resolution: "approved",
285
+ resolvedAt: raw.resolved_at,
286
+ approverRef: typeof raw.approver_ref === "string" ? raw.approver_ref : null,
287
+ alg: "Ed25519",
288
+ kid: raw.kid,
289
+ signature: raw.signature
290
+ };
291
+ }
210
292
  var VorimSDK = class _VorimSDK {
211
293
  apiKey;
212
294
  baseUrl;
@@ -776,7 +858,8 @@ var VorimSDK = class _VorimSDK {
776
858
  latencyMs: 0,
777
859
  isFallback: true,
778
860
  policyVersion: 0,
779
- escalationResolution: null
861
+ escalationResolution: null,
862
+ approval: null
780
863
  };
781
864
  }
782
865
  throw err;
@@ -849,6 +932,35 @@ var VorimSDK = class _VorimSDK {
849
932
  { decisionId }
850
933
  );
851
934
  }
935
+ /**
936
+ * Mint a portable signed receipt for a decision: a self-contained,
937
+ * offline-verifiable statement that Vorim authorised this action.
938
+ *
939
+ * Use it when something OUTSIDE Vorim has to be convinced — a settlement
940
+ * layer, a downstream anchor, a counterparty's auditor. Verification needs
941
+ * the receipt and the public key from `GET /trust/keys`: no call back to
942
+ * Vorim, no chain, no network.
943
+ *
944
+ * Reproduce the signed bytes with `portableReceiptCanonicalBytes` from
945
+ * `@vorim/shared-types` (also re-exported here), then check `signature`
946
+ * against the key matching `kid`. Never re-derive those bytes by hand: the
947
+ * canonical form is defined once precisely so two implementations cannot
948
+ * drift into signatures that do not verify.
949
+ *
950
+ * Throws 409 when the decision is not an authorisation — a denial, a
951
+ * fail-open fallback, an unresolved escalation, or one a human refused.
952
+ * A receipt only ever means yes, so there is nothing to return for a no.
953
+ *
954
+ * @example
955
+ * const d = await vorim.beforeAction({ ... });
956
+ * if (d.decision === 'allow') {
957
+ * const receipt = await vorim.mintPortableSignedReceipt(d.decisionId);
958
+ * await settleWith(receipt); // the counterparty verifies it alone
959
+ * }
960
+ */
961
+ async mintPortableSignedReceipt(decisionId) {
962
+ return this.get(`/runtime/decisions/${decisionId}/receipt`);
963
+ }
852
964
  /**
853
965
  * Map a snake_case decision row (from POST or GET) to the camelCase
854
966
  * {@link RuntimeDecision}. The SDK has no generic camelizer, so the
@@ -887,7 +999,8 @@ var VorimSDK = class _VorimSDK {
887
999
  latencyMs: raw?.latency_ms ?? 0,
888
1000
  isFallback: raw?.is_fallback ?? !hasVerdict,
889
1001
  policyVersion: raw?.policy_version ?? 0,
890
- escalationResolution: resolution
1002
+ escalationResolution: resolution,
1003
+ approval: toApprovalAttestation(raw?.approval)
891
1004
  };
892
1005
  }
893
1006
  // ─── Audit ────────────────────────────────────────────────────────
@@ -1398,6 +1511,7 @@ async function deviceLogin(opts) {
1398
1511
  isDigest,
1399
1512
  isKeyedCommitment,
1400
1513
  jcsCanonicalise,
1514
+ portableReceiptCanonicalBytes,
1401
1515
  prepareReplayContext
1402
1516
  });
1403
1517
  //# sourceMappingURL=index.cjs.map