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