@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/README.md +41 -172
- package/dist/edge.cjs +34 -8
- package/dist/edge.cjs.map +1 -1
- package/dist/edge.d.cts +2 -2
- package/dist/edge.d.ts +2 -2
- package/dist/edge.js +34 -8
- package/dist/edge.js.map +1 -1
- package/dist/index.cjs +34 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +34 -8
- package/dist/index.js.map +1 -1
- package/dist/{trusted-ip-BvSjdU80.d.cts → trusted-ip-DNO3xzCU.d.cts} +41 -9
- package/dist/{trusted-ip-BvSjdU80.d.ts → trusted-ip-DNO3xzCU.d.ts} +41 -9
- package/package.json +1 -1
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-
|
|
2
|
-
export { c as ActionBinding, d as ActionReceiptClaims, e as ActorType, f as
|
|
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
|
|
9
|
-
if (!site && request.url
|
|
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
|
-
|
|
11
|
+
url = new URL(request.url);
|
|
14
12
|
} catch {
|
|
15
13
|
}
|
|
16
14
|
}
|
|
17
|
-
|
|
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.
|
|
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();
|