@calimero-network/mero-js 29.17.0 → 30.0.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
@@ -29,7 +29,7 @@ quotes and is loaded on first use.
29
29
  ## Quick start
30
30
 
31
31
  ```ts
32
- import { CalimeroClient, browserPasskey } from '@calimero-network/mero-js';
32
+ import { CalimeroClient, browserPasskey, passkeyConfirm } from '@calimero-network/mero-js';
33
33
 
34
34
  // Reach a Calimero Cloud cluster by name.
35
35
  const client = await CalimeroClient.connect({
@@ -39,14 +39,14 @@ const client = await CalimeroClient.connect({
39
39
  });
40
40
 
41
41
  await client.signUp(browserPasskey(), 'alice'); // or signIn(browserPasskey())
42
- await client.installPackage('com.example.kv', '1.0.0'); // signed .mpk from the registry
43
- const app = await client.createApp('kv', { package: 'com.example.kv', version: '1.0.0' }, { confirmMethods: ['clear'] });
42
+ await client.packages.install({ package: 'com.example.kv', version: '1.0.0' }); // signed .mpk from the registry
43
+ const { appId: app } = await client.apps.create({ name: 'kv', package: 'com.example.kv', version: '1.0.0' });
44
44
 
45
- await client.call(app, 'set', { key: 'a', value: '1' });
46
- const { result } = await client.view(app, 'get', { key: 'a' });
47
- await client.callConfirmed(app, 'clear', {}, browserPasskey()); // passkey consent
45
+ await client.apps.call({ app, method: 'set', args: { key: 'a', value: '1' } });
46
+ const { result } = await client.apps.view({ app, method: 'get', args: { key: 'a' } });
47
+ await client.apps.call({ app, method: 'clear', args: {} }, { confirm: passkeyConfirm(browserPasskey()) }); // passkey consent
48
48
  for await (const event of client.events(app)) console.log(event);
49
- await client.upgradeApp(app, { version: '1.1.0' }, browserPasskey()); // the owner approves
49
+ await client.apps.upgrade({ app, version: '1.1.0' }, { confirm: passkeyConfirm(browserPasskey()) }); // the owner approves
50
50
  ```
51
51
 
52
52
  A development cluster (`merod local`, `merod run --dev`) sends mock quotes,
@@ -97,24 +97,18 @@ Pinned measurements go through `policy.verifyQuote` (`createQuoteVerifier`).
97
97
 
98
98
  ## The API
99
99
 
100
- Every route of the node is a generated method (`client.orgs.get({ org })`,
101
- [below](#the-runtime-and-the-route-layer)). The methods listed here are the
102
- hand-written ones, which now call those; the single-route ones are deprecated and
103
- go once the apps have moved.
104
-
105
-
106
- - **Credentials**: `signUp` (with an `invite`, on a cluster that takes new accounts by invite; `signUpPolicy` reads which), `signIn`, `refresh`, `signOut`, `signOutEverywhere`, `listSessions`, `revokeSession`, `listActivity`, `useSession`, `useApiKey`, `me`, `usage`, `addPasskey`, `labelPasskey`, `removePasskey`, `createApiKey`, `listApiKeys`, `revokeApiKey`. Adding or removing a passkey and creating an API key are approved with a passkey the account already has.
107
- - **Account recovery** (core #4844): `createRecoveryCode`, `removeRecoveryCode` (passkey-approved; the code is shown once), then signed out `startAccountRecovery(code, passkey)` and, 72 hours later, `finishAccountRecovery(passkey, accountId?)`; a passkey the account still has cancels in between (`cancelAccountRecovery`; `me()` shows `recoveryCode` and `recoveryPending`).
108
- - **Package origins**: `packageOrigins.list`, `packageOrigins.add`, `packageOrigins.remove`. A package's managers register the web origins of a frontend they host themselves (approved with a passkey); `signUp` and `signIn` on such a page send its origin, sign for that origin's relying-party id, and open a session bound to the package (`me()` answers its `app` and `origin`). An unregistered origin is refused with `OriginNotRegistered`. `packageOrigins.add(pkg, origin, passkey, { served: true })` registers a custom domain: the cluster also serves the package's frontend there from its signed bundle (`https://host`, no port; the passkey's consent names `served: true`); `list` answers `served` on each origin, and the extra refusals are `NotServing` (the cluster serves no frontends), `ClusterNotUpgraded` (a node is on an older release), `QuotaExceeded` (4 served per package, 64 per cluster) and `OriginTaken` (held with the other `served`).
109
- - **Packages**: `installPackage`, `uploadPackage`, `packages`, `package`, `uninstallPackage`; `uploadBundle` (raw WASM, development clusters only).
110
- - **Apps**: `createApp`, `listApps`, `getApp`, `deleteApp`, `setAccess`, `setAppMetadata`, `appStorage`, `appAbi`, `upgradeApp`, `transferApp`, `moveApp`.
111
- - **Calls**: `call`, `callConfirmed`, `view`, `events`. A call always carries an idempotency key, and is sent again with it while the node answers `503`, then to the next node.
112
- - **Blobs and presence**: `uploadBlob`, `downloadBlob`, `listBlobs`, `blobInfo`, `deleteBlob`; `publishPresence`, `presence`, `presenceStream`.
113
- - **Organizations**: `createOrg`, `getOrg`, `orgMembersSecurity` (owners and admins: each member's passkey count to `3+`, recovery code set, last active day, live sessions), `deleteOrg`, `setOrgMetadata`, `setMember`, `removeMember`, `setMemberMetadata`, `setCapabilities` (`ORG_CAPABILITIES`), `setTeamDefaultCapabilities`, teams, app teams (`listAppTeams`, `scopeApps`), `invite` (`{ allApps: true }`: whoever redeems it gets every app added later), `setAllApps` (owner or admin: every app added later, for a member), `redeemInvite`, `listInvites`, `revokeInvite`, recovery (`setRecoveryKey`, `startRecovery`, `cancelRecovery`, `finishRecovery`; `newRecoverySeed`, `recoveryPublicKey`). Setting or removing a member or team member, capabilities, invites (minting and revoking) and scoping apps are approved with the caller's passkey; redeeming an invite is not.
114
- - **Owner decisions** (passkey approval, never from an app's frontend): `upgradeOrg`, `upgradeRun`, `retryUpgradeRun`, `approveRelease`, `approveOutbound`, `bindPublisher`, `upgradePublished`.
115
- - **Approvals from an app**: `appsReport`, `releaseRules`, `pendingApprovals`, then `requestConsent` / `openConsentPage` to send the user to the node's consent page, and `consentResult`. Show the answer's `code` to the user before sending them to `url` (`openConsentPage`'s `confirm` hook); they should see the same code on the page (`confirmationCode(requestId)` checks it). See [Ask your users to approve node images and app upgrades](https://calimero-network.github.io/mero-js/guides/user-approvals/).
116
- - **Operator** (ops token): `opsApps`, `opsOrgs`, `opsServedOrigins` (every custom domain the log holds, by package label), `setReleaseDeadline`, `liftReleaseDeadline`.
117
- - **Any route**: its generated method (below). The untyped `get`, `post`, `put`, `delete`, `postConfirmed` and `deleteConfirmed` are deprecated.
100
+ Every route of the node is a generated method, in a group per area
101
+ (`client.apps`, `client.auth`, `client.orgs`, `client.packages`,
102
+ `client.deployments`, `client.consent`, `client.ops`, `client.public`); see
103
+ [below](#the-runtime-and-the-route-layer). The hand-written methods left are the
104
+ flows and streams a single route cannot be:
105
+
106
+ - **Credentials**: `signUp(passkey, name, { invite?, origin?, signal? })`, `signIn(passkey, { origin?, signal? })`, `refresh`, `signOut`, `signOutEverywhere`, `useSession`, `useApiKey`, `addPasskey(newPasskey, approver)`.
107
+ - **Account recovery** (core #4844): signed out, `startAccountRecovery(code, passkey)` and, 72 hours later, `finishAccountRecovery(passkey, accountId?)`. The code itself is `client.auth.recoveryCreate({}, { confirm })`.
108
+ - **Organization recovery**: `startRecovery(org, seed)` (the seed signs here and never leaves the process); `newRecoverySeed`, `recoveryPublicKey`.
109
+ - **Blobs**: `downloadBlob(app, id)`, `downloadBlobGranted(app, id, grant)` (bytes; `client.apps.blobDownload` answers a `Blob` with its type).
110
+ - **Streams**: `events(app, from?, signal?)`, `presenceStream(app, signal?)`.
111
+ - **Approvals from an app**: `pendingApprovals(org?)`, `appsReportAll(org)`, then `openConsentPage(request, …)` to send the user to the node's consent page, and `waitForConsent(requestId)`. Show the answer's `code` to the user before sending them to `url` (`openConsentPage`'s `confirm` hook); they should see the same code on the page (`confirmationCode(requestId)` checks it). See [Ask your users to approve node images and app upgrades](https://calimero-network.github.io/mero-js/guides/user-approvals/).
118
112
 
119
113
  Refusals are typed (`LoginRequired`, `PasskeyUnknownHere`, `WrongNode`, `NotFound`, `ConfirmRequired`, `ConfirmCancelled`, `ConfirmPromptBlocked`,
120
114
  `ArgsTooLarge`, `IdempotencyMismatch`, `ReleaseDeadlineError`, `RuntimeTooOld`, `ConsentStale`, `AppError`, `TrapError`,
@@ -190,9 +184,8 @@ org } } })` answers `{ data, error, response }`). Its `fetch` is
190
184
  `operatorSignature(...)` are its middleware; `unwrap(result)` throws a refusal.
191
185
  Apps should not write against it.
192
186
 
193
- The **hand-written methods** of `CalimeroClient` (`createOrg`, `call`, ...) are
194
- now thin calls onto the generated methods, kept, `@deprecated` (each names its
195
- replacement), until the apps have moved. The ceremonies (`signUp`, `signIn`, `addPasskey`,
187
+ The single-route methods of 29.x (`createOrg`, `call`, ...) are gone; see
188
+ [Upgrading from 29.x](#upgrading-from-29x). The ceremonies (`signUp`, `signIn`, `addPasskey`,
196
189
  account and organization recovery, `openConsentPage`, ...) stay as flows.
197
190
 
198
191
  The runtime's own surface toward routes is still one interface, for a route
@@ -222,6 +215,142 @@ fetches it again, records the commit and regenerates `src/generated/`;
222
215
  `pnpm check:api` fails when the generated types or methods are not those of the
223
216
  vendored document.
224
217
 
218
+ `.github/workflows/openapi-sync.yml` does this on its own: core sends a
219
+ `repository_dispatch` (`core-openapi`, with the core commit) whenever its
220
+ document changes, and a weekly run catches a missed one (or run it by hand with a
221
+ `ref`). When the document or the generated code changed, it opens or refreshes a
222
+ pull request on `chore/core-openapi` that lists the generated methods added,
223
+ removed or changed (`scripts/openapi-sync-summary.mjs`); a removed or renamed
224
+ one needs a major release.
225
+
226
+ It opens that pull request with a GitHub App's token, so the pull request's CI
227
+ runs: the organization's shared `vars.ACTIONS_APP_ID` /
228
+ `secrets.ACTIONS_APP_PRIVATE_KEY`, which must be shared with this repository. The
229
+ app must be installed on this repository
230
+ with contents and pull-requests write.
231
+
232
+ ## Upgrading from 29.x
233
+
234
+ 30.0 removes the single-route methods 29.x deprecated, and the untyped `get`,
235
+ `post`, `put`, `delete`, `postConfirmed` and `deleteConfirmed`. Each is a
236
+ generated method now, which takes one argument object and answers the route's
237
+ payload (pick the field the old method answered: `(await client.orgs.create({
238
+ name })).orgId`). A step-up takes `{ confirm: passkeyConfirm(passkey) }` as the
239
+ second argument. `client.packages` and `client.deployments` are groups, no longer
240
+ callable (`(await client.packages.list()).packages`).
241
+
242
+ | 29.x | 30.0 |
243
+ | --- | --- |
244
+ | `signUpPolicy()` | `client.deployments.signUpPublic()` |
245
+ | `listSessions()` | `(await client.auth.sessionsList()).sessions` |
246
+ | `revokeSession(session)` | `client.auth.sessionRevoke({ session })` |
247
+ | `listActivity(after)` | `(await client.auth.activityList({ after })).activity` |
248
+ | `me()` | `client.auth.me()` |
249
+ | `removePasskey(credentialId, passkey)` | `client.auth.passkeyRemove({ cred: credentialId }, { confirm: passkeyConfirm(passkey) })` |
250
+ | `labelPasskey(credentialId, label)` | `client.auth.passkeyLabel({ cred: credentialId, label })` |
251
+ | `createRecoveryCode(passkey)` | `(await client.auth.recoveryCreate({}, { confirm: passkeyConfirm(passkey) })).code` |
252
+ | `removeRecoveryCode(passkey)` | `client.auth.recoveryRemove({}, { confirm: passkeyConfirm(passkey) })` |
253
+ | `cancelAccountRecovery(passkey)` | `client.auth.accountRecoveryCancel({}, { confirm: passkeyConfirm(passkey) })` |
254
+ | `usage()` | `client.auth.usage()` |
255
+ | `attestation()` | `client.public.attestation({ nonce: '00'.repeat(32) })` |
256
+ | `listApiKeys()` | `(await client.auth.apikeyList()).keys` |
257
+ | `revokeApiKey(keyId, passkey)` | `client.auth.apikeyRevoke({ key: keyId }, { confirm: passkeyConfirm(passkey) })` |
258
+ | `createApiKey(options, passkey)` | `client.auth.apikeyCreate({ ...options }, { confirm: passkeyConfirm(passkey) })` |
259
+ | `uploadBundle(wasm)` | `(await client.packages.bundlePut({ body: wasm, contentType: 'application/wasm' })).hash` |
260
+ | `uploadBlob(app, data, contentType)` | `client.apps.blobUpload({ app, body: data, contentType })` |
261
+ | `blobContent(app, id, options)` | `client.apps.blobDownload({ app, id, grant })` (a `Blob`: `arrayBuffer()` and `type`) |
262
+ | `listBlobs(app)` | `(await client.apps.blobList({ app })).blobs` |
263
+ | `blobInfo(app, id)` | `client.apps.blobInfo({ app, id })` |
264
+ | `deleteBlob(app, id)` | `client.apps.blobDelete({ app, id })` |
265
+ | `uploadPackage(mpk)` | `client.packages.upload({ body: mpk, contentType: 'application/octet-stream' })` |
266
+ | `installPackage(pkg, version)` | `client.packages.install({ package: pkg, version })` |
267
+ | `packages()` | `(await client.packages.list()).packages` |
268
+ | `package(pkg)` | `client.packages.get({ package: pkg })` |
269
+ | `uninstallPackage(pkg, version)` | `client.packages.uninstall({ package: pkg })` or `client.packages.versionUninstall({ package: pkg, version })` |
270
+ | `listApps(filter)` | `(await client.apps.list({ ...filter })).apps` |
271
+ | `getApp(app)` | `client.apps.get({ app })` |
272
+ | `deleteApp(app)` | `client.apps.delete({ app })` |
273
+ | `setAccess(app, access)` | `client.apps.access({ app, access })` |
274
+ | `setAppMetadata(app, metadata)` | `client.apps.metadata({ app, metadata })` |
275
+ | `appXcalls(app)` | `client.apps.xcalls({ app })` |
276
+ | `appStorage(app)` | `client.apps.storage({ app })` |
277
+ | `appAbi(app)` | `client.apps.abi({ app })` |
278
+ | `transferApp(app, to, passkey)` | `client.apps.transfer({ app, to }, { confirm: passkeyConfirm(passkey) })` |
279
+ | `moveApp(app, toOrg, options, passkey)` | `client.apps.move({ app, toOrg, ...options }, { confirm: passkeyConfirm(passkey) })` |
280
+ | `upgradeApp(app, target, passkey)` | `client.apps.upgrade({ app, ...target }, { confirm: passkeyConfirm(passkey) })` |
281
+ | `createApp(name, bundle, options)` | `(await client.apps.create({ name, bundle, ...options })).appId` |
282
+ | `call(app, method, args, idempotencyKey)` | `client.apps.call({ app, method, args, idempotencyKey })` |
283
+ | `callConfirmed(app, method, args, passkey, idempotencyKey)` | `client.apps.call({ app, method, args, idempotencyKey }, { confirm: passkeyConfirm(passkey) })` |
284
+ | `view(app, method, args, options)` | `client.apps.view({ app, method, args, consistency: options.stale ? 'stale' : undefined, minIndex: options.minIndex })` |
285
+ | `publishPresence(app, seq, state)` | `client.apps.presencePublish({ app, seq, state: presenceState(state) })` |
286
+ | `presence(app)` | `(await client.apps.presenceGet({ app })).present` |
287
+ | `setAlias(alias, app)` | `client.auth.aliasSet({ alias, app })` |
288
+ | `aliases()` | `(await client.auth.aliasList()).aliases` |
289
+ | `alias(alias)` | `(await client.auth.aliasGet({ alias })).appId` |
290
+ | `deleteAlias(alias)` | `client.auth.aliasDelete({ alias })` |
291
+ | `createOrg(name, options)` | `(await client.orgs.create({ name, ...options })).orgId` |
292
+ | `setRecoveryKey(org, publicKey, passkey)` | `client.orgs.recoverySet({ org, publicKey }, { confirm: passkeyConfirm(passkey) })` |
293
+ | `cancelRecovery(org, passkey)` | `client.orgs.recoveryCancel({ org }, { confirm: passkeyConfirm(passkey) })` |
294
+ | `finishRecovery(org, passkey)` | `client.orgs.recoveryFinish({ org }, { confirm: passkeyConfirm(passkey) })` |
295
+ | `getOrg(org)` | `client.orgs.get({ org })` |
296
+ | `orgMembersSecurity(org)` | `(await client.orgs.members({ org, detail: 'security' })).members` |
297
+ | `deleteOrg(org, passkey)` | `client.orgs.delete({ org }, { confirm: passkeyConfirm(passkey) })` |
298
+ | `setOrgMetadata(org, metadata)` | `client.orgs.metadata({ org, metadata })` |
299
+ | `setMemberMetadata(org, account, metadata)` | `client.orgs.memberMetadata({ org, account, metadata })` |
300
+ | `upgradeOrg(org, target, passkey)` | `client.orgs.upgrade({ org, ...target }, { confirm: passkeyConfirm(passkey) })` |
301
+ | `upgradeRun(org, run)` | `client.orgs.upgradeStatus({ org, run })` |
302
+ | `retryUpgradeRun(org, run, passkey)` | `client.orgs.upgradeRetry({ org, run }, { confirm: passkeyConfirm(passkey) })` |
303
+ | `approveRelease(org, version, passkey, approved)` | `client.auth.accountReleaseApproval({ version, approved }, { confirm: passkeyConfirm(passkey) })` or `client.orgs.releaseApproval({ org, version, approved }, { confirm: passkeyConfirm(passkey) })` |
304
+ | `approveOutbound(org, pkg, passkey, options)` | `client.auth.accountOutboundApproval({ package: pkg, ...options }, { confirm: passkeyConfirm(passkey) })` or `client.orgs.outboundApproval({ org, package: pkg, ...options }, { confirm: passkeyConfirm(passkey) })` |
305
+ | `appsReport(org, page)` | `client.auth.accountApps({ ...page })` or `client.orgs.apps({ org, ...page })` |
306
+ | `releaseRules()` | `client.public.releasesPublic()` |
307
+ | `requestConsent(request)` | `client.consent.pageCreate({ body: request })` |
308
+ | `consentResult(requestId)` | `client.consent.pageResult({ request: requestId })` |
309
+ | `publisherBinding(signerId)` | `client.public.publisherBinding({ signer: signerId })` |
310
+ | `bindPublisher(org, proof, passkey)` | `client.orgs.publisher({ org, ...proof }, { confirm: passkeyConfirm(passkey) })` |
311
+ | `upgradePublished(org, pkg, target, passkey)` | `client.orgs.publisherUpgrade({ org, package: pkg, ...target }, { confirm: passkeyConfirm(passkey) })` |
312
+ | `opsApps(page)` | `client.ops.apps({ ...page })` |
313
+ | `opsOrgs(page)` | `client.ops.orgs({ ...page })` |
314
+ | `opsServedOrigins()` | `client.ops.served()` |
315
+ | `setReleaseDeadline(version, after)` | `client.ops.releaseDeadline({ version, after }) (after as an RFC 3339 string)` |
316
+ | `liftReleaseDeadline(version)` | `client.ops.releaseDeadlineLift({ version })` |
317
+ | `setMember(org, account, role, passkey)` | `client.orgs.setMember({ org, account, role }, { confirm: passkeyConfirm(passkey) })` |
318
+ | `removeMember(org, account, passkey)` | `client.orgs.removeMember({ org, account }, { confirm: passkeyConfirm(passkey) })` |
319
+ | `setCapabilities(org, capabilities, passkey, at)` | `client.orgs.capabilities({ org, capabilities, ...at }, { confirm: passkeyConfirm(passkey) })` |
320
+ | `setAllApps(org, account, allApps, passkey)` | `client.orgs.allApps({ org, account, allApps }, { confirm: passkeyConfirm(passkey) })` |
321
+ | `setTeamDefaultCapabilities(org, team, capabilities, passkey)` | `client.orgs.capabilities({ org, team, capabilities }, { confirm: passkeyConfirm(passkey) })` |
322
+ | `createTeam(org, name, join, parent)` | `(await client.orgs.teamCreate({ org, name, join, parent })).teamId` |
323
+ | `getTeam(org, team)` | `client.orgs.teamGet({ org, team })` |
324
+ | `updateTeam(org, team, update)` | `client.orgs.teamUpdate({ org, team, ...update })` |
325
+ | `deleteTeam(org, team, passkey)` | `client.orgs.teamDelete({ org, team }, { confirm: passkeyConfirm(passkey) })` |
326
+ | `setTeamMember(org, team, account, passkey, row)` | `client.orgs.teamSetMember({ org, team, account, ...row }, { confirm: passkeyConfirm(passkey) })` |
327
+ | `removeTeamMember(org, team, account, passkey)` | `client.orgs.teamRemoveMember({ org, team, account }, { confirm: passkeyConfirm(passkey) })` |
328
+ | `invite(org, role, passkey, teams, options)` | `(await client.orgs.inviteCreate({ org, role, teams, ...options }, { confirm: passkeyConfirm(passkey) })).token` |
329
+ | `redeemInvite(token)` | `client.orgs.inviteRedeem({ token })` |
330
+ | `listInvites(org)` | `(await client.orgs.inviteList({ org })).invites` |
331
+ | `revokeInvite(org, inviteKey, passkey)` | `client.orgs.inviteRevoke({ org, key: inviteKey }, { confirm: passkeyConfirm(passkey) })` |
332
+ | `listAppTeams(org)` | `client.orgs.appTeamList({ org })` |
333
+ | `scopeApps(org, passkey, options)` | `client.orgs.appTeamsScope({ org, ...options }, { confirm: passkeyConfirm(passkey) })` |
334
+ | `packageOrigins.list(pkg)` | `(await client.packages.originsList({ package: pkg })).origins` |
335
+ | `packageOrigins.add(pkg, origin, passkey, options)` | `client.packages.originsAdd({ package: pkg, origin, ...options }, { confirm: passkeyConfirm(passkey) })` |
336
+ | `packageOrigins.remove(pkg, origin, passkey)` | `client.packages.originsRemove({ package: pkg, origin }, { confirm: passkeyConfirm(passkey) })` |
337
+ | `grantDeployer(deployer, passkey, options)` | `client.deployments.deployerGrant({ deployer, ...options }, { confirm: passkeyConfirm(passkey) }) (until as an RFC 3339 string)` |
338
+ | `deployers()` | `client.deployments.deployerList()` |
339
+ | `revokeDeployer(deployer, passkey)` | `client.deployments.deployerRevoke({ key: deployerKey(deployer) }, { confirm: passkeyConfirm(passkey) })` (or the key string itself) |
340
+ | `createDeployment(name, owner, passkey)` | `(await client.deployments.create({ name, owner }, { confirm: passkeyConfirm(passkey) })).id` |
341
+ | `deployments()` | `(await client.deployments.list()).deployments` |
342
+ | `deployment(id)` | `client.deployments.get({ id })` |
343
+ | `deleteDeployment(id, passkey)` | `client.deployments.delete({ id }, { confirm: passkeyConfirm(passkey) })` |
344
+ | `offerApp(id, offer, passkey)` | `client.deployments.offer({ id, ...offer }, { confirm: passkeyConfirm(passkey) })` |
345
+ | `withdrawApp(id, app, passkey)` | `client.deployments.withdraw({ id, app }, { confirm: passkeyConfirm(passkey) })` |
346
+ | `deploymentOrgs(id)` | `client.deployments.orgs({ id })` |
347
+ | `get(path)` | the route's generated method: `client.get('orgs/' + org)` → `client.orgs.get({ org })` |
348
+ | `post(path, body)` | the route's generated method: `client.post('orgs', { name })` → `client.orgs.create({ name })` |
349
+ | `put(path, body)` | the route's generated method: `client.put('auth/aliases/' + alias, { app })` → `client.auth.aliasSet({ alias, app })` |
350
+ | `delete(path, body)` | the route's generated method: `client.delete('apps/' + app)` → `client.apps.delete({ app })` |
351
+ | `postConfirmed(path, body, passkey)` | the route's generated method with `{ confirm: passkeyConfirm(passkey) }`: `client.postConfirmed('orgs/' + org + '/upgrade', body, passkey)` → `client.orgs.upgrade({ org, ...body }, { confirm: passkeyConfirm(passkey) })` |
352
+ | `deleteConfirmed(path, passkey, body)` | the route's generated method with `{ confirm: passkeyConfirm(passkey) }`: `client.deleteConfirmed('orgs/' + org, passkey)` → `client.orgs.delete({ org }, { confirm: passkeyConfirm(passkey) })` |
353
+
225
354
  ## Development
226
355
 
227
356
  ```bash
@@ -3,6 +3,7 @@ export type { ApiClient, ApiClientOptions, ApiPaths, ApiResult, ApiTransport, Mi
3
3
  export { operatorSignature, passkeyConfirm, promptFailure, stepUp, userVerificationOf } from './step-up.js';
4
4
  export type { ConfirmCallback, ConfirmChallenge, OperatorProof, OperatorProofCallback, OperatorStatement, PasskeyConfirmOptions, } from './step-up.js';
5
5
  export { route } from './operation.js';
6
+ export type { ApiAnswer, ApiSchema } from './types.js';
6
7
  export type { MethodOptions, RawBody, RouteShape } from './operation.js';
7
8
  export { createRoutes } from '../generated/methods.js';
8
9
  export type { AppsRoutes, AuthRoutes, ConsentRoutes, DeploymentsRoutes, OpsRoutes, OrgsRoutes, PackagesRoutes, PublicRoutes, Routes, } from '../generated/methods.js';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Names for the generated types: a component of core's OpenAPI document, and
3
+ * the success payload of one of its operations. The types themselves are
4
+ * generated (`src/generated/api.ts`).
5
+ */
6
+ import type { components, operations } from '../generated/api.js';
7
+ /** A shared shape of the node's API (`#/components/schemas/{name}`). */
8
+ export type ApiSchema<K extends keyof components['schemas']> = components['schemas'][K];
9
+ /** What operation `K` answers on success (its `200` JSON body). */
10
+ export type ApiAnswer<K extends keyof operations> = operations[K] extends {
11
+ responses: {
12
+ 200: {
13
+ content: {
14
+ 'application/json': infer T;
15
+ };
16
+ };
17
+ };
18
+ } ? T : never;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Names for the generated types: a component of core's OpenAPI document, and
3
+ * the success payload of one of its operations. The types themselves are
4
+ * generated (`src/generated/api.ts`).
5
+ */
6
+ export {};
@@ -14,6 +14,7 @@
14
14
  * [consent page](https://calimero-network.github.io/core/protocol/consent-page/)
15
15
  * and [governance](https://calimero-network.github.io/core/protocol/governance/).
16
16
  */
17
+ import type { ApiAnswer } from '../api/types.js';
17
18
  /**
18
19
  * Who holds one decision on a cluster (core's `Authority`), fixed at genesis
19
20
  * and attested by every replica. `owner`: the parties around each app, with a
@@ -104,35 +105,7 @@ export interface LatestBlocked {
104
105
  nodes?: RuntimeShortNode[];
105
106
  }
106
107
  /** One app in a report. `name`, `team`, `availableVersions`, `latestReachable` and `latestBlocked` are in members' and accounts' reports only. */
107
- export interface ReportedApp {
108
- app: string;
109
- group: number;
110
- scope: ReportScope;
111
- /** `hex(SHA-256)` of the WASM it runs. */
112
- bundle: string;
113
- package: ReportedRelease | null;
114
- /** The package's pinned signer (`did:key`). */
115
- publisher: {
116
- signer: string;
117
- } | null;
118
- upgradesHeldBy: Authority;
119
- lastUpgrade: LastUpgrade | null;
120
- /** The releases approved to hold this app (its publisher's set, or its scope's); `null`: unrestricted. */
121
- approvedReleases: string[] | null;
122
- replicas: ReportedReplica[];
123
- name?: string;
124
- team?: string;
125
- /** Newer releases of its package it may be upgraded to, oldest first (at most 16, the newest). */
126
- availableVersions?: string[];
127
- /**
128
- * The newest of every newer release it may see that an upgrade would take
129
- * now, which may be older than all of `availableVersions`; `null` when none
130
- * would. Absent from a node before core 1.0.0-rc.16.
131
- */
132
- latestReachable?: string | null;
133
- /** Present when the newest release it may see is not `latestReachable`: which, and why. */
134
- latestBlocked?: LatestBlocked;
135
- }
108
+ export type ReportedApp = ApiAnswer<'org_apps'>['apps'][number];
136
109
  /** A mero-tee release the cluster's nodes run, with how many and whether the scope approved it. */
137
110
  export interface ClusterRelease {
138
111
  release: string;
@@ -140,34 +113,11 @@ export interface ClusterRelease {
140
113
  approved: boolean;
141
114
  }
142
115
  /** `GET /auth/apps` or `GET /orgs/{org}/apps`: one page. */
143
- export interface AppsReport {
144
- scope: ReportScope;
145
- governance: Governance;
146
- /** The scope's own approved set, newest last; `null`: none ever recorded (unrestricted). */
147
- approvedReleases: string[] | null;
148
- clusterReleases: ClusterRelease[];
149
- apps: ReportedApp[];
150
- /** Pass as `after` for the next page; `null` on the last. */
151
- next: string | null;
152
- }
116
+ export type AppsReport = ApiAnswer<'org_apps'>;
153
117
  /** `GET /ops/apps`: one page, for the operator. */
154
- export interface OpsAppsReport {
155
- /** This node had caught up with the system leader. */
156
- fresh: boolean;
157
- governance: Governance;
158
- apps: ReportedApp[];
159
- next: string | null;
160
- }
118
+ export type OpsAppsReport = ApiAnswer<'ops_apps'>;
161
119
  /** `GET /ops/orgs`: one page, for the operator. */
162
- export interface OpsOrgsReport {
163
- fresh: boolean;
164
- governance: Governance;
165
- orgs: Array<{
166
- org: string;
167
- approvedReleases: string[] | null;
168
- }>;
169
- next: string | null;
170
- }
120
+ export type OpsOrgsReport = ApiAnswer<'ops_orgs'>;
171
121
  /** A page of a report: entries after the id `after`, at most `limit` (1 to {@link MAX_REPORT_PAGE}). */
172
122
  export interface PageOptions {
173
123
  after?: string;
@@ -186,11 +136,7 @@ export interface ReleaseDeadline {
186
136
  afterSecs: number;
187
137
  }
188
138
  /** `GET /releases`: the cluster's release rules, public inside the sealed channel. */
189
- export interface ReleaseRules {
190
- governance: Governance;
191
- /** Oldest release first. */
192
- deadlines: ReleaseDeadline[];
193
- }
139
+ export type ReleaseRules = ApiAnswer<'releases_public'>;
194
140
  /** Semver order (core's `compare_versions`); text order for versions that are not semver. */
195
141
  export declare function compareVersions(a: string, b: string): number;
196
142
  /**
@@ -202,14 +148,7 @@ export declare function compareVersions(a: string, b: string): number;
202
148
  */
203
149
  export declare function stalledBy(approved: string[] | null, deadlines: ReleaseDeadline[], now?: number): ReleaseDeadline | null;
204
150
  /** `GET /publishers/{signerId}`: what a key signs to bind it here next. */
205
- export interface PublisherBindingInfo {
206
- signerId: string;
207
- /** The cluster's name, as the binding message names it. */
208
- cluster: string;
209
- /** How many bindings the key has had here: a signature binds once. */
210
- generation: number;
211
- bound: boolean;
212
- }
151
+ export type PublisherBindingInfo = ApiAnswer<'publisher_binding'>;
213
152
  /**
214
153
  * The text a package signing key signs to bind it to `org` as its publisher
215
154
  * (core's `system::publisher_binding_message`). Take `cluster` and
@@ -261,21 +200,7 @@ export type ConsentRequest = {
261
200
  returnTo: string;
262
201
  };
263
202
  /** The node's answer to a consent request: send the person to `url`. */
264
- export interface ConsentStarted {
265
- requestId: string;
266
- /** The consent page, on the node's own origin. */
267
- url: string;
268
- /** Unix seconds; a request lives 10 minutes. */
269
- expiresAt: number;
270
- /**
271
- * The confirmation code the consent page shows, `XXX-XXX`
272
- * ({@link confirmationCode} of `requestId`). Show it to the person before
273
- * sending them to `url`: the page they land on should show the same code,
274
- * which tells them it is the page their request opened. Not a secret.
275
- * Nodes older than the code leave it out.
276
- */
277
- code?: string;
278
- }
203
+ export type ConsentStarted = ApiAnswer<'consent_page_create'>;
279
204
  /** How {@link CalimeroClient.openConsentPage} sends the person to the page. */
280
205
  export interface OpenConsentOptions {
281
206
  /** Sends the browser to the page's `url`; by default `window.location.assign`. */
@@ -297,13 +222,7 @@ export interface OpenConsentOptions {
297
222
  export declare function confirmationCode(requestId: string): Promise<string>;
298
223
  export type ConsentStatus = 'pending' | 'approved' | 'declined';
299
224
  /** `GET /consent/{id}/result`. */
300
- export interface ConsentResult {
301
- requestId: string;
302
- kind: ConsentRequest['kind'];
303
- status: ConsentStatus;
304
- /** Unix seconds, once decided. */
305
- decidedAt: number | null;
306
- }
225
+ export type ConsentResult = ApiAnswer<'consent_page_result'>;
307
226
  /**
308
227
  * What the consent page put on `returnTo` when it sent the person back, or
309
228
  * `null` when `href` carries none. A hint only (anyone can type a URL): confirm