@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.mjs
CHANGED
|
@@ -2046,19 +2046,25 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2046
2046
|
me() {
|
|
2047
2047
|
return this.get("auth/me");
|
|
2048
2048
|
}
|
|
2049
|
-
/**
|
|
2050
|
-
|
|
2049
|
+
/**
|
|
2050
|
+
* Add another passkey (another device, `passkey`) to the signed-in account;
|
|
2051
|
+
* answers its credential id. The node asks for the approval of a passkey
|
|
2052
|
+
* the account already has (`412 CONFIRM_REQUIRED`, never the new one),
|
|
2053
|
+
* which `approver` gives.
|
|
2054
|
+
*/
|
|
2055
|
+
async addPasskey(passkey, approver) {
|
|
2051
2056
|
const begin = await this.post("auth/passkeys/add/begin");
|
|
2052
2057
|
const registration = await passkey.create(begin.options);
|
|
2053
|
-
const { credentialId } = await this.
|
|
2054
|
-
|
|
2055
|
-
registration
|
|
2056
|
-
|
|
2058
|
+
const { credentialId } = await this.postConfirmed(
|
|
2059
|
+
"auth/passkeys/add/finish",
|
|
2060
|
+
{ challengeId: begin.challengeId, registration },
|
|
2061
|
+
approver
|
|
2062
|
+
);
|
|
2057
2063
|
return credentialId;
|
|
2058
2064
|
}
|
|
2059
|
-
/** Remove one of the account's passkeys (not the last). */
|
|
2060
|
-
async removePasskey(credentialId) {
|
|
2061
|
-
await this.
|
|
2065
|
+
/** Remove one of the account's passkeys (not the last), approved with `passkey` (one it has). */
|
|
2066
|
+
async removePasskey(credentialId, passkey) {
|
|
2067
|
+
await this.deleteConfirmed(`auth/passkeys/${seg(credentialId)}`, passkey);
|
|
2062
2068
|
}
|
|
2063
2069
|
/** Name one of the account's passkeys (a device label); `''` clears the name. */
|
|
2064
2070
|
async labelPasskey(credentialId, label) {
|
|
@@ -2086,9 +2092,13 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2086
2092
|
async revokeApiKey(keyId) {
|
|
2087
2093
|
await this.delete(`auth/apikeys/${seg(keyId)}`);
|
|
2088
2094
|
}
|
|
2089
|
-
/**
|
|
2090
|
-
|
|
2091
|
-
|
|
2095
|
+
/**
|
|
2096
|
+
* Create an API key for an agent or server, approved with the account's
|
|
2097
|
+
* `passkey` (`412 CONFIRM_REQUIRED`); needs a passkey session (an API key
|
|
2098
|
+
* is refused `403`). The key is returned once.
|
|
2099
|
+
*/
|
|
2100
|
+
createApiKey(options, passkey) {
|
|
2101
|
+
return this.postConfirmed("auth/apikeys", { ...options }, passkey);
|
|
2092
2102
|
}
|
|
2093
2103
|
// ---------------------------------------------------------------- apps
|
|
2094
2104
|
/** Upload a raw WASM bundle (development clusters only); answers its hash. */
|
|
@@ -2196,12 +2206,19 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2196
2206
|
}
|
|
2197
2207
|
/**
|
|
2198
2208
|
* POST `body` to `path`, answering a `412 CONFIRM_REQUIRED` with `passkey`'s
|
|
2199
|
-
* assertion over the node's challenge (deleting an org, approving a release,
|
|
2209
|
+
* assertion over the node's challenge (deleting an org, approving a release,
|
|
2210
|
+
* adding a member, ...): the same body again, with `confirm`. Without a
|
|
2211
|
+
* passkey (a caller in plain JavaScript passing none) the `412` reaches the
|
|
2212
|
+
* caller as {@link ConfirmRequired}, carrying the challenge.
|
|
2200
2213
|
*/
|
|
2201
2214
|
postConfirmed(path, body, passkey) {
|
|
2202
2215
|
return this.confirmed("POST", path, body, passkey);
|
|
2203
2216
|
}
|
|
2204
|
-
/**
|
|
2217
|
+
/**
|
|
2218
|
+
* {@link postConfirmed} for a DELETE (deleting an organization, removing a
|
|
2219
|
+
* member or a passkey): `body` (`{}` by default) goes as JSON, and the
|
|
2220
|
+
* confirmed retry carries `confirm` beside it.
|
|
2221
|
+
*/
|
|
2205
2222
|
deleteConfirmed(path, passkey, body = {}) {
|
|
2206
2223
|
return this.confirmed("DELETE", path, body, passkey);
|
|
2207
2224
|
}
|
|
@@ -2209,7 +2226,7 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2209
2226
|
try {
|
|
2210
2227
|
return await send(body);
|
|
2211
2228
|
} catch (error) {
|
|
2212
|
-
if (!(error instanceof ConfirmRequired)) throw error;
|
|
2229
|
+
if (!(error instanceof ConfirmRequired) || !passkey) throw error;
|
|
2213
2230
|
const d = error.details;
|
|
2214
2231
|
let assertion;
|
|
2215
2232
|
try {
|
|
@@ -2533,20 +2550,24 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2533
2550
|
async liftReleaseDeadline(version) {
|
|
2534
2551
|
await this.delete(`ops/releases/${seg(version)}/deadline`);
|
|
2535
2552
|
}
|
|
2536
|
-
/** Add a member, or change their role
|
|
2537
|
-
async setMember(org, account, role) {
|
|
2538
|
-
await this.
|
|
2553
|
+
/** Add a member, or change their role, approved with the caller's `passkey`. */
|
|
2554
|
+
async setMember(org, account, role, passkey) {
|
|
2555
|
+
await this.postConfirmed(`orgs/${seg(org)}/members`, { account, role }, passkey);
|
|
2539
2556
|
}
|
|
2540
|
-
|
|
2541
|
-
|
|
2557
|
+
/**
|
|
2558
|
+
* Remove a member, or leave (`account` the caller's own), approved with the
|
|
2559
|
+
* caller's `passkey`.
|
|
2560
|
+
*/
|
|
2561
|
+
removeMember(org, account, passkey) {
|
|
2562
|
+
return this.deleteConfirmed(`orgs/${seg(org)}/members/${seg(account)}`, passkey);
|
|
2542
2563
|
}
|
|
2543
2564
|
/**
|
|
2544
2565
|
* Set capability bits ({@link ORG_CAPABILITIES}): for a member (`account`),
|
|
2545
2566
|
* for a member of one team (`account` and `team`), or the organization's
|
|
2546
|
-
* default (neither).
|
|
2567
|
+
* default (neither). Approved with the caller's `passkey`.
|
|
2547
2568
|
*/
|
|
2548
|
-
async setCapabilities(org, capabilities, at = {}) {
|
|
2549
|
-
await this.
|
|
2569
|
+
async setCapabilities(org, capabilities, passkey, at = {}) {
|
|
2570
|
+
await this.postConfirmed(`orgs/${seg(org)}/capabilities`, { capabilities, ...at }, passkey);
|
|
2550
2571
|
}
|
|
2551
2572
|
async createTeam(org, name, join, parent) {
|
|
2552
2573
|
const { teamId } = await this.post(`orgs/${seg(org)}/teams`, { name, join, parent });
|
|
@@ -2566,15 +2587,28 @@ var CalimeroClient = class _CalimeroClient {
|
|
|
2566
2587
|
async deleteTeam(org, team) {
|
|
2567
2588
|
await this.delete(`orgs/${seg(org)}/teams/${seg(team)}`);
|
|
2568
2589
|
}
|
|
2569
|
-
/**
|
|
2570
|
-
|
|
2571
|
-
|
|
2590
|
+
/**
|
|
2591
|
+
* Add a member to a team, or change their row: role, lead, capability bits.
|
|
2592
|
+
* Approved with the caller's `passkey`.
|
|
2593
|
+
*/
|
|
2594
|
+
async setTeamMember(org, team, account, passkey, row = {}) {
|
|
2595
|
+
await this.postConfirmed(`orgs/${seg(org)}/teams/${seg(team)}/members`, { account, ...row }, passkey);
|
|
2572
2596
|
}
|
|
2573
|
-
|
|
2574
|
-
|
|
2597
|
+
/** Remove a member from a team, approved with the caller's `passkey`. */
|
|
2598
|
+
async removeTeamMember(org, team, account, passkey) {
|
|
2599
|
+
await this.deleteConfirmed(`orgs/${seg(org)}/teams/${seg(team)}/members/${seg(account)}`, passkey);
|
|
2575
2600
|
}
|
|
2576
|
-
|
|
2577
|
-
|
|
2601
|
+
/**
|
|
2602
|
+
* Make an invite into `org` (and `teams`), approved with the caller's
|
|
2603
|
+
* `passkey`; answers its token, which {@link redeemInvite} takes (no
|
|
2604
|
+
* approval there).
|
|
2605
|
+
*/
|
|
2606
|
+
async invite(org, role, passkey, teams = [], options = {}) {
|
|
2607
|
+
const { token } = await this.postConfirmed(
|
|
2608
|
+
`orgs/${seg(org)}/invites`,
|
|
2609
|
+
{ role, teams, ...options },
|
|
2610
|
+
passkey
|
|
2611
|
+
);
|
|
2578
2612
|
return token;
|
|
2579
2613
|
}
|
|
2580
2614
|
redeemInvite(token) {
|