@calimero-network/mero-js 26.11.0 → 27.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.
Files changed (220) hide show
  1. package/README.md +73 -288
  2. package/dist/cloud-v2/attestation.d.ts +91 -0
  3. package/dist/cloud-v2/attestation.js +135 -0
  4. package/dist/cloud-v2/capabilities.d.ts +30 -0
  5. package/dist/cloud-v2/capabilities.js +31 -0
  6. package/dist/cloud-v2/client.d.ts +426 -0
  7. package/dist/cloud-v2/client.js +646 -0
  8. package/dist/cloud-v2/errors.d.ts +98 -0
  9. package/dist/cloud-v2/errors.js +165 -0
  10. package/dist/cloud-v2/index.d.ts +10 -0
  11. package/dist/cloud-v2/index.js +5 -0
  12. package/dist/cloud-v2/passkey.d.ts +27 -0
  13. package/dist/cloud-v2/passkey.js +73 -0
  14. package/dist/crypto/internal.d.ts +3 -37
  15. package/dist/crypto/internal.js +3 -72
  16. package/dist/index.browser.mjs +4 -2
  17. package/dist/index.browser.mjs.map +4 -4
  18. package/dist/index.cjs +1750 -12772
  19. package/dist/index.cjs.map +4 -4
  20. package/dist/index.d.ts +3 -56
  21. package/dist/index.js +14 -75
  22. package/dist/index.mjs +1750 -12772
  23. package/dist/index.mjs.map +4 -4
  24. package/dist/sealed/index.d.ts +4 -4
  25. package/dist/sealed/index.js +2 -2
  26. package/dist/sealed/release.d.ts +21 -76
  27. package/dist/sealed/release.js +24 -108
  28. package/dist/sealed/sealed.d.ts +8 -56
  29. package/dist/sealed/sealed.js +11 -89
  30. package/dist/sealed/verify.d.ts +7 -13
  31. package/dist/sealed/verify.js +3 -7
  32. package/package.json +8 -13
  33. package/dist/account/account-admin.d.ts +0 -80
  34. package/dist/account/account-admin.js +0 -346
  35. package/dist/account/account.d.ts +0 -196
  36. package/dist/account/account.js +0 -269
  37. package/dist/account/application-id.d.ts +0 -50
  38. package/dist/account/application-id.js +0 -83
  39. package/dist/account/bootstrap-from-invitation.d.ts +0 -110
  40. package/dist/account/bootstrap-from-invitation.js +0 -80
  41. package/dist/account/create-context.d.ts +0 -103
  42. package/dist/account/create-context.js +0 -267
  43. package/dist/account/govern.d.ts +0 -24
  44. package/dist/account/govern.js +0 -50
  45. package/dist/account/index.d.ts +0 -26
  46. package/dist/account/index.js +0 -15
  47. package/dist/account/join-as-account.d.ts +0 -23
  48. package/dist/account/join-as-account.js +0 -34
  49. package/dist/account/join-with-node.d.ts +0 -115
  50. package/dist/account/join-with-node.js +0 -161
  51. package/dist/account/node-admin.d.ts +0 -20
  52. package/dist/account/node-admin.js +0 -33
  53. package/dist/account/relay-from-invitation.d.ts +0 -137
  54. package/dist/account/relay-from-invitation.js +0 -180
  55. package/dist/account/relay-login-error.d.ts +0 -32
  56. package/dist/account/relay-login-error.js +0 -34
  57. package/dist/account/session.d.ts +0 -266
  58. package/dist/account/session.js +0 -915
  59. package/dist/account/wordlist.d.ts +0 -16
  60. package/dist/account/wordlist.js +0 -273
  61. package/dist/admin-api/admin-client.d.ts +0 -688
  62. package/dist/admin-api/admin-client.js +0 -1230
  63. package/dist/admin-api/admin-factory.d.ts +0 -14
  64. package/dist/admin-api/admin-factory.js +0 -22
  65. package/dist/admin-api/admin-types.d.ts +0 -2046
  66. package/dist/admin-api/admin-types.js +0 -12
  67. package/dist/admin-api/index.d.ts +0 -4
  68. package/dist/admin-api/index.js +0 -5
  69. package/dist/admin-api/redeem-invitation.d.ts +0 -101
  70. package/dist/admin-api/redeem-invitation.js +0 -200
  71. package/dist/auth/index.d.ts +0 -34
  72. package/dist/auth/index.js +0 -67
  73. package/dist/auth-api/auth-client.d.ts +0 -31
  74. package/dist/auth-api/auth-client.js +0 -117
  75. package/dist/auth-api/auth-factory.d.ts +0 -7
  76. package/dist/auth-api/auth-factory.js +0 -41
  77. package/dist/auth-api/auth-types.d.ts +0 -130
  78. package/dist/auth-api/auth-types.js +0 -2
  79. package/dist/auth-api/index.d.ts +0 -3
  80. package/dist/auth-api/index.js +0 -4
  81. package/dist/capabilities.d.ts +0 -84
  82. package/dist/capabilities.js +0 -117
  83. package/dist/cloud/account-ownership.d.ts +0 -63
  84. package/dist/cloud/account-ownership.js +0 -87
  85. package/dist/cloud/cloud-client.d.ts +0 -949
  86. package/dist/cloud/cloud-client.js +0 -1068
  87. package/dist/cloud/connect.d.ts +0 -213
  88. package/dist/cloud/connect.js +0 -260
  89. package/dist/cloud/enrol-redirect.d.ts +0 -181
  90. package/dist/cloud/enrol-redirect.js +0 -244
  91. package/dist/cloud/index.d.ts +0 -12
  92. package/dist/cloud/index.js +0 -10
  93. package/dist/cloud/link-redirect.d.ts +0 -95
  94. package/dist/cloud/link-redirect.js +0 -121
  95. package/dist/cloud/link-state.d.ts +0 -36
  96. package/dist/cloud/link-state.js +0 -104
  97. package/dist/cloud/routing-proof.d.ts +0 -113
  98. package/dist/cloud/routing-proof.js +0 -96
  99. package/dist/device-cert/device-cert.d.ts +0 -189
  100. package/dist/device-cert/device-cert.js +0 -239
  101. package/dist/device-cert/device-scope.d.ts +0 -58
  102. package/dist/device-cert/device-scope.js +0 -76
  103. package/dist/device-cert/index.d.ts +0 -4
  104. package/dist/device-cert/index.js +0 -3
  105. package/dist/ephemeral/codec.d.ts +0 -4
  106. package/dist/ephemeral/codec.js +0 -12
  107. package/dist/ephemeral/index.d.ts +0 -57
  108. package/dist/ephemeral/index.js +0 -101
  109. package/dist/ephemeral/types.d.ts +0 -27
  110. package/dist/ephemeral/types.js +0 -1
  111. package/dist/errors/classify.d.ts +0 -65
  112. package/dist/errors/classify.js +0 -117
  113. package/dist/errors/index.d.ts +0 -2
  114. package/dist/errors/index.js +0 -1
  115. package/dist/events/group.d.ts +0 -95
  116. package/dist/events/group.js +0 -10
  117. package/dist/events/index.d.ts +0 -5
  118. package/dist/events/index.js +0 -2
  119. package/dist/events/sse.d.ts +0 -127
  120. package/dist/events/sse.js +0 -469
  121. package/dist/events/ws.d.ts +0 -57
  122. package/dist/events/ws.js +0 -212
  123. package/dist/http-client/api-response.d.ts +0 -15
  124. package/dist/http-client/api-response.js +0 -1
  125. package/dist/http-client/http-factory.d.ts +0 -71
  126. package/dist/http-client/http-factory.js +0 -68
  127. package/dist/http-client/http-types.d.ts +0 -87
  128. package/dist/http-client/http-types.js +0 -1
  129. package/dist/http-client/index.d.ts +0 -7
  130. package/dist/http-client/index.js +0 -11
  131. package/dist/http-client/path-segment.d.ts +0 -1
  132. package/dist/http-client/path-segment.js +0 -8
  133. package/dist/http-client/retry.d.ts +0 -5
  134. package/dist/http-client/retry.js +0 -82
  135. package/dist/http-client/signal-utils.d.ts +0 -2
  136. package/dist/http-client/signal-utils.js +0 -41
  137. package/dist/http-client/web-client.d.ts +0 -80
  138. package/dist/http-client/web-client.js +0 -557
  139. package/dist/invitation/index.d.ts +0 -2
  140. package/dist/invitation/index.js +0 -2
  141. package/dist/invitation/invitation.d.ts +0 -106
  142. package/dist/invitation/invitation.js +0 -104
  143. package/dist/login/index.d.ts +0 -4
  144. package/dist/login/index.js +0 -3
  145. package/dist/login/login.d.ts +0 -111
  146. package/dist/login/login.js +0 -110
  147. package/dist/login/session.d.ts +0 -124
  148. package/dist/login/session.js +0 -141
  149. package/dist/mero-js.d.ts +0 -231
  150. package/dist/mero-js.js +0 -469
  151. package/dist/namespace-op/index.d.ts +0 -2
  152. package/dist/namespace-op/index.js +0 -3
  153. package/dist/namespace-op/namespace-op.d.ts +0 -150
  154. package/dist/namespace-op/namespace-op.js +0 -191
  155. package/dist/nodeDiscovery.d.ts +0 -47
  156. package/dist/nodeDiscovery.js +0 -101
  157. package/dist/owner-op/index.d.ts +0 -2
  158. package/dist/owner-op/index.js +0 -3
  159. package/dist/owner-op/owner-op.d.ts +0 -119
  160. package/dist/owner-op/owner-op.js +0 -214
  161. package/dist/presence/relay-presence.d.ts +0 -56
  162. package/dist/presence/relay-presence.js +0 -107
  163. package/dist/presence/statement.d.ts +0 -12
  164. package/dist/presence/statement.js +0 -17
  165. package/dist/relay/index.d.ts +0 -4
  166. package/dist/relay/index.js +0 -2
  167. package/dist/relay/nonce-source.d.ts +0 -72
  168. package/dist/relay/nonce-source.js +0 -111
  169. package/dist/relay/relay-client.d.ts +0 -472
  170. package/dist/relay/relay-client.js +0 -518
  171. package/dist/relay-attestation/attest-node-key.d.ts +0 -66
  172. package/dist/relay-attestation/attest-node-key.js +0 -110
  173. package/dist/relay-attestation/index.d.ts +0 -1
  174. package/dist/relay-attestation/index.js +0 -1
  175. package/dist/request/caller-proof.d.ts +0 -43
  176. package/dist/request/caller-proof.js +0 -36
  177. package/dist/request/index.d.ts +0 -3
  178. package/dist/request/index.js +0 -3
  179. package/dist/request/proof-signer.d.ts +0 -49
  180. package/dist/request/proof-signer.js +0 -59
  181. package/dist/request/request-sig.d.ts +0 -99
  182. package/dist/request/request-sig.js +0 -95
  183. package/dist/request-proof/authorizer.d.ts +0 -41
  184. package/dist/request-proof/authorizer.js +0 -60
  185. package/dist/request-proof/index.d.ts +0 -4
  186. package/dist/request-proof/index.js +0 -2
  187. package/dist/request-proof/request-proof.d.ts +0 -53
  188. package/dist/request-proof/request-proof.js +0 -95
  189. package/dist/rpc/index.d.ts +0 -64
  190. package/dist/rpc/index.js +0 -78
  191. package/dist/signer/index.d.ts +0 -2
  192. package/dist/signer/index.js +0 -3
  193. package/dist/signer/signer.d.ts +0 -92
  194. package/dist/signer/signer.js +0 -147
  195. package/dist/token-store/index.d.ts +0 -27
  196. package/dist/token-store/index.js +0 -62
  197. package/dist/transport/index.d.ts +0 -6
  198. package/dist/transport/index.js +0 -3
  199. package/dist/transport/mero-client.d.ts +0 -294
  200. package/dist/transport/mero-client.js +0 -386
  201. package/dist/transport/relay-observer.d.ts +0 -152
  202. package/dist/transport/relay-observer.js +0 -173
  203. package/dist/transport/relay-transport.d.ts +0 -73
  204. package/dist/transport/relay-transport.js +0 -94
  205. package/dist/transport/types.d.ts +0 -100
  206. package/dist/transport/types.js +0 -32
  207. package/dist/types/api-response.d.ts +0 -15
  208. package/dist/types/api-response.js +0 -1
  209. package/dist/types/index.d.ts +0 -1
  210. package/dist/types/index.js +0 -1
  211. package/dist/warrant/creation-warrant.d.ts +0 -163
  212. package/dist/warrant/creation-warrant.js +0 -194
  213. package/dist/warrant/governance-op.d.ts +0 -202
  214. package/dist/warrant/governance-op.js +0 -355
  215. package/dist/warrant/governance-warrant.d.ts +0 -124
  216. package/dist/warrant/governance-warrant.js +0 -164
  217. package/dist/warrant/index.d.ts +0 -8
  218. package/dist/warrant/index.js +0 -5
  219. package/dist/warrant/warrant.d.ts +0 -188
  220. package/dist/warrant/warrant.js +0 -202
@@ -0,0 +1,30 @@
1
+ /**
2
+ * What a member may do in an organization beyond their role, as core's
3
+ * `caps` bits (`setCapabilities`, `setTeamMember`'s `capabilities`). A team's
4
+ * lead and an organization's admin hold them all.
5
+ */
6
+ export declare const ORG_CAPABILITIES: {
7
+ /** Create an app in the organization (on its team, or org-wide). */
8
+ readonly CREATE_APP: number;
9
+ /** Mint invites (org-wide, or on each team the invite names). */
10
+ readonly INVITE_MEMBERS: number;
11
+ /** Inherited into open teams; denying it keeps a member out of them. */
12
+ readonly JOIN_OPEN_TEAMS: number;
13
+ /** Add and remove a team's members. */
14
+ readonly MANAGE_MEMBERS: number;
15
+ /** Upgrade the organization's apps, start org upgrade runs, approve outbound hosts (org-wide). */
16
+ readonly MANAGE_APPLICATION: number;
17
+ /** Create a top-level team without being an admin. */
18
+ readonly CREATE_TEAM: number;
19
+ /** Delete a team, and what it holds, without being an admin. */
20
+ readonly DELETE_TEAM: number;
21
+ /** Change who may join a team (open or invite-only). */
22
+ readonly MANAGE_VISIBILITY: number;
23
+ /** Set the organization's and its teams' metadata. */
24
+ readonly MANAGE_METADATA: number;
25
+ };
26
+ export type OrgCapability = keyof typeof ORG_CAPABILITIES;
27
+ /** What a member holds unless an admin says otherwise. */
28
+ export declare const DEFAULT_ORG_CAPABILITIES: number;
29
+ /** The bitmask of `names`. */
30
+ export declare function orgCapabilities(...names: OrgCapability[]): number;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * What a member may do in an organization beyond their role, as core's
3
+ * `caps` bits (`setCapabilities`, `setTeamMember`'s `capabilities`). A team's
4
+ * lead and an organization's admin hold them all.
5
+ */
6
+ export const ORG_CAPABILITIES = {
7
+ /** Create an app in the organization (on its team, or org-wide). */
8
+ CREATE_APP: 1 << 0,
9
+ /** Mint invites (org-wide, or on each team the invite names). */
10
+ INVITE_MEMBERS: 1 << 1,
11
+ /** Inherited into open teams; denying it keeps a member out of them. */
12
+ JOIN_OPEN_TEAMS: 1 << 2,
13
+ /** Add and remove a team's members. */
14
+ MANAGE_MEMBERS: 1 << 3,
15
+ /** Upgrade the organization's apps, start org upgrade runs, approve outbound hosts (org-wide). */
16
+ MANAGE_APPLICATION: 1 << 4,
17
+ /** Create a top-level team without being an admin. */
18
+ CREATE_TEAM: 1 << 5,
19
+ /** Delete a team, and what it holds, without being an admin. */
20
+ DELETE_TEAM: 1 << 6,
21
+ /** Change who may join a team (open or invite-only). */
22
+ MANAGE_VISIBILITY: 1 << 7,
23
+ /** Set the organization's and its teams' metadata. */
24
+ MANAGE_METADATA: 1 << 8,
25
+ };
26
+ /** What a member holds unless an admin says otherwise. */
27
+ export const DEFAULT_ORG_CAPABILITIES = ORG_CAPABILITIES.JOIN_OPEN_TEAMS;
28
+ /** The bitmask of `names`. */
29
+ export function orgCapabilities(...names) {
30
+ return names.reduce((mask, name) => mask | ORG_CAPABILITIES[name], 0);
31
+ }
@@ -0,0 +1,426 @@
1
+ /**
2
+ * Client for Calimero 1.0, the confidential cloud: one app = one replicated log on
3
+ * attested nodes; this client verifies the node, seals every request to it,
4
+ * signs people in with passkeys and machines with API keys.
5
+ *
6
+ * ```ts
7
+ * const cloud = new CalimeroClient({ baseUrl, policy: { release: { minReleaseVersion: '2.3.109' } } });
8
+ * await cloud.signIn(browserPasskey());
9
+ * const { result } = await cloud.call(appId, 'set', { key: 'a', value: '1' });
10
+ * ```
11
+ */
12
+ import { type AttestationDoc, type CloudPolicy } from './attestation.js';
13
+ import { type PasskeyProvider } from './passkey.js';
14
+ export { AppError, ArgsTooLarge, CalimeroError, ConfirmCancelled, ConfirmRequired, IdempotencyMismatch, LoginRequired, NotFound, TrapError, UnavailableError, errorFrom, } from './errors.js';
15
+ export type { Committed } from './errors.js';
16
+ export interface CalimeroSession {
17
+ accountId: string;
18
+ sessionToken: string;
19
+ expiresAt: number;
20
+ refreshToken: string;
21
+ }
22
+ export interface CallResult {
23
+ index: number;
24
+ result: unknown;
25
+ events: Array<{
26
+ kind: string;
27
+ data: unknown;
28
+ }>;
29
+ }
30
+ export interface ViewResult {
31
+ index: number;
32
+ result: unknown;
33
+ }
34
+ export interface CloudEvent {
35
+ id: string;
36
+ kind: string;
37
+ data: unknown;
38
+ }
39
+ /** What installing a package release answers. */
40
+ export interface PackageInstalled {
41
+ package: string;
42
+ version: string;
43
+ signerId: string;
44
+ /** Service name (`''` for a single-service bundle) -> the bundle hash it runs as. */
45
+ services: Record<string, string>;
46
+ }
47
+ /** An installed package and its releases. */
48
+ export interface PackageInfo {
49
+ package: string;
50
+ signerId: string;
51
+ owner: string;
52
+ latest: string | null;
53
+ versions: Array<{
54
+ version: string;
55
+ mpk: string;
56
+ size: number;
57
+ source: 'registry' | 'upload';
58
+ services: Record<string, string>;
59
+ metadata: unknown;
60
+ outbound: string[];
61
+ installedBy: string;
62
+ installedAt: number;
63
+ }>;
64
+ }
65
+ /** One app instance as `listApps` answers it. */
66
+ export interface AppInfo {
67
+ appId: string;
68
+ name: string;
69
+ owner: string;
70
+ org: string | null;
71
+ bundle: string;
72
+ package: string | null;
73
+ version: string | null;
74
+ }
75
+ /**
76
+ * An organization-wide upgrade run, as `upgradeOrg`, `upgradeRun` and
77
+ * `retryUpgradeRun` answer it (core's `UpgradeRun`).
78
+ */
79
+ export interface UpgradeRun {
80
+ runId: string;
81
+ package: string;
82
+ version: string;
83
+ team?: string;
84
+ cascade: boolean;
85
+ /** The account that started it, or `operator`. */
86
+ by: string;
87
+ startedAt: number;
88
+ apps: string[];
89
+ done: string[];
90
+ /** App id -> why its upgrade failed. */
91
+ failed: Record<string, unknown>;
92
+ finished: boolean;
93
+ }
94
+ /** One of an app's blobs: `blobId` base58 (what apps print), `id` hex. */
95
+ export interface BlobInfo {
96
+ blobId: string;
97
+ id: string;
98
+ size: number;
99
+ }
100
+ /** One device present in an app (`publishPresence`); `state` hex, `null` once retracted. */
101
+ export interface PresenceEntry {
102
+ account: string;
103
+ device: string;
104
+ state: string | null;
105
+ }
106
+ /** What an organization-wide upgrade targets. */
107
+ export interface OrgUpgradeTarget {
108
+ package: string;
109
+ version: string;
110
+ /** Only this team's apps (and, with `cascade`, those of the teams below it). */
111
+ team?: string;
112
+ cascade?: boolean;
113
+ migrate?: string;
114
+ }
115
+ /**
116
+ * How a call or a view is sent again while the node is unavailable (D70): with
117
+ * the same key, after a backoff that starts at `baseDelayMs` and doubles up to
118
+ * `maxDelayMs`, no jitter, at most `retries` times. The defaults are the Rust
119
+ * client's: 6 retries, 200 ms doubling, at most 2 s (about 9 s in all, past a
120
+ * leader election).
121
+ */
122
+ export interface CloudRetryOptions {
123
+ /** Retries after the first attempt. Default 6. */
124
+ retries?: number;
125
+ /** The first backoff; each retry doubles it. Default 200 ms. */
126
+ baseDelayMs?: number;
127
+ /** The longest backoff. Default 2 s. */
128
+ maxDelayMs?: number;
129
+ }
130
+ export declare const DEFAULT_RETRY: {
131
+ readonly retries: 6;
132
+ readonly baseDelayMs: 200;
133
+ readonly maxDelayMs: 2000;
134
+ };
135
+ /** The backoff before retry `retry` (0 for the first): `baseDelayMs` doubling, at most `maxDelayMs`. */
136
+ export declare function retryDelayMs(retry: number, options: {
137
+ baseDelayMs: number;
138
+ maxDelayMs: number;
139
+ }): number;
140
+ export interface CalimeroClientOptions {
141
+ /** One node of the cluster. */
142
+ baseUrl: string;
143
+ policy: CloudPolicy;
144
+ /** Fetch that carries attestation and envelopes. Defaults to global `fetch`. */
145
+ fetch?: typeof fetch;
146
+ /** How calls and views retry a 503 or a failed connection. */
147
+ retry?: CloudRetryOptions;
148
+ }
149
+ export declare class CalimeroClient {
150
+ private readonly base;
151
+ private readonly sealed;
152
+ /** The unsealed fetch, for the one route served in the clear (`/attestation`). */
153
+ private readonly raw;
154
+ private auth;
155
+ private current;
156
+ private readonly retry;
157
+ /** Rejections of the underlying `fetch` itself: the node could not be reached or dropped the connection. */
158
+ private readonly networkFailures;
159
+ constructor(options: CalimeroClientOptions);
160
+ /** Authenticate every request with an API key. */
161
+ useApiKey(key: string): void;
162
+ useSession(session: CalimeroSession): void;
163
+ get session(): CalimeroSession | undefined;
164
+ private request;
165
+ private json;
166
+ /**
167
+ * {@link json} for a call or a view (D70): while the node answers 503 or
168
+ * cannot be reached, the same request, with the same idempotency key, is sent
169
+ * again after {@link retryDelayMs} (or the pause the node asked for, if
170
+ * longer), at most `retries` times. Every other answer is final. The last
171
+ * failure surfaces as {@link UnavailableError}: the node's 503, or reason
172
+ * `network` for a connection that failed, whose `committed` is `'unknown'`.
173
+ * `retries` 0 sends the request exactly once.
174
+ */
175
+ private retried;
176
+ post<T = Record<string, unknown>>(path: string, body?: unknown): Promise<T>;
177
+ get<T = Record<string, unknown>>(path: string): Promise<T>;
178
+ put<T = Record<string, unknown>>(path: string, body?: unknown): Promise<T>;
179
+ delete<T = Record<string, unknown>>(path: string, body?: unknown): Promise<T>;
180
+ /** Create an account with a new passkey, and sign in. */
181
+ signUp(passkey: PasskeyProvider, name: string): Promise<CalimeroSession>;
182
+ /** Sign in with an existing passkey. */
183
+ signIn(passkey: PasskeyProvider): Promise<CalimeroSession>;
184
+ /** Swap the refresh token for a new session. */
185
+ refresh(): Promise<CalimeroSession>;
186
+ signOut(): Promise<void>;
187
+ /** End every session of the signed-in account, on every device, this one too. */
188
+ signOutEverywhere(): Promise<void>;
189
+ me(): Promise<Record<string, unknown>>;
190
+ /** Add another passkey (another device) to the signed-in account; answers its credential id. */
191
+ addPasskey(passkey: PasskeyProvider): Promise<string>;
192
+ /** Remove one of the account's passkeys (not the last). */
193
+ removePasskey(credentialId: string): Promise<void>;
194
+ /** Name one of the account's passkeys (a device label); `''` clears the name. */
195
+ labelPasskey(credentialId: string, label: string): Promise<void>;
196
+ /** What this account uses (apps, bundle bytes, API keys, owned orgs), with the cluster's quotas. */
197
+ usage(): Promise<Record<string, unknown>>;
198
+ /**
199
+ * The node's attestation document, unverified: for display only. Every
200
+ * request this client sends is sealed to a key it verified itself first.
201
+ */
202
+ attestation(): Promise<AttestationDoc>;
203
+ /** The account's API keys (never the keys themselves). */
204
+ listApiKeys(): Promise<Array<Record<string, unknown>>>;
205
+ revokeApiKey(keyId: string): Promise<void>;
206
+ /** Create an API key for an agent or server. The key is returned once. */
207
+ createApiKey(options: {
208
+ label?: string;
209
+ apps?: string[];
210
+ methods?: string[];
211
+ readOnly?: boolean;
212
+ allowConfirm?: boolean;
213
+ ttlSecs?: number;
214
+ }): Promise<{
215
+ keyId: string;
216
+ key: string;
217
+ }>;
218
+ /** Upload a raw WASM bundle (development clusters only); answers its hash. */
219
+ uploadBundle(wasm: Uint8Array): Promise<string>;
220
+ /** Upload a blob for `app`: `blobId` is base58 (what apps print), `id` hex. */
221
+ uploadBlob(app: string, data: Uint8Array): Promise<{
222
+ blobId: string;
223
+ id: string;
224
+ size: number;
225
+ }>;
226
+ /** One of `app`'s blobs, by id (base58 or hex). */
227
+ downloadBlob(app: string, id: string): Promise<Uint8Array>;
228
+ /** `app`'s blobs. */
229
+ listBlobs(app: string): Promise<BlobInfo[]>;
230
+ /** One of `app`'s blobs' id and size; `NotFound` if the app has no such blob. */
231
+ blobInfo(app: string, id: string): Promise<BlobInfo>;
232
+ /** Delete one of `app`'s blobs (its owner, or an admin of its organization). */
233
+ deleteBlob(app: string, id: string): Promise<void>;
234
+ /** Install a signed `.mpk` package file. */
235
+ uploadPackage(mpk: Uint8Array): Promise<PackageInstalled>;
236
+ /** Install `package@version` from the cluster's registry; every node that runs it verifies it. */
237
+ installPackage(pkg: string, version: string): Promise<PackageInstalled>;
238
+ /** Installed packages and their versions. */
239
+ packages(): Promise<PackageInfo[]>;
240
+ /** One installed package and its versions. */
241
+ package(pkg: string): Promise<PackageInfo>;
242
+ /** Uninstall one version, or the whole package. Refused while an app runs it. */
243
+ uninstallPackage(pkg: string, version?: string): Promise<Record<string, unknown>>;
244
+ /** Apps this caller reaches, optionally only those of one package or bundle. */
245
+ listApps(filter?: {
246
+ package?: string;
247
+ bundle?: string;
248
+ }): Promise<AppInfo[]>;
249
+ getApp(app: string): Promise<Record<string, unknown>>;
250
+ /** Delete an app instance (its owner, or an admin of its organization). */
251
+ deleteApp(app: string): Promise<void>;
252
+ /** Who may reach the app: `{ kind: 'owner' | 'org' | 'public' | 'accounts' | 'team', ... }`. */
253
+ setAccess(app: string, access: Record<string, unknown>): Promise<void>;
254
+ /** Set the app instance's metadata (its owner, or an admin of its organization); at most 16 KiB. */
255
+ setAppMetadata(app: string, metadata: unknown): Promise<void>;
256
+ /** What the app's storage holds: `{ keys, bytes, blobs, blobBytes }`. */
257
+ appStorage(app: string): Promise<Record<string, unknown>>;
258
+ /** The ABI the app's bundle embeds: `{ bundle, abi }`. */
259
+ appAbi(app: string): Promise<Record<string, unknown>>;
260
+ /**
261
+ * Hand the app to another account (an organization's app only to one of its
262
+ * members). The owner approves with `passkey`.
263
+ */
264
+ transferApp(app: string, to: string, passkey: PasskeyProvider): Promise<void>;
265
+ /**
266
+ * Move an app to another release of its package (`{ version }`), another
267
+ * package, or a bundle hash, running its migration. Answers the upgrade's
268
+ * entry; a failed migration rejects with code `UPGRADE_FAILED` (422).
269
+ * Where the owner holds app upgrades, the node asks for the owner's approval
270
+ * (`412 CONFIRM_REQUIRED`), which `passkey` gives.
271
+ */
272
+ upgradeApp(app: string, target: {
273
+ version?: string;
274
+ package?: string;
275
+ service?: string;
276
+ bundle?: string;
277
+ migrate?: string;
278
+ }, passkey?: PasskeyProvider): Promise<{
279
+ index: number;
280
+ status: string;
281
+ error: unknown;
282
+ }>;
283
+ /**
284
+ * POST `body` to `path`, answering a `412 CONFIRM_REQUIRED` with `passkey`'s
285
+ * assertion over the node's challenge (deleting an org, approving a release, ...).
286
+ */
287
+ postConfirmed<T>(path: string, body: Record<string, unknown>, passkey: PasskeyProvider): Promise<T>;
288
+ /** {@link postConfirmed} for a DELETE (deleting an organization). */
289
+ deleteConfirmed<T>(path: string, passkey: PasskeyProvider, body?: Record<string, unknown>): Promise<T>;
290
+ private confirmed;
291
+ /**
292
+ * Create an app instance from a bundle hash, or from a package release
293
+ * (`{ package, version?, service? }`, installed from the registry first if
294
+ * the cluster lacks it).
295
+ */
296
+ createApp(name: string, bundle: string | {
297
+ package: string;
298
+ version?: string;
299
+ service?: string;
300
+ }, options?: {
301
+ org?: string;
302
+ access?: Record<string, unknown>;
303
+ confirmMethods?: string[];
304
+ /** Arguments for the app's `init`. A failed init rejects with code `INIT_FAILED`. */
305
+ initArgs?: unknown;
306
+ }): Promise<string>;
307
+ /**
308
+ * Call a method. A retry with the same `idempotencyKey` is answered once.
309
+ * Without one, the client makes one, so its own retries of a 503 share it.
310
+ */
311
+ call(app: string, method: string, args?: unknown, idempotencyKey?: string): Promise<CallResult>;
312
+ /**
313
+ * Call a method that needs the account holder's approval: the node returns a
314
+ * challenge over this exact call, which `passkey` signs. A declined prompt
315
+ * rejects with {@link ConfirmCancelled}.
316
+ */
317
+ callConfirmed(app: string, method: string, args: unknown, passkey: PasskeyProvider, idempotencyKey?: string): Promise<CallResult>;
318
+ /** Run a read-only method: strong by default, or stale from any replica. */
319
+ view(app: string, method: string, args?: unknown, options?: {
320
+ stale?: boolean;
321
+ minIndex?: number;
322
+ }): Promise<ViewResult>;
323
+ /** Committed events from index `from`, then live, until `signal` aborts. */
324
+ events(app: string, from?: number, signal?: AbortSignal): AsyncGenerator<CloudEvent>;
325
+ /** A server-sent event stream on `path`, sealed like every other answer. */
326
+ private stream;
327
+ /**
328
+ * Publish this device's presence in `app`: `state` (at most 4 KiB) or `null`
329
+ * to retract it. The newest `seq` wins; send the same `seq` and state again
330
+ * as a heartbeat, since an entry not refreshed within 7 s is gone.
331
+ */
332
+ publishPresence(app: string, seq: number, state: Uint8Array | null): Promise<void>;
333
+ /** Who is present in `app` now. */
334
+ presence(app: string): Promise<PresenceEntry[]>;
335
+ /**
336
+ * Presence as a stream until `signal` aborts: a `snapshot` event (`data` the
337
+ * entries present), then a `presence` event (`data` one entry) per change.
338
+ */
339
+ presenceStream(app: string, signal?: AbortSignal): AsyncGenerator<CloudEvent>;
340
+ /** Name an app (its id or context id) for this account. */
341
+ setAlias(alias: string, app: string): Promise<void>;
342
+ /** This account's aliases, alias → app id. */
343
+ aliases(): Promise<Record<string, string>>;
344
+ /** The app an alias names. */
345
+ alias(alias: string): Promise<string>;
346
+ deleteAlias(alias: string): Promise<void>;
347
+ createOrg(name: string): Promise<string>;
348
+ /** The organization, with the teams this caller reaches or manages. */
349
+ getOrg(org: string): Promise<Record<string, unknown>>;
350
+ /**
351
+ * Delete an organization with its teams, invites and apps (its owner only).
352
+ * The node asks for the owner's passkey (`412 CONFIRM_REQUIRED`), which `passkey` gives.
353
+ */
354
+ deleteOrg(org: string, passkey: PasskeyProvider): Promise<void>;
355
+ /** Set the organization's metadata (an admin, or a holder of `MANAGE_METADATA`); at most 16 KiB. */
356
+ setOrgMetadata(org: string, metadata: unknown): Promise<void>;
357
+ /** Set a member's metadata (theirs, or an admin's); `null` clears it. */
358
+ setMemberMetadata(org: string, account: string, metadata: unknown): Promise<void>;
359
+ /**
360
+ * Upgrade every app of `org` that runs `target.package` to `target.version`
361
+ * (optionally one team's, with `cascade` the teams below it). The org's owner,
362
+ * or a holder of `MANAGE_APPLICATION`, approves the whole run with `passkey`.
363
+ * Answers the run; {@link upgradeRun} follows it.
364
+ */
365
+ upgradeOrg(org: string, target: OrgUpgradeTarget, passkey: PasskeyProvider): Promise<UpgradeRun>;
366
+ /** An organization-wide upgrade run: its apps, those done and those that failed. */
367
+ upgradeRun(org: string, run: string): Promise<UpgradeRun>;
368
+ /** Run the apps that failed in `run` again, as a new run, approved with `passkey`. */
369
+ retryUpgradeRun(org: string, run: string, passkey: PasskeyProvider): Promise<UpgradeRun>;
370
+ /**
371
+ * Approve a mero-tee release to hold the apps of `org`, or of this account
372
+ * outside any organization (`org` `null`); `approved: false` withdraws it.
373
+ * Until then, nodes on that release get none of those apps' data. The owner
374
+ * approves with `passkey`.
375
+ */
376
+ approveRelease(org: string | null, version: string, passkey: PasskeyProvider, approved?: boolean): Promise<Record<string, unknown>>;
377
+ /**
378
+ * Approve the URL prefixes apps from `pkg`'s publisher may call out to, for
379
+ * `org`'s apps or this account's own (`org` `null`). `prefixes` `'manifest'`
380
+ * (the default) approves every prefix the package's latest release declares;
381
+ * `replace` sets exactly `prefixes`, which is how one is revoked. Approved
382
+ * with `passkey`.
383
+ */
384
+ approveOutbound(org: string | null, pkg: string, passkey: PasskeyProvider, options?: {
385
+ prefixes?: string[] | 'manifest';
386
+ replace?: boolean;
387
+ }): Promise<Record<string, unknown>>;
388
+ /** Add a member, or change their role. */
389
+ setMember(org: string, account: string, role: 'guest' | 'member' | 'admin' | 'owner'): Promise<void>;
390
+ removeMember(org: string, account: string): Promise<Record<string, unknown>>;
391
+ /**
392
+ * Set capability bits ({@link ORG_CAPABILITIES}): for a member (`account`),
393
+ * for a member of one team (`account` and `team`), or the organization's
394
+ * default (neither).
395
+ */
396
+ setCapabilities(org: string, capabilities: number, at?: {
397
+ account?: string;
398
+ team?: string;
399
+ }): Promise<void>;
400
+ createTeam(org: string, name: string, join: 'everyone' | 'invite', parent?: string): Promise<string>;
401
+ getTeam(org: string, team: string): Promise<Record<string, unknown>>;
402
+ /**
403
+ * Rename, change who may join, set the app's metadata, or move the team:
404
+ * `parent: null` moves it to the top, an absent `parent` leaves it.
405
+ */
406
+ updateTeam(org: string, team: string, update: {
407
+ name?: string;
408
+ join?: 'everyone' | 'invite';
409
+ parent?: string | null;
410
+ metadata?: unknown;
411
+ }): Promise<void>;
412
+ /** Delete a team, the teams below it and their apps. */
413
+ deleteTeam(org: string, team: string): Promise<void>;
414
+ /** Add a member to a team, or change their row: role, lead, capability bits. */
415
+ setTeamMember(org: string, team: string, account: string, row?: {
416
+ role?: 'lead' | 'member' | 'readOnly';
417
+ lead?: boolean;
418
+ capabilities?: number;
419
+ }): Promise<void>;
420
+ removeTeamMember(org: string, team: string, account: string): Promise<void>;
421
+ invite(org: string, role: 'guest' | 'member' | 'admin', teams?: string[], options?: {
422
+ ttlSecs?: number;
423
+ uses?: number;
424
+ }): Promise<string>;
425
+ redeemInvite(token: string): Promise<Record<string, unknown>>;
426
+ }