@calimero-network/mero-js 30.1.0 → 31.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 +7 -14
- package/dist/{cloud-v2 → client}/approvals.d.ts +4 -85
- package/dist/{cloud-v2 → client}/approvals.js +4 -3
- package/dist/{cloud-v2/client.d.ts → client/calimero-client.d.ts} +32 -268
- package/dist/{cloud-v2/client.js → client/calimero-client.js} +19 -19
- package/dist/{cloud-v2 → client}/capabilities.d.ts +2 -2
- package/dist/{cloud-v2 → client}/capabilities.js +2 -2
- package/dist/client/index.d.ts +15 -0
- package/dist/client/index.js +17 -0
- package/dist/{cloud-v2/recovery.js → client/recovery-key.js} +1 -1
- package/dist/generated/methods.d.ts +3 -3
- package/dist/generated/methods.js +1 -1
- package/dist/index.browser.mjs +3 -3
- package/dist/index.browser.mjs.map +4 -4
- package/dist/index.cjs +74 -84
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -9
- package/dist/index.mjs +74 -84
- package/dist/index.mjs.map +4 -4
- package/dist/routes/index.d.ts +8 -0
- package/dist/routes/index.js +23 -0
- package/dist/{api/operation.d.ts → routes/method.d.ts} +4 -3
- package/dist/{api/operation.js → routes/method.js} +1 -1
- package/dist/{api/client.d.ts → routes/route-client.d.ts} +16 -15
- package/dist/{api/client.js → routes/route-client.js} +7 -7
- package/dist/routes/step-up.d.ts +39 -0
- package/dist/{api → routes}/step-up.js +0 -54
- package/dist/{cloud-v2 → runtime}/attestation.d.ts +5 -5
- package/dist/runtime/index.d.ts +8 -8
- package/dist/runtime/index.js +10 -7
- package/dist/{cloud-v2 → runtime}/passkey.d.ts +43 -0
- package/dist/{cloud-v2 → runtime}/passkey.js +53 -0
- package/dist/runtime/transport.d.ts +17 -17
- package/dist/runtime/transport.js +8 -8
- package/dist/runtime.browser.mjs +1 -0
- package/dist/runtime.cjs +1 -0
- package/dist/runtime.mjs +1 -0
- package/dist/sealed/release.d.ts +1 -1
- package/dist/sealed/release.js +1 -1
- package/package.json +3 -4
- package/dist/api/index.d.ts +0 -10
- package/dist/api/index.js +0 -9
- package/dist/api/step-up.d.ts +0 -81
- package/dist/cloud-v2/index.d.ts +0 -15
- package/dist/cloud-v2/index.js +0 -8
- /package/dist/{cloud-v2/recovery.d.ts → client/recovery-key.d.ts} +0 -0
- /package/dist/{api → routes}/types.d.ts +0 -0
- /package/dist/{api → routes}/types.js +0 -0
- /package/dist/{cloud-v2 → runtime}/attestation.js +0 -0
- /package/dist/{cloud-v2 → runtime}/directory.d.ts +0 -0
- /package/dist/{cloud-v2 → runtime}/directory.js +0 -0
- /package/dist/{cloud-v2 → runtime}/errors.d.ts +0 -0
- /package/dist/{cloud-v2 → runtime}/errors.js +0 -0
package/README.md
CHANGED
|
@@ -172,17 +172,10 @@ await client.apps.blobUpload({ app, body: bytes, contentType: 'image/png' });
|
|
|
172
172
|
(`x-calimero-user-verification`: `preferred` for the sign-up's confirmation,
|
|
173
173
|
`required` elsewhere).
|
|
174
174
|
- **Streams** (`events`, `presenceStream`) stay hand-written on the runtime.
|
|
175
|
-
- `createRoutes(
|
|
176
|
-
the same groups on any `NodeTransport`.
|
|
177
|
-
|
|
178
|
-
`
|
|
179
|
-
client the methods run on (`client.api.GET('/orgs/{org}', { params: { path: {
|
|
180
|
-
org } } })` answers `{ data, error, response }`). Its `fetch` is
|
|
181
|
-
`transportFetch(transport)`: the path, query and body go through the transport
|
|
182
|
-
(sealed, with the credential), and the two routes served in the clear
|
|
183
|
-
(`/attestation`, `/health`) go unsealed. `stepUp(...)` and
|
|
184
|
-
`operatorSignature(...)` are its middleware; `unwrap(result)` throws a refusal.
|
|
185
|
-
Apps should not write against it.
|
|
175
|
+
- `createRoutes(createRouteClient(transport, { confirm, operatorProof }))` builds
|
|
176
|
+
the same groups on any `NodeTransport`. The route client under them sends each
|
|
177
|
+
request through the transport (sealed, with the credential; `/attestation` and
|
|
178
|
+
`/health` in the clear); write against the groups, not against it.
|
|
186
179
|
|
|
187
180
|
The single-route methods of 29.x (`createOrg`, `call`, ...) are gone; see
|
|
188
181
|
[Upgrading from 29.x](#upgrading-from-29x). The ceremonies (`signUp`, `signIn`, `addPasskey`,
|
|
@@ -195,7 +188,7 @@ layer of your own:
|
|
|
195
188
|
interface Transport {
|
|
196
189
|
request(method: HttpMethod, path: string, options?: RequestOptions): Promise<Response>; // 2xx, body unread
|
|
197
190
|
json<T>(method: HttpMethod, path: string, options?: RequestOptions): Promise<T>;
|
|
198
|
-
events(path: string, options?: { query?; signal? }): AsyncGenerator<
|
|
191
|
+
events(path: string, options?: { query?; signal? }): AsyncGenerator<NodeEvent>;
|
|
199
192
|
}
|
|
200
193
|
// RequestOptions: { query?, body? (JSON) | bytes? + contentType?, passkey? (answers a 412),
|
|
201
194
|
// userVerification?, retry?: true | 'once' (D70), signal?, promptSignal? }
|
|
@@ -362,11 +355,11 @@ pnpm typecheck
|
|
|
362
355
|
pnpm typecheck:consumer
|
|
363
356
|
```
|
|
364
357
|
|
|
365
|
-
The cluster tests (`tests/
|
|
358
|
+
The cluster tests (`tests/cluster`) start three `merod run --dev` nodes and
|
|
366
359
|
run the client against them:
|
|
367
360
|
|
|
368
361
|
```bash
|
|
369
|
-
MEROD_BINARY=/path/to/merod KV_STORE_WASM=/path/to/kv_store.wasm pnpm test:
|
|
362
|
+
MEROD_BINARY=/path/to/merod KV_STORE_WASM=/path/to/kv_store.wasm pnpm test:cluster
|
|
370
363
|
```
|
|
371
364
|
|
|
372
365
|
Without the variables they use `../core/target/debug/merod` and
|
|
@@ -14,7 +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 '../
|
|
17
|
+
import type { ApiAnswer } from '../routes/types.js';
|
|
18
18
|
/**
|
|
19
19
|
* Who holds one decision on a cluster (core's `Authority`), fixed at genesis
|
|
20
20
|
* and attested by every replica. `owner`: the parties around each app, with a
|
|
@@ -32,16 +32,6 @@ export interface Governance {
|
|
|
32
32
|
/** Who grants deployers: the operator (left out) or the cluster's owner. */
|
|
33
33
|
deployers?: 'operator' | 'owner';
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Who upgrades a package's instances, as its signed manifest declares
|
|
37
|
-
* (`upgrades`; absent means `owner`), where the cluster leaves app upgrades to
|
|
38
|
-
* owners. `owner`: each instance's owner (an organization's
|
|
39
|
-
* `MANAGE_APPLICATION` holders); `publisher`: the `MANAGE_APPLICATION`
|
|
40
|
-
* holders of the organization the package's signing key is bound to, for
|
|
41
|
-
* every instance ({@link CalimeroClient.upgradePublished}). A package may move
|
|
42
|
-
* from `publisher` to `owner` in a later release, never back.
|
|
43
|
-
*/
|
|
44
|
-
export type UpgradeAuthority = 'owner' | 'publisher';
|
|
45
35
|
/** Whose approvals a report covers: an organization's, or the account's own apps. */
|
|
46
36
|
export type ReportScope = {
|
|
47
37
|
kind: 'account';
|
|
@@ -49,13 +39,6 @@ export type ReportScope = {
|
|
|
49
39
|
kind: 'org';
|
|
50
40
|
org: string;
|
|
51
41
|
};
|
|
52
|
-
/** A package release as a report names it. */
|
|
53
|
-
export interface ReportedRelease {
|
|
54
|
-
package: string;
|
|
55
|
-
version: string;
|
|
56
|
-
/** The service, for a multi-service bundle (account reports only). */
|
|
57
|
-
service?: string | null;
|
|
58
|
-
}
|
|
59
42
|
/** A bundle as a report names it: its digest, and its release where the reader may see it. */
|
|
60
43
|
export interface ReportedBundle {
|
|
61
44
|
bundle: string;
|
|
@@ -64,25 +47,6 @@ export interface ReportedBundle {
|
|
|
64
47
|
}
|
|
65
48
|
/** Who made an upgrade, by kind. */
|
|
66
49
|
export type ActorKind = 'owner' | 'member' | 'operator';
|
|
67
|
-
/** An app's last upgrade. `actor`, `error` and `run` are left out of the operator's report. */
|
|
68
|
-
export interface LastUpgrade {
|
|
69
|
-
from: ReportedBundle;
|
|
70
|
-
to: ReportedBundle;
|
|
71
|
-
/** Unix seconds. */
|
|
72
|
-
at: number;
|
|
73
|
-
ok: boolean;
|
|
74
|
-
actorKind: ActorKind;
|
|
75
|
-
actor?: string;
|
|
76
|
-
error?: unknown;
|
|
77
|
-
run?: string;
|
|
78
|
-
}
|
|
79
|
-
/** One replica of an app: its node, the node's attested release, and whether the app's set approves it. */
|
|
80
|
-
export interface ReportedReplica {
|
|
81
|
-
node: number;
|
|
82
|
-
/** `null` while the node's release is not known yet (it then holds nothing). */
|
|
83
|
-
release: string | null;
|
|
84
|
-
approved: boolean;
|
|
85
|
-
}
|
|
86
50
|
/** A replica's node whose runtime is older than a release needs, and what it runs: the version, or `{ before }` for a node on a release from before nodes named their runtime. */
|
|
87
51
|
export interface RuntimeShortNode {
|
|
88
52
|
node: number;
|
|
@@ -106,18 +70,8 @@ export interface LatestBlocked {
|
|
|
106
70
|
}
|
|
107
71
|
/** One app in a report. `name`, `team`, `availableVersions`, `latestReachable` and `latestBlocked` are in members' and accounts' reports only. */
|
|
108
72
|
export type ReportedApp = ApiAnswer<'org_apps'>['apps'][number];
|
|
109
|
-
/** A mero-tee release the cluster's nodes run, with how many and whether the scope approved it. */
|
|
110
|
-
export interface ClusterRelease {
|
|
111
|
-
release: string;
|
|
112
|
-
nodes: number;
|
|
113
|
-
approved: boolean;
|
|
114
|
-
}
|
|
115
73
|
/** `GET /auth/apps` or `GET /orgs/{org}/apps`: one page. */
|
|
116
74
|
export type AppsReport = ApiAnswer<'org_apps'>;
|
|
117
|
-
/** `GET /ops/apps`: one page, for the operator. */
|
|
118
|
-
export type OpsAppsReport = ApiAnswer<'ops_apps'>;
|
|
119
|
-
/** `GET /ops/orgs`: one page, for the operator. */
|
|
120
|
-
export type OpsOrgsReport = ApiAnswer<'ops_orgs'>;
|
|
121
75
|
/** A page of a report: entries after the id `after`, at most `limit` (1 to {@link MAX_REPORT_PAGE}). */
|
|
122
76
|
export interface PageOptions {
|
|
123
77
|
after?: string;
|
|
@@ -147,26 +101,16 @@ export declare function compareVersions(a: string, b: string): number;
|
|
|
147
101
|
* (unrestricted) is never stalled.
|
|
148
102
|
*/
|
|
149
103
|
export declare function stalledBy(approved: string[] | null, deadlines: ReleaseDeadline[], now?: number): ReleaseDeadline | null;
|
|
150
|
-
/** `GET /publishers/{signerId}`: what a key signs to bind it here next. */
|
|
151
|
-
export type PublisherBindingInfo = ApiAnswer<'publisher_binding'>;
|
|
152
104
|
/**
|
|
153
105
|
* The text a package signing key signs to bind it to `org` as its publisher
|
|
154
106
|
* (core's `system::publisher_binding_message`). Take `cluster` and
|
|
155
|
-
* `generation` from
|
|
107
|
+
* `generation` from `client.public.publisherBinding`; sign the UTF-8
|
|
156
108
|
* bytes with the key's Ed25519 secret and send
|
|
157
|
-
*
|
|
109
|
+
* `client.orgs.publisher`.
|
|
158
110
|
*/
|
|
159
111
|
export declare function publisherBindingMessage(cluster: string, org: string, signerId: string, generation: number): string;
|
|
160
112
|
/** {@link publisherBindingMessage} as the bytes to sign. */
|
|
161
113
|
export declare function publisherBindingBytes(cluster: string, org: string, signerId: string, generation: number): Uint8Array;
|
|
162
|
-
/** `POST /orgs/{org}/publishers`: the key's proof, base64url without padding. */
|
|
163
|
-
export interface PublisherProof {
|
|
164
|
-
signerId: string;
|
|
165
|
-
/** The Ed25519 public key the `did:key` names. */
|
|
166
|
-
publicKey: string;
|
|
167
|
-
/** Its signature over {@link publisherBindingMessage}. */
|
|
168
|
-
signature: string;
|
|
169
|
-
}
|
|
170
114
|
/** Whose approval a release or outbound request is for. */
|
|
171
115
|
export type ConsentScope = 'account' | {
|
|
172
116
|
org: string;
|
|
@@ -220,13 +164,12 @@ export interface OpenConsentOptions {
|
|
|
220
164
|
* {@link ConsentStarted.code} to check the node's answer.
|
|
221
165
|
*/
|
|
222
166
|
export declare function confirmationCode(requestId: string): Promise<string>;
|
|
223
|
-
export type ConsentStatus = 'pending' | 'approved' | 'declined';
|
|
224
167
|
/** `GET /consent/{id}/result`. */
|
|
225
168
|
export type ConsentResult = ApiAnswer<'consent_page_result'>;
|
|
226
169
|
/**
|
|
227
170
|
* What the consent page put on `returnTo` when it sent the person back, or
|
|
228
171
|
* `null` when `href` carries none. A hint only (anyone can type a URL): confirm
|
|
229
|
-
* with
|
|
172
|
+
* with `client.consent.pageResult` before acting on it.
|
|
230
173
|
*/
|
|
231
174
|
export declare function consentReturn(href: string | URL): {
|
|
232
175
|
requestId: string;
|
|
@@ -303,29 +246,5 @@ export declare function releaseConsent(scope: ReportScope, version: string, retu
|
|
|
303
246
|
* stays pending), and the page warns before.
|
|
304
247
|
*/
|
|
305
248
|
export declare function withdrawConsent(scope: ReportScope, version: string, returnTo: string): ConsentRequest;
|
|
306
|
-
/**
|
|
307
|
-
* The `release` part of a release request's model, as the consent page reads
|
|
308
|
-
* it (`GET /consent/{id}/model`, on the node's origin; the app never needs
|
|
309
|
-
* it). An approval carries the release's signed measurements; a withdrawal
|
|
310
|
-
* carries none, and says whether the release is approved now and whether it
|
|
311
|
-
* is the scope's last approved release (which cannot be withdrawn).
|
|
312
|
-
*/
|
|
313
|
-
export type ConsentReleaseModel = {
|
|
314
|
-
version: string;
|
|
315
|
-
change: 'approve';
|
|
316
|
-
alreadyApproved: boolean;
|
|
317
|
-
approved: unknown;
|
|
318
|
-
nodes: unknown;
|
|
319
|
-
profile: string | null;
|
|
320
|
-
measurements: Record<string, unknown>;
|
|
321
|
-
} | {
|
|
322
|
-
version: string;
|
|
323
|
-
change: 'withdraw';
|
|
324
|
-
currentlyApproved: boolean;
|
|
325
|
-
lastApproved: boolean;
|
|
326
|
-
approved: unknown;
|
|
327
|
-
nodes: unknown;
|
|
328
|
-
profile: string | null;
|
|
329
|
-
};
|
|
330
249
|
/** The consent request that upgrades `app` to `toVersion`. */
|
|
331
250
|
export declare function upgradeConsent(app: string, toVersion: string, returnTo: string): ConsentRequest;
|
|
@@ -60,12 +60,13 @@ export function stalledBy(approved, deadlines, now = Date.now() / 1000) {
|
|
|
60
60
|
}
|
|
61
61
|
return stall;
|
|
62
62
|
}
|
|
63
|
+
// ---------------------------------------------------------------- publishers
|
|
63
64
|
/**
|
|
64
65
|
* The text a package signing key signs to bind it to `org` as its publisher
|
|
65
66
|
* (core's `system::publisher_binding_message`). Take `cluster` and
|
|
66
|
-
* `generation` from
|
|
67
|
+
* `generation` from `client.public.publisherBinding`; sign the UTF-8
|
|
67
68
|
* bytes with the key's Ed25519 secret and send
|
|
68
|
-
*
|
|
69
|
+
* `client.orgs.publisher`.
|
|
69
70
|
*/
|
|
70
71
|
export function publisherBindingMessage(cluster, org, signerId, generation) {
|
|
71
72
|
return `calimero-publisher-binding/v1\n${cluster}\n${org}\n${signerId}\n${generation}`;
|
|
@@ -95,7 +96,7 @@ export async function confirmationCode(requestId) {
|
|
|
95
96
|
/**
|
|
96
97
|
* What the consent page put on `returnTo` when it sent the person back, or
|
|
97
98
|
* `null` when `href` carries none. A hint only (anyone can type a URL): confirm
|
|
98
|
-
* with
|
|
99
|
+
* with `client.consent.pageResult` before acting on it.
|
|
99
100
|
*/
|
|
100
101
|
export function consentReturn(href) {
|
|
101
102
|
const url = typeof href === 'string' ? new URL(href) : href;
|