@weblock-wallet/sdk 0.1.67 → 0.1.69
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 +35 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1778,11 +1778,11 @@ var storage = import_localforage.default.createInstance({
|
|
|
1778
1778
|
description: "WeBlock Wallet SDK Secure Storage"
|
|
1779
1779
|
});
|
|
1780
1780
|
var LocalForage = {
|
|
1781
|
-
async save(key, value,
|
|
1781
|
+
async save(key, value, expiryEpochMs) {
|
|
1782
1782
|
try {
|
|
1783
1783
|
const item = {
|
|
1784
1784
|
value,
|
|
1785
|
-
|
|
1785
|
+
expiryEpochMs
|
|
1786
1786
|
};
|
|
1787
1787
|
await storage.setItem(key, item);
|
|
1788
1788
|
} catch (err) {
|
|
@@ -1792,10 +1792,8 @@ var LocalForage = {
|
|
|
1792
1792
|
async get(key) {
|
|
1793
1793
|
try {
|
|
1794
1794
|
const item = await storage.getItem(key);
|
|
1795
|
-
if (!item)
|
|
1796
|
-
|
|
1797
|
-
}
|
|
1798
|
-
if (item.expiry && Date.now() > item.expiry * 1e3) {
|
|
1795
|
+
if (!item) return null;
|
|
1796
|
+
if (item.expiryEpochMs && Date.now() > item.expiryEpochMs) {
|
|
1799
1797
|
await storage.removeItem(key);
|
|
1800
1798
|
return null;
|
|
1801
1799
|
}
|
|
@@ -104917,10 +104915,26 @@ var HttpClient = class {
|
|
|
104917
104915
|
if (!accessToken) {
|
|
104918
104916
|
throw new SDKError("No access token found", "AUTH_REQUIRED" /* AUTH_REQUIRED */);
|
|
104919
104917
|
}
|
|
104918
|
+
;
|
|
104920
104919
|
headers["Authorization"] = `Bearer ${accessToken}`;
|
|
104921
104920
|
}
|
|
104922
104921
|
return headers;
|
|
104923
104922
|
}
|
|
104923
|
+
async safeReadErrorDetails(response) {
|
|
104924
|
+
const contentType = response.headers.get("content-type") || "";
|
|
104925
|
+
try {
|
|
104926
|
+
if (contentType.includes("application/json")) {
|
|
104927
|
+
return await response.json();
|
|
104928
|
+
}
|
|
104929
|
+
} catch {
|
|
104930
|
+
}
|
|
104931
|
+
try {
|
|
104932
|
+
const text = await response.text();
|
|
104933
|
+
return text || void 0;
|
|
104934
|
+
} catch {
|
|
104935
|
+
return void 0;
|
|
104936
|
+
}
|
|
104937
|
+
}
|
|
104924
104938
|
async request(method, path, data, config2 = {}) {
|
|
104925
104939
|
const headers = await this.getHeaders(config2.needsAccessToken);
|
|
104926
104940
|
const requestInit = {
|
|
@@ -104931,20 +104945,28 @@ var HttpClient = class {
|
|
|
104931
104945
|
},
|
|
104932
104946
|
credentials: config2.credentials
|
|
104933
104947
|
};
|
|
104934
|
-
if (data) {
|
|
104948
|
+
if (data !== void 0) {
|
|
104935
104949
|
requestInit.body = JSON.stringify(data);
|
|
104936
104950
|
}
|
|
104937
104951
|
const response = await fetch(`${this.baseUrl}${path}`, requestInit);
|
|
104938
104952
|
if (!response.ok) {
|
|
104953
|
+
if (config2.needsAccessToken && (response.status === 401 || response.status === 403)) {
|
|
104954
|
+
await LocalForage.delete(`${this.orgHost}:accessToken`);
|
|
104955
|
+
throw new SDKError(
|
|
104956
|
+
`Authentication required (status: ${response.status})`,
|
|
104957
|
+
"AUTH_REQUIRED" /* AUTH_REQUIRED */,
|
|
104958
|
+
await this.safeReadErrorDetails(response)
|
|
104959
|
+
);
|
|
104960
|
+
}
|
|
104939
104961
|
throw new SDKError(
|
|
104940
104962
|
`HTTP error! status: ${response.status}`,
|
|
104941
104963
|
"REQUEST_FAILED" /* REQUEST_FAILED */,
|
|
104942
|
-
await
|
|
104964
|
+
await this.safeReadErrorDetails(response)
|
|
104943
104965
|
);
|
|
104944
104966
|
}
|
|
104945
|
-
if (response.status ===
|
|
104946
|
-
|
|
104947
|
-
|
|
104967
|
+
if (response.status === 204) return void 0;
|
|
104968
|
+
const contentLength = response.headers.get("content-length");
|
|
104969
|
+
if (contentLength === "0") return void 0;
|
|
104948
104970
|
try {
|
|
104949
104971
|
return await response.json();
|
|
104950
104972
|
} catch {
|
|
@@ -106589,6 +106611,8 @@ var InternalCoreImpl = class {
|
|
|
106589
106611
|
getAddress: () => this.walletService.getAddress(),
|
|
106590
106612
|
create: (password) => this.walletService.create(password),
|
|
106591
106613
|
retrieveWallet: (password) => this.walletService.retrieveWallet(password),
|
|
106614
|
+
// Fix: expose resetPin to InternalCore wallet facade
|
|
106615
|
+
resetPin: (newPassword) => this.walletService.resetPin(newPassword),
|
|
106592
106616
|
getBalance: (address, chainId) => this.walletService.getBalance(address, chainId),
|
|
106593
106617
|
getTokenBalance: (tokenAddress, walletAddress, chainId) => this.walletService.getTokenBalance(tokenAddress, walletAddress, chainId),
|
|
106594
106618
|
sendTransaction: (params) => this.walletService.sendTransaction(params),
|
|
@@ -106611,24 +106635,13 @@ var InternalCoreImpl = class {
|
|
|
106611
106635
|
this.asset = {
|
|
106612
106636
|
transfer: (params) => this.assetService.transfer(params),
|
|
106613
106637
|
addToken: (params) => this.assetService.addToken(params),
|
|
106614
|
-
// New ERC20 methods
|
|
106615
106638
|
getTokenBalance: (params) => this.assetService.getTokenBalance(params),
|
|
106616
|
-
// ERC1155 / RBT helpers
|
|
106617
106639
|
getERC1155Balance: (params) => this.assetService.getERC1155Balance(params),
|
|
106618
106640
|
getRbtClaimable: (params) => this.assetService.getRbtClaimable(params),
|
|
106619
106641
|
claimRbt: (params) => this.assetService.claimRbt(params),
|
|
106620
106642
|
approveToken: (params) => this.assetService.approveToken(params),
|
|
106621
106643
|
getAllowance: (params) => this.assetService.getAllowance(params),
|
|
106622
|
-
// getTokenInfo: (params: TokenInfoParams) =>
|
|
106623
|
-
// this.assetService.getTokenInfo(params),
|
|
106624
106644
|
addNFTCollection: (params) => this.assetService.addNFTCollection(params),
|
|
106625
|
-
// checkSecurityTokenCompliance: (params: {
|
|
106626
|
-
// networkId: string
|
|
106627
|
-
// tokenAddress: string
|
|
106628
|
-
// from: string
|
|
106629
|
-
// to: string
|
|
106630
|
-
// amount: string
|
|
106631
|
-
// }) => this.assetService.checkSecurityTokenCompliance(params),
|
|
106632
106645
|
on: (event, listener) => this.assetService.on(event, listener),
|
|
106633
106646
|
off: (event, listener) => this.assetService.off(event, listener),
|
|
106634
106647
|
getTokenInfo: (params) => this.assetService.getTokenInfo(params),
|