@calimero-network/mero-react 10.1.1 → 10.1.2

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.d.cts CHANGED
@@ -1836,8 +1836,8 @@ declare function clearAllStorage(): void;
1836
1836
  * navigate the app window off to another origin.
1837
1837
  *
1838
1838
  * Two signals, either is enough:
1839
- * - `__TAURI_INTERNALS__`, which Tauri injects natively into every webview it
1840
- * creates, remote URLs included — what mero-js's own Tauri check reads;
1839
+ * - `__TAURI_INTERNALS__` with a callable `invoke`, which Tauri injects natively
1840
+ * into every webview it creates, remote URLs included;
1841
1841
  * - `__TAURI_FETCH_PROXY_INJECTED__`, the marker the desktop's app-window
1842
1842
  * init script sets, in case a future Tauri stops exposing the former there.
1843
1843
  *
package/dist/index.d.ts CHANGED
@@ -1836,8 +1836,8 @@ declare function clearAllStorage(): void;
1836
1836
  * navigate the app window off to another origin.
1837
1837
  *
1838
1838
  * Two signals, either is enough:
1839
- * - `__TAURI_INTERNALS__`, which Tauri injects natively into every webview it
1840
- * creates, remote URLs included — what mero-js's own Tauri check reads;
1839
+ * - `__TAURI_INTERNALS__` with a callable `invoke`, which Tauri injects natively
1840
+ * into every webview it creates, remote URLs included;
1841
1841
  * - `__TAURI_FETCH_PROXY_INJECTED__`, the marker the desktop's app-window
1842
1842
  * init script sets, in case a future Tauri stops exposing the former there.
1843
1843
  *
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createContext, useMemo, useState, useRef, useCallback, useEffect, useContext, useReducer, useId, useSyncExternalStore } from 'react';
2
- import { LocalStorageTokenStore, readDelegatedSession, parseAuthCallback, MeroJs, buildAuthLoginUrl, saveDelegatedSession, saveDelegatedCredential, clearDelegatedSession, clearDelegatedCredential, relayForContext, buildDelegatedClient, readPinnedRelayNodeKey, learnRelayNodeKey, resolveApplicationIdFromRegistry, listDelegatedContexts, createAccountAdmin, createNodeAdmin, readEnrolmentCallback, completeDeviceEnrolment, CloudClient, deviceEnrolmentUrl, DEFAULT_LOCAL_NODE_PORTS, discoverLocalNodes, nodeEndpoint, createDelegatedContext, createDelegatedPrivateContext, governRoot, memberJoinedOpenOp, signerFromSecret, compareSemver, readDelegatedCredential, bootstrapFromInvitation, rememberRelay, carryExecutorAccount, shouldRetain, redeemInvitation, listDelegatedNamespaces, AuthRevokedError, HTTPError, foundDelegatedNamespace, joinAsAccount, classifyError } from '@calimero-network/mero-js';
2
+ import { LocalStorageTokenStore, readDelegatedSession, MeroJs, buildAuthLoginUrl, saveDelegatedSession, saveDelegatedCredential, clearDelegatedSession, clearDelegatedCredential, relayForContext, buildDelegatedClient, readPinnedRelayNodeKey, learnRelayNodeKey, resolveApplicationIdFromRegistry, listDelegatedContexts, createAccountAdmin, createNodeAdmin, readEnrolmentCallback, completeDeviceEnrolment, CloudClient, deviceEnrolmentUrl, DEFAULT_LOCAL_NODE_PORTS, discoverLocalNodes, nodeEndpoint, createDelegatedContext, createDelegatedPrivateContext, governRoot, memberJoinedOpenOp, signerFromSecret, compareSemver, readDelegatedCredential, bootstrapFromInvitation, rememberRelay, carryExecutorAccount, shouldRetain, redeemInvitation, listDelegatedNamespaces, AuthRevokedError, HTTPError, foundDelegatedNamespace, joinAsAccount, parseAuthCallback, classifyError } from '@calimero-network/mero-js';
3
3
  export * from '@calimero-network/mero-js';
4
4
  export { CAPABILITIES, DEFAULT_LOCAL_NODE_PORTS, HA_ACCOUNT_NOT_LINKED_MESSAGE, HA_REFUSAL_MESSAGES, InvitationNotClaimableError, NoRelayError, NotForAccountError, applicationIdForBundle, bootstrapFromInvitation, clearDelegatedCredential, createAccountAdmin, createDelegatedContext, createNodeAdmin, discoverLocalNodes, hasCap, joinWithNode, listDelegatedContexts, localNodeUrl, nodeEndpoint, normaliseAccount, pinRelayNodeKey, probeNodeHealth, readDelegatedCredential, readPinnedRelayNodeKey, readRelayMap, relayForContext, rememberRelay, resolveApplicationIdFromRegistry, resolveRelayFromInvitation, saveDelegatedCredential, selectLatestBundle, withCap, withoutCap } from '@calimero-network/mero-js';
5
5
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -133,6 +133,15 @@ function resolveTokenAdoption(params) {
133
133
  return { adopt: false, reason: "stale" };
134
134
  }
135
135
 
136
+ // src/utils/desktop.ts
137
+ function isDesktopWindow() {
138
+ if (typeof window === "undefined") return false;
139
+ const w = window;
140
+ const internals = w.__TAURI_INTERNALS__;
141
+ const tauri = typeof internals === "object" && internals !== null && !(typeof Node !== "undefined" && internals instanceof Node) && typeof internals.invoke === "function";
142
+ return tauri || w.__TAURI_FETCH_PROXY_INJECTED__ === true;
143
+ }
144
+
136
145
  // src/storage/index.ts
137
146
  var STORAGE_KEYS = {
138
147
  ACCESS_TOKEN: "mero:access_token",
@@ -283,6 +292,21 @@ function clearAllStorage() {
283
292
  var MeroContext = createContext(null);
284
293
  var DEFAULT_REGISTRY_URL = "https://apps.calimero.network";
285
294
  var isBrowser = typeof window !== "undefined";
295
+ var DESKTOP_HOST = isDesktopWindow();
296
+ var parsedCallback = null;
297
+ function readAuthCallback() {
298
+ const href = window.location.href;
299
+ if (parsedCallback?.href !== href) {
300
+ parsedCallback = { href, result: parseAuthCallback(href, { allowUnsolicited: DESKTOP_HOST }) };
301
+ }
302
+ return parsedCallback.result;
303
+ }
304
+ function clearAuthCallbackFromUrl() {
305
+ if (!new URLSearchParams(window.location.hash.slice(1)).has("access_token")) return;
306
+ const url = new URL(window.location.href);
307
+ url.searchParams.delete("auth_state");
308
+ window.history.replaceState({}, "", url.pathname + url.search);
309
+ }
286
310
  function getPermissionsForMode(mode) {
287
311
  switch (mode) {
288
312
  case "single-context" /* SingleContext */:
@@ -345,7 +369,7 @@ function MeroProvider({
345
369
  const recoveringRef = useRef(false);
346
370
  const callbackRef = useRef(void 0);
347
371
  if (callbackRef.current === void 0 && isBrowser) {
348
- callbackRef.current = parseAuthCallback(window.location.href);
372
+ callbackRef.current = readAuthCallback();
349
373
  }
350
374
  const createMeroInstance = useCallback(
351
375
  (url) => {
@@ -478,6 +502,7 @@ function MeroProvider({
478
502
  };
479
503
  }, [delegated, contextId, packageName, registryUrl]);
480
504
  useEffect(() => {
505
+ if (isBrowser) clearAuthCallbackFromUrl();
481
506
  if (delegated) return;
482
507
  let active = true;
483
508
  const init = async () => {
@@ -492,9 +517,6 @@ function MeroProvider({
492
517
  initiated: initiatedNodeUrl,
493
518
  allowedNodeUrls
494
519
  });
495
- if (isBrowser) {
496
- window.history.replaceState({}, "", window.location.pathname + window.location.search);
497
- }
498
520
  callbackRef.current = null;
499
521
  if (rejected) {
500
522
  console.error(
@@ -1019,13 +1041,6 @@ function useAccountEnrolment({
1019
1041
  customWallet: walletOverride !== void 0
1020
1042
  };
1021
1043
  }
1022
-
1023
- // src/utils/desktop.ts
1024
- function isDesktopWindow() {
1025
- if (typeof window === "undefined") return false;
1026
- const w = window;
1027
- return "__TAURI_INTERNALS__" in w || w.__TAURI_FETCH_PROXY_INJECTED__ === true;
1028
- }
1029
1044
  var CUSTOM_SELECTION = "__custom__";
1030
1045
  var TABS = [
1031
1046
  { id: "node", label: "Node" },