@powerhousedao/connect 1.0.25-dev.4 → 1.0.25-dev.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.
Files changed (28) hide show
  1. package/dist/assets/{app-CRmO9P_Q.js → app-T9rQGx2K.js} +200 -132
  2. package/dist/assets/{app-CRmO9P_Q.js.map → app-T9rQGx2K.js.map} +1 -1
  3. package/dist/assets/{app-loader-CtKitdaN.js → app-loader-B-w7UEk6.js} +40 -24
  4. package/dist/assets/app-loader-B-w7UEk6.js.map +1 -0
  5. package/dist/assets/{browser-B8WxqFi2.js → browser-ri5iDC_K.js} +4 -4
  6. package/dist/assets/{browser-B8WxqFi2.js.map → browser-ri5iDC_K.js.map} +1 -1
  7. package/dist/assets/{ccip-CS73bbHO.js → ccip-Y3dC6oMF.js} +4 -4
  8. package/dist/assets/{ccip-CS73bbHO.js.map → ccip-Y3dC6oMF.js.map} +1 -1
  9. package/dist/assets/{content-B9a9DnAp.js → content-_hdHgMF_.js} +5 -5
  10. package/dist/assets/{content-B9a9DnAp.js.map → content-_hdHgMF_.js.map} +1 -1
  11. package/dist/assets/{index-DB7sJATC.js → index-BKMFaFhk.js} +4 -4
  12. package/dist/assets/{index-DB7sJATC.js.map → index-BKMFaFhk.js.map} +1 -1
  13. package/dist/assets/{index-a0Tjk_Qp.js → index-Baz3k_Dm.js} +5 -5
  14. package/dist/assets/{index-a0Tjk_Qp.js.map → index-Baz3k_Dm.js.map} +1 -1
  15. package/dist/assets/{index-mB2H2vrd.js → index-C6FVsc7U.js} +4 -4
  16. package/dist/assets/{index-mB2H2vrd.js.map → index-C6FVsc7U.js.map} +1 -1
  17. package/dist/assets/{index-CmPCHu-v.js → index-sowWhYc4.js} +4 -4
  18. package/dist/assets/{index-CmPCHu-v.js.map → index-sowWhYc4.js.map} +1 -1
  19. package/dist/assets/{main.BV7j6exc.js → main.B5xk8bat.js} +2 -2
  20. package/dist/assets/{main.BV7j6exc.js.map → main.B5xk8bat.js.map} +1 -1
  21. package/dist/assets/{reactor-analytics-BLqDApmT.js → reactor-analytics-BySD9c7q.js} +6 -6
  22. package/dist/assets/{reactor-analytics-BLqDApmT.js.map → reactor-analytics-BySD9c7q.js.map} +1 -1
  23. package/dist/assets/{router-DbL0m4kL.js → router-DH5pnBCa.js} +6 -6
  24. package/dist/assets/{router-DbL0m4kL.js.map → router-DH5pnBCa.js.map} +1 -1
  25. package/dist/index.html +1 -1
  26. package/dist/vite-envs.sh +1 -1
  27. package/package.json +7 -7
  28. package/dist/assets/app-loader-CtKitdaN.js.map +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ccip-CS73bbHO.js","assets/main.BV7j6exc.js","assets/app-loader-CtKitdaN.js","assets/app-loader-b43YtazY.css","assets/index-mB2H2vrd.js","assets/style-CK8AY-7U.css","assets/index-a0Tjk_Qp.js","assets/browser-B8WxqFi2.js","assets/router-DbL0m4kL.js","assets/reactor-analytics-BLqDApmT.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ccip-Y3dC6oMF.js","assets/main.B5xk8bat.js","assets/app-loader-B-w7UEk6.js","assets/app-loader-b43YtazY.css","assets/index-C6FVsc7U.js","assets/style-CK8AY-7U.css","assets/index-Baz3k_Dm.js","assets/browser-ri5iDC_K.js","assets/router-DH5pnBCa.js","assets/reactor-analytics-BySD9c7q.js"])))=>i.map(i=>d[i]);
2
2
  var __defProp = Object.defineProperty;
3
3
  var __typeError = (msg) => {
4
4
  throw TypeError(msg);
@@ -18,10 +18,10 @@ var __privateWrapper = (obj, member, setter, getter) => ({
18
18
  return __privateGet(obj, member, getter);
19
19
  }
20
20
  });
21
- var _InternalTransmitter_instances, buildInternalOperationUpdate_fn, _focused, _cleanup, _setup, _a, _online, _cleanup2, _setup2, _b, _gcTimeout, _c, _initialState, _revertState, _cache, _retryer, _defaultOptions, _abortSignalConsumed, _Query_instances, dispatch_fn, _d, _queries, _e2, _observers, _mutationCache, _retryer2, _Mutation_instances, dispatch_fn2, _f, _mutations, _scopes, _mutationId, _g, _queryCache, _mutationCache2, _defaultOptions2, _queryDefaults, _mutationDefaults, _mountCount, _unsubscribeFocus, _unsubscribeOnline, _h, _client, _currentQuery, _currentQueryInitialState, _currentResult, _currentResultState, _currentResultOptions, _currentThenable, _selectError, _selectFn, _selectResult, _lastQueryWithDefinedData, _staleTimeoutId, _refetchIntervalId, _currentRefetchInterval, _trackedProps, _QueryObserver_instances, executeFetch_fn, updateStaleTimeout_fn, computeRefetchInterval_fn, updateRefetchInterval_fn, updateTimers_fn, clearStaleTimeout_fn, clearRefetchInterval_fn, updateQuery_fn, notify_fn, _i, _subtleCrypto, _keyPair, _keyPairStorage, _did, _ConnectCrypto_instances, initCrypto_fn, initialize_fn, parseDid_fn, generateECDSAKeyPair_fn, exportKeyPair_fn, importKeyPair_fn, _sign, _verify, stringToBytes_fn;
22
- import { _ as __vitePreload } from "./main.BV7j6exc.js";
21
+ var _InternalTransmitter_instances, buildInternalOperationUpdate_fn, _focused, _cleanup, _setup, _a, _online, _cleanup2, _setup2, _b, _gcTimeout, _c, _initialState, _revertState, _cache, _retryer, _defaultOptions, _abortSignalConsumed, _Query_instances, dispatch_fn, _d, _queries, _e2, _observers, _mutationCache, _retryer2, _Mutation_instances, dispatch_fn2, _f, _mutations, _scopes, _mutationId, _g, _queryCache, _mutationCache2, _defaultOptions2, _queryDefaults, _mutationDefaults, _mountCount, _unsubscribeFocus, _unsubscribeOnline, _h, _client, _currentQuery, _currentQueryInitialState, _currentResult, _currentResultState, _currentResultOptions, _currentThenable, _selectError, _selectFn, _selectResult, _lastQueryWithDefinedData, _staleTimeoutId, _refetchIntervalId, _currentRefetchInterval, _trackedProps, _QueryObserver_instances, executeFetch_fn, updateStaleTimeout_fn, computeRefetchInterval_fn, updateRefetchInterval_fn, updateTimers_fn, clearStaleTimeout_fn, clearRefetchInterval_fn, updateQuery_fn, notify_fn, _i, _subtleCrypto, _keyPair, _keyPairStorage, _did, _bearerToken, _ConnectCrypto_instances, initCrypto_fn, initialize_fn, parseDid_fn, generateECDSAKeyPair_fn, exportKeyPair_fn, importKeyPair_fn, _sign, _verify, stringToBytes_fn;
22
+ import { _ as __vitePreload } from "./main.B5xk8bat.js";
23
23
  import { jsx as jsx$1, jsxs, Fragment } from "react/jsx-runtime";
24
- import { c as createAction, a as createReducer, i as isDocumentAction, R as ReorderStateExamplesInputSchema, D as DeleteStateExampleInputSchema, U as UpdateStateExampleInputSchema, A as AddStateExampleInputSchema, S as SetInitialStateInputSchema, b as SetStateSchemaInputSchema, d as ReorderModuleOperationsInputSchema, e as DeleteOperationInputSchema, M as MoveOperationInputSchema, f as SetOperationReducerInputSchema, g as SetOperationTemplateInputSchema, h as SetOperationDescriptionInputSchema, j as SetOperationSchemaInputSchema, k as SetOperationScopeInputSchema, l as SetOperationNameInputSchema, m as AddOperationInputSchema, n as ReorderOperationExamplesInputSchema, o as DeleteOperationExampleInputSchema, p as UpdateOperationExampleInputSchema, q as AddOperationExampleInputSchema, r as ReorderOperationErrorsInputSchema, s as DeleteOperationErrorInputSchema, t as SetOperationErrorTemplateInputSchema, u as SetOperationErrorDescriptionInputSchema, v as SetOperationErrorNameInputSchema, w as SetOperationErrorCodeInputSchema, x as AddOperationErrorInputSchema, y as ReorderModulesInputSchema, z as DeleteModuleInputSchema, B as SetModuleDescriptionInputSchema, C as SetModuleNameInputSchema, E as AddModuleInputSchema, F as ReorderChangeLogItemsInputSchema, G as DeleteChangeLogItemInputSchema, H as UpdateChangeLogItemInputSchema, I as AddChangeLogItemInputSchema, J as SetAuthorWebsiteInputSchema, K as SetAuthorNameInputSchema, L as SetModelDescriptionInputSchema, N as SetModelExtensionInputSchema, O as SetModelIdInputSchema, P as SetModelNameInputSchema, Q as baseCreateExtendedState, T as baseCreateDocument, V as baseSaveToFile, W as baseSaveToFileHandle, X as baseLoadFromFile, Y as baseLoadFromInput, Z as pascalCase, _ as logger$3, $ as utils, a0 as Icon, a1 as getDefaultExportFromCjs, a2 as LOCAL, a3 as commonjsGlobal, a4 as PUBLIC, a5 as SWITCHBOARD, a6 as locationInfoByLocation, a7 as sharingTypeOptions, a8 as objectType, a9 as recordType, aa as stringType, ab as capitalCase, ac as CLOUD, ad as createZip, ae as LZString, af as buildSignedOperation, ag as getI18n, ah as getDefaults, ai as connectConfig, aj as hashDocumentStateForScope, ak as getAugmentedNamespace, al as childLogger, am as process, an as setErrorHandler, ao as module, ap as createBrowserStorage, aq as createBrowserDocumentDriveServer, ar as generateId, as as reducer$8, at as isDocumentDrive, au as generateAddNodeAction, av as isFileNode, aw as uploadDocumentOperations, ax as updateFile, ay as addFolder, az as isFolderNode, aA as deleteNode, aB as updateNode, aC as FILE$1, aD as moveNode, aE as generateNodesCopy, aF as copyNode, aG as setDriveName, aH as setAvailableOffline, aI as setSharingType, aJ as SynchronizationUnitNotFoundError, aK as removeTrigger, aL as PullResponderTransmitter, aM as addTrigger, aN as ReadDriveNotFoundError, aO as openUrl, aP as getNodeOptions, aQ as DRIVE$1, aR as FOLDER, aS as requestPublicDrive, aT as serviceWorkerManager, aU as packageJson, aV as t$1 } from "./app-loader-CtKitdaN.js";
24
+ import { c as createAction, a as createReducer, i as isDocumentAction, R as ReorderStateExamplesInputSchema, D as DeleteStateExampleInputSchema, U as UpdateStateExampleInputSchema, A as AddStateExampleInputSchema, S as SetInitialStateInputSchema, b as SetStateSchemaInputSchema, d as ReorderModuleOperationsInputSchema, e as DeleteOperationInputSchema, M as MoveOperationInputSchema, f as SetOperationReducerInputSchema, g as SetOperationTemplateInputSchema, h as SetOperationDescriptionInputSchema, j as SetOperationSchemaInputSchema, k as SetOperationScopeInputSchema, l as SetOperationNameInputSchema, m as AddOperationInputSchema, n as ReorderOperationExamplesInputSchema, o as DeleteOperationExampleInputSchema, p as UpdateOperationExampleInputSchema, q as AddOperationExampleInputSchema, r as ReorderOperationErrorsInputSchema, s as DeleteOperationErrorInputSchema, t as SetOperationErrorTemplateInputSchema, u as SetOperationErrorDescriptionInputSchema, v as SetOperationErrorNameInputSchema, w as SetOperationErrorCodeInputSchema, x as AddOperationErrorInputSchema, y as ReorderModulesInputSchema, z as DeleteModuleInputSchema, B as SetModuleDescriptionInputSchema, C as SetModuleNameInputSchema, E as AddModuleInputSchema, F as ReorderChangeLogItemsInputSchema, G as DeleteChangeLogItemInputSchema, H as UpdateChangeLogItemInputSchema, I as AddChangeLogItemInputSchema, J as SetAuthorWebsiteInputSchema, K as SetAuthorNameInputSchema, L as SetModelDescriptionInputSchema, N as SetModelExtensionInputSchema, O as SetModelIdInputSchema, P as SetModelNameInputSchema, Q as baseCreateExtendedState, T as baseCreateDocument, V as baseSaveToFile, W as baseSaveToFileHandle, X as baseLoadFromFile, Y as baseLoadFromInput, Z as pascalCase, _ as logger$3, $ as utils, a0 as Icon, a1 as getDefaultExportFromCjs, a2 as LOCAL, a3 as commonjsGlobal, a4 as PUBLIC, a5 as SWITCHBOARD, a6 as locationInfoByLocation, a7 as sharingTypeOptions, a8 as objectType, a9 as recordType, aa as stringType, ab as capitalCase, ac as CLOUD, ad as createZip, ae as LZString, af as buildSignedOperation, ag as getI18n, ah as getDefaults, ai as connectConfig, aj as hashDocumentStateForScope, ak as getAugmentedNamespace, al as childLogger, am as process, an as setErrorHandler, ao as module, ap as createBrowserDocumentDriveServer, aq as createBrowserStorage, ar as generateId, as as reducer$8, at as isDocumentDrive, au as generateAddNodeAction, av as isFileNode, aw as uploadDocumentOperations, ax as updateFile, ay as addFolder, az as isFolderNode, aA as deleteNode, aB as updateNode, aC as FILE$1, aD as moveNode, aE as generateNodesCopy, aF as copyNode, aG as setDriveName, aH as setAvailableOffline, aI as setSharingType, aJ as SynchronizationUnitNotFoundError, aK as removeTrigger, aL as PullResponderTransmitter, aM as addTrigger, aN as ReadDriveNotFoundError, aO as openUrl, aP as getNodeOptions, aQ as DRIVE$1, aR as FOLDER, aS as requestPublicDrive, aT as serviceWorkerManager, aU as packageJson, aV as t$1 } from "./app-loader-B-w7UEk6.js";
25
25
  import * as React from "react";
26
26
  import React__default, { useLayoutEffect, useEffect, useState, forwardRef, useCallback, useContext, useRef, useMemo, createContext, Component, Fragment as Fragment$1, createElement, useId as useId$2, useSyncExternalStore, isValidElement, cloneElement, Children, useReducer, useDebugValue, Suspense, lazy } from "react";
27
27
  import * as ReactDOM from "react-dom";
@@ -22071,7 +22071,7 @@ async function call(client2, args) {
22071
22071
  } catch (err) {
22072
22072
  const data2 = getRevertErrorData(err);
22073
22073
  const { offchainLookup, offchainLookupSignature } = await __vitePreload(async () => {
22074
- const { offchainLookup: offchainLookup2, offchainLookupSignature: offchainLookupSignature2 } = await import("./ccip-CS73bbHO.js");
22074
+ const { offchainLookup: offchainLookup2, offchainLookupSignature: offchainLookupSignature2 } = await import("./ccip-Y3dC6oMF.js");
22075
22075
  return { offchainLookup: offchainLookup2, offchainLookupSignature: offchainLookupSignature2 };
22076
22076
  }, true ? __vite__mapDeps([0,1,2,3]) : void 0);
22077
22077
  if (client2.ccipRead !== false && (data2 == null ? void 0 : data2.slice(0, 10)) === offchainLookupSignature && to)
@@ -59105,6 +59105,7 @@ const _ConnectCrypto = class _ConnectCrypto {
59105
59105
  __privateAdd(this, _keyPair);
59106
59106
  __privateAdd(this, _keyPairStorage);
59107
59107
  __privateAdd(this, _did);
59108
+ __privateAdd(this, _bearerToken);
59108
59109
  __privateAdd(this, _sign, async (...args) => {
59109
59110
  return (await __privateGet(this, _subtleCrypto)).sign(...args);
59110
59111
  });
@@ -59115,16 +59116,17 @@ const _ConnectCrypto = class _ConnectCrypto {
59115
59116
  __privateSet(this, _subtleCrypto, __privateMethod(this, _ConnectCrypto_instances, initCrypto_fn).call(this));
59116
59117
  __privateSet(this, _did, __privateMethod(this, _ConnectCrypto_instances, initialize_fn).call(this));
59117
59118
  }
59118
- async getBearerToken(driveUrl) {
59119
+ async getBearerToken(driveUrl, address, refresh = false) {
59119
59120
  const issuer = await this.getIssuer();
59120
- const token2 = await createAuthBearerToken(
59121
- Number(RENOWN_CHAIN_ID$1),
59122
- RENOWN_NETWORK_ID$1,
59123
- await __privateGet(this, _did),
59124
- issuer
59125
- );
59126
- console.log("token", token2);
59127
- return token2;
59121
+ if (refresh || !__privateGet(this, _bearerToken)) {
59122
+ __privateSet(this, _bearerToken, await createAuthBearerToken(
59123
+ Number(RENOWN_CHAIN_ID$1),
59124
+ RENOWN_NETWORK_ID$1,
59125
+ address || await __privateGet(this, _did),
59126
+ issuer
59127
+ ));
59128
+ }
59129
+ return __privateGet(this, _bearerToken);
59128
59130
  }
59129
59131
  did() {
59130
59132
  return __privateGet(this, _did);
@@ -59169,6 +59171,7 @@ _subtleCrypto = new WeakMap();
59169
59171
  _keyPair = new WeakMap();
59170
59172
  _keyPairStorage = new WeakMap();
59171
59173
  _did = new WeakMap();
59174
+ _bearerToken = new WeakMap();
59172
59175
  _ConnectCrypto_instances = new WeakSet();
59173
59176
  initCrypto_fn = function() {
59174
59177
  return new Promise((resolve, reject) => {
@@ -76705,7 +76708,7 @@ const useFilteredDocumentModels = () => {
76705
76708
  return filteredDocumentModels;
76706
76709
  };
76707
76710
  async function loadBaseEditors() {
76708
- const documentModelEditor = await __vitePreload(() => import("./index-mB2H2vrd.js"), true ? __vite__mapDeps([4,2,1,3]) : void 0);
76711
+ const documentModelEditor = await __vitePreload(() => import("./index-C6FVsc7U.js"), true ? __vite__mapDeps([4,2,1,3]) : void 0);
76709
76712
  await __vitePreload(() => Promise.resolve({}), true ? __vite__mapDeps([5]) : void 0);
76710
76713
  const module2 = documentModelEditor.documentModelEditorModule;
76711
76714
  return [module2];
@@ -76738,7 +76741,123 @@ const useGetEditor = () => {
76738
76741
  const [defaultDocumentModelEditor] = useDefaultDocumentModelEditor();
76739
76742
  return (documentType2) => editors ? getEditor(documentType2, editors, defaultDocumentModelEditor.value) : void 0;
76740
76743
  };
76744
+ let _connectCrypto;
76745
+ async function initConnectCrypto() {
76746
+ const { ConnectCrypto: ConnectCrypto2 } = await __vitePreload(async () => {
76747
+ const { ConnectCrypto: ConnectCrypto3 } = await import("./index-Baz3k_Dm.js");
76748
+ return { ConnectCrypto: ConnectCrypto3 };
76749
+ }, true ? __vite__mapDeps([6,2,1,3]) : void 0);
76750
+ const { BrowserKeyStorage } = await __vitePreload(async () => {
76751
+ const { BrowserKeyStorage: BrowserKeyStorage2 } = await import("./index-Baz3k_Dm.js");
76752
+ return { BrowserKeyStorage: BrowserKeyStorage2 };
76753
+ }, true ? __vite__mapDeps([6,2,1,3]) : void 0);
76754
+ const connectCrypto = new ConnectCrypto2(new BrowserKeyStorage());
76755
+ await connectCrypto.did();
76756
+ return connectCrypto;
76757
+ }
76758
+ function getConnectCrypto() {
76759
+ if (window.connectCrypto) {
76760
+ return Promise.resolve(window.connectCrypto);
76761
+ }
76762
+ if (_connectCrypto) {
76763
+ return _connectCrypto;
76764
+ }
76765
+ _connectCrypto = initConnectCrypto();
76766
+ return _connectCrypto;
76767
+ }
76768
+ function useConnectCrypto() {
76769
+ return useMemo(
76770
+ () => ({
76771
+ async regenerateDid() {
76772
+ const crypto2 = await getConnectCrypto();
76773
+ return crypto2.regenerateDid();
76774
+ },
76775
+ async did() {
76776
+ const crypto2 = await getConnectCrypto();
76777
+ return crypto2.did();
76778
+ },
76779
+ sign: async (data) => {
76780
+ const crypto2 = await getConnectCrypto();
76781
+ return await crypto2.sign(data);
76782
+ },
76783
+ async getIssuer() {
76784
+ const crypto2 = await getConnectCrypto();
76785
+ return crypto2.getIssuer();
76786
+ },
76787
+ async getBearerToken(driveUrl, address, refresh = false) {
76788
+ const crypto2 = await getConnectCrypto();
76789
+ return crypto2.getBearerToken(driveUrl, address, refresh);
76790
+ }
76791
+ }),
76792
+ []
76793
+ );
76794
+ }
76795
+ const didAtom = atom(void 0);
76796
+ function useConnectDid() {
76797
+ const [did, setDid] = useAtom(didAtom);
76798
+ useEffect(() => {
76799
+ if (did) {
76800
+ return;
76801
+ }
76802
+ getConnectCrypto().then((c2) => c2.did()).then((did2) => setDid(did2)).catch(logger$3.error);
76803
+ });
76804
+ return did;
76805
+ }
76806
+ const renownStatusAtom = atom("idle");
76807
+ const renownAtom = atom(
76808
+ window.renown ? Promise.resolve(window.renown) : void 0
76809
+ );
76810
+ function useRenown() {
76811
+ const [renown, setRenown] = useAtom(renownAtom);
76812
+ const [, setRenownStatus] = useAtom(renownStatusAtom);
76813
+ const { did } = useConnectCrypto();
76814
+ async function initRenown(getDid) {
76815
+ setRenownStatus("loading");
76816
+ try {
76817
+ const did2 = await getDid();
76818
+ if (!did2) {
76819
+ setRenownStatus("error");
76820
+ return;
76821
+ }
76822
+ const { initRenownBrowser } = await __vitePreload(async () => {
76823
+ const { initRenownBrowser: initRenownBrowser2 } = await import("./index-Baz3k_Dm.js");
76824
+ return { initRenownBrowser: initRenownBrowser2 };
76825
+ }, true ? __vite__mapDeps([6,2,1,3]) : void 0);
76826
+ const renownBrowser = initRenownBrowser(did2);
76827
+ const renown2 = {
76828
+ user: function() {
76829
+ return Promise.resolve(renownBrowser.user);
76830
+ },
76831
+ login: function(did3) {
76832
+ return renownBrowser.login(did3);
76833
+ },
76834
+ logout() {
76835
+ return Promise.resolve(renownBrowser.logout());
76836
+ },
76837
+ on: {
76838
+ user(cb) {
76839
+ return renownBrowser.on("user", cb);
76840
+ }
76841
+ }
76842
+ };
76843
+ setRenownStatus("finished");
76844
+ return renown2;
76845
+ } catch (err) {
76846
+ console.error(
76847
+ "Error initializing renown:",
76848
+ err instanceof Error ? err.message : "Unknown error"
76849
+ );
76850
+ setRenownStatus("error");
76851
+ return void 0;
76852
+ }
76853
+ }
76854
+ if (!renown) {
76855
+ setRenown(initRenown(did));
76856
+ }
76857
+ return renown;
76858
+ }
76741
76859
  async function initReactor(reactor) {
76860
+ await initJwtHandler(reactor);
76742
76861
  const errors = await reactor.initialize();
76743
76862
  const error = errors == null ? void 0 : errors.at(0);
76744
76863
  if (error) {
@@ -76762,8 +76881,44 @@ async function initReactor(reactor) {
76762
76881
  }).catch(logger$3.error);
76763
76882
  }
76764
76883
  }
76884
+ async function initJwtHandler(server) {
76885
+ const renown = await atomStore.get(renownAtom);
76886
+ const user = await (renown == null ? void 0 : renown.user());
76887
+ const crypto2 = await getConnectCrypto();
76888
+ if (user == null ? void 0 : user.address) {
76889
+ server.setGenerateJwtHandler(async (driveUrl) => {
76890
+ return crypto2.getBearerToken(driveUrl, user.address);
76891
+ });
76892
+ }
76893
+ }
76894
+ async function waitForRenown() {
76895
+ return new Promise((resolve) => {
76896
+ const unsubscribe = observe$1((get2) => {
76897
+ try {
76898
+ const status = get2(renownStatusAtom);
76899
+ if (status === "finished" || status === "error") {
76900
+ unsubscribe();
76901
+ resolve();
76902
+ }
76903
+ } catch (err) {
76904
+ console.warn(
76905
+ "Error observing renown status:",
76906
+ err instanceof Error ? err.message : "Unknown error"
76907
+ );
76908
+ unsubscribe();
76909
+ resolve();
76910
+ }
76911
+ }, atomStore);
76912
+ setTimeout(() => {
76913
+ unsubscribe();
76914
+ console.warn("Timed out waiting for renown to initialize");
76915
+ resolve();
76916
+ }, 5e3);
76917
+ });
76918
+ }
76765
76919
  async function createReactor() {
76766
76920
  var _a2;
76921
+ await waitForRenown();
76767
76922
  const storage = atomStore.get(storageAtom);
76768
76923
  const documentModels = await atomStore.get(documentModelsAtom);
76769
76924
  const server = ((_a2 = window.electronAPI) == null ? void 0 : _a2.documentDrive) ?? createBrowserDocumentDriveServer(documentModels, storage);
@@ -76855,120 +77010,12 @@ const acceptedCookiesAtom = atomWithStorage(
76855
77010
  const useAcceptedCookies = () => {
76856
77011
  return useAtom(acceptedCookiesAtom);
76857
77012
  };
76858
- let _connectCrypto;
76859
- async function initConnectCrypto() {
76860
- const { ConnectCrypto: ConnectCrypto2 } = await __vitePreload(async () => {
76861
- const { ConnectCrypto: ConnectCrypto3 } = await import("./index-a0Tjk_Qp.js");
76862
- return { ConnectCrypto: ConnectCrypto3 };
76863
- }, true ? __vite__mapDeps([6,2,1,3]) : void 0);
76864
- const { BrowserKeyStorage } = await __vitePreload(async () => {
76865
- const { BrowserKeyStorage: BrowserKeyStorage2 } = await import("./index-a0Tjk_Qp.js");
76866
- return { BrowserKeyStorage: BrowserKeyStorage2 };
76867
- }, true ? __vite__mapDeps([6,2,1,3]) : void 0);
76868
- const connectCrypto = new ConnectCrypto2(new BrowserKeyStorage());
76869
- await connectCrypto.did();
76870
- return connectCrypto;
76871
- }
76872
- function getConnectCrypto() {
76873
- if (window.connectCrypto) {
76874
- return Promise.resolve(window.connectCrypto);
76875
- }
76876
- if (_connectCrypto) {
76877
- return _connectCrypto;
76878
- }
76879
- _connectCrypto = initConnectCrypto();
76880
- return _connectCrypto;
76881
- }
76882
- function useConnectCrypto() {
76883
- return useMemo(
76884
- () => ({
76885
- async regenerateDid() {
76886
- const crypto2 = await getConnectCrypto();
76887
- return crypto2.regenerateDid();
76888
- },
76889
- async did() {
76890
- const crypto2 = await getConnectCrypto();
76891
- return crypto2.did();
76892
- },
76893
- sign: async (data) => {
76894
- const crypto2 = await getConnectCrypto();
76895
- return await crypto2.sign(data);
76896
- },
76897
- async getIssuer() {
76898
- const crypto2 = await getConnectCrypto();
76899
- return crypto2.getIssuer();
76900
- },
76901
- async getBearerToken(driveUrl) {
76902
- const crypto2 = await getConnectCrypto();
76903
- return crypto2.getBearerToken(driveUrl);
76904
- }
76905
- }),
76906
- []
76907
- );
76908
- }
76909
- const didAtom = atom(void 0);
76910
- function useConnectDid() {
76911
- const [did, setDid] = useAtom(didAtom);
76912
- useEffect(() => {
76913
- if (did) {
76914
- return;
76915
- }
76916
- getConnectCrypto().then((c2) => c2.did()).then((did2) => setDid(did2)).catch(logger$3.error);
76917
- });
76918
- return did;
76919
- }
76920
- const renownAtom = atom(
76921
- window.renown ? Promise.resolve(window.renown) : void 0
76922
- );
76923
- function useRenown() {
76924
- const [renown, setRenown] = useAtom(renownAtom);
76925
- const { did, getBearerToken } = useConnectCrypto();
76926
- const reactor = useUnwrappedReactor();
76927
- useEffect(() => {
76928
- if (!renown || !reactor || !did) {
76929
- return;
76930
- }
76931
- reactor.setGenerateJwtHandler(getBearerToken);
76932
- }, [renown, reactor]);
76933
- async function initRenown(getDid) {
76934
- const did2 = await getDid();
76935
- if (!did2) {
76936
- return;
76937
- }
76938
- const { initRenownBrowser } = await __vitePreload(async () => {
76939
- const { initRenownBrowser: initRenownBrowser2 } = await import("./index-a0Tjk_Qp.js");
76940
- return { initRenownBrowser: initRenownBrowser2 };
76941
- }, true ? __vite__mapDeps([6,2,1,3]) : void 0);
76942
- const renownBrowser = initRenownBrowser(did2);
76943
- const renown2 = {
76944
- user: function() {
76945
- return Promise.resolve(renownBrowser.user);
76946
- },
76947
- login: function(did3) {
76948
- return renownBrowser.login(did3);
76949
- },
76950
- logout() {
76951
- return Promise.resolve(renownBrowser.logout());
76952
- },
76953
- on: {
76954
- user(cb) {
76955
- return renownBrowser.on("user", cb);
76956
- }
76957
- }
76958
- };
76959
- return renown2;
76960
- }
76961
- if (!renown) {
76962
- setRenown(initRenown(did));
76963
- }
76964
- return renown;
76965
- }
76966
77013
  const loginStatusAtom = atom("initial");
76967
77014
  const useLogin = () => {
76968
77015
  const [status, setStatus] = useAtom(loginStatusAtom);
76969
77016
  const user = useUser();
76970
77017
  const renown = useRenown();
76971
- const { did } = useConnectCrypto();
77018
+ const { did, getBearerToken } = useConnectCrypto();
76972
77019
  const openRenown = useCallback(async () => {
76973
77020
  var _a2;
76974
77021
  const connectId = await did();
@@ -77004,6 +77051,11 @@ const useLogin = () => {
77004
77051
  const newUser = await renown.login(userDid);
77005
77052
  if (newUser) {
77006
77053
  setStatus("authorized");
77054
+ atomStore.get(reactorAtom).then((reactor) => {
77055
+ reactor.setGenerateJwtHandler(
77056
+ async (driveUrl) => getBearerToken(driveUrl, newUser.address)
77057
+ );
77058
+ }).catch((err) => console.error(err));
77007
77059
  return newUser;
77008
77060
  } else {
77009
77061
  setStatus("not-authorized");
@@ -77023,6 +77075,9 @@ const useLogin = () => {
77023
77075
  const logout = useCallback(async () => {
77024
77076
  setStatus("initial");
77025
77077
  await (renown == null ? void 0 : renown.logout());
77078
+ atomStore.get(reactorAtom).then((reactor) => {
77079
+ reactor.removeJwtHandler();
77080
+ }).catch((err) => console.error(err));
77026
77081
  }, [renown]);
77027
77082
  return useMemo(
77028
77083
  () => ({
@@ -83481,6 +83536,7 @@ const Analytics = () => {
83481
83536
  };
83482
83537
  function AddDriveModal(props) {
83483
83538
  const { open, onAddLocalDrive, onAddRemoteDrive, onClose } = props;
83539
+ const user = useUser();
83484
83540
  const apps = useApps();
83485
83541
  const { getBearerToken } = useConnectCrypto();
83486
83542
  async function onAddLocalDriveSubmit(data) {
@@ -83498,10 +83554,22 @@ function AddDriveModal(props) {
83498
83554
  onAddLocalDrive: onAddLocalDriveSubmit,
83499
83555
  onAddRemoteDrive: onAddRemoteDriveSubmit,
83500
83556
  requestPublicDrive: async (url) => {
83501
- const authToken = await getBearerToken(url);
83502
- return requestPublicDrive(url, {
83503
- Authorization: `Bearer ${authToken}`
83504
- });
83557
+ try {
83558
+ const authToken = await getBearerToken(url, user == null ? void 0 : user.address);
83559
+ return requestPublicDrive(url, {
83560
+ Authorization: `Bearer ${authToken}`
83561
+ });
83562
+ } catch (error) {
83563
+ console.error(error);
83564
+ const authToken = await getBearerToken(
83565
+ url,
83566
+ user == null ? void 0 : user.address,
83567
+ true
83568
+ );
83569
+ return requestPublicDrive(url, {
83570
+ Authorization: `Bearer ${authToken}`
83571
+ });
83572
+ }
83505
83573
  },
83506
83574
  onOpenChange: (status) => {
83507
83575
  if (!status) return onClose();
@@ -91633,7 +91701,7 @@ async function createAnalyticsStore({ databaseName }) {
91633
91701
  return globalAnalytics.store;
91634
91702
  }
91635
91703
  const { BrowserAnalyticsStore } = await __vitePreload(async () => {
91636
- const { BrowserAnalyticsStore: BrowserAnalyticsStore2 } = await import("./browser-B8WxqFi2.js");
91704
+ const { BrowserAnalyticsStore: BrowserAnalyticsStore2 } = await import("./browser-ri5iDC_K.js");
91637
91705
  return { BrowserAnalyticsStore: BrowserAnalyticsStore2 };
91638
91706
  }, true ? __vite__mapDeps([7,2,1,3]) : void 0);
91639
91707
  const store = new BrowserAnalyticsStore({ databaseName });
@@ -91765,7 +91833,7 @@ atomStore.sub(reactorAtom, () => {
91765
91833
  return atomStore.get(processorManagerAtom);
91766
91834
  });
91767
91835
  const Router = React__default.lazy(async () => {
91768
- const createRouterComponent = await __vitePreload(() => import("./router-DbL0m4kL.js").then((n2) => n2.r), true ? __vite__mapDeps([8,1,2,3]) : void 0);
91836
+ const createRouterComponent = await __vitePreload(() => import("./router-DH5pnBCa.js").then((n2) => n2.r), true ? __vite__mapDeps([8,1,2,3]) : void 0);
91769
91837
  const router = await createRouterComponent.default();
91770
91838
  return { default: router };
91771
91839
  });
@@ -91777,7 +91845,7 @@ const Preloader = () => {
91777
91845
  return null;
91778
91846
  };
91779
91847
  const ReactorAnalyticsProvider = lazy(
91780
- () => __vitePreload(() => import("./reactor-analytics-BLqDApmT.js"), true ? __vite__mapDeps([9,1,2,3]) : void 0)
91848
+ () => __vitePreload(() => import("./reactor-analytics-BySD9c7q.js"), true ? __vite__mapDeps([9,1,2,3]) : void 0)
91781
91849
  );
91782
91850
  const App = () => /* @__PURE__ */ jsx$1(React__default.StrictMode, { children: /* @__PURE__ */ jsx$1(Suspense, { fallback: /* @__PURE__ */ jsx$1(Fragment, {}), children: /* @__PURE__ */ jsxs(Provider, { store: atomStore, children: [
91783
91851
  /* @__PURE__ */ jsx$1(Preloader, {}),
@@ -91955,4 +92023,4 @@ export {
91955
92023
  isLatestVersion as y,
91956
92024
  useParams as z
91957
92025
  };
91958
- //# sourceMappingURL=app-CRmO9P_Q.js.map
92026
+ //# sourceMappingURL=app-T9rQGx2K.js.map