@chitmark/sdk 0.6.5 → 0.8.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/LICENSE +2 -2
- package/README.md +20 -3
- package/dist/edge.cjs +575 -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 +558 -13
- package/dist/edge.js.map +1 -1
- package/dist/index.cjs +608 -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 +590 -13
- package/dist/index.js.map +1 -1
- package/dist/{trusted-ip-Ngrp6dUP.d.cts → trusted-ip-BvSjdU80.d.cts} +460 -12
- package/dist/{trusted-ip-Ngrp6dUP.d.ts → trusted-ip-BvSjdU80.d.ts} +460 -12
- package/package.json +3 -4
|
@@ -1,5 +1,30 @@
|
|
|
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
|
-
* Shared API types for Chitmark
|
|
27
|
+
* Shared API types for Chitmark.
|
|
3
28
|
* Aligns with openapi/openapi.yaml and SDK.md.
|
|
4
29
|
*/
|
|
5
30
|
/** Routing decision from verify. When degraded, this is always "challenge". */
|
|
@@ -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,219 @@ 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 AttributionResolveOptions {
|
|
370
|
+
request: {
|
|
371
|
+
url?: string;
|
|
372
|
+
headers: Headers | Record<string, string | string[] | undefined>;
|
|
373
|
+
};
|
|
374
|
+
/** Explicit site origin for requests with a relative URL, such as IncomingMessage. */
|
|
375
|
+
site?: string;
|
|
376
|
+
/** Opaque credential supplied by the integrating server, never a raw browser cookie. */
|
|
377
|
+
session?: string;
|
|
378
|
+
agentProof?: AttributionAgentProof;
|
|
379
|
+
piiMode?: PiiMode;
|
|
380
|
+
idempotencyKey?: string;
|
|
381
|
+
}
|
|
382
|
+
interface AttributionResult {
|
|
383
|
+
id: string;
|
|
384
|
+
agent: {
|
|
385
|
+
detected: boolean;
|
|
386
|
+
provider: string | null;
|
|
387
|
+
operator_verified: boolean;
|
|
388
|
+
};
|
|
389
|
+
identity: {
|
|
390
|
+
recognized: boolean;
|
|
391
|
+
subject_id: string | null;
|
|
392
|
+
scope: "site" | null;
|
|
393
|
+
match: "none" | "existing_session" | "verified_identity_link";
|
|
394
|
+
};
|
|
395
|
+
principal: {
|
|
396
|
+
status: "unknown" | "previously_verified";
|
|
397
|
+
email: string | null;
|
|
398
|
+
email_verified: boolean | null;
|
|
399
|
+
current_delegation_verified: boolean | null;
|
|
400
|
+
document_verified: boolean | null;
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
interface AttributionLinkRequest {
|
|
404
|
+
enrollmentId: string;
|
|
405
|
+
site: string;
|
|
406
|
+
agentKey: {
|
|
407
|
+
kty: "OKP";
|
|
408
|
+
crv: "Ed25519";
|
|
409
|
+
x: string;
|
|
410
|
+
};
|
|
411
|
+
recipientKeyId: string;
|
|
412
|
+
emailConsent: boolean;
|
|
413
|
+
expiresAt: number;
|
|
414
|
+
principalProof: string;
|
|
415
|
+
}
|
|
416
|
+
interface AttributionLink {
|
|
417
|
+
id: string;
|
|
418
|
+
expires_at: number;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** Integer USD cents. Customer purchases are separate from Chitmark subscriptions. */
|
|
422
|
+
interface PaidResource {
|
|
423
|
+
resourceId: string;
|
|
424
|
+
version: number;
|
|
425
|
+
kind: "api_call" | "dataset" | "compute";
|
|
426
|
+
unit: "call" | "access" | "compute_second";
|
|
427
|
+
unitAmount: number;
|
|
428
|
+
currency: "usd";
|
|
429
|
+
minQuantity: number;
|
|
430
|
+
maxQuantity: number;
|
|
431
|
+
maxAmount: number;
|
|
432
|
+
quoteTtlSeconds: number;
|
|
433
|
+
accessTtlSeconds: number;
|
|
434
|
+
enabled: boolean;
|
|
435
|
+
refundTerms: "unused_only";
|
|
436
|
+
}
|
|
437
|
+
type ChargeBase = {
|
|
438
|
+
sellerTenantId: string;
|
|
439
|
+
idempotencyKey?: string;
|
|
440
|
+
};
|
|
441
|
+
type PurchaseRef = ChargeBase & {
|
|
442
|
+
purchaseId: string;
|
|
443
|
+
};
|
|
444
|
+
type ChargeRequest = (ChargeBase & {
|
|
445
|
+
operation: "resource";
|
|
446
|
+
resourceId: string;
|
|
447
|
+
}) | (ChargeBase & {
|
|
448
|
+
operation: "quote";
|
|
449
|
+
resourceId: string;
|
|
450
|
+
quantity: number;
|
|
451
|
+
operationDigest: string;
|
|
452
|
+
}) | (PurchaseRef & {
|
|
453
|
+
operation: "accept";
|
|
454
|
+
quoteVersion: string;
|
|
455
|
+
maxAmount: number;
|
|
456
|
+
currency: "usd";
|
|
457
|
+
}) | (PurchaseRef & {
|
|
458
|
+
operation: "status" | "cancel" | "reconcile";
|
|
459
|
+
}) | (PurchaseRef & {
|
|
460
|
+
operation: "permission";
|
|
461
|
+
allowed: boolean;
|
|
462
|
+
eventId?: string;
|
|
463
|
+
}) | (PurchaseRef & {
|
|
464
|
+
operation: "reserve";
|
|
465
|
+
executionId: string;
|
|
466
|
+
operationDigest: string;
|
|
467
|
+
units: number;
|
|
468
|
+
}) | (PurchaseRef & {
|
|
469
|
+
operation: "usage";
|
|
470
|
+
executionId: string;
|
|
471
|
+
sequence: number;
|
|
472
|
+
usedUnits: number;
|
|
473
|
+
result: "delivered" | "failed" | "unknown";
|
|
474
|
+
}) | (PurchaseRef & {
|
|
475
|
+
operation: "refund";
|
|
476
|
+
amount: number;
|
|
477
|
+
}) | (ChargeBase & {
|
|
478
|
+
operation: "configure";
|
|
479
|
+
resource: PaidResource;
|
|
480
|
+
}) | (ChargeBase & {
|
|
481
|
+
operation: "budget";
|
|
482
|
+
buyerTenantId: string;
|
|
483
|
+
limit: number;
|
|
484
|
+
});
|
|
485
|
+
interface ChargeQuote {
|
|
486
|
+
version: string;
|
|
487
|
+
sellerTenantId: string;
|
|
488
|
+
buyerTenantId: string;
|
|
489
|
+
actingAgent: string;
|
|
490
|
+
resource: PaidResource;
|
|
491
|
+
quantity: number;
|
|
492
|
+
amount: number;
|
|
493
|
+
currency: "usd";
|
|
494
|
+
operationDigest: string;
|
|
495
|
+
expiresAt: number;
|
|
496
|
+
accessUntil: number;
|
|
497
|
+
}
|
|
498
|
+
interface ChargeExecution {
|
|
499
|
+
executionId: string;
|
|
500
|
+
/** Original seller-owned verify event captured at reservation, when required. */
|
|
501
|
+
eventId?: string;
|
|
502
|
+
units: number;
|
|
503
|
+
usedUnits: number;
|
|
504
|
+
sequence: number;
|
|
505
|
+
state: "reserved" | "delivered" | "failed" | "unknown";
|
|
506
|
+
leaseUntil: number;
|
|
507
|
+
}
|
|
508
|
+
interface ChargePurchase {
|
|
509
|
+
purchaseId: string;
|
|
510
|
+
quote: ChargeQuote;
|
|
511
|
+
accepted: boolean;
|
|
512
|
+
permission: {
|
|
513
|
+
allowed: boolean;
|
|
514
|
+
source: "seller";
|
|
515
|
+
eventId?: string;
|
|
516
|
+
};
|
|
517
|
+
payment: {
|
|
518
|
+
state: "pending" | "authorized" | "settled" | "failed" | "canceled" | "partially_refunded" | "refunded" | "disputed" | "unknown";
|
|
519
|
+
authorizedAmount: number;
|
|
520
|
+
capturedAmount: number;
|
|
521
|
+
refundedAmount: number;
|
|
522
|
+
refundState?: "none" | "pending" | "succeeded" | "failed" | "unknown";
|
|
523
|
+
disputedAmount: number;
|
|
524
|
+
providerFee: number | null;
|
|
525
|
+
checkedAt: number | null;
|
|
526
|
+
source: "provider";
|
|
527
|
+
};
|
|
528
|
+
delivery: {
|
|
529
|
+
source: "seller_report";
|
|
530
|
+
executions: ChargeExecution[];
|
|
531
|
+
};
|
|
532
|
+
stopped: boolean;
|
|
533
|
+
refundRequestedAmount: number;
|
|
534
|
+
createdAt: number;
|
|
535
|
+
updatedAt: number;
|
|
536
|
+
checkoutUrl?: string;
|
|
537
|
+
}
|
|
538
|
+
type ChargeResponse = {
|
|
539
|
+
ok: true;
|
|
540
|
+
purchase: ChargePurchase;
|
|
541
|
+
next: "accept" | "pay" | "wait" | "seller_permission" | "execute" | "reconcile" | "complete";
|
|
542
|
+
reservation?: {
|
|
543
|
+
executionId: string;
|
|
544
|
+
granted: boolean;
|
|
545
|
+
leaseUntil: number;
|
|
546
|
+
};
|
|
547
|
+
} | {
|
|
548
|
+
ok: true;
|
|
549
|
+
resource: PaidResource;
|
|
550
|
+
} | {
|
|
551
|
+
ok: true;
|
|
552
|
+
budget: {
|
|
553
|
+
limit: number;
|
|
554
|
+
committed: number;
|
|
555
|
+
};
|
|
556
|
+
};
|
|
557
|
+
/** Operational summary, never an execution authorization. Seller cost is optional
|
|
558
|
+
* application evidence; absent cost/fees leaves margin unknown. */
|
|
559
|
+
declare function summarizeCharge(p: ChargePurchase, now?: number, sellerCostCents?: number): {
|
|
560
|
+
paidCompletion: boolean;
|
|
561
|
+
billedCents: number;
|
|
562
|
+
sellerReportedDeliveredCents: number;
|
|
563
|
+
deliveredUnits: number;
|
|
564
|
+
unresolvedUnits: number;
|
|
565
|
+
unresolvedAgeUpperBoundMs: number | null;
|
|
566
|
+
refundedCents: number;
|
|
567
|
+
disputedCents: number;
|
|
568
|
+
captureFeeCents: number | null;
|
|
569
|
+
sellerNetAfterCaptureFeeCents: number | null;
|
|
570
|
+
sellerMarginCents: number | null;
|
|
571
|
+
duplicateCharges: null;
|
|
572
|
+
duplicateEffects: null;
|
|
573
|
+
observedElapsedMs: number;
|
|
574
|
+
};
|
|
575
|
+
|
|
320
576
|
/**
|
|
321
577
|
* Base error for all Chitmark client failures.
|
|
322
578
|
*/
|
|
@@ -393,7 +649,7 @@ interface VerdictTokenClaims {
|
|
|
393
649
|
exp: number;
|
|
394
650
|
degraded: boolean;
|
|
395
651
|
}
|
|
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";
|
|
652
|
+
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
653
|
declare class VerdictTokenError extends ChitmarkError {
|
|
398
654
|
name: string;
|
|
399
655
|
constructor(code: VerdictTokenErrorCode, message: string);
|
|
@@ -435,11 +691,35 @@ interface VerifyVerdictTokenOptions {
|
|
|
435
691
|
* cross-service authorization, not optional hints.
|
|
436
692
|
*/
|
|
437
693
|
declare function verifyVerdictToken(token: string, options: VerifyVerdictTokenOptions): Promise<VerdictTokenClaims>;
|
|
694
|
+
/** Actions whose receipts require `tenant_step_up` proof and a bound subject. */
|
|
695
|
+
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"];
|
|
696
|
+
type SensitiveReceiptAction = (typeof SENSITIVE_RECEIPT_ACTIONS)[number];
|
|
697
|
+
interface VerifyActionReceiptOptions extends Omit<VerifyVerdictTokenOptions, "aud" | "issuer" | "leewaySeconds"> {
|
|
698
|
+
audience: string;
|
|
699
|
+
action: "trial_activation" | SensitiveReceiptAction;
|
|
700
|
+
subject?: string;
|
|
701
|
+
environment: "test" | "live";
|
|
702
|
+
surface: string;
|
|
703
|
+
digest: string;
|
|
704
|
+
policy: string;
|
|
705
|
+
proof: "none" | "pow_severe" | "tenant_step_up";
|
|
706
|
+
}
|
|
707
|
+
interface ActionReceiptClaims extends VerdictTokenClaims {
|
|
708
|
+
action: "trial_activation" | SensitiveReceiptAction;
|
|
709
|
+
subject?: string;
|
|
710
|
+
environment: "test" | "live";
|
|
711
|
+
surface: string;
|
|
712
|
+
digest: string;
|
|
713
|
+
policy: string;
|
|
714
|
+
proof: "none" | "pow_severe" | "tenant_step_up";
|
|
715
|
+
enforcementMode: "enforce";
|
|
716
|
+
}
|
|
717
|
+
/** Verify authorization for an exact operation, using trusted expected values. */
|
|
718
|
+
declare function verifyActionReceipt(token: string, options: VerifyActionReceiptOptions): Promise<ActionReceiptClaims>;
|
|
438
719
|
|
|
439
720
|
/**
|
|
440
|
-
* Official Chitmark client
|
|
441
|
-
*
|
|
442
|
-
* tuned by business outcomes.
|
|
721
|
+
* Official Chitmark client: security operations and the paid-access lifecycle.
|
|
722
|
+
* Trust decisions on agent-mediated actions, tuned by business outcomes.
|
|
443
723
|
*
|
|
444
724
|
* @example
|
|
445
725
|
* ```ts
|
|
@@ -451,7 +731,16 @@ declare function verifyVerdictToken(token: string, options: VerifyVerdictTokenOp
|
|
|
451
731
|
* ```
|
|
452
732
|
*/
|
|
453
733
|
declare class Chitmark {
|
|
454
|
-
|
|
734
|
+
readonly attribution: {
|
|
735
|
+
resolve: (input: AttributionResolveOptions) => Promise<AttributionResult>;
|
|
736
|
+
get: (id: string) => Promise<AttributionResult>;
|
|
737
|
+
createLink: (input: AttributionLinkRequest, idempotencyKey?: string) => Promise<AttributionLink>;
|
|
738
|
+
revokeLink: (id: string) => Promise<void>;
|
|
739
|
+
};
|
|
740
|
+
/** Paid access lifecycle. Transport uncertainty must be resumed, never treated as payment. */
|
|
741
|
+
charge(request: ChargeRequest): Promise<ChargeResponse>;
|
|
742
|
+
private readonly apiKey?;
|
|
743
|
+
private readonly credentialProvider?;
|
|
455
744
|
private readonly baseUrl;
|
|
456
745
|
private readonly timeoutMs;
|
|
457
746
|
private readonly piiMode;
|
|
@@ -499,7 +788,8 @@ declare class Chitmark {
|
|
|
499
788
|
/**
|
|
500
789
|
* Complete a challenge by submitting its solved proof. Clears only the bound
|
|
501
790
|
* session, once. Does not authorize the action: re-verify with
|
|
502
|
-
* `context.challengeId`
|
|
791
|
+
* `context.challengeId` for standalone challenges or the original action
|
|
792
|
+
* binding plus the challenge and event IDs for operation-bound challenges.
|
|
503
793
|
*/
|
|
504
794
|
completeChallenge(request: {
|
|
505
795
|
eventId: string;
|
|
@@ -523,6 +813,7 @@ declare class Chitmark {
|
|
|
523
813
|
method: string;
|
|
524
814
|
body?: unknown;
|
|
525
815
|
idempotencyKey?: string;
|
|
816
|
+
timeoutMs?: number;
|
|
526
817
|
}): Promise<T>;
|
|
527
818
|
/** Public accessors for inspection / tests. */
|
|
528
819
|
get config(): {
|
|
@@ -594,6 +885,163 @@ declare function isEligibleAllow(verdict: Verdict): verdict is EligibleAllowVerd
|
|
|
594
885
|
*/
|
|
595
886
|
declare function verdictToHttpStatus(verdict: Verdict): ChitmarkHttpStatus;
|
|
596
887
|
|
|
888
|
+
/** Server-owned operation for the trial credit grant profile. Use opaque IDs. */
|
|
889
|
+
interface TrialCreditOperation {
|
|
890
|
+
operationId: string;
|
|
891
|
+
target: string;
|
|
892
|
+
quota: number;
|
|
893
|
+
recipient?: string;
|
|
894
|
+
}
|
|
895
|
+
/** Hash the exact operation that will be executed. IDs are case sensitive. */
|
|
896
|
+
declare function trialCreditOperationDigest(operation: TrialCreditOperation): Promise<string>;
|
|
897
|
+
|
|
898
|
+
/** Offline evidence only. These APIs never grant execution authority or fetch trust. */
|
|
899
|
+
type EvidenceKey = {
|
|
900
|
+
kid: string;
|
|
901
|
+
jwk: Record<string, unknown>;
|
|
902
|
+
notBefore: number;
|
|
903
|
+
notAfter: number;
|
|
904
|
+
revokedAt?: number;
|
|
905
|
+
compromisedAt?: number;
|
|
906
|
+
};
|
|
907
|
+
type EvidenceSigningKey = {
|
|
908
|
+
kty?: string;
|
|
909
|
+
crv?: string;
|
|
910
|
+
alg?: string;
|
|
911
|
+
x?: string;
|
|
912
|
+
y?: string;
|
|
913
|
+
d?: string;
|
|
914
|
+
ext?: boolean;
|
|
915
|
+
key_ops?: string[];
|
|
916
|
+
};
|
|
917
|
+
declare class EvidenceError extends Error {
|
|
918
|
+
readonly code: string;
|
|
919
|
+
constructor(code: string);
|
|
920
|
+
}
|
|
921
|
+
declare function evidenceAssert(value: unknown, code: string): asserts value;
|
|
922
|
+
/** Restricted canonical JSON: ASCII strings/keys, safe integers, arrays and plain objects. */
|
|
923
|
+
declare function canonicalEvidence(value: unknown): string;
|
|
924
|
+
declare function evidenceHash(value: string): Promise<string>;
|
|
925
|
+
declare function evidenceKeyAt(history: EvidenceKey[], kid: string, at: number): EvidenceKey;
|
|
926
|
+
declare function verifyEvidenceSignature(token: string, typ: string, history: EvidenceKey[], at: number): Promise<Record<string, unknown>>;
|
|
927
|
+
declare function signEvidence(payload: object, typ: string, kid: string, jwk: EvidenceSigningKey): Promise<string>;
|
|
928
|
+
type PortableRecord = {
|
|
929
|
+
id: string;
|
|
930
|
+
eventId: string;
|
|
931
|
+
kind: "decision" | "execution" | "outcome";
|
|
932
|
+
occurredAt: number;
|
|
933
|
+
recordedAt: number;
|
|
934
|
+
policyRevision: string | null;
|
|
935
|
+
result: string;
|
|
936
|
+
source: "decision_service" | "customer_report";
|
|
937
|
+
receipt: string | null;
|
|
938
|
+
};
|
|
939
|
+
type EvidenceManifest = {
|
|
940
|
+
version: 1;
|
|
941
|
+
issuer: "https://portal.chitmark.com";
|
|
942
|
+
purpose: "historical_evidence";
|
|
943
|
+
tenantId: string;
|
|
944
|
+
startAt: number;
|
|
945
|
+
endAt: number;
|
|
946
|
+
createdAt: number;
|
|
947
|
+
sourceAsOf: number;
|
|
948
|
+
timeBasis: "issuer_and_ingestion_clocks_not_independent_time";
|
|
949
|
+
completeness: "unknown";
|
|
950
|
+
gaps: string[];
|
|
951
|
+
retention: {
|
|
952
|
+
deleteAfter: number;
|
|
953
|
+
recipient: string;
|
|
954
|
+
exportedCopies: "recipient_controlled";
|
|
955
|
+
redaction: "minimized";
|
|
956
|
+
};
|
|
957
|
+
records: PortableRecord[];
|
|
958
|
+
};
|
|
959
|
+
declare function validateManifest(value: EvidenceManifest, tenantId: string): void;
|
|
960
|
+
type EvidenceBundle = {
|
|
961
|
+
manifest: EvidenceManifest;
|
|
962
|
+
signature: string;
|
|
963
|
+
};
|
|
964
|
+
declare function verifyEvidenceBundle(bundle: EvidenceBundle, options: {
|
|
965
|
+
tenantId: string;
|
|
966
|
+
recipient: string;
|
|
967
|
+
trustedKeys: EvidenceKey[];
|
|
968
|
+
now: number;
|
|
969
|
+
}): Promise<{
|
|
970
|
+
purpose: "historical_evidence";
|
|
971
|
+
executionAuthorized: false;
|
|
972
|
+
integrity: "valid";
|
|
973
|
+
completeness: "unknown";
|
|
974
|
+
outcomeTruth: "not_established";
|
|
975
|
+
gaps: string[];
|
|
976
|
+
}>;
|
|
977
|
+
/** The witness is supplied by the caller from an independently retained checkpoint,
|
|
978
|
+
* never taken from a bundle's own claims. Hash comparison binds the exact receipt. */
|
|
979
|
+
declare function verifyHistoricalReceipt(token: string, options: {
|
|
980
|
+
tenantId: string;
|
|
981
|
+
session: string;
|
|
982
|
+
trustedKeys: EvidenceKey[];
|
|
983
|
+
witness?: {
|
|
984
|
+
tokenHash: string;
|
|
985
|
+
observedAt: number;
|
|
986
|
+
};
|
|
987
|
+
}): Promise<{
|
|
988
|
+
purpose: "historical_evidence";
|
|
989
|
+
executionAuthorized: false;
|
|
990
|
+
eventId: string;
|
|
991
|
+
policyRevision: string | null;
|
|
992
|
+
timeIntegrity: string;
|
|
993
|
+
}>;
|
|
994
|
+
|
|
995
|
+
type EvidenceCheckpoint = {
|
|
996
|
+
version: 1;
|
|
997
|
+
tenantId: string;
|
|
998
|
+
epoch: string;
|
|
999
|
+
expiresAt: number;
|
|
1000
|
+
size: number;
|
|
1001
|
+
root: string;
|
|
1002
|
+
observedAt: number;
|
|
1003
|
+
};
|
|
1004
|
+
type Commitment = {
|
|
1005
|
+
id: string;
|
|
1006
|
+
salt: string;
|
|
1007
|
+
record: object;
|
|
1008
|
+
ingestedAt: number;
|
|
1009
|
+
};
|
|
1010
|
+
declare const evidenceCommitment: (cp: Pick<EvidenceCheckpoint, "tenantId" | "epoch" | "expiresAt">, record: object, salt: string) => Promise<string>;
|
|
1011
|
+
/** Bounded linear commitment proof, not a public transparency log or a minimal Merkle proof. */
|
|
1012
|
+
declare function checkpointFromCommitments(input: {
|
|
1013
|
+
tenantId: string;
|
|
1014
|
+
epoch: string;
|
|
1015
|
+
expiresAt: number;
|
|
1016
|
+
observedAt: number;
|
|
1017
|
+
commitments: string[];
|
|
1018
|
+
}): Promise<EvidenceCheckpoint>;
|
|
1019
|
+
declare function verifyCheckpointAppend(older: EvidenceCheckpoint, newer: EvidenceCheckpoint, appended: string[] | null, options: {
|
|
1020
|
+
tenantId: string;
|
|
1021
|
+
now: number;
|
|
1022
|
+
}): Promise<{
|
|
1023
|
+
status: "unavailable";
|
|
1024
|
+
completeness: "unknown";
|
|
1025
|
+
} | {
|
|
1026
|
+
status: "consistent";
|
|
1027
|
+
completeness: "unknown";
|
|
1028
|
+
}>;
|
|
1029
|
+
declare function verifyCheckpointInclusion(checkpoint: EvidenceCheckpoint, proof: {
|
|
1030
|
+
index: number;
|
|
1031
|
+
record: object;
|
|
1032
|
+
salt: string;
|
|
1033
|
+
commitments: string[];
|
|
1034
|
+
} | null, options: {
|
|
1035
|
+
tenantId: string;
|
|
1036
|
+
now: number;
|
|
1037
|
+
}): Promise<{
|
|
1038
|
+
status: "unavailable";
|
|
1039
|
+
completeness: "unknown";
|
|
1040
|
+
} | {
|
|
1041
|
+
status: "included";
|
|
1042
|
+
completeness: "unknown";
|
|
1043
|
+
}>;
|
|
1044
|
+
|
|
597
1045
|
/**
|
|
598
1046
|
* Resolve a client IP for verify subject signals from a Fetch Request.
|
|
599
1047
|
*
|
|
@@ -605,4 +1053,4 @@ declare function verdictToHttpStatus(verdict: Verdict): ChitmarkHttpStatus;
|
|
|
605
1053
|
*/
|
|
606
1054
|
declare function getTrustedClientIp(req: Request): string;
|
|
607
1055
|
|
|
608
|
-
export { type Action as A,
|
|
1056
|
+
export { type VerdictTokenClaims as $, type Action as A, type DecisionCosts as B, Chitmark as C, type Decision as D, type EligibleAllowVerdict as E, type EnforcementMode as F, type EvidenceBundle as G, type EvidenceCheckpoint as H, EvidenceError as I, type EvidenceKey as J, type EvidenceManifest as K, type EvidenceSigningKey as L, type FeedbackRequest as M, type FeedbackResponse as N, type FeedbackSource as O, type FeedbackUnit as P, type OnDegraded as Q, type Outcome as R, type PiiMode as S, type PortableRecord as T, type Principal as U, type VerifyContext as V, SENSITIVE_RECEIPT_ACTIONS as W, type SensitiveReceiptAction as X, type Subject as Y, type TrialCreditOperation as Z, VERDICT_TOKEN_ISSUER as _, type VerifyRequest as a, VerdictTokenError as a0, type VerdictTokenErrorCode as a1, type VerifyActionReceiptOptions as a2, type VerifyVerdictTokenOptions as a3, type WorkloadCredential as a4, canonicalEvidence as a5, checkpointFromCommitments as a6, createDPoPCredentialProvider as a7, degradedChallengeVerdict as a8, enforceDegradedNeverAllow as a9, summarizeCharge as aA, evidenceAssert as aa, evidenceCommitment as ab, evidenceHash as ac, evidenceKeyAt as ad, getTrustedClientIp as ae, hashEmailSha256 as af, isEligibleAllow as ag, minimizeFormData as ah, signEvidence as ai, trialCreditOperationDigest as aj, truncateIp as ak, validateManifest as al, verdictToHttpStatus as am, verifyActionReceipt as an, verifyCheckpointAppend as ao, verifyCheckpointInclusion as ap, verifyEvidenceBundle as aq, verifyEvidenceSignature as ar, verifyHistoricalReceipt as as, verifyVerdictToken as at, type ChargeExecution as au, type ChargePurchase as av, type ChargeQuote as aw, type ChargeRequest as ax, type ChargeResponse as ay, type PaidResource as az, type Verdict as b, type ActionBinding as c, type ActionReceiptClaims as d, type ActorType as e, type AttributionAgentProof as f, type AttributionLink as g, type AttributionLinkRequest as h, type AttributionResolveOptions as i, type AttributionResult as j, CHITMARK_HTTP_STATUS as k, CHITMARK_HTTP_STATUS_MEANING as l, type ChallengeCompletionResponse as m, type ChallengeMethod as n, type ChallengeProof as o, type ChallengeRequest as p, type ChallengeResponse as q, type ChallengeRiskTier as r, ChitmarkApiError as s, type ChitmarkEnv as t, ChitmarkError as u, type ChitmarkErrorBody as v, type ChitmarkHttpStatus as w, type ChitmarkOptions as x, type Commitment as y, type CredentialProvider as z };
|