@calimero-network/mero-js 27.5.0 → 28.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 +2 -2
- package/dist/cloud-v2/client.d.ts +46 -17
- package/dist/cloud-v2/client.js +56 -30
- package/dist/index.browser.mjs +3 -3
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +64 -30
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +64 -30
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2157,19 +2157,25 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2157
2157
|
me() {
|
|
2158
2158
|
return this.get("auth/me");
|
|
2159
2159
|
}
|
|
2160
|
-
/**
|
|
2161
|
-
|
|
2160
|
+
/**
|
|
2161
|
+
* Add another passkey (another device, `passkey`) to the signed-in account;
|
|
2162
|
+
* answers its credential id. The node asks for the approval of a passkey
|
|
2163
|
+
* the account already has (`412 CONFIRM_REQUIRED`, never the new one),
|
|
2164
|
+
* which `approver` gives.
|
|
2165
|
+
*/
|
|
2166
|
+
async addPasskey(passkey, approver) {
|
|
2162
2167
|
const begin = await this.post("auth/passkeys/add/begin");
|
|
2163
2168
|
const registration = await passkey.create(begin.options);
|
|
2164
|
-
const { credentialId } = await this.
|
|
2165
|
-
|
|
2166
|
-
registration
|
|
2167
|
-
|
|
2169
|
+
const { credentialId } = await this.postConfirmed(
|
|
2170
|
+
"auth/passkeys/add/finish",
|
|
2171
|
+
{ challengeId: begin.challengeId, registration },
|
|
2172
|
+
approver
|
|
2173
|
+
);
|
|
2168
2174
|
return credentialId;
|
|
2169
2175
|
}
|
|
2170
|
-
/** Remove one of the account's passkeys (not the last). */
|
|
2171
|
-
async removePasskey(credentialId) {
|
|
2172
|
-
await this.
|
|
2176
|
+
/** Remove one of the account's passkeys (not the last), approved with `passkey` (one it has). */
|
|
2177
|
+
async removePasskey(credentialId, passkey) {
|
|
2178
|
+
await this.deleteConfirmed(`auth/passkeys/${seg(credentialId)}`, passkey);
|
|
2173
2179
|
}
|
|
2174
2180
|
/** Name one of the account's passkeys (a device label); `''` clears the name. */
|
|
2175
2181
|
async labelPasskey(credentialId, label) {
|
|
@@ -2197,9 +2203,13 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2197
2203
|
async revokeApiKey(keyId) {
|
|
2198
2204
|
await this.delete(`auth/apikeys/${seg(keyId)}`);
|
|
2199
2205
|
}
|
|
2200
|
-
/**
|
|
2201
|
-
|
|
2202
|
-
|
|
2206
|
+
/**
|
|
2207
|
+
* Create an API key for an agent or server, approved with the account's
|
|
2208
|
+
* `passkey` (`412 CONFIRM_REQUIRED`); needs a passkey session (an API key
|
|
2209
|
+
* is refused `403`). The key is returned once.
|
|
2210
|
+
*/
|
|
2211
|
+
createApiKey(options, passkey) {
|
|
2212
|
+
return this.postConfirmed("auth/apikeys", { ...options }, passkey);
|
|
2203
2213
|
}
|
|
2204
2214
|
// ---------------------------------------------------------------- apps
|
|
2205
2215
|
/** Upload a raw WASM bundle (development clusters only); answers its hash. */
|
|
@@ -2307,12 +2317,19 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2307
2317
|
}
|
|
2308
2318
|
/**
|
|
2309
2319
|
* POST `body` to `path`, answering a `412 CONFIRM_REQUIRED` with `passkey`'s
|
|
2310
|
-
* assertion over the node's challenge (deleting an org, approving a release,
|
|
2320
|
+
* assertion over the node's challenge (deleting an org, approving a release,
|
|
2321
|
+
* adding a member, ...): the same body again, with `confirm`. Without a
|
|
2322
|
+
* passkey (a caller in plain JavaScript passing none) the `412` reaches the
|
|
2323
|
+
* caller as {@link ConfirmRequired}, carrying the challenge.
|
|
2311
2324
|
*/
|
|
2312
2325
|
postConfirmed(path, body, passkey) {
|
|
2313
2326
|
return this.confirmed("POST", path, body, passkey);
|
|
2314
2327
|
}
|
|
2315
|
-
/**
|
|
2328
|
+
/**
|
|
2329
|
+
* {@link postConfirmed} for a DELETE (deleting an organization, removing a
|
|
2330
|
+
* member or a passkey): `body` (`{}` by default) goes as JSON, and the
|
|
2331
|
+
* confirmed retry carries `confirm` beside it.
|
|
2332
|
+
*/
|
|
2316
2333
|
deleteConfirmed(path, passkey, body = {}) {
|
|
2317
2334
|
return this.confirmed("DELETE", path, body, passkey);
|
|
2318
2335
|
}
|
|
@@ -2320,7 +2337,7 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2320
2337
|
try {
|
|
2321
2338
|
return await send(body);
|
|
2322
2339
|
} catch (error) {
|
|
2323
|
-
if (!(error instanceof ConfirmRequired)) throw error;
|
|
2340
|
+
if (!(error instanceof ConfirmRequired) || !passkey) throw error;
|
|
2324
2341
|
const d = error.details;
|
|
2325
2342
|
let assertion;
|
|
2326
2343
|
try {
|
|
@@ -2644,20 +2661,24 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2644
2661
|
async liftReleaseDeadline(version) {
|
|
2645
2662
|
await this.delete(`ops/releases/${seg(version)}/deadline`);
|
|
2646
2663
|
}
|
|
2647
|
-
/** Add a member, or change their role
|
|
2648
|
-
async setMember(org, account, role) {
|
|
2649
|
-
await this.
|
|
2664
|
+
/** Add a member, or change their role, approved with the caller's `passkey`. */
|
|
2665
|
+
async setMember(org, account, role, passkey) {
|
|
2666
|
+
await this.postConfirmed(`orgs/${seg(org)}/members`, { account, role }, passkey);
|
|
2650
2667
|
}
|
|
2651
|
-
|
|
2652
|
-
|
|
2668
|
+
/**
|
|
2669
|
+
* Remove a member, or leave (`account` the caller's own), approved with the
|
|
2670
|
+
* caller's `passkey`.
|
|
2671
|
+
*/
|
|
2672
|
+
removeMember(org, account, passkey) {
|
|
2673
|
+
return this.deleteConfirmed(`orgs/${seg(org)}/members/${seg(account)}`, passkey);
|
|
2653
2674
|
}
|
|
2654
2675
|
/**
|
|
2655
2676
|
* Set capability bits ({@link ORG_CAPABILITIES}): for a member (`account`),
|
|
2656
2677
|
* for a member of one team (`account` and `team`), or the organization's
|
|
2657
|
-
* default (neither).
|
|
2678
|
+
* default (neither). Approved with the caller's `passkey`.
|
|
2658
2679
|
*/
|
|
2659
|
-
async setCapabilities(org, capabilities, at = {}) {
|
|
2660
|
-
await this.
|
|
2680
|
+
async setCapabilities(org, capabilities, passkey, at = {}) {
|
|
2681
|
+
await this.postConfirmed(`orgs/${seg(org)}/capabilities`, { capabilities, ...at }, passkey);
|
|
2661
2682
|
}
|
|
2662
2683
|
async createTeam(org, name, join, parent) {
|
|
2663
2684
|
const { teamId } = await this.post(`orgs/${seg(org)}/teams`, { name, join, parent });
|
|
@@ -2677,15 +2698,28 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2677
2698
|
async deleteTeam(org, team) {
|
|
2678
2699
|
await this.delete(`orgs/${seg(org)}/teams/${seg(team)}`);
|
|
2679
2700
|
}
|
|
2680
|
-
/**
|
|
2681
|
-
|
|
2682
|
-
|
|
2701
|
+
/**
|
|
2702
|
+
* Add a member to a team, or change their row: role, lead, capability bits.
|
|
2703
|
+
* Approved with the caller's `passkey`.
|
|
2704
|
+
*/
|
|
2705
|
+
async setTeamMember(org, team, account, passkey, row = {}) {
|
|
2706
|
+
await this.postConfirmed(`orgs/${seg(org)}/teams/${seg(team)}/members`, { account, ...row }, passkey);
|
|
2683
2707
|
}
|
|
2684
|
-
|
|
2685
|
-
|
|
2708
|
+
/** Remove a member from a team, approved with the caller's `passkey`. */
|
|
2709
|
+
async removeTeamMember(org, team, account, passkey) {
|
|
2710
|
+
await this.deleteConfirmed(`orgs/${seg(org)}/teams/${seg(team)}/members/${seg(account)}`, passkey);
|
|
2686
2711
|
}
|
|
2687
|
-
|
|
2688
|
-
|
|
2712
|
+
/**
|
|
2713
|
+
* Make an invite into `org` (and `teams`), approved with the caller's
|
|
2714
|
+
* `passkey`; answers its token, which {@link redeemInvite} takes (no
|
|
2715
|
+
* approval there).
|
|
2716
|
+
*/
|
|
2717
|
+
async invite(org, role, passkey, teams = [], options = {}) {
|
|
2718
|
+
const { token } = await this.postConfirmed(
|
|
2719
|
+
`orgs/${seg(org)}/invites`,
|
|
2720
|
+
{ role, teams, ...options },
|
|
2721
|
+
passkey
|
|
2722
|
+
);
|
|
2689
2723
|
return token;
|
|
2690
2724
|
}
|
|
2691
2725
|
redeemInvite(token) {
|