@nomosprotocol/sdk 2.5.0 → 2.7.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 +92 -1
- package/dist/index.cjs +465 -13
- package/dist/index.d.cts +161 -2
- package/dist/index.d.ts +161 -2
- package/dist/index.js +463 -13
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CurrencyPolicy, ActVerdict, KeyCertificate as KeyCertificate$2, RevocationStatement, RevocationList, ScopeTerms } from '@nomosprotocol/verify';
|
|
1
|
+
import { RegistrarRecord, CurrencyPolicy, ActVerdict, KeyCertificate as KeyCertificate$2, RevocationStatement, RevocationList, ScopeTerms } from '@nomosprotocol/verify';
|
|
2
2
|
export { bindingDigest, verifyAct, verifyArtifact, verifySeal } from '@nomosprotocol/verify';
|
|
3
3
|
|
|
4
4
|
interface VerifyDecisionParams {
|
|
@@ -80,9 +80,77 @@ interface CanParams {
|
|
|
80
80
|
/** The facts to evaluate. Either pass this explicitly, or spread the facts flat alongside
|
|
81
81
|
* `authority`/`action` — both shapes are accepted (explicit `inputs` wins if both given). */
|
|
82
82
|
inputs?: Record<string, unknown>;
|
|
83
|
+
/** Resolution rail (NOMOS-SPEC-014 Draft): the properties that attach law to an act —
|
|
84
|
+
* e.g. { jurisdiction: 'EU', sector: 'ai' }. With `context` and NO `authority`/`artifact_id`/
|
|
85
|
+
* `artifact`, the server first resolves WHICH authorities govern this context (from its own
|
|
86
|
+
* signed registrar chain — never from anything you present), asks every one of them, and
|
|
87
|
+
* combines strictly. Returns a CanResolutionResult instead of a CanResult. Keyless. */
|
|
88
|
+
context?: Record<string, unknown>;
|
|
83
89
|
/** Flat-facts convenience: any extra keys are treated as inputs when `inputs` is omitted. */
|
|
84
90
|
[key: string]: unknown;
|
|
85
91
|
}
|
|
92
|
+
/** One governing authority the resolver found for a context (NOMOS-SPEC-014). */
|
|
93
|
+
interface ResolvedAuthorityRef {
|
|
94
|
+
authority: string;
|
|
95
|
+
version: string | null;
|
|
96
|
+
registrar: string;
|
|
97
|
+
scope: string;
|
|
98
|
+
}
|
|
99
|
+
/** One resolved authority's answer inside a resolution-rail can() call. `verdict` is null with
|
|
100
|
+
* `unavailable` set when the member could not be consulted — which holds the WHOLE combined
|
|
101
|
+
* answer open (INSUFFICIENT_DATA), never acts as a permit. */
|
|
102
|
+
interface CanResolutionMember {
|
|
103
|
+
authority: string;
|
|
104
|
+
verdict: string | null;
|
|
105
|
+
unavailable: string | null;
|
|
106
|
+
query_id?: string | null;
|
|
107
|
+
rule?: string | null;
|
|
108
|
+
reason?: string | null;
|
|
109
|
+
escalation_id?: string | null;
|
|
110
|
+
revoked?: boolean;
|
|
111
|
+
missing_facts?: string[];
|
|
112
|
+
}
|
|
113
|
+
/** The resolution rail's answer (NOMOS-SPEC-014): which authorities govern, each one's own
|
|
114
|
+
* sealed answer, and the strict combination. `verdict` adds two values CanResult never has:
|
|
115
|
+
* INSUFFICIENT_DATA (resolution or a member held open — named in `open_facts`/`resolution`)
|
|
116
|
+
* and CONFLICT (two registrars assert exclusive precedence; a person settles it). */
|
|
117
|
+
interface CanResolutionResult {
|
|
118
|
+
mode: 'resolution';
|
|
119
|
+
allowed: boolean;
|
|
120
|
+
verdict: 'AUTHORIZED' | 'DENIED' | 'ESCALATED' | 'INSUFFICIENT_DATA' | 'CONFLICT';
|
|
121
|
+
reason: string;
|
|
122
|
+
resolution: {
|
|
123
|
+
status: 'RESOLVED' | 'CONFLICT' | 'INCOMPLETE';
|
|
124
|
+
applicable?: ResolvedAuthorityRef[];
|
|
125
|
+
missing?: {
|
|
126
|
+
context_facts: string[];
|
|
127
|
+
unreachable_registrars: string[];
|
|
128
|
+
stale_closures: string[];
|
|
129
|
+
/** SPEC-014 0.2.0: a current closure names law the registrar's log no longer claims, or the reverse */
|
|
130
|
+
closure_disagreements?: Array<{
|
|
131
|
+
registrar: string;
|
|
132
|
+
authority: string;
|
|
133
|
+
reason: 'closed_but_not_claimed' | 'claimed_but_not_closed';
|
|
134
|
+
}>;
|
|
135
|
+
/** SPEC-014 0.2.0: registrars whose log copy is older than the relying party's bound */
|
|
136
|
+
stale_heads?: string[];
|
|
137
|
+
};
|
|
138
|
+
conflicts?: unknown[];
|
|
139
|
+
proof: unknown;
|
|
140
|
+
};
|
|
141
|
+
members: CanResolutionMember[];
|
|
142
|
+
deciding_authorities: string[];
|
|
143
|
+
escalations: Array<{
|
|
144
|
+
authority: string;
|
|
145
|
+
escalation_id: string | null;
|
|
146
|
+
}>;
|
|
147
|
+
open_facts: string[];
|
|
148
|
+
/** The laws this answer was computed under (the resolved set). */
|
|
149
|
+
answered_under?: string[];
|
|
150
|
+
/** What the answer covers, in words: the registrar lists only its own authorities, so other law
|
|
151
|
+
* may also apply. An empty set is never AUTHORIZED. */
|
|
152
|
+
coverage?: string;
|
|
153
|
+
}
|
|
86
154
|
interface CanOptions {
|
|
87
155
|
/** Override the API host (defaults to the public NOMOS Exchange). */
|
|
88
156
|
baseUrl?: string;
|
|
@@ -836,6 +904,12 @@ declare class Nomos {
|
|
|
836
904
|
can(params: CanParams, opts?: CanOptions): Promise<CanResult>;
|
|
837
905
|
}
|
|
838
906
|
|
|
907
|
+
declare function can(params: CanParams & {
|
|
908
|
+
context: Record<string, unknown>;
|
|
909
|
+
authority?: undefined;
|
|
910
|
+
artifact_id?: undefined;
|
|
911
|
+
artifact?: undefined;
|
|
912
|
+
}, opts?: CanOptions): Promise<CanResolutionResult>;
|
|
839
913
|
declare function can(params: CanParams, opts?: CanOptions): Promise<CanResult>;
|
|
840
914
|
/**
|
|
841
915
|
* Ready-to-use, keyless entry point matching the canonical `nomos.can(...)` form.
|
|
@@ -941,6 +1015,64 @@ declare function suggestToolBindings(artifact: string, tools: ToolDescription[],
|
|
|
941
1015
|
/** A plain report of a suggestion, for the person who has to check it. */
|
|
942
1016
|
declare function describeSuggestion(s: BindingSuggestion): string;
|
|
943
1017
|
|
|
1018
|
+
/**
|
|
1019
|
+
* Registrar logs for accept({ resolution }) (NOMOS-SPEC-014, Draft): which laws apply where, as a
|
|
1020
|
+
* registrar you pin has signed them.
|
|
1021
|
+
*
|
|
1022
|
+
* registrarSource() fetches a registrar's public log and its signed head, and checks them with
|
|
1023
|
+
* @nomosprotocol/verify before anything is used: every entry's hash and the chain from 64 zeros; the
|
|
1024
|
+
* head's signature under the key YOU pin (never a key fetched from the same place as the log); the
|
|
1025
|
+
* head's age against your bound; and that today's log extends the head it saw last time, so history
|
|
1026
|
+
* can only be added to. It then folds the log into the record the resolver reads.
|
|
1027
|
+
*
|
|
1028
|
+
* A registrar that cannot be read, or whose copy fails a check, throws RegistrarUnavailable, and
|
|
1029
|
+
* accept() refuses to commit with 503 and Retry-After. An unreadable registrar is never read as
|
|
1030
|
+
* "no law applies" (SPEC-014 C8).
|
|
1031
|
+
*/
|
|
1032
|
+
|
|
1033
|
+
declare class RegistrarUnavailable extends Error {
|
|
1034
|
+
readonly retryAfterSeconds: number;
|
|
1035
|
+
readonly registrar: string;
|
|
1036
|
+
constructor(message: string, retryAfterSeconds: number, registrar: string);
|
|
1037
|
+
}
|
|
1038
|
+
interface RegistrarSourceOptions {
|
|
1039
|
+
/** The id you pin this registrar under; resolution names it in its answers. */
|
|
1040
|
+
id: string;
|
|
1041
|
+
/** Where the registrar serves its log: the origin of `/.well-known/nomos-exchange-log` (the NOMOS
|
|
1042
|
+
* platform registrar is https://www.nomosprotocol.com). */
|
|
1043
|
+
url: string;
|
|
1044
|
+
/** The registrar's signing key, which you pin (PEM). Heads signed by any other key are refused. */
|
|
1045
|
+
publicKeyPem: string;
|
|
1046
|
+
/** The scope the registrar is certified over (SPEC-014 C6). Default: everything it claims. */
|
|
1047
|
+
certifiedScope?: string;
|
|
1048
|
+
/** How old a signed head may be before the copy is stale (SPEC-014 0.2.0). Default 600. */
|
|
1049
|
+
maxHeadAgeSeconds?: number;
|
|
1050
|
+
/** How long to reuse a verified log before fetching again. Default 60. */
|
|
1051
|
+
refreshSeconds?: number;
|
|
1052
|
+
/** The head you kept from an earlier run (for example the last receipt's `resolution.heads`). The
|
|
1053
|
+
* first read must extend it. Without it, the history check starts from this process's first
|
|
1054
|
+
* read: create each source once and reuse it, since a new source forgets the head it saw. */
|
|
1055
|
+
initialHead?: {
|
|
1056
|
+
size: number;
|
|
1057
|
+
hash: string;
|
|
1058
|
+
} | null;
|
|
1059
|
+
fetch?: typeof fetch;
|
|
1060
|
+
now?: () => Date;
|
|
1061
|
+
}
|
|
1062
|
+
interface RegistrarView {
|
|
1063
|
+
record: RegistrarRecord;
|
|
1064
|
+
head: {
|
|
1065
|
+
size: number;
|
|
1066
|
+
hash: string;
|
|
1067
|
+
at: string;
|
|
1068
|
+
kid: string;
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
type RegistrarSource = (() => Promise<RegistrarView>) & {
|
|
1072
|
+
id: string;
|
|
1073
|
+
};
|
|
1074
|
+
declare function registrarSource(o: RegistrarSourceOptions): RegistrarSource;
|
|
1075
|
+
|
|
944
1076
|
type SignatureSuite = 'Ed25519' | 'ES256';
|
|
945
1077
|
interface Signer {
|
|
946
1078
|
/** NOMOS-SPEC-001 §8.4 key id of the public key. */
|
|
@@ -1125,6 +1257,29 @@ interface AcceptedAuthority {
|
|
|
1125
1257
|
currencyPolicy: CurrencyPolicy;
|
|
1126
1258
|
/** Your record of the version in force: the seal hash of the version you accept. */
|
|
1127
1259
|
inForceSealHash?: string;
|
|
1260
|
+
/** The name your pinned registrars list this authority under (its Exchange name), when it is a
|
|
1261
|
+
* law they list. Resolution counts an Act under this authority as carrying that law. */
|
|
1262
|
+
registrarName?: string;
|
|
1263
|
+
}
|
|
1264
|
+
/** accept({ resolution }): before committing, work out which laws govern this act here, now, from
|
|
1265
|
+
* registrars you pin, and commit only if the Act carries every one (NOMOS-SPEC-014). */
|
|
1266
|
+
interface AcceptResolution {
|
|
1267
|
+
/** The registrars whose law you undertake to honour (registrarSource()). */
|
|
1268
|
+
registrars: RegistrarSource[];
|
|
1269
|
+
/** The context that decides which law applies (jurisdiction, established_in, subjects_in,
|
|
1270
|
+
* output_used_in, ...), from YOUR knowledge and your own state. It is never read from the Act:
|
|
1271
|
+
* a carrier that stated its own context would choose the law again. A fact you leave out is
|
|
1272
|
+
* unknown, so a law that turns on it holds the Act (INCOMPLETE), never permits it. */
|
|
1273
|
+
context: (act: any, localFacts: Record<string, unknown>) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
1274
|
+
}
|
|
1275
|
+
/** What resolution decided, kept on the receipt so an auditor can replay it against the logs. */
|
|
1276
|
+
interface ReceiptResolution {
|
|
1277
|
+
status: 'RESOLVED' | 'INCOMPLETE' | 'CONFLICT';
|
|
1278
|
+
context: Record<string, unknown>;
|
|
1279
|
+
applicable: string[];
|
|
1280
|
+
/** The log head of each registrar consulted (id → head hash). */
|
|
1281
|
+
heads: Record<string, string>;
|
|
1282
|
+
laws_not_presented?: string[];
|
|
1128
1283
|
}
|
|
1129
1284
|
interface Receipt {
|
|
1130
1285
|
act_id: string;
|
|
@@ -1138,6 +1293,7 @@ interface Receipt {
|
|
|
1138
1293
|
in_force_source?: string;
|
|
1139
1294
|
currency_policy: CurrencyPolicy;
|
|
1140
1295
|
consent_origins?: string[];
|
|
1296
|
+
resolution?: ReceiptResolution;
|
|
1141
1297
|
}
|
|
1142
1298
|
/** One atomic operation (SPEC-008 §8). `tx` is passed to `commit` and `localFacts` so your own
|
|
1143
1299
|
* writes and reads share it. */
|
|
@@ -1193,6 +1349,9 @@ interface AcceptOptions<Tx = unknown> {
|
|
|
1193
1349
|
certs?: Set<string>;
|
|
1194
1350
|
artifacts?: Set<string>;
|
|
1195
1351
|
};
|
|
1352
|
+
/** Resolve which laws govern the act before committing (NOMOS-SPEC-014, Draft). Without it,
|
|
1353
|
+
* accept() verifies the one authority the Act carries, as before. */
|
|
1354
|
+
resolution?: AcceptResolution;
|
|
1196
1355
|
/** `shadow`: verify and record every verdict, never commit. For pilots. */
|
|
1197
1356
|
mode?: 'enforce' | 'shadow';
|
|
1198
1357
|
/** Every verdict, committed or not (SPEC-008 §9: a receipt for every verification). */
|
|
@@ -1676,4 +1835,4 @@ declare function approver(o: ApproverOptions): {
|
|
|
1676
1835
|
pending: Map<string, Pending>;
|
|
1677
1836
|
};
|
|
1678
1837
|
|
|
1679
|
-
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 AwaitApprovalOptions, type BindingProposal, type BindingSuggestion, type BuildActOptions, type CanApproval, type CanCaller, type CanOptions, type CanParams, type CanResult, type CanVerdict, type CertificateRegistry, type ChainVerdictDecision, type ConservedStateInfo, type ConservedStateReceipt, type Contradiction, type DetectContradictionsParams, type DetectContradictionsResult, type EnrolmentClaims, type FactBinding, type GenerateGovernanceParams, type GenerateGovernanceResult, type IssueOptions, type IssuerDocument, type IssuerOptions, type KeyCertificate$1 as KeyCertificate, type ListArtifactsParams, MAX_PRESENTED, 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 PasskeyApproverOptions, type PasskeyCredential, type PasskeyStore, type PendingApproval, type PgClient, type PgPool, type PolicyField, type PostgresStoreOptions, type Receipt, RegistryError, type RegistryStore, type RelyingPartyDocument, type RequestOptions, type Reservation, type ReserveByActParams, type ReserveByQueryParams, type ReserveParams, type RevocationSourceOptions, RevocationUnavailable, type SignatureSuite, type Signer, type ToolBindings, type ToolDescription, type UnresolvedFact, type Verdict, type VerifyChainOptions, type VerifyChainParams, type VerifyChainResult, type VerifyDecisionParams, type VerifyDecisionResult, WELL_KNOWN, type WithLastResponse, type WitnessDocument, type WitnessOptions, accept, act, applyToolBindings, approver, buildAct, can, certificateRegistry, certify, describeSuggestion, fetchDocument, generateSigner, issuer, kidOf, localSigner, memoryPasskeyStore, memoryRegistryStore, memoryStore, nomos, originOf, parseToolBindings, passkeyApprover, postgresPasskeyStore, postgresRegistryStore, postgresStore, presentedCertificates, readAttestation, reliedKids, revocationListCertificates, revocationSource, seal, seededSigner, signConsent, signEnrolmentToken, signInForce, signRevocation, signRevocationList, signTestimony, statusFor, suggestToolBindings, verifyChain, verifyEnrolmentToken, witness };
|
|
1838
|
+
export { ACT_MEDIA_TYPE, type AcceptOptions, type AcceptResolution, 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 AwaitApprovalOptions, type BindingProposal, type BindingSuggestion, type BuildActOptions, type CanApproval, type CanCaller, type CanOptions, type CanParams, type CanResolutionMember, type CanResolutionResult, type CanResult, type CanVerdict, type CertificateRegistry, type ChainVerdictDecision, type ConservedStateInfo, type ConservedStateReceipt, type Contradiction, type DetectContradictionsParams, type DetectContradictionsResult, type EnrolmentClaims, type FactBinding, type GenerateGovernanceParams, type GenerateGovernanceResult, type IssueOptions, type IssuerDocument, type IssuerOptions, type KeyCertificate$1 as KeyCertificate, type ListArtifactsParams, MAX_PRESENTED, 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 PasskeyApproverOptions, type PasskeyCredential, type PasskeyStore, type PendingApproval, type PgClient, type PgPool, type PolicyField, type PostgresStoreOptions, type Receipt, type ReceiptResolution, type RegistrarSource, type RegistrarSourceOptions, RegistrarUnavailable, type RegistrarView, RegistryError, type RegistryStore, type RelyingPartyDocument, type RequestOptions, type Reservation, type ReserveByActParams, type ReserveByQueryParams, type ReserveParams, type ResolvedAuthorityRef, type RevocationSourceOptions, RevocationUnavailable, type SignatureSuite, type Signer, type ToolBindings, type ToolDescription, type UnresolvedFact, type Verdict, type VerifyChainOptions, type VerifyChainParams, type VerifyChainResult, type VerifyDecisionParams, type VerifyDecisionResult, WELL_KNOWN, type WithLastResponse, type WitnessDocument, type WitnessOptions, accept, act, applyToolBindings, approver, buildAct, can, certificateRegistry, certify, describeSuggestion, fetchDocument, generateSigner, issuer, kidOf, localSigner, memoryPasskeyStore, memoryRegistryStore, memoryStore, nomos, originOf, parseToolBindings, passkeyApprover, postgresPasskeyStore, postgresRegistryStore, postgresStore, presentedCertificates, readAttestation, registrarSource, reliedKids, revocationListCertificates, revocationSource, seal, seededSigner, signConsent, signEnrolmentToken, signInForce, signRevocation, signRevocationList, signTestimony, statusFor, suggestToolBindings, verifyChain, verifyEnrolmentToken, witness };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CurrencyPolicy, ActVerdict, KeyCertificate as KeyCertificate$2, RevocationStatement, RevocationList, ScopeTerms } from '@nomosprotocol/verify';
|
|
1
|
+
import { RegistrarRecord, CurrencyPolicy, ActVerdict, KeyCertificate as KeyCertificate$2, RevocationStatement, RevocationList, ScopeTerms } from '@nomosprotocol/verify';
|
|
2
2
|
export { bindingDigest, verifyAct, verifyArtifact, verifySeal } from '@nomosprotocol/verify';
|
|
3
3
|
|
|
4
4
|
interface VerifyDecisionParams {
|
|
@@ -80,9 +80,77 @@ interface CanParams {
|
|
|
80
80
|
/** The facts to evaluate. Either pass this explicitly, or spread the facts flat alongside
|
|
81
81
|
* `authority`/`action` — both shapes are accepted (explicit `inputs` wins if both given). */
|
|
82
82
|
inputs?: Record<string, unknown>;
|
|
83
|
+
/** Resolution rail (NOMOS-SPEC-014 Draft): the properties that attach law to an act —
|
|
84
|
+
* e.g. { jurisdiction: 'EU', sector: 'ai' }. With `context` and NO `authority`/`artifact_id`/
|
|
85
|
+
* `artifact`, the server first resolves WHICH authorities govern this context (from its own
|
|
86
|
+
* signed registrar chain — never from anything you present), asks every one of them, and
|
|
87
|
+
* combines strictly. Returns a CanResolutionResult instead of a CanResult. Keyless. */
|
|
88
|
+
context?: Record<string, unknown>;
|
|
83
89
|
/** Flat-facts convenience: any extra keys are treated as inputs when `inputs` is omitted. */
|
|
84
90
|
[key: string]: unknown;
|
|
85
91
|
}
|
|
92
|
+
/** One governing authority the resolver found for a context (NOMOS-SPEC-014). */
|
|
93
|
+
interface ResolvedAuthorityRef {
|
|
94
|
+
authority: string;
|
|
95
|
+
version: string | null;
|
|
96
|
+
registrar: string;
|
|
97
|
+
scope: string;
|
|
98
|
+
}
|
|
99
|
+
/** One resolved authority's answer inside a resolution-rail can() call. `verdict` is null with
|
|
100
|
+
* `unavailable` set when the member could not be consulted — which holds the WHOLE combined
|
|
101
|
+
* answer open (INSUFFICIENT_DATA), never acts as a permit. */
|
|
102
|
+
interface CanResolutionMember {
|
|
103
|
+
authority: string;
|
|
104
|
+
verdict: string | null;
|
|
105
|
+
unavailable: string | null;
|
|
106
|
+
query_id?: string | null;
|
|
107
|
+
rule?: string | null;
|
|
108
|
+
reason?: string | null;
|
|
109
|
+
escalation_id?: string | null;
|
|
110
|
+
revoked?: boolean;
|
|
111
|
+
missing_facts?: string[];
|
|
112
|
+
}
|
|
113
|
+
/** The resolution rail's answer (NOMOS-SPEC-014): which authorities govern, each one's own
|
|
114
|
+
* sealed answer, and the strict combination. `verdict` adds two values CanResult never has:
|
|
115
|
+
* INSUFFICIENT_DATA (resolution or a member held open — named in `open_facts`/`resolution`)
|
|
116
|
+
* and CONFLICT (two registrars assert exclusive precedence; a person settles it). */
|
|
117
|
+
interface CanResolutionResult {
|
|
118
|
+
mode: 'resolution';
|
|
119
|
+
allowed: boolean;
|
|
120
|
+
verdict: 'AUTHORIZED' | 'DENIED' | 'ESCALATED' | 'INSUFFICIENT_DATA' | 'CONFLICT';
|
|
121
|
+
reason: string;
|
|
122
|
+
resolution: {
|
|
123
|
+
status: 'RESOLVED' | 'CONFLICT' | 'INCOMPLETE';
|
|
124
|
+
applicable?: ResolvedAuthorityRef[];
|
|
125
|
+
missing?: {
|
|
126
|
+
context_facts: string[];
|
|
127
|
+
unreachable_registrars: string[];
|
|
128
|
+
stale_closures: string[];
|
|
129
|
+
/** SPEC-014 0.2.0: a current closure names law the registrar's log no longer claims, or the reverse */
|
|
130
|
+
closure_disagreements?: Array<{
|
|
131
|
+
registrar: string;
|
|
132
|
+
authority: string;
|
|
133
|
+
reason: 'closed_but_not_claimed' | 'claimed_but_not_closed';
|
|
134
|
+
}>;
|
|
135
|
+
/** SPEC-014 0.2.0: registrars whose log copy is older than the relying party's bound */
|
|
136
|
+
stale_heads?: string[];
|
|
137
|
+
};
|
|
138
|
+
conflicts?: unknown[];
|
|
139
|
+
proof: unknown;
|
|
140
|
+
};
|
|
141
|
+
members: CanResolutionMember[];
|
|
142
|
+
deciding_authorities: string[];
|
|
143
|
+
escalations: Array<{
|
|
144
|
+
authority: string;
|
|
145
|
+
escalation_id: string | null;
|
|
146
|
+
}>;
|
|
147
|
+
open_facts: string[];
|
|
148
|
+
/** The laws this answer was computed under (the resolved set). */
|
|
149
|
+
answered_under?: string[];
|
|
150
|
+
/** What the answer covers, in words: the registrar lists only its own authorities, so other law
|
|
151
|
+
* may also apply. An empty set is never AUTHORIZED. */
|
|
152
|
+
coverage?: string;
|
|
153
|
+
}
|
|
86
154
|
interface CanOptions {
|
|
87
155
|
/** Override the API host (defaults to the public NOMOS Exchange). */
|
|
88
156
|
baseUrl?: string;
|
|
@@ -836,6 +904,12 @@ declare class Nomos {
|
|
|
836
904
|
can(params: CanParams, opts?: CanOptions): Promise<CanResult>;
|
|
837
905
|
}
|
|
838
906
|
|
|
907
|
+
declare function can(params: CanParams & {
|
|
908
|
+
context: Record<string, unknown>;
|
|
909
|
+
authority?: undefined;
|
|
910
|
+
artifact_id?: undefined;
|
|
911
|
+
artifact?: undefined;
|
|
912
|
+
}, opts?: CanOptions): Promise<CanResolutionResult>;
|
|
839
913
|
declare function can(params: CanParams, opts?: CanOptions): Promise<CanResult>;
|
|
840
914
|
/**
|
|
841
915
|
* Ready-to-use, keyless entry point matching the canonical `nomos.can(...)` form.
|
|
@@ -941,6 +1015,64 @@ declare function suggestToolBindings(artifact: string, tools: ToolDescription[],
|
|
|
941
1015
|
/** A plain report of a suggestion, for the person who has to check it. */
|
|
942
1016
|
declare function describeSuggestion(s: BindingSuggestion): string;
|
|
943
1017
|
|
|
1018
|
+
/**
|
|
1019
|
+
* Registrar logs for accept({ resolution }) (NOMOS-SPEC-014, Draft): which laws apply where, as a
|
|
1020
|
+
* registrar you pin has signed them.
|
|
1021
|
+
*
|
|
1022
|
+
* registrarSource() fetches a registrar's public log and its signed head, and checks them with
|
|
1023
|
+
* @nomosprotocol/verify before anything is used: every entry's hash and the chain from 64 zeros; the
|
|
1024
|
+
* head's signature under the key YOU pin (never a key fetched from the same place as the log); the
|
|
1025
|
+
* head's age against your bound; and that today's log extends the head it saw last time, so history
|
|
1026
|
+
* can only be added to. It then folds the log into the record the resolver reads.
|
|
1027
|
+
*
|
|
1028
|
+
* A registrar that cannot be read, or whose copy fails a check, throws RegistrarUnavailable, and
|
|
1029
|
+
* accept() refuses to commit with 503 and Retry-After. An unreadable registrar is never read as
|
|
1030
|
+
* "no law applies" (SPEC-014 C8).
|
|
1031
|
+
*/
|
|
1032
|
+
|
|
1033
|
+
declare class RegistrarUnavailable extends Error {
|
|
1034
|
+
readonly retryAfterSeconds: number;
|
|
1035
|
+
readonly registrar: string;
|
|
1036
|
+
constructor(message: string, retryAfterSeconds: number, registrar: string);
|
|
1037
|
+
}
|
|
1038
|
+
interface RegistrarSourceOptions {
|
|
1039
|
+
/** The id you pin this registrar under; resolution names it in its answers. */
|
|
1040
|
+
id: string;
|
|
1041
|
+
/** Where the registrar serves its log: the origin of `/.well-known/nomos-exchange-log` (the NOMOS
|
|
1042
|
+
* platform registrar is https://www.nomosprotocol.com). */
|
|
1043
|
+
url: string;
|
|
1044
|
+
/** The registrar's signing key, which you pin (PEM). Heads signed by any other key are refused. */
|
|
1045
|
+
publicKeyPem: string;
|
|
1046
|
+
/** The scope the registrar is certified over (SPEC-014 C6). Default: everything it claims. */
|
|
1047
|
+
certifiedScope?: string;
|
|
1048
|
+
/** How old a signed head may be before the copy is stale (SPEC-014 0.2.0). Default 600. */
|
|
1049
|
+
maxHeadAgeSeconds?: number;
|
|
1050
|
+
/** How long to reuse a verified log before fetching again. Default 60. */
|
|
1051
|
+
refreshSeconds?: number;
|
|
1052
|
+
/** The head you kept from an earlier run (for example the last receipt's `resolution.heads`). The
|
|
1053
|
+
* first read must extend it. Without it, the history check starts from this process's first
|
|
1054
|
+
* read: create each source once and reuse it, since a new source forgets the head it saw. */
|
|
1055
|
+
initialHead?: {
|
|
1056
|
+
size: number;
|
|
1057
|
+
hash: string;
|
|
1058
|
+
} | null;
|
|
1059
|
+
fetch?: typeof fetch;
|
|
1060
|
+
now?: () => Date;
|
|
1061
|
+
}
|
|
1062
|
+
interface RegistrarView {
|
|
1063
|
+
record: RegistrarRecord;
|
|
1064
|
+
head: {
|
|
1065
|
+
size: number;
|
|
1066
|
+
hash: string;
|
|
1067
|
+
at: string;
|
|
1068
|
+
kid: string;
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
type RegistrarSource = (() => Promise<RegistrarView>) & {
|
|
1072
|
+
id: string;
|
|
1073
|
+
};
|
|
1074
|
+
declare function registrarSource(o: RegistrarSourceOptions): RegistrarSource;
|
|
1075
|
+
|
|
944
1076
|
type SignatureSuite = 'Ed25519' | 'ES256';
|
|
945
1077
|
interface Signer {
|
|
946
1078
|
/** NOMOS-SPEC-001 §8.4 key id of the public key. */
|
|
@@ -1125,6 +1257,29 @@ interface AcceptedAuthority {
|
|
|
1125
1257
|
currencyPolicy: CurrencyPolicy;
|
|
1126
1258
|
/** Your record of the version in force: the seal hash of the version you accept. */
|
|
1127
1259
|
inForceSealHash?: string;
|
|
1260
|
+
/** The name your pinned registrars list this authority under (its Exchange name), when it is a
|
|
1261
|
+
* law they list. Resolution counts an Act under this authority as carrying that law. */
|
|
1262
|
+
registrarName?: string;
|
|
1263
|
+
}
|
|
1264
|
+
/** accept({ resolution }): before committing, work out which laws govern this act here, now, from
|
|
1265
|
+
* registrars you pin, and commit only if the Act carries every one (NOMOS-SPEC-014). */
|
|
1266
|
+
interface AcceptResolution {
|
|
1267
|
+
/** The registrars whose law you undertake to honour (registrarSource()). */
|
|
1268
|
+
registrars: RegistrarSource[];
|
|
1269
|
+
/** The context that decides which law applies (jurisdiction, established_in, subjects_in,
|
|
1270
|
+
* output_used_in, ...), from YOUR knowledge and your own state. It is never read from the Act:
|
|
1271
|
+
* a carrier that stated its own context would choose the law again. A fact you leave out is
|
|
1272
|
+
* unknown, so a law that turns on it holds the Act (INCOMPLETE), never permits it. */
|
|
1273
|
+
context: (act: any, localFacts: Record<string, unknown>) => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
1274
|
+
}
|
|
1275
|
+
/** What resolution decided, kept on the receipt so an auditor can replay it against the logs. */
|
|
1276
|
+
interface ReceiptResolution {
|
|
1277
|
+
status: 'RESOLVED' | 'INCOMPLETE' | 'CONFLICT';
|
|
1278
|
+
context: Record<string, unknown>;
|
|
1279
|
+
applicable: string[];
|
|
1280
|
+
/** The log head of each registrar consulted (id → head hash). */
|
|
1281
|
+
heads: Record<string, string>;
|
|
1282
|
+
laws_not_presented?: string[];
|
|
1128
1283
|
}
|
|
1129
1284
|
interface Receipt {
|
|
1130
1285
|
act_id: string;
|
|
@@ -1138,6 +1293,7 @@ interface Receipt {
|
|
|
1138
1293
|
in_force_source?: string;
|
|
1139
1294
|
currency_policy: CurrencyPolicy;
|
|
1140
1295
|
consent_origins?: string[];
|
|
1296
|
+
resolution?: ReceiptResolution;
|
|
1141
1297
|
}
|
|
1142
1298
|
/** One atomic operation (SPEC-008 §8). `tx` is passed to `commit` and `localFacts` so your own
|
|
1143
1299
|
* writes and reads share it. */
|
|
@@ -1193,6 +1349,9 @@ interface AcceptOptions<Tx = unknown> {
|
|
|
1193
1349
|
certs?: Set<string>;
|
|
1194
1350
|
artifacts?: Set<string>;
|
|
1195
1351
|
};
|
|
1352
|
+
/** Resolve which laws govern the act before committing (NOMOS-SPEC-014, Draft). Without it,
|
|
1353
|
+
* accept() verifies the one authority the Act carries, as before. */
|
|
1354
|
+
resolution?: AcceptResolution;
|
|
1196
1355
|
/** `shadow`: verify and record every verdict, never commit. For pilots. */
|
|
1197
1356
|
mode?: 'enforce' | 'shadow';
|
|
1198
1357
|
/** Every verdict, committed or not (SPEC-008 §9: a receipt for every verification). */
|
|
@@ -1676,4 +1835,4 @@ declare function approver(o: ApproverOptions): {
|
|
|
1676
1835
|
pending: Map<string, Pending>;
|
|
1677
1836
|
};
|
|
1678
1837
|
|
|
1679
|
-
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 AwaitApprovalOptions, type BindingProposal, type BindingSuggestion, type BuildActOptions, type CanApproval, type CanCaller, type CanOptions, type CanParams, type CanResult, type CanVerdict, type CertificateRegistry, type ChainVerdictDecision, type ConservedStateInfo, type ConservedStateReceipt, type Contradiction, type DetectContradictionsParams, type DetectContradictionsResult, type EnrolmentClaims, type FactBinding, type GenerateGovernanceParams, type GenerateGovernanceResult, type IssueOptions, type IssuerDocument, type IssuerOptions, type KeyCertificate$1 as KeyCertificate, type ListArtifactsParams, MAX_PRESENTED, 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 PasskeyApproverOptions, type PasskeyCredential, type PasskeyStore, type PendingApproval, type PgClient, type PgPool, type PolicyField, type PostgresStoreOptions, type Receipt, RegistryError, type RegistryStore, type RelyingPartyDocument, type RequestOptions, type Reservation, type ReserveByActParams, type ReserveByQueryParams, type ReserveParams, type RevocationSourceOptions, RevocationUnavailable, type SignatureSuite, type Signer, type ToolBindings, type ToolDescription, type UnresolvedFact, type Verdict, type VerifyChainOptions, type VerifyChainParams, type VerifyChainResult, type VerifyDecisionParams, type VerifyDecisionResult, WELL_KNOWN, type WithLastResponse, type WitnessDocument, type WitnessOptions, accept, act, applyToolBindings, approver, buildAct, can, certificateRegistry, certify, describeSuggestion, fetchDocument, generateSigner, issuer, kidOf, localSigner, memoryPasskeyStore, memoryRegistryStore, memoryStore, nomos, originOf, parseToolBindings, passkeyApprover, postgresPasskeyStore, postgresRegistryStore, postgresStore, presentedCertificates, readAttestation, reliedKids, revocationListCertificates, revocationSource, seal, seededSigner, signConsent, signEnrolmentToken, signInForce, signRevocation, signRevocationList, signTestimony, statusFor, suggestToolBindings, verifyChain, verifyEnrolmentToken, witness };
|
|
1838
|
+
export { ACT_MEDIA_TYPE, type AcceptOptions, type AcceptResolution, 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 AwaitApprovalOptions, type BindingProposal, type BindingSuggestion, type BuildActOptions, type CanApproval, type CanCaller, type CanOptions, type CanParams, type CanResolutionMember, type CanResolutionResult, type CanResult, type CanVerdict, type CertificateRegistry, type ChainVerdictDecision, type ConservedStateInfo, type ConservedStateReceipt, type Contradiction, type DetectContradictionsParams, type DetectContradictionsResult, type EnrolmentClaims, type FactBinding, type GenerateGovernanceParams, type GenerateGovernanceResult, type IssueOptions, type IssuerDocument, type IssuerOptions, type KeyCertificate$1 as KeyCertificate, type ListArtifactsParams, MAX_PRESENTED, 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 PasskeyApproverOptions, type PasskeyCredential, type PasskeyStore, type PendingApproval, type PgClient, type PgPool, type PolicyField, type PostgresStoreOptions, type Receipt, type ReceiptResolution, type RegistrarSource, type RegistrarSourceOptions, RegistrarUnavailable, type RegistrarView, RegistryError, type RegistryStore, type RelyingPartyDocument, type RequestOptions, type Reservation, type ReserveByActParams, type ReserveByQueryParams, type ReserveParams, type ResolvedAuthorityRef, type RevocationSourceOptions, RevocationUnavailable, type SignatureSuite, type Signer, type ToolBindings, type ToolDescription, type UnresolvedFact, type Verdict, type VerifyChainOptions, type VerifyChainParams, type VerifyChainResult, type VerifyDecisionParams, type VerifyDecisionResult, WELL_KNOWN, type WithLastResponse, type WitnessDocument, type WitnessOptions, accept, act, applyToolBindings, approver, buildAct, can, certificateRegistry, certify, describeSuggestion, fetchDocument, generateSigner, issuer, kidOf, localSigner, memoryPasskeyStore, memoryRegistryStore, memoryStore, nomos, originOf, parseToolBindings, passkeyApprover, postgresPasskeyStore, postgresRegistryStore, postgresStore, presentedCertificates, readAttestation, registrarSource, reliedKids, revocationListCertificates, revocationSource, seal, seededSigner, signConsent, signEnrolmentToken, signInForce, signRevocation, signRevocationList, signTestimony, statusFor, suggestToolBindings, verifyChain, verifyEnrolmentToken, witness };
|