@passkeyme/auth 1.2.0 → 1.3.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.
package/dist/index.umd.js CHANGED
@@ -5,7 +5,7 @@
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
7
  /**
8
- * Internal logging utility for PasskeyMe SDK
8
+ * Internal logging utility for Passkeyme SDK
9
9
  * Provides controlled logging that can be enabled/disabled in production
10
10
  */
11
11
  class Logger {
@@ -80,7 +80,7 @@
80
80
  });
81
81
 
82
82
  /**
83
- * Enhanced Error Handling for PasskeyMe SDK
83
+ * Enhanced Error Handling for Passkeyme SDK
84
84
  */
85
85
  exports.PasskeymeErrorCode = void 0;
86
86
  (function (PasskeymeErrorCode) {
@@ -240,7 +240,7 @@
240
240
  */
241
241
  class ErrorHandler {
242
242
  static logError(error, context) {
243
- console.group(`🚨 PasskeyMe Error${context ? ` [${context}]` : ""}`);
243
+ console.group(`🚨 Passkeyme Error${context ? ` [${context}]` : ""}`);
244
244
  logger.error("Code:", error.code);
245
245
  logger.error("Message:", error.message);
246
246
  logger.error("User Message:", error.userMessage);
@@ -262,7 +262,7 @@
262
262
  }
263
263
 
264
264
  /**
265
- * API Client for PasskeyMe authentication services
265
+ * API Client for Passkeyme authentication services
266
266
  */
267
267
  class PasskeymeApiClient {
268
268
  constructor(appId, baseUrl = "https://auth.passkeyme.com", debug = false) {
@@ -325,7 +325,7 @@
325
325
  * Get authentication configuration for the app
326
326
  */
327
327
  async getConfig() {
328
- const backendConfig = await this.request(`/api/auth/${this.appId}/config`);
328
+ const backendConfig = await this.request(`/api/${this.appId}/config`);
329
329
  // Map backend response to SDK format
330
330
  return {
331
331
  appId: backendConfig.app_id,
@@ -348,7 +348,7 @@
348
348
  */
349
349
  async startOAuth(provider, redirectUri) {
350
350
  const params = new URLSearchParams({ redirect_uri: redirectUri });
351
- const url = `${this.baseUrl}/api/auth/${this.appId}/oauth/${provider}/start?${params}`;
351
+ const url = `${this.baseUrl}/auth/${this.appId}/oauth/${provider}/start?${params}`;
352
352
  this.log("OAuth start URL:", url);
353
353
  return url;
354
354
  }
@@ -356,7 +356,7 @@
356
356
  * Start passkey authentication
357
357
  */
358
358
  async startPasskeyAuth(username) {
359
- return this.request(`/api/auth/${this.appId}/passkey/start`, {
359
+ return this.request(`/auth/${this.appId}/passkey/start`, {
360
360
  method: "POST",
361
361
  body: JSON.stringify({ username }),
362
362
  });
@@ -365,7 +365,7 @@
365
365
  * Complete passkey authentication
366
366
  */
367
367
  async completePasskeyAuth(credential, redirectUri) {
368
- return this.request(`/api/auth/${this.appId}/passkey/complete`, {
368
+ return this.request(`/auth/${this.appId}/passkey/complete`, {
369
369
  method: "POST",
370
370
  body: JSON.stringify({ credential, redirect_uri: redirectUri }),
371
371
  });
@@ -374,7 +374,7 @@
374
374
  * Login with username/password
375
375
  */
376
376
  async loginWithPassword(username, password, redirectUri) {
377
- return this.request(`/api/auth/${this.appId}/password/login`, {
377
+ return this.request(`/auth/${this.appId}/password/login`, {
378
378
  method: "POST",
379
379
  body: JSON.stringify({
380
380
  username,
@@ -387,7 +387,7 @@
387
387
  * Handle OAuth callback
388
388
  */
389
389
  async handleOAuthCallback(code, state) {
390
- return this.request(`/api/auth/${this.appId}/oauth/callback`, {
390
+ return this.request(`/auth/${this.appId}/oauth/callback`, {
391
391
  method: "POST",
392
392
  body: JSON.stringify({ code, state }),
393
393
  });
@@ -401,7 +401,7 @@
401
401
  token: token,
402
402
  app_id: this.appId,
403
403
  });
404
- const response = (await this.request(`/api/auth/verify-token?${params.toString()}`, {
404
+ const response = (await this.request(`/auth/verify-token?${params.toString()}`, {
405
405
  method: "GET",
406
406
  }));
407
407
  if (!response.valid) {
@@ -428,7 +428,7 @@
428
428
  * Refresh access token
429
429
  */
430
430
  async refreshToken(refreshToken) {
431
- return this.request("/api/auth/refresh-token", {
431
+ return this.request("/auth/refresh-token", {
432
432
  method: "POST",
433
433
  body: JSON.stringify({ refresh_token: refreshToken }),
434
434
  });
@@ -437,13 +437,13 @@
437
437
  * Get JWKS for token verification
438
438
  */
439
439
  async getJWKS() {
440
- return this.request("/api/auth/jwks");
440
+ return this.request("/auth/jwks");
441
441
  }
442
442
  /**
443
443
  * Exchange authorization code for tokens (hosted auth callback)
444
444
  */
445
445
  async exchangeCodeForTokens(code, redirectUri) {
446
- const result = await this.request("/api/auth/callback", {
446
+ const result = await this.request("/auth/callback", {
447
447
  method: "POST",
448
448
  body: JSON.stringify({
449
449
  code,
@@ -459,7 +459,7 @@
459
459
  * Browser storage implementation using localStorage or sessionStorage
460
460
  */
461
461
  class BrowserStorageProvider {
462
- constructor(useSessionStorage = false, keyPrefix = "@PasskeyMe:") {
462
+ constructor(useSessionStorage = false, keyPrefix = "@Passkeyme:") {
463
463
  this.keyPrefix = keyPrefix;
464
464
  if (typeof window === "undefined") {
465
465
  // Server-side environment - create a no-op storage
@@ -526,7 +526,7 @@
526
526
  }
527
527
 
528
528
  /**
529
- * Secure token storage for PasskeyMe Auth SDK
529
+ * Secure token storage for Passkeyme Auth SDK
530
530
  */
531
531
  class TokenStorage {
532
532
  constructor(storage, useSessionStorage = false) {
@@ -632,7 +632,7 @@
632
632
  TokenStorage.TOKEN_TYPE_KEY = "passkeyme_token_type";
633
633
 
634
634
  /**
635
- * Platform SDK Interface for PasskeyMe
635
+ * Platform SDK Interface for Passkeyme
636
636
  *
637
637
  * This interface abstracts platform-specific passkey operations,
638
638
  * allowing the core SDK to work across web, React Native, and other platforms.
@@ -805,7 +805,7 @@
805
805
  }
806
806
 
807
807
  /**
808
- * Main PasskeyMe Authentication SDK class
808
+ * Main Passkeyme Authentication SDK class
809
809
  */
810
810
  class PasskeymeAuth {
811
811
  constructor(config) {
@@ -1015,7 +1015,7 @@
1015
1015
  const params = new URLSearchParams({
1016
1016
  redirect_uri: finalRedirectUri,
1017
1017
  });
1018
- const oauthUrl = `${this.config.baseUrl}/api/auth/${this.config.appId}/oauth/${provider}/start?${params.toString()}`;
1018
+ const oauthUrl = `${this.config.baseUrl}/auth/${this.config.appId}/oauth/${provider}/start?${params.toString()}`;
1019
1019
  logger.debug("Redirecting directly to OAuth provider:", provider, oauthUrl);
1020
1020
  this.performRedirect(oauthUrl, finalRedirectUri);
1021
1021
  }
@@ -1367,7 +1367,7 @@
1367
1367
  const sdk = this.passkeySDK;
1368
1368
  // Dynamic import for axios (ES modules compatible)
1369
1369
  const { default: axios } = await Promise.resolve().then(function () { return index; });
1370
- // Create axios instance for PasskeyMe API
1370
+ // Create axios instance for Passkeyme API
1371
1371
  const axiosInstance = axios.create({
1372
1372
  baseURL: `${this.config.baseUrl}/webauthn/${this.config.appId}`,
1373
1373
  headers: {
@@ -1788,9 +1788,9 @@
1788
1788
  }
1789
1789
 
1790
1790
  /**
1791
- * PasskeyMe Authentication SDK
1791
+ * Passkeyme Authentication SDK
1792
1792
  *
1793
- * A simple, Firebase Auth-like SDK for authentication with PasskeyMe.
1793
+ * A simple, Firebase Auth-like SDK for authentication with Passkeyme.
1794
1794
  *
1795
1795
  * @example
1796
1796
  * ```typescript
@@ -1816,7 +1816,7 @@
1816
1816
  */
1817
1817
  // Main exports
1818
1818
  /**
1819
- * Create a new PasskeyMe Auth instance
1819
+ * Create a new Passkeyme Auth instance
1820
1820
  *
1821
1821
  * @param config - Configuration options
1822
1822
  * @returns PasskeymeAuth instance
@@ -1965,6 +1965,27 @@
1965
1965
  return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
1966
1966
  };
1967
1967
 
1968
+ /**
1969
+ * Determine if a value is an empty object (safely handles Buffers)
1970
+ *
1971
+ * @param {*} val The value to test
1972
+ *
1973
+ * @returns {boolean} True if value is an empty object, otherwise false
1974
+ */
1975
+ const isEmptyObject = (val) => {
1976
+ // Early return for non-objects or Buffers to prevent RangeError
1977
+ if (!isObject(val) || isBuffer(val)) {
1978
+ return false;
1979
+ }
1980
+
1981
+ try {
1982
+ return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
1983
+ } catch (e) {
1984
+ // Fallback for any other objects that might cause RangeError with Object.keys()
1985
+ return false;
1986
+ }
1987
+ };
1988
+
1968
1989
  /**
1969
1990
  * Determine if a value is a Date
1970
1991
  *
@@ -2087,6 +2108,11 @@
2087
2108
  fn.call(null, obj[i], i, obj);
2088
2109
  }
2089
2110
  } else {
2111
+ // Buffer check
2112
+ if (isBuffer(obj)) {
2113
+ return;
2114
+ }
2115
+
2090
2116
  // Iterate over object keys
2091
2117
  const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
2092
2118
  const len = keys.length;
@@ -2100,6 +2126,10 @@
2100
2126
  }
2101
2127
 
2102
2128
  function findKey(obj, key) {
2129
+ if (isBuffer(obj)){
2130
+ return null;
2131
+ }
2132
+
2103
2133
  key = key.toLowerCase();
2104
2134
  const keys = Object.keys(obj);
2105
2135
  let i = keys.length;
@@ -2453,6 +2483,11 @@
2453
2483
  return;
2454
2484
  }
2455
2485
 
2486
+ //Buffer check
2487
+ if (isBuffer(source)) {
2488
+ return source;
2489
+ }
2490
+
2456
2491
  if(!('toJSON' in source)) {
2457
2492
  stack[i] = source;
2458
2493
  const target = isArray(source) ? [] : {};
@@ -2524,6 +2559,7 @@
2524
2559
  isBoolean,
2525
2560
  isObject,
2526
2561
  isPlainObject,
2562
+ isEmptyObject,
2527
2563
  isReadableStream,
2528
2564
  isRequest,
2529
2565
  isResponse,
@@ -3155,7 +3191,7 @@
3155
3191
  };
3156
3192
 
3157
3193
  function toURLEncodedForm(data, options) {
3158
- return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
3194
+ return toFormData(data, new platform.classes.URLSearchParams(), {
3159
3195
  visitor: function(value, key, path, helpers) {
3160
3196
  if (platform.isNode && utils$1.isBuffer(value)) {
3161
3197
  this.append(key, value.toString('base64'));
@@ -3163,8 +3199,9 @@
3163
3199
  }
3164
3200
 
3165
3201
  return helpers.defaultVisitor.apply(this, arguments);
3166
- }
3167
- }, options));
3202
+ },
3203
+ ...options
3204
+ });
3168
3205
  }
3169
3206
 
3170
3207
  /**
@@ -3917,7 +3954,7 @@
3917
3954
  clearTimeout(timer);
3918
3955
  timer = null;
3919
3956
  }
3920
- fn.apply(null, args);
3957
+ fn(...args);
3921
3958
  };
3922
3959
 
3923
3960
  const throttled = (...args) => {
@@ -4173,7 +4210,7 @@
4173
4210
  headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
4174
4211
  };
4175
4212
 
4176
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
4213
+ utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
4177
4214
  const merge = mergeMap[prop] || mergeDeepProperties;
4178
4215
  const configValue = merge(config1[prop], config2[prop], prop);
4179
4216
  (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
@@ -4914,7 +4951,7 @@
4914
4951
  });
4915
4952
  }
4916
4953
 
4917
- const VERSION = "1.10.0";
4954
+ const VERSION = "1.11.0";
4918
4955
 
4919
4956
  const validators$1 = {};
4920
4957
 
@@ -5153,8 +5190,8 @@
5153
5190
 
5154
5191
  if (!synchronousRequestInterceptors) {
5155
5192
  const chain = [dispatchRequest.bind(this), undefined];
5156
- chain.unshift.apply(chain, requestInterceptorChain);
5157
- chain.push.apply(chain, responseInterceptorChain);
5193
+ chain.unshift(...requestInterceptorChain);
5194
+ chain.push(...responseInterceptorChain);
5158
5195
  len = chain.length;
5159
5196
 
5160
5197
  promise = Promise.resolve(config);