@passkeyme/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/CHANGELOG.md +1 -1
- package/LICENSE +1 -1
- package/README.md +4 -4
- package/dist/index.esm.js +62 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +62 -25
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +62 -25
- package/dist/index.umd.js.map +1 -1
- package/dist/src/api-client.d.ts +2 -2
- package/dist/src/api-client.d.ts.map +1 -1
- package/dist/src/errors.d.ts +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/passkeyme-auth.d.ts +1 -1
- package/dist/src/platform/PasskeySDK.d.ts +1 -1
- package/dist/src/storage/StorageProvider.d.ts +1 -1
- package/dist/src/storage/index.d.ts +1 -1
- package/dist/src/token-storage.d.ts +1 -1
- package/dist/src/types.d.ts +6 -6
- package/dist/src/utils/logger.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Internal logging utility for
|
|
6
|
+
* Internal logging utility for Passkeyme SDK
|
|
7
7
|
* Provides controlled logging that can be enabled/disabled in production
|
|
8
8
|
*/
|
|
9
9
|
class Logger {
|
|
@@ -78,7 +78,7 @@ const storageLogger = new Logger({
|
|
|
78
78
|
});
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* Enhanced Error Handling for
|
|
81
|
+
* Enhanced Error Handling for Passkeyme SDK
|
|
82
82
|
*/
|
|
83
83
|
exports.PasskeymeErrorCode = void 0;
|
|
84
84
|
(function (PasskeymeErrorCode) {
|
|
@@ -238,7 +238,7 @@ class PasskeymeError extends Error {
|
|
|
238
238
|
*/
|
|
239
239
|
class ErrorHandler {
|
|
240
240
|
static logError(error, context) {
|
|
241
|
-
console.group(`🚨
|
|
241
|
+
console.group(`🚨 Passkeyme Error${context ? ` [${context}]` : ""}`);
|
|
242
242
|
logger.error("Code:", error.code);
|
|
243
243
|
logger.error("Message:", error.message);
|
|
244
244
|
logger.error("User Message:", error.userMessage);
|
|
@@ -260,10 +260,10 @@ class ErrorHandler {
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
/**
|
|
263
|
-
* API Client for
|
|
263
|
+
* API Client for Passkeyme authentication services
|
|
264
264
|
*/
|
|
265
265
|
class PasskeymeApiClient {
|
|
266
|
-
constructor(appId, baseUrl
|
|
266
|
+
constructor(appId, baseUrl, debug = false) {
|
|
267
267
|
this.appId = appId;
|
|
268
268
|
this.baseUrl = baseUrl.replace(/\/$/, ""); // Remove trailing slash
|
|
269
269
|
this.debug = debug;
|
|
@@ -323,7 +323,7 @@ class PasskeymeApiClient {
|
|
|
323
323
|
* Get authentication configuration for the app
|
|
324
324
|
*/
|
|
325
325
|
async getConfig() {
|
|
326
|
-
const backendConfig = await this.request(
|
|
326
|
+
const backendConfig = await this.request(`${this.baseUrl}/api/auth/${this.appId}/config`);
|
|
327
327
|
// Map backend response to SDK format
|
|
328
328
|
return {
|
|
329
329
|
appId: backendConfig.app_id,
|
|
@@ -372,7 +372,7 @@ class PasskeymeApiClient {
|
|
|
372
372
|
* Login with username/password
|
|
373
373
|
*/
|
|
374
374
|
async loginWithPassword(username, password, redirectUri) {
|
|
375
|
-
return this.request(`/api/auth/${this.appId}/
|
|
375
|
+
return this.request(`/api/auth/${this.appId}/login`, {
|
|
376
376
|
method: "POST",
|
|
377
377
|
body: JSON.stringify({
|
|
378
378
|
username,
|
|
@@ -399,7 +399,7 @@ class PasskeymeApiClient {
|
|
|
399
399
|
token: token,
|
|
400
400
|
app_id: this.appId,
|
|
401
401
|
});
|
|
402
|
-
const response = (await this.request(
|
|
402
|
+
const response = (await this.request(`${this.baseUrl}/api/auth/verify-token?${params.toString()}`, {
|
|
403
403
|
method: "GET",
|
|
404
404
|
}));
|
|
405
405
|
if (!response.valid) {
|
|
@@ -457,7 +457,7 @@ class PasskeymeApiClient {
|
|
|
457
457
|
* Browser storage implementation using localStorage or sessionStorage
|
|
458
458
|
*/
|
|
459
459
|
class BrowserStorageProvider {
|
|
460
|
-
constructor(useSessionStorage = false, keyPrefix = "@
|
|
460
|
+
constructor(useSessionStorage = false, keyPrefix = "@Passkeyme:") {
|
|
461
461
|
this.keyPrefix = keyPrefix;
|
|
462
462
|
if (typeof window === "undefined") {
|
|
463
463
|
// Server-side environment - create a no-op storage
|
|
@@ -524,7 +524,7 @@ class BrowserStorageProvider {
|
|
|
524
524
|
}
|
|
525
525
|
|
|
526
526
|
/**
|
|
527
|
-
* Secure token storage for
|
|
527
|
+
* Secure token storage for Passkeyme Auth SDK
|
|
528
528
|
*/
|
|
529
529
|
class TokenStorage {
|
|
530
530
|
constructor(storage, useSessionStorage = false) {
|
|
@@ -630,7 +630,7 @@ TokenStorage.EXPIRES_AT_KEY = "passkeyme_expires_at";
|
|
|
630
630
|
TokenStorage.TOKEN_TYPE_KEY = "passkeyme_token_type";
|
|
631
631
|
|
|
632
632
|
/**
|
|
633
|
-
* Platform SDK Interface for
|
|
633
|
+
* Platform SDK Interface for Passkeyme
|
|
634
634
|
*
|
|
635
635
|
* This interface abstracts platform-specific passkey operations,
|
|
636
636
|
* allowing the core SDK to work across web, React Native, and other platforms.
|
|
@@ -803,7 +803,7 @@ catch (error) {
|
|
|
803
803
|
}
|
|
804
804
|
|
|
805
805
|
/**
|
|
806
|
-
* Main
|
|
806
|
+
* Main Passkeyme Authentication SDK class
|
|
807
807
|
*/
|
|
808
808
|
class PasskeymeAuth {
|
|
809
809
|
constructor(config) {
|
|
@@ -1013,7 +1013,7 @@ class PasskeymeAuth {
|
|
|
1013
1013
|
const params = new URLSearchParams({
|
|
1014
1014
|
redirect_uri: finalRedirectUri,
|
|
1015
1015
|
});
|
|
1016
|
-
const oauthUrl = `${this.config.baseUrl}/
|
|
1016
|
+
const oauthUrl = `${this.config.baseUrl}/auth/${this.config.appId}/oauth/${provider}/start?${params.toString()}`;
|
|
1017
1017
|
logger.debug("Redirecting directly to OAuth provider:", provider, oauthUrl);
|
|
1018
1018
|
this.performRedirect(oauthUrl, finalRedirectUri);
|
|
1019
1019
|
}
|
|
@@ -1365,7 +1365,7 @@ class PasskeymeAuth {
|
|
|
1365
1365
|
const sdk = this.passkeySDK;
|
|
1366
1366
|
// Dynamic import for axios (ES modules compatible)
|
|
1367
1367
|
const { default: axios } = await Promise.resolve().then(function () { return index; });
|
|
1368
|
-
// Create axios instance for
|
|
1368
|
+
// Create axios instance for Passkeyme API
|
|
1369
1369
|
const axiosInstance = axios.create({
|
|
1370
1370
|
baseURL: `${this.config.baseUrl}/webauthn/${this.config.appId}`,
|
|
1371
1371
|
headers: {
|
|
@@ -1786,9 +1786,9 @@ async function addAuthHeader(auth, headers = {}, headerName = "Authorization", t
|
|
|
1786
1786
|
}
|
|
1787
1787
|
|
|
1788
1788
|
/**
|
|
1789
|
-
*
|
|
1789
|
+
* Passkeyme Authentication SDK
|
|
1790
1790
|
*
|
|
1791
|
-
* A simple, Firebase Auth-like SDK for authentication with
|
|
1791
|
+
* A simple, Firebase Auth-like SDK for authentication with Passkeyme.
|
|
1792
1792
|
*
|
|
1793
1793
|
* @example
|
|
1794
1794
|
* ```typescript
|
|
@@ -1814,7 +1814,7 @@ async function addAuthHeader(auth, headers = {}, headerName = "Authorization", t
|
|
|
1814
1814
|
*/
|
|
1815
1815
|
// Main exports
|
|
1816
1816
|
/**
|
|
1817
|
-
* Create a new
|
|
1817
|
+
* Create a new Passkeyme Auth instance
|
|
1818
1818
|
*
|
|
1819
1819
|
* @param config - Configuration options
|
|
1820
1820
|
* @returns PasskeymeAuth instance
|
|
@@ -1963,6 +1963,27 @@ const isPlainObject = (val) => {
|
|
|
1963
1963
|
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
|
|
1964
1964
|
};
|
|
1965
1965
|
|
|
1966
|
+
/**
|
|
1967
|
+
* Determine if a value is an empty object (safely handles Buffers)
|
|
1968
|
+
*
|
|
1969
|
+
* @param {*} val The value to test
|
|
1970
|
+
*
|
|
1971
|
+
* @returns {boolean} True if value is an empty object, otherwise false
|
|
1972
|
+
*/
|
|
1973
|
+
const isEmptyObject = (val) => {
|
|
1974
|
+
// Early return for non-objects or Buffers to prevent RangeError
|
|
1975
|
+
if (!isObject(val) || isBuffer(val)) {
|
|
1976
|
+
return false;
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
try {
|
|
1980
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
1981
|
+
} catch (e) {
|
|
1982
|
+
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
1983
|
+
return false;
|
|
1984
|
+
}
|
|
1985
|
+
};
|
|
1986
|
+
|
|
1966
1987
|
/**
|
|
1967
1988
|
* Determine if a value is a Date
|
|
1968
1989
|
*
|
|
@@ -2085,6 +2106,11 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
2085
2106
|
fn.call(null, obj[i], i, obj);
|
|
2086
2107
|
}
|
|
2087
2108
|
} else {
|
|
2109
|
+
// Buffer check
|
|
2110
|
+
if (isBuffer(obj)) {
|
|
2111
|
+
return;
|
|
2112
|
+
}
|
|
2113
|
+
|
|
2088
2114
|
// Iterate over object keys
|
|
2089
2115
|
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
2090
2116
|
const len = keys.length;
|
|
@@ -2098,6 +2124,10 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
2098
2124
|
}
|
|
2099
2125
|
|
|
2100
2126
|
function findKey(obj, key) {
|
|
2127
|
+
if (isBuffer(obj)){
|
|
2128
|
+
return null;
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2101
2131
|
key = key.toLowerCase();
|
|
2102
2132
|
const keys = Object.keys(obj);
|
|
2103
2133
|
let i = keys.length;
|
|
@@ -2451,6 +2481,11 @@ const toJSONObject = (obj) => {
|
|
|
2451
2481
|
return;
|
|
2452
2482
|
}
|
|
2453
2483
|
|
|
2484
|
+
//Buffer check
|
|
2485
|
+
if (isBuffer(source)) {
|
|
2486
|
+
return source;
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2454
2489
|
if(!('toJSON' in source)) {
|
|
2455
2490
|
stack[i] = source;
|
|
2456
2491
|
const target = isArray(source) ? [] : {};
|
|
@@ -2522,6 +2557,7 @@ var utils$1 = {
|
|
|
2522
2557
|
isBoolean,
|
|
2523
2558
|
isObject,
|
|
2524
2559
|
isPlainObject,
|
|
2560
|
+
isEmptyObject,
|
|
2525
2561
|
isReadableStream,
|
|
2526
2562
|
isRequest,
|
|
2527
2563
|
isResponse,
|
|
@@ -3153,7 +3189,7 @@ var platform = {
|
|
|
3153
3189
|
};
|
|
3154
3190
|
|
|
3155
3191
|
function toURLEncodedForm(data, options) {
|
|
3156
|
-
return toFormData(data, new platform.classes.URLSearchParams(),
|
|
3192
|
+
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
3157
3193
|
visitor: function(value, key, path, helpers) {
|
|
3158
3194
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
3159
3195
|
this.append(key, value.toString('base64'));
|
|
@@ -3161,8 +3197,9 @@ function toURLEncodedForm(data, options) {
|
|
|
3161
3197
|
}
|
|
3162
3198
|
|
|
3163
3199
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
3164
|
-
}
|
|
3165
|
-
|
|
3200
|
+
},
|
|
3201
|
+
...options
|
|
3202
|
+
});
|
|
3166
3203
|
}
|
|
3167
3204
|
|
|
3168
3205
|
/**
|
|
@@ -3915,7 +3952,7 @@ function throttle(fn, freq) {
|
|
|
3915
3952
|
clearTimeout(timer);
|
|
3916
3953
|
timer = null;
|
|
3917
3954
|
}
|
|
3918
|
-
fn
|
|
3955
|
+
fn(...args);
|
|
3919
3956
|
};
|
|
3920
3957
|
|
|
3921
3958
|
const throttled = (...args) => {
|
|
@@ -4171,7 +4208,7 @@ function mergeConfig(config1, config2) {
|
|
|
4171
4208
|
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
|
4172
4209
|
};
|
|
4173
4210
|
|
|
4174
|
-
utils$1.forEach(Object.keys(
|
|
4211
|
+
utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
4175
4212
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
4176
4213
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
4177
4214
|
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
@@ -4912,7 +4949,7 @@ function dispatchRequest(config) {
|
|
|
4912
4949
|
});
|
|
4913
4950
|
}
|
|
4914
4951
|
|
|
4915
|
-
const VERSION = "1.
|
|
4952
|
+
const VERSION = "1.11.0";
|
|
4916
4953
|
|
|
4917
4954
|
const validators$1 = {};
|
|
4918
4955
|
|
|
@@ -5151,8 +5188,8 @@ class Axios {
|
|
|
5151
5188
|
|
|
5152
5189
|
if (!synchronousRequestInterceptors) {
|
|
5153
5190
|
const chain = [dispatchRequest.bind(this), undefined];
|
|
5154
|
-
chain.unshift
|
|
5155
|
-
chain.push
|
|
5191
|
+
chain.unshift(...requestInterceptorChain);
|
|
5192
|
+
chain.push(...responseInterceptorChain);
|
|
5156
5193
|
len = chain.length;
|
|
5157
5194
|
|
|
5158
5195
|
promise = Promise.resolve(config);
|