@portal-hq/web 1.0.0 → 1.0.1

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.
@@ -20,7 +20,7 @@ class Portal {
20
20
  // Required
21
21
  gatewayConfig,
22
22
  // Optional
23
- apiKey, authToken, authUrl, autoApprove = false, chainId = 1, gdrive, passkey, host = 'web.portalhq.io', mpcVersion = 'v6', featureFlags = {
23
+ apiKey, authToken, authUrl, autoApprove = false, chainId = 1, gdrive, passkey, host = 'web.portalhq.io', mpcVersion = 'v6', mpcHost = 'mpc-client.portalhq.io', featureFlags = {
24
24
  optimized: false,
25
25
  }, }) {
26
26
  this.ready = false;
@@ -33,6 +33,7 @@ class Portal {
33
33
  this.chainId = chainId;
34
34
  this.gatewayConfig = gatewayConfig;
35
35
  this.host = host;
36
+ this.mpcHost = mpcHost;
36
37
  this.mpcVersion = mpcVersion;
37
38
  this.featureFlags = featureFlags;
38
39
  if (gdrive) {
@@ -136,24 +137,6 @@ class Portal {
136
137
  return address;
137
138
  });
138
139
  }
139
- /**
140
- * @deprecated This method is deprecated and will be removed in a future version.
141
- * Use the `recoverWallet` method instead.
142
- */
143
- legacyRecoverWallet(cipherText, progress = () => {
144
- // Noop
145
- }) {
146
- return __awaiter(this, void 0, void 0, function* () {
147
- const recoveredCipherText = yield this.mpc.legacyRecover({
148
- cipherText,
149
- host: this.host,
150
- mpcVersion: this.mpcVersion,
151
- featureFlags: this.featureFlags,
152
- }, progress);
153
- this.address = yield this.mpc.getAddress();
154
- return recoveredCipherText;
155
- });
156
- }
157
140
  provisionWallet(cipherText, backupMethod, backupConfigs, progress = () => {
158
141
  // Noop
159
142
  }) {
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MpcErrorCodes = exports.MpcError = void 0;
13
13
  const errors_1 = require("./errors");
14
14
  const index_1 = require("../index");
15
- const WEB_SDK_VERSION = '1.0.0';
15
+ const WEB_SDK_VERSION = '1.0.1';
16
16
  class Mpc {
17
17
  constructor({ portal }) {
18
18
  this.configureIframe = () => {
@@ -26,6 +26,8 @@ class Mpc {
26
26
  passkey: this.portal.passkeyConfig,
27
27
  host: this.portal.host,
28
28
  rpcUrl: this.portal.getRpcUrl(),
29
+ mpcHost: this.portal.mpcHost,
30
+ mpcVersion: this.portal.mpcVersion,
29
31
  featureFlags: this.portal.featureFlags,
30
32
  };
31
33
  const message = {
@@ -278,51 +280,6 @@ class Mpc {
278
280
  });
279
281
  });
280
282
  }
281
- legacyRecover(data, progress = () => {
282
- // Noop
283
- }) {
284
- return __awaiter(this, void 0, void 0, function* () {
285
- return new Promise((resolve, reject) => {
286
- const handleRecover = (message) => {
287
- const { type, data } = message.data;
288
- const { origin } = message;
289
- // ignore any broadcast postMessages
290
- if (origin !== this.getOrigin()) {
291
- return;
292
- }
293
- if (type === 'portal:wasm:legacyRecoverError') {
294
- // Remove the event listeners
295
- window.removeEventListener('message', handleRecover);
296
- window.removeEventListener('message', handleProgress);
297
- reject(new errors_1.PortalMpcError(data));
298
- }
299
- else if (type === 'portal:wasm:legacyRecoverResult') {
300
- // Remove the event listeners
301
- window.removeEventListener('message', handleRecover);
302
- window.removeEventListener('message', handleProgress);
303
- resolve(data);
304
- }
305
- };
306
- const handleProgress = (message) => {
307
- const { type, data: status } = message.data;
308
- const { origin } = message;
309
- // ignore any broadcast postMessages
310
- if (origin !== this.getOrigin()) {
311
- return;
312
- }
313
- if (type === 'portal:wasm:legacyRecoverProgress') {
314
- void progress(status);
315
- }
316
- };
317
- window.addEventListener('message', handleRecover);
318
- window.addEventListener('message', handleProgress);
319
- this.postMessage({
320
- type: 'portal:wasm:legacyRecover',
321
- data,
322
- });
323
- });
324
- });
325
- }
326
283
  sign(data, progress = () => {
327
284
  // Noop
328
285
  }) {
@@ -261,11 +261,10 @@ class Provider {
261
261
  case 'eth_signTypedData_v4':
262
262
  case 'personal_sign': {
263
263
  const result = yield this.portal.mpc.sign({
264
- host: this.portal.host,
264
+ chainId: this.portal.chainId.toString(),
265
265
  method,
266
- mpcVersion: this.portal.mpcVersion,
267
266
  params: this.buildParams(method, params),
268
- featureFlags: this.portal.featureFlags,
267
+ rpcUrl: this.portal.getRpcUrl(),
269
268
  });
270
269
  return result;
271
270
  }
package/lib/esm/index.js CHANGED
@@ -14,7 +14,7 @@ class Portal {
14
14
  // Required
15
15
  gatewayConfig,
16
16
  // Optional
17
- apiKey, authToken, authUrl, autoApprove = false, chainId = 1, gdrive, passkey, host = 'web.portalhq.io', mpcVersion = 'v6', featureFlags = {
17
+ apiKey, authToken, authUrl, autoApprove = false, chainId = 1, gdrive, passkey, host = 'web.portalhq.io', mpcVersion = 'v6', mpcHost = 'mpc-client.portalhq.io', featureFlags = {
18
18
  optimized: false,
19
19
  }, }) {
20
20
  this.ready = false;
@@ -27,6 +27,7 @@ class Portal {
27
27
  this.chainId = chainId;
28
28
  this.gatewayConfig = gatewayConfig;
29
29
  this.host = host;
30
+ this.mpcHost = mpcHost;
30
31
  this.mpcVersion = mpcVersion;
31
32
  this.featureFlags = featureFlags;
32
33
  if (gdrive) {
@@ -130,24 +131,6 @@ class Portal {
130
131
  return address;
131
132
  });
132
133
  }
133
- /**
134
- * @deprecated This method is deprecated and will be removed in a future version.
135
- * Use the `recoverWallet` method instead.
136
- */
137
- legacyRecoverWallet(cipherText, progress = () => {
138
- // Noop
139
- }) {
140
- return __awaiter(this, void 0, void 0, function* () {
141
- const recoveredCipherText = yield this.mpc.legacyRecover({
142
- cipherText,
143
- host: this.host,
144
- mpcVersion: this.mpcVersion,
145
- featureFlags: this.featureFlags,
146
- }, progress);
147
- this.address = yield this.mpc.getAddress();
148
- return recoveredCipherText;
149
- });
150
- }
151
134
  provisionWallet(cipherText, backupMethod, backupConfigs, progress = () => {
152
135
  // Noop
153
136
  }) {
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { PortalMpcError } from './errors';
11
11
  import { BackupMethods } from '../index';
12
- const WEB_SDK_VERSION = '1.0.0';
12
+ const WEB_SDK_VERSION = '1.0.1';
13
13
  class Mpc {
14
14
  constructor({ portal }) {
15
15
  this.configureIframe = () => {
@@ -23,6 +23,8 @@ class Mpc {
23
23
  passkey: this.portal.passkeyConfig,
24
24
  host: this.portal.host,
25
25
  rpcUrl: this.portal.getRpcUrl(),
26
+ mpcHost: this.portal.mpcHost,
27
+ mpcVersion: this.portal.mpcVersion,
26
28
  featureFlags: this.portal.featureFlags,
27
29
  };
28
30
  const message = {
@@ -275,51 +277,6 @@ class Mpc {
275
277
  });
276
278
  });
277
279
  }
278
- legacyRecover(data, progress = () => {
279
- // Noop
280
- }) {
281
- return __awaiter(this, void 0, void 0, function* () {
282
- return new Promise((resolve, reject) => {
283
- const handleRecover = (message) => {
284
- const { type, data } = message.data;
285
- const { origin } = message;
286
- // ignore any broadcast postMessages
287
- if (origin !== this.getOrigin()) {
288
- return;
289
- }
290
- if (type === 'portal:wasm:legacyRecoverError') {
291
- // Remove the event listeners
292
- window.removeEventListener('message', handleRecover);
293
- window.removeEventListener('message', handleProgress);
294
- reject(new PortalMpcError(data));
295
- }
296
- else if (type === 'portal:wasm:legacyRecoverResult') {
297
- // Remove the event listeners
298
- window.removeEventListener('message', handleRecover);
299
- window.removeEventListener('message', handleProgress);
300
- resolve(data);
301
- }
302
- };
303
- const handleProgress = (message) => {
304
- const { type, data: status } = message.data;
305
- const { origin } = message;
306
- // ignore any broadcast postMessages
307
- if (origin !== this.getOrigin()) {
308
- return;
309
- }
310
- if (type === 'portal:wasm:legacyRecoverProgress') {
311
- void progress(status);
312
- }
313
- };
314
- window.addEventListener('message', handleRecover);
315
- window.addEventListener('message', handleProgress);
316
- this.postMessage({
317
- type: 'portal:wasm:legacyRecover',
318
- data,
319
- });
320
- });
321
- });
322
- }
323
280
  sign(data, progress = () => {
324
281
  // Noop
325
282
  }) {
@@ -259,11 +259,10 @@ class Provider {
259
259
  case 'eth_signTypedData_v4':
260
260
  case 'personal_sign': {
261
261
  const result = yield this.portal.mpc.sign({
262
- host: this.portal.host,
262
+ chainId: this.portal.chainId.toString(),
263
263
  method,
264
- mpcVersion: this.portal.mpcVersion,
265
264
  params: this.buildParams(method, params),
266
- featureFlags: this.portal.featureFlags,
265
+ rpcUrl: this.portal.getRpcUrl(),
267
266
  });
268
267
  return result;
269
268
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Portal MPC Support for Web",
4
4
  "author": "Portal Labs, Inc.",
5
5
  "homepage": "https://portalhq.io/",
6
- "version": "1.0.0",
6
+ "version": "1.0.1",
7
7
  "license": "MIT",
8
8
  "main": "lib/commonjs/index",
9
9
  "module": "lib/esm/index",
package/src/index.ts CHANGED
@@ -33,6 +33,7 @@ class Portal {
33
33
  public passkeyConfig?: PasskeyConfig
34
34
  public host: string
35
35
  public mpc: Mpc
36
+ public mpcHost: string
36
37
  public mpcVersion: string
37
38
  public provider: Provider
38
39
  public ready = false
@@ -56,6 +57,7 @@ class Portal {
56
57
  passkey,
57
58
  host = 'web.portalhq.io',
58
59
  mpcVersion = 'v6',
60
+ mpcHost = 'mpc-client.portalhq.io',
59
61
  featureFlags = {
60
62
  optimized: false,
61
63
  },
@@ -67,6 +69,7 @@ class Portal {
67
69
  this.chainId = chainId
68
70
  this.gatewayConfig = gatewayConfig
69
71
  this.host = host
72
+ this.mpcHost = mpcHost
70
73
  this.mpcVersion = mpcVersion
71
74
  this.featureFlags = featureFlags
72
75
 
@@ -205,31 +208,6 @@ class Portal {
205
208
  return address
206
209
  }
207
210
 
208
- /**
209
- * @deprecated This method is deprecated and will be removed in a future version.
210
- * Use the `recoverWallet` method instead.
211
- */
212
- public async legacyRecoverWallet(
213
- cipherText: string,
214
- progress: ProgressCallback = () => {
215
- // Noop
216
- },
217
- ): Promise<string> {
218
- const recoveredCipherText = await this.mpc.legacyRecover(
219
- {
220
- cipherText,
221
- host: this.host,
222
- mpcVersion: this.mpcVersion,
223
- featureFlags: this.featureFlags,
224
- },
225
- progress,
226
- )
227
-
228
- this.address = await this.mpc.getAddress()
229
-
230
- return recoveredCipherText
231
- }
232
-
233
211
  public async provisionWallet(
234
212
  cipherText: string,
235
213
  backupMethod: BackupMethods,
package/src/mpc/index.ts CHANGED
@@ -9,7 +9,6 @@ import type {
9
9
  EjectArgs,
10
10
  GenerateArgs,
11
11
  IframeConfigurationOptions,
12
- LegacyRecoverArgs,
13
12
  MpcOptions,
14
13
  MpcStatus,
15
14
  NFT,
@@ -26,7 +25,7 @@ import type {
26
25
  WorkerResult,
27
26
  } from '../../types'
28
27
 
29
- const WEB_SDK_VERSION = '1.0.0'
28
+ const WEB_SDK_VERSION = '1.0.1'
30
29
 
31
30
  class Mpc {
32
31
  public iframe?: HTMLIFrameElement
@@ -329,61 +328,6 @@ class Mpc {
329
328
  })
330
329
  }
331
330
 
332
- public async legacyRecover(
333
- data: LegacyRecoverArgs,
334
- progress: ProgressCallback = () => {
335
- // Noop
336
- },
337
- ): Promise<string> {
338
- return new Promise((resolve, reject) => {
339
- const handleRecover = (message: MessageEvent<WorkerResult>) => {
340
- const { type, data } = message.data
341
- const { origin } = message
342
-
343
- // ignore any broadcast postMessages
344
- if (origin !== this.getOrigin()) {
345
- return
346
- }
347
-
348
- if (type === 'portal:wasm:legacyRecoverError') {
349
- // Remove the event listeners
350
- window.removeEventListener('message', handleRecover)
351
- window.removeEventListener('message', handleProgress)
352
-
353
- reject(new PortalMpcError(data as PortalError))
354
- } else if (type === 'portal:wasm:legacyRecoverResult') {
355
- // Remove the event listeners
356
- window.removeEventListener('message', handleRecover)
357
- window.removeEventListener('message', handleProgress)
358
-
359
- resolve(data as string)
360
- }
361
- }
362
-
363
- const handleProgress = (message: MessageEvent<WorkerResult>) => {
364
- const { type, data: status } = message.data
365
- const { origin } = message
366
-
367
- // ignore any broadcast postMessages
368
- if (origin !== this.getOrigin()) {
369
- return
370
- }
371
-
372
- if (type === 'portal:wasm:legacyRecoverProgress') {
373
- void progress(status as MpcStatus)
374
- }
375
- }
376
-
377
- window.addEventListener('message', handleRecover)
378
- window.addEventListener('message', handleProgress)
379
-
380
- this.postMessage({
381
- type: 'portal:wasm:legacyRecover',
382
- data,
383
- })
384
- })
385
- }
386
-
387
331
  public async sign(
388
332
  data: SignArgs,
389
333
  progress: ProgressCallback = () => {
@@ -885,6 +829,8 @@ class Mpc {
885
829
  passkey: this.portal.passkeyConfig,
886
830
  host: this.portal.host,
887
831
  rpcUrl: this.portal.getRpcUrl(),
832
+ mpcHost: this.portal.mpcHost,
833
+ mpcVersion: this.portal.mpcVersion,
888
834
  featureFlags: this.portal.featureFlags,
889
835
  }
890
836
 
@@ -303,11 +303,10 @@ class Provider {
303
303
  case 'eth_signTypedData_v4':
304
304
  case 'personal_sign': {
305
305
  const result = await this.portal.mpc.sign({
306
- host: this.portal.host,
306
+ chainId: this.portal.chainId.toString(),
307
307
  method,
308
- mpcVersion: this.portal.mpcVersion,
309
308
  params: this.buildParams(method, params),
310
- featureFlags: this.portal.featureFlags,
309
+ rpcUrl: this.portal.getRpcUrl(),
311
310
  })
312
311
 
313
312
  return result
package/types.d.ts CHANGED
@@ -177,6 +177,15 @@ export interface DecryptResult {
177
177
  error: PortalError
178
178
  }
179
179
 
180
+ export interface EjectArgs extends RecoverArgs {
181
+ organizationBackupShare: string
182
+ }
183
+
184
+ export interface EjectWorkerArgs extends MpcOperationArgs {
185
+ clientShare: string
186
+ organizationBackupShare: string
187
+ }
188
+
180
189
  export interface GatewayConfig {
181
190
  [key: number]: string
182
191
  }
@@ -231,6 +240,8 @@ export interface IframeConfigurationOptions {
231
240
  passkey?: PasskeyConfig
232
241
  host: string
233
242
  rpcUrl: string
243
+ mpcHost: string
244
+ mpcVersion: string
234
245
 
235
246
  // One of these three is required for authentication
236
247
  apiKey?: string
@@ -293,6 +304,14 @@ export interface NFTContract {
293
304
  address: string
294
305
  }
295
306
 
307
+ export interface PasskeyConfig {
308
+ relyingParty?: string = 'backup.web.portalhq.io'
309
+ }
310
+
311
+ export interface PasskeyStatusResponse {
312
+ status: PasskeyStatus
313
+ }
314
+
296
315
  export interface PedersonParams {
297
316
  n: string
298
317
  s: string
@@ -325,6 +344,7 @@ export interface PortalOptions {
325
344
  gdrive?: GDriveConfig
326
345
  passkey?: PasskeyConfig
327
346
  host?: string
347
+ mpcHost?: string
328
348
  keychain?: KeychainAdapter
329
349
  mpcVersion?: string
330
350
  featureFlags?: FeatureFlags
@@ -375,9 +395,6 @@ export interface RequestArguments {
375
395
  params?: unknown[] | SigningRequestParams
376
396
  }
377
397
 
378
- export interface LegacyRecoverArgs extends MpcOperationArgs {
379
- cipherText: string
380
- }
381
398
  export interface RecoverArgs extends MpcOperationArgs {
382
399
  cipherText: string
383
400
  backupMethod: BackupMethods
@@ -385,15 +402,6 @@ export interface RecoverArgs extends MpcOperationArgs {
385
402
  featureFlags?: FeatureFlags // TODO: Remove this
386
403
  }
387
404
 
388
- export interface EjectArgs extends RecoverArgs {
389
- organizationBackupShare: string
390
- }
391
-
392
- export interface EjectWorkerArgs extends MpcOperationArgs {
393
- clientShare: string
394
- organizationBackupShare: string
395
- }
396
-
397
405
  export interface RotateResult {
398
406
  data: RotateData
399
407
  error: PortalError
@@ -414,10 +422,11 @@ export interface RpcErrorOptions {
414
422
  data?: unknown
415
423
  }
416
424
 
417
- export interface SignArgs extends MpcOperationArgs {
425
+ export interface SignArgs {
426
+ chainId: string
418
427
  method: string
419
428
  params: string
420
- featureFlags?: FeatureFlags
429
+ rpcUrl: string
421
430
  }
422
431
 
423
432
  export interface SignData {