@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/CHANGELOG.md +1 -1
- package/LICENSE +1 -1
- package/README.md +4 -4
- package/dist/index.esm.js +68 -31
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +68 -31
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +68 -31
- package/dist/index.umd.js.map +1 -1
- package/dist/src/api-client.d.ts +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/CHANGELOG.md
CHANGED
|
@@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
16
16
|
|
|
17
17
|
### 🎉 First Stable Release
|
|
18
18
|
|
|
19
|
-
This marks the first stable release of the
|
|
19
|
+
This marks the first stable release of the Passkeyme Authentication SDK with enterprise-grade quality and comprehensive feature set.
|
|
20
20
|
|
|
21
21
|
### Added
|
|
22
22
|
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -193,7 +193,7 @@ unsubscribe();
|
|
|
193
193
|
|
|
194
194
|
```typescript
|
|
195
195
|
const auth = new PasskeymeAuth({
|
|
196
|
-
appId: "your-app-id", // Required: From
|
|
196
|
+
appId: "your-app-id", // Required: From Passkeyme dashboard
|
|
197
197
|
redirectUri: "http://localhost:3000/callback", // Optional: Default callback URL
|
|
198
198
|
debug: true, // Optional: Enable debug logging
|
|
199
199
|
});
|
|
@@ -273,7 +273,7 @@ unsubscribe();
|
|
|
273
273
|
|
|
274
274
|
## 🆚 vs Firebase Auth
|
|
275
275
|
|
|
276
|
-
| Feature |
|
|
276
|
+
| Feature | Passkeyme Auth | Firebase Auth |
|
|
277
277
|
| -------------------- | -------------------------- | --------------------------- |
|
|
278
278
|
| **Setup Complexity** | ✅ Single provider | ❌ Multiple services needed |
|
|
279
279
|
| **Hosted Auth UI** | ✅ Pre-built, customizable | ❌ Build your own |
|
|
@@ -571,7 +571,7 @@ export default function AuthCallback() {
|
|
|
571
571
|
|
|
572
572
|
## 🛠️ Development
|
|
573
573
|
|
|
574
|
-
This package is part of the
|
|
574
|
+
This package is part of the Passkeyme project. For development:
|
|
575
575
|
|
|
576
576
|
```bash
|
|
577
577
|
# Install dependencies
|
|
@@ -593,6 +593,6 @@ MIT - see LICENSE file for details.
|
|
|
593
593
|
|
|
594
594
|
## 🤝 Support
|
|
595
595
|
|
|
596
|
-
- **Documentation**: https://passkeyme.com
|
|
596
|
+
- **Documentation**: https://docs.passkeyme.com
|
|
597
597
|
- **Issues**: https://github.com/passkeyme/passkeyme/issues
|
|
598
598
|
- **Discord**: https://discord.gg/passkeyme
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Internal logging utility for
|
|
2
|
+
* Internal logging utility for Passkeyme SDK
|
|
3
3
|
* Provides controlled logging that can be enabled/disabled in production
|
|
4
4
|
*/
|
|
5
5
|
class Logger {
|
|
@@ -74,7 +74,7 @@ const storageLogger = new Logger({
|
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* Enhanced Error Handling for
|
|
77
|
+
* Enhanced Error Handling for Passkeyme SDK
|
|
78
78
|
*/
|
|
79
79
|
var PasskeymeErrorCode;
|
|
80
80
|
(function (PasskeymeErrorCode) {
|
|
@@ -234,7 +234,7 @@ class PasskeymeError extends Error {
|
|
|
234
234
|
*/
|
|
235
235
|
class ErrorHandler {
|
|
236
236
|
static logError(error, context) {
|
|
237
|
-
console.group(`🚨
|
|
237
|
+
console.group(`🚨 Passkeyme Error${context ? ` [${context}]` : ""}`);
|
|
238
238
|
logger.error("Code:", error.code);
|
|
239
239
|
logger.error("Message:", error.message);
|
|
240
240
|
logger.error("User Message:", error.userMessage);
|
|
@@ -256,7 +256,7 @@ class ErrorHandler {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
/**
|
|
259
|
-
* API Client for
|
|
259
|
+
* API Client for Passkeyme authentication services
|
|
260
260
|
*/
|
|
261
261
|
class PasskeymeApiClient {
|
|
262
262
|
constructor(appId, baseUrl = "https://auth.passkeyme.com", debug = false) {
|
|
@@ -319,7 +319,7 @@ class PasskeymeApiClient {
|
|
|
319
319
|
* Get authentication configuration for the app
|
|
320
320
|
*/
|
|
321
321
|
async getConfig() {
|
|
322
|
-
const backendConfig = await this.request(`/api
|
|
322
|
+
const backendConfig = await this.request(`/api/${this.appId}/config`);
|
|
323
323
|
// Map backend response to SDK format
|
|
324
324
|
return {
|
|
325
325
|
appId: backendConfig.app_id,
|
|
@@ -342,7 +342,7 @@ class PasskeymeApiClient {
|
|
|
342
342
|
*/
|
|
343
343
|
async startOAuth(provider, redirectUri) {
|
|
344
344
|
const params = new URLSearchParams({ redirect_uri: redirectUri });
|
|
345
|
-
const url = `${this.baseUrl}/
|
|
345
|
+
const url = `${this.baseUrl}/auth/${this.appId}/oauth/${provider}/start?${params}`;
|
|
346
346
|
this.log("OAuth start URL:", url);
|
|
347
347
|
return url;
|
|
348
348
|
}
|
|
@@ -350,7 +350,7 @@ class PasskeymeApiClient {
|
|
|
350
350
|
* Start passkey authentication
|
|
351
351
|
*/
|
|
352
352
|
async startPasskeyAuth(username) {
|
|
353
|
-
return this.request(`/
|
|
353
|
+
return this.request(`/auth/${this.appId}/passkey/start`, {
|
|
354
354
|
method: "POST",
|
|
355
355
|
body: JSON.stringify({ username }),
|
|
356
356
|
});
|
|
@@ -359,7 +359,7 @@ class PasskeymeApiClient {
|
|
|
359
359
|
* Complete passkey authentication
|
|
360
360
|
*/
|
|
361
361
|
async completePasskeyAuth(credential, redirectUri) {
|
|
362
|
-
return this.request(`/
|
|
362
|
+
return this.request(`/auth/${this.appId}/passkey/complete`, {
|
|
363
363
|
method: "POST",
|
|
364
364
|
body: JSON.stringify({ credential, redirect_uri: redirectUri }),
|
|
365
365
|
});
|
|
@@ -368,7 +368,7 @@ class PasskeymeApiClient {
|
|
|
368
368
|
* Login with username/password
|
|
369
369
|
*/
|
|
370
370
|
async loginWithPassword(username, password, redirectUri) {
|
|
371
|
-
return this.request(`/
|
|
371
|
+
return this.request(`/auth/${this.appId}/password/login`, {
|
|
372
372
|
method: "POST",
|
|
373
373
|
body: JSON.stringify({
|
|
374
374
|
username,
|
|
@@ -381,7 +381,7 @@ class PasskeymeApiClient {
|
|
|
381
381
|
* Handle OAuth callback
|
|
382
382
|
*/
|
|
383
383
|
async handleOAuthCallback(code, state) {
|
|
384
|
-
return this.request(`/
|
|
384
|
+
return this.request(`/auth/${this.appId}/oauth/callback`, {
|
|
385
385
|
method: "POST",
|
|
386
386
|
body: JSON.stringify({ code, state }),
|
|
387
387
|
});
|
|
@@ -395,7 +395,7 @@ class PasskeymeApiClient {
|
|
|
395
395
|
token: token,
|
|
396
396
|
app_id: this.appId,
|
|
397
397
|
});
|
|
398
|
-
const response = (await this.request(`/
|
|
398
|
+
const response = (await this.request(`/auth/verify-token?${params.toString()}`, {
|
|
399
399
|
method: "GET",
|
|
400
400
|
}));
|
|
401
401
|
if (!response.valid) {
|
|
@@ -422,7 +422,7 @@ class PasskeymeApiClient {
|
|
|
422
422
|
* Refresh access token
|
|
423
423
|
*/
|
|
424
424
|
async refreshToken(refreshToken) {
|
|
425
|
-
return this.request("/
|
|
425
|
+
return this.request("/auth/refresh-token", {
|
|
426
426
|
method: "POST",
|
|
427
427
|
body: JSON.stringify({ refresh_token: refreshToken }),
|
|
428
428
|
});
|
|
@@ -431,13 +431,13 @@ class PasskeymeApiClient {
|
|
|
431
431
|
* Get JWKS for token verification
|
|
432
432
|
*/
|
|
433
433
|
async getJWKS() {
|
|
434
|
-
return this.request("/
|
|
434
|
+
return this.request("/auth/jwks");
|
|
435
435
|
}
|
|
436
436
|
/**
|
|
437
437
|
* Exchange authorization code for tokens (hosted auth callback)
|
|
438
438
|
*/
|
|
439
439
|
async exchangeCodeForTokens(code, redirectUri) {
|
|
440
|
-
const result = await this.request("/
|
|
440
|
+
const result = await this.request("/auth/callback", {
|
|
441
441
|
method: "POST",
|
|
442
442
|
body: JSON.stringify({
|
|
443
443
|
code,
|
|
@@ -453,7 +453,7 @@ class PasskeymeApiClient {
|
|
|
453
453
|
* Browser storage implementation using localStorage or sessionStorage
|
|
454
454
|
*/
|
|
455
455
|
class BrowserStorageProvider {
|
|
456
|
-
constructor(useSessionStorage = false, keyPrefix = "@
|
|
456
|
+
constructor(useSessionStorage = false, keyPrefix = "@Passkeyme:") {
|
|
457
457
|
this.keyPrefix = keyPrefix;
|
|
458
458
|
if (typeof window === "undefined") {
|
|
459
459
|
// Server-side environment - create a no-op storage
|
|
@@ -520,7 +520,7 @@ class BrowserStorageProvider {
|
|
|
520
520
|
}
|
|
521
521
|
|
|
522
522
|
/**
|
|
523
|
-
* Secure token storage for
|
|
523
|
+
* Secure token storage for Passkeyme Auth SDK
|
|
524
524
|
*/
|
|
525
525
|
class TokenStorage {
|
|
526
526
|
constructor(storage, useSessionStorage = false) {
|
|
@@ -626,7 +626,7 @@ TokenStorage.EXPIRES_AT_KEY = "passkeyme_expires_at";
|
|
|
626
626
|
TokenStorage.TOKEN_TYPE_KEY = "passkeyme_token_type";
|
|
627
627
|
|
|
628
628
|
/**
|
|
629
|
-
* Platform SDK Interface for
|
|
629
|
+
* Platform SDK Interface for Passkeyme
|
|
630
630
|
*
|
|
631
631
|
* This interface abstracts platform-specific passkey operations,
|
|
632
632
|
* allowing the core SDK to work across web, React Native, and other platforms.
|
|
@@ -799,7 +799,7 @@ catch (error) {
|
|
|
799
799
|
}
|
|
800
800
|
|
|
801
801
|
/**
|
|
802
|
-
* Main
|
|
802
|
+
* Main Passkeyme Authentication SDK class
|
|
803
803
|
*/
|
|
804
804
|
class PasskeymeAuth {
|
|
805
805
|
constructor(config) {
|
|
@@ -1009,7 +1009,7 @@ class PasskeymeAuth {
|
|
|
1009
1009
|
const params = new URLSearchParams({
|
|
1010
1010
|
redirect_uri: finalRedirectUri,
|
|
1011
1011
|
});
|
|
1012
|
-
const oauthUrl = `${this.config.baseUrl}/
|
|
1012
|
+
const oauthUrl = `${this.config.baseUrl}/auth/${this.config.appId}/oauth/${provider}/start?${params.toString()}`;
|
|
1013
1013
|
logger.debug("Redirecting directly to OAuth provider:", provider, oauthUrl);
|
|
1014
1014
|
this.performRedirect(oauthUrl, finalRedirectUri);
|
|
1015
1015
|
}
|
|
@@ -1361,7 +1361,7 @@ class PasskeymeAuth {
|
|
|
1361
1361
|
const sdk = this.passkeySDK;
|
|
1362
1362
|
// Dynamic import for axios (ES modules compatible)
|
|
1363
1363
|
const { default: axios } = await Promise.resolve().then(function () { return index; });
|
|
1364
|
-
// Create axios instance for
|
|
1364
|
+
// Create axios instance for Passkeyme API
|
|
1365
1365
|
const axiosInstance = axios.create({
|
|
1366
1366
|
baseURL: `${this.config.baseUrl}/webauthn/${this.config.appId}`,
|
|
1367
1367
|
headers: {
|
|
@@ -1782,9 +1782,9 @@ async function addAuthHeader(auth, headers = {}, headerName = "Authorization", t
|
|
|
1782
1782
|
}
|
|
1783
1783
|
|
|
1784
1784
|
/**
|
|
1785
|
-
*
|
|
1785
|
+
* Passkeyme Authentication SDK
|
|
1786
1786
|
*
|
|
1787
|
-
* A simple, Firebase Auth-like SDK for authentication with
|
|
1787
|
+
* A simple, Firebase Auth-like SDK for authentication with Passkeyme.
|
|
1788
1788
|
*
|
|
1789
1789
|
* @example
|
|
1790
1790
|
* ```typescript
|
|
@@ -1810,7 +1810,7 @@ async function addAuthHeader(auth, headers = {}, headerName = "Authorization", t
|
|
|
1810
1810
|
*/
|
|
1811
1811
|
// Main exports
|
|
1812
1812
|
/**
|
|
1813
|
-
* Create a new
|
|
1813
|
+
* Create a new Passkeyme Auth instance
|
|
1814
1814
|
*
|
|
1815
1815
|
* @param config - Configuration options
|
|
1816
1816
|
* @returns PasskeymeAuth instance
|
|
@@ -1959,6 +1959,27 @@ const isPlainObject = (val) => {
|
|
|
1959
1959
|
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
|
|
1960
1960
|
};
|
|
1961
1961
|
|
|
1962
|
+
/**
|
|
1963
|
+
* Determine if a value is an empty object (safely handles Buffers)
|
|
1964
|
+
*
|
|
1965
|
+
* @param {*} val The value to test
|
|
1966
|
+
*
|
|
1967
|
+
* @returns {boolean} True if value is an empty object, otherwise false
|
|
1968
|
+
*/
|
|
1969
|
+
const isEmptyObject = (val) => {
|
|
1970
|
+
// Early return for non-objects or Buffers to prevent RangeError
|
|
1971
|
+
if (!isObject(val) || isBuffer(val)) {
|
|
1972
|
+
return false;
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
try {
|
|
1976
|
+
return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
|
|
1977
|
+
} catch (e) {
|
|
1978
|
+
// Fallback for any other objects that might cause RangeError with Object.keys()
|
|
1979
|
+
return false;
|
|
1980
|
+
}
|
|
1981
|
+
};
|
|
1982
|
+
|
|
1962
1983
|
/**
|
|
1963
1984
|
* Determine if a value is a Date
|
|
1964
1985
|
*
|
|
@@ -2081,6 +2102,11 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
2081
2102
|
fn.call(null, obj[i], i, obj);
|
|
2082
2103
|
}
|
|
2083
2104
|
} else {
|
|
2105
|
+
// Buffer check
|
|
2106
|
+
if (isBuffer(obj)) {
|
|
2107
|
+
return;
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2084
2110
|
// Iterate over object keys
|
|
2085
2111
|
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
2086
2112
|
const len = keys.length;
|
|
@@ -2094,6 +2120,10 @@ function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
|
|
2094
2120
|
}
|
|
2095
2121
|
|
|
2096
2122
|
function findKey(obj, key) {
|
|
2123
|
+
if (isBuffer(obj)){
|
|
2124
|
+
return null;
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2097
2127
|
key = key.toLowerCase();
|
|
2098
2128
|
const keys = Object.keys(obj);
|
|
2099
2129
|
let i = keys.length;
|
|
@@ -2447,6 +2477,11 @@ const toJSONObject = (obj) => {
|
|
|
2447
2477
|
return;
|
|
2448
2478
|
}
|
|
2449
2479
|
|
|
2480
|
+
//Buffer check
|
|
2481
|
+
if (isBuffer(source)) {
|
|
2482
|
+
return source;
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2450
2485
|
if(!('toJSON' in source)) {
|
|
2451
2486
|
stack[i] = source;
|
|
2452
2487
|
const target = isArray(source) ? [] : {};
|
|
@@ -2518,6 +2553,7 @@ var utils$1 = {
|
|
|
2518
2553
|
isBoolean,
|
|
2519
2554
|
isObject,
|
|
2520
2555
|
isPlainObject,
|
|
2556
|
+
isEmptyObject,
|
|
2521
2557
|
isReadableStream,
|
|
2522
2558
|
isRequest,
|
|
2523
2559
|
isResponse,
|
|
@@ -3149,7 +3185,7 @@ var platform = {
|
|
|
3149
3185
|
};
|
|
3150
3186
|
|
|
3151
3187
|
function toURLEncodedForm(data, options) {
|
|
3152
|
-
return toFormData(data, new platform.classes.URLSearchParams(),
|
|
3188
|
+
return toFormData(data, new platform.classes.URLSearchParams(), {
|
|
3153
3189
|
visitor: function(value, key, path, helpers) {
|
|
3154
3190
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
3155
3191
|
this.append(key, value.toString('base64'));
|
|
@@ -3157,8 +3193,9 @@ function toURLEncodedForm(data, options) {
|
|
|
3157
3193
|
}
|
|
3158
3194
|
|
|
3159
3195
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
3160
|
-
}
|
|
3161
|
-
|
|
3196
|
+
},
|
|
3197
|
+
...options
|
|
3198
|
+
});
|
|
3162
3199
|
}
|
|
3163
3200
|
|
|
3164
3201
|
/**
|
|
@@ -3911,7 +3948,7 @@ function throttle(fn, freq) {
|
|
|
3911
3948
|
clearTimeout(timer);
|
|
3912
3949
|
timer = null;
|
|
3913
3950
|
}
|
|
3914
|
-
fn
|
|
3951
|
+
fn(...args);
|
|
3915
3952
|
};
|
|
3916
3953
|
|
|
3917
3954
|
const throttled = (...args) => {
|
|
@@ -4167,7 +4204,7 @@ function mergeConfig(config1, config2) {
|
|
|
4167
4204
|
headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
|
|
4168
4205
|
};
|
|
4169
4206
|
|
|
4170
|
-
utils$1.forEach(Object.keys(
|
|
4207
|
+
utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
|
|
4171
4208
|
const merge = mergeMap[prop] || mergeDeepProperties;
|
|
4172
4209
|
const configValue = merge(config1[prop], config2[prop], prop);
|
|
4173
4210
|
(utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
|
|
@@ -4908,7 +4945,7 @@ function dispatchRequest(config) {
|
|
|
4908
4945
|
});
|
|
4909
4946
|
}
|
|
4910
4947
|
|
|
4911
|
-
const VERSION = "1.
|
|
4948
|
+
const VERSION = "1.11.0";
|
|
4912
4949
|
|
|
4913
4950
|
const validators$1 = {};
|
|
4914
4951
|
|
|
@@ -5147,8 +5184,8 @@ class Axios {
|
|
|
5147
5184
|
|
|
5148
5185
|
if (!synchronousRequestInterceptors) {
|
|
5149
5186
|
const chain = [dispatchRequest.bind(this), undefined];
|
|
5150
|
-
chain.unshift
|
|
5151
|
-
chain.push
|
|
5187
|
+
chain.unshift(...requestInterceptorChain);
|
|
5188
|
+
chain.push(...responseInterceptorChain);
|
|
5152
5189
|
len = chain.length;
|
|
5153
5190
|
|
|
5154
5191
|
promise = Promise.resolve(config);
|