@rool-dev/extension 0.4.1 → 0.4.2-dev.e292e1c
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/dev/host-shell.js +71 -35
- package/dist/dev/host-shell.js.map +1 -1
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +10 -0
- package/dist/reactive.svelte.d.ts +9 -0
- package/dist/reactive.svelte.d.ts.map +1 -1
- package/dist/reactive.svelte.js +15 -0
- package/package.json +2 -2
package/dist/dev/host-shell.js
CHANGED
|
@@ -4556,21 +4556,22 @@ var BrowserAuthProvider = class {
|
|
|
4556
4556
|
* Initiate login by redirecting to auth page.
|
|
4557
4557
|
* @param appName - The name of the application requesting login (displayed on auth page)
|
|
4558
4558
|
*/
|
|
4559
|
-
login(appName) {
|
|
4560
|
-
this.redirectToAuth("login", appName);
|
|
4559
|
+
login(appName, params) {
|
|
4560
|
+
this.redirectToAuth("login", appName, params);
|
|
4561
4561
|
}
|
|
4562
4562
|
/**
|
|
4563
4563
|
* Initiate signup by redirecting to auth page.
|
|
4564
4564
|
* @param appName - The name of the application requesting signup (displayed on auth page)
|
|
4565
4565
|
*/
|
|
4566
|
-
signup(appName) {
|
|
4567
|
-
this.redirectToAuth("signup", appName);
|
|
4566
|
+
signup(appName, params) {
|
|
4567
|
+
this.redirectToAuth("signup", appName, params);
|
|
4568
4568
|
}
|
|
4569
|
-
redirectToAuth(flow, appName) {
|
|
4569
|
+
redirectToAuth(flow, appName, params) {
|
|
4570
4570
|
const url = new URL(`${this.authBaseUrl}/${flow}`);
|
|
4571
4571
|
const redirectTarget = window.location.origin + window.location.pathname + window.location.search;
|
|
4572
4572
|
url.searchParams.set("redirect_uri", redirectTarget);
|
|
4573
4573
|
url.searchParams.set("app_name", appName);
|
|
4574
|
+
if (params) for (const [key, value] of Object.entries(params)) url.searchParams.set(key, value);
|
|
4574
4575
|
const state = this.generateState();
|
|
4575
4576
|
this.storeState(state);
|
|
4576
4577
|
url.searchParams.set("state", state);
|
|
@@ -4843,15 +4844,15 @@ var AuthManager = class {
|
|
|
4843
4844
|
* Initiate login.
|
|
4844
4845
|
* @param appName - The name of the application requesting login (displayed on auth page)
|
|
4845
4846
|
*/
|
|
4846
|
-
login(appName) {
|
|
4847
|
-
return this.provider.login(appName);
|
|
4847
|
+
login(appName, params) {
|
|
4848
|
+
return this.provider.login(appName, params);
|
|
4848
4849
|
}
|
|
4849
4850
|
/**
|
|
4850
4851
|
* Initiate signup.
|
|
4851
4852
|
* @param appName - The name of the application requesting signup (displayed on auth page)
|
|
4852
4853
|
*/
|
|
4853
|
-
signup(appName) {
|
|
4854
|
-
return this.provider.signup(appName);
|
|
4854
|
+
signup(appName, params) {
|
|
4855
|
+
return this.provider.signup(appName, params);
|
|
4855
4856
|
}
|
|
4856
4857
|
/**
|
|
4857
4858
|
* Logout - clear all tokens and state.
|
|
@@ -7200,19 +7201,10 @@ var MediaClient = class {
|
|
|
7200
7201
|
}
|
|
7201
7202
|
/**
|
|
7202
7203
|
* Fetch an external URL via the server proxy (bypasses CORS).
|
|
7204
|
+
* Uses POST /fetch/:spaceId with cache-control hint for media.
|
|
7203
7205
|
*/
|
|
7204
7206
|
async fetchViaProxy(spaceId, url) {
|
|
7205
|
-
const
|
|
7206
|
-
if (!tokens) throw new Error("Not authenticated");
|
|
7207
|
-
const headers = {
|
|
7208
|
-
Authorization: `Bearer ${tokens.accessToken}`,
|
|
7209
|
-
"X-Rool-Token": tokens.roolToken
|
|
7210
|
-
};
|
|
7211
|
-
const proxyUrl = `${this.baseUrl(spaceId)}/proxy?url=${encodeURIComponent(url)}`;
|
|
7212
|
-
const response = await fetch(proxyUrl, {
|
|
7213
|
-
method: "GET",
|
|
7214
|
-
headers
|
|
7215
|
-
});
|
|
7207
|
+
const response = await this.proxyFetch(spaceId, url, { headers: { "Cache-Control": "private, max-age=3600" } });
|
|
7216
7208
|
if (!response.ok) throw new Error(`Failed to fetch media via proxy: ${response.status} ${response.statusText}`);
|
|
7217
7209
|
return response;
|
|
7218
7210
|
}
|
|
@@ -7234,6 +7226,29 @@ var MediaClient = class {
|
|
|
7234
7226
|
if (!response.ok && response.status !== 204) throw new Error(`Failed to delete media: ${response.status} ${response.statusText}`);
|
|
7235
7227
|
}
|
|
7236
7228
|
/**
|
|
7229
|
+
* Proxied fetch — execute an HTTP request via the server, bypassing CORS.
|
|
7230
|
+
* Uses POST /fetch/:spaceId on the backend.
|
|
7231
|
+
*/
|
|
7232
|
+
async proxyFetch(spaceId, url, init) {
|
|
7233
|
+
const tokens = await this.config.authManager.getTokens();
|
|
7234
|
+
if (!tokens) throw new Error("Not authenticated");
|
|
7235
|
+
const fetchUrl = `${this.config.backendOrigin}/fetch/${encodeURIComponent(spaceId)}`;
|
|
7236
|
+
return await fetch(fetchUrl, {
|
|
7237
|
+
method: "POST",
|
|
7238
|
+
headers: {
|
|
7239
|
+
"Content-Type": "application/json",
|
|
7240
|
+
Authorization: `Bearer ${tokens.accessToken}`,
|
|
7241
|
+
"X-Rool-Token": tokens.roolToken
|
|
7242
|
+
},
|
|
7243
|
+
body: JSON.stringify({
|
|
7244
|
+
url,
|
|
7245
|
+
method: init?.method,
|
|
7246
|
+
headers: init?.headers,
|
|
7247
|
+
body: init?.body
|
|
7248
|
+
})
|
|
7249
|
+
});
|
|
7250
|
+
}
|
|
7251
|
+
/**
|
|
7237
7252
|
* Export a space as a zip archive containing data and media.
|
|
7238
7253
|
* The archive includes data.json with objects, relations, metadata, and channels,
|
|
7239
7254
|
* plus a media/ folder with all media files.
|
|
@@ -8115,6 +8130,17 @@ var RoolChannel = class extends EventEmitter {
|
|
|
8115
8130
|
return this.mediaClient.delete(this._id, url);
|
|
8116
8131
|
}
|
|
8117
8132
|
/**
|
|
8133
|
+
* Fetch an external URL via the server proxy, bypassing CORS restrictions.
|
|
8134
|
+
* Requires editor role or above. Blocked for private/internal IP ranges (SSRF protection).
|
|
8135
|
+
*
|
|
8136
|
+
* @param url - The URL to fetch
|
|
8137
|
+
* @param init - Optional method, headers, and body
|
|
8138
|
+
* @returns The proxied Response
|
|
8139
|
+
*/
|
|
8140
|
+
async fetch(url, init) {
|
|
8141
|
+
return this.mediaClient.proxyFetch(this._id, url, init);
|
|
8142
|
+
}
|
|
8143
|
+
/**
|
|
8118
8144
|
* Register a collector that resolves when the object arrives via SSE.
|
|
8119
8145
|
* If the object is already in the buffer (arrived before collector), resolves immediately.
|
|
8120
8146
|
* @internal
|
|
@@ -8643,15 +8669,16 @@ var RoolClient = class extends EventEmitter {
|
|
|
8643
8669
|
* Initiate login by redirecting to auth page.
|
|
8644
8670
|
* @param appName - The name of the application requesting login (displayed on auth page)
|
|
8645
8671
|
*/
|
|
8646
|
-
async login(appName) {
|
|
8647
|
-
return this.authManager.login(appName);
|
|
8672
|
+
async login(appName, params) {
|
|
8673
|
+
return this.authManager.login(appName, params);
|
|
8648
8674
|
}
|
|
8649
8675
|
/**
|
|
8650
8676
|
* Initiate signup by redirecting to auth page.
|
|
8651
8677
|
* @param appName - The name of the application requesting signup (displayed on auth page)
|
|
8678
|
+
* @param params - Optional additional query parameters to pass to the auth server
|
|
8652
8679
|
*/
|
|
8653
|
-
async signup(appName) {
|
|
8654
|
-
return this.authManager.signup(appName);
|
|
8680
|
+
async signup(appName, params) {
|
|
8681
|
+
return this.authManager.signup(appName, params);
|
|
8655
8682
|
}
|
|
8656
8683
|
/**
|
|
8657
8684
|
* Logout - clear all tokens and state.
|
|
@@ -8677,12 +8704,12 @@ var RoolClient = class extends EventEmitter {
|
|
|
8677
8704
|
}
|
|
8678
8705
|
/**
|
|
8679
8706
|
* Make an authenticated fetch request to the Rool API.
|
|
8680
|
-
*
|
|
8707
|
+
* @internal Not part of the public API — use typed methods instead.
|
|
8681
8708
|
*
|
|
8682
8709
|
* @param path - Path relative to the base URL (e.g., '/billing/usage')
|
|
8683
8710
|
* @param init - Standard fetch RequestInit options. Authorization header is added automatically.
|
|
8684
8711
|
*/
|
|
8685
|
-
async
|
|
8712
|
+
async _api(path, init) {
|
|
8686
8713
|
const tokens = await this.authManager.getTokens();
|
|
8687
8714
|
if (!tokens) throw new Error("Not authenticated");
|
|
8688
8715
|
const headers = new Headers(init?.headers);
|
|
@@ -8978,15 +9005,9 @@ var RoolClient = class extends EventEmitter {
|
|
|
8978
9005
|
}
|
|
8979
9006
|
/**
|
|
8980
9007
|
* Execute an arbitrary GraphQL query or mutation.
|
|
8981
|
-
*
|
|
8982
|
-
*
|
|
8983
|
-
* @example
|
|
8984
|
-
* const result = await client.graphql<{ lastMessages: Message[] }>(
|
|
8985
|
-
* `query trace($spaceId: String!) { trace(spaceId: $spaceId) }`,
|
|
8986
|
-
* { spaceId: 'abc123' }
|
|
8987
|
-
* );
|
|
9008
|
+
* @internal Not part of the public API — use typed methods instead.
|
|
8988
9009
|
*/
|
|
8989
|
-
async
|
|
9010
|
+
async _graphql(query, variables) {
|
|
8990
9011
|
return this.graphqlClient.query(query, variables);
|
|
8991
9012
|
}
|
|
8992
9013
|
registerChannel(spaceId, channel) {
|
|
@@ -9140,7 +9161,8 @@ var ALLOWED_METHODS = new Set([
|
|
|
9140
9161
|
"canRedo",
|
|
9141
9162
|
"undo",
|
|
9142
9163
|
"redo",
|
|
9143
|
-
"clearHistory"
|
|
9164
|
+
"clearHistory",
|
|
9165
|
+
"fetch"
|
|
9144
9166
|
]);
|
|
9145
9167
|
var CONVERSATION_METHODS = new Set([
|
|
9146
9168
|
"getInteractions",
|
|
@@ -9241,6 +9263,20 @@ var BridgeHost = class {
|
|
|
9241
9263
|
result = fn.apply(target, args);
|
|
9242
9264
|
if (result instanceof Promise) result = await result;
|
|
9243
9265
|
} else result = fn;
|
|
9266
|
+
if (method === "fetch" && result instanceof Response) {
|
|
9267
|
+
const response = result;
|
|
9268
|
+
const headers = {};
|
|
9269
|
+
response.headers.forEach((v, k) => {
|
|
9270
|
+
headers[k] = v;
|
|
9271
|
+
});
|
|
9272
|
+
const body = await response.arrayBuffer();
|
|
9273
|
+
result = {
|
|
9274
|
+
status: response.status,
|
|
9275
|
+
statusText: response.statusText,
|
|
9276
|
+
headers,
|
|
9277
|
+
body
|
|
9278
|
+
};
|
|
9279
|
+
}
|
|
9244
9280
|
this._postToApp({
|
|
9245
9281
|
type: "rool:response",
|
|
9246
9282
|
id,
|