@nomosprotocol/sdk 1.4.0 → 2.0.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 +78 -1
- package/dist/index.cjs +5211 -9
- package/dist/index.d.cts +411 -18
- package/dist/index.d.ts +411 -18
- package/dist/index.js +5182 -7
- package/package.json +23 -9
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { CurrencyPolicy, ActVerdict } from '@nomosprotocol/verify';
|
|
2
|
+
export { bindingDigest, verifyAct, verifyArtifact, verifySeal } from '@nomosprotocol/verify';
|
|
3
|
+
|
|
1
4
|
interface VerifyDecisionParams {
|
|
2
5
|
/** Artifact ID from NOMOS Studio or the Exchange */
|
|
3
6
|
artifact_id: string;
|
|
@@ -68,7 +71,7 @@ interface CanParams {
|
|
|
68
71
|
* both `nomos.can()` and `client.can()`. */
|
|
69
72
|
artifact?: unknown;
|
|
70
73
|
/** The key certificates presented alongside `artifact` — order never affects the result. */
|
|
71
|
-
key_certs?: KeyCertificate[];
|
|
74
|
+
key_certs?: KeyCertificate$1[];
|
|
72
75
|
/** The root public key (PEM) YOU have independently decided to trust. There is deliberately no
|
|
73
76
|
* default — see the chain-of-trust design note for why. Required alongside `artifact`. */
|
|
74
77
|
root_public_key_pem?: string;
|
|
@@ -214,7 +217,7 @@ interface ConservedStateReceipt {
|
|
|
214
217
|
reference?: string;
|
|
215
218
|
}
|
|
216
219
|
type ChainVerdictDecision = 'ALLOWED' | 'ISSUER_NOT_RECOGNIZED' | 'KEY_REVOKED' | 'CERTIFICATE_REVOKED' | 'OUT_OF_SCOPE' | 'SEAL_INVALID' | 'MALFORMED';
|
|
217
|
-
interface KeyCertificate {
|
|
220
|
+
interface KeyCertificate$1 {
|
|
218
221
|
parent_kid: string;
|
|
219
222
|
child_kid: string;
|
|
220
223
|
child_public_key_pem: string;
|
|
@@ -228,13 +231,15 @@ interface VerifyChainParams {
|
|
|
228
231
|
/** The sealed .nomos artifact being presented. */
|
|
229
232
|
artifact: unknown;
|
|
230
233
|
/** The set of key certificates presented alongside it — order never affects the result. */
|
|
231
|
-
key_certs: KeyCertificate[];
|
|
234
|
+
key_certs: KeyCertificate$1[];
|
|
232
235
|
/** The root public key (PEM) the CALLER has independently decided to trust. There is
|
|
233
236
|
* deliberately no default — see the chain-of-trust design note for why. */
|
|
234
237
|
root_public_key_pem: string;
|
|
235
238
|
}
|
|
236
239
|
interface VerifyChainOptions {
|
|
237
|
-
/**
|
|
240
|
+
/** Ask the hosted platform instead of verifying locally. Off by default. */
|
|
241
|
+
remote?: boolean;
|
|
242
|
+
/** With `remote`: override the API host (defaults to the public NOMOS platform). */
|
|
238
243
|
baseUrl?: string;
|
|
239
244
|
signal?: AbortSignal;
|
|
240
245
|
}
|
|
@@ -789,24 +794,412 @@ declare const nomos: {
|
|
|
789
794
|
};
|
|
790
795
|
|
|
791
796
|
/**
|
|
792
|
-
*
|
|
793
|
-
*
|
|
794
|
-
* have independently decided to trust — entirely server-side against nomos-chain.ts's pure
|
|
795
|
-
* verifier, with no account or API key required (keyless, matching `nomos.can()`'s precedent).
|
|
797
|
+
* NOMOS-SPEC-007 rev. 1.9 chain verification: does this artifact's signing key resolve, through the
|
|
798
|
+
* presented key certificates, to a root you have decided to trust, and was it delegated this artifact?
|
|
796
799
|
*
|
|
797
|
-
*
|
|
798
|
-
*
|
|
800
|
+
* Computed locally by @nomosprotocol/verify: no network call, no account, and no dependence on any
|
|
801
|
+
* NOMOS service being up or honest. There is no default root: `root_public_key_pem` is required, so
|
|
802
|
+
* the trust decision stays with you. Pass `{ remote: true }` only to ask the hosted platform instead.
|
|
799
803
|
*
|
|
800
804
|
* @example
|
|
801
|
-
*
|
|
802
|
-
*
|
|
803
|
-
* const result = await verifyChain({
|
|
804
|
-
* artifact: sealedArtifact,
|
|
805
|
-
* key_certs: [rootToIntermediate, intermediateToLeaf],
|
|
806
|
-
* root_public_key_pem: myPinnedRootPem,
|
|
807
|
-
* });
|
|
805
|
+
* const result = await verifyChain({ artifact, key_certs, root_public_key_pem: myPinnedRootPem });
|
|
808
806
|
* if (result.decision === 'ALLOWED') { ... }
|
|
809
807
|
*/
|
|
810
808
|
declare function verifyChain(params: VerifyChainParams, opts?: VerifyChainOptions): Promise<VerifyChainResult>;
|
|
811
809
|
|
|
812
|
-
|
|
810
|
+
type SignatureSuite = 'Ed25519' | 'ES256';
|
|
811
|
+
interface Signer {
|
|
812
|
+
/** NOMOS-SPEC-001 §8.4 key id of the public key. */
|
|
813
|
+
kid: string;
|
|
814
|
+
/** The public key, canonical SPKI PEM (NOMOS-SPEC-010 §3.1). */
|
|
815
|
+
publicKeyPem: string;
|
|
816
|
+
/** The suite this key signs under. */
|
|
817
|
+
algorithm: SignatureSuite;
|
|
818
|
+
/** Signs the exact payload bytes. Returns the signature in the suite's encoding, base64. */
|
|
819
|
+
sign(payload: Uint8Array): Promise<string>;
|
|
820
|
+
}
|
|
821
|
+
declare function kidOf(publicKeyPem: string): string;
|
|
822
|
+
/** A signer over a private key held in this process: PKCS#8 PEM. For development and tests;
|
|
823
|
+
* in production pass a Signer backed by your KMS or HSM. */
|
|
824
|
+
declare function localSigner(privateKeyPem: string): Signer;
|
|
825
|
+
/** A fresh in-memory key. For development and tests only. */
|
|
826
|
+
declare function generateSigner(algorithm?: SignatureSuite): Signer & {
|
|
827
|
+
privateKeyPem: string;
|
|
828
|
+
};
|
|
829
|
+
/** A deterministic Ed25519 key from a seed string: the same test key on every machine. Never for
|
|
830
|
+
* anything real — the seed is the key. */
|
|
831
|
+
declare function seededSigner(seed: string): Signer;
|
|
832
|
+
|
|
833
|
+
interface Action {
|
|
834
|
+
type: string;
|
|
835
|
+
subject?: string;
|
|
836
|
+
params?: Record<string, unknown>;
|
|
837
|
+
}
|
|
838
|
+
interface KeyCertificate {
|
|
839
|
+
parent_kid: string;
|
|
840
|
+
child_kid: string;
|
|
841
|
+
child_public_key_pem: string;
|
|
842
|
+
scope?: string | null;
|
|
843
|
+
issued_at: string;
|
|
844
|
+
expires_at: string;
|
|
845
|
+
algorithm: 'Ed25519' | 'ES256';
|
|
846
|
+
signature: string;
|
|
847
|
+
}
|
|
848
|
+
/** NOMOS-SPEC-007 §3: `parent` certifies `child` within `scope` until `expiresAt`. */
|
|
849
|
+
declare function certify(parent: Signer, child: {
|
|
850
|
+
kid: string;
|
|
851
|
+
publicKeyPem: string;
|
|
852
|
+
}, opts: {
|
|
853
|
+
scope?: string;
|
|
854
|
+
issuedAt?: Date;
|
|
855
|
+
expiresAt: Date;
|
|
856
|
+
}): Promise<KeyCertificate>;
|
|
857
|
+
/** NOMOS-SPEC-001 §8: seal an artifact body with the issuer's key. */
|
|
858
|
+
declare function seal(body: Record<string, unknown>, issuer: Signer, signedBy: Record<string, unknown> | string): Promise<any>;
|
|
859
|
+
/** NOMOS-SPEC-008 §3: a witness's signed statement of one fact about one subject. */
|
|
860
|
+
declare function signTestimony(witness: Signer, t: {
|
|
861
|
+
claim: string;
|
|
862
|
+
value: unknown;
|
|
863
|
+
about?: string | null;
|
|
864
|
+
asOf?: Date;
|
|
865
|
+
validUntil: Date;
|
|
866
|
+
}): Promise<any>;
|
|
867
|
+
/** NOMOS-SPEC-008 §4: an approver's consent to exactly this Act, in this role. */
|
|
868
|
+
declare function signConsent(approver: Signer, act: any, role: string, decision?: 'approve' | 'refuse'): Promise<any>;
|
|
869
|
+
/** NOMOS-SPEC-008 §5.4: the issuer's statement that this exact version is in force, for a day at most. */
|
|
870
|
+
declare function signInForce(issuer: Signer, artifact: any, opts: {
|
|
871
|
+
asOf?: Date;
|
|
872
|
+
validUntil: Date;
|
|
873
|
+
}): Promise<any>;
|
|
874
|
+
interface BuildActOptions {
|
|
875
|
+
relyingParty: string;
|
|
876
|
+
action: Action;
|
|
877
|
+
artifact: any;
|
|
878
|
+
keyCerts: KeyCertificate[];
|
|
879
|
+
testimony?: any[];
|
|
880
|
+
presenterFacts?: Record<string, unknown>;
|
|
881
|
+
inForce?: any;
|
|
882
|
+
/** Validity window in seconds (SPEC-008 §5.1). Longer windows leave a person time to approve. */
|
|
883
|
+
windowSeconds?: number;
|
|
884
|
+
now?: Date;
|
|
885
|
+
}
|
|
886
|
+
/** NOMOS-SPEC-008 §2: assemble an Act. It needs no key: what makes it valid is what it carries. */
|
|
887
|
+
declare function buildAct(o: BuildActOptions): any;
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* NOMOS-SPEC-009 §3 discovery documents. A document tells a carrier where to go and what to bring;
|
|
891
|
+
* it never decides anything (§2), so nothing here is trusted beyond what the verifier rechecks.
|
|
892
|
+
*/
|
|
893
|
+
|
|
894
|
+
interface RelyingPartyDocument {
|
|
895
|
+
nomos_document: 'relying-party';
|
|
896
|
+
version: '1';
|
|
897
|
+
relying_party_id: string;
|
|
898
|
+
act_endpoint: string;
|
|
899
|
+
roots: Array<{
|
|
900
|
+
kid: string;
|
|
901
|
+
public_key_pem: string;
|
|
902
|
+
}>;
|
|
903
|
+
authorities: Array<{
|
|
904
|
+
artifact_id: string;
|
|
905
|
+
issuer?: string;
|
|
906
|
+
actions: string[];
|
|
907
|
+
currency_policy: 'record' | 'record_or_statement';
|
|
908
|
+
in_force_seal_hash?: string;
|
|
909
|
+
}>;
|
|
910
|
+
local_facts?: string[];
|
|
911
|
+
max_window_seconds: number;
|
|
912
|
+
max_act_bytes?: number;
|
|
913
|
+
consent_suites?: string[];
|
|
914
|
+
valid_until?: string;
|
|
915
|
+
}
|
|
916
|
+
interface IssuerDocument {
|
|
917
|
+
nomos_document: 'issuer';
|
|
918
|
+
version: '1';
|
|
919
|
+
issuer_id: string;
|
|
920
|
+
authorities: Array<{
|
|
921
|
+
artifact_id: string;
|
|
922
|
+
version: string;
|
|
923
|
+
seal_hash: string;
|
|
924
|
+
artifact_url: string;
|
|
925
|
+
in_force_url?: string;
|
|
926
|
+
}>;
|
|
927
|
+
key_certs: KeyCertificate[];
|
|
928
|
+
witnesses?: string[];
|
|
929
|
+
approvals?: Array<{
|
|
930
|
+
role: string;
|
|
931
|
+
endpoint: string;
|
|
932
|
+
}>;
|
|
933
|
+
revocations_url?: string;
|
|
934
|
+
valid_until?: string;
|
|
935
|
+
}
|
|
936
|
+
interface WitnessDocument {
|
|
937
|
+
nomos_document: 'witness';
|
|
938
|
+
version: '1';
|
|
939
|
+
witness_id: string;
|
|
940
|
+
kid: string;
|
|
941
|
+
claims: string[];
|
|
942
|
+
statement_endpoint: string;
|
|
943
|
+
access?: string;
|
|
944
|
+
valid_until?: string;
|
|
945
|
+
}
|
|
946
|
+
declare const PATH: {
|
|
947
|
+
readonly 'relying-party': "/.well-known/nomos-relying-party";
|
|
948
|
+
readonly issuer: "/.well-known/nomos-issuer";
|
|
949
|
+
readonly witness: "/.well-known/nomos-witness";
|
|
950
|
+
};
|
|
951
|
+
type Kind = keyof typeof PATH;
|
|
952
|
+
type DocOf<K extends Kind> = K extends 'relying-party' ? RelyingPartyDocument : K extends 'issuer' ? IssuerDocument : WitnessDocument;
|
|
953
|
+
declare class NomosDiscoveryError extends Error {
|
|
954
|
+
readonly url: string;
|
|
955
|
+
constructor(message: string, url: string);
|
|
956
|
+
}
|
|
957
|
+
/** The origin of a URL or bare origin: `https://shop.example/anything` → `https://shop.example`. */
|
|
958
|
+
declare function originOf(to: string): string;
|
|
959
|
+
/** Fetches and checks one discovery document (§2 rule 4, §3). */
|
|
960
|
+
declare function fetchDocument<K extends Kind>(kind: K, origin: string, fetchImpl?: typeof fetch): Promise<DocOf<K>>;
|
|
961
|
+
declare const WELL_KNOWN: {
|
|
962
|
+
readonly 'relying-party': "/.well-known/nomos-relying-party";
|
|
963
|
+
readonly issuer: "/.well-known/nomos-issuer";
|
|
964
|
+
readonly witness: "/.well-known/nomos-witness";
|
|
965
|
+
};
|
|
966
|
+
|
|
967
|
+
/**
|
|
968
|
+
* accept() — the relying party: the system that makes the change.
|
|
969
|
+
*
|
|
970
|
+
* const rp = accept({ relyingPartyId, root, authorities, commit });
|
|
971
|
+
* app.use(rp.express()); // Express, Connect, node:http
|
|
972
|
+
* export default { fetch: rp.fetch }; // Hono, Next.js, Cloudflare, Deno, Bun
|
|
973
|
+
*
|
|
974
|
+
* For every Act it receives it runs NOMOS-SPEC-008 §6 with @nomosprotocol/verify, locally, and on
|
|
975
|
+
* AUTHORIZED applies §8 exactly, in one transaction: record the nonce, re-read its own facts
|
|
976
|
+
* (re-verifying if they moved), hand `commit` a copy of exactly the verified action, and store the
|
|
977
|
+
* receipt. It answers with the NOMOS-SPEC-009 §6.2 status codes and serves its own discovery
|
|
978
|
+
* document (§3.1), generated from this same configuration so the two can never disagree (§2).
|
|
979
|
+
*/
|
|
980
|
+
|
|
981
|
+
interface AcceptedAuthority {
|
|
982
|
+
/** The sealed artifact's meta.artifact_id. */
|
|
983
|
+
artifactId: string;
|
|
984
|
+
/** Origin of the issuer document (NOMOS-SPEC-009 §3.2), advertised so carriers can find it. */
|
|
985
|
+
issuer?: string;
|
|
986
|
+
/** The action types this system commits under this authority. Anything else is refused. */
|
|
987
|
+
actions: string[];
|
|
988
|
+
/** SPEC-008 §5.5. `record` (RECOMMENDED) needs `inForceSealHash`. */
|
|
989
|
+
currencyPolicy: CurrencyPolicy;
|
|
990
|
+
/** Your record of the version in force: the seal hash of the version you accept. */
|
|
991
|
+
inForceSealHash?: string;
|
|
992
|
+
}
|
|
993
|
+
interface Receipt {
|
|
994
|
+
act_id: string;
|
|
995
|
+
act_digest: string;
|
|
996
|
+
decision: string;
|
|
997
|
+
rule: string | null;
|
|
998
|
+
by_consent?: boolean;
|
|
999
|
+
verified_at: string;
|
|
1000
|
+
committed_at?: string;
|
|
1001
|
+
relying_party_facts: Record<string, unknown>;
|
|
1002
|
+
in_force_source?: string;
|
|
1003
|
+
currency_policy: CurrencyPolicy;
|
|
1004
|
+
consent_origins?: string[];
|
|
1005
|
+
}
|
|
1006
|
+
/** One atomic operation (SPEC-008 §8). `tx` is passed to `commit` and `localFacts` so your own
|
|
1007
|
+
* writes and reads share it. */
|
|
1008
|
+
interface AcceptTransaction<Tx = unknown> {
|
|
1009
|
+
/** Records the nonce. false if it was already recorded (a concurrent duplicate). */
|
|
1010
|
+
claimNonce(nonce: string): Promise<boolean>;
|
|
1011
|
+
putReceipt(nonce: string, receipt: Receipt): Promise<void>;
|
|
1012
|
+
tx: Tx;
|
|
1013
|
+
}
|
|
1014
|
+
interface AcceptStore<Tx = unknown> {
|
|
1015
|
+
hasNonce(nonce: string): Promise<boolean>;
|
|
1016
|
+
receiptFor(nonce: string): Promise<Receipt | null>;
|
|
1017
|
+
transaction<T>(fn: (t: AcceptTransaction<Tx>) => Promise<T>): Promise<T>;
|
|
1018
|
+
}
|
|
1019
|
+
interface AcceptOptions<Tx = unknown> {
|
|
1020
|
+
/** Your identifier. Acts addressed to anything else are refused (SPEC-008 §5.3). */
|
|
1021
|
+
relyingPartyId: string;
|
|
1022
|
+
/** The root you pin (PEM). There is no default root. */
|
|
1023
|
+
root: string;
|
|
1024
|
+
authorities: AcceptedAuthority[];
|
|
1025
|
+
/** Applies the change. Receives a deep copy of exactly the verified action, and nothing else
|
|
1026
|
+
* from the request (SPEC-009 §6.4). Its return value is sent back as `result`. */
|
|
1027
|
+
commit: (action: {
|
|
1028
|
+
type: string;
|
|
1029
|
+
subject?: string;
|
|
1030
|
+
params: Record<string, unknown>;
|
|
1031
|
+
}, ctx: {
|
|
1032
|
+
tx: Tx;
|
|
1033
|
+
actId: string;
|
|
1034
|
+
}) => Promise<unknown> | unknown;
|
|
1035
|
+
/** Facts you supply from your own state (inputs with source `relying_party`). Called once to
|
|
1036
|
+
* verify, and again inside the transaction to check nothing moved (SPEC-008 §8 step 3). */
|
|
1037
|
+
localFacts?: (act: any, tx?: Tx) => Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
1038
|
+
/** Where nonces and receipts live. Defaults to memory, for development only. */
|
|
1039
|
+
store?: AcceptStore<Tx>;
|
|
1040
|
+
/** The absolute URL carriers POST Acts to, as advertised in your discovery document. */
|
|
1041
|
+
actEndpoint: string;
|
|
1042
|
+
/** SPEC-008 §5.1 / SPEC-009 §6.3. Long enough for a person to approve. Default 900. */
|
|
1043
|
+
maxWindowSeconds?: number;
|
|
1044
|
+
maxActBytes?: number;
|
|
1045
|
+
/** Current revocation state (SPEC-006, SPEC-007 §5). Read on every verification. */
|
|
1046
|
+
revocations?: () => Promise<{
|
|
1047
|
+
kids?: Set<string>;
|
|
1048
|
+
certs?: Set<string>;
|
|
1049
|
+
artifacts?: Set<string>;
|
|
1050
|
+
}> | {
|
|
1051
|
+
kids?: Set<string>;
|
|
1052
|
+
certs?: Set<string>;
|
|
1053
|
+
artifacts?: Set<string>;
|
|
1054
|
+
};
|
|
1055
|
+
/** `shadow`: verify and record every verdict, never commit. For pilots. */
|
|
1056
|
+
mode?: 'enforce' | 'shadow';
|
|
1057
|
+
/** Every verdict, committed or not (SPEC-008 §9: a receipt for every verification). */
|
|
1058
|
+
onVerdict?: (verdict: ActVerdict, receipt: Receipt) => void | Promise<void>;
|
|
1059
|
+
/** How long this document is valid for, in seconds. Default one day. */
|
|
1060
|
+
documentTtlSeconds?: number;
|
|
1061
|
+
now?: () => Date;
|
|
1062
|
+
}
|
|
1063
|
+
interface Answer {
|
|
1064
|
+
status: number;
|
|
1065
|
+
headers: Record<string, string>;
|
|
1066
|
+
body: Record<string, unknown>;
|
|
1067
|
+
}
|
|
1068
|
+
declare const statusFor: (decision: string) => number;
|
|
1069
|
+
declare const ACT_MEDIA_TYPE = "application/nomos-act+json";
|
|
1070
|
+
/** Nonces and receipts in memory, one transaction at a time. Lost on restart, single process:
|
|
1071
|
+
* for development and tests only. Use a database-backed store in production. */
|
|
1072
|
+
declare function memoryStore(): AcceptStore<null>;
|
|
1073
|
+
declare function accept<Tx = unknown>(o: AcceptOptions<Tx>): {
|
|
1074
|
+
handle: (req: {
|
|
1075
|
+
method?: string;
|
|
1076
|
+
headers: Record<string, string | string[] | undefined>;
|
|
1077
|
+
body: string | Uint8Array;
|
|
1078
|
+
}) => Promise<Answer>;
|
|
1079
|
+
document: () => RelyingPartyDocument;
|
|
1080
|
+
fetch: (request: Request) => Promise<Response>;
|
|
1081
|
+
express: () => (req: any, res: any, next?: () => void) => Promise<void>;
|
|
1082
|
+
node: () => (req: any, res: any, next?: () => void) => Promise<void>;
|
|
1083
|
+
};
|
|
1084
|
+
|
|
1085
|
+
type ActStatus = 'committed' | 'escalated' | 'incomplete' | 'denied' | 'refused' | 'replayed';
|
|
1086
|
+
interface ActResult {
|
|
1087
|
+
status: ActStatus;
|
|
1088
|
+
/** The relying party's verdict, exactly as it returned it (SPEC-009 §6.2). */
|
|
1089
|
+
verdict: Record<string, any>;
|
|
1090
|
+
/** When committed: the receipt, and what the relying party's commit returned. */
|
|
1091
|
+
receipt?: Record<string, any>;
|
|
1092
|
+
result?: unknown;
|
|
1093
|
+
/** When incomplete: the facts that could still change the outcome, and why each is missing. */
|
|
1094
|
+
missing?: Array<{
|
|
1095
|
+
fact: string;
|
|
1096
|
+
source: string | null;
|
|
1097
|
+
why: string;
|
|
1098
|
+
}>;
|
|
1099
|
+
/** When escalated and not approved in time: where a person can approve. */
|
|
1100
|
+
approvalUrl?: string;
|
|
1101
|
+
/** The Act as submitted, for your records. */
|
|
1102
|
+
act: any;
|
|
1103
|
+
/** What happened, in one sentence. */
|
|
1104
|
+
summary: string;
|
|
1105
|
+
}
|
|
1106
|
+
interface ActOptions {
|
|
1107
|
+
/** The relying party: its origin or any URL on it. */
|
|
1108
|
+
to: string;
|
|
1109
|
+
action: Action;
|
|
1110
|
+
/** Which authority to act under, when the relying party accepts several for this action type. */
|
|
1111
|
+
authority?: string;
|
|
1112
|
+
/** Facts the carrier supplies itself (inputs whose declared source is `presenter`). */
|
|
1113
|
+
presenterFacts?: Record<string, unknown>;
|
|
1114
|
+
/** Credentials for witnesses that need them: origin → headers (SPEC-009 §3.3 `access`). */
|
|
1115
|
+
witnessHeaders?: Record<string, Record<string, string>>;
|
|
1116
|
+
/** Wait up to this long for a person to approve, in ms. Default: until the Act expires. */
|
|
1117
|
+
approvalTimeoutMs?: number;
|
|
1118
|
+
/** Called once per pending approval with the page a person can approve on. */
|
|
1119
|
+
onApproval?: (approval: {
|
|
1120
|
+
role: string;
|
|
1121
|
+
url?: string;
|
|
1122
|
+
actDigest: string;
|
|
1123
|
+
}) => void;
|
|
1124
|
+
/** Use a specific fetch (tests, proxies). */
|
|
1125
|
+
fetch?: typeof fetch;
|
|
1126
|
+
/** Poll interval for pending approvals, ms. Default 1000. */
|
|
1127
|
+
pollMs?: number;
|
|
1128
|
+
}
|
|
1129
|
+
declare class NomosActError extends Error {
|
|
1130
|
+
constructor(message: string);
|
|
1131
|
+
}
|
|
1132
|
+
declare function act(o: ActOptions): Promise<ActResult>;
|
|
1133
|
+
|
|
1134
|
+
interface IssuerOptions {
|
|
1135
|
+
/** Your public origin, e.g. https://policy.acme.example */
|
|
1136
|
+
origin: string;
|
|
1137
|
+
issuerId: string;
|
|
1138
|
+
/** The key that sealed the authorities; it also signs in-force statements (SPEC-008 §5.4). */
|
|
1139
|
+
signer: Signer;
|
|
1140
|
+
/** Sealed artifacts, each the version currently in force. */
|
|
1141
|
+
authorities: any[];
|
|
1142
|
+
/** The certificate pool carriers present: your sealing key, witnesses, approvers (SPEC-007). */
|
|
1143
|
+
keyCerts: KeyCertificate[];
|
|
1144
|
+
witnesses?: string[];
|
|
1145
|
+
approvals?: Array<{
|
|
1146
|
+
role: string;
|
|
1147
|
+
endpoint: string;
|
|
1148
|
+
}>;
|
|
1149
|
+
revocationsUrl?: string;
|
|
1150
|
+
}
|
|
1151
|
+
declare function issuer(o: IssuerOptions): {
|
|
1152
|
+
fetch: (request: Request) => Promise<Response>;
|
|
1153
|
+
express: () => (req: any, res: any, next?: () => void) => Promise<any>;
|
|
1154
|
+
node: () => (req: any, res: any, next?: () => void) => Promise<any>;
|
|
1155
|
+
document: () => IssuerDocument;
|
|
1156
|
+
};
|
|
1157
|
+
interface WitnessOptions {
|
|
1158
|
+
origin: string;
|
|
1159
|
+
witnessId: string;
|
|
1160
|
+
/** A key certified for exactly these claims (SPEC-007 rev. 1.8 §3.4.1). */
|
|
1161
|
+
signer: Signer;
|
|
1162
|
+
/** Each claim this witness states, and how to read its current value for a subject. Return
|
|
1163
|
+
* undefined when the subject is unknown. */
|
|
1164
|
+
claims: Record<string, (about: string | null) => unknown | Promise<unknown>>;
|
|
1165
|
+
/** How long a statement stays true, at most, in seconds. Default 900. */
|
|
1166
|
+
maxValiditySeconds?: number;
|
|
1167
|
+
/** Your access control (SPEC-009 §3.3): return false to refuse a requester. */
|
|
1168
|
+
authorize?: (request: {
|
|
1169
|
+
claim: string;
|
|
1170
|
+
about: string | null;
|
|
1171
|
+
}) => boolean | Promise<boolean>;
|
|
1172
|
+
access?: string;
|
|
1173
|
+
}
|
|
1174
|
+
declare function witness(o: WitnessOptions): {
|
|
1175
|
+
fetch: (request: Request) => Promise<Response>;
|
|
1176
|
+
express: () => (req: any, res: any, next?: () => void) => Promise<any>;
|
|
1177
|
+
node: () => (req: any, res: any, next?: () => void) => Promise<any>;
|
|
1178
|
+
document: () => WitnessDocument;
|
|
1179
|
+
};
|
|
1180
|
+
interface ApproverOptions {
|
|
1181
|
+
origin: string;
|
|
1182
|
+
/** The person's key, certified with `consent:<role> approver:<their id>` (SPEC-007 rev. 1.9 §3.7). */
|
|
1183
|
+
signer: Signer;
|
|
1184
|
+
roles: string[];
|
|
1185
|
+
/** 'page' (default): a person approves on a page this handler serves. 'auto': approve every
|
|
1186
|
+
* request at once — development only. Or a function that decides. */
|
|
1187
|
+
decide?: 'page' | 'auto' | ((request: {
|
|
1188
|
+
role: string;
|
|
1189
|
+
act: any;
|
|
1190
|
+
}) => boolean | Promise<boolean>);
|
|
1191
|
+
}
|
|
1192
|
+
interface Pending {
|
|
1193
|
+
role: string;
|
|
1194
|
+
act: any;
|
|
1195
|
+
status: 'pending' | 'approved' | 'refused' | 'expired';
|
|
1196
|
+
consent?: any;
|
|
1197
|
+
}
|
|
1198
|
+
declare function approver(o: ApproverOptions): {
|
|
1199
|
+
fetch: (request: Request) => Promise<Response>;
|
|
1200
|
+
express: () => (req: any, res: any, next?: () => void) => Promise<any>;
|
|
1201
|
+
node: () => (req: any, res: any, next?: () => void) => Promise<any>;
|
|
1202
|
+
pending: Map<string, Pending>;
|
|
1203
|
+
};
|
|
1204
|
+
|
|
1205
|
+
export { ACT_MEDIA_TYPE, type AcceptOptions, type AcceptStore, type AcceptTransaction, type AcceptedAuthority, type KeyCertificate as ActKeyCertificate, type ActOptions, type ActResult, type ActStatus, type Action, type Answer, type ApproverOptions, type Artifact, type ArtifactList, type ArtifactSchema, type ArtifactSchemaField, type AttestationInfo, type BuildActOptions, type CanOptions, type CanParams, type CanResult, type CanVerdict, type ChainVerdictDecision, type ConservedStateInfo, type ConservedStateReceipt, type Contradiction, type DetectContradictionsParams, type DetectContradictionsResult, type GenerateGovernanceParams, type GenerateGovernanceResult, type IssuerDocument, type IssuerOptions, type KeyCertificate$1 as KeyCertificate, type ListArtifactsParams, Nomos, NomosAPIError, NomosActError, NomosAuthenticationError, NomosAuthorizationError, type NomosConfig, NomosDiscoveryError, NomosError, type NomosErrorCode, NomosIssuerNotTrustedError, NomosNetworkError, NomosNotFoundError, NomosPaymentRequiredError, NomosRateLimitError, type NomosRawResponse, NomosValidationError, type NomosWebhookEvent, type NomosWebhookEventType, NomosWebhookSignatureError, type Receipt, type RelyingPartyDocument, type RequestOptions, type Reservation, type ReserveByActParams, type ReserveByQueryParams, type ReserveParams, type SignatureSuite, type Signer, type Verdict, type VerifyChainOptions, type VerifyChainParams, type VerifyChainResult, type VerifyDecisionParams, type VerifyDecisionResult, WELL_KNOWN, type WithLastResponse, type WitnessDocument, type WitnessOptions, accept, act, approver, buildAct, can, certify, fetchDocument, generateSigner, issuer, kidOf, localSigner, memoryStore, nomos, originOf, seal, seededSigner, signConsent, signInForce, signTestimony, statusFor, verifyChain, witness };
|