@verentis/sdk 0.2.5 → 0.2.6
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/index.cjs +20 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -171,6 +171,7 @@ var ContextModule = class {
|
|
|
171
171
|
_apiUrl = null;
|
|
172
172
|
_application = null;
|
|
173
173
|
_installation = null;
|
|
174
|
+
_grants = null;
|
|
174
175
|
/** The current workspace */
|
|
175
176
|
get workspace() {
|
|
176
177
|
if (!this._workspace) {
|
|
@@ -217,6 +218,21 @@ var ContextModule = class {
|
|
|
217
218
|
get installation() {
|
|
218
219
|
return this._installation ? { ...this._installation } : null;
|
|
219
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* The boundaries of a brokered token (canvas documents), as the host sent them with the token; `null` when the
|
|
223
|
+
* token is not boundary-confined by a broker (or in standalone mode).
|
|
224
|
+
*/
|
|
225
|
+
get grants() {
|
|
226
|
+
return this._grants ? this._grants.map((grant) => ({ ...grant })) : null;
|
|
227
|
+
}
|
|
228
|
+
/** Update the token's grants from the host's init or token refresh message */
|
|
229
|
+
setGrants(grants) {
|
|
230
|
+
if (!Array.isArray(grants)) {
|
|
231
|
+
this._grants = null;
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
this._grants = grants.filter((grant) => typeof grant === "object" && grant !== null && typeof grant.type === "string" && typeof grant.identifier === "string" && typeof grant.path === "string" && grant.path.startsWith("/") && (grant.mode === "read" || grant.mode === "write") && typeof grant.source === "string").map((grant) => ({ type: grant.type, identifier: grant.identifier, path: grant.path, mode: grant.mode, source: grant.source }));
|
|
235
|
+
}
|
|
220
236
|
/** Update context from the host's init message */
|
|
221
237
|
setFromAppContext(ctx) {
|
|
222
238
|
if (ctx.application !== void 0 && (typeof ctx.application !== "object" || ctx.application === null || typeof ctx.application.manifestPath !== "string" || !ctx.application.manifestPath.startsWith("/") || typeof ctx.application.manifestNodeId !== "string" || !ctx.application.manifestNodeId.trim() || typeof ctx.application.branch !== "string" || !ctx.application.branch || ctx.application.branch !== ctx.application.branch.trim().toLowerCase() || /[\u0000-\u001f\u007f]/.test(ctx.application.branch))) {
|
|
@@ -1744,6 +1760,10 @@ var VerentisClient = class {
|
|
|
1744
1760
|
bridgeAuth.setHostOrigin(hostOrigin);
|
|
1745
1761
|
bridgeAuth.setToken(token);
|
|
1746
1762
|
this.context.setFromAppContext(context);
|
|
1763
|
+
this.context.setGrants(token.grants);
|
|
1764
|
+
this.bridge.on("verentis:token:refreshed", (message) => {
|
|
1765
|
+
if (message.type === "verentis:token:refreshed") this.context.setGrants(message.token?.grants);
|
|
1766
|
+
});
|
|
1747
1767
|
const http = new HttpTransport(
|
|
1748
1768
|
context.apiUrl,
|
|
1749
1769
|
bridgeAuth,
|