@medialane/sdk 0.146.0 → 0.148.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.
@@ -754,6 +754,10 @@ var ApiClient = class {
754
754
  async verifyEmailCode(email, code) {
755
755
  await this.post("/v1/auth/email/verify-code", { email, code });
756
756
  }
757
+ async confirmEmail(token) {
758
+ const body = await this.post("/v1/auth/email/confirm", { token });
759
+ return { email: body.email };
760
+ }
757
761
  setupWalletKey(params) {
758
762
  return this.post("/v1/users/me/wallet/key", params);
759
763
  }
@@ -13077,6 +13081,42 @@ async function completeDeployment(deps, onStep, options = {}) {
13077
13081
  deps.store.notifyChange();
13078
13082
  return { sealed, siwsToken };
13079
13083
  }
13084
+ function createDeploymentCoordinator(execute) {
13085
+ let inFlight = null;
13086
+ let currentStep = null;
13087
+ const listeners = /* @__PURE__ */ new Set();
13088
+ return {
13089
+ run(onStep, options = {}) {
13090
+ if (inFlight) {
13091
+ if (options.forceNew) {
13092
+ return Promise.reject(new Error("A wallet setup is already in progress."));
13093
+ }
13094
+ if (currentStep) onStep(currentStep);
13095
+ listeners.add(onStep);
13096
+ return inFlight.finally(() => listeners.delete(onStep));
13097
+ }
13098
+ listeners.add(onStep);
13099
+ let started;
13100
+ try {
13101
+ started = execute((step) => {
13102
+ currentStep = step;
13103
+ for (const listener of listeners) listener(step);
13104
+ }, options);
13105
+ } catch (err) {
13106
+ listeners.clear();
13107
+ return Promise.reject(err);
13108
+ }
13109
+ const run = started.finally(() => {
13110
+ inFlight = null;
13111
+ currentStep = null;
13112
+ listeners.clear();
13113
+ });
13114
+ inFlight = run;
13115
+ return run;
13116
+ },
13117
+ isDeploying: () => inFlight !== null
13118
+ };
13119
+ }
13080
13120
 
13081
13121
  // src/wallet/client.ts
13082
13122
  function describeDevices(owners, thisDevicePubkey) {
@@ -13093,6 +13133,18 @@ function canRemoveDevice(devices, guid) {
13093
13133
  }
13094
13134
  function createMediaWallet(config) {
13095
13135
  const ttl = config.unlockTtlMs ?? 2e4;
13136
+ const deployments = createDeploymentCoordinator((onStep, options) => {
13137
+ if (!config.backendUrl) throw new Error("This wallet has no backend url configured for sign-in");
13138
+ const deps = {
13139
+ store: config.store,
13140
+ passkey: config.passkey,
13141
+ provider: config.provider,
13142
+ backendUrl: config.backendUrl,
13143
+ deployProxyUrl: config.deployProxyUrl,
13144
+ fetchImpl: config.fetchImpl
13145
+ };
13146
+ return completeDeployment(deps, onStep, options);
13147
+ });
13096
13148
  const unlockCache = /* @__PURE__ */ new Map();
13097
13149
  const lock = (address) => {
13098
13150
  const entry = unlockCache.get(address);
@@ -13178,18 +13230,8 @@ function createMediaWallet(config) {
13178
13230
  const { transactionHash } = await run(sealed, [buildRemoveOwnerByGuidCall(sealed.address, ownerGuid)]);
13179
13231
  return transactionHash;
13180
13232
  },
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
- }
13233
+ completeDeployment: (onStep, options) => deployments.run(onStep, options),
13234
+ isDeploying: () => deployments.isDeploying()
13193
13235
  };
13194
13236
  }
13195
13237
 
@@ -13281,6 +13323,7 @@ exports.computeAccountAddress = computeAccountAddress;
13281
13323
  exports.computeOwnerGuid = computeOwnerGuid;
13282
13324
  exports.confirmIntentBestEffort = confirmIntentBestEffort;
13283
13325
  exports.createAdminSessionGrant = createAdminSessionGrant;
13326
+ exports.createDeploymentCoordinator = createDeploymentCoordinator;
13284
13327
  exports.createMediaWallet = createMediaWallet;
13285
13328
  exports.createOwnerStore = createOwnerStore;
13286
13329
  exports.createPasskeyOwner = createPasskeyOwner;