@explorins/pers-signer 1.0.31 → 1.0.33
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/browser.cjs.js +19 -5
- package/dist/browser.cjs.js.map +1 -1
- package/dist/browser.esm.js +19 -5
- package/dist/browser.esm.js.map +1 -1
- package/dist/index.cjs.js +19 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +19 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/react-native.cjs.js +19 -5
- package/dist/react-native.cjs.js.map +1 -1
- package/dist/react-native.esm.js +19 -5
- package/dist/react-native.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -393,7 +393,7 @@ class AuthenticationService {
|
|
|
393
393
|
async combinedAuthentication(identifier, persAccessToken) {
|
|
394
394
|
try {
|
|
395
395
|
// Step 1: Try to login with PERS token first (this will get signer JWT if user exists)
|
|
396
|
-
let signerToken;
|
|
396
|
+
let signerToken = null;
|
|
397
397
|
try {
|
|
398
398
|
const loginResult = await this.loginWithPersToken(persAccessToken);
|
|
399
399
|
// Extract token from login result
|
|
@@ -407,6 +407,11 @@ class AuthenticationService {
|
|
|
407
407
|
catch (loginError) {
|
|
408
408
|
// Step 2: User doesn't exist - register with v1 API (Unified Flow)
|
|
409
409
|
try {
|
|
410
|
+
// Only proceed to registration if the error is explicitly 'user_not_found'
|
|
411
|
+
const errorMessage = loginError instanceof Error ? loginError.message : String(loginError);
|
|
412
|
+
if (errorMessage !== 'user_not_found') {
|
|
413
|
+
throw loginError;
|
|
414
|
+
}
|
|
410
415
|
const registerResult = await this.registerUser(persAccessToken);
|
|
411
416
|
if (registerResult && registerResult.access_token) {
|
|
412
417
|
signerToken = registerResult.access_token;
|
|
@@ -417,9 +422,13 @@ class AuthenticationService {
|
|
|
417
422
|
}
|
|
418
423
|
catch (registerError) {
|
|
419
424
|
console.error(`[AuthenticationService] Registration failed for ${identifier}:`, registerError);
|
|
425
|
+
// Explicitly rethrow to abort the entire authentication process
|
|
420
426
|
throw registerError;
|
|
421
427
|
}
|
|
422
428
|
}
|
|
429
|
+
if (!signerToken) {
|
|
430
|
+
throw new Error('Authentication failed: Unable to obtain signer token');
|
|
431
|
+
}
|
|
423
432
|
const user = {
|
|
424
433
|
identifier: identifier,
|
|
425
434
|
signerAuthToken: signerToken,
|
|
@@ -429,8 +438,9 @@ class AuthenticationService {
|
|
|
429
438
|
return user;
|
|
430
439
|
}
|
|
431
440
|
catch (error) {
|
|
432
|
-
|
|
433
|
-
|
|
441
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
442
|
+
console.error(`[PersSignerSDK] Combined authentication failed for ${identifier}:`, errorMessage);
|
|
443
|
+
throw new Error(`Combined authentication failed: ${errorMessage}`);
|
|
434
444
|
}
|
|
435
445
|
}
|
|
436
446
|
}
|
|
@@ -2148,12 +2158,16 @@ class PersSignerSDK {
|
|
|
2148
2158
|
*/
|
|
2149
2159
|
constructor(config) {
|
|
2150
2160
|
this.config = config;
|
|
2161
|
+
// Safe hostname/origin extraction - window.location may be undefined in React Native
|
|
2162
|
+
const hasWindowLocation = typeof window !== 'undefined' && typeof window.location !== 'undefined';
|
|
2163
|
+
const hostname = hasWindowLocation ? window.location.hostname : 'localhost';
|
|
2164
|
+
const origin = hasWindowLocation ? window.location.origin : undefined;
|
|
2151
2165
|
setConfigProvider(new WebConfigProvider({
|
|
2152
2166
|
apiUrl: config.apiUrl || SIGNER_CONFIG.DEFAULT_SIGNER_API_URL,
|
|
2153
2167
|
relyingParty: {
|
|
2154
|
-
id:
|
|
2168
|
+
id: hostname,
|
|
2155
2169
|
name: config.relyingPartyName || SIGNER_CONFIG.DEFAULT_RELYING_PARTY_NAME,
|
|
2156
|
-
origin:
|
|
2170
|
+
origin: origin,
|
|
2157
2171
|
},
|
|
2158
2172
|
}));
|
|
2159
2173
|
this.authenticationService = new AuthenticationService(this.config);
|