@medialane/sdk 0.146.0 → 0.147.0

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.
@@ -13077,6 +13077,42 @@ async function completeDeployment(deps, onStep, options = {}) {
13077
13077
  deps.store.notifyChange();
13078
13078
  return { sealed, siwsToken };
13079
13079
  }
13080
+ function createDeploymentCoordinator(execute) {
13081
+ let inFlight = null;
13082
+ let currentStep = null;
13083
+ const listeners = /* @__PURE__ */ new Set();
13084
+ return {
13085
+ run(onStep, options = {}) {
13086
+ if (inFlight) {
13087
+ if (options.forceNew) {
13088
+ return Promise.reject(new Error("A wallet setup is already in progress."));
13089
+ }
13090
+ if (currentStep) onStep(currentStep);
13091
+ listeners.add(onStep);
13092
+ return inFlight.finally(() => listeners.delete(onStep));
13093
+ }
13094
+ listeners.add(onStep);
13095
+ let started;
13096
+ try {
13097
+ started = execute((step) => {
13098
+ currentStep = step;
13099
+ for (const listener of listeners) listener(step);
13100
+ }, options);
13101
+ } catch (err) {
13102
+ listeners.clear();
13103
+ return Promise.reject(err);
13104
+ }
13105
+ const run = started.finally(() => {
13106
+ inFlight = null;
13107
+ currentStep = null;
13108
+ listeners.clear();
13109
+ });
13110
+ inFlight = run;
13111
+ return run;
13112
+ },
13113
+ isDeploying: () => inFlight !== null
13114
+ };
13115
+ }
13080
13116
 
13081
13117
  // src/wallet/client.ts
13082
13118
  function describeDevices(owners, thisDevicePubkey) {
@@ -13093,6 +13129,18 @@ function canRemoveDevice(devices, guid) {
13093
13129
  }
13094
13130
  function createMediaWallet(config) {
13095
13131
  const ttl = config.unlockTtlMs ?? 2e4;
13132
+ const deployments = createDeploymentCoordinator((onStep, options) => {
13133
+ if (!config.backendUrl) throw new Error("This wallet has no backend url configured for sign-in");
13134
+ const deps = {
13135
+ store: config.store,
13136
+ passkey: config.passkey,
13137
+ provider: config.provider,
13138
+ backendUrl: config.backendUrl,
13139
+ deployProxyUrl: config.deployProxyUrl,
13140
+ fetchImpl: config.fetchImpl
13141
+ };
13142
+ return completeDeployment(deps, onStep, options);
13143
+ });
13096
13144
  const unlockCache = /* @__PURE__ */ new Map();
13097
13145
  const lock = (address) => {
13098
13146
  const entry = unlockCache.get(address);
@@ -13178,18 +13226,8 @@ function createMediaWallet(config) {
13178
13226
  const { transactionHash } = await run(sealed, [buildRemoveOwnerByGuidCall(sealed.address, ownerGuid)]);
13179
13227
  return transactionHash;
13180
13228
  },
13181
- completeDeployment(onStep, options = {}) {
13182
- if (!config.backendUrl) throw new Error("This wallet has no backend url configured for sign-in");
13183
- const deps = {
13184
- store: config.store,
13185
- passkey: config.passkey,
13186
- provider: config.provider,
13187
- backendUrl: config.backendUrl,
13188
- deployProxyUrl: config.deployProxyUrl,
13189
- fetchImpl: config.fetchImpl
13190
- };
13191
- return completeDeployment(deps, onStep, options);
13192
- }
13229
+ completeDeployment: (onStep, options) => deployments.run(onStep, options),
13230
+ isDeploying: () => deployments.isDeploying()
13193
13231
  };
13194
13232
  }
13195
13233
 
@@ -13281,6 +13319,7 @@ exports.computeAccountAddress = computeAccountAddress;
13281
13319
  exports.computeOwnerGuid = computeOwnerGuid;
13282
13320
  exports.confirmIntentBestEffort = confirmIntentBestEffort;
13283
13321
  exports.createAdminSessionGrant = createAdminSessionGrant;
13322
+ exports.createDeploymentCoordinator = createDeploymentCoordinator;
13284
13323
  exports.createMediaWallet = createMediaWallet;
13285
13324
  exports.createOwnerStore = createOwnerStore;
13286
13325
  exports.createPasskeyOwner = createPasskeyOwner;