@calimero-network/mero-js 35.2.1 → 35.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/client/approvals.d.ts +4 -0
- package/dist/client/approvals.js +8 -1
- package/dist/client/calimero-client.d.ts +33 -2
- package/dist/client/calimero-client.js +47 -0
- package/dist/client/index.d.ts +6 -3
- package/dist/client/index.js +3 -2
- package/dist/client/package-capabilities.d.ts +42 -0
- package/dist/client/package-capabilities.js +2 -0
- package/dist/client/receipts.d.ts +176 -0
- package/dist/client/receipts.js +475 -0
- package/dist/generated/api.d.ts +126 -4
- package/dist/generated/methods.d.ts +7 -1
- package/dist/generated/methods.js +7 -1
- package/dist/index.browser.mjs +4 -4
- package/dist/index.browser.mjs.map +4 -4
- package/dist/index.cjs +2175 -1546
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2175 -1546
- package/dist/index.mjs.map +4 -4
- package/dist/package/pack.d.ts +1 -0
- package/dist/package/pack.js +11 -5
- package/dist/recovery/backup-files.d.ts +4 -1
- package/dist/recovery/backup-files.js +28 -1
- package/dist/runtime/attestation.d.ts +33 -1
- package/dist/runtime/attestation.js +114 -31
- package/dist/runtime/index.d.ts +3 -3
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/transport.d.ts +41 -2
- package/dist/runtime/transport.js +101 -8
- package/dist/runtime.browser.mjs +1 -0
- package/dist/runtime.cjs +1 -0
- package/dist/runtime.mjs +1 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ for await (const event of client.events(app)) console.log(event);
|
|
|
70
70
|
await client.apps.upgrade({ app, version: '1.1.0' }, { confirm: passkeyConfirm(browserPasskey()) }); // the owner approves
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
A development cluster (`
|
|
73
|
+
A development cluster (`meroctl local up`, `merod run --dev`) sends mock quotes,
|
|
74
74
|
which pass only with `policy: { allowMock: true }`. Nothing is read from the
|
|
75
75
|
environment.
|
|
76
76
|
|
|
@@ -388,12 +388,12 @@ MEROD_BINARY=/path/to/merod KV_STORE_WASM=/path/to/kv_store.wasm pnpm test:clust
|
|
|
388
388
|
`KV_STORE_WASM` is core's kv component (`apps/v2-fixtures/kv`, a `calimero:app`
|
|
389
389
|
component for `wasm32-wasip2`). Without the variables they use
|
|
390
390
|
`../core/target/debug/merod` and `../core/target/app-components/kv.wasm` from a
|
|
391
|
-
sibling core checkout, built there
|
|
391
|
+
sibling core checkout (1.0.0-rc.24 or later), built there with core's
|
|
392
|
+
`meroctl`:
|
|
392
393
|
|
|
393
394
|
```bash
|
|
394
|
-
cargo build -p merod
|
|
395
|
-
|
|
396
|
-
mero-app-build apps/v2-fixtures/kv --out target/app-components/kv.wasm
|
|
395
|
+
cargo build -p merod -p meroctl
|
|
396
|
+
target/debug/meroctl app build apps/v2-fixtures/kv --out target/app-components/kv.wasm
|
|
397
397
|
```
|
|
398
398
|
|
|
399
399
|
`scripts/download-released-merod.sh` fetches the newest released 1.0 `merod`
|
|
@@ -32,6 +32,8 @@ export interface Governance {
|
|
|
32
32
|
deployments?: 'open' | 'granted';
|
|
33
33
|
/** Who grants deployers: the operator (left out) or the cluster's owner. */
|
|
34
34
|
deployers?: 'operator' | 'owner';
|
|
35
|
+
/** Who may create an account: anyone (`open`, left out), invitees or pre-authorized people only. */
|
|
36
|
+
signUp?: 'open' | 'invite' | 'closed';
|
|
35
37
|
}
|
|
36
38
|
/** Whose approvals a report covers: an organization's, or the account's own apps. */
|
|
37
39
|
export type ReportScope = {
|
|
@@ -258,6 +260,8 @@ export declare const RELEASE_VERIFIER = "https://mero-tee.vercel.app";
|
|
|
258
260
|
export declare function releaseNotesUrl(version: string): string;
|
|
259
261
|
/** The public verifier's page for a mero-tee release. */
|
|
260
262
|
export declare function verifyReleaseUrl(version: string): string;
|
|
263
|
+
/** The public verifier's page for a node: it fetches a fresh quote from `nodeUrl` and checks it against `release`. */
|
|
264
|
+
export declare function verifyNodeUrl(nodeUrl: string, release: string): string;
|
|
261
265
|
/** A mero-tee release the cluster's nodes run that the scope has not approved. */
|
|
262
266
|
export interface PendingRelease {
|
|
263
267
|
version: string;
|
package/dist/client/approvals.js
CHANGED
|
@@ -122,9 +122,16 @@ export const RELEASE_VERIFIER = 'https://mero-tee.vercel.app';
|
|
|
122
122
|
export function releaseNotesUrl(version) {
|
|
123
123
|
return `https://github.com/calimero-network/mero-tee/releases/tag/mero-tee-v${encodeURIComponent(version)}`;
|
|
124
124
|
}
|
|
125
|
+
function verifierUrl(query) {
|
|
126
|
+
return `${RELEASE_VERIFIER}/mero-tee?${new URLSearchParams(query)}`;
|
|
127
|
+
}
|
|
125
128
|
/** The public verifier's page for a mero-tee release. */
|
|
126
129
|
export function verifyReleaseUrl(version) {
|
|
127
|
-
return
|
|
130
|
+
return verifierUrl({ release_tag: `mero-tee-v${version}` });
|
|
131
|
+
}
|
|
132
|
+
/** The public verifier's page for a node: it fetches a fresh quote from `nodeUrl` and checks it against `release`. */
|
|
133
|
+
export function verifyNodeUrl(nodeUrl, release) {
|
|
134
|
+
return verifierUrl({ node_url: nodeUrl.replace(/\/+$/, ''), release_tag: `mero-tee-v${release}` });
|
|
128
135
|
}
|
|
129
136
|
/**
|
|
130
137
|
* The pending list from a scope's report pages (every page's apps
|
|
@@ -9,12 +9,14 @@
|
|
|
9
9
|
* const { result } = await cloud.call(appId, 'set', { key: 'a', value: '1' });
|
|
10
10
|
* ```
|
|
11
11
|
*/
|
|
12
|
-
import { DEFAULT_RETRY, NodeTransport, retryDelayMs, type CalimeroSession, type NodeEvent, type RetryOptions } from '../runtime/transport.js';
|
|
13
|
-
import { type NodePolicy } from '../runtime/attestation.js';
|
|
12
|
+
import { DEFAULT_RETRY, NodeTransport, retryDelayMs, type CalimeroSession, type NodeEvent, type NodeVerificationState, type RetryOptions } from '../runtime/transport.js';
|
|
13
|
+
import { type NodePolicy, type NodeVerification } from '../runtime/attestation.js';
|
|
14
14
|
import { type PasskeyProvider } from '../runtime/passkey.js';
|
|
15
15
|
import { type RouteClientOptions } from '../routes/route-client.js';
|
|
16
|
+
import type { PackageCapabilities } from './package-capabilities.js';
|
|
16
17
|
import { type Routes } from '../generated/methods.js';
|
|
17
18
|
import { type ExportedFile, type FileSink } from './files.js';
|
|
19
|
+
import { type AttestedCluster, type PipelineReceipt, type ReceiptAnswer } from './receipts.js';
|
|
18
20
|
import { type AppsReport, type ConsentRequest, type ConsentResult, type ConsentStarted, type OpenConsentOptions, type ResumeConsentOptions, type PendingApprovals } from './approvals.js';
|
|
19
21
|
import type { ApiAnswer, ApiSchema } from '../routes/types.js';
|
|
20
22
|
export { AppError, ArgsTooLarge, BadOrigin, CalimeroError, ConfirmCancelled, ConfirmPromptBlocked, ConfirmRequired, IdempotencyMismatch, LoginRequired, ConsentStale, FeatureNotActive, NotFound, OriginNotRegistered, OriginTaken, PasskeyUnknownHere, QuotaExceeded, RecoveryNotReady, ReleaseDeadlineError, RuntimeTooOld, SignUpRefused, TrapError, UnavailableError, WrongNode, WrongRecoveryCode, errorFrom, } from '../runtime/errors.js';
|
|
@@ -265,12 +267,22 @@ export declare class CalimeroClient {
|
|
|
265
267
|
get nodeUrl(): string;
|
|
266
268
|
/** Every node this client may use, in the order it moves through them. */
|
|
267
269
|
get nodes(): string[];
|
|
270
|
+
/** What the check of node `url` (from {@link nodes}; default: in use) established, or `undefined` before it first ran. */
|
|
271
|
+
verification(url?: string): NodeVerificationState | undefined;
|
|
272
|
+
/** Wait for the check requests wait for, starting it if needed, and answer its outcome (not thrown) without a request. */
|
|
273
|
+
verify(url?: string): Promise<NodeVerificationState>;
|
|
268
274
|
/** Authenticate every request with an API key. */
|
|
269
275
|
useApiKey(key: string): void;
|
|
270
276
|
useSession(session: CalimeroSession): void;
|
|
271
277
|
get session(): CalimeroSession | undefined;
|
|
272
278
|
/** A JSON request through the transport, to an untyped path. */
|
|
273
279
|
private json;
|
|
280
|
+
/** Attest `app` on node `url` (from {@link nodes}; default: in use): the record's `appHash` is the one the node bound. */
|
|
281
|
+
attestApp(app: string, url?: string): Promise<NodeVerification>;
|
|
282
|
+
/** The manifest facts and ABI of a package version (of `service`, for a multi-service release), for a signed-in caller. */
|
|
283
|
+
packageCapabilities(pkg: string, version: string, options?: {
|
|
284
|
+
service?: string;
|
|
285
|
+
}): Promise<PackageCapabilities>;
|
|
274
286
|
/**
|
|
275
287
|
* Create an account with a new passkey, and sign in. The node then asks the
|
|
276
288
|
* new passkey to sign the account it creates (`412 CONFIRM_REQUIRED`), so a
|
|
@@ -361,6 +373,25 @@ export declare class CalimeroClient {
|
|
|
361
373
|
exportFileTo(app: string, id: string, sink: FileSink, signal?: AbortSignal): Promise<ExportedFile>;
|
|
362
374
|
/** The plaintext of sealed file `id` of component app `app`, in memory; use {@link exportFileTo} for a large one. */
|
|
363
375
|
exportFile(app: string, id: string, signal?: AbortSignal): Promise<Uint8Array>;
|
|
376
|
+
/** The policy this client attests nodes under; a client without one verifies nothing. */
|
|
377
|
+
private get attestationPolicy();
|
|
378
|
+
/**
|
|
379
|
+
* Verify every replica of `app` under this client's policy: each one's quote binds its receipt key,
|
|
380
|
+
* the cluster's governance, and its cluster and node id. Answers the attested receipt key per node
|
|
381
|
+
* and the governance.
|
|
382
|
+
*/
|
|
383
|
+
verifyAppCluster(app: string): Promise<AttestedCluster>;
|
|
384
|
+
/**
|
|
385
|
+
* The signed receipt of an ended pipeline run, version 2 (`client.apps.pipelineReceiptReceipt`):
|
|
386
|
+
* with each job's report evidence and job node attestation. A version 1 answer does not verify.
|
|
387
|
+
*/
|
|
388
|
+
pipelineReceipt(app: string, run: string): Promise<ReceiptAnswer>;
|
|
389
|
+
/**
|
|
390
|
+
* Verify the receipt of a pipeline run ({@link pipelineReceipt}): signed by the key an attested replica
|
|
391
|
+
* holds, for `app` and `run`, with every job's report signed by a job key a job node attests. Throws
|
|
392
|
+
* when it is not; answers the receipt.
|
|
393
|
+
*/
|
|
394
|
+
verifyPipelineReceipt(app: string, run: string, answer: ReceiptAnswer): Promise<PipelineReceipt>;
|
|
364
395
|
/**
|
|
365
396
|
* Download a component app's blob with a grant one of its runs handed out
|
|
366
397
|
* (`BlobRef::grant`, up to 24 h). No session needed: the grant is the
|
|
@@ -18,6 +18,7 @@ import { createRoutes } from '../generated/methods.js';
|
|
|
18
18
|
import { passkeyConfirm } from '../runtime/passkey.js';
|
|
19
19
|
import { exportFile, exportFileTo } from './files.js';
|
|
20
20
|
import { signRecovery } from './recovery-key.js';
|
|
21
|
+
import { verifyAppCluster, verifyPipelineReceipt } from './receipts.js';
|
|
21
22
|
import { CONSENT_STORAGE_KEY, confirmationCode, pageQuery, pendingApprovalsFrom, withoutConsentReturn, } from './approvals.js';
|
|
22
23
|
export { AppError, ArgsTooLarge, BadOrigin, CalimeroError, ConfirmCancelled, ConfirmPromptBlocked, ConfirmRequired, IdempotencyMismatch, LoginRequired, ConsentStale, FeatureNotActive, NotFound, OriginNotRegistered, OriginTaken, PasskeyUnknownHere, QuotaExceeded, RecoveryNotReady, ReleaseDeadlineError, RuntimeTooOld, SignUpRefused, TrapError, UnavailableError, WrongNode, WrongRecoveryCode, errorFrom, } from '../runtime/errors.js';
|
|
23
24
|
/** The largest file sent as one request, and the part size a session is asked for. */
|
|
@@ -144,6 +145,14 @@ export class CalimeroClient {
|
|
|
144
145
|
get nodes() {
|
|
145
146
|
return this.transport.nodes;
|
|
146
147
|
}
|
|
148
|
+
/** What the check of node `url` (from {@link nodes}; default: in use) established, or `undefined` before it first ran. */
|
|
149
|
+
verification(url) {
|
|
150
|
+
return this.transport.verification(url);
|
|
151
|
+
}
|
|
152
|
+
/** Wait for the check requests wait for, starting it if needed, and answer its outcome (not thrown) without a request. */
|
|
153
|
+
verify(url) {
|
|
154
|
+
return this.transport.verify(url);
|
|
155
|
+
}
|
|
147
156
|
/** Authenticate every request with an API key. */
|
|
148
157
|
useApiKey(key) {
|
|
149
158
|
this.transport.useApiKey(key);
|
|
@@ -158,6 +167,14 @@ export class CalimeroClient {
|
|
|
158
167
|
json(method, path, body) {
|
|
159
168
|
return this.transport.json(method, path, { body });
|
|
160
169
|
}
|
|
170
|
+
/** Attest `app` on node `url` (from {@link nodes}; default: in use): the record's `appHash` is the one the node bound. */
|
|
171
|
+
attestApp(app, url) {
|
|
172
|
+
return this.transport.attestApp(app, url);
|
|
173
|
+
}
|
|
174
|
+
/** The manifest facts and ABI of a package version (of `service`, for a multi-service release), for a signed-in caller. */
|
|
175
|
+
packageCapabilities(pkg, version, options = {}) {
|
|
176
|
+
return this.transport.json('GET', routePath('packages/{package}/{version}/capabilities', { package: pkg, version }), { query: { service: options.service } });
|
|
177
|
+
}
|
|
161
178
|
// ---------------------------------------------------------------- identity
|
|
162
179
|
/**
|
|
163
180
|
* Create an account with a new passkey, and sign in. The node then asks the
|
|
@@ -349,6 +366,36 @@ export class CalimeroClient {
|
|
|
349
366
|
exportFile(app, id, signal) {
|
|
350
367
|
return exportFile(this.exportClient, app, id, signal);
|
|
351
368
|
}
|
|
369
|
+
/** The policy this client attests nodes under; a client without one verifies nothing. */
|
|
370
|
+
get attestationPolicy() {
|
|
371
|
+
const policy = this.transport.nodePolicy;
|
|
372
|
+
if (!policy)
|
|
373
|
+
throw new Error('this client has no attestation policy, so it cannot verify an attestation');
|
|
374
|
+
return policy;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Verify every replica of `app` under this client's policy: each one's quote binds its receipt key,
|
|
378
|
+
* the cluster's governance, and its cluster and node id. Answers the attested receipt key per node
|
|
379
|
+
* and the governance.
|
|
380
|
+
*/
|
|
381
|
+
async verifyAppCluster(app) {
|
|
382
|
+
return verifyAppCluster(this, app, this.attestationPolicy);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* The signed receipt of an ended pipeline run, version 2 (`client.apps.pipelineReceiptReceipt`):
|
|
386
|
+
* with each job's report evidence and job node attestation. A version 1 answer does not verify.
|
|
387
|
+
*/
|
|
388
|
+
async pipelineReceipt(app, run) {
|
|
389
|
+
return (await this.apps.pipelineReceiptReceipt({ app, run, version: 2 }));
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Verify the receipt of a pipeline run ({@link pipelineReceipt}): signed by the key an attested replica
|
|
393
|
+
* holds, for `app` and `run`, with every job's report signed by a job key a job node attests. Throws
|
|
394
|
+
* when it is not; answers the receipt.
|
|
395
|
+
*/
|
|
396
|
+
async verifyPipelineReceipt(app, run, answer) {
|
|
397
|
+
return verifyPipelineReceipt(this, app, run, answer, this.attestationPolicy);
|
|
398
|
+
}
|
|
352
399
|
/**
|
|
353
400
|
* Download a component app's blob with a grant one of its runs handed out
|
|
354
401
|
* (`BlobRef::grant`, up to 24 h). No session needed: the grant is the
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
export { CalimeroClient, FILE_PART_BYTES, deployerKey, frontendManifest, pageDeployment, presenceState } from './calimero-client.js';
|
|
2
2
|
export { ExportError } from './files.js';
|
|
3
|
+
export { jobKeyBinding, receiptMessage, reportMessage, verifyAppCluster, verifyJobReports, verifyPipelineReceipt, verifyReceiptKey } from './receipts.js';
|
|
4
|
+
export type { AttestedCluster, CachedRun, FileRef, JobAttestationDoc, JobEvidence, JobOutput, PipelineReceipt, ReportFields, StepReceipt, StepRunProof, ReceiptAnswer, ReceiptKeyDoc } from './receipts.js';
|
|
3
5
|
export type { ExportErrorCode, ExportedFile, FileSink } from './files.js';
|
|
4
6
|
export { DEFAULT_DIRECTORY, DirectoryError } from '../runtime/directory.js';
|
|
5
7
|
export type { DirectoryFailure } from '../runtime/directory.js';
|
|
6
8
|
export { AppError, ArgsTooLarge, BadOrigin, CalimeroError, ClusterNotUpgraded, ConfirmCancelled, ConfirmPromptBlocked, ConfirmRequired, IdempotencyMismatch, LoginRequired, ConsentStale, FeatureNotActive, NotFound, NotServing, OriginNotRegistered, OriginTaken, PasskeyUnknownHere, QuotaExceeded, RecoveryNotReady, ReleaseDeadlineError, RuntimeTooOld, SignUpRefused, TrapError, UnavailableError, WrongNode, WrongRecoveryCode, errorFrom, } from '../runtime/errors.js';
|
|
7
9
|
export type { Committed, SignUpRefusal } from '../runtime/errors.js';
|
|
8
10
|
export type { AppInfo, AppTeam, AppTeams, BlobInfo, FileData, FileInfo, DeadLetter, Deployer, FrontendManifest, PackageOrigin, SignInOptions, AccountRecovery, SignUpOptions, SignUpPolicy, CallResult, CalimeroClientOptions, CalimeroConnectOptions, NodeEvent, CalimeroSession, PackageInfo, RetryOptions, OrgInfo, OrgInvite, OrgMode, RecoveryTimes, PresenceEntry, ScopeAppsResult, ScopedAppTeam, TeamInfo, UpgradeRun, ViewResult, } from './calimero-client.js';
|
|
9
|
-
export {
|
|
10
|
-
export
|
|
11
|
+
export type { AppAbi, AppAbiMethod, AppMethodKind, PackageCapabilities } from './package-capabilities.js';
|
|
12
|
+
export { claimedRelease, fetchAttestedKey, freshCollateral, MOCK_QUOTE_HEADER, verifyNode } from '../runtime/attestation.js';
|
|
13
|
+
export type { AttestationDoc, NodePolicy, NodeReleasePolicy, NodeVerification } from '../runtime/attestation.js';
|
|
11
14
|
export { browserPasskey, b64url, fromB64url, passkeyConfirm } from '../runtime/passkey.js';
|
|
12
15
|
export { MAX_RECOVERY_NONCE_BYTES, RECOVERY_DOMAIN, newRecoverySeed, parseRecoverySeed, recoveryMessage, recoveryPublicKey, recoverySeedText, signRecovery, } from './recovery-key.js';
|
|
13
16
|
export type { ConfirmCallback, ConfirmChallenge, PasskeyConfirmOptions, AssertionJSON, PasskeyCreateOptions, PasskeyGetOptions, PasskeyProvider, PasskeyUserVerification, RegistrationJSON, } from '../runtime/passkey.js';
|
|
14
|
-
export { CONSENT_STORAGE_KEY, MAX_REPORT_PAGE, RELEASE_VERIFIER, acceptInviteConsent, compareVersions, confirmationCode, consentReturn, createInviteConsent, createOrgConsent, deleteOrgConsent, leaveOrgConsent, removeMemberConsent, removeMemberTeamsConsent, renameOrgConsent, revokeInviteConsent, setAllAppsConsent, setCapabilitiesConsent, setMemberRoleConsent, setMemberTeamsConsent, pageQuery, pendingApprovalsFrom, publisherBindingBytes, publisherBindingMessage, releaseConsent, releaseNotesUrl, stalledBy, upgradeConsent, verifyReleaseUrl, withdrawConsent, withoutConsentReturn, } from './approvals.js';
|
|
17
|
+
export { CONSENT_STORAGE_KEY, MAX_REPORT_PAGE, RELEASE_VERIFIER, acceptInviteConsent, compareVersions, confirmationCode, consentReturn, createInviteConsent, createOrgConsent, deleteOrgConsent, leaveOrgConsent, removeMemberConsent, removeMemberTeamsConsent, renameOrgConsent, revokeInviteConsent, setAllAppsConsent, setCapabilitiesConsent, setMemberRoleConsent, setMemberTeamsConsent, pageQuery, pendingApprovalsFrom, publisherBindingBytes, publisherBindingMessage, releaseConsent, releaseNotesUrl, stalledBy, upgradeConsent, verifyNodeUrl, verifyReleaseUrl, withdrawConsent, withoutConsentReturn, } from './approvals.js';
|
|
15
18
|
export type { ActorKind, AppsReport, Authority, CapabilitiesConsentSubject, ConsentKind, ConsentOutcomes, ConsentRequest, ConsentResult, ConsentResultOf, ConsentScope, ConsentStarted, InviteConsentSubject, InviteRole, MemberTeamConsent, OrgRole, TeamRole, OpenConsentOptions, ResumeConsentOptions, Governance, LatestBlocked, PageOptions, PendingApprovals, PendingRelease, PendingUpgrade, ReleaseDeadline, ReleaseRules, ReportScope, ReportedApp, ReportedBundle, RuntimeShortNode, } from './approvals.js';
|
|
16
19
|
export { DEFAULT_ORG_CAPABILITIES, ORG_CAPABILITIES, orgCapabilities } from './capabilities.js';
|
|
17
20
|
export type { OrgCapability } from './capabilities.js';
|
package/dist/client/index.js
CHANGED
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
// use. src/routes/index.ts describes the layering.
|
|
10
10
|
export { CalimeroClient, FILE_PART_BYTES, deployerKey, frontendManifest, pageDeployment, presenceState } from './calimero-client.js';
|
|
11
11
|
export { ExportError } from './files.js';
|
|
12
|
+
export { jobKeyBinding, receiptMessage, reportMessage, verifyAppCluster, verifyJobReports, verifyPipelineReceipt, verifyReceiptKey } from './receipts.js';
|
|
12
13
|
export { DEFAULT_DIRECTORY, DirectoryError } from '../runtime/directory.js';
|
|
13
14
|
export { AppError, ArgsTooLarge, BadOrigin, CalimeroError, ClusterNotUpgraded, ConfirmCancelled, ConfirmPromptBlocked, ConfirmRequired, IdempotencyMismatch, LoginRequired, ConsentStale, FeatureNotActive, NotFound, NotServing, OriginNotRegistered, OriginTaken, PasskeyUnknownHere, QuotaExceeded, RecoveryNotReady, ReleaseDeadlineError, RuntimeTooOld, SignUpRefused, TrapError, UnavailableError, WrongNode, WrongRecoveryCode, errorFrom, } from '../runtime/errors.js';
|
|
14
|
-
export { claimedRelease, fetchAttestedKey, freshCollateral, MOCK_QUOTE_HEADER } from '../runtime/attestation.js';
|
|
15
|
+
export { claimedRelease, fetchAttestedKey, freshCollateral, MOCK_QUOTE_HEADER, verifyNode } from '../runtime/attestation.js';
|
|
15
16
|
export { browserPasskey, b64url, fromB64url, passkeyConfirm } from '../runtime/passkey.js';
|
|
16
17
|
export { MAX_RECOVERY_NONCE_BYTES, RECOVERY_DOMAIN, newRecoverySeed, parseRecoverySeed, recoveryMessage, recoveryPublicKey, recoverySeedText, signRecovery, } from './recovery-key.js';
|
|
17
|
-
export { CONSENT_STORAGE_KEY, MAX_REPORT_PAGE, RELEASE_VERIFIER, acceptInviteConsent, compareVersions, confirmationCode, consentReturn, createInviteConsent, createOrgConsent, deleteOrgConsent, leaveOrgConsent, removeMemberConsent, removeMemberTeamsConsent, renameOrgConsent, revokeInviteConsent, setAllAppsConsent, setCapabilitiesConsent, setMemberRoleConsent, setMemberTeamsConsent, pageQuery, pendingApprovalsFrom, publisherBindingBytes, publisherBindingMessage, releaseConsent, releaseNotesUrl, stalledBy, upgradeConsent, verifyReleaseUrl, withdrawConsent, withoutConsentReturn, } from './approvals.js';
|
|
18
|
+
export { CONSENT_STORAGE_KEY, MAX_REPORT_PAGE, RELEASE_VERIFIER, acceptInviteConsent, compareVersions, confirmationCode, consentReturn, createInviteConsent, createOrgConsent, deleteOrgConsent, leaveOrgConsent, removeMemberConsent, removeMemberTeamsConsent, renameOrgConsent, revokeInviteConsent, setAllAppsConsent, setCapabilitiesConsent, setMemberRoleConsent, setMemberTeamsConsent, pageQuery, pendingApprovalsFrom, publisherBindingBytes, publisherBindingMessage, releaseConsent, releaseNotesUrl, stalledBy, upgradeConsent, verifyNodeUrl, verifyReleaseUrl, withdrawConsent, withoutConsentReturn, } from './approvals.js';
|
|
18
19
|
export { DEFAULT_ORG_CAPABILITIES, ORG_CAPABILITIES, orgCapabilities } from './capabilities.js';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** What `GET /packages/{package}/{version}/capabilities` answers: a package version's manifest facts and its app's ABI. */
|
|
2
|
+
export type AppMethodKind = 'init' | 'call' | 'view' | 'timer' | 'action' | 'compute';
|
|
3
|
+
export interface AppAbiMethod {
|
|
4
|
+
kind: AppMethodKind;
|
|
5
|
+
/** `[name, type]` per parameter. */
|
|
6
|
+
params: [string, string][];
|
|
7
|
+
returns: string | null;
|
|
8
|
+
confirm: boolean;
|
|
9
|
+
public: boolean;
|
|
10
|
+
allowSystem: boolean;
|
|
11
|
+
every?: string;
|
|
12
|
+
rate?: string;
|
|
13
|
+
allowApps?: string[];
|
|
14
|
+
allowAction?: boolean;
|
|
15
|
+
compute?: Record<string, unknown>;
|
|
16
|
+
computeResult?: boolean;
|
|
17
|
+
doc?: string;
|
|
18
|
+
}
|
|
19
|
+
/** The app's `calimero:abi` document. */
|
|
20
|
+
export interface AppAbi {
|
|
21
|
+
abiVersion: string;
|
|
22
|
+
world: string;
|
|
23
|
+
state: string;
|
|
24
|
+
methods: Record<string, AppAbiMethod>;
|
|
25
|
+
errors: unknown[];
|
|
26
|
+
events: unknown[];
|
|
27
|
+
types?: unknown;
|
|
28
|
+
}
|
|
29
|
+
export interface PackageCapabilities {
|
|
30
|
+
package: string;
|
|
31
|
+
version: string;
|
|
32
|
+
service: string | null;
|
|
33
|
+
bundle: string;
|
|
34
|
+
mpk: string;
|
|
35
|
+
manifestHash: string;
|
|
36
|
+
signer: string;
|
|
37
|
+
name: string | null;
|
|
38
|
+
author: string | null;
|
|
39
|
+
/** Hosts the app may call out to. */
|
|
40
|
+
outbound: string[];
|
|
41
|
+
abi: AppAbi | null;
|
|
42
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checking a pipeline run's receipt as core's `calimero-client` does (`Client::verify_app_cluster`,
|
|
3
|
+
* `attest::verify_receipt_key`, `Client::verify_receipt`): the receipt is signed by the answering
|
|
4
|
+
* node's receipt key, and that key is one every replica's quote attests, bound to the cluster and
|
|
5
|
+
* node the entry node names. A quote of the unbound `receipt-key.v2` form is never accepted. A
|
|
6
|
+
* version 2 receipt also proves each job's report: its job key signed what the proof says, and a
|
|
7
|
+
* job node's quote under the client's policy binds that key, node, cluster and cluster identity.
|
|
8
|
+
*/
|
|
9
|
+
import { type AttestationDoc, type NodePolicy } from '../runtime/attestation.js';
|
|
10
|
+
import type { AppsRoutes } from '../generated/methods.js';
|
|
11
|
+
import type { Governance } from './approvals.js';
|
|
12
|
+
/** A receipt-key attestation: the quote binds the key, the governance, and the cluster and node asked for. */
|
|
13
|
+
export type ReceiptKeyDoc = AttestationDoc & {
|
|
14
|
+
receiptKey?: string;
|
|
15
|
+
governance?: Governance;
|
|
16
|
+
};
|
|
17
|
+
/** What `GET /apps/{app}/pipeline-runs/{run}/receipt` answers: the receipt as sent, the signing node, its signature (hex). Checked at run time. */
|
|
18
|
+
export interface ReceiptAnswer {
|
|
19
|
+
receipt: unknown;
|
|
20
|
+
node: unknown;
|
|
21
|
+
signature: unknown;
|
|
22
|
+
}
|
|
23
|
+
/** A file named by id, size and plaintext SHA-256 (hex). */
|
|
24
|
+
export interface FileRef {
|
|
25
|
+
id: string;
|
|
26
|
+
size: number;
|
|
27
|
+
sha256: string;
|
|
28
|
+
}
|
|
29
|
+
/** What one step run's proof records: which job node ran which assignment, and what came out. */
|
|
30
|
+
export interface StepRunProof {
|
|
31
|
+
run: string;
|
|
32
|
+
step: string;
|
|
33
|
+
index: number;
|
|
34
|
+
outcome: string;
|
|
35
|
+
attempt: number;
|
|
36
|
+
node?: number | null;
|
|
37
|
+
jobKey?: string | null;
|
|
38
|
+
assignmentDigest?: string | null;
|
|
39
|
+
reportSha256?: string | null;
|
|
40
|
+
signature?: string | null;
|
|
41
|
+
outputs: FileRef[];
|
|
42
|
+
usage: {
|
|
43
|
+
cpuMicros: string;
|
|
44
|
+
gibMicros: string;
|
|
45
|
+
fuel: string;
|
|
46
|
+
};
|
|
47
|
+
/** What the job's report signs that the fields above do not (version 2 only). */
|
|
48
|
+
job?: JobEvidence | null;
|
|
49
|
+
}
|
|
50
|
+
/** A file as a job's report signs it: id, plaintext size and SHA-256, and each ciphertext segment's SHA-256 (lowercase hex). */
|
|
51
|
+
export interface JobOutput {
|
|
52
|
+
id: string;
|
|
53
|
+
size: number;
|
|
54
|
+
sha256: string;
|
|
55
|
+
segments: string[];
|
|
56
|
+
}
|
|
57
|
+
/** The rest of what a job's report signs: the result's hash, the failure text, each output's segment hashes, the module log. */
|
|
58
|
+
export interface JobEvidence {
|
|
59
|
+
resultSha256: string;
|
|
60
|
+
message?: string;
|
|
61
|
+
segments: string[][];
|
|
62
|
+
log?: JobOutput | null;
|
|
63
|
+
}
|
|
64
|
+
/** A job node's `purpose=jobs` attestation: the quote binds its transport key, job key, release, cluster, node and cluster identity. */
|
|
65
|
+
export type JobAttestationDoc = AttestationDoc & {
|
|
66
|
+
jobKey?: string;
|
|
67
|
+
clusterIdentity?: string;
|
|
68
|
+
};
|
|
69
|
+
/** A run answered from the step cache: it ran nothing, so it has no proof. */
|
|
70
|
+
export interface CachedRun {
|
|
71
|
+
index: number;
|
|
72
|
+
cached: boolean;
|
|
73
|
+
cacheKey: string;
|
|
74
|
+
}
|
|
75
|
+
export interface StepReceipt {
|
|
76
|
+
status: string;
|
|
77
|
+
reason?: string | null;
|
|
78
|
+
runs: (CachedRun | StepRunProof)[];
|
|
79
|
+
}
|
|
80
|
+
/** What the node states about a finished pipeline run (core's `PipelineReceipt`). `cluster` is the cluster identity key, hex. */
|
|
81
|
+
export interface PipelineReceipt {
|
|
82
|
+
version: number;
|
|
83
|
+
cluster: string;
|
|
84
|
+
app: string;
|
|
85
|
+
run: string;
|
|
86
|
+
pipeline: string;
|
|
87
|
+
release: string;
|
|
88
|
+
pipelineHash: string;
|
|
89
|
+
modules: Record<string, string>;
|
|
90
|
+
inputs: Record<string, FileRef[]>;
|
|
91
|
+
params: Record<string, unknown>;
|
|
92
|
+
state: string;
|
|
93
|
+
startTsMs: number;
|
|
94
|
+
endTsMs: number;
|
|
95
|
+
steps: Record<string, StepReceipt>;
|
|
96
|
+
costSoFar?: string | null;
|
|
97
|
+
/** Each job key a proof names, its job node's attestation (version 2 only). */
|
|
98
|
+
jobAttestations?: Record<string, JobAttestationDoc>;
|
|
99
|
+
}
|
|
100
|
+
/** Every replica of an app, attested: its receipt key by node id, the governance they all attest, and the cluster name every quote bound. */
|
|
101
|
+
export interface AttestedCluster {
|
|
102
|
+
keys: Map<number, Uint8Array>;
|
|
103
|
+
governance: Governance;
|
|
104
|
+
cluster: string;
|
|
105
|
+
}
|
|
106
|
+
type AttestationRoutes = Pick<AppsRoutes, 'attestation'>;
|
|
107
|
+
/**
|
|
108
|
+
* Checks a receipt-key attestation as core's `verify_receipt_key` does: its quote binds the key, the
|
|
109
|
+
* governance and the `cluster` and `node` the caller asked for (never the document's own fields, which
|
|
110
|
+
* nothing signs). Answers the key and the governance rebuilt from its canonical fields.
|
|
111
|
+
*/
|
|
112
|
+
export declare function verifyReceiptKey(doc: ReceiptKeyDoc, nonce: Uint8Array, cluster: string, node: number, policy: NodePolicy): Promise<{
|
|
113
|
+
key: Uint8Array;
|
|
114
|
+
governance: Governance;
|
|
115
|
+
}>;
|
|
116
|
+
/**
|
|
117
|
+
* Verifies every replica of `app` (core's `Client::verify_app_cluster`): each one's quote over a fresh
|
|
118
|
+
* nonce, held to `policy`, binding its receipt key, the cluster's governance, and the cluster and node
|
|
119
|
+
* id the entry node names. Any replica error, a node id that differs from the document's, or replicas
|
|
120
|
+
* that attest other governance fails the whole check.
|
|
121
|
+
*/
|
|
122
|
+
export declare function verifyAppCluster(client: {
|
|
123
|
+
apps: AttestationRoutes;
|
|
124
|
+
}, app: string, policy: NodePolicy): Promise<AttestedCluster>;
|
|
125
|
+
/** The bytes a receipt's signature covers (core's `receipt_message`): the domain, then the canonical JSON. */
|
|
126
|
+
export declare const receiptMessage: (receipt: unknown) => Uint8Array;
|
|
127
|
+
/**
|
|
128
|
+
* Whether `answer` is signed by `key` (core's `verify_pipeline_receipt`). Answers the receipt as parsed
|
|
129
|
+
* from the canonical bytes that were verified, checked against core's receipt schema.
|
|
130
|
+
*/
|
|
131
|
+
export declare function verifyReceiptSignature(answer: ReceiptAnswer, key: Uint8Array): Promise<PipelineReceipt>;
|
|
132
|
+
/** One job report's signed fields, in the order {@link reportMessage} writes them (core's `ReportFields`). */
|
|
133
|
+
export interface ReportFields {
|
|
134
|
+
/** SHA-256 of the assignment message the job ran (hex). */
|
|
135
|
+
assignment: string;
|
|
136
|
+
app: string;
|
|
137
|
+
run: string;
|
|
138
|
+
attempt: number;
|
|
139
|
+
/** `null` for a done report, else why it failed. */
|
|
140
|
+
reason: string | null;
|
|
141
|
+
message: string;
|
|
142
|
+
resultSha256: string;
|
|
143
|
+
outputs: JobOutput[];
|
|
144
|
+
/** CPU micros, GiB micros, fuel, as decimal strings. */
|
|
145
|
+
usage: [string, string, string];
|
|
146
|
+
log?: JobOutput | null;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The bytes a job node signs for one report (core's `report_message`): the domain, the assignment digest,
|
|
150
|
+
* the length-prefixed app, run, reason and message, the result's hash, the outputs, the usage, then the
|
|
151
|
+
* log after its own domain; integers big-endian, hashes as their 32 bytes.
|
|
152
|
+
*/
|
|
153
|
+
export declare function reportMessage(f: ReportFields): Uint8Array;
|
|
154
|
+
/**
|
|
155
|
+
* What a job-node attestation's quote binds after the nonce (core's `job_key_binding`): both keys, the
|
|
156
|
+
* release and cluster (length-prefixed), the node id, and the cluster identity when there is one. Hex.
|
|
157
|
+
*/
|
|
158
|
+
export declare function jobKeyBinding(transportKey: Uint8Array, jobKey: Uint8Array, release: string, cluster: string, node: number, clusterIdentity?: Uint8Array): Promise<string>;
|
|
159
|
+
/**
|
|
160
|
+
* Checks every step run's proof of a version 2 receipt (core's `verify_job_reports`), each step's runs
|
|
161
|
+
* listed once in index order, and answers each job key that signed a report with the node it ran on; a
|
|
162
|
+
* key named on two nodes is refused. Whose key each is (its attestation) is for the caller to verify.
|
|
163
|
+
* What a job signed is proven; the rest (step and run states, cached runs, and the node and key a
|
|
164
|
+
* leader-ended run names) is the signing replica's word.
|
|
165
|
+
*/
|
|
166
|
+
export declare function verifyJobReports(receipt: PipelineReceipt): Promise<Map<string, number>>;
|
|
167
|
+
/**
|
|
168
|
+
* Checks that the node that answered holds a receipt key attested under `policy` ({@link verifyAppCluster})
|
|
169
|
+
* and signed `answer` with it, that the receipt is for `app` and `run`, that every job report it names is
|
|
170
|
+
* signed by its job key ({@link verifyJobReports}), and that each such key is a job node's of the attested
|
|
171
|
+
* cluster and the receipt's cluster identity, under `policy`. A version 1 receipt is refused. Answers the receipt.
|
|
172
|
+
*/
|
|
173
|
+
export declare function verifyPipelineReceipt(client: {
|
|
174
|
+
apps: AttestationRoutes;
|
|
175
|
+
}, app: string, run: string, answer: ReceiptAnswer, policy: NodePolicy): Promise<PipelineReceipt>;
|
|
176
|
+
export {};
|