@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.cjs
CHANGED
|
@@ -2038,6 +2038,53 @@ var AdminApiClient = class {
|
|
|
2038
2038
|
)
|
|
2039
2039
|
);
|
|
2040
2040
|
}
|
|
2041
|
+
/**
|
|
2042
|
+
* Issue an access grant: a token whose holder may call `request.methods` in
|
|
2043
|
+
* `contextId`, as this node, with no session of its own.
|
|
2044
|
+
*
|
|
2045
|
+
* A grant only narrows: each method must be one this session's own token may
|
|
2046
|
+
* execute in the context (`403` otherwise), and an account session is refused
|
|
2047
|
+
* (`403`), since a granted call runs as the node. The token is in the answer
|
|
2048
|
+
* once and never again; the node keeps only its hash.
|
|
2049
|
+
*/
|
|
2050
|
+
async createAccessGrant(contextId, request) {
|
|
2051
|
+
return unwrap(
|
|
2052
|
+
await this.httpClient.post(
|
|
2053
|
+
`/admin-api/contexts/${pathSegment(contextId)}/grants`,
|
|
2054
|
+
{ methods: request.methods, label: request.label ?? "", notAfter: request.notAfter ?? null }
|
|
2055
|
+
)
|
|
2056
|
+
);
|
|
2057
|
+
}
|
|
2058
|
+
/** The access grants of `contextId` this session could have issued. */
|
|
2059
|
+
async listAccessGrants(contextId) {
|
|
2060
|
+
return unwrap(
|
|
2061
|
+
await this.httpClient.get(
|
|
2062
|
+
`/admin-api/contexts/${pathSegment(contextId)}/grants`
|
|
2063
|
+
)
|
|
2064
|
+
);
|
|
2065
|
+
}
|
|
2066
|
+
/** Revoke an access grant. A grant this session cannot see is a `404`. */
|
|
2067
|
+
async revokeAccessGrant(contextId, grantId) {
|
|
2068
|
+
return unwrap(
|
|
2069
|
+
await this.httpClient.delete(
|
|
2070
|
+
`/admin-api/contexts/${pathSegment(contextId)}/grants/${pathSegment(grantId)}`
|
|
2071
|
+
)
|
|
2072
|
+
);
|
|
2073
|
+
}
|
|
2074
|
+
/**
|
|
2075
|
+
* Call one method under an access grant. The token is the whole credential:
|
|
2076
|
+
* the route is public on every node, so this works from a client holding no
|
|
2077
|
+
* session at all. A method the grant does not name, an unknown or revoked
|
|
2078
|
+
* token, and an expired grant are each a `403`.
|
|
2079
|
+
*/
|
|
2080
|
+
async callWithAccessGrant(contextId, request) {
|
|
2081
|
+
return unwrap(
|
|
2082
|
+
await this.httpClient.post(
|
|
2083
|
+
`/admin-api/contexts/${pathSegment(contextId)}/grant-calls`,
|
|
2084
|
+
request
|
|
2085
|
+
)
|
|
2086
|
+
);
|
|
2087
|
+
}
|
|
2041
2088
|
/**
|
|
2042
2089
|
* Ask what this node can do for a member in `contextId`, before they sign
|
|
2043
2090
|
* anything.
|
|
@@ -13433,8 +13480,9 @@ async function verifySignedAgentPolicy(policy, bundle, options = {}) {
|
|
|
13433
13480
|
} catch {
|
|
13434
13481
|
throw new Error("The signed agent policy is not JSON");
|
|
13435
13482
|
}
|
|
13436
|
-
|
|
13437
|
-
|
|
13483
|
+
const role2 = options.role ?? "agent";
|
|
13484
|
+
if (parsed?.role !== role2) {
|
|
13485
|
+
throw new Error(`The signed file is a ${JSON.stringify(parsed?.role)} policy, not an ${role2} one`);
|
|
13438
13486
|
}
|
|
13439
13487
|
const profile = options.profile ?? PRODUCTION_PROFILE;
|
|
13440
13488
|
if (parsed.profile !== profile) {
|