@ceramicnetwork/blockchain-utils-validation 1.6.7 → 2.0.0-alpha.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.
- package/README.md +9 -1
- package/lib/blockchain-handler.d.ts +0 -0
- package/lib/blockchain-handler.d.ts.map +0 -0
- package/lib/blockchain-handler.js +1 -2
- package/lib/blockchain-handler.js.map +0 -0
- package/lib/blockchains/__tests__/fixtures.d.ts +0 -0
- package/lib/blockchains/__tests__/fixtures.d.ts.map +0 -0
- package/lib/blockchains/__tests__/fixtures.js +1 -4
- package/lib/blockchains/__tests__/fixtures.js.map +1 -1
- package/lib/blockchains/cosmos.d.ts +2 -3
- package/lib/blockchains/cosmos.d.ts.map +1 -1
- package/lib/blockchains/cosmos.js +10 -34
- package/lib/blockchains/cosmos.js.map +1 -1
- package/lib/blockchains/eosio.d.ts +2 -3
- package/lib/blockchains/eosio.d.ts.map +1 -1
- package/lib/blockchains/eosio.js +7 -31
- package/lib/blockchains/eosio.js.map +1 -1
- package/lib/blockchains/ethereum.d.ts +2 -3
- package/lib/blockchains/ethereum.d.ts.map +1 -1
- package/lib/blockchains/ethereum.js +19 -36
- package/lib/blockchains/ethereum.js.map +1 -1
- package/lib/blockchains/filecoin.d.ts +2 -3
- package/lib/blockchains/filecoin.d.ts.map +1 -1
- package/lib/blockchains/filecoin.js +6 -30
- package/lib/blockchains/filecoin.js.map +1 -1
- package/lib/blockchains/near.d.ts +2 -3
- package/lib/blockchains/near.d.ts.map +1 -1
- package/lib/blockchains/near.js +9 -36
- package/lib/blockchains/near.js.map +1 -1
- package/lib/blockchains/polkadot.d.ts +2 -3
- package/lib/blockchains/polkadot.d.ts.map +1 -1
- package/lib/blockchains/polkadot.js +7 -13
- package/lib/blockchains/polkadot.js.map +1 -1
- package/lib/blockchains/solana.d.ts +2 -3
- package/lib/blockchains/solana.d.ts.map +1 -1
- package/lib/blockchains/solana.js +7 -31
- package/lib/blockchains/solana.js.map +1 -1
- package/lib/blockchains/tezos.d.ts +2 -3
- package/lib/blockchains/tezos.d.ts.map +1 -1
- package/lib/blockchains/tezos.js +18 -44
- package/lib/blockchains/tezos.js.map +1 -1
- package/lib/index.d.ts +0 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +24 -28
- package/lib/index.js.map +1 -1
- package/package.json +26 -20
- package/CHANGELOG.md +0 -696
package/README.md
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Utils for validation of linked blockchain accounts
|
|
2
|
+

|
|
3
|
+
[](https://lbesson.mit-license.org/)
|
|
4
|
+
[](https://discord.gg/6VRZpGP)
|
|
5
|
+
[](https://twitter.com/ceramicnetwork)
|
|
2
6
|
|
|
3
7
|
> This package contains utility functions to validate links of blockchain accounts linked a DID.
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
## Installation
|
|
6
10
|
```shell
|
|
7
11
|
npm install @ceramicnetwork/blockchain-utils-validation
|
|
8
12
|
```
|
|
9
13
|
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
See the [Ceramic developer site](https://developers.ceramic.network/) for more details about how to use this package.
|
|
17
|
+
|
|
10
18
|
## Contributing
|
|
11
19
|
We are happy to accept small and large contributions. Make sure to check out the [Ceramic specifications](https://github.com/ceramicnetwork/specs) for details of how the protocol works.
|
|
12
20
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../../src/blockchains/__tests__/fixtures.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../../src/blockchains/__tests__/fixtures.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,EAAE,EAAE;QACF,KAAK,EAAE;YACL,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,+EAA+E;YACxF,SAAS,EACP,sIAAsI;SACzI;QACD,OAAO,EAAE;YACP,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,+EAA+E;YACxF,SAAS,EACP,sIAAsI;SACzI;KACF;IACD,EAAE,EAAE;QACF,KAAK,EAAE;YACL,OAAO,EAAE,CAAC;YACV,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,+EAA+E;YACxF,SAAS,EACP,sIAAsI;YACxI,OAAO,EAAE,4CAA4C;SACtD;QACD,OAAO,EAAE;YACP,OAAO,EAAE,CAAC;YACV,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,+EAA+E;YACxF,SAAS,EACP,sIAAsI;YACxI,OAAO,EAAE,4CAA4C;SACtD;KACF;CACF,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BlockchainHandler } from '../blockchain-handler';
|
|
1
|
+
import { BlockchainHandler } from '../blockchain-handler.js';
|
|
2
2
|
import { LinkProof } from '@ceramicnetwork/blockchain-utils-linking';
|
|
3
3
|
export declare function validateLink(proof: LinkProof): Promise<LinkProof | null>;
|
|
4
|
-
declare const
|
|
5
|
-
export default Handler;
|
|
4
|
+
export declare const handler: BlockchainHandler;
|
|
6
5
|
//# sourceMappingURL=cosmos.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmos.d.ts","sourceRoot":"","sources":["../../src/blockchains/cosmos.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cosmos.d.ts","sourceRoot":"","sources":["../../src/blockchains/cosmos.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAU,MAAM,0CAA0C,CAAA;AAW5E,wBAAsB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAS9E;AAED,eAAO,MAAM,OAAO,EAAE,iBAGrB,CAAA"}
|
|
@@ -1,45 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.validateLink = void 0;
|
|
23
|
-
const caip_1 = require("caip");
|
|
24
|
-
const sig_1 = require("@tendermint/sig");
|
|
25
|
-
const blockchain_utils_linking_1 = require("@ceramicnetwork/blockchain-utils-linking");
|
|
26
|
-
const uint8arrays = __importStar(require("uint8arrays"));
|
|
1
|
+
import tendermint from '@tendermint/sig';
|
|
2
|
+
import { cosmos } from '@ceramicnetwork/blockchain-utils-linking';
|
|
3
|
+
import * as uint8arrays from 'uint8arrays';
|
|
4
|
+
import { normalizeAccountId } from '@ceramicnetwork/common';
|
|
27
5
|
const namespace = 'cosmos';
|
|
28
6
|
const stringEncode = (str) => uint8arrays.toString(uint8arrays.fromString(str), 'base64pad');
|
|
29
7
|
const stringDecode = (str) => uint8arrays.toString(uint8arrays.fromString(str, 'base64pad'));
|
|
30
|
-
async function validateLink(proof) {
|
|
31
|
-
const account =
|
|
8
|
+
export async function validateLink(proof) {
|
|
9
|
+
const account = normalizeAccountId(proof.account);
|
|
32
10
|
const encodedMsg = stringEncode(proof.message);
|
|
33
|
-
const payload =
|
|
11
|
+
const payload = cosmos.asTransaction(account.address, encodedMsg);
|
|
34
12
|
const sigObj = JSON.parse(stringDecode(proof.signature));
|
|
35
|
-
const Tx = { ...payload, ...
|
|
36
|
-
const is_sig_valid =
|
|
13
|
+
const Tx = { ...payload, ...cosmos.getMetaData(), signatures: [sigObj] };
|
|
14
|
+
const is_sig_valid = tendermint.verifyTx(Tx, cosmos.getMetaData());
|
|
37
15
|
return is_sig_valid ? proof : null;
|
|
38
16
|
}
|
|
39
|
-
|
|
40
|
-
const Handler = {
|
|
17
|
+
export const handler = {
|
|
41
18
|
namespace,
|
|
42
19
|
validateLink,
|
|
43
20
|
};
|
|
44
|
-
exports.default = Handler;
|
|
45
21
|
//# sourceMappingURL=cosmos.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmos.js","sourceRoot":"","sources":["../../src/blockchains/cosmos.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cosmos.js","sourceRoot":"","sources":["../../src/blockchains/cosmos.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,iBAAiB,CAAA;AAExC,OAAO,EAAa,MAAM,EAAE,MAAM,0CAA0C,CAAA;AAC5E,OAAO,KAAK,WAAW,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE3D,MAAM,SAAS,GAAG,QAAQ,CAAA;AAE1B,MAAM,YAAY,GAAG,CAAC,GAAW,EAAU,EAAE,CAC3C,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,CAAA;AAChE,MAAM,YAAY,GAAG,CAAC,GAAW,EAAU,EAAE,CAC3C,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAA;AAEhE,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAgB;IAEjD,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACjD,MAAM,UAAU,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAC9C,MAAM,OAAO,GAAG,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IACjE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAA;IACxD,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,CAAC,MAAM,CAAC,EAAE,CAAA;IACxE,MAAM,YAAY,GAAG,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;IAClE,OAAO,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AACpC,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAsB;IACxC,SAAS;IACT,YAAY;CACb,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BlockchainHandler } from '../blockchain-handler';
|
|
1
|
+
import { BlockchainHandler } from '../blockchain-handler.js';
|
|
2
2
|
import * as linking from '@ceramicnetwork/blockchain-utils-linking';
|
|
3
3
|
export declare function validateLink(proof: linking.LinkProof): Promise<linking.LinkProof | null>;
|
|
4
|
-
declare const
|
|
5
|
-
export default Handler;
|
|
4
|
+
export declare const handler: BlockchainHandler;
|
|
6
5
|
//# sourceMappingURL=eosio.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eosio.d.ts","sourceRoot":"","sources":["../../src/blockchains/eosio.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eosio.d.ts","sourceRoot":"","sources":["../../src/blockchains/eosio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,OAAO,MAAM,0CAA0C,CAAA;AAKnE,wBAAsB,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAW9F;AAED,eAAO,MAAM,OAAO,EAAE,iBAGrB,CAAA"}
|
package/lib/blockchains/eosio.js
CHANGED
|
@@ -1,34 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.validateLink = void 0;
|
|
23
|
-
const caip_1 = require("caip");
|
|
24
|
-
const eosio_signing_tools_1 = require("@smontero/eosio-signing-tools");
|
|
25
|
-
const linking = __importStar(require("@ceramicnetwork/blockchain-utils-linking"));
|
|
1
|
+
import { SigningTools } from '@smontero/eosio-signing-tools';
|
|
2
|
+
import * as linking from '@ceramicnetwork/blockchain-utils-linking';
|
|
3
|
+
import { normalizeAccountId } from '@ceramicnetwork/common';
|
|
26
4
|
const namespace = 'eosio';
|
|
27
|
-
async function validateLink(proof) {
|
|
5
|
+
export async function validateLink(proof) {
|
|
28
6
|
const { message, signature, account } = proof;
|
|
29
|
-
const accountID =
|
|
7
|
+
const accountID = normalizeAccountId(account);
|
|
30
8
|
const { address, chainId } = accountID;
|
|
31
|
-
const success = await
|
|
9
|
+
const success = await SigningTools.verifySignature({
|
|
32
10
|
chainId: chainId.reference,
|
|
33
11
|
account: address,
|
|
34
12
|
signature,
|
|
@@ -36,10 +14,8 @@ async function validateLink(proof) {
|
|
|
36
14
|
});
|
|
37
15
|
return success ? proof : null;
|
|
38
16
|
}
|
|
39
|
-
|
|
40
|
-
const Handler = {
|
|
17
|
+
export const handler = {
|
|
41
18
|
namespace,
|
|
42
19
|
validateLink,
|
|
43
20
|
};
|
|
44
|
-
exports.default = Handler;
|
|
45
21
|
//# sourceMappingURL=eosio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eosio.js","sourceRoot":"","sources":["../../src/blockchains/eosio.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eosio.js","sourceRoot":"","sources":["../../src/blockchains/eosio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAE5D,OAAO,KAAK,OAAO,MAAM,0CAA0C,CAAA;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE3D,MAAM,SAAS,GAAG,OAAO,CAAA;AAEzB,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAwB;IACzD,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,KAAK,CAAA;IAC7C,MAAM,SAAS,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;IAC7C,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,SAAS,CAAA;IACtC,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,eAAe,CAAC;QACjD,OAAO,EAAE,OAAO,CAAC,SAAS;QAC1B,OAAO,EAAE,OAAO;QAChB,SAAS;QACT,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC;KAClD,CAAC,CAAA;IACF,OAAO,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AAC/B,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAsB;IACxC,SAAS;IACT,YAAY;CACb,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BlockchainHandler } from '../blockchain-handler';
|
|
2
|
-
declare const handler: BlockchainHandler;
|
|
3
|
-
export default handler;
|
|
1
|
+
import { BlockchainHandler } from '../blockchain-handler.js';
|
|
2
|
+
export declare const handler: BlockchainHandler;
|
|
4
3
|
//# sourceMappingURL=ethereum.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethereum.d.ts","sourceRoot":"","sources":["../../src/blockchains/ethereum.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ethereum.d.ts","sourceRoot":"","sources":["../../src/blockchains/ethereum.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AA0E5D,eAAO,MAAM,OAAO,EAAE,iBAGrB,CAAA"}
|
|
@@ -1,29 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
const wallet_1 = require("@ethersproject/wallet");
|
|
23
|
-
const contracts_1 = require("@ethersproject/contracts");
|
|
24
|
-
const providers = __importStar(require("@ethersproject/providers"));
|
|
25
|
-
const caip_1 = require("caip");
|
|
26
|
-
const uint8arrays = __importStar(require("uint8arrays"));
|
|
1
|
+
import { verifyMessage } from '@ethersproject/wallet';
|
|
2
|
+
import { Contract } from '@ethersproject/contracts';
|
|
3
|
+
import * as providers from '@ethersproject/providers';
|
|
4
|
+
import { AccountId } from 'caip';
|
|
5
|
+
import * as uint8arrays from 'uint8arrays';
|
|
6
|
+
import { normalizeAccountId } from '@ceramicnetwork/common';
|
|
27
7
|
const ADDRESS_TYPES = {
|
|
28
8
|
ethereumEOA: 'ethereum-eoa',
|
|
29
9
|
erc1271: 'erc1271',
|
|
@@ -45,7 +25,7 @@ function getEthersProvider(chainId) {
|
|
|
45
25
|
return network._defaultProvider(providers);
|
|
46
26
|
}
|
|
47
27
|
function toV2Proof(proof, address) {
|
|
48
|
-
proof.account = new
|
|
28
|
+
proof.account = new AccountId({
|
|
49
29
|
address: (proof.version === 1 ? proof.address : address) || '',
|
|
50
30
|
chainId: {
|
|
51
31
|
namespace,
|
|
@@ -58,10 +38,10 @@ function toV2Proof(proof, address) {
|
|
|
58
38
|
return proof;
|
|
59
39
|
}
|
|
60
40
|
async function validateEoaLink(proof) {
|
|
61
|
-
const recoveredAddr =
|
|
41
|
+
const recoveredAddr = verifyMessage(proof.message, proof.signature).toLowerCase();
|
|
62
42
|
if (proof.version !== 2)
|
|
63
43
|
proof = toV2Proof(proof, recoveredAddr);
|
|
64
|
-
const account = new
|
|
44
|
+
const account = new AccountId(proof.account);
|
|
65
45
|
if (account.address !== recoveredAddr) {
|
|
66
46
|
return null;
|
|
67
47
|
}
|
|
@@ -70,24 +50,27 @@ async function validateEoaLink(proof) {
|
|
|
70
50
|
async function validateErc1271Link(proof) {
|
|
71
51
|
if (proof.version === 1)
|
|
72
52
|
proof = toV2Proof(proof);
|
|
73
|
-
const account = new
|
|
53
|
+
const account = new AccountId(proof.account);
|
|
74
54
|
const provider = getEthersProvider(account.chainId.reference);
|
|
75
|
-
const contract = new
|
|
55
|
+
const contract = new Contract(account.address, ERC1271_ABI, provider);
|
|
76
56
|
const message = utf8toHex(proof.message);
|
|
77
57
|
const returnValue = await contract.isValidSignature(message, proof.signature);
|
|
78
58
|
return returnValue === MAGIC_ERC1271_VALUE ? proof : null;
|
|
79
59
|
}
|
|
80
60
|
async function validateLink(proof) {
|
|
81
|
-
|
|
82
|
-
|
|
61
|
+
const proofCopy = { ...proof };
|
|
62
|
+
if (proofCopy.account) {
|
|
63
|
+
proofCopy.account = normalizeAccountId(proofCopy.account).toString();
|
|
64
|
+
}
|
|
65
|
+
if (proofCopy.type === ADDRESS_TYPES.erc1271) {
|
|
66
|
+
return await validateErc1271Link(proofCopy);
|
|
83
67
|
}
|
|
84
68
|
else {
|
|
85
|
-
return await validateEoaLink(
|
|
69
|
+
return await validateEoaLink(proofCopy);
|
|
86
70
|
}
|
|
87
71
|
}
|
|
88
|
-
const handler = {
|
|
72
|
+
export const handler = {
|
|
89
73
|
namespace,
|
|
90
74
|
validateLink,
|
|
91
75
|
};
|
|
92
|
-
exports.default = handler;
|
|
93
76
|
//# sourceMappingURL=ethereum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../../src/blockchains/ethereum.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../../src/blockchains/ethereum.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BlockchainHandler } from '../blockchain-handler';
|
|
1
|
+
import { BlockchainHandler } from '../blockchain-handler.js';
|
|
2
2
|
import * as linking from '@ceramicnetwork/blockchain-utils-linking';
|
|
3
3
|
export declare function validateLink(proof: linking.LinkProof): Promise<linking.LinkProof | null>;
|
|
4
|
-
declare const
|
|
5
|
-
export default Handler;
|
|
4
|
+
export declare const handler: BlockchainHandler;
|
|
6
5
|
//# sourceMappingURL=filecoin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filecoin.d.ts","sourceRoot":"","sources":["../../src/blockchains/filecoin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"filecoin.d.ts","sourceRoot":"","sources":["../../src/blockchains/filecoin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,OAAO,MAAM,0CAA0C,CAAA;AAMnE,wBAAsB,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAW9F;AAED,eAAO,MAAM,OAAO,EAAE,iBAGrB,CAAA"}
|
|
@@ -1,31 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.validateLink = void 0;
|
|
23
|
-
const caip_1 = require("caip");
|
|
24
|
-
const linking = __importStar(require("@ceramicnetwork/blockchain-utils-linking"));
|
|
25
|
-
const signingTools = __importStar(require("@zondax/filecoin-signing-tools"));
|
|
1
|
+
import * as linking from '@ceramicnetwork/blockchain-utils-linking';
|
|
2
|
+
import * as signingTools from '@zondax/filecoin-signing-tools';
|
|
3
|
+
import { normalizeAccountId } from '@ceramicnetwork/common';
|
|
26
4
|
const namespace = 'fil';
|
|
27
|
-
async function validateLink(proof) {
|
|
28
|
-
const account =
|
|
5
|
+
export async function validateLink(proof) {
|
|
6
|
+
const account = normalizeAccountId(proof.account);
|
|
29
7
|
const payload = linking.filecoin.asTransaction(account.address, proof.message);
|
|
30
8
|
const transaction = signingTools.transactionSerialize(payload);
|
|
31
9
|
const recover = signingTools.verifySignature(proof.signature, transaction);
|
|
@@ -36,10 +14,8 @@ async function validateLink(proof) {
|
|
|
36
14
|
return null;
|
|
37
15
|
}
|
|
38
16
|
}
|
|
39
|
-
|
|
40
|
-
const Handler = {
|
|
17
|
+
export const handler = {
|
|
41
18
|
namespace,
|
|
42
19
|
validateLink,
|
|
43
20
|
};
|
|
44
|
-
exports.default = Handler;
|
|
45
21
|
//# sourceMappingURL=filecoin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filecoin.js","sourceRoot":"","sources":["../../src/blockchains/filecoin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filecoin.js","sourceRoot":"","sources":["../../src/blockchains/filecoin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,0CAA0C,CAAA;AACnE,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAA;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE3D,MAAM,SAAS,GAAG,KAAK,CAAA;AAEvB,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAwB;IAEzD,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;IAC9E,MAAM,WAAW,GAAG,YAAY,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;IAC9D,MAAM,OAAO,GAAG,YAAY,CAAC,eAAe,CAAC,KAAK,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;IAC1E,IAAI,OAAO,EAAE;QACX,OAAO,KAAK,CAAA;KACb;SAAM;QACL,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAsB;IACxC,SAAS;IACT,YAAY;CACb,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BlockchainHandler } from '../blockchain-handler';
|
|
1
|
+
import { BlockchainHandler } from '../blockchain-handler.js';
|
|
2
2
|
import { LinkProof } from '@ceramicnetwork/blockchain-utils-linking';
|
|
3
3
|
export declare function validateLink(proof: LinkProof): Promise<LinkProof | null>;
|
|
4
|
-
declare const
|
|
5
|
-
export default Handler;
|
|
4
|
+
export declare const handler: BlockchainHandler;
|
|
6
5
|
//# sourceMappingURL=near.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"near.d.ts","sourceRoot":"","sources":["../../src/blockchains/near.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"near.d.ts","sourceRoot":"","sources":["../../src/blockchains/near.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAA;AAuBpE,wBAAsB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAM9E;AAED,eAAO,MAAM,OAAO,EAAE,iBAGrB,CAAA"}
|
package/lib/blockchains/near.js
CHANGED
|
@@ -1,50 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.validateLink = void 0;
|
|
26
|
-
const uint8arrays = __importStar(require("uint8arrays"));
|
|
27
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
28
|
-
const tweetnacl_1 = __importDefault(require("tweetnacl"));
|
|
29
|
-
const caip_1 = require("caip");
|
|
1
|
+
import * as uint8arrays from 'uint8arrays';
|
|
2
|
+
import crypto from 'crypto';
|
|
3
|
+
import nacl from 'tweetnacl';
|
|
4
|
+
import { normalizeAccountId } from '@ceramicnetwork/common';
|
|
30
5
|
const verifySignature = async (pubKey, message, signature) => {
|
|
31
|
-
const hash =
|
|
6
|
+
const hash = crypto.createHash('sha256').update(message).digest();
|
|
32
7
|
const hashString = uint8arrays.toString(hash, 'base64');
|
|
33
|
-
const verified =
|
|
8
|
+
const verified = nacl.sign.detached.verify(uint8arrays.fromString(hashString, 'base64'), signature, pubKey);
|
|
34
9
|
return verified;
|
|
35
10
|
};
|
|
36
11
|
const namespace = 'near';
|
|
37
|
-
async function validateLink(proof) {
|
|
38
|
-
const pubKey = uint8arrays.fromString(
|
|
12
|
+
export async function validateLink(proof) {
|
|
13
|
+
const pubKey = uint8arrays.fromString(normalizeAccountId(proof.account).address, 'base58btc');
|
|
39
14
|
const msg = proof.message;
|
|
40
15
|
const sig = uint8arrays.fromString(proof.signature, 'base64');
|
|
41
16
|
const is_sig_valid = await verifySignature(pubKey, msg, sig);
|
|
42
17
|
return is_sig_valid ? proof : null;
|
|
43
18
|
}
|
|
44
|
-
|
|
45
|
-
const Handler = {
|
|
19
|
+
export const handler = {
|
|
46
20
|
namespace,
|
|
47
21
|
validateLink,
|
|
48
22
|
};
|
|
49
|
-
exports.default = Handler;
|
|
50
23
|
//# sourceMappingURL=near.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"near.js","sourceRoot":"","sources":["../../src/blockchains/near.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"near.js","sourceRoot":"","sources":["../../src/blockchains/near.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,WAAW,MAAM,aAAa,CAAA;AAC1C,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE3D,MAAM,eAAe,GAAG,KAAK,EAC3B,MAAkB,EAClB,OAAe,EACf,SAAqB,EACH,EAAE;IACpB,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAA;IACjE,MAAM,UAAU,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CACxC,WAAW,CAAC,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,EAC5C,SAAS,EACT,MAAM,CACP,CAAA;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,SAAS,GAAG,MAAM,CAAA;AAExB,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,KAAgB;IACjD,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;IAC7F,MAAM,GAAG,GAAG,KAAK,CAAC,OAAO,CAAA;IACzB,MAAM,GAAG,GAAG,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;IAC7D,MAAM,YAAY,GAAG,MAAM,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;IAC5D,OAAO,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AACpC,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAsB;IACxC,SAAS;IACT,YAAY;CACb,CAAA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { BlockchainHandler } from '../blockchain-handler';
|
|
2
|
-
declare const
|
|
3
|
-
export default Handler;
|
|
1
|
+
import { BlockchainHandler } from '../blockchain-handler.js';
|
|
2
|
+
export declare const handler: BlockchainHandler;
|
|
4
3
|
//# sourceMappingURL=polkadot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polkadot.d.ts","sourceRoot":"","sources":["../../src/blockchains/polkadot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"polkadot.d.ts","sourceRoot":"","sources":["../../src/blockchains/polkadot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAkB5D,eAAO,MAAM,OAAO,EAAE,iBAGrB,CAAA"}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const caip_1 = require("caip");
|
|
7
|
-
const util_crypto_1 = require("@polkadot/util-crypto");
|
|
8
|
-
const uint8arrays_1 = __importDefault(require("uint8arrays"));
|
|
1
|
+
import { signatureVerify } from '@polkadot/util-crypto';
|
|
2
|
+
import * as uint8arrays from 'uint8arrays';
|
|
3
|
+
import { normalizeAccountId } from '@ceramicnetwork/common';
|
|
9
4
|
const namespace = 'polkadot';
|
|
10
|
-
const stringHex = (str) => `0x${
|
|
5
|
+
const stringHex = (str) => `0x${uint8arrays.toString(uint8arrays.fromString(str), 'base16')}`;
|
|
11
6
|
async function validateLink(proof) {
|
|
12
|
-
const address =
|
|
7
|
+
const address = normalizeAccountId(proof.account).address;
|
|
13
8
|
const message = stringHex(proof.message);
|
|
14
|
-
const res = await
|
|
9
|
+
const res = await signatureVerify(message, proof.signature, address);
|
|
15
10
|
return res.isValid ? proof : null;
|
|
16
11
|
}
|
|
17
|
-
const
|
|
12
|
+
export const handler = {
|
|
18
13
|
namespace,
|
|
19
14
|
validateLink,
|
|
20
15
|
};
|
|
21
|
-
exports.default = Handler;
|
|
22
16
|
//# sourceMappingURL=polkadot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polkadot.js","sourceRoot":"","sources":["../../src/blockchains/polkadot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"polkadot.js","sourceRoot":"","sources":["../../src/blockchains/polkadot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,OAAO,KAAK,WAAW,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE3D,MAAM,SAAS,GAAG,UAAU,CAAA;AAE5B,MAAM,SAAS,GAAG,CAAC,GAAW,EAAU,EAAE,CACxC,KAAK,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAA;AAEpE,KAAK,UAAU,YAAY,CAAC,KAAgB;IAC1C,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,CAAA;IACzD,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IACxC,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IACpE,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAA;AACnC,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAsB;IACxC,SAAS;IACT,YAAY;CACb,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { BlockchainHandler } from '../blockchain-handler';
|
|
1
|
+
import { BlockchainHandler } from '../blockchain-handler.js';
|
|
2
2
|
import { LinkProof } from '@ceramicnetwork/blockchain-utils-linking';
|
|
3
3
|
export declare function validateLink(proof: LinkProof): Promise<LinkProof | null>;
|
|
4
|
-
declare const
|
|
5
|
-
export default Handler;
|
|
4
|
+
export declare const handler: BlockchainHandler;
|
|
6
5
|
//# sourceMappingURL=solana.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/blockchains/solana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../src/blockchains/solana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAA;AAgBpE,wBAAsB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAM9E;AAED,eAAO,MAAM,OAAO,EAAE,iBAGrB,CAAA"}
|
|
@@ -1,44 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.validateLink = void 0;
|
|
23
|
-
const caip_1 = require("caip");
|
|
24
|
-
const uint8arrays = __importStar(require("uint8arrays"));
|
|
25
|
-
const ed25519_1 = require("@stablelib/ed25519");
|
|
1
|
+
import { AccountId } from 'caip';
|
|
2
|
+
import * as uint8arrays from 'uint8arrays';
|
|
3
|
+
import { verify } from '@stablelib/ed25519';
|
|
26
4
|
const verifySignature = async (pubKey, message, signature) => {
|
|
27
|
-
const verified =
|
|
5
|
+
const verified = verify(pubKey, uint8arrays.fromString(message), signature);
|
|
28
6
|
return verified;
|
|
29
7
|
};
|
|
30
8
|
const namespace = 'solana';
|
|
31
|
-
async function validateLink(proof) {
|
|
32
|
-
const pubKey = uint8arrays.fromString(new
|
|
9
|
+
export async function validateLink(proof) {
|
|
10
|
+
const pubKey = uint8arrays.fromString(new AccountId(proof.account).address, 'base58btc');
|
|
33
11
|
const msg = proof.message;
|
|
34
12
|
const sig = uint8arrays.fromString(proof.signature, 'base64');
|
|
35
13
|
const is_sig_valid = await verifySignature(pubKey, msg, sig);
|
|
36
14
|
return is_sig_valid ? proof : null;
|
|
37
15
|
}
|
|
38
|
-
|
|
39
|
-
const Handler = {
|
|
16
|
+
export const handler = {
|
|
40
17
|
namespace,
|
|
41
18
|
validateLink,
|
|
42
19
|
};
|
|
43
|
-
exports.default = Handler;
|
|
44
20
|
//# sourceMappingURL=solana.js.map
|