@passkeyme/react-auth 1.2.0 → 2.0.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.js CHANGED
@@ -6,7 +6,7 @@ var auth = require('@passkeyme/auth');
6
6
  var reactDom = require('react-dom');
7
7
 
8
8
  /**
9
- * React Context Provider for PasskeyMe Authentication (Core)
9
+ * React Context Provider for Passkeyme Authentication (Core)
10
10
  * This is the shared provider for React and React Native
11
11
  */
12
12
  const PasskeymeContext = React.createContext(null);
@@ -113,7 +113,7 @@ const PasskeymeProvider$1 = ({ config, children, loadingComponent = null, errorC
113
113
  };
114
114
 
115
115
  /**
116
- * Core React hooks for PasskeyMe Authentication
116
+ * Core React hooks for Passkeyme Authentication
117
117
  * Shared between React and React Native
118
118
  */
119
119
  // Simple debug function for core package
@@ -125,7 +125,7 @@ function debugLog$1(config, ...args) {
125
125
  const usePasskeyme = () => {
126
126
  const { auth: auth$1, user, loading, error, isAuthenticated, authLoading, setAuthLoading, config, } = usePasskeymeContext();
127
127
  if (!auth$1) {
128
- throw new Error("PasskeyMe auth instance not available");
128
+ throw new Error("Passkeyme auth instance not available");
129
129
  }
130
130
  const redirectToLogin = React.useCallback((options) => {
131
131
  return auth$1.redirectToLogin(options);
@@ -643,7 +643,7 @@ const PasskeymeProvider = ({ children, config, enableNotifications = true, ...co
643
643
  };
644
644
 
645
645
  /**
646
- * Enhanced Loading States for PasskeyMe SDK
646
+ * Enhanced Loading States for Passkeyme SDK
647
647
  * Provides granular loading feedback for better user experience
648
648
  */
649
649
  const LOADING_STATE_INFO = {
@@ -1778,7 +1778,7 @@ const importLogger = {
1778
1778
  };
1779
1779
 
1780
1780
  /**
1781
- * Debug utilities for PasskeyMe React SDK
1781
+ * Debug utilities for Passkeyme React SDK
1782
1782
  */
1783
1783
  /**
1784
1784
  * Debug utility to conditionally log messages
@@ -1787,7 +1787,7 @@ function debugLog(config, component, ...args) {
1787
1787
  if (config.debug) {
1788
1788
  // Use both professional logger and console.log to ensure visibility
1789
1789
  const timestamp = new Date().toISOString();
1790
- console.log(`[${timestamp}] [PasskeyMe:${component}]`, ...args);
1790
+ console.log(`[${timestamp}] [Passkeyme:${component}]`, ...args);
1791
1791
  debugLogger.debug(`[${component}]`, ...args);
1792
1792
  }
1793
1793
  }
@@ -2235,7 +2235,7 @@ const defaultTheme = {
2235
2235
  },
2236
2236
  };
2237
2237
  /**
2238
- * PasskeyMe Authentication Panel Component
2238
+ * Passkeyme Authentication Panel Component
2239
2239
  *
2240
2240
  * A fully customizable authentication panel that handles passkey and OAuth authentication
2241
2241
  * with extensive theming and configuration options.
@@ -2563,6 +2563,27 @@ const isPlainObject = (val) => {
2563
2563
  return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
2564
2564
  };
2565
2565
 
2566
+ /**
2567
+ * Determine if a value is an empty object (safely handles Buffers)
2568
+ *
2569
+ * @param {*} val The value to test
2570
+ *
2571
+ * @returns {boolean} True if value is an empty object, otherwise false
2572
+ */
2573
+ const isEmptyObject = (val) => {
2574
+ // Early return for non-objects or Buffers to prevent RangeError
2575
+ if (!isObject(val) || isBuffer(val)) {
2576
+ return false;
2577
+ }
2578
+
2579
+ try {
2580
+ return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
2581
+ } catch (e) {
2582
+ // Fallback for any other objects that might cause RangeError with Object.keys()
2583
+ return false;
2584
+ }
2585
+ };
2586
+
2566
2587
  /**
2567
2588
  * Determine if a value is a Date
2568
2589
  *
@@ -2685,6 +2706,11 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
2685
2706
  fn.call(null, obj[i], i, obj);
2686
2707
  }
2687
2708
  } else {
2709
+ // Buffer check
2710
+ if (isBuffer(obj)) {
2711
+ return;
2712
+ }
2713
+
2688
2714
  // Iterate over object keys
2689
2715
  const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
2690
2716
  const len = keys.length;
@@ -2698,6 +2724,10 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
2698
2724
  }
2699
2725
 
2700
2726
  function findKey(obj, key) {
2727
+ if (isBuffer(obj)){
2728
+ return null;
2729
+ }
2730
+
2701
2731
  key = key.toLowerCase();
2702
2732
  const keys = Object.keys(obj);
2703
2733
  let i = keys.length;
@@ -3051,6 +3081,11 @@ const toJSONObject = (obj) => {
3051
3081
  return;
3052
3082
  }
3053
3083
 
3084
+ //Buffer check
3085
+ if (isBuffer(source)) {
3086
+ return source;
3087
+ }
3088
+
3054
3089
  if(!('toJSON' in source)) {
3055
3090
  stack[i] = source;
3056
3091
  const target = isArray(source) ? [] : {};
@@ -3122,6 +3157,7 @@ var utils$1 = {
3122
3157
  isBoolean,
3123
3158
  isObject,
3124
3159
  isPlainObject,
3160
+ isEmptyObject,
3125
3161
  isReadableStream,
3126
3162
  isRequest,
3127
3163
  isResponse,
@@ -3753,7 +3789,7 @@ var platform = {
3753
3789
  };
3754
3790
 
3755
3791
  function toURLEncodedForm(data, options) {
3756
- return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
3792
+ return toFormData(data, new platform.classes.URLSearchParams(), {
3757
3793
  visitor: function(value, key, path, helpers) {
3758
3794
  if (platform.isNode && utils$1.isBuffer(value)) {
3759
3795
  this.append(key, value.toString('base64'));
@@ -3761,8 +3797,9 @@ function toURLEncodedForm(data, options) {
3761
3797
  }
3762
3798
 
3763
3799
  return helpers.defaultVisitor.apply(this, arguments);
3764
- }
3765
- }, options));
3800
+ },
3801
+ ...options
3802
+ });
3766
3803
  }
3767
3804
 
3768
3805
  /**
@@ -4515,7 +4552,7 @@ function throttle(fn, freq) {
4515
4552
  clearTimeout(timer);
4516
4553
  timer = null;
4517
4554
  }
4518
- fn.apply(null, args);
4555
+ fn(...args);
4519
4556
  };
4520
4557
 
4521
4558
  const throttled = (...args) => {
@@ -4771,7 +4808,7 @@ function mergeConfig(config1, config2) {
4771
4808
  headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
4772
4809
  };
4773
4810
 
4774
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
4811
+ utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
4775
4812
  const merge = mergeMap[prop] || mergeDeepProperties;
4776
4813
  const configValue = merge(config1[prop], config2[prop], prop);
4777
4814
  (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
@@ -5512,7 +5549,7 @@ function dispatchRequest(config) {
5512
5549
  });
5513
5550
  }
5514
5551
 
5515
- const VERSION = "1.10.0";
5552
+ const VERSION = "1.11.0";
5516
5553
 
5517
5554
  const validators$1 = {};
5518
5555
 
@@ -5751,8 +5788,8 @@ class Axios {
5751
5788
 
5752
5789
  if (!synchronousRequestInterceptors) {
5753
5790
  const chain = [dispatchRequest.bind(this), undefined];
5754
- chain.unshift.apply(chain, requestInterceptorChain);
5755
- chain.push.apply(chain, responseInterceptorChain);
5791
+ chain.unshift(...requestInterceptorChain);
5792
+ chain.push(...responseInterceptorChain);
5756
5793
  len = chain.length;
5757
5794
 
5758
5795
  promise = Promise.resolve(config);
@@ -6240,7 +6277,7 @@ const DefaultPasskeyPrompt = ({ user, onRegister, onSkip, loading, }) => (jsxRun
6240
6277
  textAlign: "center",
6241
6278
  }, children: "You can always set this up later in your account settings" })] }));
6242
6279
  /**
6243
- * Built-in OAuth callback handler component for PasskeyMe authentication.
6280
+ * Built-in OAuth callback handler component for Passkeyme authentication.
6244
6281
  *
6245
6282
  * This component automatically handles the OAuth callback flow including:
6246
6283
  * - Token extraction from URL parameters
@@ -6392,7 +6429,7 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
6392
6429
  return;
6393
6430
  try {
6394
6431
  updateState({ passkeyRegistering: true });
6395
- // Create axios instance for PasskeyMe API
6432
+ // Create axios instance for Passkeyme API
6396
6433
  const axiosInstance = axios$1.create({
6397
6434
  baseURL: `${getBaseUrl()}/webauthn/${config.appId}`,
6398
6435
  headers: {
@@ -7026,7 +7063,7 @@ const withAuth = (Component, options) => {
7026
7063
  };
7027
7064
 
7028
7065
  /**
7029
- * Performance monitoring utilities for PasskeyMe React SDK
7066
+ * Performance monitoring utilities for Passkeyme React SDK
7030
7067
  */
7031
7068
  /**
7032
7069
  * Hook to monitor component performance
@@ -7143,7 +7180,7 @@ const useMemoryMonitor = (enabled = process.env.NODE_ENV === "development") => {
7143
7180
  */
7144
7181
  const devWarn = (condition, message, ...args) => {
7145
7182
  if (process.env.NODE_ENV === "development" && condition) {
7146
- console.warn(`[PasskeyMe Dev Warning] ${message}`, ...args);
7183
+ console.warn(`[Passkeyme Dev Warning] ${message}`, ...args);
7147
7184
  }
7148
7185
  };
7149
7186
  /**
@@ -7151,7 +7188,7 @@ const devWarn = (condition, message, ...args) => {
7151
7188
  */
7152
7189
  const devError = (condition, message, ...args) => {
7153
7190
  if (process.env.NODE_ENV === "development" && condition) {
7154
- console.error(`[PasskeyMe Dev Error] ${message}`, ...args);
7191
+ console.error(`[Passkeyme Dev Error] ${message}`, ...args);
7155
7192
  }
7156
7193
  };
7157
7194
  /**
@@ -7182,14 +7219,14 @@ const initDevTools = () => {
7182
7219
  resetAuth: () => {
7183
7220
  localStorage.removeItem("passkeyme_auth_token");
7184
7221
  localStorage.removeItem("passkeyme_user_data");
7185
- console.log("[PasskeyMe Dev] Authentication state reset");
7222
+ console.log("[Passkeyme Dev] Authentication state reset");
7186
7223
  window.location.reload();
7187
7224
  },
7188
7225
  // Show current state
7189
7226
  showState: () => {
7190
7227
  const token = localStorage.getItem("passkeyme_auth_token");
7191
7228
  const user = localStorage.getItem("passkeyme_user_data");
7192
- console.log("[PasskeyMe Dev] Current State:", {
7229
+ console.log("[Passkeyme Dev] Current State:", {
7193
7230
  hasToken: !!token,
7194
7231
  token: token ? "Present" : "None",
7195
7232
  user: user ? JSON.parse(user) : null,
@@ -7198,17 +7235,17 @@ const initDevTools = () => {
7198
7235
  // Enable debug mode
7199
7236
  enableDebug: () => {
7200
7237
  localStorage.setItem("passkeyme_debug", "true");
7201
- console.log("[PasskeyMe Dev] Debug mode enabled");
7238
+ console.log("[Passkeyme Dev] Debug mode enabled");
7202
7239
  window.location.reload();
7203
7240
  },
7204
7241
  // Disable debug mode
7205
7242
  disableDebug: () => {
7206
7243
  localStorage.removeItem("passkeyme_debug");
7207
- console.log("[PasskeyMe Dev] Debug mode disabled");
7244
+ console.log("[Passkeyme Dev] Debug mode disabled");
7208
7245
  window.location.reload();
7209
7246
  },
7210
7247
  };
7211
- console.log("[PasskeyMe Dev] Development tools loaded. Use window.__PASSKEYME_DEV__ for utilities.");
7248
+ console.log("[Passkeyme Dev] Development tools loaded. Use window.__PASSKEYME_DEV__ for utilities.");
7212
7249
  }
7213
7250
  };
7214
7251
  /**
@@ -7223,7 +7260,7 @@ const withDevTools = (Component, displayName) => {
7223
7260
  // Log renders in development
7224
7261
  React.useEffect(() => {
7225
7262
  if (localStorage.getItem("passkeyme_debug") === "true") {
7226
- console.log(`[PasskeyMe Dev] ${componentName} rendered with props:`, props);
7263
+ console.log(`[Passkeyme Dev] ${componentName} rendered with props:`, props);
7227
7264
  }
7228
7265
  });
7229
7266
  // Validate required props
@@ -7280,7 +7317,7 @@ const DebugPanel = ({ data, position = "bottom-right", }) => {
7280
7317
  overflow: "auto",
7281
7318
  zIndex: 9999,
7282
7319
  border: "1px solid #333",
7283
- }, children: [jsxRuntime.jsx("div", { style: { fontWeight: "bold", marginBottom: "8px" }, children: "\uD83D\uDC1B PasskeyMe Debug Panel" }), jsxRuntime.jsx("pre", { style: { margin: 0, whiteSpace: "pre-wrap" }, children: JSON.stringify(data, null, 2) })] }));
7320
+ }, children: [jsxRuntime.jsx("div", { style: { fontWeight: "bold", marginBottom: "8px" }, children: "\uD83D\uDC1B Passkeyme Debug Panel" }), jsxRuntime.jsx("pre", { style: { margin: 0, whiteSpace: "pre-wrap" }, children: JSON.stringify(data, null, 2) })] }));
7284
7321
  };
7285
7322
  /**
7286
7323
  * Component performance profiler for development
@@ -7345,7 +7382,7 @@ const createLazyComponent = (importFn, fallback) => {
7345
7382
  };
7346
7383
 
7347
7384
  /**
7348
- * Optimized localStorage utilities for PasskeyMe React SDK
7385
+ * Optimized localStorage utilities for Passkeyme React SDK
7349
7386
  * Provides caching, compression, and performance optimizations
7350
7387
  */
7351
7388
  /**
@@ -7931,7 +7968,7 @@ const PerformanceIndicator = ({ threshold = 100, position = "top-right", }) => {
7931
7968
  };
7932
7969
 
7933
7970
  /**
7934
- * Import optimization utility for PasskeyMe React SDK
7971
+ * Import optimization utility for Passkeyme React SDK
7935
7972
  * Analyzes and optimizes bundle imports to reduce bundle size
7936
7973
  *
7937
7974
  * Note: This utility is intended for build-time analysis in Node.js environments only.
@@ -8379,7 +8416,7 @@ class PasskeymeErrorBoundary extends React.Component {
8379
8416
  onError === null || onError === void 0 ? void 0 : onError(error, errorInfo);
8380
8417
  // Log to console in development
8381
8418
  if (process.env.NODE_ENV === "development") {
8382
- console.error("PasskeyMe Error Boundary caught an error:", error, errorInfo);
8419
+ console.error("Passkeyme Error Boundary caught an error:", error, errorInfo);
8383
8420
  }
8384
8421
  }
8385
8422
  render() {
@@ -8501,7 +8538,7 @@ const createPerformanceTracker = () => {
8501
8538
  };
8502
8539
 
8503
8540
  /**
8504
- * Mock provider for testing components that use PasskeyMe
8541
+ * Mock provider for testing components that use Passkeyme
8505
8542
  */
8506
8543
  const MockPasskeymeProvider = ({ children, config = {}, initialUser = null, initialLoading = false, initialError = null, }) => {
8507
8544
  const mockConfig = {
@@ -8512,7 +8549,7 @@ const MockPasskeymeProvider = ({ children, config = {}, initialUser = null, init
8512
8549
  return jsxRuntime.jsx(PasskeymeProvider$1, { config: mockConfig, children: children });
8513
8550
  };
8514
8551
  /**
8515
- * Custom render function with PasskeyMe provider
8552
+ * Custom render function with Passkeyme provider
8516
8553
  * Note: Requires @testing-library/react render function to be passed in
8517
8554
  */
8518
8555
  const createRenderWithPasskeymeProvider = (renderFunction) => (ui, options = {}) => {
@@ -8782,21 +8819,21 @@ const DevToolsDashboard = ({ show = process.env.NODE_ENV === "development", posi
8782
8819
  console.log = (...args) => {
8783
8820
  var _a;
8784
8821
  originalConsole.log(...args);
8785
- if ((_a = args[0]) === null || _a === void 0 ? void 0 : _a.toString().includes("[PasskeyMe")) {
8822
+ if ((_a = args[0]) === null || _a === void 0 ? void 0 : _a.toString().includes("[Passkeyme")) {
8786
8823
  addLog("info", args.join(" "), args.slice(1));
8787
8824
  }
8788
8825
  };
8789
8826
  console.warn = (...args) => {
8790
8827
  var _a;
8791
8828
  originalConsole.warn(...args);
8792
- if ((_a = args[0]) === null || _a === void 0 ? void 0 : _a.toString().includes("[PasskeyMe")) {
8829
+ if ((_a = args[0]) === null || _a === void 0 ? void 0 : _a.toString().includes("[Passkeyme")) {
8793
8830
  addLog("warn", args.join(" "), args.slice(1));
8794
8831
  }
8795
8832
  };
8796
8833
  console.error = (...args) => {
8797
8834
  var _a;
8798
8835
  originalConsole.error(...args);
8799
- if ((_a = args[0]) === null || _a === void 0 ? void 0 : _a.toString().includes("[PasskeyMe")) {
8836
+ if ((_a = args[0]) === null || _a === void 0 ? void 0 : _a.toString().includes("[Passkeyme")) {
8800
8837
  addLog("error", args.join(" "), args.slice(1));
8801
8838
  }
8802
8839
  };
@@ -8862,7 +8899,7 @@ const DevToolsDashboard = ({ show = process.env.NODE_ENV === "development", posi
8862
8899
  };
8863
8900
  const testError = () => {
8864
8901
  const error = new auth.PasskeymeError("DEV_TEST_ERROR");
8865
- console.error("[PasskeyMe Dev] Test error:", error);
8902
+ console.error("[Passkeyme Dev] Test error:", error);
8866
8903
  addLog("error", "Test error triggered", error);
8867
8904
  };
8868
8905
  const exportState = () => {
@@ -8879,7 +8916,7 @@ const DevToolsDashboard = ({ show = process.env.NODE_ENV === "development", posi
8879
8916
  debug: localStorage.getItem("passkeyme_debug"),
8880
8917
  },
8881
8918
  };
8882
- console.log("[PasskeyMe Dev] Current state:", state);
8919
+ console.log("[Passkeyme Dev] Current state:", state);
8883
8920
  (_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(JSON.stringify(state, null, 2));
8884
8921
  addLog("info", "State exported to clipboard");
8885
8922
  };
@@ -8933,7 +8970,7 @@ const DevToolsDashboard = ({ show = process.env.NODE_ENV === "development", posi
8933
8970
  cursor: "pointer",
8934
8971
  marginRight: "4px",
8935
8972
  });
8936
- return (jsxRuntime.jsxs("div", { style: baseStyles, children: [jsxRuntime.jsxs("div", { style: headerStyles, onClick: () => setIsCollapsed(!isCollapsed), children: [jsxRuntime.jsx("span", { children: "\uD83D\uDEE0\uFE0F PasskeyMe DevTools" }), jsxRuntime.jsx("span", { children: isCollapsed ? "▲" : "▼" })] }), !isCollapsed && (jsxRuntime.jsxs("div", { style: contentStyles, children: [jsxRuntime.jsxs("div", { style: { marginBottom: "12px" }, children: [jsxRuntime.jsx("button", { onClick: () => setActiveTab("state"), style: tabStyle(activeTab === "state"), children: "State" }), jsxRuntime.jsx("button", { onClick: () => setActiveTab("logs"), style: tabStyle(activeTab === "logs"), children: "Logs" })] }), activeTab === "state" && renderStateTab(), activeTab === "logs" && renderLogsTab()] }))] }));
8973
+ return (jsxRuntime.jsxs("div", { style: baseStyles, children: [jsxRuntime.jsxs("div", { style: headerStyles, onClick: () => setIsCollapsed(!isCollapsed), children: [jsxRuntime.jsx("span", { children: "\uD83D\uDEE0\uFE0F Passkeyme DevTools" }), jsxRuntime.jsx("span", { children: isCollapsed ? "▲" : "▼" })] }), !isCollapsed && (jsxRuntime.jsxs("div", { style: contentStyles, children: [jsxRuntime.jsxs("div", { style: { marginBottom: "12px" }, children: [jsxRuntime.jsx("button", { onClick: () => setActiveTab("state"), style: tabStyle(activeTab === "state"), children: "State" }), jsxRuntime.jsx("button", { onClick: () => setActiveTab("logs"), style: tabStyle(activeTab === "logs"), children: "Logs" })] }), activeTab === "state" && renderStateTab(), activeTab === "logs" && renderLogsTab()] }))] }));
8937
8974
  };
8938
8975
  // Auto-initialize dev tools
8939
8976
  if (process.env.NODE_ENV === "development" && typeof window !== "undefined") {