@portal-hq/core
Advanced tools
Comparing version 0.3.5 to 0.3.6
@@ -28,3 +28,3 @@ import Storage from '@portal-hq/gdrive-storage' | ||
gatewayConfig: 'test', | ||
mpcVersion: 'v2', | ||
mpcVersion: 'v3', | ||
} as PortalOptions | ||
@@ -31,0 +31,0 @@ |
@@ -36,5 +36,5 @@ "use strict"; | ||
// Optional | ||
address = null, apiHost = 'api.portalhq.io', autoApprove = false, mpcEnabled = true, mpcHost = 'mpc.portalhq.io', mpcVersion = 'v2', }) { | ||
address = null, apiHost = 'api.portalhq.io', autoApprove = false, mpcEnabled = true, mpcHost = 'mpc.portalhq.io', mpcVersion = 'v3', }) { | ||
this.address = ''; | ||
this.mpcVersion = 'v2'; | ||
this.mpcVersion = 'v3'; | ||
this.apiKey = apiKey; | ||
@@ -48,4 +48,4 @@ this.autoApprove = autoApprove; | ||
this.gatewayConfig = gatewayConfig; | ||
if (mpcVersion != 'v2') { | ||
throw new Error('Mpc Version is not supported. Only v2 is currently supported.'); | ||
if (mpcVersion != 'v3') { | ||
throw new Error('Mpc Version is not supported. Only v3 is currently supported.'); | ||
} | ||
@@ -52,0 +52,0 @@ this.mpcVersion = mpcVersion; |
@@ -49,3 +49,3 @@ "use strict"; | ||
class PortalMpc { | ||
constructor({ apiKey, chainId, host = 'mpc.portalhq.io', isSimulator, keychain, portal, storage, rpc, mpcVersion = 'v2', }) { | ||
constructor({ apiKey, chainId, host = 'mpc.portalhq.io', isSimulator, keychain, portal, storage, rpc, mpcVersion = 'v3', }) { | ||
this.address = ''; | ||
@@ -101,3 +101,3 @@ this.chainId = 1; | ||
JSON.parse(res); | ||
if (this.mpcVersion == 'v2') { | ||
if (this.mpcVersion == 'v3') { | ||
const { data, error } = JSON.parse(res); | ||
@@ -132,3 +132,3 @@ if (error && error.code > 0) { | ||
else { | ||
throw new errors_1.default(errors_1.MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v2'); | ||
throw new errors_1.default(errors_1.MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v3'); | ||
} | ||
@@ -201,3 +201,3 @@ } | ||
const privateKey = yield storage.read(); | ||
if (this.mpcVersion == 'v2') { | ||
if (this.mpcVersion == 'v3') { | ||
return this.decryptShareV1(cipherText, privateKey); | ||
@@ -284,3 +284,3 @@ } | ||
let backupShare; | ||
if (this.mpcVersion == 'v2') { | ||
if (this.mpcVersion == 'v3') { | ||
// this.recoverBackup() returns an object with the all new fields, | ||
@@ -304,3 +304,3 @@ // so we use the store the new dkgObject. (only the Bks and public key are the same) | ||
else { | ||
throw new errors_1.default(errors_1.MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v2'); | ||
throw new errors_1.default(errors_1.MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v3'); | ||
} | ||
@@ -384,7 +384,7 @@ yield storage.write(backupShare.privateKey); | ||
} | ||
const { data, error } = this.mpcVersion == 'v2' | ||
const { data, error } = this.mpcVersion == '3' | ||
? JSON.parse(res) | ||
: JSON.parse(res); | ||
if (error) { | ||
throw new Error(error); | ||
if (error && error.code > 0) { | ||
throw new utils_2.PortalMpcError(error); | ||
} | ||
@@ -420,3 +420,3 @@ else { | ||
} | ||
if (this.mpcVersion == 'v2') { | ||
if (this.mpcVersion == 'v3') { | ||
const { data, error } = JSON.parse(res); | ||
@@ -442,3 +442,3 @@ if (error && error.code > 0) { | ||
else { | ||
throw new errors_1.default(errors_1.MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v2'); | ||
throw new errors_1.default(errors_1.MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v3'); | ||
} | ||
@@ -445,0 +445,0 @@ }); |
@@ -23,5 +23,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
// Optional | ||
address = null, apiHost = 'api.portalhq.io', autoApprove = false, mpcEnabled = true, mpcHost = 'mpc.portalhq.io', mpcVersion = 'v2', }) { | ||
address = null, apiHost = 'api.portalhq.io', autoApprove = false, mpcEnabled = true, mpcHost = 'mpc.portalhq.io', mpcVersion = 'v3', }) { | ||
this.address = ''; | ||
this.mpcVersion = 'v2'; | ||
this.mpcVersion = 'v3'; | ||
this.apiKey = apiKey; | ||
@@ -35,4 +35,4 @@ this.autoApprove = autoApprove; | ||
this.gatewayConfig = gatewayConfig; | ||
if (mpcVersion != 'v2') { | ||
throw new Error('Mpc Version is not supported. Only v2 is currently supported.'); | ||
if (mpcVersion != 'v3') { | ||
throw new Error('Mpc Version is not supported. Only v3 is currently supported.'); | ||
} | ||
@@ -39,0 +39,0 @@ this.mpcVersion = mpcVersion; |
@@ -21,3 +21,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
class PortalMpc { | ||
constructor({ apiKey, chainId, host = 'mpc.portalhq.io', isSimulator, keychain, portal, storage, rpc, mpcVersion = 'v2', }) { | ||
constructor({ apiKey, chainId, host = 'mpc.portalhq.io', isSimulator, keychain, portal, storage, rpc, mpcVersion = 'v3', }) { | ||
this.address = ''; | ||
@@ -73,3 +73,3 @@ this.chainId = 1; | ||
JSON.parse(res); | ||
if (this.mpcVersion == 'v2') { | ||
if (this.mpcVersion == 'v3') { | ||
const { data, error } = JSON.parse(res); | ||
@@ -104,3 +104,3 @@ if (error && error.code > 0) { | ||
else { | ||
throw new MpcError(MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v2'); | ||
throw new MpcError(MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v3'); | ||
} | ||
@@ -173,3 +173,3 @@ } | ||
const privateKey = yield storage.read(); | ||
if (this.mpcVersion == 'v2') { | ||
if (this.mpcVersion == 'v3') { | ||
return this.decryptShareV1(cipherText, privateKey); | ||
@@ -256,3 +256,3 @@ } | ||
let backupShare; | ||
if (this.mpcVersion == 'v2') { | ||
if (this.mpcVersion == 'v3') { | ||
// this.recoverBackup() returns an object with the all new fields, | ||
@@ -276,3 +276,3 @@ // so we use the store the new dkgObject. (only the Bks and public key are the same) | ||
else { | ||
throw new MpcError(MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v2'); | ||
throw new MpcError(MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v3'); | ||
} | ||
@@ -356,7 +356,7 @@ yield storage.write(backupShare.privateKey); | ||
} | ||
const { data, error } = this.mpcVersion == 'v2' | ||
const { data, error } = this.mpcVersion == '3' | ||
? JSON.parse(res) | ||
: JSON.parse(res); | ||
if (error) { | ||
throw new Error(error); | ||
if (error && error.code > 0) { | ||
throw new PortalMpcError(error); | ||
} | ||
@@ -392,3 +392,3 @@ else { | ||
} | ||
if (this.mpcVersion == 'v2') { | ||
if (this.mpcVersion == 'v3') { | ||
const { data, error } = JSON.parse(res); | ||
@@ -414,3 +414,3 @@ if (error && error.code > 0) { | ||
else { | ||
throw new MpcError(MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v2'); | ||
throw new MpcError(MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v3'); | ||
} | ||
@@ -417,0 +417,0 @@ }); |
@@ -6,3 +6,3 @@ { | ||
"homepage": "https://portalhq.io/", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"license": "MIT", | ||
@@ -31,9 +31,9 @@ "main": "lib/commonjs/index", | ||
"dependencies": { | ||
"@portal-hq/provider": "^0.3.5", | ||
"@portal-hq/utils": "^0.3.4" | ||
"@portal-hq/provider": "^0.3.6", | ||
"@portal-hq/utils": "^0.3.6" | ||
}, | ||
"devDependencies": { | ||
"@babel/preset-typescript": "^7.18.6", | ||
"@portal-hq/gdrive-storage": "^0.3.5", | ||
"@portal-hq/keychain": "^0.3.4", | ||
"@portal-hq/gdrive-storage": "^0.3.6", | ||
"@portal-hq/keychain": "^0.3.6", | ||
"@types/jest": "^29.2.0", | ||
@@ -40,0 +40,0 @@ "@types/react": "*", |
@@ -31,3 +31,3 @@ import { Provider, type GatewayLike } from '@portal-hq/provider' | ||
public gatewayConfig: GatewayLike | ||
public mpcVersion: string = 'v2' | ||
public mpcVersion: string = 'v3' | ||
@@ -49,3 +49,3 @@ constructor({ | ||
mpcHost = 'mpc.portalhq.io', | ||
mpcVersion = 'v2', | ||
mpcVersion = 'v3', | ||
}: PortalOptions) { | ||
@@ -61,5 +61,5 @@ this.apiKey = apiKey | ||
if (mpcVersion != 'v2') { | ||
if (mpcVersion != 'v3') { | ||
throw new Error( | ||
'Mpc Version is not supported. Only v2 is currently supported.', | ||
'Mpc Version is not supported. Only v3 is currently supported.', | ||
) | ||
@@ -66,0 +66,0 @@ } |
@@ -63,3 +63,3 @@ import { NativeModules } from 'react-native' | ||
rpc, | ||
mpcVersion = 'v2', | ||
mpcVersion = 'v3', | ||
}: PortalMpcOptions) { | ||
@@ -126,3 +126,3 @@ this.apiKey = apiKey | ||
JSON.parse(res) | ||
if (this.mpcVersion == 'v2') { | ||
if (this.mpcVersion == 'v3') { | ||
const { data, error } = JSON.parse(res) as RotateResultV1 | ||
@@ -160,3 +160,3 @@ | ||
} else { | ||
throw new MpcError(MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v2') | ||
throw new MpcError(MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v3') | ||
} | ||
@@ -236,3 +236,3 @@ } catch (e) { | ||
if (this.mpcVersion == 'v2') { | ||
if (this.mpcVersion == 'v3') { | ||
return this.decryptShareV1(cipherText, privateKey) | ||
@@ -337,3 +337,3 @@ } | ||
let backupShare | ||
if (this.mpcVersion == 'v2') { | ||
if (this.mpcVersion == 'v3') { | ||
// this.recoverBackup() returns an object with the all new fields, | ||
@@ -358,3 +358,3 @@ // so we use the store the new dkgObject. (only the Bks and public key are the same) | ||
} else { | ||
throw new MpcError(MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v2') | ||
throw new MpcError(MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v3') | ||
} | ||
@@ -457,8 +457,8 @@ | ||
const { data, error } = | ||
this.mpcVersion == 'v2' | ||
this.mpcVersion == '3' | ||
? (JSON.parse(res) as RotateResultV1) | ||
: (JSON.parse(res) as RotateResult) | ||
if (error) { | ||
throw new Error(error) | ||
if (error && error.code > 0) { | ||
throw new PortalMpcError(error) | ||
} else { | ||
@@ -501,3 +501,3 @@ return data | ||
if (this.mpcVersion == 'v2') { | ||
if (this.mpcVersion == 'v3') { | ||
const { data, error } = JSON.parse(res) as RotateResultV1 | ||
@@ -523,3 +523,3 @@ if (error && error.code > 0) { | ||
} else { | ||
throw new MpcError(MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v2') | ||
throw new MpcError(MpcErrorCodes.UNSUPPORTED_MPC_VERSION, 'must be v3') | ||
} | ||
@@ -526,0 +526,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 4 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
106107031
84
13
Updated@portal-hq/provider@^0.3.6
Updated@portal-hq/utils@^0.3.6