@passkeyme/react-auth 1.1.8 → 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.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 = {
@@ -1055,16 +1055,30 @@ const providerStyles = {
1055
1055
  color: "white",
1056
1056
  border: "1px solid #1877f2",
1057
1057
  },
1058
+ apple: {
1059
+ backgroundColor: "#000",
1060
+ color: "white",
1061
+ border: "1px solid #000",
1062
+ },
1063
+ microsoft: {
1064
+ backgroundColor: "#0078d4",
1065
+ color: "white",
1066
+ border: "1px solid #0078d4",
1067
+ },
1058
1068
  };
1059
1069
  const providerIcons = {
1060
1070
  google: "🌐",
1061
1071
  github: "📱",
1062
1072
  facebook: "📘",
1073
+ apple: "🍎",
1074
+ microsoft: "Ⓜ️",
1063
1075
  };
1064
1076
  const providerNames = {
1065
1077
  google: "Google",
1066
1078
  github: "GitHub",
1067
1079
  facebook: "Facebook",
1080
+ apple: "Apple",
1081
+ microsoft: "Microsoft",
1068
1082
  };
1069
1083
  const PasskeymeOAuthButtonComponent = ({ provider, variant = "default", size = "medium", redirectUri, children, className = "", style = {}, disabled = false, onClick, loading: externalLoading = false, }) => {
1070
1084
  const { redirectToOAuth, loading: authLoading } = usePasskeyme();
@@ -1764,7 +1778,7 @@ const importLogger = {
1764
1778
  };
1765
1779
 
1766
1780
  /**
1767
- * Debug utilities for PasskeyMe React SDK
1781
+ * Debug utilities for Passkeyme React SDK
1768
1782
  */
1769
1783
  /**
1770
1784
  * Debug utility to conditionally log messages
@@ -1773,7 +1787,7 @@ function debugLog(config, component, ...args) {
1773
1787
  if (config.debug) {
1774
1788
  // Use both professional logger and console.log to ensure visibility
1775
1789
  const timestamp = new Date().toISOString();
1776
- console.log(`[${timestamp}] [PasskeyMe:${component}]`, ...args);
1790
+ console.log(`[${timestamp}] [Passkeyme:${component}]`, ...args);
1777
1791
  debugLogger.debug(`[${component}]`, ...args);
1778
1792
  }
1779
1793
  }
@@ -2221,14 +2235,14 @@ const defaultTheme = {
2221
2235
  },
2222
2236
  };
2223
2237
  /**
2224
- * PasskeyMe Authentication Panel Component
2238
+ * Passkeyme Authentication Panel Component
2225
2239
  *
2226
2240
  * A fully customizable authentication panel that handles passkey and OAuth authentication
2227
2241
  * with extensive theming and configuration options.
2228
2242
  */
2229
2243
  const PasskeymeAuthPanel = ({
2230
2244
  // Core functionality
2231
- providers = ["google", "github"], enablePasskeys = true, enableUsernamePassword: _enableUsernamePassword = false, // Reserved for future implementation
2245
+ providers = ["google", "github", "apple", "microsoft"], enablePasskeys = true, enableUsernamePassword: _enableUsernamePassword = false, // Reserved for future implementation
2232
2246
  redirectUri, state: _state, // Reserved for future implementation
2233
2247
  // Layout & behavior
2234
2248
  layout = "vertical", spacing = "normal", passkeyFirst = true, hideProvidersInitially = false, autoTriggerPasskey = true,
@@ -2549,6 +2563,27 @@ const isPlainObject = (val) => {
2549
2563
  return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
2550
2564
  };
2551
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
+
2552
2587
  /**
2553
2588
  * Determine if a value is a Date
2554
2589
  *
@@ -2671,6 +2706,11 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
2671
2706
  fn.call(null, obj[i], i, obj);
2672
2707
  }
2673
2708
  } else {
2709
+ // Buffer check
2710
+ if (isBuffer(obj)) {
2711
+ return;
2712
+ }
2713
+
2674
2714
  // Iterate over object keys
2675
2715
  const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
2676
2716
  const len = keys.length;
@@ -2684,6 +2724,10 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
2684
2724
  }
2685
2725
 
2686
2726
  function findKey(obj, key) {
2727
+ if (isBuffer(obj)){
2728
+ return null;
2729
+ }
2730
+
2687
2731
  key = key.toLowerCase();
2688
2732
  const keys = Object.keys(obj);
2689
2733
  let i = keys.length;
@@ -3037,6 +3081,11 @@ const toJSONObject = (obj) => {
3037
3081
  return;
3038
3082
  }
3039
3083
 
3084
+ //Buffer check
3085
+ if (isBuffer(source)) {
3086
+ return source;
3087
+ }
3088
+
3040
3089
  if(!('toJSON' in source)) {
3041
3090
  stack[i] = source;
3042
3091
  const target = isArray(source) ? [] : {};
@@ -3108,6 +3157,7 @@ var utils$1 = {
3108
3157
  isBoolean,
3109
3158
  isObject,
3110
3159
  isPlainObject,
3160
+ isEmptyObject,
3111
3161
  isReadableStream,
3112
3162
  isRequest,
3113
3163
  isResponse,
@@ -3739,7 +3789,7 @@ var platform = {
3739
3789
  };
3740
3790
 
3741
3791
  function toURLEncodedForm(data, options) {
3742
- return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
3792
+ return toFormData(data, new platform.classes.URLSearchParams(), {
3743
3793
  visitor: function(value, key, path, helpers) {
3744
3794
  if (platform.isNode && utils$1.isBuffer(value)) {
3745
3795
  this.append(key, value.toString('base64'));
@@ -3747,8 +3797,9 @@ function toURLEncodedForm(data, options) {
3747
3797
  }
3748
3798
 
3749
3799
  return helpers.defaultVisitor.apply(this, arguments);
3750
- }
3751
- }, options));
3800
+ },
3801
+ ...options
3802
+ });
3752
3803
  }
3753
3804
 
3754
3805
  /**
@@ -4501,7 +4552,7 @@ function throttle(fn, freq) {
4501
4552
  clearTimeout(timer);
4502
4553
  timer = null;
4503
4554
  }
4504
- fn.apply(null, args);
4555
+ fn(...args);
4505
4556
  };
4506
4557
 
4507
4558
  const throttled = (...args) => {
@@ -4757,7 +4808,7 @@ function mergeConfig(config1, config2) {
4757
4808
  headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
4758
4809
  };
4759
4810
 
4760
- utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
4811
+ utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
4761
4812
  const merge = mergeMap[prop] || mergeDeepProperties;
4762
4813
  const configValue = merge(config1[prop], config2[prop], prop);
4763
4814
  (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
@@ -5498,7 +5549,7 @@ function dispatchRequest(config) {
5498
5549
  });
5499
5550
  }
5500
5551
 
5501
- const VERSION = "1.10.0";
5552
+ const VERSION = "1.11.0";
5502
5553
 
5503
5554
  const validators$1 = {};
5504
5555
 
@@ -5737,8 +5788,8 @@ class Axios {
5737
5788
 
5738
5789
  if (!synchronousRequestInterceptors) {
5739
5790
  const chain = [dispatchRequest.bind(this), undefined];
5740
- chain.unshift.apply(chain, requestInterceptorChain);
5741
- chain.push.apply(chain, responseInterceptorChain);
5791
+ chain.unshift(...requestInterceptorChain);
5792
+ chain.push(...responseInterceptorChain);
5742
5793
  len = chain.length;
5743
5794
 
5744
5795
  promise = Promise.resolve(config);
@@ -6226,7 +6277,7 @@ const DefaultPasskeyPrompt = ({ user, onRegister, onSkip, loading, }) => (jsxRun
6226
6277
  textAlign: "center",
6227
6278
  }, children: "You can always set this up later in your account settings" })] }));
6228
6279
  /**
6229
- * Built-in OAuth callback handler component for PasskeyMe authentication.
6280
+ * Built-in OAuth callback handler component for Passkeyme authentication.
6230
6281
  *
6231
6282
  * This component automatically handles the OAuth callback flow including:
6232
6283
  * - Token extraction from URL parameters
@@ -6378,7 +6429,7 @@ const PasskeymeCallbackHandler = ({ loadingComponent: LoadingComponent, errorCom
6378
6429
  return;
6379
6430
  try {
6380
6431
  updateState({ passkeyRegistering: true });
6381
- // Create axios instance for PasskeyMe API
6432
+ // Create axios instance for Passkeyme API
6382
6433
  const axiosInstance = axios$1.create({
6383
6434
  baseURL: `${getBaseUrl()}/webauthn/${config.appId}`,
6384
6435
  headers: {
@@ -7012,7 +7063,7 @@ const withAuth = (Component, options) => {
7012
7063
  };
7013
7064
 
7014
7065
  /**
7015
- * Performance monitoring utilities for PasskeyMe React SDK
7066
+ * Performance monitoring utilities for Passkeyme React SDK
7016
7067
  */
7017
7068
  /**
7018
7069
  * Hook to monitor component performance
@@ -7129,7 +7180,7 @@ const useMemoryMonitor = (enabled = process.env.NODE_ENV === "development") => {
7129
7180
  */
7130
7181
  const devWarn = (condition, message, ...args) => {
7131
7182
  if (process.env.NODE_ENV === "development" && condition) {
7132
- console.warn(`[PasskeyMe Dev Warning] ${message}`, ...args);
7183
+ console.warn(`[Passkeyme Dev Warning] ${message}`, ...args);
7133
7184
  }
7134
7185
  };
7135
7186
  /**
@@ -7137,7 +7188,7 @@ const devWarn = (condition, message, ...args) => {
7137
7188
  */
7138
7189
  const devError = (condition, message, ...args) => {
7139
7190
  if (process.env.NODE_ENV === "development" && condition) {
7140
- console.error(`[PasskeyMe Dev Error] ${message}`, ...args);
7191
+ console.error(`[Passkeyme Dev Error] ${message}`, ...args);
7141
7192
  }
7142
7193
  };
7143
7194
  /**
@@ -7168,14 +7219,14 @@ const initDevTools = () => {
7168
7219
  resetAuth: () => {
7169
7220
  localStorage.removeItem("passkeyme_auth_token");
7170
7221
  localStorage.removeItem("passkeyme_user_data");
7171
- console.log("[PasskeyMe Dev] Authentication state reset");
7222
+ console.log("[Passkeyme Dev] Authentication state reset");
7172
7223
  window.location.reload();
7173
7224
  },
7174
7225
  // Show current state
7175
7226
  showState: () => {
7176
7227
  const token = localStorage.getItem("passkeyme_auth_token");
7177
7228
  const user = localStorage.getItem("passkeyme_user_data");
7178
- console.log("[PasskeyMe Dev] Current State:", {
7229
+ console.log("[Passkeyme Dev] Current State:", {
7179
7230
  hasToken: !!token,
7180
7231
  token: token ? "Present" : "None",
7181
7232
  user: user ? JSON.parse(user) : null,
@@ -7184,17 +7235,17 @@ const initDevTools = () => {
7184
7235
  // Enable debug mode
7185
7236
  enableDebug: () => {
7186
7237
  localStorage.setItem("passkeyme_debug", "true");
7187
- console.log("[PasskeyMe Dev] Debug mode enabled");
7238
+ console.log("[Passkeyme Dev] Debug mode enabled");
7188
7239
  window.location.reload();
7189
7240
  },
7190
7241
  // Disable debug mode
7191
7242
  disableDebug: () => {
7192
7243
  localStorage.removeItem("passkeyme_debug");
7193
- console.log("[PasskeyMe Dev] Debug mode disabled");
7244
+ console.log("[Passkeyme Dev] Debug mode disabled");
7194
7245
  window.location.reload();
7195
7246
  },
7196
7247
  };
7197
- 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.");
7198
7249
  }
7199
7250
  };
7200
7251
  /**
@@ -7209,7 +7260,7 @@ const withDevTools = (Component, displayName) => {
7209
7260
  // Log renders in development
7210
7261
  React.useEffect(() => {
7211
7262
  if (localStorage.getItem("passkeyme_debug") === "true") {
7212
- console.log(`[PasskeyMe Dev] ${componentName} rendered with props:`, props);
7263
+ console.log(`[Passkeyme Dev] ${componentName} rendered with props:`, props);
7213
7264
  }
7214
7265
  });
7215
7266
  // Validate required props
@@ -7266,7 +7317,7 @@ const DebugPanel = ({ data, position = "bottom-right", }) => {
7266
7317
  overflow: "auto",
7267
7318
  zIndex: 9999,
7268
7319
  border: "1px solid #333",
7269
- }, 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) })] }));
7270
7321
  };
7271
7322
  /**
7272
7323
  * Component performance profiler for development
@@ -7331,7 +7382,7 @@ const createLazyComponent = (importFn, fallback) => {
7331
7382
  };
7332
7383
 
7333
7384
  /**
7334
- * Optimized localStorage utilities for PasskeyMe React SDK
7385
+ * Optimized localStorage utilities for Passkeyme React SDK
7335
7386
  * Provides caching, compression, and performance optimizations
7336
7387
  */
7337
7388
  /**
@@ -7917,7 +7968,7 @@ const PerformanceIndicator = ({ threshold = 100, position = "top-right", }) => {
7917
7968
  };
7918
7969
 
7919
7970
  /**
7920
- * Import optimization utility for PasskeyMe React SDK
7971
+ * Import optimization utility for Passkeyme React SDK
7921
7972
  * Analyzes and optimizes bundle imports to reduce bundle size
7922
7973
  *
7923
7974
  * Note: This utility is intended for build-time analysis in Node.js environments only.
@@ -8365,7 +8416,7 @@ class PasskeymeErrorBoundary extends React.Component {
8365
8416
  onError === null || onError === void 0 ? void 0 : onError(error, errorInfo);
8366
8417
  // Log to console in development
8367
8418
  if (process.env.NODE_ENV === "development") {
8368
- console.error("PasskeyMe Error Boundary caught an error:", error, errorInfo);
8419
+ console.error("Passkeyme Error Boundary caught an error:", error, errorInfo);
8369
8420
  }
8370
8421
  }
8371
8422
  render() {
@@ -8487,7 +8538,7 @@ const createPerformanceTracker = () => {
8487
8538
  };
8488
8539
 
8489
8540
  /**
8490
- * Mock provider for testing components that use PasskeyMe
8541
+ * Mock provider for testing components that use Passkeyme
8491
8542
  */
8492
8543
  const MockPasskeymeProvider = ({ children, config = {}, initialUser = null, initialLoading = false, initialError = null, }) => {
8493
8544
  const mockConfig = {
@@ -8498,7 +8549,7 @@ const MockPasskeymeProvider = ({ children, config = {}, initialUser = null, init
8498
8549
  return jsxRuntime.jsx(PasskeymeProvider$1, { config: mockConfig, children: children });
8499
8550
  };
8500
8551
  /**
8501
- * Custom render function with PasskeyMe provider
8552
+ * Custom render function with Passkeyme provider
8502
8553
  * Note: Requires @testing-library/react render function to be passed in
8503
8554
  */
8504
8555
  const createRenderWithPasskeymeProvider = (renderFunction) => (ui, options = {}) => {
@@ -8768,21 +8819,21 @@ const DevToolsDashboard = ({ show = process.env.NODE_ENV === "development", posi
8768
8819
  console.log = (...args) => {
8769
8820
  var _a;
8770
8821
  originalConsole.log(...args);
8771
- 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")) {
8772
8823
  addLog("info", args.join(" "), args.slice(1));
8773
8824
  }
8774
8825
  };
8775
8826
  console.warn = (...args) => {
8776
8827
  var _a;
8777
8828
  originalConsole.warn(...args);
8778
- 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")) {
8779
8830
  addLog("warn", args.join(" "), args.slice(1));
8780
8831
  }
8781
8832
  };
8782
8833
  console.error = (...args) => {
8783
8834
  var _a;
8784
8835
  originalConsole.error(...args);
8785
- 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")) {
8786
8837
  addLog("error", args.join(" "), args.slice(1));
8787
8838
  }
8788
8839
  };
@@ -8848,7 +8899,7 @@ const DevToolsDashboard = ({ show = process.env.NODE_ENV === "development", posi
8848
8899
  };
8849
8900
  const testError = () => {
8850
8901
  const error = new auth.PasskeymeError("DEV_TEST_ERROR");
8851
- console.error("[PasskeyMe Dev] Test error:", error);
8902
+ console.error("[Passkeyme Dev] Test error:", error);
8852
8903
  addLog("error", "Test error triggered", error);
8853
8904
  };
8854
8905
  const exportState = () => {
@@ -8865,7 +8916,7 @@ const DevToolsDashboard = ({ show = process.env.NODE_ENV === "development", posi
8865
8916
  debug: localStorage.getItem("passkeyme_debug"),
8866
8917
  },
8867
8918
  };
8868
- console.log("[PasskeyMe Dev] Current state:", state);
8919
+ console.log("[Passkeyme Dev] Current state:", state);
8869
8920
  (_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText(JSON.stringify(state, null, 2));
8870
8921
  addLog("info", "State exported to clipboard");
8871
8922
  };
@@ -8919,7 +8970,7 @@ const DevToolsDashboard = ({ show = process.env.NODE_ENV === "development", posi
8919
8970
  cursor: "pointer",
8920
8971
  marginRight: "4px",
8921
8972
  });
8922
- 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()] }))] }));
8923
8974
  };
8924
8975
  // Auto-initialize dev tools
8925
8976
  if (process.env.NODE_ENV === "development" && typeof window !== "undefined") {