@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/browser.cjs.js
CHANGED
|
@@ -1600,7 +1600,7 @@ class AuthenticationService {
|
|
|
1600
1600
|
async combinedAuthentication(identifier, persAccessToken) {
|
|
1601
1601
|
try {
|
|
1602
1602
|
// Step 1: Try to login with PERS token first (this will get signer JWT if user exists)
|
|
1603
|
-
let signerToken;
|
|
1603
|
+
let signerToken = null;
|
|
1604
1604
|
try {
|
|
1605
1605
|
const loginResult = await this.loginWithPersToken(persAccessToken);
|
|
1606
1606
|
// Extract token from login result
|
|
@@ -1614,6 +1614,11 @@ class AuthenticationService {
|
|
|
1614
1614
|
catch (loginError) {
|
|
1615
1615
|
// Step 2: User doesn't exist - register with v1 API (Unified Flow)
|
|
1616
1616
|
try {
|
|
1617
|
+
// Only proceed to registration if the error is explicitly 'user_not_found'
|
|
1618
|
+
const errorMessage = loginError instanceof Error ? loginError.message : String(loginError);
|
|
1619
|
+
if (errorMessage !== 'user_not_found') {
|
|
1620
|
+
throw loginError;
|
|
1621
|
+
}
|
|
1617
1622
|
const registerResult = await this.registerUser(persAccessToken);
|
|
1618
1623
|
if (registerResult && registerResult.access_token) {
|
|
1619
1624
|
signerToken = registerResult.access_token;
|
|
@@ -1624,9 +1629,13 @@ class AuthenticationService {
|
|
|
1624
1629
|
}
|
|
1625
1630
|
catch (registerError) {
|
|
1626
1631
|
console.error(`[AuthenticationService] Registration failed for ${identifier}:`, registerError);
|
|
1632
|
+
// Explicitly rethrow to abort the entire authentication process
|
|
1627
1633
|
throw registerError;
|
|
1628
1634
|
}
|
|
1629
1635
|
}
|
|
1636
|
+
if (!signerToken) {
|
|
1637
|
+
throw new Error('Authentication failed: Unable to obtain signer token');
|
|
1638
|
+
}
|
|
1630
1639
|
const user = {
|
|
1631
1640
|
identifier: identifier,
|
|
1632
1641
|
signerAuthToken: signerToken,
|
|
@@ -1636,8 +1645,9 @@ class AuthenticationService {
|
|
|
1636
1645
|
return user;
|
|
1637
1646
|
}
|
|
1638
1647
|
catch (error) {
|
|
1639
|
-
|
|
1640
|
-
|
|
1648
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1649
|
+
console.error(`[PersSignerSDK] Combined authentication failed for ${identifier}:`, errorMessage);
|
|
1650
|
+
throw new Error(`Combined authentication failed: ${errorMessage}`);
|
|
1641
1651
|
}
|
|
1642
1652
|
}
|
|
1643
1653
|
}
|
|
@@ -1771,12 +1781,16 @@ class PersSignerSDK {
|
|
|
1771
1781
|
*/
|
|
1772
1782
|
constructor(config) {
|
|
1773
1783
|
this.config = config;
|
|
1784
|
+
// Safe hostname/origin extraction - window.location may be undefined in React Native
|
|
1785
|
+
const hasWindowLocation = typeof window !== 'undefined' && typeof window.location !== 'undefined';
|
|
1786
|
+
const hostname = hasWindowLocation ? window.location.hostname : 'localhost';
|
|
1787
|
+
const origin = hasWindowLocation ? window.location.origin : undefined;
|
|
1774
1788
|
setConfigProvider(new WebConfigProvider({
|
|
1775
1789
|
apiUrl: config.apiUrl || SIGNER_CONFIG.DEFAULT_SIGNER_API_URL,
|
|
1776
1790
|
relyingParty: {
|
|
1777
|
-
id:
|
|
1791
|
+
id: hostname,
|
|
1778
1792
|
name: config.relyingPartyName || SIGNER_CONFIG.DEFAULT_RELYING_PARTY_NAME,
|
|
1779
|
-
origin:
|
|
1793
|
+
origin: origin,
|
|
1780
1794
|
},
|
|
1781
1795
|
}));
|
|
1782
1796
|
this.authenticationService = new AuthenticationService(this.config);
|