@owney/sdk 0.7.17 → 0.7.18
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/index.cjs +19 -10
- package/dist/index.js +19 -10
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -762,7 +762,7 @@ var isJwtExpired = (token) => {
|
|
|
762
762
|
}
|
|
763
763
|
};
|
|
764
764
|
var memorySessions = /* @__PURE__ */ new Map();
|
|
765
|
-
var isFreshSession = (session) => !!session && !!session.token && !isJwtExpired(session.token);
|
|
765
|
+
var isFreshSession = (session) => !!session && typeof session.isPredeployed === "boolean" && !!session.token && !isJwtExpired(session.token);
|
|
766
766
|
var readLegacySession = (store, address) => {
|
|
767
767
|
if (!store) return null;
|
|
768
768
|
const prefix = legacyKeyPrefix(address);
|
|
@@ -1177,6 +1177,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1177
1177
|
internals.httpClient.setAuthToken(cached.token);
|
|
1178
1178
|
internals.authenticatedUserId = cached.userId;
|
|
1179
1179
|
internals.hasActiveSessionKey = cached.hasActiveSessionKey;
|
|
1180
|
+
internals.isPredeployed = cached.isPredeployed;
|
|
1180
1181
|
return;
|
|
1181
1182
|
}
|
|
1182
1183
|
}
|
|
@@ -1188,7 +1189,8 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1188
1189
|
writeSession(newAddress, newChainId, {
|
|
1189
1190
|
token: newToken,
|
|
1190
1191
|
userId: internals.authenticatedUserId,
|
|
1191
|
-
hasActiveSessionKey: internals.hasActiveSessionKey
|
|
1192
|
+
hasActiveSessionKey: internals.hasActiveSessionKey,
|
|
1193
|
+
isPredeployed: internals.isPredeployed
|
|
1192
1194
|
});
|
|
1193
1195
|
}
|
|
1194
1196
|
};
|
|
@@ -1639,12 +1641,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1639
1641
|
);
|
|
1640
1642
|
return;
|
|
1641
1643
|
}
|
|
1642
|
-
const { hasActiveSessionKey } = await this.readWalletState(ownerAddress);
|
|
1643
1644
|
await this.ensureSessionKey(
|
|
1644
1645
|
ownerAddress,
|
|
1645
1646
|
chainId,
|
|
1646
|
-
wallet.address
|
|
1647
|
-
hasActiveSessionKey
|
|
1647
|
+
wallet.address
|
|
1648
1648
|
);
|
|
1649
1649
|
} catch (error) {
|
|
1650
1650
|
console.warn(
|
|
@@ -1653,7 +1653,17 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1653
1653
|
);
|
|
1654
1654
|
}
|
|
1655
1655
|
}
|
|
1656
|
-
async ensureSessionKey(ownerAddress, chainId, smartWallet
|
|
1656
|
+
async ensureSessionKey(ownerAddress, chainId, smartWallet) {
|
|
1657
|
+
const walletState = await this.readWalletState(ownerAddress);
|
|
1658
|
+
const predeployed = walletState.predeployed;
|
|
1659
|
+
if (predeployed !== false) {
|
|
1660
|
+
debugLog("zyfai:onboard", "skipping manual session key", {
|
|
1661
|
+
chainId,
|
|
1662
|
+
predeployed
|
|
1663
|
+
});
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
const hasActiveSessionKey = walletState.hasActiveSessionKey;
|
|
1657
1667
|
const attemptKey = `${ownerAddress.toLowerCase()}:${chainId}`;
|
|
1658
1668
|
if (this.sessionKeyAttempts.has(attemptKey)) {
|
|
1659
1669
|
debugLog(
|
|
@@ -1746,12 +1756,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1746
1756
|
"zyfai:onboard",
|
|
1747
1757
|
"Safe already has code -> no deploy needed, checking the session key"
|
|
1748
1758
|
);
|
|
1749
|
-
const { hasActiveSessionKey } = await this.readWalletState(ownerAddress);
|
|
1750
1759
|
await this.ensureSessionKey(
|
|
1751
1760
|
ownerAddress,
|
|
1752
1761
|
chainId,
|
|
1753
|
-
wallet.address
|
|
1754
|
-
hasActiveSessionKey
|
|
1762
|
+
wallet.address
|
|
1755
1763
|
);
|
|
1756
1764
|
return wallet.address;
|
|
1757
1765
|
}
|
|
@@ -4369,7 +4377,8 @@ function buildSIWXConfig(deps) {
|
|
|
4369
4377
|
writeSession(address, id, {
|
|
4370
4378
|
token: login.accessToken,
|
|
4371
4379
|
userId: login.userId ?? null,
|
|
4372
|
-
hasActiveSessionKey: Boolean(login.hasActiveSessionKey)
|
|
4380
|
+
hasActiveSessionKey: Boolean(login.hasActiveSessionKey),
|
|
4381
|
+
isPredeployed: login.predeployed
|
|
4373
4382
|
});
|
|
4374
4383
|
const stored = {
|
|
4375
4384
|
data: session.data,
|
package/dist/index.js
CHANGED
|
@@ -729,7 +729,7 @@ var isJwtExpired = (token) => {
|
|
|
729
729
|
}
|
|
730
730
|
};
|
|
731
731
|
var memorySessions = /* @__PURE__ */ new Map();
|
|
732
|
-
var isFreshSession = (session) => !!session && !!session.token && !isJwtExpired(session.token);
|
|
732
|
+
var isFreshSession = (session) => !!session && typeof session.isPredeployed === "boolean" && !!session.token && !isJwtExpired(session.token);
|
|
733
733
|
var readLegacySession = (store, address) => {
|
|
734
734
|
if (!store) return null;
|
|
735
735
|
const prefix = legacyKeyPrefix(address);
|
|
@@ -1144,6 +1144,7 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1144
1144
|
internals.httpClient.setAuthToken(cached.token);
|
|
1145
1145
|
internals.authenticatedUserId = cached.userId;
|
|
1146
1146
|
internals.hasActiveSessionKey = cached.hasActiveSessionKey;
|
|
1147
|
+
internals.isPredeployed = cached.isPredeployed;
|
|
1147
1148
|
return;
|
|
1148
1149
|
}
|
|
1149
1150
|
}
|
|
@@ -1155,7 +1156,8 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1155
1156
|
writeSession(newAddress, newChainId, {
|
|
1156
1157
|
token: newToken,
|
|
1157
1158
|
userId: internals.authenticatedUserId,
|
|
1158
|
-
hasActiveSessionKey: internals.hasActiveSessionKey
|
|
1159
|
+
hasActiveSessionKey: internals.hasActiveSessionKey,
|
|
1160
|
+
isPredeployed: internals.isPredeployed
|
|
1159
1161
|
});
|
|
1160
1162
|
}
|
|
1161
1163
|
};
|
|
@@ -1606,12 +1608,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1606
1608
|
);
|
|
1607
1609
|
return;
|
|
1608
1610
|
}
|
|
1609
|
-
const { hasActiveSessionKey } = await this.readWalletState(ownerAddress);
|
|
1610
1611
|
await this.ensureSessionKey(
|
|
1611
1612
|
ownerAddress,
|
|
1612
1613
|
chainId,
|
|
1613
|
-
wallet.address
|
|
1614
|
-
hasActiveSessionKey
|
|
1614
|
+
wallet.address
|
|
1615
1615
|
);
|
|
1616
1616
|
} catch (error) {
|
|
1617
1617
|
console.warn(
|
|
@@ -1620,7 +1620,17 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1620
1620
|
);
|
|
1621
1621
|
}
|
|
1622
1622
|
}
|
|
1623
|
-
async ensureSessionKey(ownerAddress, chainId, smartWallet
|
|
1623
|
+
async ensureSessionKey(ownerAddress, chainId, smartWallet) {
|
|
1624
|
+
const walletState = await this.readWalletState(ownerAddress);
|
|
1625
|
+
const predeployed = walletState.predeployed;
|
|
1626
|
+
if (predeployed !== false) {
|
|
1627
|
+
debugLog("zyfai:onboard", "skipping manual session key", {
|
|
1628
|
+
chainId,
|
|
1629
|
+
predeployed
|
|
1630
|
+
});
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
const hasActiveSessionKey = walletState.hasActiveSessionKey;
|
|
1624
1634
|
const attemptKey = `${ownerAddress.toLowerCase()}:${chainId}`;
|
|
1625
1635
|
if (this.sessionKeyAttempts.has(attemptKey)) {
|
|
1626
1636
|
debugLog(
|
|
@@ -1713,12 +1723,10 @@ var ZyfaiAgent = class _ZyfaiAgent {
|
|
|
1713
1723
|
"zyfai:onboard",
|
|
1714
1724
|
"Safe already has code -> no deploy needed, checking the session key"
|
|
1715
1725
|
);
|
|
1716
|
-
const { hasActiveSessionKey } = await this.readWalletState(ownerAddress);
|
|
1717
1726
|
await this.ensureSessionKey(
|
|
1718
1727
|
ownerAddress,
|
|
1719
1728
|
chainId,
|
|
1720
|
-
wallet.address
|
|
1721
|
-
hasActiveSessionKey
|
|
1729
|
+
wallet.address
|
|
1722
1730
|
);
|
|
1723
1731
|
return wallet.address;
|
|
1724
1732
|
}
|
|
@@ -4340,7 +4348,8 @@ function buildSIWXConfig(deps) {
|
|
|
4340
4348
|
writeSession(address, id, {
|
|
4341
4349
|
token: login.accessToken,
|
|
4342
4350
|
userId: login.userId ?? null,
|
|
4343
|
-
hasActiveSessionKey: Boolean(login.hasActiveSessionKey)
|
|
4351
|
+
hasActiveSessionKey: Boolean(login.hasActiveSessionKey),
|
|
4352
|
+
isPredeployed: login.predeployed
|
|
4344
4353
|
});
|
|
4345
4354
|
const stored = {
|
|
4346
4355
|
data: session.data,
|