@imtbl/sdk 0.1.6 → 0.1.7
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 +1095 -21
- package/dist/index.d.ts +39 -1
- package/dist/index.js +1094 -23
- package/dist/passport.js +14 -11
- package/dist/provider.d.ts +961 -0
- package/dist/provider.js +1143 -0
- package/package.json +10 -1
package/dist/passport.js
CHANGED
|
@@ -519,24 +519,25 @@ class ImmutableXClient {
|
|
|
519
519
|
function serializeEthSignature(sig) {
|
|
520
520
|
// This is because golang appends a recovery param
|
|
521
521
|
// https://github.com/ethers-io/ethers.js/issues/823
|
|
522
|
-
return encUtils.addHexPrefix(encUtils.padLeft(sig.r.toString(16), 64)
|
|
523
|
-
encUtils.padLeft(sig.s.toString(16), 64)
|
|
524
|
-
encUtils.padLeft(sig.recoveryParam?.toString(16) || '', 2));
|
|
522
|
+
return encUtils.addHexPrefix(encUtils.padLeft(sig.r.toString(16), 64)
|
|
523
|
+
+ encUtils.padLeft(sig.s.toString(16), 64)
|
|
524
|
+
+ encUtils.padLeft(sig.recoveryParam?.toString(16) || '', 2));
|
|
525
525
|
}
|
|
526
526
|
function importRecoveryParam(v) {
|
|
527
|
+
const isValidBigNumber = new BN(v, 16).cmp(new BN(27)) !== -1
|
|
528
|
+
? new BN(v, 16).sub(new BN(27)).toNumber()
|
|
529
|
+
: new BN(v, 16).toNumber();
|
|
527
530
|
return v.trim()
|
|
528
|
-
?
|
|
529
|
-
? new BN(v, 16).sub(new BN(27)).toNumber()
|
|
530
|
-
: new BN(v, 16).toNumber()
|
|
531
|
+
? isValidBigNumber
|
|
531
532
|
: undefined;
|
|
532
533
|
}
|
|
533
534
|
// used chained with serializeEthSignature. serializeEthSignature(deserializeSignature(...))
|
|
534
535
|
function deserializeSignature(sig, size = 64) {
|
|
535
|
-
|
|
536
|
+
const removedHexPrefixSig = encUtils.removeHexPrefix(sig);
|
|
536
537
|
return {
|
|
537
|
-
r: new BN(
|
|
538
|
-
s: new BN(
|
|
539
|
-
recoveryParam: importRecoveryParam(
|
|
538
|
+
r: new BN(removedHexPrefixSig.substring(0, size), 'hex'),
|
|
539
|
+
s: new BN(removedHexPrefixSig.substring(size, size * 2), 'hex'),
|
|
540
|
+
recoveryParam: importRecoveryParam(removedHexPrefixSig.substring(size * 2, size * 2 + 2)),
|
|
540
541
|
};
|
|
541
542
|
}
|
|
542
543
|
async function signRaw(payload, signer) {
|
|
@@ -567,6 +568,7 @@ function convertToSignableToken(token) {
|
|
|
567
568
|
},
|
|
568
569
|
};
|
|
569
570
|
case 'ETH':
|
|
571
|
+
default:
|
|
570
572
|
return {
|
|
571
573
|
type: 'ETH',
|
|
572
574
|
data: {
|
|
@@ -1261,7 +1263,7 @@ class PassportImxProvider {
|
|
|
1261
1263
|
throw new PassportError('Operation not supported', PassportErrorType.OPERATION_NOT_SUPPORTED_ERROR);
|
|
1262
1264
|
}
|
|
1263
1265
|
getAddress() {
|
|
1264
|
-
return Promise.resolve(this.
|
|
1266
|
+
return Promise.resolve(this.user.etherKey);
|
|
1265
1267
|
}
|
|
1266
1268
|
}
|
|
1267
1269
|
|
|
@@ -1371,6 +1373,7 @@ async function registerPassport({ ethSigner, starkSigner, usersApi }, authorizat
|
|
|
1371
1373
|
}
|
|
1372
1374
|
|
|
1373
1375
|
// TODO: Remove this once the dependency has been added
|
|
1376
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
1374
1377
|
class Passport {
|
|
1375
1378
|
authManager;
|
|
1376
1379
|
magicAdapter;
|