@dotbots-boutique/auth-sdk 1.0.13 → 1.0.14

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/cjs/index.js CHANGED
@@ -257,6 +257,7 @@ class DotBotsAuth {
257
257
  this.listeners = new Map();
258
258
  this.cachedUser = null;
259
259
  this.initialized = false;
260
+ this.initializePromise = null;
260
261
  this.config = config;
261
262
  this.environment = this.detectEnvironment();
262
263
  console.warn(`[DotBotsAuth] SDK v${DotBotsAuth.SDK_VERSION} — env: ${this.environment}, appId: ${config.appId}`);
@@ -266,6 +267,13 @@ class DotBotsAuth {
266
267
  this.proxyConfigManager = new ProxyConfigManager(config.apiUrl, config.appId, this.environment);
267
268
  }
268
269
  async initialize() {
270
+ // Idempotency guard — safe to call multiple times (React StrictMode)
271
+ if (this.initializePromise)
272
+ return this.initializePromise;
273
+ this.initializePromise = this._doInitialize();
274
+ return this.initializePromise;
275
+ }
276
+ async _doInitialize() {
269
277
  // Step 1 — Fetch proxy config
270
278
  await this.proxyConfigManager.fetchConfig();
271
279
  // Step 2 — Authenticate
@@ -448,7 +456,7 @@ class DotBotsAuth {
448
456
  }
449
457
  }
450
458
  }
451
- DotBotsAuth.SDK_VERSION = '1.0.13';
459
+ DotBotsAuth.SDK_VERSION = '1.0.14';
452
460
 
453
461
  exports.DotBotsAuth = DotBotsAuth;
454
462
  exports.DotBotsAuthError = DotBotsAuthError;
package/dist/esm/index.js CHANGED
@@ -255,6 +255,7 @@ class DotBotsAuth {
255
255
  this.listeners = new Map();
256
256
  this.cachedUser = null;
257
257
  this.initialized = false;
258
+ this.initializePromise = null;
258
259
  this.config = config;
259
260
  this.environment = this.detectEnvironment();
260
261
  console.warn(`[DotBotsAuth] SDK v${DotBotsAuth.SDK_VERSION} — env: ${this.environment}, appId: ${config.appId}`);
@@ -264,6 +265,13 @@ class DotBotsAuth {
264
265
  this.proxyConfigManager = new ProxyConfigManager(config.apiUrl, config.appId, this.environment);
265
266
  }
266
267
  async initialize() {
268
+ // Idempotency guard — safe to call multiple times (React StrictMode)
269
+ if (this.initializePromise)
270
+ return this.initializePromise;
271
+ this.initializePromise = this._doInitialize();
272
+ return this.initializePromise;
273
+ }
274
+ async _doInitialize() {
267
275
  // Step 1 — Fetch proxy config
268
276
  await this.proxyConfigManager.fetchConfig();
269
277
  // Step 2 — Authenticate
@@ -446,6 +454,6 @@ class DotBotsAuth {
446
454
  }
447
455
  }
448
456
  }
449
- DotBotsAuth.SDK_VERSION = '1.0.13';
457
+ DotBotsAuth.SDK_VERSION = '1.0.14';
450
458
 
451
459
  export { DotBotsAuth, DotBotsAuthError };
@@ -8,9 +8,11 @@ export declare class DotBotsAuth {
8
8
  private readonly listeners;
9
9
  private cachedUser;
10
10
  private initialized;
11
- static readonly SDK_VERSION = "1.0.13";
11
+ private initializePromise;
12
+ static readonly SDK_VERSION = "1.0.14";
12
13
  constructor(config: DotBotsConfig);
13
14
  initialize(): Promise<void>;
15
+ private _doInitialize;
14
16
  getUser(): Promise<DotBotsUser>;
15
17
  can(permission: string): boolean;
16
18
  canAll(permissions: string[]): boolean;
@@ -255,6 +255,7 @@ class DotBotsAuth {
255
255
  this.listeners = new Map();
256
256
  this.cachedUser = null;
257
257
  this.initialized = false;
258
+ this.initializePromise = null;
258
259
  this.config = config;
259
260
  this.environment = this.detectEnvironment();
260
261
  console.warn(`[DotBotsAuth] SDK v${DotBotsAuth.SDK_VERSION} — env: ${this.environment}, appId: ${config.appId}`);
@@ -264,6 +265,13 @@ class DotBotsAuth {
264
265
  this.proxyConfigManager = new ProxyConfigManager(config.apiUrl, config.appId, this.environment);
265
266
  }
266
267
  async initialize() {
268
+ // Idempotency guard — safe to call multiple times (React StrictMode)
269
+ if (this.initializePromise)
270
+ return this.initializePromise;
271
+ this.initializePromise = this._doInitialize();
272
+ return this.initializePromise;
273
+ }
274
+ async _doInitialize() {
267
275
  // Step 1 — Fetch proxy config
268
276
  await this.proxyConfigManager.fetchConfig();
269
277
  // Step 2 — Authenticate
@@ -446,6 +454,6 @@ class DotBotsAuth {
446
454
  }
447
455
  }
448
456
  }
449
- DotBotsAuth.SDK_VERSION = '1.0.13';
457
+ DotBotsAuth.SDK_VERSION = '1.0.14';
450
458
 
451
459
  export { DotBotsAuth, DotBotsAuthError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotbots-boutique/auth-sdk",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Authentication SDK for DotBots marketplace apps",
5
5
  "license": "MIT",
6
6
  "type": "module",