@getpara/core-sdk 2.26.0 → 2.27.0
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/cjs/constants.js
CHANGED
|
@@ -46,7 +46,7 @@ __export(constants_exports, {
|
|
|
46
46
|
TRANSACTION_REVIEW_TIMEOUT_MS: () => TRANSACTION_REVIEW_TIMEOUT_MS
|
|
47
47
|
});
|
|
48
48
|
module.exports = __toCommonJS(constants_exports);
|
|
49
|
-
const PARA_CORE_VERSION = "2.
|
|
49
|
+
const PARA_CORE_VERSION = "2.27.0";
|
|
50
50
|
const PREFIX = "@CAPSULE/";
|
|
51
51
|
const PARA_PREFIX = "@PARA/";
|
|
52
52
|
const LOCAL_STORAGE_AUTH_INFO = `${PREFIX}authInfo`;
|
|
@@ -71,7 +71,7 @@ var import_events = require("../types/events.js");
|
|
|
71
71
|
var import_shareDistribution = require("../shares/shareDistribution.js");
|
|
72
72
|
var import_constants = require("../constants.js");
|
|
73
73
|
var import_stateListener = require("../utils/stateListener.js");
|
|
74
|
-
var _stateManager, _authService, _walletService, _pollingService, _paraCoreInterface, _isCreateGuestWalletsPending, _fetchOverridePromise;
|
|
74
|
+
var _stateManager, _authService, _walletService, _pollingService, _paraCoreInterface, _isCreateGuestWalletsPending, _fetchOverridePromise, _claimPregenWalletEntities;
|
|
75
75
|
class PregenWalletService {
|
|
76
76
|
constructor(paraCore) {
|
|
77
77
|
__privateAdd(this, _stateManager);
|
|
@@ -129,37 +129,50 @@ class PregenWalletService {
|
|
|
129
129
|
}
|
|
130
130
|
const { supportedWalletTypes } = yield __privateGet(this, _paraCoreInterface).assertPartner();
|
|
131
131
|
const pregenWallets = yield this.getPregenWallets();
|
|
132
|
-
let recoverySecret
|
|
132
|
+
let recoverySecret;
|
|
133
|
+
let walletIds = {};
|
|
133
134
|
if (pregenWallets.length > 0) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
135
|
+
let candidates = pregenWallets.filter((w) => {
|
|
136
|
+
var _a;
|
|
137
|
+
return !!((_a = __privateGet(this, _walletService).wallets[w.id]) == null ? void 0 : _a.signer);
|
|
138
|
+
});
|
|
139
|
+
if (candidates.length === 0) {
|
|
140
|
+
try {
|
|
141
|
+
const shares = yield __privateGet(this, _paraCoreInterface).ctx.enclaveClient.getPregenShares({
|
|
142
|
+
userId: __privateGet(this, _authService).userId,
|
|
143
|
+
walletIds: pregenWallets.map((w) => w.id),
|
|
144
|
+
partnerId: pregenWallets[0].partnerId
|
|
145
|
+
});
|
|
146
|
+
for (const share of shares) {
|
|
147
|
+
const wallet = pregenWallets.find((w) => w.id === share.walletId);
|
|
148
|
+
if (wallet) {
|
|
149
|
+
__privateGet(this, _walletService).wallets[wallet.id] = {
|
|
150
|
+
id: wallet.id,
|
|
151
|
+
address: wallet.address,
|
|
152
|
+
scheme: wallet.scheme,
|
|
153
|
+
type: wallet.type,
|
|
154
|
+
partnerId: wallet.partnerId,
|
|
155
|
+
isPregen: wallet.isPregen,
|
|
156
|
+
pregenIdentifier: wallet.pregenIdentifier,
|
|
157
|
+
pregenIdentifierType: wallet.pregenIdentifierType,
|
|
158
|
+
signer: share.signer,
|
|
159
|
+
createdAt: String(wallet.createdAt)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
155
162
|
}
|
|
163
|
+
} catch (err) {
|
|
164
|
+
console.warn("[performClaimPregenWallets] Failed to fetch pregen shares:", err);
|
|
156
165
|
}
|
|
157
|
-
|
|
158
|
-
|
|
166
|
+
candidates = pregenWallets.filter((w) => {
|
|
167
|
+
var _a;
|
|
168
|
+
return !!((_a = __privateGet(this, _walletService).wallets[w.id]) == null ? void 0 : _a.signer);
|
|
169
|
+
});
|
|
159
170
|
}
|
|
160
|
-
recoverySecret = yield this.
|
|
171
|
+
const { recoverySecret: claimRecoverySecret, claimedWalletIds } = yield __privateGet(this, _claimPregenWalletEntities).call(this, candidates);
|
|
172
|
+
recoverySecret = claimRecoverySecret;
|
|
173
|
+
const claimed = candidates.filter((w) => claimedWalletIds.includes(w.id));
|
|
161
174
|
walletIds = supportedWalletTypes.reduce((acc, { type }) => {
|
|
162
|
-
const wallet =
|
|
175
|
+
const wallet = claimed.find((w) => !!import_wallet2.WalletSchemeTypeMap[w.scheme][type]);
|
|
163
176
|
if (!wallet) {
|
|
164
177
|
return acc;
|
|
165
178
|
}
|
|
@@ -173,22 +186,42 @@ class PregenWalletService {
|
|
|
173
186
|
return resp;
|
|
174
187
|
});
|
|
175
188
|
this.claimPregenWallets = (..._0) => __async(this, [..._0], function* ({ pregenId } = {}) {
|
|
176
|
-
var _a;
|
|
177
189
|
__privateGet(this, _paraCoreInterface).requireApiKey();
|
|
178
190
|
const pregenWallets = pregenId ? yield this.getPregenWallets({ pregenId }) : yield this.getPregenWallets();
|
|
179
191
|
if (pregenWallets.length === 0) {
|
|
180
192
|
return void 0;
|
|
181
193
|
}
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
194
|
+
const { recoverySecret } = yield __privateGet(this, _claimPregenWalletEntities).call(this, pregenWallets);
|
|
195
|
+
return recoverySecret;
|
|
196
|
+
});
|
|
197
|
+
// Claims only the pregen entities for which the SDK has local signer
|
|
198
|
+
// material. Wallets without signer material are skipped (warned, not
|
|
199
|
+
// thrown) so a stale/duplicate backend row cannot block login.
|
|
200
|
+
// Returns the wallet IDs the backend confirmed claiming so callers can
|
|
201
|
+
// surface only confirmed wallets.
|
|
202
|
+
__privateAdd(this, _claimPregenWalletEntities, (pregenWallets) => __async(this, null, function* () {
|
|
203
|
+
var _a;
|
|
204
|
+
const claimable = pregenWallets.filter((w) => {
|
|
205
|
+
var _a2;
|
|
206
|
+
return !!((_a2 = __privateGet(this, _walletService).wallets[w.id]) == null ? void 0 : _a2.signer);
|
|
207
|
+
});
|
|
208
|
+
const skipped = pregenWallets.filter((w) => {
|
|
209
|
+
var _a2;
|
|
210
|
+
return !((_a2 = __privateGet(this, _walletService).wallets[w.id]) == null ? void 0 : _a2.signer);
|
|
211
|
+
});
|
|
212
|
+
if (skipped.length > 0) {
|
|
213
|
+
console.warn(
|
|
214
|
+
"[claimPregenWallets] Skipping pregen wallets without local share material:",
|
|
215
|
+
skipped.map((w) => w.id)
|
|
186
216
|
);
|
|
187
217
|
}
|
|
218
|
+
if (claimable.length === 0) {
|
|
219
|
+
return { recoverySecret: void 0, claimedWalletIds: [] };
|
|
220
|
+
}
|
|
188
221
|
let newRecoverySecret;
|
|
189
222
|
const { walletIds } = yield __privateGet(this, _paraCoreInterface).ctx.client.claimPregenWallets({
|
|
190
223
|
userId: __privateGet(this, _authService).userId,
|
|
191
|
-
walletIds:
|
|
224
|
+
walletIds: claimable.map((w) => w.id)
|
|
192
225
|
});
|
|
193
226
|
for (const walletId of walletIds) {
|
|
194
227
|
const wallet = __privateGet(this, _walletService).wallets[walletId];
|
|
@@ -233,8 +266,8 @@ class PregenWalletService {
|
|
|
233
266
|
});
|
|
234
267
|
}
|
|
235
268
|
yield __privateGet(this, _walletService).setWallets(__privateGet(this, _walletService).wallets);
|
|
236
|
-
return newRecoverySecret;
|
|
237
|
-
});
|
|
269
|
+
return { recoverySecret: newRecoverySecret, claimedWalletIds: walletIds };
|
|
270
|
+
}));
|
|
238
271
|
this.getPregenWallets = (..._0) => __async(this, [..._0], function* ({ pregenId } = {}) {
|
|
239
272
|
const pregenIds = pregenId ? (0, import_user_management_client.toPregenIds)(pregenId) : this.pregenIds;
|
|
240
273
|
if (!pregenIds || Object.keys(pregenIds).length === 0) {
|
|
@@ -438,6 +471,7 @@ _pollingService = new WeakMap();
|
|
|
438
471
|
_paraCoreInterface = new WeakMap();
|
|
439
472
|
_isCreateGuestWalletsPending = new WeakMap();
|
|
440
473
|
_fetchOverridePromise = new WeakMap();
|
|
474
|
+
_claimPregenWalletEntities = new WeakMap();
|
|
441
475
|
// Annotate the CommonJS export names for ESM import in node:
|
|
442
476
|
0 && (module.exports = {
|
|
443
477
|
PregenWalletService
|
package/dist/esm/constants.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
__spreadProps,
|
|
7
7
|
__spreadValues
|
|
8
8
|
} from "../chunk-7B52C2XE.js";
|
|
9
|
-
var _stateManager, _authService, _walletService, _pollingService, _paraCoreInterface, _isCreateGuestWalletsPending, _fetchOverridePromise;
|
|
9
|
+
var _stateManager, _authService, _walletService, _pollingService, _paraCoreInterface, _isCreateGuestWalletsPending, _fetchOverridePromise, _claimPregenWalletEntities;
|
|
10
10
|
import {
|
|
11
11
|
isPregenAuth,
|
|
12
12
|
toPregenIds,
|
|
@@ -81,37 +81,50 @@ class PregenWalletService {
|
|
|
81
81
|
}
|
|
82
82
|
const { supportedWalletTypes } = yield __privateGet(this, _paraCoreInterface).assertPartner();
|
|
83
83
|
const pregenWallets = yield this.getPregenWallets();
|
|
84
|
-
let recoverySecret
|
|
84
|
+
let recoverySecret;
|
|
85
|
+
let walletIds = {};
|
|
85
86
|
if (pregenWallets.length > 0) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
87
|
+
let candidates = pregenWallets.filter((w) => {
|
|
88
|
+
var _a;
|
|
89
|
+
return !!((_a = __privateGet(this, _walletService).wallets[w.id]) == null ? void 0 : _a.signer);
|
|
90
|
+
});
|
|
91
|
+
if (candidates.length === 0) {
|
|
92
|
+
try {
|
|
93
|
+
const shares = yield __privateGet(this, _paraCoreInterface).ctx.enclaveClient.getPregenShares({
|
|
94
|
+
userId: __privateGet(this, _authService).userId,
|
|
95
|
+
walletIds: pregenWallets.map((w) => w.id),
|
|
96
|
+
partnerId: pregenWallets[0].partnerId
|
|
97
|
+
});
|
|
98
|
+
for (const share of shares) {
|
|
99
|
+
const wallet = pregenWallets.find((w) => w.id === share.walletId);
|
|
100
|
+
if (wallet) {
|
|
101
|
+
__privateGet(this, _walletService).wallets[wallet.id] = {
|
|
102
|
+
id: wallet.id,
|
|
103
|
+
address: wallet.address,
|
|
104
|
+
scheme: wallet.scheme,
|
|
105
|
+
type: wallet.type,
|
|
106
|
+
partnerId: wallet.partnerId,
|
|
107
|
+
isPregen: wallet.isPregen,
|
|
108
|
+
pregenIdentifier: wallet.pregenIdentifier,
|
|
109
|
+
pregenIdentifierType: wallet.pregenIdentifierType,
|
|
110
|
+
signer: share.signer,
|
|
111
|
+
createdAt: String(wallet.createdAt)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
107
114
|
}
|
|
115
|
+
} catch (err) {
|
|
116
|
+
console.warn("[performClaimPregenWallets] Failed to fetch pregen shares:", err);
|
|
108
117
|
}
|
|
109
|
-
|
|
110
|
-
|
|
118
|
+
candidates = pregenWallets.filter((w) => {
|
|
119
|
+
var _a;
|
|
120
|
+
return !!((_a = __privateGet(this, _walletService).wallets[w.id]) == null ? void 0 : _a.signer);
|
|
121
|
+
});
|
|
111
122
|
}
|
|
112
|
-
recoverySecret = yield this.
|
|
123
|
+
const { recoverySecret: claimRecoverySecret, claimedWalletIds } = yield __privateGet(this, _claimPregenWalletEntities).call(this, candidates);
|
|
124
|
+
recoverySecret = claimRecoverySecret;
|
|
125
|
+
const claimed = candidates.filter((w) => claimedWalletIds.includes(w.id));
|
|
113
126
|
walletIds = supportedWalletTypes.reduce((acc, { type }) => {
|
|
114
|
-
const wallet =
|
|
127
|
+
const wallet = claimed.find((w) => !!WalletSchemeTypeMap[w.scheme][type]);
|
|
115
128
|
if (!wallet) {
|
|
116
129
|
return acc;
|
|
117
130
|
}
|
|
@@ -125,22 +138,42 @@ class PregenWalletService {
|
|
|
125
138
|
return resp;
|
|
126
139
|
});
|
|
127
140
|
this.claimPregenWallets = (..._0) => __async(this, [..._0], function* ({ pregenId } = {}) {
|
|
128
|
-
var _a;
|
|
129
141
|
__privateGet(this, _paraCoreInterface).requireApiKey();
|
|
130
142
|
const pregenWallets = pregenId ? yield this.getPregenWallets({ pregenId }) : yield this.getPregenWallets();
|
|
131
143
|
if (pregenWallets.length === 0) {
|
|
132
144
|
return void 0;
|
|
133
145
|
}
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
146
|
+
const { recoverySecret } = yield __privateGet(this, _claimPregenWalletEntities).call(this, pregenWallets);
|
|
147
|
+
return recoverySecret;
|
|
148
|
+
});
|
|
149
|
+
// Claims only the pregen entities for which the SDK has local signer
|
|
150
|
+
// material. Wallets without signer material are skipped (warned, not
|
|
151
|
+
// thrown) so a stale/duplicate backend row cannot block login.
|
|
152
|
+
// Returns the wallet IDs the backend confirmed claiming so callers can
|
|
153
|
+
// surface only confirmed wallets.
|
|
154
|
+
__privateAdd(this, _claimPregenWalletEntities, (pregenWallets) => __async(this, null, function* () {
|
|
155
|
+
var _a;
|
|
156
|
+
const claimable = pregenWallets.filter((w) => {
|
|
157
|
+
var _a2;
|
|
158
|
+
return !!((_a2 = __privateGet(this, _walletService).wallets[w.id]) == null ? void 0 : _a2.signer);
|
|
159
|
+
});
|
|
160
|
+
const skipped = pregenWallets.filter((w) => {
|
|
161
|
+
var _a2;
|
|
162
|
+
return !((_a2 = __privateGet(this, _walletService).wallets[w.id]) == null ? void 0 : _a2.signer);
|
|
163
|
+
});
|
|
164
|
+
if (skipped.length > 0) {
|
|
165
|
+
console.warn(
|
|
166
|
+
"[claimPregenWallets] Skipping pregen wallets without local share material:",
|
|
167
|
+
skipped.map((w) => w.id)
|
|
138
168
|
);
|
|
139
169
|
}
|
|
170
|
+
if (claimable.length === 0) {
|
|
171
|
+
return { recoverySecret: void 0, claimedWalletIds: [] };
|
|
172
|
+
}
|
|
140
173
|
let newRecoverySecret;
|
|
141
174
|
const { walletIds } = yield __privateGet(this, _paraCoreInterface).ctx.client.claimPregenWallets({
|
|
142
175
|
userId: __privateGet(this, _authService).userId,
|
|
143
|
-
walletIds:
|
|
176
|
+
walletIds: claimable.map((w) => w.id)
|
|
144
177
|
});
|
|
145
178
|
for (const walletId of walletIds) {
|
|
146
179
|
const wallet = __privateGet(this, _walletService).wallets[walletId];
|
|
@@ -185,8 +218,8 @@ class PregenWalletService {
|
|
|
185
218
|
});
|
|
186
219
|
}
|
|
187
220
|
yield __privateGet(this, _walletService).setWallets(__privateGet(this, _walletService).wallets);
|
|
188
|
-
return newRecoverySecret;
|
|
189
|
-
});
|
|
221
|
+
return { recoverySecret: newRecoverySecret, claimedWalletIds: walletIds };
|
|
222
|
+
}));
|
|
190
223
|
this.getPregenWallets = (..._0) => __async(this, [..._0], function* ({ pregenId } = {}) {
|
|
191
224
|
const pregenIds = pregenId ? toPregenIds(pregenId) : this.pregenIds;
|
|
192
225
|
if (!pregenIds || Object.keys(pregenIds).length === 0) {
|
|
@@ -390,6 +423,7 @@ _pollingService = new WeakMap();
|
|
|
390
423
|
_paraCoreInterface = new WeakMap();
|
|
391
424
|
_isCreateGuestWalletsPending = new WeakMap();
|
|
392
425
|
_fetchOverridePromise = new WeakMap();
|
|
426
|
+
_claimPregenWalletEntities = new WeakMap();
|
|
393
427
|
export {
|
|
394
428
|
PregenWalletService
|
|
395
429
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/core-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.27.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@celo/utils": "^8.0.2",
|
|
6
6
|
"@cosmjs/encoding": "^0.32.4",
|
|
7
7
|
"@ethereumjs/util": "^9.1.0",
|
|
8
|
-
"@getpara/user-management-client": "2.
|
|
8
|
+
"@getpara/user-management-client": "2.27.0",
|
|
9
9
|
"@noble/hashes": "^1.5.0",
|
|
10
10
|
"axios": "^1.8.4",
|
|
11
11
|
"base64url": "^3.0.1",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dist",
|
|
31
31
|
"package.json"
|
|
32
32
|
],
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "9f3045c8e2b0b372c792a7a35a997d5955f910b1",
|
|
34
34
|
"main": "dist/cjs/index.js",
|
|
35
35
|
"module": "dist/esm/index.js",
|
|
36
36
|
"scripts": {
|