@chitmark/sdk 0.7.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 -155
- package/dist/edge.cjs +601 -12
- 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 +584 -13
- package/dist/edge.js.map +1 -1
- package/dist/index.cjs +634 -12
- 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 +616 -13
- package/dist/index.js.map +1 -1
- package/dist/{trusted-ip-DnCZnqQx.d.cts → trusted-ip-DNO3xzCU.d.cts} +490 -9
- package/dist/{trusted-ip-DnCZnqQx.d.ts → trusted-ip-DNO3xzCU.d.ts} +490 -9
- package/package.json +2 -2
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
/** Explicit sender-constrained credential profile. No static-key fallback. */
|
|
2
|
+
interface CredentialProvider {
|
|
3
|
+
headers(input: {
|
|
4
|
+
url: string;
|
|
5
|
+
method: string;
|
|
6
|
+
signal: AbortSignal;
|
|
7
|
+
}): Promise<{
|
|
8
|
+
Authorization: string;
|
|
9
|
+
DPoP: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
interface WorkloadCredential {
|
|
13
|
+
accessToken: string;
|
|
14
|
+
expiresAt: number;
|
|
15
|
+
trustExpiresAt: number;
|
|
16
|
+
revocationValidUntil: number;
|
|
17
|
+
}
|
|
18
|
+
declare function createDPoPCredentialProvider(options: {
|
|
19
|
+
privateKey: CryptoKey;
|
|
20
|
+
publicJwk: JsonWebKey;
|
|
21
|
+
/** Issuer-specific authenticated exchange. Must bind tokens to publicJwk. */
|
|
22
|
+
load: (signal: AbortSignal) => Promise<WorkloadCredential>;
|
|
23
|
+
refreshTimeoutMs?: number;
|
|
24
|
+
}): CredentialProvider;
|
|
25
|
+
|
|
1
26
|
/**
|
|
2
27
|
* Shared API types for Chitmark.
|
|
3
28
|
* Aligns with openapi/openapi.yaml and SDK.md.
|
|
@@ -20,11 +45,11 @@ type Action = "signup" | "trial_activation" | "api_key" | "demo_request" | "quot
|
|
|
20
45
|
* Not "Chitmark challenged/denied a legitimate user" — that is
|
|
21
46
|
* `context.decisionCosts.falseChallenge` / `falseDeny` on verify.
|
|
22
47
|
*/
|
|
23
|
-
type Outcome = "credit_burn" | "multi_account_cluster" | "abuse_confirmed" | "converted" | "chargeback" | "churned" | "false_positive";
|
|
48
|
+
type Outcome = "credit_burn" | "multi_account_cluster" | "abuse_confirmed" | "converted" | "chargeback" | "churned" | "grant_applied" | "export_executed" | "false_positive";
|
|
24
49
|
/** Asymmetric-cost challenge methods (best → worst for anti-abuse).
|
|
25
50
|
* `payment_preauth` validates a payment-provider setup result; it does not
|
|
26
51
|
* transfer funds or authorize a purchase. */
|
|
27
|
-
type ChallengeMethod = "payment_preauth" | "proof_of_work" | "device_attestation" | "web_bot_auth_stepup" | "email_otp";
|
|
52
|
+
type ChallengeMethod = "payment_preauth" | "proof_of_work" | "tenant_step_up" | "device_attestation" | "web_bot_auth_stepup" | "email_otp";
|
|
28
53
|
/** Client-side PII minimization mode. Default is hashed. Raw is opt-in only. */
|
|
29
54
|
type PiiMode = "raw" | "hashed" | "none";
|
|
30
55
|
/** Environment target; selects default base URL. */
|
|
@@ -147,7 +172,15 @@ interface VerifyContext {
|
|
|
147
172
|
[key: string]: unknown;
|
|
148
173
|
}
|
|
149
174
|
/** Request body for POST /v1/verify. */
|
|
175
|
+
interface ActionBinding {
|
|
176
|
+
/** Tenant-scoped opaque principal reference for sensitive actions. */
|
|
177
|
+
subject?: string;
|
|
178
|
+
digest: string;
|
|
179
|
+
challengeId?: string;
|
|
180
|
+
eventId?: string;
|
|
181
|
+
}
|
|
150
182
|
interface VerifyRequest {
|
|
183
|
+
actionBinding?: ActionBinding;
|
|
151
184
|
idempotencyKey?: string;
|
|
152
185
|
action: Action;
|
|
153
186
|
/** Binding id you supply for this action attempt. Prefer high-entropy,
|
|
@@ -210,6 +243,7 @@ interface FeedbackResponse {
|
|
|
210
243
|
type ChallengeRiskTier = "default" | "elevated" | "severe";
|
|
211
244
|
/** Request body for POST /v1/challenge: issue or complete. */
|
|
212
245
|
interface ChallengeRequest {
|
|
246
|
+
pendingReceipt?: string;
|
|
213
247
|
/** eventId from the verify verdict that routed to challenge. */
|
|
214
248
|
eventId: string;
|
|
215
249
|
/** Binding id you supply for one action attempt. Prefer high-entropy,
|
|
@@ -235,6 +269,9 @@ interface ChallengeRequest {
|
|
|
235
269
|
}
|
|
236
270
|
/** Server-verified completion proof. */
|
|
237
271
|
type ChallengeProof = {
|
|
272
|
+
type: "tenant_step_up";
|
|
273
|
+
assertion: string;
|
|
274
|
+
} | {
|
|
238
275
|
type: "proof_of_work";
|
|
239
276
|
/** First nonce where sha256(`${challengeId}:${seed}:${nonce}`) hex starts with `difficulty` zero nibbles. */
|
|
240
277
|
nonce: string;
|
|
@@ -248,6 +285,9 @@ interface ChallengeResponse {
|
|
|
248
285
|
challengeId: string;
|
|
249
286
|
method: ChallengeMethod;
|
|
250
287
|
instructions: {
|
|
288
|
+
type: "tenant_step_up";
|
|
289
|
+
nonce: string;
|
|
290
|
+
} | {
|
|
251
291
|
type: "pow";
|
|
252
292
|
/** Leading zero nibbles required. Sealed at issue; completion validates this value. */
|
|
253
293
|
difficulty: number;
|
|
@@ -268,7 +308,8 @@ interface ChallengeResponse {
|
|
|
268
308
|
}
|
|
269
309
|
/** Response from POST /v1/challenge (completion mode).
|
|
270
310
|
* Session-state change only: does not authorize the action. Re-verify with
|
|
271
|
-
* `context.challengeId`
|
|
311
|
+
* `context.challengeId` for standalone challenges or the original action
|
|
312
|
+
* binding plus the challenge and event IDs for operation-bound challenges. */
|
|
272
313
|
interface ChallengeCompletionResponse {
|
|
273
314
|
/** Friction satisfied for boundTo; not permission to continue without re-verify. */
|
|
274
315
|
ok: true;
|
|
@@ -280,7 +321,9 @@ interface ChallengeCompletionResponse {
|
|
|
280
321
|
/** Client constructor options. */
|
|
281
322
|
interface ChitmarkOptions {
|
|
282
323
|
/** API key (Bearer). Use process.env.CHITMARK_API_KEY. */
|
|
283
|
-
apiKey
|
|
324
|
+
apiKey?: string;
|
|
325
|
+
/** Explicit DPoP authentication; mutually exclusive with apiKey. */
|
|
326
|
+
credentialProvider?: CredentialProvider;
|
|
284
327
|
/**
|
|
285
328
|
* Timeout/error behavior. Fixed to "challenge": never allow silent bypass.
|
|
286
329
|
* @default "challenge"
|
|
@@ -317,6 +360,251 @@ interface ChitmarkErrorBody {
|
|
|
317
360
|
code?: string;
|
|
318
361
|
}
|
|
319
362
|
|
|
363
|
+
interface AttributionAgentProof {
|
|
364
|
+
linkId: string;
|
|
365
|
+
nonce: string;
|
|
366
|
+
issuedAt: number;
|
|
367
|
+
signature: string;
|
|
368
|
+
}
|
|
369
|
+
interface AttributionAgentKey {
|
|
370
|
+
kty: "OKP";
|
|
371
|
+
crv: "Ed25519";
|
|
372
|
+
x: string;
|
|
373
|
+
}
|
|
374
|
+
interface AttributionNetworkProof {
|
|
375
|
+
iss: "chitmark-agent-key-v1";
|
|
376
|
+
agentKey: AttributionAgentKey;
|
|
377
|
+
nonce: string;
|
|
378
|
+
issuedAt: number;
|
|
379
|
+
signature: string;
|
|
380
|
+
}
|
|
381
|
+
interface AttributionResolveOptions {
|
|
382
|
+
request: {
|
|
383
|
+
url?: string;
|
|
384
|
+
headers: Headers | Record<string, string | string[] | undefined>;
|
|
385
|
+
};
|
|
386
|
+
/** Explicit site origin for requests with a relative URL, such as IncomingMessage. */
|
|
387
|
+
site?: string;
|
|
388
|
+
/** Opaque credential supplied by the integrating server, never a raw browser cookie. */
|
|
389
|
+
session?: string;
|
|
390
|
+
agentProof?: AttributionAgentProof | AttributionNetworkProof;
|
|
391
|
+
/** The recipient's configured disclosure purpose. Defaults to identity_attribution. */
|
|
392
|
+
purpose?: string;
|
|
393
|
+
piiMode?: PiiMode;
|
|
394
|
+
idempotencyKey?: string;
|
|
395
|
+
}
|
|
396
|
+
interface AttributionResult {
|
|
397
|
+
id: string;
|
|
398
|
+
agent: {
|
|
399
|
+
detected: boolean;
|
|
400
|
+
provider: string | null;
|
|
401
|
+
operator_verified: boolean;
|
|
402
|
+
};
|
|
403
|
+
identity: {
|
|
404
|
+
recognized: boolean;
|
|
405
|
+
subject_id: string | null;
|
|
406
|
+
scope: "site" | null;
|
|
407
|
+
match: "none" | "existing_session" | "verified_identity_link" | "verified_agent_account";
|
|
408
|
+
};
|
|
409
|
+
principal: {
|
|
410
|
+
status: "unknown" | "previously_verified" | "withheld";
|
|
411
|
+
email: string | null;
|
|
412
|
+
email_verified: boolean | null;
|
|
413
|
+
current_delegation_verified: boolean | null;
|
|
414
|
+
document_verified: boolean | null;
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
interface AttributionLinkRequest {
|
|
418
|
+
enrollmentId: string;
|
|
419
|
+
site: string;
|
|
420
|
+
agentKey: AttributionAgentKey;
|
|
421
|
+
recipientKeyId: string;
|
|
422
|
+
emailConsent: boolean;
|
|
423
|
+
expiresAt: number;
|
|
424
|
+
principalProof: string;
|
|
425
|
+
}
|
|
426
|
+
interface AttributionNetworkAgentRequest {
|
|
427
|
+
kind: "network_agent";
|
|
428
|
+
enrollmentId: string;
|
|
429
|
+
agentKey: AttributionAgentKey;
|
|
430
|
+
principalProof: string;
|
|
431
|
+
agentProof: string;
|
|
432
|
+
expiresAt: number;
|
|
433
|
+
rotation?: {
|
|
434
|
+
agentId: string;
|
|
435
|
+
previousKey: AttributionAgentKey;
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
interface AttributionNetworkGrantRequest {
|
|
439
|
+
kind: "network_grant";
|
|
440
|
+
agentId: string;
|
|
441
|
+
site: string;
|
|
442
|
+
recipientKeyId: string;
|
|
443
|
+
purpose: string;
|
|
444
|
+
emailConsent: boolean;
|
|
445
|
+
expiresAt: number;
|
|
446
|
+
principalProof: string;
|
|
447
|
+
}
|
|
448
|
+
interface AttributionLink {
|
|
449
|
+
id: string;
|
|
450
|
+
expires_at: number;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/** Integer USD cents. Customer purchases are separate from Chitmark subscriptions. */
|
|
454
|
+
interface PaidResource {
|
|
455
|
+
resourceId: string;
|
|
456
|
+
version: number;
|
|
457
|
+
kind: "api_call" | "dataset" | "compute";
|
|
458
|
+
unit: "call" | "access" | "compute_second";
|
|
459
|
+
unitAmount: number;
|
|
460
|
+
currency: "usd";
|
|
461
|
+
minQuantity: number;
|
|
462
|
+
maxQuantity: number;
|
|
463
|
+
maxAmount: number;
|
|
464
|
+
quoteTtlSeconds: number;
|
|
465
|
+
accessTtlSeconds: number;
|
|
466
|
+
enabled: boolean;
|
|
467
|
+
refundTerms: "unused_only";
|
|
468
|
+
}
|
|
469
|
+
type ChargeBase = {
|
|
470
|
+
sellerTenantId: string;
|
|
471
|
+
idempotencyKey?: string;
|
|
472
|
+
};
|
|
473
|
+
type PurchaseRef = ChargeBase & {
|
|
474
|
+
purchaseId: string;
|
|
475
|
+
};
|
|
476
|
+
type ChargeRequest = (ChargeBase & {
|
|
477
|
+
operation: "resource";
|
|
478
|
+
resourceId: string;
|
|
479
|
+
}) | (ChargeBase & {
|
|
480
|
+
operation: "quote";
|
|
481
|
+
resourceId: string;
|
|
482
|
+
quantity: number;
|
|
483
|
+
operationDigest: string;
|
|
484
|
+
}) | (PurchaseRef & {
|
|
485
|
+
operation: "accept";
|
|
486
|
+
quoteVersion: string;
|
|
487
|
+
maxAmount: number;
|
|
488
|
+
currency: "usd";
|
|
489
|
+
}) | (PurchaseRef & {
|
|
490
|
+
operation: "status" | "cancel" | "reconcile";
|
|
491
|
+
}) | (PurchaseRef & {
|
|
492
|
+
operation: "permission";
|
|
493
|
+
allowed: boolean;
|
|
494
|
+
eventId?: string;
|
|
495
|
+
}) | (PurchaseRef & {
|
|
496
|
+
operation: "reserve";
|
|
497
|
+
executionId: string;
|
|
498
|
+
operationDigest: string;
|
|
499
|
+
units: number;
|
|
500
|
+
}) | (PurchaseRef & {
|
|
501
|
+
operation: "usage";
|
|
502
|
+
executionId: string;
|
|
503
|
+
sequence: number;
|
|
504
|
+
usedUnits: number;
|
|
505
|
+
result: "delivered" | "failed" | "unknown";
|
|
506
|
+
}) | (PurchaseRef & {
|
|
507
|
+
operation: "refund";
|
|
508
|
+
amount: number;
|
|
509
|
+
}) | (ChargeBase & {
|
|
510
|
+
operation: "configure";
|
|
511
|
+
resource: PaidResource;
|
|
512
|
+
}) | (ChargeBase & {
|
|
513
|
+
operation: "budget";
|
|
514
|
+
buyerTenantId: string;
|
|
515
|
+
limit: number;
|
|
516
|
+
});
|
|
517
|
+
interface ChargeQuote {
|
|
518
|
+
version: string;
|
|
519
|
+
sellerTenantId: string;
|
|
520
|
+
buyerTenantId: string;
|
|
521
|
+
actingAgent: string;
|
|
522
|
+
resource: PaidResource;
|
|
523
|
+
quantity: number;
|
|
524
|
+
amount: number;
|
|
525
|
+
currency: "usd";
|
|
526
|
+
operationDigest: string;
|
|
527
|
+
expiresAt: number;
|
|
528
|
+
accessUntil: number;
|
|
529
|
+
}
|
|
530
|
+
interface ChargeExecution {
|
|
531
|
+
executionId: string;
|
|
532
|
+
/** Original seller-owned verify event captured at reservation, when required. */
|
|
533
|
+
eventId?: string;
|
|
534
|
+
units: number;
|
|
535
|
+
usedUnits: number;
|
|
536
|
+
sequence: number;
|
|
537
|
+
state: "reserved" | "delivered" | "failed" | "unknown";
|
|
538
|
+
leaseUntil: number;
|
|
539
|
+
}
|
|
540
|
+
interface ChargePurchase {
|
|
541
|
+
purchaseId: string;
|
|
542
|
+
quote: ChargeQuote;
|
|
543
|
+
accepted: boolean;
|
|
544
|
+
permission: {
|
|
545
|
+
allowed: boolean;
|
|
546
|
+
source: "seller";
|
|
547
|
+
eventId?: string;
|
|
548
|
+
};
|
|
549
|
+
payment: {
|
|
550
|
+
state: "pending" | "authorized" | "settled" | "failed" | "canceled" | "partially_refunded" | "refunded" | "disputed" | "unknown";
|
|
551
|
+
authorizedAmount: number;
|
|
552
|
+
capturedAmount: number;
|
|
553
|
+
refundedAmount: number;
|
|
554
|
+
refundState?: "none" | "pending" | "succeeded" | "failed" | "unknown";
|
|
555
|
+
disputedAmount: number;
|
|
556
|
+
providerFee: number | null;
|
|
557
|
+
checkedAt: number | null;
|
|
558
|
+
source: "provider";
|
|
559
|
+
};
|
|
560
|
+
delivery: {
|
|
561
|
+
source: "seller_report";
|
|
562
|
+
executions: ChargeExecution[];
|
|
563
|
+
};
|
|
564
|
+
stopped: boolean;
|
|
565
|
+
refundRequestedAmount: number;
|
|
566
|
+
createdAt: number;
|
|
567
|
+
updatedAt: number;
|
|
568
|
+
checkoutUrl?: string;
|
|
569
|
+
}
|
|
570
|
+
type ChargeResponse = {
|
|
571
|
+
ok: true;
|
|
572
|
+
purchase: ChargePurchase;
|
|
573
|
+
next: "accept" | "pay" | "wait" | "seller_permission" | "execute" | "reconcile" | "complete";
|
|
574
|
+
reservation?: {
|
|
575
|
+
executionId: string;
|
|
576
|
+
granted: boolean;
|
|
577
|
+
leaseUntil: number;
|
|
578
|
+
};
|
|
579
|
+
} | {
|
|
580
|
+
ok: true;
|
|
581
|
+
resource: PaidResource;
|
|
582
|
+
} | {
|
|
583
|
+
ok: true;
|
|
584
|
+
budget: {
|
|
585
|
+
limit: number;
|
|
586
|
+
committed: number;
|
|
587
|
+
};
|
|
588
|
+
};
|
|
589
|
+
/** Operational summary, never an execution authorization. Seller cost is optional
|
|
590
|
+
* application evidence; absent cost/fees leaves margin unknown. */
|
|
591
|
+
declare function summarizeCharge(p: ChargePurchase, now?: number, sellerCostCents?: number): {
|
|
592
|
+
paidCompletion: boolean;
|
|
593
|
+
billedCents: number;
|
|
594
|
+
sellerReportedDeliveredCents: number;
|
|
595
|
+
deliveredUnits: number;
|
|
596
|
+
unresolvedUnits: number;
|
|
597
|
+
unresolvedAgeUpperBoundMs: number | null;
|
|
598
|
+
refundedCents: number;
|
|
599
|
+
disputedCents: number;
|
|
600
|
+
captureFeeCents: number | null;
|
|
601
|
+
sellerNetAfterCaptureFeeCents: number | null;
|
|
602
|
+
sellerMarginCents: number | null;
|
|
603
|
+
duplicateCharges: null;
|
|
604
|
+
duplicateEffects: null;
|
|
605
|
+
observedElapsedMs: number;
|
|
606
|
+
};
|
|
607
|
+
|
|
320
608
|
/**
|
|
321
609
|
* Base error for all Chitmark client failures.
|
|
322
610
|
*/
|
|
@@ -393,7 +681,7 @@ interface VerdictTokenClaims {
|
|
|
393
681
|
exp: number;
|
|
394
682
|
degraded: boolean;
|
|
395
683
|
}
|
|
396
|
-
type VerdictTokenErrorCode = "malformed_token" | "wrong_algorithm" | "wrong_type" | "jwks_unavailable" | "unknown_kid" | "invalid_signature" | "expired" | "not_yet_valid" | "wrong_issuer" | "wrong_session" | "wrong_aud" | "wrong_tenant";
|
|
684
|
+
type VerdictTokenErrorCode = "malformed_token" | "wrong_algorithm" | "wrong_type" | "jwks_unavailable" | "unknown_kid" | "invalid_signature" | "expired" | "not_yet_valid" | "wrong_issuer" | "wrong_session" | "wrong_aud" | "wrong_tenant" | "wrong_action_binding";
|
|
397
685
|
declare class VerdictTokenError extends ChitmarkError {
|
|
398
686
|
name: string;
|
|
399
687
|
constructor(code: VerdictTokenErrorCode, message: string);
|
|
@@ -435,9 +723,34 @@ interface VerifyVerdictTokenOptions {
|
|
|
435
723
|
* cross-service authorization, not optional hints.
|
|
436
724
|
*/
|
|
437
725
|
declare function verifyVerdictToken(token: string, options: VerifyVerdictTokenOptions): Promise<VerdictTokenClaims>;
|
|
726
|
+
/** Actions whose receipts require `tenant_step_up` proof and a bound subject. */
|
|
727
|
+
declare const SENSITIVE_RECEIPT_ACTIONS: readonly ["api_key", "data_export", "session_establish", "privilege_elevate", "authenticator_replace", "recovery_contact_change", "session_use", "privilege_change", "release_deploy", "bulk_mutation", "commitment_change", "agent_effect", "agent_escalation", "quote_generate", "queue_priority"];
|
|
728
|
+
type SensitiveReceiptAction = (typeof SENSITIVE_RECEIPT_ACTIONS)[number];
|
|
729
|
+
interface VerifyActionReceiptOptions extends Omit<VerifyVerdictTokenOptions, "aud" | "issuer" | "leewaySeconds"> {
|
|
730
|
+
audience: string;
|
|
731
|
+
action: "trial_activation" | SensitiveReceiptAction;
|
|
732
|
+
subject?: string;
|
|
733
|
+
environment: "test" | "live";
|
|
734
|
+
surface: string;
|
|
735
|
+
digest: string;
|
|
736
|
+
policy: string;
|
|
737
|
+
proof: "none" | "pow_severe" | "tenant_step_up";
|
|
738
|
+
}
|
|
739
|
+
interface ActionReceiptClaims extends VerdictTokenClaims {
|
|
740
|
+
action: "trial_activation" | SensitiveReceiptAction;
|
|
741
|
+
subject?: string;
|
|
742
|
+
environment: "test" | "live";
|
|
743
|
+
surface: string;
|
|
744
|
+
digest: string;
|
|
745
|
+
policy: string;
|
|
746
|
+
proof: "none" | "pow_severe" | "tenant_step_up";
|
|
747
|
+
enforcementMode: "enforce";
|
|
748
|
+
}
|
|
749
|
+
/** Verify authorization for an exact operation, using trusted expected values. */
|
|
750
|
+
declare function verifyActionReceipt(token: string, options: VerifyActionReceiptOptions): Promise<ActionReceiptClaims>;
|
|
438
751
|
|
|
439
752
|
/**
|
|
440
|
-
* Official Chitmark client:
|
|
753
|
+
* Official Chitmark client: security operations and the paid-access lifecycle.
|
|
441
754
|
* Trust decisions on agent-mediated actions, tuned by business outcomes.
|
|
442
755
|
*
|
|
443
756
|
* @example
|
|
@@ -450,7 +763,16 @@ declare function verifyVerdictToken(token: string, options: VerifyVerdictTokenOp
|
|
|
450
763
|
* ```
|
|
451
764
|
*/
|
|
452
765
|
declare class Chitmark {
|
|
453
|
-
|
|
766
|
+
readonly attribution: {
|
|
767
|
+
resolve: (input: AttributionResolveOptions) => Promise<AttributionResult>;
|
|
768
|
+
get: (id: string) => Promise<AttributionResult>;
|
|
769
|
+
createLink: (input: AttributionLinkRequest | AttributionNetworkAgentRequest | AttributionNetworkGrantRequest, idempotencyKey?: string) => Promise<AttributionLink>;
|
|
770
|
+
revokeLink: (id: string) => Promise<void>;
|
|
771
|
+
};
|
|
772
|
+
/** Paid access lifecycle. Transport uncertainty must be resumed, never treated as payment. */
|
|
773
|
+
charge(request: ChargeRequest): Promise<ChargeResponse>;
|
|
774
|
+
private readonly apiKey?;
|
|
775
|
+
private readonly credentialProvider?;
|
|
454
776
|
private readonly baseUrl;
|
|
455
777
|
private readonly timeoutMs;
|
|
456
778
|
private readonly piiMode;
|
|
@@ -498,7 +820,8 @@ declare class Chitmark {
|
|
|
498
820
|
/**
|
|
499
821
|
* Complete a challenge by submitting its solved proof. Clears only the bound
|
|
500
822
|
* session, once. Does not authorize the action: re-verify with
|
|
501
|
-
* `context.challengeId`
|
|
823
|
+
* `context.challengeId` for standalone challenges or the original action
|
|
824
|
+
* binding plus the challenge and event IDs for operation-bound challenges.
|
|
502
825
|
*/
|
|
503
826
|
completeChallenge(request: {
|
|
504
827
|
eventId: string;
|
|
@@ -522,6 +845,7 @@ declare class Chitmark {
|
|
|
522
845
|
method: string;
|
|
523
846
|
body?: unknown;
|
|
524
847
|
idempotencyKey?: string;
|
|
848
|
+
timeoutMs?: number;
|
|
525
849
|
}): Promise<T>;
|
|
526
850
|
/** Public accessors for inspection / tests. */
|
|
527
851
|
get config(): {
|
|
@@ -593,6 +917,163 @@ declare function isEligibleAllow(verdict: Verdict): verdict is EligibleAllowVerd
|
|
|
593
917
|
*/
|
|
594
918
|
declare function verdictToHttpStatus(verdict: Verdict): ChitmarkHttpStatus;
|
|
595
919
|
|
|
920
|
+
/** Server-owned operation for the trial credit grant profile. Use opaque IDs. */
|
|
921
|
+
interface TrialCreditOperation {
|
|
922
|
+
operationId: string;
|
|
923
|
+
target: string;
|
|
924
|
+
quota: number;
|
|
925
|
+
recipient?: string;
|
|
926
|
+
}
|
|
927
|
+
/** Hash the exact operation that will be executed. IDs are case sensitive. */
|
|
928
|
+
declare function trialCreditOperationDigest(operation: TrialCreditOperation): Promise<string>;
|
|
929
|
+
|
|
930
|
+
/** Offline evidence only. These APIs never grant execution authority or fetch trust. */
|
|
931
|
+
type EvidenceKey = {
|
|
932
|
+
kid: string;
|
|
933
|
+
jwk: Record<string, unknown>;
|
|
934
|
+
notBefore: number;
|
|
935
|
+
notAfter: number;
|
|
936
|
+
revokedAt?: number;
|
|
937
|
+
compromisedAt?: number;
|
|
938
|
+
};
|
|
939
|
+
type EvidenceSigningKey = {
|
|
940
|
+
kty?: string;
|
|
941
|
+
crv?: string;
|
|
942
|
+
alg?: string;
|
|
943
|
+
x?: string;
|
|
944
|
+
y?: string;
|
|
945
|
+
d?: string;
|
|
946
|
+
ext?: boolean;
|
|
947
|
+
key_ops?: string[];
|
|
948
|
+
};
|
|
949
|
+
declare class EvidenceError extends Error {
|
|
950
|
+
readonly code: string;
|
|
951
|
+
constructor(code: string);
|
|
952
|
+
}
|
|
953
|
+
declare function evidenceAssert(value: unknown, code: string): asserts value;
|
|
954
|
+
/** Restricted canonical JSON: ASCII strings/keys, safe integers, arrays and plain objects. */
|
|
955
|
+
declare function canonicalEvidence(value: unknown): string;
|
|
956
|
+
declare function evidenceHash(value: string): Promise<string>;
|
|
957
|
+
declare function evidenceKeyAt(history: EvidenceKey[], kid: string, at: number): EvidenceKey;
|
|
958
|
+
declare function verifyEvidenceSignature(token: string, typ: string, history: EvidenceKey[], at: number): Promise<Record<string, unknown>>;
|
|
959
|
+
declare function signEvidence(payload: object, typ: string, kid: string, jwk: EvidenceSigningKey): Promise<string>;
|
|
960
|
+
type PortableRecord = {
|
|
961
|
+
id: string;
|
|
962
|
+
eventId: string;
|
|
963
|
+
kind: "decision" | "execution" | "outcome";
|
|
964
|
+
occurredAt: number;
|
|
965
|
+
recordedAt: number;
|
|
966
|
+
policyRevision: string | null;
|
|
967
|
+
result: string;
|
|
968
|
+
source: "decision_service" | "customer_report";
|
|
969
|
+
receipt: string | null;
|
|
970
|
+
};
|
|
971
|
+
type EvidenceManifest = {
|
|
972
|
+
version: 1;
|
|
973
|
+
issuer: "https://portal.chitmark.com";
|
|
974
|
+
purpose: "historical_evidence";
|
|
975
|
+
tenantId: string;
|
|
976
|
+
startAt: number;
|
|
977
|
+
endAt: number;
|
|
978
|
+
createdAt: number;
|
|
979
|
+
sourceAsOf: number;
|
|
980
|
+
timeBasis: "issuer_and_ingestion_clocks_not_independent_time";
|
|
981
|
+
completeness: "unknown";
|
|
982
|
+
gaps: string[];
|
|
983
|
+
retention: {
|
|
984
|
+
deleteAfter: number;
|
|
985
|
+
recipient: string;
|
|
986
|
+
exportedCopies: "recipient_controlled";
|
|
987
|
+
redaction: "minimized";
|
|
988
|
+
};
|
|
989
|
+
records: PortableRecord[];
|
|
990
|
+
};
|
|
991
|
+
declare function validateManifest(value: EvidenceManifest, tenantId: string): void;
|
|
992
|
+
type EvidenceBundle = {
|
|
993
|
+
manifest: EvidenceManifest;
|
|
994
|
+
signature: string;
|
|
995
|
+
};
|
|
996
|
+
declare function verifyEvidenceBundle(bundle: EvidenceBundle, options: {
|
|
997
|
+
tenantId: string;
|
|
998
|
+
recipient: string;
|
|
999
|
+
trustedKeys: EvidenceKey[];
|
|
1000
|
+
now: number;
|
|
1001
|
+
}): Promise<{
|
|
1002
|
+
purpose: "historical_evidence";
|
|
1003
|
+
executionAuthorized: false;
|
|
1004
|
+
integrity: "valid";
|
|
1005
|
+
completeness: "unknown";
|
|
1006
|
+
outcomeTruth: "not_established";
|
|
1007
|
+
gaps: string[];
|
|
1008
|
+
}>;
|
|
1009
|
+
/** The witness is supplied by the caller from an independently retained checkpoint,
|
|
1010
|
+
* never taken from a bundle's own claims. Hash comparison binds the exact receipt. */
|
|
1011
|
+
declare function verifyHistoricalReceipt(token: string, options: {
|
|
1012
|
+
tenantId: string;
|
|
1013
|
+
session: string;
|
|
1014
|
+
trustedKeys: EvidenceKey[];
|
|
1015
|
+
witness?: {
|
|
1016
|
+
tokenHash: string;
|
|
1017
|
+
observedAt: number;
|
|
1018
|
+
};
|
|
1019
|
+
}): Promise<{
|
|
1020
|
+
purpose: "historical_evidence";
|
|
1021
|
+
executionAuthorized: false;
|
|
1022
|
+
eventId: string;
|
|
1023
|
+
policyRevision: string | null;
|
|
1024
|
+
timeIntegrity: string;
|
|
1025
|
+
}>;
|
|
1026
|
+
|
|
1027
|
+
type EvidenceCheckpoint = {
|
|
1028
|
+
version: 1;
|
|
1029
|
+
tenantId: string;
|
|
1030
|
+
epoch: string;
|
|
1031
|
+
expiresAt: number;
|
|
1032
|
+
size: number;
|
|
1033
|
+
root: string;
|
|
1034
|
+
observedAt: number;
|
|
1035
|
+
};
|
|
1036
|
+
type Commitment = {
|
|
1037
|
+
id: string;
|
|
1038
|
+
salt: string;
|
|
1039
|
+
record: object;
|
|
1040
|
+
ingestedAt: number;
|
|
1041
|
+
};
|
|
1042
|
+
declare const evidenceCommitment: (cp: Pick<EvidenceCheckpoint, "tenantId" | "epoch" | "expiresAt">, record: object, salt: string) => Promise<string>;
|
|
1043
|
+
/** Bounded linear commitment proof, not a public transparency log or a minimal Merkle proof. */
|
|
1044
|
+
declare function checkpointFromCommitments(input: {
|
|
1045
|
+
tenantId: string;
|
|
1046
|
+
epoch: string;
|
|
1047
|
+
expiresAt: number;
|
|
1048
|
+
observedAt: number;
|
|
1049
|
+
commitments: string[];
|
|
1050
|
+
}): Promise<EvidenceCheckpoint>;
|
|
1051
|
+
declare function verifyCheckpointAppend(older: EvidenceCheckpoint, newer: EvidenceCheckpoint, appended: string[] | null, options: {
|
|
1052
|
+
tenantId: string;
|
|
1053
|
+
now: number;
|
|
1054
|
+
}): Promise<{
|
|
1055
|
+
status: "unavailable";
|
|
1056
|
+
completeness: "unknown";
|
|
1057
|
+
} | {
|
|
1058
|
+
status: "consistent";
|
|
1059
|
+
completeness: "unknown";
|
|
1060
|
+
}>;
|
|
1061
|
+
declare function verifyCheckpointInclusion(checkpoint: EvidenceCheckpoint, proof: {
|
|
1062
|
+
index: number;
|
|
1063
|
+
record: object;
|
|
1064
|
+
salt: string;
|
|
1065
|
+
commitments: string[];
|
|
1066
|
+
} | null, options: {
|
|
1067
|
+
tenantId: string;
|
|
1068
|
+
now: number;
|
|
1069
|
+
}): Promise<{
|
|
1070
|
+
status: "unavailable";
|
|
1071
|
+
completeness: "unknown";
|
|
1072
|
+
} | {
|
|
1073
|
+
status: "included";
|
|
1074
|
+
completeness: "unknown";
|
|
1075
|
+
}>;
|
|
1076
|
+
|
|
596
1077
|
/**
|
|
597
1078
|
* Resolve a client IP for verify subject signals from a Fetch Request.
|
|
598
1079
|
*
|
|
@@ -604,4 +1085,4 @@ declare function verdictToHttpStatus(verdict: Verdict): ChitmarkHttpStatus;
|
|
|
604
1085
|
*/
|
|
605
1086
|
declare function getTrustedClientIp(req: Request): string;
|
|
606
1087
|
|
|
607
|
-
export { type Action as A,
|
|
1088
|
+
export { type SensitiveReceiptAction as $, type Action as A, type ChitmarkHttpStatus as B, Chitmark as C, type ChitmarkOptions as D, type Commitment as E, type CredentialProvider as F, type Decision as G, type DecisionCosts as H, type EligibleAllowVerdict as I, type EnforcementMode as J, type EvidenceBundle as K, type EvidenceCheckpoint as L, EvidenceError as M, type EvidenceKey as N, type EvidenceManifest as O, type EvidenceSigningKey as P, type FeedbackRequest as Q, type FeedbackResponse as R, type FeedbackSource as S, type FeedbackUnit as T, type OnDegraded as U, type VerifyContext as V, type Outcome as W, type PiiMode as X, type PortableRecord as Y, type Principal as Z, SENSITIVE_RECEIPT_ACTIONS as _, type VerifyRequest as a, type Subject as a0, type TrialCreditOperation as a1, VERDICT_TOKEN_ISSUER as a2, type VerdictTokenClaims as a3, VerdictTokenError as a4, type VerdictTokenErrorCode as a5, type VerifyActionReceiptOptions as a6, type VerifyVerdictTokenOptions as a7, type WorkloadCredential as a8, canonicalEvidence as a9, type ChargeQuote as aA, type ChargeRequest as aB, type ChargeResponse as aC, type PaidResource as aD, summarizeCharge as aE, checkpointFromCommitments as aa, createDPoPCredentialProvider as ab, degradedChallengeVerdict as ac, enforceDegradedNeverAllow as ad, evidenceAssert as ae, evidenceCommitment as af, evidenceHash as ag, evidenceKeyAt as ah, getTrustedClientIp as ai, hashEmailSha256 as aj, isEligibleAllow as ak, minimizeFormData as al, signEvidence as am, trialCreditOperationDigest as an, truncateIp as ao, validateManifest as ap, verdictToHttpStatus as aq, verifyActionReceipt as ar, verifyCheckpointAppend as as, verifyCheckpointInclusion as at, verifyEvidenceBundle as au, verifyEvidenceSignature as av, verifyHistoricalReceipt as aw, verifyVerdictToken as ax, type ChargeExecution as ay, type ChargePurchase as az, type Verdict as b, type ActionBinding as c, type ActionReceiptClaims as d, type ActorType as e, type AttributionAgentKey as f, type AttributionAgentProof as g, type AttributionLink as h, type AttributionLinkRequest as i, type AttributionNetworkAgentRequest as j, type AttributionNetworkGrantRequest as k, type AttributionNetworkProof as l, type AttributionResolveOptions as m, type AttributionResult as n, CHITMARK_HTTP_STATUS as o, CHITMARK_HTTP_STATUS_MEANING as p, type ChallengeCompletionResponse as q, type ChallengeMethod as r, type ChallengeProof as s, type ChallengeRequest as t, type ChallengeResponse as u, type ChallengeRiskTier as v, ChitmarkApiError as w, type ChitmarkEnv as x, ChitmarkError as y, type ChitmarkErrorBody as z };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chitmark/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"description": "Chitmark TypeScript SDK for Trust Decisions, Agent Attribution, and Agent Paid Access",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": "Chitmark",
|
|
7
7
|
"homepage": "https://chitmark.com",
|