@chitmark/sdk 0.8.0 → 0.9.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/dist/edge.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as Chitmark, A as Action, V as VerifyContext, a as VerifyRequest, b as Verdict } from './trusted-ip-BvSjdU80.js';
2
- export { c as ActionBinding, d as ActionReceiptClaims, e as ActorType, f as AttributionAgentProof, g as AttributionLink, h as AttributionLinkRequest, i as AttributionResolveOptions, j as AttributionResult, k as CHITMARK_HTTP_STATUS, l as CHITMARK_HTTP_STATUS_MEANING, m as ChallengeCompletionResponse, n as ChallengeMethod, o as ChallengeProof, p as ChallengeRequest, q as ChallengeResponse, r as ChallengeRiskTier, s as ChitmarkApiError, t as ChitmarkEnv, u as ChitmarkError, v as ChitmarkErrorBody, w as ChitmarkHttpStatus, x as ChitmarkOptions, y as Commitment, z as CredentialProvider, D as Decision, B as DecisionCosts, E as EligibleAllowVerdict, F as EnforcementMode, G as EvidenceBundle, H as EvidenceCheckpoint, I as EvidenceError, J as EvidenceKey, K as EvidenceManifest, L as EvidenceSigningKey, M as FeedbackRequest, N as FeedbackResponse, O as FeedbackSource, P as FeedbackUnit, Q as OnDegraded, R as Outcome, S as PiiMode, T as PortableRecord, U as Principal, W as SENSITIVE_RECEIPT_ACTIONS, X as SensitiveReceiptAction, Y as Subject, Z as TrialCreditOperation, _ as VERDICT_TOKEN_ISSUER, $ as VerdictTokenClaims, a0 as VerdictTokenError, a1 as VerdictTokenErrorCode, a2 as VerifyActionReceiptOptions, a3 as VerifyVerdictTokenOptions, a4 as WorkloadCredential, a5 as canonicalEvidence, a6 as checkpointFromCommitments, a7 as createDPoPCredentialProvider, a8 as degradedChallengeVerdict, a9 as enforceDegradedNeverAllow, aa as evidenceAssert, ab as evidenceCommitment, ac as evidenceHash, ad as evidenceKeyAt, ae as getTrustedClientIp, af as hashEmailSha256, ag as isEligibleAllow, ah as minimizeFormData, ai as signEvidence, aj as trialCreditOperationDigest, ak as truncateIp, al as validateManifest, am as verdictToHttpStatus, an as verifyActionReceipt, ao as verifyCheckpointAppend, ap as verifyCheckpointInclusion, aq as verifyEvidenceBundle, ar as verifyEvidenceSignature, as as verifyHistoricalReceipt, at as verifyVerdictToken } from './trusted-ip-BvSjdU80.js';
1
+ import { C as Chitmark, A as Action, V as VerifyContext, a as VerifyRequest, b as Verdict } from './trusted-ip-DNO3xzCU.js';
2
+ export { c as ActionBinding, d as ActionReceiptClaims, e as ActorType, f as AttributionAgentKey, g as AttributionAgentProof, h as AttributionLink, i as AttributionLinkRequest, j as AttributionNetworkAgentRequest, k as AttributionNetworkGrantRequest, l as AttributionNetworkProof, m as AttributionResolveOptions, n as AttributionResult, o as CHITMARK_HTTP_STATUS, p as CHITMARK_HTTP_STATUS_MEANING, q as ChallengeCompletionResponse, r as ChallengeMethod, s as ChallengeProof, t as ChallengeRequest, u as ChallengeResponse, v as ChallengeRiskTier, w as ChitmarkApiError, x as ChitmarkEnv, y as ChitmarkError, z as ChitmarkErrorBody, B as ChitmarkHttpStatus, D as ChitmarkOptions, E as Commitment, F as CredentialProvider, G as Decision, H as DecisionCosts, I as EligibleAllowVerdict, J as EnforcementMode, K as EvidenceBundle, L as EvidenceCheckpoint, M as EvidenceError, N as EvidenceKey, O as EvidenceManifest, P as EvidenceSigningKey, Q as FeedbackRequest, R as FeedbackResponse, S as FeedbackSource, T as FeedbackUnit, U as OnDegraded, W as Outcome, X as PiiMode, Y as PortableRecord, Z as Principal, _ as SENSITIVE_RECEIPT_ACTIONS, $ as SensitiveReceiptAction, a0 as Subject, a1 as TrialCreditOperation, a2 as VERDICT_TOKEN_ISSUER, a3 as VerdictTokenClaims, a4 as VerdictTokenError, a5 as VerdictTokenErrorCode, a6 as VerifyActionReceiptOptions, a7 as VerifyVerdictTokenOptions, a8 as WorkloadCredential, a9 as canonicalEvidence, aa as checkpointFromCommitments, ab as createDPoPCredentialProvider, ac as degradedChallengeVerdict, ad as enforceDegradedNeverAllow, ae as evidenceAssert, af as evidenceCommitment, ag as evidenceHash, ah as evidenceKeyAt, ai as getTrustedClientIp, aj as hashEmailSha256, ak as isEligibleAllow, al as minimizeFormData, am as signEvidence, an as trialCreditOperationDigest, ao as truncateIp, ap as validateManifest, aq as verdictToHttpStatus, ar as verifyActionReceipt, as as verifyCheckpointAppend, at as verifyCheckpointInclusion, au as verifyEvidenceBundle, av as verifyEvidenceSignature, aw as verifyHistoricalReceipt, ax as verifyVerdictToken } from './trusted-ip-DNO3xzCU.js';
3
3
 
4
4
  interface VerifyRequestFromRequestOptions {
5
5
  action: Action;
package/dist/edge.js CHANGED
@@ -1,20 +1,46 @@
1
1
  // src/attribution.ts
2
2
  function attributionEvidence(options, mode) {
3
- const { request, agentProof, session, piiMode = mode } = options;
3
+ const { request, agentProof, session, purpose, piiMode = mode } = options;
4
4
  const headers = request.headers;
5
5
  const header = typeof headers.get === "function" ? headers.get("chitmark-agent-proof") : Object.entries(headers).find(
6
6
  ([name]) => name.toLowerCase() === "chitmark-agent-proof"
7
7
  )?.[1];
8
- let site = options.site;
9
- if (!site && request.url?.startsWith("https://")) site = new URL(request.url).origin;
10
- let proof = agentProof;
11
- if (!proof && typeof header === "string" && header.length <= 2048 && site) {
8
+ let url;
9
+ if (!options.site && request.url) {
12
10
  try {
13
- proof = JSON.parse(header);
11
+ url = new URL(request.url);
14
12
  } catch {
15
13
  }
16
14
  }
17
- return { site, session, piiMode, agentProof: proof };
15
+ const site = options.site ?? (url?.protocol === "https:" ? url.origin : void 0);
16
+ const proof = agentProof ?? (site ? parseProof(header) : void 0);
17
+ return { site, session, piiMode, purpose, agentProof: proof };
18
+ }
19
+ function parseProof(header) {
20
+ if (typeof header !== "string" || header.length > 2048) return;
21
+ try {
22
+ const value = JSON.parse(header);
23
+ if (!value || typeof value.nonce !== "string" || value.nonce.length > 36 || typeof value.issuedAt !== "number" || !Number.isSafeInteger(value.issuedAt) || typeof value.signature !== "string" || value.signature.length > 86)
24
+ return;
25
+ const { nonce, issuedAt, signature } = value;
26
+ if ("iss" in value) {
27
+ const key = value.agentKey;
28
+ if (value.iss === "chitmark-agent-key-v1" && key?.kty === "OKP" && key.crv === "Ed25519" && typeof key.x === "string" && key.x.length === 43 && !("d" in key)) {
29
+ return {
30
+ iss: value.iss,
31
+ agentKey: { kty: key.kty, crv: key.crv, x: key.x },
32
+ nonce,
33
+ issuedAt,
34
+ signature
35
+ };
36
+ }
37
+ return;
38
+ }
39
+ if (typeof value.linkId === "string" && value.linkId.length <= 36)
40
+ return { linkId: value.linkId, nonce, issuedAt, signature };
41
+ } catch {
42
+ }
43
+ return void 0;
18
44
  }
19
45
 
20
46
  // src/credentials.ts
@@ -151,7 +177,7 @@ var DEFAULT_BASE_URLS = {
151
177
  };
152
178
  var DEFAULT_TIMEOUT_MS = 800;
153
179
  var LOCAL_TIMEOUT_MS = 2e3;
154
- var SDK_VERSION = "0.8.0";
180
+ var SDK_VERSION = "0.9.0";
155
181
  function defaultTimeoutMs(baseUrl) {
156
182
  try {
157
183
  const host = new URL(baseUrl).hostname.replace(/^\[|\]$/g, "").toLowerCase();