@calimero-network/mero-js 26.7.0 → 26.9.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/dist/admin-api/admin-client.d.ts +22 -1
- package/dist/admin-api/admin-client.js +29 -0
- package/dist/admin-api/admin-types.d.ts +49 -0
- package/dist/agent-gate/policy.d.ts +7 -1
- package/dist/agent-gate/policy.js +4 -3
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +50 -2
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +50 -2
- package/dist/index.mjs.map +3 -3
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1740,6 +1740,53 @@ var AdminApiClient = class {
|
|
|
1740
1740
|
)
|
|
1741
1741
|
);
|
|
1742
1742
|
}
|
|
1743
|
+
/**
|
|
1744
|
+
* Issue an access grant: a token whose holder may call `request.methods` in
|
|
1745
|
+
* `contextId`, as this node, with no session of its own.
|
|
1746
|
+
*
|
|
1747
|
+
* A grant only narrows: each method must be one this session's own token may
|
|
1748
|
+
* execute in the context (`403` otherwise), and an account session is refused
|
|
1749
|
+
* (`403`), since a granted call runs as the node. The token is in the answer
|
|
1750
|
+
* once and never again; the node keeps only its hash.
|
|
1751
|
+
*/
|
|
1752
|
+
async createAccessGrant(contextId, request) {
|
|
1753
|
+
return unwrap(
|
|
1754
|
+
await this.httpClient.post(
|
|
1755
|
+
`/admin-api/contexts/${pathSegment(contextId)}/grants`,
|
|
1756
|
+
{ methods: request.methods, label: request.label ?? "", notAfter: request.notAfter ?? null }
|
|
1757
|
+
)
|
|
1758
|
+
);
|
|
1759
|
+
}
|
|
1760
|
+
/** The access grants of `contextId` this session could have issued. */
|
|
1761
|
+
async listAccessGrants(contextId) {
|
|
1762
|
+
return unwrap(
|
|
1763
|
+
await this.httpClient.get(
|
|
1764
|
+
`/admin-api/contexts/${pathSegment(contextId)}/grants`
|
|
1765
|
+
)
|
|
1766
|
+
);
|
|
1767
|
+
}
|
|
1768
|
+
/** Revoke an access grant. A grant this session cannot see is a `404`. */
|
|
1769
|
+
async revokeAccessGrant(contextId, grantId) {
|
|
1770
|
+
return unwrap(
|
|
1771
|
+
await this.httpClient.delete(
|
|
1772
|
+
`/admin-api/contexts/${pathSegment(contextId)}/grants/${pathSegment(grantId)}`
|
|
1773
|
+
)
|
|
1774
|
+
);
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* Call one method under an access grant. The token is the whole credential:
|
|
1778
|
+
* the route is public on every node, so this works from a client holding no
|
|
1779
|
+
* session at all. A method the grant does not name, an unknown or revoked
|
|
1780
|
+
* token, and an expired grant are each a `403`.
|
|
1781
|
+
*/
|
|
1782
|
+
async callWithAccessGrant(contextId, request) {
|
|
1783
|
+
return unwrap(
|
|
1784
|
+
await this.httpClient.post(
|
|
1785
|
+
`/admin-api/contexts/${pathSegment(contextId)}/grant-calls`,
|
|
1786
|
+
request
|
|
1787
|
+
)
|
|
1788
|
+
);
|
|
1789
|
+
}
|
|
1743
1790
|
/**
|
|
1744
1791
|
* Ask what this node can do for a member in `contextId`, before they sign
|
|
1745
1792
|
* anything.
|
|
@@ -13135,8 +13182,9 @@ async function verifySignedAgentPolicy(policy, bundle, options = {}) {
|
|
|
13135
13182
|
} catch {
|
|
13136
13183
|
throw new Error("The signed agent policy is not JSON");
|
|
13137
13184
|
}
|
|
13138
|
-
|
|
13139
|
-
|
|
13185
|
+
const role2 = options.role ?? "agent";
|
|
13186
|
+
if (parsed?.role !== role2) {
|
|
13187
|
+
throw new Error(`The signed file is a ${JSON.stringify(parsed?.role)} policy, not an ${role2} one`);
|
|
13140
13188
|
}
|
|
13141
13189
|
const profile = options.profile ?? PRODUCTION_PROFILE;
|
|
13142
13190
|
if (parsed.profile !== profile) {
|