@bsv/dpp-overlay-topics 0.4.0-beta.1

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.
Files changed (87) hide show
  1. package/LICENSE +58 -0
  2. package/README.md +169 -0
  3. package/dist/anchorStorage.d.ts +58 -0
  4. package/dist/anchorStorage.d.ts.map +1 -0
  5. package/dist/anchorStorage.js +72 -0
  6. package/dist/anchorStorage.js.map +1 -0
  7. package/dist/attestationAnchor.d.ts +10 -0
  8. package/dist/attestationAnchor.d.ts.map +1 -0
  9. package/dist/attestationAnchor.js +10 -0
  10. package/dist/attestationAnchor.js.map +1 -0
  11. package/dist/attestationStorage.d.ts +49 -0
  12. package/dist/attestationStorage.d.ts.map +1 -0
  13. package/dist/attestationStorage.js +78 -0
  14. package/dist/attestationStorage.js.map +1 -0
  15. package/dist/capabilities.d.ts +127 -0
  16. package/dist/capabilities.d.ts.map +1 -0
  17. package/dist/capabilities.js +210 -0
  18. package/dist/capabilities.js.map +1 -0
  19. package/dist/engineStorage.d.ts +106 -0
  20. package/dist/engineStorage.d.ts.map +1 -0
  21. package/dist/engineStorage.js +253 -0
  22. package/dist/engineStorage.js.map +1 -0
  23. package/dist/evidenceExport.d.ts +189 -0
  24. package/dist/evidenceExport.d.ts.map +1 -0
  25. package/dist/evidenceExport.js +517 -0
  26. package/dist/evidenceExport.js.map +1 -0
  27. package/dist/history.d.ts +114 -0
  28. package/dist/history.d.ts.map +1 -0
  29. package/dist/history.js +215 -0
  30. package/dist/history.js.map +1 -0
  31. package/dist/index.d.ts +269 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +1223 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/lib.d.ts +31 -0
  36. package/dist/lib.d.ts.map +1 -0
  37. package/dist/lib.js +31 -0
  38. package/dist/lib.js.map +1 -0
  39. package/dist/limits.d.ts +44 -0
  40. package/dist/limits.d.ts.map +1 -0
  41. package/dist/limits.js +44 -0
  42. package/dist/limits.js.map +1 -0
  43. package/dist/lsAttestation.d.ts +21 -0
  44. package/dist/lsAttestation.d.ts.map +1 -0
  45. package/dist/lsAttestation.js +45 -0
  46. package/dist/lsAttestation.js.map +1 -0
  47. package/dist/lsDpp.d.ts +53 -0
  48. package/dist/lsDpp.d.ts.map +1 -0
  49. package/dist/lsDpp.js +148 -0
  50. package/dist/lsDpp.js.map +1 -0
  51. package/dist/lsUoraDpp.d.ts +55 -0
  52. package/dist/lsUoraDpp.d.ts.map +1 -0
  53. package/dist/lsUoraDpp.js +152 -0
  54. package/dist/lsUoraDpp.js.map +1 -0
  55. package/dist/policyConfig.d.ts +31 -0
  56. package/dist/policyConfig.d.ts.map +1 -0
  57. package/dist/policyConfig.js +112 -0
  58. package/dist/policyConfig.js.map +1 -0
  59. package/dist/retraction.d.ts +41 -0
  60. package/dist/retraction.d.ts.map +1 -0
  61. package/dist/retraction.js +147 -0
  62. package/dist/retraction.js.map +1 -0
  63. package/dist/storage.d.ts +117 -0
  64. package/dist/storage.d.ts.map +1 -0
  65. package/dist/storage.js +158 -0
  66. package/dist/storage.js.map +1 -0
  67. package/dist/sync.d.ts +75 -0
  68. package/dist/sync.d.ts.map +1 -0
  69. package/dist/sync.js +118 -0
  70. package/dist/sync.js.map +1 -0
  71. package/dist/tmAttestation.d.ts +36 -0
  72. package/dist/tmAttestation.d.ts.map +1 -0
  73. package/dist/tmAttestation.js +50 -0
  74. package/dist/tmAttestation.js.map +1 -0
  75. package/dist/tmDpp.d.ts +154 -0
  76. package/dist/tmDpp.d.ts.map +1 -0
  77. package/dist/tmDpp.js +397 -0
  78. package/dist/tmDpp.js.map +1 -0
  79. package/dist/tmUoraDpp.d.ts +73 -0
  80. package/dist/tmUoraDpp.d.ts.map +1 -0
  81. package/dist/tmUoraDpp.js +150 -0
  82. package/dist/tmUoraDpp.js.map +1 -0
  83. package/dist/uoraAnchor.d.ts +209 -0
  84. package/dist/uoraAnchor.d.ts.map +1 -0
  85. package/dist/uoraAnchor.js +433 -0
  86. package/dist/uoraAnchor.js.map +1 -0
  87. package/package.json +51 -0
@@ -0,0 +1,127 @@
1
+ import { type PublisherPolicyConfig } from './policyConfig.js';
2
+ /**
3
+ * `info.version` of `contracts/overlay.yaml`, the wire this node speaks. A
4
+ * test holds the two equal, so the document cannot claim a contract version
5
+ * the file does not carry.
6
+ */
7
+ export declare const OVERLAY_HTTP_CONTRACT_VERSION = "0.7.0-draft";
8
+ /** The recommended baseline this node claims (`conformance/baseline-native-1.json`). */
9
+ export declare const BASELINE_ID = "native-baseline@2";
10
+ /**
11
+ * The policy version reported when no policy chain is configured: the keys
12
+ * come from the environment, not from a signed policy, and this string, the
13
+ * one the published example carries, says so.
14
+ */
15
+ export declare const IMPLICIT_POLICY_VERSION = "reference-node-environment";
16
+ /** The operator profile a node without peers, or without a federation policy, runs under. */
17
+ export declare const SINGLE_OPERATOR_PROFILE = "single-operator@1";
18
+ /**
19
+ * The operator profile claimed only when both halves are configured: a
20
+ * publisher policy whose scope names two or more operators, and peers to
21
+ * synchronise from. Either alone is single-operator@1 with a longer
22
+ * configuration; the profile's manifest says two processes under one
23
+ * administration prove the mechanism and never independence, and the
24
+ * document claims support, not independence.
25
+ */
26
+ export declare const FEDERATED_OPERATORS_PROFILE = "federated-operators@1";
27
+ /**
28
+ * The VSC seal representation this node indexes commitments to. Its rules live
29
+ * in the `@bsv/vsc` workspace, which this package does not depend on, so the
30
+ * two identifiers are repeated here; a test holds them equal to
31
+ * `conformance/baseline-native-1.json`.
32
+ */
33
+ export declare const VSC_SEAL_REPRESENTATION = "vsc-seal-json-v1";
34
+ export declare const VSC_SEAL_MEDIA_TYPE = "application/vc+ld+json";
35
+ export type CapabilityRole = 'passport-reader' | 'attestation-verifier' | 'passport-writer' | 'attestation-issuer' | 'registry' | 'overlay';
36
+ export interface CapabilityDocument {
37
+ capabilitiesVersion: '1';
38
+ implementation: {
39
+ name: string;
40
+ version: string;
41
+ sourceRevision?: string;
42
+ baselineId?: string;
43
+ };
44
+ roles: CapabilityRole[];
45
+ protocols: Array<{
46
+ id: string;
47
+ version: string;
48
+ }>;
49
+ profiles: Array<{
50
+ id: string;
51
+ version: string;
52
+ kind: 'industry' | 'exchange' | 'operator' | 'custody';
53
+ artefactDigests?: Record<string, string>;
54
+ options?: Record<string, unknown>;
55
+ }>;
56
+ representations: Array<{
57
+ id: string;
58
+ mediaType: string;
59
+ verification: 'content' | 'commitment-only';
60
+ }>;
61
+ proofSuites: string[];
62
+ anchorFormats: Array<{
63
+ prefix: string;
64
+ status: 'current' | 'historical' | 'refused';
65
+ }>;
66
+ topics: string[];
67
+ services: string[];
68
+ publisherPolicy: {
69
+ policyVersion: string;
70
+ publisherKeys: string[];
71
+ anchoringServices: string[];
72
+ ownerConsent: 'not-selected' | 'required';
73
+ transferAuthorities: string[];
74
+ };
75
+ synchronisation: {
76
+ profile: string;
77
+ discovery: 'none' | 'ship-slap' | 'static-peers';
78
+ gasp: boolean;
79
+ peers: string[];
80
+ };
81
+ limits: Record<string, number | string>;
82
+ unsupported: Array<{
83
+ id: string;
84
+ reason: string;
85
+ }>;
86
+ }
87
+ export interface CapabilityInput {
88
+ /** The verified chain, when PUBLISHER_POLICY_FILE is set. */
89
+ publisherPolicy?: PublisherPolicyConfig;
90
+ /** SERVICE_IDENTITY_KEY: the whole policy when no chain is configured. */
91
+ serviceIdentityKey?: string;
92
+ /** ANCHOR_SERVICE_KEYS: the anchoring services admitted when no chain is configured. */
93
+ anchorServiceKeys?: string[];
94
+ ownerConsent?: boolean | {
95
+ authorities: string[];
96
+ };
97
+ /** CONTROL_AUTHORITIES: identity keys whose version 2 UPDATE, TRANSFER or RETIRE is admitted without a control proof. */
98
+ controlAuthorities?: string[];
99
+ /** ACCEPTANCE_COMMITMENT=required: the managed-custody profile is selected, so a version 2 TRANSFER must carry its acceptance commitment. */
100
+ managedAcceptance?: boolean;
101
+ /** Whether EXPORT_SIGNING_KEY is set. */
102
+ exportAvailable: boolean;
103
+ /** Whether EXPORT_TOKEN is set, so GET /evidence-export needs a bearer. */
104
+ completeExportBearer?: boolean;
105
+ /** Whether POST /retract can ask the network about a transaction (false under CHAIN_TRACKER=scripts-only). */
106
+ networkOracleConfigured: boolean;
107
+ /** The instant the active keys are read at. */
108
+ at: Date;
109
+ /** A source revision to publish, when the deployment knows one. */
110
+ sourceRevision?: string;
111
+ /** SYNC_PEERS: the static peers this node synchronises from; none means synchronisation is off. */
112
+ syncPeers?: string[];
113
+ /** SYNC_INTERVAL_MS, reported beside the peers; 0 means one round at startup only. */
114
+ syncIntervalMs?: number;
115
+ }
116
+ /** This package's name and version, from its own manifest. */
117
+ export declare function implementationIdentity(): {
118
+ name: string;
119
+ version: string;
120
+ };
121
+ /** `bsv-attestation-anchor-v1` is the protocol `bsv-attestation-anchor` at version `1`: the prefix is the constant, the split is here. */
122
+ export declare function protocolFromPrefix(prefix: string): {
123
+ id: string;
124
+ version: string;
125
+ };
126
+ export declare function buildCapabilities(input: CapabilityInput): CapabilityDocument;
127
+ //# sourceMappingURL=capabilities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AA2BA,OAAO,EAA+B,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAG3F;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,gBAAgB,CAAA;AAE1D,wFAAwF;AACxF,eAAO,MAAM,WAAW,sBAAsB,CAAA;AAE9C;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,+BAA+B,CAAA;AAEnE,6FAA6F;AAC7F,eAAO,MAAM,uBAAuB,sBAAsB,CAAA;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,0BAA0B,CAAA;AAElE;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,qBAAqB,CAAA;AACzD,eAAO,MAAM,mBAAmB,2BAA2B,CAAA;AAE3D,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,sBAAsB,G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A8D;AAC9D,wBAAgB,sBAAsB,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAG1E;AAED,0IAA0I;AAC1I,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAIlF;AAQD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,GAAG,kBAAkB,CA2I5E"}
@@ -0,0 +1,210 @@
1
+ /**
2
+ * The capability document (`spec/conformance.md` section 4,
3
+ * `contracts/capabilities.schema.json`): what this node declares it supports,
4
+ * built from the constants the wire is built from and from the configuration
5
+ * the node actually runs with, never typed by hand where a constant exists.
6
+ * A claim of support, checkable against the ledger; never proof of authority
7
+ * or of conformance. `conformance/examples/capabilities-reference-node.json`
8
+ * is what this produces for the reference configuration.
9
+ */
10
+ import { readFileSync } from 'node:fs';
11
+ import { ATTESTATION_ANCHOR_PREFIX, LIFECYCLE_MEDIA_TYPE, LIFECYCLE_REPRESENTATION, MANAGED_CUSTODY_PROFILE, STANDARD_VERSION, STANDARD_VERSION_V2, policyInForceAt, } from '@bsv/dpp-core';
12
+ import { DPP_TOPIC } from './tmDpp.js';
13
+ import { DPP_SERVICE, MAX_LOOKUP_RESULTS } from './lsDpp.js';
14
+ import { ATTESTATION_TOPIC } from './tmAttestation.js';
15
+ import { ATTESTATION_SERVICE } from './lsAttestation.js';
16
+ import { DEFAULT_ATTESTATION_RESULTS, MAX_ATTESTATION_RESULTS } from './attestationStorage.js';
17
+ import { UORA_SERVICE, UORA_TOPIC } from './lsUoraDpp.js';
18
+ import { UORA_ANCHOR_PREFIX, UORA_ANCHOR_PREFIX_V1, UORA_ANCHOR_PREFIX_V2 } from './uoraAnchor.js';
19
+ import { DEFAULT_PAGE_SIZE, MAX_BODY_BYTES, MAX_EXPORT_PART_BYTES, MAX_EXPORT_STATES, MAX_PAGE_SIZE, SNAPSHOT_TTL_MS } from './limits.js';
20
+ import { newestPolicy, policyKeysFor } from './policyConfig.js';
21
+ import { DEFAULT_SYNC_INTERVAL_MS } from './sync.js';
22
+ /**
23
+ * `info.version` of `contracts/overlay.yaml`, the wire this node speaks. A
24
+ * test holds the two equal, so the document cannot claim a contract version
25
+ * the file does not carry.
26
+ */
27
+ export const OVERLAY_HTTP_CONTRACT_VERSION = '0.7.0-draft';
28
+ /** The recommended baseline this node claims (`conformance/baseline-native-1.json`). */
29
+ export const BASELINE_ID = 'native-baseline@2';
30
+ /**
31
+ * The policy version reported when no policy chain is configured: the keys
32
+ * come from the environment, not from a signed policy, and this string, the
33
+ * one the published example carries, says so.
34
+ */
35
+ export const IMPLICIT_POLICY_VERSION = 'reference-node-environment';
36
+ /** The operator profile a node without peers, or without a federation policy, runs under. */
37
+ export const SINGLE_OPERATOR_PROFILE = 'single-operator@1';
38
+ /**
39
+ * The operator profile claimed only when both halves are configured: a
40
+ * publisher policy whose scope names two or more operators, and peers to
41
+ * synchronise from. Either alone is single-operator@1 with a longer
42
+ * configuration; the profile's manifest says two processes under one
43
+ * administration prove the mechanism and never independence, and the
44
+ * document claims support, not independence.
45
+ */
46
+ export const FEDERATED_OPERATORS_PROFILE = 'federated-operators@1';
47
+ /**
48
+ * The VSC seal representation this node indexes commitments to. Its rules live
49
+ * in the `@bsv/vsc` workspace, which this package does not depend on, so the
50
+ * two identifiers are repeated here; a test holds them equal to
51
+ * `conformance/baseline-native-1.json`.
52
+ */
53
+ export const VSC_SEAL_REPRESENTATION = 'vsc-seal-json-v1';
54
+ export const VSC_SEAL_MEDIA_TYPE = 'application/vc+ld+json';
55
+ /** This package's name and version, from its own manifest. */
56
+ export function implementationIdentity() {
57
+ const manifest = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
58
+ return { name: manifest.name, version: manifest.version };
59
+ }
60
+ /** `bsv-attestation-anchor-v1` is the protocol `bsv-attestation-anchor` at version `1`: the prefix is the constant, the split is here. */
61
+ export function protocolFromPrefix(prefix) {
62
+ const match = /^(.+)-v(\d+)$/.exec(prefix);
63
+ if (match == null)
64
+ throw new Error(`${prefix} does not end in a version`);
65
+ return { id: match[1], version: match[2] };
66
+ }
67
+ function profileEntry(profile) {
68
+ const at = profile.indexOf('@');
69
+ if (at <= 0)
70
+ throw new Error(`${profile} is not id@version`);
71
+ return { id: profile.slice(0, at), version: profile.slice(at + 1) };
72
+ }
73
+ export function buildCapabilities(input) {
74
+ const policy = input.publisherPolicy;
75
+ const chain = policy?.chain;
76
+ const peers = [...(input.syncPeers ?? [])];
77
+ const synchronising = peers.length > 0;
78
+ const federated = synchronising && policy != null && newestPolicy(policy).scope.operators.length >= 2;
79
+ const operatorProfile = federated ? FEDERATED_OPERATORS_PROFILE : SINGLE_OPERATOR_PROFILE;
80
+ const inForce = chain == null ? undefined : policyInForceAt(chain, input.at);
81
+ // The same question admission asks, at this instant: the policy's keys where
82
+ // it covers the topic, the environment's where it does not or where there is
83
+ // no policy at all.
84
+ const publisherKeys = (chain == null ? undefined : policyKeysFor(chain, input.at, 'state-publisher', DPP_TOPIC)) ??
85
+ (input.serviceIdentityKey == null || input.serviceIdentityKey === '' ? [] : [input.serviceIdentityKey]);
86
+ const anchorPolicyKeys = chain == null ? undefined : policyKeysFor(chain, input.at, 'anchor-publisher', ATTESTATION_TOPIC);
87
+ const anchoringServices = anchorPolicyKeys ?? input.anchorServiceKeys ?? [];
88
+ // An empty list means two different things: under a policy that covers the
89
+ // anchor topic, no anchoring service is admitted; with no policy over the
90
+ // topic and no static list, every well-formed anchor is. The second is
91
+ // named under unsupported so the list is never read as the first.
92
+ const anchorsUnrestricted = anchorPolicyKeys == null && anchoringServices.length === 0;
93
+ const consentSelected = input.ownerConsent != null && input.ownerConsent !== false;
94
+ const transferAuthorities = typeof input.ownerConsent === 'object' ? [...input.ownerConsent.authorities] : [];
95
+ const controlAuthorities = input.controlAuthorities ?? transferAuthorities;
96
+ const managedAcceptance = input.managedAcceptance === true;
97
+ const unsupported = [
98
+ { id: 'ship-slap-discovery', reason: 'This node advertises nothing; a public deployment declares its discovery profile separately.' },
99
+ ...(synchronising
100
+ ? []
101
+ : [{ id: 'gasp-synchronisation', reason: 'Peer synchronisation is off in this host; federated-operators@1 is a separate operator profile, and naming it does not start a synchronisation.' }]),
102
+ { id: 'credential-content-verification', reason: 'An overlay indexes commitments and authenticates anchoring-service metadata; credential proof, status and authority are verified by a registry or reader.' },
103
+ ];
104
+ if (anchorsUnrestricted) {
105
+ unsupported.push({
106
+ id: 'anchoring-service-restriction',
107
+ reason: 'No publisher policy covers tm_attestation and ANCHOR_SERVICE_KEYS is unset, so every well-formed anchor is admitted whoever wrote it; publisherPolicy.anchoringServices is empty because nothing restricts, not because nothing is admitted.',
108
+ });
109
+ }
110
+ if (policy == null) {
111
+ unsupported.push({
112
+ id: 'publisher-key-rotation',
113
+ reason: 'No PUBLISHER_POLICY_FILE is configured: the single SERVICE_IDENTITY_KEY is an implicit single-operator policy with no rotation history, and every state is checked against it whatever its timestamp.',
114
+ });
115
+ }
116
+ if (!input.exportAvailable) {
117
+ unsupported.push({
118
+ id: 'evidence-package-export',
119
+ reason: 'EXPORT_SIGNING_KEY is unset, so GET /evidence-package and GET /evidence-export answer 503 export-unavailable; the bounded lookup and GET /history remain.',
120
+ });
121
+ }
122
+ if (!input.networkOracleConfigured) {
123
+ unsupported.push({
124
+ id: 'retraction-network-check',
125
+ reason: 'No header source is configured (CHAIN_TRACKER=scripts-only), so POST /retract cannot ask the network whether it knows a transaction and relies on the local merkle-path check alone, which its answer states.',
126
+ });
127
+ }
128
+ const implementation = implementationIdentity();
129
+ return {
130
+ capabilitiesVersion: '1',
131
+ implementation: {
132
+ name: implementation.name,
133
+ version: implementation.version,
134
+ ...(input.sourceRevision == null ? {} : { sourceRevision: input.sourceRevision }),
135
+ baselineId: BASELINE_ID,
136
+ },
137
+ roles: ['overlay'],
138
+ protocols: [
139
+ { id: 'dpp-record', version: STANDARD_VERSION },
140
+ { id: 'dpp-record', version: STANDARD_VERSION_V2 },
141
+ protocolFromPrefix(ATTESTATION_ANCHOR_PREFIX),
142
+ { id: 'overlay-http', version: OVERLAY_HTTP_CONTRACT_VERSION },
143
+ ],
144
+ profiles: [
145
+ {
146
+ ...profileEntry(operatorProfile),
147
+ kind: 'operator',
148
+ options: {
149
+ discovery: synchronising ? 'static-peers' : 'none',
150
+ gasp: synchronising,
151
+ ...(policy == null ? {} : { operators: [...newestPolicy(policy).scope.operators] }),
152
+ ...(synchronising ? { peers, syncIntervalMs: input.syncIntervalMs ?? DEFAULT_SYNC_INTERVAL_MS } : {}),
153
+ },
154
+ },
155
+ // The custody profile this index admits version 2 states under: the
156
+ // managed-custody profile when its acceptance commitment is required,
157
+ // else the record model baseline, named so a writer learns which rule
158
+ // applies from the document and not from a refusal.
159
+ {
160
+ ...profileEntry(managedAcceptance ? MANAGED_CUSTODY_PROFILE : 'record-model-baseline@2'),
161
+ kind: 'custody',
162
+ options: {
163
+ acceptanceCommitment: managedAcceptance ? 'required' : 'not-selected',
164
+ controlAuthorities,
165
+ },
166
+ },
167
+ ],
168
+ representations: [
169
+ { id: LIFECYCLE_REPRESENTATION, mediaType: LIFECYCLE_MEDIA_TYPE, verification: 'commitment-only' },
170
+ { id: VSC_SEAL_REPRESENTATION, mediaType: VSC_SEAL_MEDIA_TYPE, verification: 'commitment-only' },
171
+ ],
172
+ proofSuites: [],
173
+ anchorFormats: [
174
+ { prefix: ATTESTATION_ANCHOR_PREFIX, status: 'current' },
175
+ { prefix: UORA_ANCHOR_PREFIX, status: 'historical' },
176
+ { prefix: UORA_ANCHOR_PREFIX_V1, status: 'historical' },
177
+ { prefix: UORA_ANCHOR_PREFIX_V2, status: 'refused' },
178
+ ],
179
+ topics: [DPP_TOPIC, ATTESTATION_TOPIC, UORA_TOPIC],
180
+ services: [DPP_SERVICE, ATTESTATION_SERVICE, UORA_SERVICE],
181
+ publisherPolicy: {
182
+ policyVersion: policy == null ? IMPLICIT_POLICY_VERSION : String((inForce ?? newestPolicy(policy)).policyVersion),
183
+ publisherKeys,
184
+ anchoringServices,
185
+ ownerConsent: consentSelected ? 'required' : 'not-selected',
186
+ transferAuthorities,
187
+ },
188
+ synchronisation: { profile: operatorProfile, discovery: synchronising ? 'static-peers' : 'none', gasp: synchronising, peers },
189
+ limits: {
190
+ maxLookupResults: MAX_LOOKUP_RESULTS,
191
+ defaultAnchorPageSize: DEFAULT_ATTESTATION_RESULTS,
192
+ maxAnchorPageSize: MAX_ATTESTATION_RESULTS,
193
+ maxBodyBytes: MAX_BODY_BYTES,
194
+ defaultHistoryPageSize: DEFAULT_PAGE_SIZE,
195
+ maxHistoryPageSize: MAX_PAGE_SIZE,
196
+ historySnapshotTtlSeconds: SNAPSHOT_TTL_MS / 1000,
197
+ evidencePackageExport: input.exportAvailable ? 'available' : 'unavailable',
198
+ maxEvidencePackageStates: MAX_EXPORT_STATES,
199
+ // The complete export: open like GET /history, or behind the bearer
200
+ // EXPORT_TOKEN names; each part bounded by both numbers below.
201
+ evidenceExport: input.exportAvailable ? (input.completeExportBearer === true ? 'bearer' : 'open') : 'unavailable',
202
+ maxEvidenceExportPartStates: MAX_EXPORT_STATES,
203
+ maxEvidenceExportPartBytes: MAX_EXPORT_PART_BYTES,
204
+ maxSyncPageSize: MAX_PAGE_SIZE,
205
+ ...(synchronising ? { syncIntervalMs: input.syncIntervalMs ?? DEFAULT_SYNC_INTERVAL_MS } : {}),
206
+ },
207
+ unsupported,
208
+ };
209
+ }
210
+ //# sourceMappingURL=capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../src/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,GAChB,MAAM,e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AC,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE;QAC7H,MAAM,EAAE;YACN,gBAAgB,EAAE,kBAAkB;YACpC,qBAAqB,EAAE,2BAA2B;YAClD,iBAAiB,EAAE,uBAAuB;YAC1C,YAAY,EAAE,cAAc;YAC5B,sBAAsB,EAAE,iBAAiB;YACzC,kBAAkB,EAAE,aAAa;YACjC,yBAAyB,EAAE,eAAe,GAAG,IAAI;YACjD,qBAAqB,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa;YAC1E,wBAAwB,EAAE,iBAAiB;YAC3C,oEAAoE;YACpE,+DAA+D;YAC/D,cAAc,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,oBAAoB,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,aAAa;YACjH,2BAA2B,EAAE,iBAAiB;YAC9C,0BAA0B,EAAE,qBAAqB;YACjD,eAAe,EAAE,aAAa;YAC9B,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,IAAI,wBAAwB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/F;QACD,WAAW;KACZ,CAAA;AACH,CAAC"}
@@ -0,0 +1,106 @@
1
+ import type { AppliedTransaction, Output, Storage } from '@bsv/overlay';
2
+ import type { Db } from 'mongodb';
3
+ /**
4
+ * The overlay Engine's own storage, which is a different thing from
5
+ * `DppRecordStore` in storage.ts.
6
+ *
7
+ * The engine tracks admitted UTXOs, their spend state, their consumption
8
+ * graph and the BEEF each transaction arrived in. `ls_dpp` separately keeps
9
+ * the passport index it answers lookups from. `@bsv/overlay` ships only a
10
+ * knex implementation of this interface, whose migration chain is MySQL-only
11
+ * (`INSERT IGNORE` and `longblob` in
12
+ * node_modules/@bsv/overlay/src/storage/knex/migrations/2024-07-17-001-transactions.ts),
13
+ * so a MySQL instance would have to be provisioned beside the service purely
14
+ * for the engine. The DPP programme already runs one database. These two
15
+ * implementations keep it that way.
16
+ *
17
+ * Semantics mirror KnexStorage exactly, including its quirks:
18
+ * - `insertOutput` never overwrites an existing (txid, outputIndex, topic).
19
+ * - BEEF is stored once per txid, not per output.
20
+ * - `deleteOutput` ignores the topic argument when deleting, and drops the
21
+ * BEEF only when the txid has no outputs left.
22
+ *
23
+ * Both also implement `RetractableStorage`: two operations the upstream
24
+ * interface lacks and `POST /retract` needs, undoing a spend mark and
25
+ * forgetting an applied transaction, so a retracted phantom state leaves the
26
+ * real tip a tip and can be announced again if the network later takes it.
27
+ */
28
+ /**
29
+ * The engine storage plus what a retraction needs. The upstream `Storage`
30
+ * only ever marks an output spent, because the Engine's own eviction prunes a
31
+ * consumed lineage whole and never restores one. Retraction restores one, so
32
+ * it needs the inverse. Since `@bsv/overlay` 2.3.1 the interface itself
33
+ * declares the optional `deleteAppliedTransaction(txid, topic)`, which the
34
+ * Engine uses to evict unproven admissions it has stopped waiting for, and
35
+ * the same member serves retraction here; both implementations below provide
36
+ * it. `markUTXOAsUnspent` stays this package's own. Both are optional so a
37
+ * foreign `Storage` still fits; without them the retraction route says which
38
+ * repair it could not make.
39
+ */
40
+ export interface RetractableStorage extends Storage {
41
+ /** Clear the spent flag on an output whose spender was retracted. */
42
+ markUTXOAsUnspent?: (txid: string, outputIndex: number, topic: string) => Promise<void>;
43
+ }
44
+ /** Engine storage in memory: for tests, local runs and the offline rehearsal. */
45
+ export declare class InMemoryOverlayStorage implements RetractableStorage {
46
+ private readonly outputs;
47
+ private readonly transactions;
48
+ private readonly applied;
49
+ private readonly interactions;
50
+ insertOutput(utxo: Output): Promise<void>;
51
+ findOutput(txid: string, outputIndex: number, topic?: string, spent?: boolean, includeBEEF?: boolean): Promise<Output | null>;
52
+ findOutputsByOutpoints(outpoints: Array<{
53
+ txid: string;
54
+ outputIndex: number;
55
+ }>, includeBEEF?: boolean): Promise<Output[]>;
56
+ findOutputsForTransaction(txid: string, includeBEEF?: boolean): Promise<Output[]>;
57
+ findUTXOsForTopic(topic: string, since?: number, limit?: number, includeBEEF?: boolean): Promise<Output[]>;
58
+ deleteOutput(txid: string, outputIndex: number, _topic: string): Promise<void>;
59
+ markUTXOAsSpent(txid: string, outputIndex: number, topic: string): Promise<void>;
60
+ markUTXOAsUnspent(txid: string, outputIndex: number, topic: string): Promise<void>;
61
+ updateConsumedBy(txid: string, outputIndex: number, topic: string, consumedBy: Array<{
62
+ txid: string;
63
+ outputIndex: number;
64
+ }>): Promise<void>;
65
+ updateTransactionBEEF(txid: string, beef: number[]): Promise<void>;
66
+ updateOutputBlockHeight(txid: string, outputIndex: number, topic: string, blockHeight: number): Promise<void>;
67
+ insertAppliedTransaction(tx: AppliedTransaction): Promise<void>;
68
+ doesAppliedTransactionExist(tx: AppliedTransaction): Promise<boolean>;
69
+ deleteAppliedTransaction(txid: string, topic: string): Promise<void>;
70
+ updateLastInteraction(host: string, topic: string, since: number): Promise<void>;
71
+ getLastInteraction(host: string, topic: string): Promise<number>;
72
+ }
73
+ /** Engine storage on MongoDB: the hosted deployment's persistence. */
74
+ export declare class MongoOverlayStorage implements RetractableStorage {
75
+ private readonly outputs;
76
+ private readonly transactions;
77
+ private readonly applied;
78
+ private readonly interactions;
79
+ constructor(db: Db, prefix?: string);
80
+ /** Call once at boot; index creation is not on any request path. */
81
+ ensureIndexes(): Promise<void>;
82
+ private beefFor;
83
+ insertOutput(utxo: Output): Promise<void>;
84
+ findOutput(txid: string, outputIndex: number, topic?: string, spent?: boolean, includeBEEF?: boolean): Promise<Output | null>;
85
+ findOutputsByOutpoints(outpoints: Array<{
86
+ txid: string;
87
+ outputIndex: number;
88
+ }>, includeBEEF?: boolean): Promise<Output[]>;
89
+ findOutputsForTransaction(txid: string, includeBEEF?: boolean): Promise<Output[]>;
90
+ findUTXOsForTopic(topic: string, since?: number, limit?: number, includeBEEF?: boolean): Promise<Output[]>;
91
+ deleteOutput(txid: string, outputIndex: number, _topic: string): Promise<void>;
92
+ markUTXOAsSpent(txid: string, outputIndex: number, topic: string): Promise<void>;
93
+ markUTXOAsUnspent(txid: string, outputIndex: number, topic: string): Promise<void>;
94
+ updateConsumedBy(txid: string, outputIndex: number, topic: string, consumedBy: Array<{
95
+ txid: string;
96
+ outputIndex: number;
97
+ }>): Promise<void>;
98
+ updateTransactionBEEF(txid: string, beef: number[]): Promise<void>;
99
+ updateOutputBlockHeight(txid: string, outputIndex: number, topic: string, blockHeight: number): Promise<void>;
100
+ insertAppliedTransaction(tx: AppliedTransaction): Promise<void>;
101
+ doesAppliedTransactionExist(tx: AppliedTransaction): Promise<boolean>;
102
+ deleteAppliedTransaction(txid: string, topic: string): Promise<void>;
103
+ updateLastInteraction(host: string, topic: string, since: number): Promise<void>;
104
+ getLastInteraction(host: string, topic: string): Promise<number>;
105
+ }
106
+ //# sourceMappingURL=engineStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engineStorage.d.ts","sourceRoot":"","sources":["../src/engineStorage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,KAAK,EAAc,EAAE,EAAE,MAAM,SAAS,CAAA;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,kBAAmB,SAAQ,OAAO;IACjD,qEAAqE;IACrE,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACxF;AAsED,iFAAiF;AACjF,qBAAa,sBAAuB,YAAW,kBAAkB;IAC/D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAC1D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA4B;I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