hypha-rpc 0.20.36 → 0.20.38

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.
@@ -4762,8 +4762,8 @@ class WebsocketRPCConnection {
4762
4762
  this._enable_reconnect = true;
4763
4763
  this._closed = false;
4764
4764
  this._websocket.onmessage = (event) => {
4765
- if (typeof data === "string") {
4766
- const parsedData = JSON.parse(data);
4765
+ if (typeof event.data === "string") {
4766
+ const parsedData = JSON.parse(event.data);
4767
4767
  // Check if the message is a reconnection token
4768
4768
  if (parsedData.type === "reconnection_token") {
4769
4769
  this._reconnection_token = parsedData.reconnection_token;
@@ -4909,6 +4909,8 @@ function normalizeServerUrl(server_url) {
4909
4909
 
4910
4910
  async function login(config) {
4911
4911
  const service_id = config.login_service_id || "public/hypha-login";
4912
+ const workspace = config.workspace;
4913
+ const expires_in = config.expires_in;
4912
4914
  const timeout = config.login_timeout || 60;
4913
4915
  const callback = config.login_callback;
4914
4916
  const profile = config.profile;
@@ -4920,13 +4922,18 @@ async function login(config) {
4920
4922
  try {
4921
4923
  const svc = await server.getService(service_id);
4922
4924
  (0,_utils__WEBPACK_IMPORTED_MODULE_1__.assert)(svc, `Failed to get the login service: ${service_id}`);
4923
- const context = await svc.start();
4925
+ let context;
4926
+ if (workspace) {
4927
+ context = await svc.start({ workspace, expires_in, _rkwargs: true });
4928
+ } else {
4929
+ context = await svc.start();
4930
+ }
4924
4931
  if (callback) {
4925
4932
  await callback(context);
4926
4933
  } else {
4927
4934
  console.log(`Please open your browser and login at ${context.login_url}`);
4928
4935
  }
4929
- return await svc.check(context.key, timeout, profile);
4936
+ return await svc.check(context.key, { timeout, profile, _rkwargs: true });
4930
4937
  } catch (error) {
4931
4938
  throw error;
4932
4939
  } finally {