verdifax 1.2.0 → 1.3.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/index.d.ts CHANGED
@@ -318,8 +318,13 @@ interface DeterminismRun {
318
318
  manifest_hash: string;
319
319
  bundle_hash: string;
320
320
  duration_ms: number;
321
+ /** `ok`, `stage_error`, or the refusal or halt kind, such as
322
+ * `pepg_deny`. */
321
323
  status: string;
322
324
  error?: string;
325
+ /** The sealed receipt of a refused or halted run. The run's manifest
326
+ * hash covers its hash. */
327
+ receipt?: Record<string, unknown>;
323
328
  }
324
329
  /** How the two runs of a determinism check compared. */
325
330
  interface DeterminismDiff {
@@ -327,9 +332,12 @@ interface DeterminismDiff {
327
332
  manifest_hash_differs: boolean;
328
333
  bundle_hash_differs: boolean;
329
334
  differing_fields?: string[];
335
+ /** Why there is no verdict, when neither run sealed a record. */
336
+ reason?: string;
330
337
  }
331
338
  /** Body returned by POST /execute/verify-determinism. `deterministic`
332
- * means both runs ended ok with equal manifest hashes. */
339
+ * means both runs ended the same way, completed or refused, with equal
340
+ * manifest hashes. */
333
341
  interface VerifyDeterminismResponse {
334
342
  ok: boolean;
335
343
  deterministic: boolean;
@@ -476,6 +484,8 @@ interface ListRunsParams {
476
484
  * for the full sealed manifest. */
477
485
  interface RunSummary {
478
486
  id: number;
487
+ /** The key that requested the run. */
488
+ api_key_id?: number;
479
489
  created_at: string;
480
490
  program_id: Hex64;
481
491
  route_id: string;
@@ -512,6 +522,9 @@ interface ExportRunsParams {
512
522
  /** One run in an evidence export: what the server stored, not a verdict. */
513
523
  interface ExportRow {
514
524
  run_id: number;
525
+ /** The key that requested the run, so an account's export can be
526
+ * grouped by key. */
527
+ api_key_id?: number;
515
528
  created_at: string;
516
529
  status: RunStatus;
517
530
  error_stage: string;
@@ -541,6 +554,21 @@ interface RunsExport {
541
554
  /** Rows returned, counted by status. */
542
555
  by_status: Record<string, number>;
543
556
  runs: ExportRow[];
557
+ /** The key's policy documents, when it has loaded any. */
558
+ policy_documents?: PolicyWithDocument[];
559
+ /** The key's policy changes, oldest first, when it has loaded any. */
560
+ policy_history?: PolicyActivation[];
561
+ /** The key's account, as `account-N`. */
562
+ account_id?: string;
563
+ /** The account's policy documents, when it has loaded any. */
564
+ account_policy_documents?: PolicyWithDocument[];
565
+ /** The account's policy changes, oldest first, when it has loaded any. */
566
+ account_policy_history?: PolicyActivation[];
567
+ }
568
+ /** Returned by {@link VerdifaxClient.exportAccountRuns}: the runs of every
569
+ * key in the account, with the account's policy documents and changes. */
570
+ interface AccountRunsExport extends RunsExport {
571
+ account_id: string;
544
572
  }
545
573
  /** Returned by {@link VerdifaxClient.exportRunsCSV}. */
546
574
  interface RunsExportCSV {
@@ -629,6 +657,93 @@ interface AdminCreateKeyResponse {
629
657
  name: string;
630
658
  secret: string;
631
659
  hint: string;
660
+ /** The key's account, as `account-N`. */
661
+ account_id?: string;
662
+ }
663
+ /** Options for {@link VerdifaxClient.adminCreateKey}. */
664
+ interface AdminCreateKeyOptions {
665
+ /** Puts the customer key in this existing account, by its number. Without
666
+ * it the key gets an account of its own. A key never changes account. */
667
+ accountId?: number;
668
+ }
669
+ /** A key's tier. */
670
+ type KeyTier = "trial" | "production";
671
+ /** An account, a company on Verdifax, as GET /admin/accounts lists it. The
672
+ * account number is a label Verdifax assigned, not a verified company
673
+ * identity. */
674
+ interface Account {
675
+ /** `account-N`, as records seal it. */
676
+ account_id: string;
677
+ id: number;
678
+ name: string;
679
+ tier: string;
680
+ created_at: string;
681
+ /** Member keys not revoked. */
682
+ member_keys: number;
683
+ /** Owner keys not revoked. */
684
+ owner_keys: number;
685
+ /** The chain of the account's policy changes, `account-N`. */
686
+ chain_id: string;
687
+ identity?: string;
688
+ policy_scope?: string;
689
+ }
690
+ /** Returned by {@link VerdifaxClient.getAccount}. */
691
+ interface AccountInfo extends Account {
692
+ ok: boolean;
693
+ }
694
+ /** One of an account's keys, without its secret. */
695
+ interface AccountKey {
696
+ id: number;
697
+ name: string;
698
+ account_id: string;
699
+ /** True for an owner key, which manages the account and cannot run
700
+ * anything. */
701
+ owner: boolean;
702
+ tier: string;
703
+ created_at: string;
704
+ last_used_at: string;
705
+ run_count: number;
706
+ revoked: boolean;
707
+ expires_at?: string;
708
+ }
709
+ /** Returned by {@link VerdifaxClient.listAccountKeys}. */
710
+ interface AccountKeyList {
711
+ ok: boolean;
712
+ account_id: string;
713
+ keys: AccountKey[];
714
+ }
715
+ /** A new key with its secret, which is shown this once. */
716
+ interface CreatedAccountKey extends AccountKey {
717
+ ok: boolean;
718
+ secret: string;
719
+ /** True when the key needs a request key before it can run. */
720
+ request_key_required: boolean;
721
+ hint: string;
722
+ }
723
+ /** Returned by {@link VerdifaxClient.revokeAccountKey}. */
724
+ interface AccountKeyRevocation {
725
+ ok: boolean;
726
+ id: number;
727
+ revoked: boolean;
728
+ }
729
+ /** Options for {@link VerdifaxClient.createAccountKey}. */
730
+ interface CreateAccountKeyOptions {
731
+ /** RFC 3339 or YYYY-MM-DD. */
732
+ expiresAt?: string;
733
+ }
734
+ /** Options for {@link VerdifaxClient.adminCreateAccount}. */
735
+ interface AdminCreateAccountOptions {
736
+ /** `trial` when left out. */
737
+ tier?: KeyTier;
738
+ /** When the owner key expires: RFC 3339 or YYYY-MM-DD. */
739
+ expiresAt?: string;
740
+ }
741
+ /** Returned by {@link VerdifaxClient.adminCreateAccount}: the account and
742
+ * its first owner key, with the secret. */
743
+ interface AdminCreateAccountResponse {
744
+ ok: boolean;
745
+ account: Account;
746
+ owner_key: CreatedAccountKey;
632
747
  }
633
748
  /** Projection returned by {@link VerdifaxClient.adminListKeys}.
634
749
  * Secrets are NEVER surfaced, only metadata. */
@@ -722,10 +837,12 @@ declare const MAX_BATCH_ROWS = 1000;
722
837
  * | `listDeletionReceipts(id)` | GET /runs/{id}/deletion-receipts | required |
723
838
  * | `adminErase(req)` | POST /admin/erase | required |
724
839
  * | `dcaeVerify(bundle)` | POST /dcae/verify | none |
725
- * | `adminCreateKey(name)` | POST /admin/keys | required |
840
+ * | `adminCreateKey(name, options)` | POST /admin/keys | required |
726
841
  * | `adminListKeys()` | GET /admin/keys | required |
727
842
  * | `adminRevokeKey(id)` | DELETE /admin/keys/{id} | required |
728
843
  * | `adminClearRequestKey(id)` | DELETE /admin/keys/{id}/request-key | required |
844
+ * | `adminCreateAccount(name, options)` | POST /admin/accounts | required |
845
+ * | `adminListAccounts()` | GET /admin/accounts | required |
729
846
  * | `attestClaudeResponse(...)` | POST /execute (helper) | required |
730
847
  * | `attestOpenAIResponse(...)` | POST /execute (helper) | required |
731
848
  * | `registerRequestKey()` | POST /keys/request-key | required |
@@ -737,6 +854,21 @@ declare const MAX_BATCH_ROWS = 1000;
737
854
  * | `testPolicy(req)` | POST /policies/test | required |
738
855
  * | `getPolicyHistory()` | GET /policies/history | required |
739
856
  * | `activatePolicy(documentHash)` | POST /policies/{document_hash}/activate | required |
857
+ * | `getAccount()` | GET /account | owner key |
858
+ * | `createAccountKey(name, options)` | POST /account/keys | owner key |
859
+ * | `listAccountKeys()` | GET /account/keys | owner key |
860
+ * | `revokeAccountKey(id)` | DELETE /account/keys/{id} | owner key |
861
+ * | `registerAccountRequestKey()` | POST /account/request-key | owner key |
862
+ * | `clearAccountRequestKey()` | DELETE /account/request-key | owner key |
863
+ * | `listAccountRuns(params)` | GET /account/runs | owner key |
864
+ * | `exportAccountRuns(params)` | GET /account/runs/export | owner key |
865
+ * | `exportAccountRunsCSV(params)` | GET /account/runs/export?format=csv | owner key |
866
+ * | `uploadAccountPolicy(document)` | POST /account/policies | owner key |
867
+ * | `listAccountPolicies()` | GET /account/policies | owner key |
868
+ * | `getAccountPolicy(documentHash)` | GET /account/policies/{document_hash} | owner key |
869
+ * | `testAccountPolicy(req)` | POST /account/policies/test | owner key |
870
+ * | `getAccountPolicyHistory()` | GET /account/policies/history | owner key |
871
+ * | `activateAccountPolicy(documentHash)` | POST /account/policies/{document_hash}/activate | owner key |
740
872
  * | `job(jobId)` | none, returns a {@link VerdifaxJob} | none |
741
873
  *
742
874
  * With the `signingKey` option set, every path to POST /execute carries
@@ -795,6 +927,7 @@ declare class VerdifaxClient {
795
927
  * that the client holds the private key. From then on the server
796
928
  * refuses a run on this API key without a request signature. */
797
929
  registerRequestKey(): Promise<RequestKeyRegistration>;
930
+ private registerRequestKeyAt;
798
931
  /** Replaces the registered key with `newSigningKey`. The new key proves
799
932
  * itself and this client's current key approves the change. After
800
933
  * success this client signs with the new key. If the call fails it
@@ -808,6 +941,7 @@ declare class VerdifaxClient {
808
941
  * unsigned requests, because the server refuses a signed run on an API
809
942
  * key with no registered key. If the call fails it keeps the key. */
810
943
  clearRequestKey(): Promise<void>;
944
+ private clearRequestKeyAt;
811
945
  /** Stores a policy document. Nothing changes until it is activated with
812
946
  * {@link activatePolicy}. The server hashes the exact text, so this
813
947
  * sends the string it is given unchanged and refuses anything that is
@@ -843,12 +977,73 @@ declare class VerdifaxClient {
843
977
  * {@link APIError} and is not retried: read the policies again and
844
978
  * decide. */
845
979
  activatePolicy(documentHash: Hex64): Promise<PolicyActivation>;
980
+ private uploadPolicyAt;
981
+ private getPolicyAt;
982
+ private testPolicyAt;
983
+ /** Posts the change that follows the newest one in `chain`, signed by
984
+ * the request key when the client has one. */
985
+ private activatePolicyAt;
986
+ /** The owner's account: its number, name, tier, key counts and the
987
+ * chain of its policy changes. */
988
+ getAccount(): Promise<AccountInfo>;
989
+ /** Creates a member key in the account. It takes the account's tier and
990
+ * stays in the account for life. The secret is in the result this once.
991
+ * On a trial account the key needs a request key before it can run. */
992
+ createAccountKey(name: string, options?: CreateAccountKeyOptions): Promise<CreatedAccountKey>;
993
+ /** Every key in the account, owner keys included, without secrets. */
994
+ listAccountKeys(): Promise<AccountKeyList>;
995
+ /** Revokes one of the account's member keys. A key in another account,
996
+ * or an owner key, throws {@link NotFoundError}. */
997
+ revokeAccountKey(keyId: number): Promise<AccountKeyRevocation>;
998
+ /** Registers this client's public key as the owner key's request key,
999
+ * which must sign every change to the account's policy. It works as
1000
+ * {@link registerRequestKey} does. */
1001
+ registerAccountRequestKey(): Promise<RequestKeyRegistration>;
1002
+ /** Clears the owner key's request key, as {@link clearRequestKey} does
1003
+ * for a key's own. With none registered the account's policy cannot be
1004
+ * changed. A trial owner key's request key cannot be cleared. */
1005
+ clearAccountRequestKey(): Promise<void>;
1006
+ /** The runs of every key in the account, paged as {@link listRuns}. */
1007
+ listAccountRuns(params?: ListRunsParams): Promise<{
1008
+ runs: RunSummary[];
1009
+ total: number;
1010
+ }>;
1011
+ /** The runs of every key in the account in a period, as
1012
+ * {@link exportRuns} lists a key's, with the account's number, its
1013
+ * policy documents and its chain of changes. The account's view covers
1014
+ * the runs its keys made through Verdifax, not runs made elsewhere. */
1015
+ exportAccountRuns(params?: ExportRunsParams): Promise<AccountRunsExport>;
1016
+ /** The same rows as {@link exportAccountRuns} as raw CSV text, checked
1017
+ * as {@link exportRunsCSV} checks a key's. */
1018
+ exportAccountRunsCSV(params?: ExportRunsParams): Promise<RunsExportCSV>;
1019
+ /** Stores an account policy document, as {@link uploadPolicy} stores a
1020
+ * key's. Every key in the account must pass the account's policy on top
1021
+ * of its own. Verdifax does not write, review or approve it. */
1022
+ uploadAccountPolicy(document: string): Promise<Policy>;
1023
+ /** The account's stored documents, its chain `account-N`, the newest
1024
+ * change in it and the document in force. */
1025
+ listAccountPolicies(): Promise<PolicyList>;
1026
+ /** One of the account's documents, with its exact text. */
1027
+ getAccountPolicy(documentHash: Hex64): Promise<PolicyWithDocument>;
1028
+ /** {@link testPolicy} for the account's documents. It seals nothing. */
1029
+ testAccountPolicy(req: PolicyTestRequest): Promise<PolicyTestResult>;
1030
+ /** The account's policy changes, oldest first, in the form
1031
+ * `verdifax-verify --policy-history FILE` reads. */
1032
+ getAccountPolicyHistory(): Promise<PolicyActivation[]>;
1033
+ /** Makes a stored document the account's policy in force, as
1034
+ * {@link activatePolicy} does for a key's. It reads
1035
+ * {@link listAccountPolicies} for the chain and its newest change, and
1036
+ * the owner key's request key signs the change over that chain,
1037
+ * `account-N`. The server refuses an unsigned account change, so this
1038
+ * needs the `signingKey` option and refuses to send without it. */
1039
+ activateAccountPolicy(documentHash: Hex64): Promise<PolicyActivation>;
846
1040
  getRun(runId: number): Promise<Run>;
847
1041
  verifyRun(runId: number): Promise<VerifyResponse>;
848
1042
  listRuns(params?: ListRunsParams): Promise<{
849
1043
  runs: RunSummary[];
850
1044
  total: number;
851
1045
  }>;
1046
+ private listRunsAt;
852
1047
  /** Searches this key's runs. `manifest_hash` matches a prefix. The
853
1048
  * server ignores a `from` or `to` it cannot parse here, unlike
854
1049
  * {@link exportRuns}, which refuses one. */
@@ -867,6 +1062,7 @@ declare class VerdifaxClient {
867
1062
  * does not send those headers, so that a cut-off export cannot pass
868
1063
  * for a complete one. */
869
1064
  exportRunsCSV(params?: ExportRunsParams): Promise<RunsExportCSV>;
1065
+ private exportCSVAt;
870
1066
  private exportPath;
871
1067
  listAttestations(params?: ListAttestationsParams): Promise<AttestationList>;
872
1068
  getAttestation(attestationId: number): Promise<Record<string, unknown>>;
@@ -897,7 +1093,16 @@ declare class VerdifaxClient {
897
1093
  listDeletionReceipts(runId: number): Promise<DeletionReceipt[]>;
898
1094
  adminErase(req: AdminEraseRequest): Promise<DeletionReceipt>;
899
1095
  dcaeVerify(bundle: DCAEProofBundle): Promise<DCAEVerdict>;
900
- adminCreateKey(name: string): Promise<AdminCreateKeyResponse>;
1096
+ /** Creates a customer key. With `accountId` the key joins that existing
1097
+ * account; without it the key gets an account of its own. A key never
1098
+ * changes account. */
1099
+ adminCreateKey(name: string, options?: AdminCreateKeyOptions): Promise<AdminCreateKeyResponse>;
1100
+ /** Creates an account and its first owner key, whose secret is in the
1101
+ * result this once. The owner key creates the member keys. The account
1102
+ * number is a label Verdifax assigned, not a verified company identity. */
1103
+ adminCreateAccount(name: string, options?: AdminCreateAccountOptions): Promise<AdminCreateAccountResponse>;
1104
+ /** Every account, with its key counts. */
1105
+ adminListAccounts(): Promise<Account[]>;
901
1106
  adminListKeys(): Promise<AdminAPIKey[]>;
902
1107
  adminRevokeKey(keyId: number): Promise<void>;
903
1108
  /** Clears the request key on an API key whose holder lost it, after a
@@ -1229,4 +1434,4 @@ declare class APIKeyRequiredError extends VerdifaxError {
1229
1434
  constructor();
1230
1435
  }
1231
1436
 
1232
- export { APIError, APIKeyRequiredError, type AdminAPIKey, type AdminCreateKeyResponse, type AdminEraseRequest, type AttestRequest, type AttestationList, AuthError, CRES_ENGINE_VERSION, CRES_PREIMAGE_VERSION, type ClientConfig, type DCAEProofBundle, type DCAEVerdict, DCAE_PREIMAGE_VERSION, DSE_FORMULA_VERSION, type DeletionReceipt, type DeterminismDiff, type DeterminismRun, EXECUTE_FIELDS, type ExecuteBatchResponse, type ExecuteBatchResult, type ExecuteRequest, type ExecuteResponse, type ExecutionManifest, type ExportRow, type ExportRunsParams, type FormulaEra, type Health, type Hex64, type JobLink, type JobStepOptions, type ListAttestationsParams, type ListRunsParams, MAX_BATCH_ROWS, NotFoundError, type PDFFormat, type Policy, type PolicyActivation, type PolicyActivationSignature, type PolicyActorType, type PolicyClassification, type PolicyContext, type PolicyList, type PolicyObjectType, type PolicyTestRequest, type PolicyTestResult, type PolicyWithDocument, RUN_STATUSES, type ReproducibilityContext, type RequestKeyChange, type RequestKeyPair, type RequestKeyRegistration, type RequestKeyRegistrationBody, type RequestSignature, type RequestSignatureV2, type Run, type RunStats, type RunStatus, type RunSummary, type RunsExport, type RunsExportCSV, type SearchRunsParams, type SignedRequestBody, VerdifaxClient, VerdifaxError, VerdifaxJob, type VerdifaxVersion, type VerifyDeterminismResponse, type VerifyResponse, captureEnvironment, cresReceiptHash, dcaeClosureHash, dseDispatchHash, formatProviderPayload, fromEnv, generateRequestKeyPair, policyActivationApproval, policyActivationPreimage, requestKeyChangeApproval, requestKeyChangePreimage, requestKeyRegistrationBody, requestSignaturePreimage, requestSignaturePreimageV2, signRequest, signRequestV2, validateHex64, validateJobName, validateRouteId };
1437
+ export { APIError, APIKeyRequiredError, type Account, type AccountInfo, type AccountKey, type AccountKeyList, type AccountKeyRevocation, type AccountRunsExport, type AdminAPIKey, type AdminCreateAccountOptions, type AdminCreateAccountResponse, type AdminCreateKeyOptions, type AdminCreateKeyResponse, type AdminEraseRequest, type AttestRequest, type AttestationList, AuthError, CRES_ENGINE_VERSION, CRES_PREIMAGE_VERSION, type ClientConfig, type CreateAccountKeyOptions, type CreatedAccountKey, type DCAEProofBundle, type DCAEVerdict, DCAE_PREIMAGE_VERSION, DSE_FORMULA_VERSION, type DeletionReceipt, type DeterminismDiff, type DeterminismRun, EXECUTE_FIELDS, type ExecuteBatchResponse, type ExecuteBatchResult, type ExecuteRequest, type ExecuteResponse, type ExecutionManifest, type ExportRow, type ExportRunsParams, type FormulaEra, type Health, type Hex64, type JobLink, type JobStepOptions, type KeyTier, type ListAttestationsParams, type ListRunsParams, MAX_BATCH_ROWS, NotFoundError, type PDFFormat, type Policy, type PolicyActivation, type PolicyActivationSignature, type PolicyActorType, type PolicyClassification, type PolicyContext, type PolicyList, type PolicyObjectType, type PolicyTestRequest, type PolicyTestResult, type PolicyWithDocument, RUN_STATUSES, type ReproducibilityContext, type RequestKeyChange, type RequestKeyPair, type RequestKeyRegistration, type RequestKeyRegistrationBody, type RequestSignature, type RequestSignatureV2, type Run, type RunStats, type RunStatus, type RunSummary, type RunsExport, type RunsExportCSV, type SearchRunsParams, type SignedRequestBody, VerdifaxClient, VerdifaxError, VerdifaxJob, type VerdifaxVersion, type VerifyDeterminismResponse, type VerifyResponse, captureEnvironment, cresReceiptHash, dcaeClosureHash, dseDispatchHash, formatProviderPayload, fromEnv, generateRequestKeyPair, policyActivationApproval, policyActivationPreimage, requestKeyChangeApproval, requestKeyChangePreimage, requestKeyRegistrationBody, requestSignaturePreimage, requestSignaturePreimageV2, signRequest, signRequestV2, validateHex64, validateJobName, validateRouteId };