@forgezero/runtime 0.1.7 → 0.1.8
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 +357 -118
- package/dist/custody-share.js +12 -0
- package/dist/phrase.d.ts +1 -1
- package/package.json +260 -261
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
GENERATED FILE — do not edit.
|
|
3
3
|
|
|
4
|
-
Change
|
|
4
|
+
Change tools/generate-guides.ts or its typed sources, run `bun run guides`,
|
|
5
5
|
and commit the generator and rendered files together.
|
|
6
6
|
-->
|
|
7
7
|
|
|
@@ -9,14 +9,77 @@
|
|
|
9
9
|
|
|
10
10
|
The machinery behind a request handler — jobs, queues, an outbox, a hash-chained audit trail, mail, backups, schema validation and exact money. 44 public modules, each imported on its own.
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## Package overview
|
|
13
13
|
|
|
14
|
-
Anyone running a service, for the work that happens outside a request. Separate from `access` because a Cloudflare Worker wants the request pipeline and cannot run a backup job. Supported runtimes: bun, node.
|
|
14
|
+
Anyone running a service, for the work that happens outside a request. Separate from `access` because a Cloudflare Worker wants the request pipeline and cannot run a backup job. Supported runtimes: bun, node. Package root: @forgezero/runtime. The sections below show the actual named imports emitted by each declaration entry point; wildcard imports are intentionally not used in the documentation.
|
|
15
15
|
|
|
16
16
|
```text
|
|
17
|
-
|
|
17
|
+
bun add @forgezero/runtime
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
+
## ForgeZero package family
|
|
21
|
+
|
|
22
|
+
The five packages are installation boundaries. Choose a package by who installs it; choose a subpath by the capability used in that file.
|
|
23
|
+
|
|
24
|
+
| package | short description | runtimes | documentation |
|
|
25
|
+
|---|---|---|---|
|
|
26
|
+
| @forgezero/vault | Scoped secret access with Agent, API-key and systemd-credential sources. | bun, node, workers, deno | [Open](https://www.forgezero.net/docs/vault-package) |
|
|
27
|
+
| @forgezero/access | Typed route, principal, factor, RBAC and request-pipeline contracts. | bun, node, workers, deno | [Open](https://www.forgezero.net/docs/access) |
|
|
28
|
+
| @forgezero/providers | Typed external providers with priority, health and classified fallback. | bun, node, workers, deno | [Open](https://www.forgezero.net/docs/providers) |
|
|
29
|
+
| @forgezero/runtime | Portable runtime primitives for queries, jobs, events, schemas and finance. | bun, node | [Open](https://www.forgezero.net/docs/runtime) |
|
|
30
|
+
| @forgezero/agent | Operator CLI and managed-node agent for bootstrap, deploy and lifecycle. | bun, node | [Open](https://www.forgezero.net/docs/agent) |
|
|
31
|
+
|
|
32
|
+
## @forgezero/runtime public imports and commands
|
|
33
|
+
|
|
34
|
+
Every row links to the detailed explanation and named-import/example area below. This table and those details are generated from the package inventory and emitted declarations.
|
|
35
|
+
|
|
36
|
+
| public entry | short description | runtime | details |
|
|
37
|
+
|---|---|---|---|
|
|
38
|
+
| @forgezero/runtime/query | Provider-neutral typed function contracts: decode untrusted input, run with caller-supplied services or storage, and strictly validate the result without coupling business logic to ForgeZero or ArangoDB. | portable | [Details + example](#forgezero-runtime-query) |
|
|
39
|
+
| @forgezero/runtime/jobs | Background work that never overlaps itself, advances a cursor only on success, and can be paused and inspected. | portable | [Details + example](#forgezero-runtime-jobs) |
|
|
40
|
+
| @forgezero/runtime/queue | Memory-only keyed work queue — awaited results, parallel across keys and strictly sequential within one; clustered callers atomically claim ownership in their own business store before submitting. | portable | [Details + example](#forgezero-runtime-queue) |
|
|
41
|
+
| @forgezero/runtime/outbox | Write the event with the record, deliver it after, in order per key with backoff and a dead-letter queue. | portable | [Details + example](#forgezero-runtime-outbox) |
|
|
42
|
+
| @forgezero/runtime/audit | Append-only records chained by hash, with a verifier that names the first altered entry. | portable | [Details + example](#forgezero-runtime-audit) |
|
|
43
|
+
| @forgezero/runtime/backup | Encrypted, chunked, verified snapshots to object storage — and the restore that reads them back. | portable | [Details + example](#forgezero-runtime-backup) |
|
|
44
|
+
| @forgezero/runtime/notify | Render a named template to text and HTML, escaped per part, refusing to send with a blank where a value should be. | portable | [Details + example](#forgezero-runtime-notify) |
|
|
45
|
+
| @forgezero/runtime/notify/templates | The six transactional messages ForgeZero sends. | portable | [Details + example](#forgezero-runtime-notify-templates) |
|
|
46
|
+
| @forgezero/runtime/calendar | Billing periods computed from an anchor, working days, holidays and due dates. | portable | [Details + example](#forgezero-runtime-calendar) |
|
|
47
|
+
| @forgezero/runtime/compliance | Screening as a decision record — tiers, rules and lists, failing closed when a list is unreachable. | portable | [Details + example](#forgezero-runtime-compliance) |
|
|
48
|
+
| @forgezero/runtime/totp | RFC 6238 TOTP on the existing HMAC — base32, an asymmetric window, and replay left to the caller. | portable | [Details + example](#forgezero-runtime-totp) |
|
|
49
|
+
| @forgezero/runtime/passkey | Passkeys for sites that are not us. A vault-held credential is as unphishable as one in a security chip provided the RP ID check never slips — `evil-example.com` ends with `example.com` and is a different site. | portable | [Details + example](#forgezero-runtime-passkey) |
|
|
50
|
+
| @forgezero/runtime/phrase | BIP-39 recovery phrases, and the salted verifier that proves one without being able to reconstruct it. | portable | [Details + example](#forgezero-runtime-phrase) |
|
|
51
|
+
| @forgezero/runtime/snp | Parse an AMD SEV-SNP attestation report at the firmware ABI offsets, and compare a TCB component by component so a microcode bump cannot mask a firmware downgrade. | portable | [Details + example](#forgezero-runtime-snp) |
|
|
52
|
+
| @forgezero/runtime/importers | Read secrets out of a .env, a CSV, or a Bitwarden or 1Password export — skipping what cannot be understood rather than guessing, and never putting a value in an error. | portable | [Details + example](#forgezero-runtime-importers) |
|
|
53
|
+
| @forgezero/runtime/openssh | OpenSSH wire encoding, so a derived ed25519 key becomes a line that pastes into authorized_keys. | portable | [Details + example](#forgezero-runtime-openssh) |
|
|
54
|
+
| @forgezero/runtime/ssh-cert | OpenSSH certificates, so access expires instead of having to be hunted down. Takes a signing FUNCTION rather than a secret key, which is what lets the CA live in a vault that never hands it out. | portable | [Details + example](#forgezero-runtime-ssh-cert) |
|
|
55
|
+
| @forgezero/runtime/slip10 | SLIP-0010 derivation for ed25519, hardened-only — BIP-32 does not work on this curve and produces halves that do not correspond. | portable | [Details + example](#forgezero-runtime-slip10) |
|
|
56
|
+
| @forgezero/runtime/identity | Hybrid Ed25519 + ML-DSA-65 request signing. One canonical string, so the compute agent that signs inside a guest and the API that verifies cannot drift — which two implementations of it certainly would. | portable | [Details + example](#forgezero-runtime-identity) |
|
|
57
|
+
| @forgezero/runtime/schema | Validate against JSON Schema, restrict what a caller may declare, and describe a schema as a form. | portable | [Details + example](#forgezero-runtime-schema) |
|
|
58
|
+
| @forgezero/runtime/schema/typebox | The TypeBox validator behind that interface. | portable | [Details + example](#forgezero-runtime-schema-typebox) |
|
|
59
|
+
| @forgezero/runtime/finance/discounts | Promotions as arithmetic over integer minor units. They never stack — one winner — and a percentage rounds down, because rounding a discount up gives away a unit of currency per invoice forever. | portable | [Details + example](#forgezero-runtime-finance-discounts) |
|
|
60
|
+
| @forgezero/runtime/finance/money | Exact amounts in minor units with the asset attached, so two currencies cannot be added. | portable | [Details + example](#forgezero-runtime-finance-money) |
|
|
61
|
+
| @forgezero/runtime/finance/venues | Trading venues, market types and symbols as data — spot, margin and futures behind one order model. | portable | [Details + example](#forgezero-runtime-finance-venues) |
|
|
62
|
+
| @forgezero/runtime/finance/ledger | Double-entry postings and derived balances. A hold is a posting, not a lock — the queue does the ordering. | portable | [Details + example](#forgezero-runtime-finance-ledger) |
|
|
63
|
+
| @forgezero/runtime/finance/commission | Profit net of flows, a high-water mark, the tier split and the referral share of our income. | portable | [Details + example](#forgezero-runtime-finance-commission) |
|
|
64
|
+
| @forgezero/runtime/finance/rates | What an asset is worth in USD, and how old that answer is. A peg never ages; a quote always does. | portable | [Details + example](#forgezero-runtime-finance-rates) |
|
|
65
|
+
| @forgezero/runtime/finance/transfers | Deposits and withdrawals as ordered pipelines, with screening reserved at position zero. | portable | [Details + example](#forgezero-runtime-finance-transfers) |
|
|
66
|
+
| @forgezero/runtime/finance/chain | Which chains exist, their confirmation depth by value band, assets and explorers — as data an admin edits. | portable | [Details + example](#forgezero-runtime-finance-chain) |
|
|
67
|
+
| @forgezero/runtime/finance/custody | Derive CREATE2 deposit addresses and EIP-712 custody digests — arithmetic over a seed and a salt, needing no credential and no node. | portable | [Details + example](#forgezero-runtime-finance-custody) |
|
|
68
|
+
| @forgezero/runtime/finance/derive | Declare a field ForgeZero generates rather than the tenant supplying: BIP-44 path arithmetic, and the choice of who is capable of generating the key. | portable | [Details + example](#forgezero-runtime-finance-derive) |
|
|
69
|
+
| @forgezero/runtime/finance/tax | Which jurisdiction may tax a sale, who accounts for it, and the three ways to be zero that report differently. Rates are data. | portable | [Details + example](#forgezero-runtime-finance-tax) |
|
|
70
|
+
| @forgezero/runtime/finance/storage | Write an amount so it is both exact and sortable: an authoritative string, and a number that is only an index. | portable | [Details + example](#forgezero-runtime-finance-storage) |
|
|
71
|
+
| @forgezero/runtime/realtime | Provider-neutral realtime audience, shard, event and delivery contracts. | portable | [Details + example](#forgezero-runtime-realtime) |
|
|
72
|
+
| @forgezero/runtime/passkey-hybrid | Versioned WebAuthn PRF plus ML-DSA companion proof construction and verification. | portable | [Details + example](#forgezero-runtime-passkey-hybrid) |
|
|
73
|
+
| @forgezero/runtime/otpauth | Parse and render otpauth URIs without binding enrolment to a UI framework. | portable | [Details + example](#forgezero-runtime-otpauth) |
|
|
74
|
+
| @forgezero/runtime/pipeline | Typed ordered application-pipeline execution with explicit evidence. | portable | [Details + example](#forgezero-runtime-pipeline) |
|
|
75
|
+
| @forgezero/runtime/finance/chain-addresses | Chain-address derivation records and validation independent of a node provider. | portable | [Details + example](#forgezero-runtime-finance-chain-addresses) |
|
|
76
|
+
| @forgezero/runtime/finance/chain-deposits | Provider-neutral deposit observation, confirmation and credit transitions. | portable | [Details + example](#forgezero-runtime-finance-chain-deposits) |
|
|
77
|
+
| @forgezero/runtime/finance/chain-withdrawals | Provider-neutral withdrawal approval, broadcast and finality transitions. | portable | [Details + example](#forgezero-runtime-finance-chain-withdrawals) |
|
|
78
|
+
| @forgezero/runtime/finance/chain-reconcile | Deterministic reconciliation between chain observations and durable transfer state. | portable | [Details + example](#forgezero-runtime-finance-chain-reconcile) |
|
|
79
|
+
| @forgezero/runtime/finance/market | Market order, fill and quote contracts independent of any exchange adapter. | portable | [Details + example](#forgezero-runtime-finance-market) |
|
|
80
|
+
| @forgezero/runtime/custody-share | Threshold-share parsing, validation and reconstruction. | portable | [Details + example](#forgezero-runtime-custody-share) |
|
|
81
|
+
| @forgezero/runtime/custody-crypto | Hybrid ML-KEM-768 plus X25519 custody-share sealing and opening. | portable | [Details + example](#forgezero-runtime-custody-crypto) |
|
|
82
|
+
|
|
20
83
|
## Commands
|
|
21
84
|
|
|
22
85
|
bun add @forgezero/runtime — Install runtime contracts; import the required subpath so unused capabilities stay out of the bundle.
|
|
@@ -25,382 +88,558 @@ bun add @forgezero/runtime — Install runtime contracts; import the required su
|
|
|
25
88
|
bun add @forgezero/runtime
|
|
26
89
|
```
|
|
27
90
|
|
|
91
|
+
<a id="forgezero-runtime-query"></a>
|
|
28
92
|
## @forgezero/runtime/query
|
|
29
93
|
|
|
30
|
-
Provider-neutral typed function contracts: decode untrusted input, run with caller-supplied services or storage, and strictly validate the result without coupling business logic to ForgeZero or ArangoDB.
|
|
94
|
+
Provider-neutral typed function contracts: decode untrusted input, run with caller-supplied services or storage, and strictly validate the result without coupling business logic to ForgeZero or ArangoDB. Named value imports: QueryContractError, defineQuery, implementQuery. Named type imports: QueryCodec, QueryContract, QueryDecode, QueryExecution, QueryImplementation, QueryInput, QueryIssue, QueryOutput. Import only the names used by this file.
|
|
31
95
|
|
|
32
96
|
```text
|
|
33
|
-
import
|
|
97
|
+
import { QueryContractError, defineQuery, implementQuery } from '@forgezero/runtime/query';
|
|
98
|
+
import type { QueryCodec, QueryContract, QueryDecode, QueryExecution, QueryImplementation, QueryInput } from '@forgezero/runtime/query';
|
|
99
|
+
import type { QueryIssue, QueryOutput } from '@forgezero/runtime/query';
|
|
34
100
|
```
|
|
35
101
|
|
|
102
|
+
## @forgezero/runtime/query — Define and implement a typed query
|
|
103
|
+
|
|
104
|
+
Decode untrusted input and validate output around injected storage/services rather than embedding a database query in the route adapter.
|
|
105
|
+
|
|
106
|
+
```text
|
|
107
|
+
import { defineQuery, implementQuery } from '@forgezero/runtime/query';
|
|
108
|
+
import { T, type Static, typeboxQueryCodec } from '@forgezero/runtime/schema/typebox';
|
|
109
|
+
|
|
110
|
+
const OrderKey = T.Object({ orderKey: T.String({ minLength: 1 }) });
|
|
111
|
+
const Order = T.Object({ orderKey: T.String(), total: T.String() });
|
|
112
|
+
type OrderRow = Static<typeof Order>;
|
|
113
|
+
type Stores = { orders: { find(key: string): Promise<OrderRow | null> } };
|
|
114
|
+
declare const stores: Stores;
|
|
115
|
+
|
|
116
|
+
const findOrder = defineQuery({
|
|
117
|
+
name: 'orders.find',
|
|
118
|
+
input: typeboxQueryCodec(OrderKey),
|
|
119
|
+
output: typeboxQueryCodec(T.Union([Order, T.Null()]))
|
|
120
|
+
});
|
|
121
|
+
export const runFindOrder = implementQuery(findOrder,
|
|
122
|
+
(context: Stores, input) => context.orders.find(input.orderKey)
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const order = await runFindOrder.execute(stores, { orderKey: 'ord_123' });
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
<a id="forgezero-runtime-jobs"></a>
|
|
36
129
|
## @forgezero/runtime/jobs
|
|
37
130
|
|
|
38
|
-
Background work that never overlaps itself, advances a cursor only on success, and can be paused and inspected.
|
|
131
|
+
Background work that never overlaps itself, advances a cursor only on success, and can be paused and inspected. Named value imports: VERSION, createScheduler, cursorJob, defineJob, everyMs, memoryLock, nextWallClockAt, storeLock, systemClock. Named type imports: Clock, CursorBatch, CursorJobSpec, CursorStore, JobContext, JobLock, JobReport, JobResult, JobSpec, Lease, LockStore, Scheduler, SchedulerOptions, WallClockSchedule. Import only the names used by this file.
|
|
39
132
|
|
|
40
133
|
```text
|
|
41
|
-
import
|
|
134
|
+
import { VERSION, createScheduler, cursorJob, defineJob, everyMs, memoryLock } from '@forgezero/runtime/jobs';
|
|
135
|
+
import { nextWallClockAt, storeLock, systemClock } from '@forgezero/runtime/jobs';
|
|
136
|
+
import type { Clock, CursorBatch, CursorJobSpec, CursorStore, JobContext, JobLock } from '@forgezero/runtime/jobs';
|
|
137
|
+
import type { JobReport, JobResult, JobSpec, Lease, LockStore, Scheduler } from '@forgezero/runtime/jobs';
|
|
138
|
+
import type { SchedulerOptions, WallClockSchedule } from '@forgezero/runtime/jobs';
|
|
42
139
|
```
|
|
43
140
|
|
|
141
|
+
<a id="forgezero-runtime-queue"></a>
|
|
44
142
|
## @forgezero/runtime/queue
|
|
45
143
|
|
|
46
|
-
Memory-only keyed work queue — awaited results, parallel across keys and strictly sequential within one; clustered callers atomically claim ownership in their own business store before submitting.
|
|
144
|
+
Memory-only keyed work queue — awaited results, parallel across keys and strictly sequential within one; clustered callers atomically claim ownership in their own business store before submitting. Named value imports: QueueKeyStoppedError, QueueStoppedError, TaskCancelledError, createQueue, queueWidthFor. Named type imports: DrainReport, Queue, QueueOptions, QueueResourcePolicy, QueueTask, RetryPolicy. Import only the names used by this file.
|
|
47
145
|
|
|
48
146
|
```text
|
|
49
|
-
import
|
|
147
|
+
import { QueueKeyStoppedError, QueueStoppedError, TaskCancelledError, createQueue, queueWidthFor } from '@forgezero/runtime/queue';
|
|
148
|
+
import type { DrainReport, Queue, QueueOptions, QueueResourcePolicy, QueueTask, RetryPolicy } from '@forgezero/runtime/queue';
|
|
50
149
|
```
|
|
51
150
|
|
|
151
|
+
<a id="forgezero-runtime-outbox"></a>
|
|
52
152
|
## @forgezero/runtime/outbox
|
|
53
153
|
|
|
54
|
-
Write the event with the record, deliver it after, in order per key with backoff and a dead-letter queue.
|
|
154
|
+
Write the event with the record, deliver it after, in order per key with backoff and a dead-letter queue. Named value imports: DEFAULT_POLICY, EVENT_STATES, OutboxError, VERSION, backoffMs, createOutbox, memoryStore, outboxJob. Named type imports: DeliveryPolicy, DeliveryResult, DrainReport, EventState, Outbox, OutboxEvent, OutboxOptions, OutboxStore, PublishInput, Transport. Import only the names used by this file.
|
|
55
155
|
|
|
56
156
|
```text
|
|
57
|
-
import
|
|
157
|
+
import { DEFAULT_POLICY, EVENT_STATES, OutboxError, VERSION, backoffMs, createOutbox } from '@forgezero/runtime/outbox';
|
|
158
|
+
import { memoryStore, outboxJob } from '@forgezero/runtime/outbox';
|
|
159
|
+
import type { DeliveryPolicy, DeliveryResult, DrainReport, EventState, Outbox, OutboxEvent } from '@forgezero/runtime/outbox';
|
|
160
|
+
import type { OutboxOptions, OutboxStore, PublishInput, Transport } from '@forgezero/runtime/outbox';
|
|
58
161
|
```
|
|
59
162
|
|
|
163
|
+
<a id="forgezero-runtime-audit"></a>
|
|
60
164
|
## @forgezero/runtime/audit
|
|
61
165
|
|
|
62
|
-
Append-only records chained by hash, with a verifier that names the first altered entry.
|
|
166
|
+
Append-only records chained by hash, with a verifier that names the first altered entry. Named value imports: AuditChainError, GENESIS_DIGEST, VERSION, appendRecord, canonicalise, createAuditChain, exportRange, hashDigester, memoryStore, sealedDigester, verifyChain, verifyExport. Named type imports: AppendOptions, AuditChain, AuditChainOptions, AuditEntry, AuditExport, AuditRecord, AuditStore, ChainVerdict, Digester, EffectAuditRecord. Import only the names used by this file.
|
|
63
167
|
|
|
64
168
|
```text
|
|
65
|
-
import
|
|
169
|
+
import { AuditChainError, GENESIS_DIGEST, VERSION, appendRecord, canonicalise, createAuditChain } from '@forgezero/runtime/audit';
|
|
170
|
+
import { exportRange, hashDigester, memoryStore, sealedDigester, verifyChain, verifyExport } from '@forgezero/runtime/audit';
|
|
171
|
+
import type { AppendOptions, AuditChain, AuditChainOptions, AuditEntry, AuditExport, AuditRecord } from '@forgezero/runtime/audit';
|
|
172
|
+
import type { AuditStore, ChainVerdict, Digester, EffectAuditRecord } from '@forgezero/runtime/audit';
|
|
66
173
|
```
|
|
67
174
|
|
|
175
|
+
<a id="forgezero-runtime-backup"></a>
|
|
68
176
|
## @forgezero/runtime/backup
|
|
69
177
|
|
|
70
|
-
Encrypted, chunked, verified snapshots to object storage — and the restore that reads them back.
|
|
178
|
+
Encrypted, chunked, verified snapshots to object storage — and the restore that reads them back. Named value imports: BackupError, DEFAULT_RETENTION, SNAPSHOT_FORMAT, VERSION, backupJob, listSnapshots, prune, restore, selectForDeletion, snapshot, verifySnapshot. Named type imports: ChunkRecord, ObjectStore, RestoreOptions, RestoreReport, RetentionPolicy, RowSink, RowSource, SnapshotManifest, SnapshotOptions, VerifyReport. Import only the names used by this file.
|
|
71
179
|
|
|
72
180
|
```text
|
|
73
|
-
import
|
|
181
|
+
import { BackupError, DEFAULT_RETENTION, SNAPSHOT_FORMAT, VERSION, backupJob, listSnapshots } from '@forgezero/runtime/backup';
|
|
182
|
+
import { prune, restore, selectForDeletion, snapshot, verifySnapshot } from '@forgezero/runtime/backup';
|
|
183
|
+
import type { ChunkRecord, ObjectStore, RestoreOptions, RestoreReport, RetentionPolicy, RowSink } from '@forgezero/runtime/backup';
|
|
184
|
+
import type { RowSource, SnapshotManifest, SnapshotOptions, VerifyReport } from '@forgezero/runtime/backup';
|
|
74
185
|
```
|
|
75
186
|
|
|
187
|
+
<a id="forgezero-runtime-notify"></a>
|
|
76
188
|
## @forgezero/runtime/notify
|
|
77
189
|
|
|
78
|
-
Render a named template to text and HTML, escaped per part, refusing to send with a blank where a value should be.
|
|
190
|
+
Render a named template to text and HTML, escaped per part, refusing to send with a blank where a value should be. Named value imports: CHANNELS, NotifyError, VERSION, assertHeaderSafe, button, codeBlock, createNotifier, defineTemplate, escapeHtml, layout, preview, render. Named type imports: Channel, Notification, Notifier, NotifierOptions, Rendered, TemplateSpec, Transport. Import only the names used by this file.
|
|
79
191
|
|
|
80
192
|
```text
|
|
81
|
-
import
|
|
193
|
+
import { CHANNELS, NotifyError, VERSION, assertHeaderSafe, button, codeBlock } from '@forgezero/runtime/notify';
|
|
194
|
+
import { createNotifier, defineTemplate, escapeHtml, layout, preview, render } from '@forgezero/runtime/notify';
|
|
195
|
+
import type { Channel, Notification, Notifier, NotifierOptions, Rendered, TemplateSpec } from '@forgezero/runtime/notify';
|
|
196
|
+
import type { Transport } from '@forgezero/runtime/notify';
|
|
82
197
|
```
|
|
83
198
|
|
|
199
|
+
<a id="forgezero-runtime-notify-templates"></a>
|
|
84
200
|
## @forgezero/runtime/notify/templates
|
|
85
201
|
|
|
86
|
-
The six transactional messages ForgeZero sends.
|
|
202
|
+
The six transactional messages ForgeZero sends. Named value imports: TEMPLATES, ceremonyProposed, custodianEnrolment, escapeHtml, invitation, newDevice, signInCode, vaultLocked. Named type imports: TemplateKey. Import only the names used by this file.
|
|
87
203
|
|
|
88
204
|
```text
|
|
89
|
-
import
|
|
205
|
+
import { TEMPLATES, ceremonyProposed, custodianEnrolment, escapeHtml, invitation, newDevice } from '@forgezero/runtime/notify/templates';
|
|
206
|
+
import { signInCode, vaultLocked } from '@forgezero/runtime/notify/templates';
|
|
207
|
+
import type { TemplateKey } from '@forgezero/runtime/notify/templates';
|
|
90
208
|
```
|
|
91
209
|
|
|
210
|
+
<a id="forgezero-runtime-calendar"></a>
|
|
92
211
|
## @forgezero/runtime/calendar
|
|
93
212
|
|
|
94
|
-
Billing periods computed from an anchor, working days, holidays and due dates.
|
|
213
|
+
Billing periods computed from an anchor, working days, holidays and due dates. Named value imports: CalendarError, DAY_MS, DEFAULT_WORKING_DAYS, closedPeriods, dayOfWeek, daysOverdue, fromDay, isOverdue, isWorkingDay, nextWorkingDay, periodAt, periodIndexOn, periodOn, toDay, workingDaysBetween. Named type imports: BillingSchedule, Calendar, IsoDate, Period. Import only the names used by this file.
|
|
95
214
|
|
|
96
215
|
```text
|
|
97
|
-
import
|
|
216
|
+
import { CalendarError, DAY_MS, DEFAULT_WORKING_DAYS, closedPeriods, dayOfWeek, daysOverdue } from '@forgezero/runtime/calendar';
|
|
217
|
+
import { fromDay, isOverdue, isWorkingDay, nextWorkingDay, periodAt, periodIndexOn } from '@forgezero/runtime/calendar';
|
|
218
|
+
import { periodOn, toDay, workingDaysBetween } from '@forgezero/runtime/calendar';
|
|
219
|
+
import type { BillingSchedule, Calendar, IsoDate, Period } from '@forgezero/runtime/calendar';
|
|
98
220
|
```
|
|
99
221
|
|
|
222
|
+
<a id="forgezero-runtime-compliance"></a>
|
|
100
223
|
## @forgezero/runtime/compliance
|
|
101
224
|
|
|
102
|
-
Screening as a decision record — tiers, rules and lists, failing closed when a list is unreachable.
|
|
225
|
+
Screening as a decision record — tiers, rules and lists, failing closed when a list is unreachable. Named value imports: ComplianceError, RISK_LEVELS, VERIFICATION_TIERS, combineLists, countryRule, newCounterpartyRule, screen, screeningStage, staticList, tierLimitRule, unavailableList. Named type imports: ListEntry, RiskLevel, Rule, RuleHit, ScreenOptions, ScreeningList, StageOptions, Subject, Verdict, VerificationTier. Import only the names used by this file.
|
|
103
226
|
|
|
104
227
|
```text
|
|
105
|
-
import
|
|
228
|
+
import { ComplianceError, RISK_LEVELS, VERIFICATION_TIERS, combineLists, countryRule, newCounterpartyRule } from '@forgezero/runtime/compliance';
|
|
229
|
+
import { screen, screeningStage, staticList, tierLimitRule, unavailableList } from '@forgezero/runtime/compliance';
|
|
230
|
+
import type { ListEntry, RiskLevel, Rule, RuleHit, ScreenOptions, ScreeningList } from '@forgezero/runtime/compliance';
|
|
231
|
+
import type { StageOptions, Subject, Verdict, VerificationTier } from '@forgezero/runtime/compliance';
|
|
106
232
|
```
|
|
107
233
|
|
|
234
|
+
<a id="forgezero-runtime-totp"></a>
|
|
108
235
|
## @forgezero/runtime/totp
|
|
109
236
|
|
|
110
|
-
RFC 6238 TOTP on the existing HMAC — base32, an asymmetric window, and replay left to the caller.
|
|
237
|
+
RFC 6238 TOTP on the existing HMAC — base32, an asymmetric window, and replay left to the caller. Named value imports: DEFAULT_DIGITS, DEFAULT_STEP_SECONDS, TotpError, assertCode, codeAt, codeFor, counterAt, enrolmentUri, fromBase32, generateSecret, secondsRemaining, toBase32, verifyCode. Named type imports: TotpOptions, VerifyOptions, VerifyResult. Import only the names used by this file.
|
|
111
238
|
|
|
112
239
|
```text
|
|
113
|
-
import
|
|
240
|
+
import { DEFAULT_DIGITS, DEFAULT_STEP_SECONDS, TotpError, assertCode, codeAt, codeFor } from '@forgezero/runtime/totp';
|
|
241
|
+
import { counterAt, enrolmentUri, fromBase32, generateSecret, secondsRemaining, toBase32 } from '@forgezero/runtime/totp';
|
|
242
|
+
import { verifyCode } from '@forgezero/runtime/totp';
|
|
243
|
+
import type { TotpOptions, VerifyOptions, VerifyResult } from '@forgezero/runtime/totp';
|
|
114
244
|
```
|
|
115
245
|
|
|
246
|
+
<a id="forgezero-runtime-passkey"></a>
|
|
116
247
|
## @forgezero/runtime/passkey
|
|
117
248
|
|
|
118
|
-
Passkeys for sites that are not us. A vault-held credential is as unphishable as one in a security chip provided the RP ID check never slips — `evil-example.com` ends with `example.com` and is a different site.
|
|
249
|
+
Passkeys for sites that are not us. A vault-held credential is as unphishable as one in a security chip provided the RP ID check never slips — `evil-example.com` ends with `example.com` and is a different site. Named value imports: FLAG_BE, FLAG_BS, FLAG_UP, FLAG_UV, PasskeyError, assertPasskey, authenticatorData, credentialIdFor, passkeysFor, rpIdMatches, verifyAssertion. Named type imports: Assertion, AssertionRequest, StoredPasskey. Import only the names used by this file.
|
|
119
250
|
|
|
120
251
|
```text
|
|
121
|
-
import
|
|
252
|
+
import { FLAG_BE, FLAG_BS, FLAG_UP, FLAG_UV, PasskeyError, assertPasskey } from '@forgezero/runtime/passkey';
|
|
253
|
+
import { authenticatorData, credentialIdFor, passkeysFor, rpIdMatches, verifyAssertion } from '@forgezero/runtime/passkey';
|
|
254
|
+
import type { Assertion, AssertionRequest, StoredPasskey } from '@forgezero/runtime/passkey';
|
|
122
255
|
```
|
|
123
256
|
|
|
257
|
+
<a id="forgezero-runtime-phrase"></a>
|
|
124
258
|
## @forgezero/runtime/phrase
|
|
125
259
|
|
|
126
|
-
BIP-39 recovery phrases, and the salted verifier that proves one without being able to reconstruct it.
|
|
260
|
+
BIP-39 recovery phrases, and the salted verifier that proves one without being able to reconstruct it. Named value imports: PHRASE_SALT_BYTES, PHRASE_WORDS, generatePhrase, newSalt, phraseToKey, phraseVerifier, validatePhrase. Named type imports: none. Import only the names used by this file.
|
|
127
261
|
|
|
128
262
|
```text
|
|
129
|
-
import
|
|
263
|
+
import { PHRASE_SALT_BYTES, PHRASE_WORDS, generatePhrase, newSalt, phraseToKey, phraseVerifier } from '@forgezero/runtime/phrase';
|
|
264
|
+
import { validatePhrase } from '@forgezero/runtime/phrase';
|
|
130
265
|
```
|
|
131
266
|
|
|
267
|
+
<a id="forgezero-runtime-snp"></a>
|
|
132
268
|
## @forgezero/runtime/snp
|
|
133
269
|
|
|
134
|
-
Parse an AMD SEV-SNP attestation report at the firmware ABI offsets, and compare a TCB component by component so a microcode bump cannot mask a firmware downgrade.
|
|
270
|
+
Parse an AMD SEV-SNP attestation report at the firmware ABI offsets, and compare a TCB component by component so a microcode bump cannot mask a firmware downgrade. Named value imports: REPORT_BYTES, SnpError, bindsNonce, parseSnpReport, tcbAtLeast. Named type imports: GuestPolicy, SnpReport, TcbVersion. Import only the names used by this file.
|
|
135
271
|
|
|
136
272
|
```text
|
|
137
|
-
import
|
|
273
|
+
import { REPORT_BYTES, SnpError, bindsNonce, parseSnpReport, tcbAtLeast } from '@forgezero/runtime/snp';
|
|
274
|
+
import type { GuestPolicy, SnpReport, TcbVersion } from '@forgezero/runtime/snp';
|
|
138
275
|
```
|
|
139
276
|
|
|
277
|
+
<a id="forgezero-runtime-importers"></a>
|
|
140
278
|
## @forgezero/runtime/importers
|
|
141
279
|
|
|
142
|
-
Read secrets out of a .env, a CSV, or a Bitwarden or 1Password export — skipping what cannot be understood rather than guessing, and never putting a value in an error.
|
|
280
|
+
Read secrets out of a .env, a CSV, or a Bitwarden or 1Password export — skipping what cannot be understood rather than guessing, and never putting a value in an error. Named value imports: IMPORT_FORMATS, normaliseName, parseBitwarden, parseCsv, parseEnv, parseImport, parseOnePassword. Named type imports: ImportFormat, ImportResult, ImportedSecret, Skipped. Import only the names used by this file.
|
|
143
281
|
|
|
144
282
|
```text
|
|
145
|
-
import
|
|
283
|
+
import { IMPORT_FORMATS, normaliseName, parseBitwarden, parseCsv, parseEnv, parseImport } from '@forgezero/runtime/importers';
|
|
284
|
+
import { parseOnePassword } from '@forgezero/runtime/importers';
|
|
285
|
+
import type { ImportFormat, ImportResult, ImportedSecret, Skipped } from '@forgezero/runtime/importers';
|
|
146
286
|
```
|
|
147
287
|
|
|
288
|
+
<a id="forgezero-runtime-openssh"></a>
|
|
148
289
|
## @forgezero/runtime/openssh
|
|
149
290
|
|
|
150
|
-
OpenSSH wire encoding, so a derived ed25519 key becomes a line that pastes into authorized_keys.
|
|
291
|
+
OpenSSH wire encoding, so a derived ed25519 key becomes a line that pastes into authorized_keys. Named value imports: OpenSshError, authorizedKey, fingerprint, parseAuthorizedKey, publicKeyBlob, signatureBlob. Named type imports: none. Import only the names used by this file.
|
|
151
292
|
|
|
152
293
|
```text
|
|
153
|
-
import
|
|
294
|
+
import { OpenSshError, authorizedKey, fingerprint, parseAuthorizedKey, publicKeyBlob, signatureBlob } from '@forgezero/runtime/openssh';
|
|
154
295
|
```
|
|
155
296
|
|
|
297
|
+
<a id="forgezero-runtime-ssh-cert"></a>
|
|
156
298
|
## @forgezero/runtime/ssh-cert
|
|
157
299
|
|
|
158
|
-
OpenSSH certificates, so access expires instead of having to be hunted down. Takes a signing FUNCTION rather than a secret key, which is what lets the CA live in a vault that never hands it out.
|
|
300
|
+
OpenSSH certificates, so access expires instead of having to be hunted down. Takes a signing FUNCTION rather than a secret key, which is what lets the CA live in a vault that never hands it out. Named value imports: CERT_TYPE_HOST, CERT_TYPE_USER, DEFAULT_EXTENSIONS, SshCertError, caFingerprint, caFromSecretKey, caPublicKeyLine, isCurrentlyValid, signCertificate. Named type imports: CertificateAuthority, CertificateRequest. Import only the names used by this file.
|
|
159
301
|
|
|
160
302
|
```text
|
|
161
|
-
import
|
|
303
|
+
import { CERT_TYPE_HOST, CERT_TYPE_USER, DEFAULT_EXTENSIONS, SshCertError, caFingerprint, caFromSecretKey } from '@forgezero/runtime/ssh-cert';
|
|
304
|
+
import { caPublicKeyLine, isCurrentlyValid, signCertificate } from '@forgezero/runtime/ssh-cert';
|
|
305
|
+
import type { CertificateAuthority, CertificateRequest } from '@forgezero/runtime/ssh-cert';
|
|
162
306
|
```
|
|
163
307
|
|
|
308
|
+
<a id="forgezero-runtime-slip10"></a>
|
|
164
309
|
## @forgezero/runtime/slip10
|
|
165
310
|
|
|
166
|
-
SLIP-0010 derivation for ed25519, hardened-only — BIP-32 does not work on this curve and produces halves that do not correspond.
|
|
311
|
+
SLIP-0010 derivation for ed25519, hardened-only — BIP-32 does not work on this curve and produces halves that do not correspond. Named value imports: HARDENED_OFFSET, Slip10Error, deriveChild, derivePath, masterFromSeed. Named type imports: Slip10Node. Import only the names used by this file.
|
|
167
312
|
|
|
168
313
|
```text
|
|
169
|
-
import
|
|
314
|
+
import { HARDENED_OFFSET, Slip10Error, deriveChild, derivePath, masterFromSeed } from '@forgezero/runtime/slip10';
|
|
315
|
+
import type { Slip10Node } from '@forgezero/runtime/slip10';
|
|
170
316
|
```
|
|
171
317
|
|
|
318
|
+
<a id="forgezero-runtime-identity"></a>
|
|
172
319
|
## @forgezero/runtime/identity
|
|
173
320
|
|
|
174
|
-
Hybrid Ed25519 + ML-DSA-65 request signing. One canonical string, so the compute agent that signs inside a guest and the API that verifies cannot drift — which two implementations of it certainly would.
|
|
321
|
+
Hybrid Ed25519 + ML-DSA-65 request signing. One canonical string, so the compute agent that signs inside a guest and the API that verifies cannot drift — which two implementations of it certainly would. Named value imports: CLOCK_SKEW_SECONDS, REQUEST_SIGNATURE_SUITE, RESPONSE_KEY_HEADER, RESPONSE_SEALING_SUITE, canonicalString, decodeSignatureHeader, deriveKeysFromSeed, derivePublicKeysFromSeed, encodeSignatureHeader, generateNodeKeys, generateResponseRecipient, openResponse, sealResponse, signRequest, validResponsePublicKey, verifyRequest. Named type imports: NodeKeyPair, NodePublicKeys, ResponseRecipient, SealedResponse, SignedEnvelope, VerifyFailure. Import only the names used by this file.
|
|
175
322
|
|
|
176
323
|
```text
|
|
177
|
-
import
|
|
324
|
+
import { CLOCK_SKEW_SECONDS, REQUEST_SIGNATURE_SUITE, RESPONSE_KEY_HEADER, RESPONSE_SEALING_SUITE, canonicalString, decodeSignatureHeader } from '@forgezero/runtime/identity';
|
|
325
|
+
import { deriveKeysFromSeed, derivePublicKeysFromSeed, encodeSignatureHeader, generateNodeKeys, generateResponseRecipient, openResponse } from '@forgezero/runtime/identity';
|
|
326
|
+
import { sealResponse, signRequest, validResponsePublicKey, verifyRequest } from '@forgezero/runtime/identity';
|
|
327
|
+
import type { NodeKeyPair, NodePublicKeys, ResponseRecipient, SealedResponse, SignedEnvelope, VerifyFailure } from '@forgezero/runtime/identity';
|
|
178
328
|
```
|
|
179
329
|
|
|
330
|
+
<a id="forgezero-runtime-schema"></a>
|
|
180
331
|
## @forgezero/runtime/schema
|
|
181
332
|
|
|
182
|
-
Validate against JSON Schema, restrict what a caller may declare, and describe a schema as a form.
|
|
333
|
+
Validate against JSON Schema, restrict what a caller may declare, and describe a schema as a form. Named value imports: DEFAULT_RESTRICTIONS, SCHEMA_VERSION, SchemaError, VERSION, describeJsonSchema, readableFields, restrictJsonSchema, writeOnlyPaths. Named type imports: FieldKind, FormField, Restrictions, SchemaValidator, ValidationResult. Import only the names used by this file.
|
|
183
334
|
|
|
184
335
|
```text
|
|
185
|
-
import
|
|
336
|
+
import { DEFAULT_RESTRICTIONS, SCHEMA_VERSION, SchemaError, VERSION, describeJsonSchema, readableFields } from '@forgezero/runtime/schema';
|
|
337
|
+
import { restrictJsonSchema, writeOnlyPaths } from '@forgezero/runtime/schema';
|
|
338
|
+
import type { FieldKind, FormField, Restrictions, SchemaValidator, ValidationResult } from '@forgezero/runtime/schema';
|
|
186
339
|
```
|
|
187
340
|
|
|
341
|
+
## @forgezero/runtime/schema — Restrict an untrusted JSON Schema before storing it
|
|
342
|
+
|
|
343
|
+
Tenant-supplied schemas are data, not executable code. Restriction rejects references, remote identifiers, unsupported keywords, excessive depth/size, and arrays without a bounded maxItems. Form metadata is derived from the accepted schema; write-only fields remain identifiable for secret handling.
|
|
344
|
+
|
|
345
|
+
```text
|
|
346
|
+
import { restrictJsonSchema, describeJsonSchema, writeOnlyPaths } from '@forgezero/runtime/schema';
|
|
347
|
+
|
|
348
|
+
const schema = restrictJsonSchema({
|
|
349
|
+
type: 'object', additionalProperties: false,
|
|
350
|
+
properties: {
|
|
351
|
+
recipients: { type: 'array', maxItems: 100, items: { type: 'string' } },
|
|
352
|
+
apiKey: { type: 'string', title: 'API key', writeOnly: true }
|
|
353
|
+
},
|
|
354
|
+
required: ['apiKey']
|
|
355
|
+
});
|
|
356
|
+
const fields = describeJsonSchema(schema);
|
|
357
|
+
const secretFields = writeOnlyPaths(fields);
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
<a id="forgezero-runtime-schema-typebox"></a>
|
|
188
361
|
## @forgezero/runtime/schema/typebox
|
|
189
362
|
|
|
190
|
-
The TypeBox validator behind that interface.
|
|
363
|
+
The TypeBox validator behind that interface. Named value imports: T, parse, typebox, typeboxQueryCodec. Named type imports: Static, TSchema. Import only the names used by this file.
|
|
364
|
+
|
|
365
|
+
```text
|
|
366
|
+
import { T, parse, typebox, typeboxQueryCodec } from '@forgezero/runtime/schema/typebox';
|
|
367
|
+
import type { Static, TSchema } from '@forgezero/runtime/schema/typebox';
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## @forgezero/runtime/schema/typebox — One TypeBox shape for runtime validation and static types
|
|
371
|
+
|
|
372
|
+
TypeBox is an optional peer. Its schema is JSON Schema, so the same restriction and form layer applies. The query codec validates both untrusted input and returned output; malformed values fail instead of being coerced.
|
|
191
373
|
|
|
192
374
|
```text
|
|
193
|
-
import
|
|
375
|
+
import { T, type Static, parse, typeboxQueryCodec } from '@forgezero/runtime/schema/typebox';
|
|
376
|
+
|
|
377
|
+
const User = T.Object({
|
|
378
|
+
userKey: T.String({ minLength: 1 }),
|
|
379
|
+
roles: T.Array(T.String(), { maxItems: 32 })
|
|
380
|
+
}, { additionalProperties: false });
|
|
381
|
+
type User = Static<typeof User>;
|
|
382
|
+
const user: User = parse(User, unknownInput);
|
|
383
|
+
const codec = typeboxQueryCodec(User);
|
|
194
384
|
```
|
|
195
385
|
|
|
386
|
+
<a id="forgezero-runtime-finance-discounts"></a>
|
|
196
387
|
## @forgezero/runtime/finance/discounts
|
|
197
388
|
|
|
198
|
-
Promotions as arithmetic over integer minor units. They never stack — one winner — and a percentage rounds down, because rounding a discount up gives away a unit of currency per invoice forever.
|
|
389
|
+
Promotions as arithmetic over integer minor units. They never stack — one winner — and a percentage rounds down, because rounding a discount up gives away a unit of currency per invoice forever. Named value imports: DiscountError, assertCode, assertWindow, bestDiscount, discountFor, ineligibility, normaliseCode. Named type imports: AppliedDiscount, DiscountKind, Ineligibility, Promotion. Import only the names used by this file.
|
|
199
390
|
|
|
200
391
|
```text
|
|
201
|
-
import
|
|
392
|
+
import { DiscountError, assertCode, assertWindow, bestDiscount, discountFor, ineligibility } from '@forgezero/runtime/finance/discounts';
|
|
393
|
+
import { normaliseCode } from '@forgezero/runtime/finance/discounts';
|
|
394
|
+
import type { AppliedDiscount, DiscountKind, Ineligibility, Promotion } from '@forgezero/runtime/finance/discounts';
|
|
202
395
|
```
|
|
203
396
|
|
|
397
|
+
<a id="forgezero-runtime-finance-money"></a>
|
|
204
398
|
## @forgezero/runtime/finance/money
|
|
205
399
|
|
|
206
|
-
Exact amounts in minor units with the asset attached, so two currencies cannot be added.
|
|
400
|
+
Exact amounts in minor units with the asset attached, so two currencies cannot be added. Named value imports: ASSETS, MoneyError, ROUNDING, VERSION, abs, add, allocate, assetSpec, compare, convert, defineAsset, equals, formatAmount, isNegative, isZero, money, mulRate, negate, parseAmount, subtract, toStep, zero. Named type imports: AssetSpec, Money, Rounding. Import only the names used by this file.
|
|
207
401
|
|
|
208
402
|
```text
|
|
209
|
-
import
|
|
403
|
+
import { ASSETS, MoneyError, ROUNDING, VERSION, abs, add } from '@forgezero/runtime/finance/money';
|
|
404
|
+
import { allocate, assetSpec, compare, convert, defineAsset, equals } from '@forgezero/runtime/finance/money';
|
|
405
|
+
import { formatAmount, isNegative, isZero, money, mulRate, negate } from '@forgezero/runtime/finance/money';
|
|
406
|
+
import { parseAmount, subtract, toStep, zero } from '@forgezero/runtime/finance/money';
|
|
407
|
+
import type { AssetSpec, Money, Rounding } from '@forgezero/runtime/finance/money';
|
|
210
408
|
```
|
|
211
409
|
|
|
410
|
+
<a id="forgezero-runtime-finance-venues"></a>
|
|
212
411
|
## @forgezero/runtime/finance/venues
|
|
213
412
|
|
|
214
|
-
Trading venues, market types and symbols as data — spot, margin and futures behind one order model.
|
|
413
|
+
Trading venues, market types and symbols as data — spot, margin and futures behind one order model. Named value imports: MARKET_TYPES, ORDER_SIDES, ORDER_TYPES, TIME_IN_FORCE, VENUES, VERSION, VenueError, notionalOf, parseSymbol, submitOrder, symbolOf, validateOrder, venue, venuesFor. Named type imports: MarketSpec, MarketType, OrderRequest, OrderResult, OrderSide, OrderStatus, OrderType, TimeInForce, VenueAdapter, VenueSpec. Import only the names used by this file.
|
|
215
414
|
|
|
216
415
|
```text
|
|
217
|
-
import
|
|
416
|
+
import { MARKET_TYPES, ORDER_SIDES, ORDER_TYPES, TIME_IN_FORCE, VENUES, VERSION } from '@forgezero/runtime/finance/venues';
|
|
417
|
+
import { VenueError, notionalOf, parseSymbol, submitOrder, symbolOf, validateOrder } from '@forgezero/runtime/finance/venues';
|
|
418
|
+
import { venue, venuesFor } from '@forgezero/runtime/finance/venues';
|
|
419
|
+
import type { MarketSpec, MarketType, OrderRequest, OrderResult, OrderSide, OrderStatus } from '@forgezero/runtime/finance/venues';
|
|
420
|
+
import type { OrderType, TimeInForce, VenueAdapter, VenueSpec } from '@forgezero/runtime/finance/venues';
|
|
218
421
|
```
|
|
219
422
|
|
|
423
|
+
<a id="forgezero-runtime-finance-ledger"></a>
|
|
220
424
|
## @forgezero/runtime/finance/ledger
|
|
221
425
|
|
|
222
|
-
Double-entry postings and derived balances. A hold is a posting, not a lock — the queue does the ordering.
|
|
426
|
+
Double-entry postings and derived balances. A hold is a posting, not a lock — the queue does the ordering. Named value imports: ACCOUNT_KINDS, BUCKETS, LedgerError, MAX_LEDGER_ENTRIES, VERSION, accountId, assertAvailable, assertBalanced, availableOf, balanceOf, balancesFrom, captureHold, heldOf, parseAccount, placeHold, queueKeyFor, releaseHold, statement, totalOf, transfer, trialBalance. Named type imports: AccountKind, AccountRef, Bucket, Entry, Transaction, TrialBalance. Import only the names used by this file.
|
|
223
427
|
|
|
224
428
|
```text
|
|
225
|
-
import
|
|
429
|
+
import { ACCOUNT_KINDS, BUCKETS, LedgerError, MAX_LEDGER_ENTRIES, VERSION, accountId } from '@forgezero/runtime/finance/ledger';
|
|
430
|
+
import { assertAvailable, assertBalanced, availableOf, balanceOf, balancesFrom, captureHold } from '@forgezero/runtime/finance/ledger';
|
|
431
|
+
import { heldOf, parseAccount, placeHold, queueKeyFor, releaseHold, statement } from '@forgezero/runtime/finance/ledger';
|
|
432
|
+
import { totalOf, transfer, trialBalance } from '@forgezero/runtime/finance/ledger';
|
|
433
|
+
import type { AccountKind, AccountRef, Bucket, Entry, Transaction, TrialBalance } from '@forgezero/runtime/finance/ledger';
|
|
226
434
|
```
|
|
227
435
|
|
|
436
|
+
<a id="forgezero-runtime-finance-commission"></a>
|
|
228
437
|
## @forgezero/runtime/finance/commission
|
|
229
438
|
|
|
230
|
-
Profit net of flows, a high-water mark, the tier split and the referral share of our income.
|
|
439
|
+
Profit net of flows, a high-water mark, the tier split and the referral share of our income. Named value imports: CommissionError, allocate, chargeableProfit, commissionTransaction, nextHighWaterMark, periodProfit, projectPrepay, splitCommission, splitReferrals. Named type imports: CommissionInput, CommissionSplit, PeriodPerformance, Prepay, PrepayInput, ReferralShare. Import only the names used by this file.
|
|
231
440
|
|
|
232
441
|
```text
|
|
233
|
-
import
|
|
442
|
+
import { CommissionError, allocate, chargeableProfit, commissionTransaction, nextHighWaterMark, periodProfit } from '@forgezero/runtime/finance/commission';
|
|
443
|
+
import { projectPrepay, splitCommission, splitReferrals } from '@forgezero/runtime/finance/commission';
|
|
444
|
+
import type { CommissionInput, CommissionSplit, PeriodPerformance, Prepay, PrepayInput, ReferralShare } from '@forgezero/runtime/finance/commission';
|
|
234
445
|
```
|
|
235
446
|
|
|
447
|
+
<a id="forgezero-runtime-finance-rates"></a>
|
|
236
448
|
## @forgezero/runtime/finance/rates
|
|
237
449
|
|
|
238
|
-
What an asset is worth in USD, and how old that answer is. A peg never ages; a quote always does.
|
|
450
|
+
What an asset is worth in USD, and how old that answer is. A peg never ages; a quote always does. Named value imports: BASE_ASSET, RATE_SOURCES, RateError, assertRate, createRateTable, describeRate, isRegistered, peg, rateRefreshJob, refreshRates, registerAsset. Named type imports: AssetEntry, AssetRate, RateFetcher, RateSource, RateTable, RateTableOptions, RefreshReport. Import only the names used by this file.
|
|
239
451
|
|
|
240
452
|
```text
|
|
241
|
-
import
|
|
453
|
+
import { BASE_ASSET, RATE_SOURCES, RateError, assertRate, createRateTable, describeRate } from '@forgezero/runtime/finance/rates';
|
|
454
|
+
import { isRegistered, peg, rateRefreshJob, refreshRates, registerAsset } from '@forgezero/runtime/finance/rates';
|
|
455
|
+
import type { AssetEntry, AssetRate, RateFetcher, RateSource, RateTable, RateTableOptions } from '@forgezero/runtime/finance/rates';
|
|
456
|
+
import type { RefreshReport } from '@forgezero/runtime/finance/rates';
|
|
242
457
|
```
|
|
243
458
|
|
|
459
|
+
<a id="forgezero-runtime-finance-transfers"></a>
|
|
244
460
|
## @forgezero/runtime/finance/transfers
|
|
245
461
|
|
|
246
|
-
Deposits and withdrawals as ordered pipelines, with screening reserved at position zero.
|
|
462
|
+
Deposits and withdrawals as ordered pipelines, with screening reserved at position zero. Named value imports: DIRECTIONS, PipelineError, SCREENING_ORDER, approvalStage, balanceStage, createTransferPipeline, limitsStage, notFrozenStage, screeningStage. Named type imports: Direction, PipelineResult, Stage, StageOutcome, Transfer, TransferPipeline. Import only the names used by this file.
|
|
247
463
|
|
|
248
464
|
```text
|
|
249
|
-
import
|
|
465
|
+
import { DIRECTIONS, PipelineError, SCREENING_ORDER, approvalStage, balanceStage, createTransferPipeline } from '@forgezero/runtime/finance/transfers';
|
|
466
|
+
import { limitsStage, notFrozenStage, screeningStage } from '@forgezero/runtime/finance/transfers';
|
|
467
|
+
import type { Direction, PipelineResult, Stage, StageOutcome, Transfer, TransferPipeline } from '@forgezero/runtime/finance/transfers';
|
|
250
468
|
```
|
|
251
469
|
|
|
470
|
+
<a id="forgezero-runtime-finance-chain"></a>
|
|
252
471
|
## @forgezero/runtime/finance/chain
|
|
253
472
|
|
|
254
|
-
Which chains exist, their confirmation depth by value band, assets and explorers — as data an admin edits.
|
|
473
|
+
Which chains exist, their confirmation depth by value band, assets and explorers — as data an admin edits. Named value imports: ADDRESS_SCHEMES, ChainError, SEED_CHAINS, SEED_CHAIN_ASSETS, assertChain, confirmationsFor, createChainRegistry, estimatedSeconds, validateAddress. Named type imports: AddressScheme, ChainAsset, ChainRegistry, ChainSpec, ConfirmationBand. Import only the names used by this file.
|
|
255
474
|
|
|
256
475
|
```text
|
|
257
|
-
import
|
|
476
|
+
import { ADDRESS_SCHEMES, ChainError, SEED_CHAINS, SEED_CHAIN_ASSETS, assertChain, confirmationsFor } from '@forgezero/runtime/finance/chain';
|
|
477
|
+
import { createChainRegistry, estimatedSeconds, validateAddress } from '@forgezero/runtime/finance/chain';
|
|
478
|
+
import type { AddressScheme, ChainAsset, ChainRegistry, ChainSpec, ConfirmationBand } from '@forgezero/runtime/finance/chain';
|
|
258
479
|
```
|
|
259
480
|
|
|
481
|
+
<a id="forgezero-runtime-finance-custody"></a>
|
|
260
482
|
## @forgezero/runtime/finance/custody
|
|
261
483
|
|
|
262
|
-
Derive CREATE2 deposit addresses and EIP-712 custody digests — arithmetic over a seed and a salt, needing no credential and no node.
|
|
484
|
+
Derive CREATE2 deposit addresses and EIP-712 custody digests — arithmetic over a seed and a salt, needing no credential and no node. Named value imports: CustodyError, VERSION, depositAddress, domainSeparator, orderSignatures, saltFor, toChecksumAddress, withdrawDigest. Named type imports: none. Import only the names used by this file.
|
|
263
485
|
|
|
264
486
|
```text
|
|
265
|
-
import
|
|
487
|
+
import { CustodyError, VERSION, depositAddress, domainSeparator, orderSignatures, saltFor } from '@forgezero/runtime/finance/custody';
|
|
488
|
+
import { toChecksumAddress, withdrawDigest } from '@forgezero/runtime/finance/custody';
|
|
266
489
|
```
|
|
267
490
|
|
|
491
|
+
<a id="forgezero-runtime-finance-derive"></a>
|
|
268
492
|
## @forgezero/runtime/finance/derive
|
|
269
493
|
|
|
270
|
-
Declare a field ForgeZero generates rather than the tenant supplying: BIP-44 path arithmetic, and the choice of who is capable of generating the key.
|
|
494
|
+
Declare a field ForgeZero generates rather than the tenant supplying: BIP-44 path arithmetic, and the choice of who is capable of generating the key. Named value imports: CUSTODY, DERIVE_KEYWORD, DeriveError, SCHEMES, assertDeriveSpec, custodyOf, deriveSpecOf, derivedFields, derivedPaths, pathFor, suppliedPaths. Named type imports: Custody, DeriveSpec, DerivedField, Scheme. Import only the names used by this file.
|
|
271
495
|
|
|
272
496
|
```text
|
|
273
|
-
import
|
|
497
|
+
import { CUSTODY, DERIVE_KEYWORD, DeriveError, SCHEMES, assertDeriveSpec, custodyOf } from '@forgezero/runtime/finance/derive';
|
|
498
|
+
import { deriveSpecOf, derivedFields, derivedPaths, pathFor, suppliedPaths } from '@forgezero/runtime/finance/derive';
|
|
499
|
+
import type { Custody, DeriveSpec, DerivedField, Scheme } from '@forgezero/runtime/finance/derive';
|
|
274
500
|
```
|
|
275
501
|
|
|
502
|
+
<a id="forgezero-runtime-finance-tax"></a>
|
|
276
503
|
## @forgezero/runtime/finance/tax
|
|
277
504
|
|
|
278
|
-
Which jurisdiction may tax a sale, who accounts for it, and the three ways to be zero that report differently. Rates are data.
|
|
505
|
+
Which jurisdiction may tax a sale, who accounts for it, and the three ways to be zero that report differently. Rates are data. Named value imports: TREATMENTS, TaxError, applyTax, assertTaxRate, decideTax, describeTax, parseRate, percent, totalWithTax. Named type imports: Customer, Supplier, TaxAmounts, TaxDecision, TaxRate, Treatment. Import only the names used by this file.
|
|
279
506
|
|
|
280
507
|
```text
|
|
281
|
-
import
|
|
508
|
+
import { TREATMENTS, TaxError, applyTax, assertTaxRate, decideTax, describeTax } from '@forgezero/runtime/finance/tax';
|
|
509
|
+
import { parseRate, percent, totalWithTax } from '@forgezero/runtime/finance/tax';
|
|
510
|
+
import type { Customer, Supplier, TaxAmounts, TaxDecision, TaxRate, Treatment } from '@forgezero/runtime/finance/tax';
|
|
282
511
|
```
|
|
283
512
|
|
|
513
|
+
<a id="forgezero-runtime-finance-storage"></a>
|
|
284
514
|
## @forgezero/runtime/finance/storage
|
|
285
515
|
|
|
286
|
-
Write an amount so it is both exact and sortable: an authoritative string, and a number that is only an index.
|
|
516
|
+
Write an amount so it is both exact and sortable: an authoritative string, and a number that is only an index. Named value imports: SORT_FIELD, fromStored, rangeBounds, sortExact, sortKey, storeAmount, toStored, withinRange. Named type imports: StoredMoney. Import only the names used by this file.
|
|
287
517
|
|
|
288
518
|
```text
|
|
289
|
-
import
|
|
519
|
+
import { SORT_FIELD, fromStored, rangeBounds, sortExact, sortKey, storeAmount } from '@forgezero/runtime/finance/storage';
|
|
520
|
+
import { toStored, withinRange } from '@forgezero/runtime/finance/storage';
|
|
521
|
+
import type { StoredMoney } from '@forgezero/runtime/finance/storage';
|
|
290
522
|
```
|
|
291
523
|
|
|
524
|
+
<a id="forgezero-runtime-realtime"></a>
|
|
292
525
|
## @forgezero/runtime/realtime
|
|
293
526
|
|
|
294
|
-
Provider-neutral realtime audience, shard, event and delivery contracts.
|
|
527
|
+
Provider-neutral realtime audience, shard, event and delivery contracts. Named value imports: REALTIME_MAX_BATCH_BYTES, REALTIME_MAX_EVENTS, REALTIME_MAX_EVENT_BYTES, REALTIME_MAX_SHARDS_PER_TOPIC, REALTIME_MAX_SOCKETS_PER_SHARD, canReceiveRealtimeAudience, issueRealtimeSubscriptionTicket, realtimeBatchBytes, realtimeHmac, realtimeShardKey, validateRealtimeAudience, validateRealtimeBatch, validateRealtimeSubscriptionTicket, verifyRealtimeHmac, verifyRealtimeSubscriptionToken. Named type imports: RealtimeAudience, RealtimeBatch, RealtimeEvent, RealtimePrincipalKind, RealtimeSubscriptionTicket. Import only the names used by this file.
|
|
295
528
|
|
|
296
529
|
```text
|
|
297
|
-
import
|
|
530
|
+
import { REALTIME_MAX_BATCH_BYTES, REALTIME_MAX_EVENTS, REALTIME_MAX_EVENT_BYTES, REALTIME_MAX_SHARDS_PER_TOPIC, REALTIME_MAX_SOCKETS_PER_SHARD, canReceiveRealtimeAudience } from '@forgezero/runtime/realtime';
|
|
531
|
+
import { issueRealtimeSubscriptionTicket, realtimeBatchBytes, realtimeHmac, realtimeShardKey, validateRealtimeAudience, validateRealtimeBatch } from '@forgezero/runtime/realtime';
|
|
532
|
+
import { validateRealtimeSubscriptionTicket, verifyRealtimeHmac, verifyRealtimeSubscriptionToken } from '@forgezero/runtime/realtime';
|
|
533
|
+
import type { RealtimeAudience, RealtimeBatch, RealtimeEvent, RealtimePrincipalKind, RealtimeSubscriptionTicket } from '@forgezero/runtime/realtime';
|
|
298
534
|
```
|
|
299
535
|
|
|
536
|
+
<a id="forgezero-runtime-passkey-hybrid"></a>
|
|
300
537
|
## @forgezero/runtime/passkey-hybrid
|
|
301
538
|
|
|
302
|
-
Versioned WebAuthn PRF plus ML-DSA companion proof construction and verification.
|
|
539
|
+
Versioned WebAuthn PRF plus ML-DSA companion proof construction and verification. Named value imports: PASSKEY_HYBRID_SUITE, PASSKEY_HYBRID_VERSION, PASSKEY_ML_DSA_PUBLIC_KEY_BYTES, PASSKEY_ML_DSA_SIGNATURE_BYTES, PASSKEY_PRF_SALT, createPasskeyHybridProof, passkeyHybridMessage, verifyPasskeyHybridProof. Named type imports: PasskeyHybridBinding, PasskeyHybridProof, PasskeyHybridPurpose, PasskeyHybridRegistrationProof. Import only the names used by this file.
|
|
303
540
|
|
|
304
541
|
```text
|
|
305
|
-
import
|
|
542
|
+
import { PASSKEY_HYBRID_SUITE, PASSKEY_HYBRID_VERSION, PASSKEY_ML_DSA_PUBLIC_KEY_BYTES, PASSKEY_ML_DSA_SIGNATURE_BYTES, PASSKEY_PRF_SALT, createPasskeyHybridProof } from '@forgezero/runtime/passkey-hybrid';
|
|
543
|
+
import { passkeyHybridMessage, verifyPasskeyHybridProof } from '@forgezero/runtime/passkey-hybrid';
|
|
544
|
+
import type { PasskeyHybridBinding, PasskeyHybridProof, PasskeyHybridPurpose, PasskeyHybridRegistrationProof } from '@forgezero/runtime/passkey-hybrid';
|
|
306
545
|
```
|
|
307
546
|
|
|
547
|
+
<a id="forgezero-runtime-otpauth"></a>
|
|
308
548
|
## @forgezero/runtime/otpauth
|
|
309
549
|
|
|
310
|
-
Parse and render otpauth URIs without binding enrolment to a UI framework.
|
|
550
|
+
Parse and render otpauth URIs without binding enrolment to a UI framework. Named value imports: formatOtpAuth, fromManualSecret, newOtpAuth, parseOtpAuth. Named type imports: OtpAuth. Import only the names used by this file.
|
|
311
551
|
|
|
312
552
|
```text
|
|
313
|
-
import
|
|
553
|
+
import { formatOtpAuth, fromManualSecret, newOtpAuth, parseOtpAuth } from '@forgezero/runtime/otpauth';
|
|
554
|
+
import type { OtpAuth } from '@forgezero/runtime/otpauth';
|
|
314
555
|
```
|
|
315
556
|
|
|
557
|
+
<a id="forgezero-runtime-pipeline"></a>
|
|
316
558
|
## @forgezero/runtime/pipeline
|
|
317
559
|
|
|
318
|
-
Typed ordered application-pipeline execution with explicit evidence.
|
|
560
|
+
Typed ordered application-pipeline execution with explicit evidence. Named value imports: GIT_PROVIDERS, PipelineError, parsePush, shouldDeploy, verifyWebhook, webhookPath. Named type imports: DeployTrigger, GitProvider, PushEvent. Import only the names used by this file.
|
|
319
561
|
|
|
320
562
|
```text
|
|
321
|
-
import
|
|
563
|
+
import { GIT_PROVIDERS, PipelineError, parsePush, shouldDeploy, verifyWebhook, webhookPath } from '@forgezero/runtime/pipeline';
|
|
564
|
+
import type { DeployTrigger, GitProvider, PushEvent } from '@forgezero/runtime/pipeline';
|
|
322
565
|
```
|
|
323
566
|
|
|
567
|
+
<a id="forgezero-runtime-finance-chain-addresses"></a>
|
|
324
568
|
## @forgezero/runtime/finance/chain-addresses
|
|
325
569
|
|
|
326
|
-
Chain-address derivation records and validation independent of a node provider.
|
|
570
|
+
Chain-address derivation records and validation independent of a node provider. Named value imports: AddressError, COUNTERFACTUAL_SCHEMES, assertDerivationMatches, create2Address, depositAddressBook, depositSaltFor, deriveDepositAddress, ownerOfAddress, toChecksumAddress, validateAddress. Named type imports: AddressScheme, ChainDeployment. Import only the names used by this file.
|
|
327
571
|
|
|
328
572
|
```text
|
|
329
|
-
import
|
|
573
|
+
import { AddressError, COUNTERFACTUAL_SCHEMES, assertDerivationMatches, create2Address, depositAddressBook, depositSaltFor } from '@forgezero/runtime/finance/chain-addresses';
|
|
574
|
+
import { deriveDepositAddress, ownerOfAddress, toChecksumAddress, validateAddress } from '@forgezero/runtime/finance/chain-addresses';
|
|
575
|
+
import type { AddressScheme, ChainDeployment } from '@forgezero/runtime/finance/chain-addresses';
|
|
330
576
|
```
|
|
331
577
|
|
|
578
|
+
<a id="forgezero-runtime-finance-chain-deposits"></a>
|
|
332
579
|
## @forgezero/runtime/finance/chain-deposits
|
|
333
580
|
|
|
334
|
-
Provider-neutral deposit observation, confirmation and credit transitions.
|
|
581
|
+
Provider-neutral deposit observation, confirmation and credit transitions. Named value imports: DepositError, creditDeposit, cursorFrom, depositReference, describeScan, isConfirmed, rescanRange, scanOnce. Named type imports: ChainReader, ChainTransfer, DepositCursor, ScanContext, ScanReport. Import only the names used by this file.
|
|
335
582
|
|
|
336
583
|
```text
|
|
337
|
-
import
|
|
584
|
+
import { DepositError, creditDeposit, cursorFrom, depositReference, describeScan, isConfirmed } from '@forgezero/runtime/finance/chain-deposits';
|
|
585
|
+
import { rescanRange, scanOnce } from '@forgezero/runtime/finance/chain-deposits';
|
|
586
|
+
import type { ChainReader, ChainTransfer, DepositCursor, ScanContext, ScanReport } from '@forgezero/runtime/finance/chain-deposits';
|
|
338
587
|
```
|
|
339
588
|
|
|
589
|
+
<a id="forgezero-runtime-finance-chain-withdrawals"></a>
|
|
340
590
|
## @forgezero/runtime/finance/chain-withdrawals
|
|
341
591
|
|
|
342
|
-
Provider-neutral withdrawal approval, broadcast and finality transitions.
|
|
592
|
+
Provider-neutral withdrawal approval, broadcast and finality transitions. Named value imports: WITHDRAWAL_STATES, WithdrawalError, approveWithdrawal, broadcastKeyFor, canTransition, confirmWithdrawal, describeSweep, holdReference, markFailed, processOnce, refundFailed, rejectWithdrawal, requestWithdrawal, sweepForPayout. Named type imports: Broadcaster, SweepCandidate, SweepPlan, Withdrawal, WithdrawalState. Import only the names used by this file.
|
|
343
593
|
|
|
344
594
|
```text
|
|
345
|
-
import
|
|
595
|
+
import { WITHDRAWAL_STATES, WithdrawalError, approveWithdrawal, broadcastKeyFor, canTransition, confirmWithdrawal } from '@forgezero/runtime/finance/chain-withdrawals';
|
|
596
|
+
import { describeSweep, holdReference, markFailed, processOnce, refundFailed, rejectWithdrawal } from '@forgezero/runtime/finance/chain-withdrawals';
|
|
597
|
+
import { requestWithdrawal, sweepForPayout } from '@forgezero/runtime/finance/chain-withdrawals';
|
|
598
|
+
import type { Broadcaster, SweepCandidate, SweepPlan, Withdrawal, WithdrawalState } from '@forgezero/runtime/finance/chain-withdrawals';
|
|
346
599
|
```
|
|
347
600
|
|
|
601
|
+
<a id="forgezero-runtime-finance-chain-reconcile"></a>
|
|
348
602
|
## @forgezero/runtime/finance/chain-reconcile
|
|
349
603
|
|
|
350
|
-
Deterministic reconciliation between chain observations and durable transfer state.
|
|
604
|
+
Deterministic reconciliation between chain observations and durable transfer state. Named value imports: DISCREPANCY_KINDS, ReconcileError, reconcileOnce, reconcileReport, shortfallUsd. Named type imports: Discrepancy, DiscrepancyKind, LedgerLiability, OnChainHolding, ReconcileReport. Import only the names used by this file.
|
|
351
605
|
|
|
352
606
|
```text
|
|
353
|
-
import
|
|
607
|
+
import { DISCREPANCY_KINDS, ReconcileError, reconcileOnce, reconcileReport, shortfallUsd } from '@forgezero/runtime/finance/chain-reconcile';
|
|
608
|
+
import type { Discrepancy, DiscrepancyKind, LedgerLiability, OnChainHolding, ReconcileReport } from '@forgezero/runtime/finance/chain-reconcile';
|
|
354
609
|
```
|
|
355
610
|
|
|
611
|
+
<a id="forgezero-runtime-finance-market"></a>
|
|
356
612
|
## @forgezero/runtime/finance/market
|
|
357
613
|
|
|
358
|
-
Market order, fill and quote contracts independent of any exchange adapter.
|
|
614
|
+
Market order, fill and quote contracts independent of any exchange adapter. Named value imports: MarketError, createFeed, disagreementOf, isStale, lastPrice, limitFor, stalenessOf, subscribe. Named type imports: Feed, FeedEvent, FeedOptions, PriceResult, Quote, StalenessPolicy, VenueSource. Import only the names used by this file.
|
|
359
615
|
|
|
360
616
|
```text
|
|
361
|
-
import
|
|
617
|
+
import { MarketError, createFeed, disagreementOf, isStale, lastPrice, limitFor } from '@forgezero/runtime/finance/market';
|
|
618
|
+
import { stalenessOf, subscribe } from '@forgezero/runtime/finance/market';
|
|
619
|
+
import type { Feed, FeedEvent, FeedOptions, PriceResult, Quote, StalenessPolicy } from '@forgezero/runtime/finance/market';
|
|
620
|
+
import type { VenueSource } from '@forgezero/runtime/finance/market';
|
|
362
621
|
```
|
|
363
622
|
|
|
623
|
+
<a id="forgezero-runtime-custody-share"></a>
|
|
364
624
|
## @forgezero/runtime/custody-share
|
|
365
625
|
|
|
366
|
-
Threshold-share parsing, validation and reconstruction.
|
|
626
|
+
Threshold-share parsing, validation and reconstruction. Named value imports: PROBE_BYTES, factorWrapAad, joinProbeAndShare, openFactorEnvelope, openSealedToFactor, openShareWithPasskey, openShareWithPhrase, passkeyWrappingKey, phraseWrappingKey, sealShare, shareIndexOf, splitProbeAndShare, wrappingKeysFor. Named type imports: SealedShare, WrappingKeys. Import only the names used by this file.
|
|
367
627
|
|
|
368
628
|
```text
|
|
369
|
-
import
|
|
629
|
+
import { PROBE_BYTES, factorWrapAad, joinProbeAndShare, openFactorEnvelope, openSealedToFactor, openShareWithPasskey } from '@forgezero/runtime/custody-share';
|
|
630
|
+
import { openShareWithPhrase, passkeyWrappingKey, phraseWrappingKey, sealShare, shareIndexOf, splitProbeAndShare } from '@forgezero/runtime/custody-share';
|
|
631
|
+
import { wrappingKeysFor } from '@forgezero/runtime/custody-share';
|
|
632
|
+
import type { SealedShare, WrappingKeys } from '@forgezero/runtime/custody-share';
|
|
370
633
|
```
|
|
371
634
|
|
|
635
|
+
<a id="forgezero-runtime-custody-crypto"></a>
|
|
372
636
|
## @forgezero/runtime/custody-crypto
|
|
373
637
|
|
|
374
|
-
Hybrid ML-KEM-768 plus X25519 custody-share sealing and opening.
|
|
375
|
-
|
|
376
|
-
```text
|
|
377
|
-
import * as api from '@forgezero/runtime/custody-crypto';
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
## Define and implement a typed query
|
|
381
|
-
|
|
382
|
-
Decode untrusted input and validate output around injected storage/services rather than embedding a database query in the route adapter.
|
|
638
|
+
Hybrid ML-KEM-768 plus X25519 custody-share sealing and opening. Named value imports: deriveKey, openFromKey, openWithKey, sealToKey, sealWithKey, wrappingKeyPair. Named type imports: CipherBox, SealedToKey. Import only the names used by this file.
|
|
383
639
|
|
|
384
640
|
```text
|
|
385
|
-
import {
|
|
386
|
-
import {
|
|
387
|
-
|
|
388
|
-
const OrderKey = T.Object({ orderKey: T.String({ minLength: 1 }) });
|
|
389
|
-
const Order = T.Object({ orderKey: T.String(), total: T.String() });
|
|
390
|
-
type OrderRow = Static<typeof Order>;
|
|
391
|
-
type Stores = { orders: { find(key: string): Promise<OrderRow | null> } };
|
|
392
|
-
declare const stores: Stores;
|
|
393
|
-
|
|
394
|
-
const findOrder = defineQuery({
|
|
395
|
-
name: 'orders.find',
|
|
396
|
-
input: typeboxQueryCodec(OrderKey),
|
|
397
|
-
output: typeboxQueryCodec(T.Union([Order, T.Null()]))
|
|
398
|
-
});
|
|
399
|
-
export const runFindOrder = implementQuery(findOrder,
|
|
400
|
-
(context: Stores, input) => context.orders.find(input.orderKey)
|
|
401
|
-
);
|
|
402
|
-
|
|
403
|
-
const order = await runFindOrder.execute(stores, { orderKey: 'ord_123' });
|
|
641
|
+
import { deriveKey, openFromKey, openWithKey, sealToKey, sealWithKey, wrappingKeyPair } from '@forgezero/runtime/custody-crypto';
|
|
642
|
+
import type { CipherBox, SealedToKey } from '@forgezero/runtime/custody-crypto';
|
|
404
643
|
```
|
|
405
644
|
|
|
406
645
|
## 1. Install, then import a subpath
|