@calimero-network/mero-js 35.2.1 → 35.3.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 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 (`merod local`, `merod run --dev`) sends mock quotes,
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 as core's `e2e.yml` builds them:
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
- scripts/install-mero-app-build.sh
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`
@@ -258,6 +258,8 @@ export declare const RELEASE_VERIFIER = "https://mero-tee.vercel.app";
258
258
  export declare function releaseNotesUrl(version: string): string;
259
259
  /** The public verifier's page for a mero-tee release. */
260
260
  export declare function verifyReleaseUrl(version: string): string;
261
+ /** The public verifier's page for a node: it fetches a fresh quote from `nodeUrl` and checks it against `release`. */
262
+ export declare function verifyNodeUrl(nodeUrl: string, release: string): string;
261
263
  /** A mero-tee release the cluster's nodes run that the scope has not approved. */
262
264
  export interface PendingRelease {
263
265
  version: string;
@@ -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 `${RELEASE_VERIFIER}/mero-tee?release_tag=${encodeURIComponent(`mero-tee-v${version}`)}`;
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,10 +9,11 @@
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';
18
19
  import { type AppsReport, type ConsentRequest, type ConsentResult, type ConsentStarted, type OpenConsentOptions, type ResumeConsentOptions, type PendingApprovals } from './approvals.js';
@@ -265,12 +266,22 @@ export declare class CalimeroClient {
265
266
  get nodeUrl(): string;
266
267
  /** Every node this client may use, in the order it moves through them. */
267
268
  get nodes(): string[];
269
+ /** What the check of node `url` (from {@link nodes}; default: in use) established, or `undefined` before it first ran. */
270
+ verification(url?: string): NodeVerificationState | undefined;
271
+ /** Wait for the check requests wait for, starting it if needed, and answer its outcome (not thrown) without a request. */
272
+ verify(url?: string): Promise<NodeVerificationState>;
268
273
  /** Authenticate every request with an API key. */
269
274
  useApiKey(key: string): void;
270
275
  useSession(session: CalimeroSession): void;
271
276
  get session(): CalimeroSession | undefined;
272
277
  /** A JSON request through the transport, to an untyped path. */
273
278
  private json;
279
+ /** Attest `app` on node `url` (from {@link nodes}; default: in use): the record's `appHash` is the one the node bound. */
280
+ attestApp(app: string, url?: string): Promise<NodeVerification>;
281
+ /** The manifest facts and ABI of a package version (of `service`, for a multi-service release), for a signed-in caller. */
282
+ packageCapabilities(pkg: string, version: string, options?: {
283
+ service?: string;
284
+ }): Promise<PackageCapabilities>;
274
285
  /**
275
286
  * Create an account with a new passkey, and sign in. The node then asks the
276
287
  * new passkey to sign the account it creates (`412 CONFIRM_REQUIRED`), so a
@@ -144,6 +144,14 @@ export class CalimeroClient {
144
144
  get nodes() {
145
145
  return this.transport.nodes;
146
146
  }
147
+ /** What the check of node `url` (from {@link nodes}; default: in use) established, or `undefined` before it first ran. */
148
+ verification(url) {
149
+ return this.transport.verification(url);
150
+ }
151
+ /** Wait for the check requests wait for, starting it if needed, and answer its outcome (not thrown) without a request. */
152
+ verify(url) {
153
+ return this.transport.verify(url);
154
+ }
147
155
  /** Authenticate every request with an API key. */
148
156
  useApiKey(key) {
149
157
  this.transport.useApiKey(key);
@@ -158,6 +166,14 @@ export class CalimeroClient {
158
166
  json(method, path, body) {
159
167
  return this.transport.json(method, path, { body });
160
168
  }
169
+ /** Attest `app` on node `url` (from {@link nodes}; default: in use): the record's `appHash` is the one the node bound. */
170
+ attestApp(app, url) {
171
+ return this.transport.attestApp(app, url);
172
+ }
173
+ /** The manifest facts and ABI of a package version (of `service`, for a multi-service release), for a signed-in caller. */
174
+ packageCapabilities(pkg, version, options = {}) {
175
+ return this.transport.json('GET', routePath('packages/{package}/{version}/capabilities', { package: pkg, version }), { query: { service: options.service } });
176
+ }
161
177
  // ---------------------------------------------------------------- identity
162
178
  /**
163
179
  * Create an account with a new passkey, and sign in. The node then asks the
@@ -6,12 +6,13 @@ export type { DirectoryFailure } from '../runtime/directory.js';
6
6
  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
7
  export type { Committed, SignUpRefusal } from '../runtime/errors.js';
8
8
  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 { claimedRelease, fetchAttestedKey, freshCollateral, MOCK_QUOTE_HEADER } from '../runtime/attestation.js';
10
- export type { AttestationDoc, NodePolicy, NodeReleasePolicy } from '../runtime/attestation.js';
9
+ export type { AppAbi, AppAbiMethod, AppMethodKind, PackageCapabilities } from './package-capabilities.js';
10
+ export { claimedRelease, fetchAttestedKey, freshCollateral, MOCK_QUOTE_HEADER, verifyNode } from '../runtime/attestation.js';
11
+ export type { AttestationDoc, NodePolicy, NodeReleasePolicy, NodeVerification } from '../runtime/attestation.js';
11
12
  export { browserPasskey, b64url, fromB64url, passkeyConfirm } from '../runtime/passkey.js';
12
13
  export { MAX_RECOVERY_NONCE_BYTES, RECOVERY_DOMAIN, newRecoverySeed, parseRecoverySeed, recoveryMessage, recoveryPublicKey, recoverySeedText, signRecovery, } from './recovery-key.js';
13
14
  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';
15
+ 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
16
  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
17
  export { DEFAULT_ORG_CAPABILITIES, ORG_CAPABILITIES, orgCapabilities } from './capabilities.js';
17
18
  export type { OrgCapability } from './capabilities.js';
@@ -11,8 +11,8 @@ export { CalimeroClient, FILE_PART_BYTES, deployerKey, frontendManifest, pageDep
11
11
  export { ExportError } from './files.js';
12
12
  export { DEFAULT_DIRECTORY, DirectoryError } from '../runtime/directory.js';
13
13
  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';
14
+ export { claimedRelease, fetchAttestedKey, freshCollateral, MOCK_QUOTE_HEADER, verifyNode } from '../runtime/attestation.js';
15
15
  export { browserPasskey, b64url, fromB64url, passkeyConfirm } from '../runtime/passkey.js';
16
16
  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';
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';
18
18
  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,2 @@
1
+ /** What `GET /packages/{package}/{version}/capabilities` answers: a package version's manifest facts and its app's ABI. */
2
+ export {};