@frequency-chain/ethereum-utils 1.17.0-rc6 → 1.17.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/browser/frequency-ethereum-utils.esm.min.js +135 -305
- package/browser/frequency-ethereum-utils.umd.min.js +109 -293
- package/cjs/signature.definitions.js +10 -3
- package/cjs/signature.js +13 -15
- package/esm/signature.definitions.js +9 -2
- package/esm/signature.js +14 -16
- package/index.d.ts +4 -3
- package/package.json +5 -5
- package/signature.d.ts +2 -2
- package/signature.definitions.d.ts +2 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SIWF_SIGNED_REQUEST_PAYLOAD_DEFINITION = exports.ITEMIZED_SIGNATURE_PAYLOAD_DEFINITION_V2 = exports.PAGINATED_UPSERT_SIGNATURE_PAYLOAD_DEFINITION_V2 = exports.PAGINATED_DELETE_SIGNATURE_PAYLOAD_DEFINITION_V2 = exports.PASSKEY_PUBLIC_KEY_DEFINITION = exports.CLAIM_HANDLE_PAYLOAD_DEFINITION = exports.AUTHORIZED_KEY_DATA_DEFINITION = exports.ADD_KEY_DATA_DEFINITION = exports.ADD_PROVIDER_DEFINITION = exports.
|
|
3
|
+
exports.SIWF_SIGNED_REQUEST_PAYLOAD_DEFINITION = exports.ITEMIZED_SIGNATURE_PAYLOAD_DEFINITION_V2 = exports.PAGINATED_UPSERT_SIGNATURE_PAYLOAD_DEFINITION_V2 = exports.PAGINATED_DELETE_SIGNATURE_PAYLOAD_DEFINITION_V2 = exports.PASSKEY_PUBLIC_KEY_DEFINITION = exports.CLAIM_HANDLE_PAYLOAD_DEFINITION = exports.AUTHORIZED_KEY_DATA_DEFINITION = exports.ADD_KEY_DATA_DEFINITION = exports.ADD_PROVIDER_DEFINITION = exports.EIP712_DOMAIN_TESTNET = exports.EIP712_DOMAIN_MAINNET = exports.EIP712_DOMAIN_DEFINITION = void 0;
|
|
4
4
|
exports.EIP712_DOMAIN_DEFINITION = {
|
|
5
5
|
EIP712Domain: [
|
|
6
6
|
{
|
|
@@ -21,8 +21,15 @@ exports.EIP712_DOMAIN_DEFINITION = {
|
|
|
21
21
|
},
|
|
22
22
|
],
|
|
23
23
|
};
|
|
24
|
-
// using
|
|
25
|
-
exports.
|
|
24
|
+
// using 2091 for mainnet
|
|
25
|
+
exports.EIP712_DOMAIN_MAINNET = {
|
|
26
|
+
name: 'Frequency',
|
|
27
|
+
version: '1',
|
|
28
|
+
chainId: '0x082B',
|
|
29
|
+
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
|
|
30
|
+
};
|
|
31
|
+
// using pallet_revive test chain ID for testnet/dev
|
|
32
|
+
exports.EIP712_DOMAIN_TESTNET = {
|
|
26
33
|
name: 'Frequency',
|
|
27
34
|
version: '1',
|
|
28
35
|
chainId: '0x190f1b44',
|
package/cjs/signature.js
CHANGED
|
@@ -36,16 +36,15 @@ const signature_definitions_js_1 = require("./signature.definitions.js");
|
|
|
36
36
|
* @param payload
|
|
37
37
|
* @param chain
|
|
38
38
|
*/
|
|
39
|
-
async function sign(secretKey, payload, chain
|
|
39
|
+
async function sign(secretKey, payload, chain) {
|
|
40
40
|
const signatureType = getSignatureType(payload.type);
|
|
41
41
|
const normalizedPayload = normalizePayload(payload);
|
|
42
42
|
const wallet = new ethers_1.ethers.Wallet(secretKey);
|
|
43
43
|
let signature;
|
|
44
44
|
switch (signatureType) {
|
|
45
45
|
case 'EIP-712':
|
|
46
|
-
// TODO: use correct chainID for different networks
|
|
47
46
|
// TODO: use correct contract address for different payloads
|
|
48
|
-
signature = await wallet.signTypedData(signature_definitions_js_1.
|
|
47
|
+
signature = await wallet.signTypedData(chain === 'Mainnet-Frequency' ? signature_definitions_js_1.EIP712_DOMAIN_MAINNET : signature_definitions_js_1.EIP712_DOMAIN_TESTNET, getTypesFor(payload.type), normalizedPayload);
|
|
49
48
|
break;
|
|
50
49
|
case 'EIP-191':
|
|
51
50
|
signature = await wallet.signMessage(payload.message);
|
|
@@ -62,15 +61,14 @@ async function sign(secretKey, payload, chain = 'Mainnet-Frequency') {
|
|
|
62
61
|
* @param payload
|
|
63
62
|
* @param chain
|
|
64
63
|
*/
|
|
65
|
-
function verifySignature(ethereumAddress, signature, payload, chain
|
|
64
|
+
function verifySignature(ethereumAddress, signature, payload, chain) {
|
|
66
65
|
const signatureType = getSignatureType(payload.type);
|
|
67
66
|
const normalizedPayload = normalizePayload(payload);
|
|
68
67
|
let recoveredAddress;
|
|
69
68
|
switch (signatureType) {
|
|
70
69
|
case 'EIP-712':
|
|
71
|
-
// TODO: use correct chainID for different networks
|
|
72
70
|
// TODO: use correct contract address for different payloads
|
|
73
|
-
recoveredAddress = ethers_1.ethers.verifyTypedData(signature_definitions_js_1.
|
|
71
|
+
recoveredAddress = ethers_1.ethers.verifyTypedData(chain === 'Mainnet-Frequency' ? signature_definitions_js_1.EIP712_DOMAIN_MAINNET : signature_definitions_js_1.EIP712_DOMAIN_TESTNET, getTypesFor(payload.type), normalizedPayload, signature);
|
|
74
72
|
break;
|
|
75
73
|
case 'EIP-191':
|
|
76
74
|
recoveredAddress = ethers_1.ethers.verifyMessage(payload.message, signature);
|
|
@@ -343,7 +341,7 @@ function createSiwfLoginRequestPayload(message) {
|
|
|
343
341
|
* @param expirationBlock Block number after which this payload is invalid
|
|
344
342
|
* @param domain
|
|
345
343
|
*/
|
|
346
|
-
function getEip712BrowserRequestAddKeyData(msaId, newPublicKey, expirationBlock, domain = signature_definitions_js_1.
|
|
344
|
+
function getEip712BrowserRequestAddKeyData(msaId, newPublicKey, expirationBlock, domain = signature_definitions_js_1.EIP712_DOMAIN_MAINNET) {
|
|
347
345
|
const message = createAddKeyData(msaId, newPublicKey, expirationBlock);
|
|
348
346
|
const normalized = normalizePayload(message);
|
|
349
347
|
return createEip712Payload(signature_definitions_js_1.ADD_KEY_DATA_DEFINITION, message.type, domain, normalized);
|
|
@@ -356,7 +354,7 @@ function getEip712BrowserRequestAddKeyData(msaId, newPublicKey, expirationBlock,
|
|
|
356
354
|
* @param expirationBlock Block number after which this payload is invalid
|
|
357
355
|
* @param domain
|
|
358
356
|
*/
|
|
359
|
-
function getEip712BrowserRequestAuthorizedKeyData(msaId, authorizedPublicKey, expirationBlock, domain = signature_definitions_js_1.
|
|
357
|
+
function getEip712BrowserRequestAuthorizedKeyData(msaId, authorizedPublicKey, expirationBlock, domain = signature_definitions_js_1.EIP712_DOMAIN_MAINNET) {
|
|
360
358
|
const message = createAuthorizedKeyData(msaId, authorizedPublicKey, expirationBlock);
|
|
361
359
|
const normalized = normalizePayload(message);
|
|
362
360
|
return createEip712Payload(signature_definitions_js_1.AUTHORIZED_KEY_DATA_DEFINITION, message.type, domain, normalized);
|
|
@@ -369,7 +367,7 @@ function getEip712BrowserRequestAuthorizedKeyData(msaId, authorizedPublicKey, ex
|
|
|
369
367
|
* @param expirationBlock Block number after which this payload is invalid
|
|
370
368
|
* @param domain
|
|
371
369
|
*/
|
|
372
|
-
function getEip712BrowserRequestAddProvider(authorizedMsaId, schemaIds, expirationBlock, domain = signature_definitions_js_1.
|
|
370
|
+
function getEip712BrowserRequestAddProvider(authorizedMsaId, schemaIds, expirationBlock, domain = signature_definitions_js_1.EIP712_DOMAIN_MAINNET) {
|
|
373
371
|
const message = createAddProvider(authorizedMsaId, schemaIds, expirationBlock);
|
|
374
372
|
const normalized = normalizePayload(message);
|
|
375
373
|
return createEip712Payload(signature_definitions_js_1.ADD_PROVIDER_DEFINITION, message.type, domain, normalized);
|
|
@@ -384,7 +382,7 @@ function getEip712BrowserRequestAddProvider(authorizedMsaId, schemaIds, expirati
|
|
|
384
382
|
* @param payload HexString or Uint8Array data to upsert
|
|
385
383
|
* @param domain
|
|
386
384
|
*/
|
|
387
|
-
function getEip712BrowserRequestPaginatedUpsertSignaturePayloadV2(schemaId, pageId, targetHash, expiration, payload, domain = signature_definitions_js_1.
|
|
385
|
+
function getEip712BrowserRequestPaginatedUpsertSignaturePayloadV2(schemaId, pageId, targetHash, expiration, payload, domain = signature_definitions_js_1.EIP712_DOMAIN_MAINNET) {
|
|
388
386
|
const message = createPaginatedUpsertSignaturePayloadV2(schemaId, pageId, targetHash, expiration, payload);
|
|
389
387
|
const normalized = normalizePayload(message);
|
|
390
388
|
return createEip712Payload(signature_definitions_js_1.PAGINATED_UPSERT_SIGNATURE_PAYLOAD_DEFINITION_V2, message.type, domain, normalized);
|
|
@@ -398,7 +396,7 @@ function getEip712BrowserRequestPaginatedUpsertSignaturePayloadV2(schemaId, page
|
|
|
398
396
|
* @param expiration uint32 expiration block
|
|
399
397
|
* @param domain
|
|
400
398
|
*/
|
|
401
|
-
function getEip712BrowserRequestPaginatedDeleteSignaturePayloadV2(schemaId, pageId, targetHash, expiration, domain = signature_definitions_js_1.
|
|
399
|
+
function getEip712BrowserRequestPaginatedDeleteSignaturePayloadV2(schemaId, pageId, targetHash, expiration, domain = signature_definitions_js_1.EIP712_DOMAIN_MAINNET) {
|
|
402
400
|
const message = createPaginatedDeleteSignaturePayloadV2(schemaId, pageId, targetHash, expiration);
|
|
403
401
|
const normalized = normalizePayload(message);
|
|
404
402
|
return createEip712Payload(signature_definitions_js_1.PAGINATED_DELETE_SIGNATURE_PAYLOAD_DEFINITION_V2, message.type, domain, normalized);
|
|
@@ -412,7 +410,7 @@ function getEip712BrowserRequestPaginatedDeleteSignaturePayloadV2(schemaId, page
|
|
|
412
410
|
* @param actions Array of Add/Delete itemized actions
|
|
413
411
|
* @param domain
|
|
414
412
|
*/
|
|
415
|
-
function getEip712BrowserRequestItemizedSignaturePayloadV2(schemaId, targetHash, expiration, actions, domain = signature_definitions_js_1.
|
|
413
|
+
function getEip712BrowserRequestItemizedSignaturePayloadV2(schemaId, targetHash, expiration, actions, domain = signature_definitions_js_1.EIP712_DOMAIN_MAINNET) {
|
|
416
414
|
const message = createItemizedSignaturePayloadV2(schemaId, targetHash, expiration, actions);
|
|
417
415
|
const normalized = normalizePayload(message);
|
|
418
416
|
return createEip712Payload(signature_definitions_js_1.ITEMIZED_SIGNATURE_PAYLOAD_DEFINITION_V2, message.type, domain, normalized);
|
|
@@ -424,7 +422,7 @@ function getEip712BrowserRequestItemizedSignaturePayloadV2(schemaId, targetHash,
|
|
|
424
422
|
* @param expirationBlock Block number after which this payload is invalid
|
|
425
423
|
* @param domain
|
|
426
424
|
*/
|
|
427
|
-
function getEip712BrowserRequestClaimHandlePayload(handle, expirationBlock, domain = signature_definitions_js_1.
|
|
425
|
+
function getEip712BrowserRequestClaimHandlePayload(handle, expirationBlock, domain = signature_definitions_js_1.EIP712_DOMAIN_MAINNET) {
|
|
428
426
|
const message = createClaimHandlePayload(handle, expirationBlock);
|
|
429
427
|
const normalized = normalizePayload(message);
|
|
430
428
|
return createEip712Payload(signature_definitions_js_1.CLAIM_HANDLE_PAYLOAD_DEFINITION, message.type, domain, normalized);
|
|
@@ -435,7 +433,7 @@ function getEip712BrowserRequestClaimHandlePayload(handle, expirationBlock, doma
|
|
|
435
433
|
* @param publicKey The passkey’s public key (hex string or raw bytes)
|
|
436
434
|
* @param domain
|
|
437
435
|
*/
|
|
438
|
-
function getEip712BrowserRequestPasskeyPublicKey(publicKey, domain = signature_definitions_js_1.
|
|
436
|
+
function getEip712BrowserRequestPasskeyPublicKey(publicKey, domain = signature_definitions_js_1.EIP712_DOMAIN_MAINNET) {
|
|
439
437
|
const message = createPasskeyPublicKey(publicKey);
|
|
440
438
|
const normalized = normalizePayload(message);
|
|
441
439
|
return createEip712Payload(signature_definitions_js_1.PASSKEY_PUBLIC_KEY_DEFINITION, message.type, domain, normalized);
|
|
@@ -448,7 +446,7 @@ function getEip712BrowserRequestPasskeyPublicKey(publicKey, domain = signature_d
|
|
|
448
446
|
* @param userIdentifierAdminUrl Only used for custom integration situations.
|
|
449
447
|
* @param domain
|
|
450
448
|
*/
|
|
451
|
-
function getEip712BrowserRequestSiwfSignedRequestPayload(callback, permissions, userIdentifierAdminUrl, domain = signature_definitions_js_1.
|
|
449
|
+
function getEip712BrowserRequestSiwfSignedRequestPayload(callback, permissions, userIdentifierAdminUrl, domain = signature_definitions_js_1.EIP712_DOMAIN_MAINNET) {
|
|
452
450
|
const message = createSiwfSignedRequestPayload(callback, permissions, userIdentifierAdminUrl);
|
|
453
451
|
const normalized = normalizePayload(message);
|
|
454
452
|
return createEip712Payload(signature_definitions_js_1.SIWF_SIGNED_REQUEST_PAYLOAD_DEFINITION, message.type, domain, normalized);
|
|
@@ -18,8 +18,15 @@ export const EIP712_DOMAIN_DEFINITION = {
|
|
|
18
18
|
},
|
|
19
19
|
],
|
|
20
20
|
};
|
|
21
|
-
// using
|
|
22
|
-
export const
|
|
21
|
+
// using 2091 for mainnet
|
|
22
|
+
export const EIP712_DOMAIN_MAINNET = {
|
|
23
|
+
name: 'Frequency',
|
|
24
|
+
version: '1',
|
|
25
|
+
chainId: '0x082B',
|
|
26
|
+
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
|
|
27
|
+
};
|
|
28
|
+
// using pallet_revive test chain ID for testnet/dev
|
|
29
|
+
export const EIP712_DOMAIN_TESTNET = {
|
|
23
30
|
name: 'Frequency',
|
|
24
31
|
version: '1',
|
|
25
32
|
chainId: '0x190f1b44',
|
package/esm/signature.js
CHANGED
|
@@ -2,23 +2,22 @@ import { assert, isHexString, isValidUint16, isValidUint32, isValidUint64String
|
|
|
2
2
|
import { reverseUnifiedAddressToEthereumAddress } from './address.js';
|
|
3
3
|
import { ethers } from 'ethers';
|
|
4
4
|
import { u8aToHex } from '@polkadot/util';
|
|
5
|
-
import { ADD_KEY_DATA_DEFINITION, ADD_PROVIDER_DEFINITION, AUTHORIZED_KEY_DATA_DEFINITION, CLAIM_HANDLE_PAYLOAD_DEFINITION,
|
|
5
|
+
import { ADD_KEY_DATA_DEFINITION, ADD_PROVIDER_DEFINITION, AUTHORIZED_KEY_DATA_DEFINITION, CLAIM_HANDLE_PAYLOAD_DEFINITION, EIP712_DOMAIN_MAINNET, EIP712_DOMAIN_DEFINITION, ITEMIZED_SIGNATURE_PAYLOAD_DEFINITION_V2, PAGINATED_DELETE_SIGNATURE_PAYLOAD_DEFINITION_V2, PAGINATED_UPSERT_SIGNATURE_PAYLOAD_DEFINITION_V2, PASSKEY_PUBLIC_KEY_DEFINITION, SIWF_SIGNED_REQUEST_PAYLOAD_DEFINITION, EIP712_DOMAIN_TESTNET, } from './signature.definitions.js';
|
|
6
6
|
/**
|
|
7
7
|
* Signing EIP-712 or ERC-191 compatible signature based on payload
|
|
8
8
|
* @param secretKey
|
|
9
9
|
* @param payload
|
|
10
10
|
* @param chain
|
|
11
11
|
*/
|
|
12
|
-
export async function sign(secretKey, payload, chain
|
|
12
|
+
export async function sign(secretKey, payload, chain) {
|
|
13
13
|
const signatureType = getSignatureType(payload.type);
|
|
14
14
|
const normalizedPayload = normalizePayload(payload);
|
|
15
15
|
const wallet = new ethers.Wallet(secretKey);
|
|
16
16
|
let signature;
|
|
17
17
|
switch (signatureType) {
|
|
18
18
|
case 'EIP-712':
|
|
19
|
-
// TODO: use correct chainID for different networks
|
|
20
19
|
// TODO: use correct contract address for different payloads
|
|
21
|
-
signature = await wallet.signTypedData(
|
|
20
|
+
signature = await wallet.signTypedData(chain === 'Mainnet-Frequency' ? EIP712_DOMAIN_MAINNET : EIP712_DOMAIN_TESTNET, getTypesFor(payload.type), normalizedPayload);
|
|
22
21
|
break;
|
|
23
22
|
case 'EIP-191':
|
|
24
23
|
signature = await wallet.signMessage(payload.message);
|
|
@@ -35,15 +34,14 @@ export async function sign(secretKey, payload, chain = 'Mainnet-Frequency') {
|
|
|
35
34
|
* @param payload
|
|
36
35
|
* @param chain
|
|
37
36
|
*/
|
|
38
|
-
export function verifySignature(ethereumAddress, signature, payload, chain
|
|
37
|
+
export function verifySignature(ethereumAddress, signature, payload, chain) {
|
|
39
38
|
const signatureType = getSignatureType(payload.type);
|
|
40
39
|
const normalizedPayload = normalizePayload(payload);
|
|
41
40
|
let recoveredAddress;
|
|
42
41
|
switch (signatureType) {
|
|
43
42
|
case 'EIP-712':
|
|
44
|
-
// TODO: use correct chainID for different networks
|
|
45
43
|
// TODO: use correct contract address for different payloads
|
|
46
|
-
recoveredAddress = ethers.verifyTypedData(
|
|
44
|
+
recoveredAddress = ethers.verifyTypedData(chain === 'Mainnet-Frequency' ? EIP712_DOMAIN_MAINNET : EIP712_DOMAIN_TESTNET, getTypesFor(payload.type), normalizedPayload, signature);
|
|
47
45
|
break;
|
|
48
46
|
case 'EIP-191':
|
|
49
47
|
recoveredAddress = ethers.verifyMessage(payload.message, signature);
|
|
@@ -316,7 +314,7 @@ export function createSiwfLoginRequestPayload(message) {
|
|
|
316
314
|
* @param expirationBlock Block number after which this payload is invalid
|
|
317
315
|
* @param domain
|
|
318
316
|
*/
|
|
319
|
-
export function getEip712BrowserRequestAddKeyData(msaId, newPublicKey, expirationBlock, domain =
|
|
317
|
+
export function getEip712BrowserRequestAddKeyData(msaId, newPublicKey, expirationBlock, domain = EIP712_DOMAIN_MAINNET) {
|
|
320
318
|
const message = createAddKeyData(msaId, newPublicKey, expirationBlock);
|
|
321
319
|
const normalized = normalizePayload(message);
|
|
322
320
|
return createEip712Payload(ADD_KEY_DATA_DEFINITION, message.type, domain, normalized);
|
|
@@ -329,7 +327,7 @@ export function getEip712BrowserRequestAddKeyData(msaId, newPublicKey, expiratio
|
|
|
329
327
|
* @param expirationBlock Block number after which this payload is invalid
|
|
330
328
|
* @param domain
|
|
331
329
|
*/
|
|
332
|
-
export function getEip712BrowserRequestAuthorizedKeyData(msaId, authorizedPublicKey, expirationBlock, domain =
|
|
330
|
+
export function getEip712BrowserRequestAuthorizedKeyData(msaId, authorizedPublicKey, expirationBlock, domain = EIP712_DOMAIN_MAINNET) {
|
|
333
331
|
const message = createAuthorizedKeyData(msaId, authorizedPublicKey, expirationBlock);
|
|
334
332
|
const normalized = normalizePayload(message);
|
|
335
333
|
return createEip712Payload(AUTHORIZED_KEY_DATA_DEFINITION, message.type, domain, normalized);
|
|
@@ -342,7 +340,7 @@ export function getEip712BrowserRequestAuthorizedKeyData(msaId, authorizedPublic
|
|
|
342
340
|
* @param expirationBlock Block number after which this payload is invalid
|
|
343
341
|
* @param domain
|
|
344
342
|
*/
|
|
345
|
-
export function getEip712BrowserRequestAddProvider(authorizedMsaId, schemaIds, expirationBlock, domain =
|
|
343
|
+
export function getEip712BrowserRequestAddProvider(authorizedMsaId, schemaIds, expirationBlock, domain = EIP712_DOMAIN_MAINNET) {
|
|
346
344
|
const message = createAddProvider(authorizedMsaId, schemaIds, expirationBlock);
|
|
347
345
|
const normalized = normalizePayload(message);
|
|
348
346
|
return createEip712Payload(ADD_PROVIDER_DEFINITION, message.type, domain, normalized);
|
|
@@ -357,7 +355,7 @@ export function getEip712BrowserRequestAddProvider(authorizedMsaId, schemaIds, e
|
|
|
357
355
|
* @param payload HexString or Uint8Array data to upsert
|
|
358
356
|
* @param domain
|
|
359
357
|
*/
|
|
360
|
-
export function getEip712BrowserRequestPaginatedUpsertSignaturePayloadV2(schemaId, pageId, targetHash, expiration, payload, domain =
|
|
358
|
+
export function getEip712BrowserRequestPaginatedUpsertSignaturePayloadV2(schemaId, pageId, targetHash, expiration, payload, domain = EIP712_DOMAIN_MAINNET) {
|
|
361
359
|
const message = createPaginatedUpsertSignaturePayloadV2(schemaId, pageId, targetHash, expiration, payload);
|
|
362
360
|
const normalized = normalizePayload(message);
|
|
363
361
|
return createEip712Payload(PAGINATED_UPSERT_SIGNATURE_PAYLOAD_DEFINITION_V2, message.type, domain, normalized);
|
|
@@ -371,7 +369,7 @@ export function getEip712BrowserRequestPaginatedUpsertSignaturePayloadV2(schemaI
|
|
|
371
369
|
* @param expiration uint32 expiration block
|
|
372
370
|
* @param domain
|
|
373
371
|
*/
|
|
374
|
-
export function getEip712BrowserRequestPaginatedDeleteSignaturePayloadV2(schemaId, pageId, targetHash, expiration, domain =
|
|
372
|
+
export function getEip712BrowserRequestPaginatedDeleteSignaturePayloadV2(schemaId, pageId, targetHash, expiration, domain = EIP712_DOMAIN_MAINNET) {
|
|
375
373
|
const message = createPaginatedDeleteSignaturePayloadV2(schemaId, pageId, targetHash, expiration);
|
|
376
374
|
const normalized = normalizePayload(message);
|
|
377
375
|
return createEip712Payload(PAGINATED_DELETE_SIGNATURE_PAYLOAD_DEFINITION_V2, message.type, domain, normalized);
|
|
@@ -385,7 +383,7 @@ export function getEip712BrowserRequestPaginatedDeleteSignaturePayloadV2(schemaI
|
|
|
385
383
|
* @param actions Array of Add/Delete itemized actions
|
|
386
384
|
* @param domain
|
|
387
385
|
*/
|
|
388
|
-
export function getEip712BrowserRequestItemizedSignaturePayloadV2(schemaId, targetHash, expiration, actions, domain =
|
|
386
|
+
export function getEip712BrowserRequestItemizedSignaturePayloadV2(schemaId, targetHash, expiration, actions, domain = EIP712_DOMAIN_MAINNET) {
|
|
389
387
|
const message = createItemizedSignaturePayloadV2(schemaId, targetHash, expiration, actions);
|
|
390
388
|
const normalized = normalizePayload(message);
|
|
391
389
|
return createEip712Payload(ITEMIZED_SIGNATURE_PAYLOAD_DEFINITION_V2, message.type, domain, normalized);
|
|
@@ -397,7 +395,7 @@ export function getEip712BrowserRequestItemizedSignaturePayloadV2(schemaId, targ
|
|
|
397
395
|
* @param expirationBlock Block number after which this payload is invalid
|
|
398
396
|
* @param domain
|
|
399
397
|
*/
|
|
400
|
-
export function getEip712BrowserRequestClaimHandlePayload(handle, expirationBlock, domain =
|
|
398
|
+
export function getEip712BrowserRequestClaimHandlePayload(handle, expirationBlock, domain = EIP712_DOMAIN_MAINNET) {
|
|
401
399
|
const message = createClaimHandlePayload(handle, expirationBlock);
|
|
402
400
|
const normalized = normalizePayload(message);
|
|
403
401
|
return createEip712Payload(CLAIM_HANDLE_PAYLOAD_DEFINITION, message.type, domain, normalized);
|
|
@@ -408,7 +406,7 @@ export function getEip712BrowserRequestClaimHandlePayload(handle, expirationBloc
|
|
|
408
406
|
* @param publicKey The passkey’s public key (hex string or raw bytes)
|
|
409
407
|
* @param domain
|
|
410
408
|
*/
|
|
411
|
-
export function getEip712BrowserRequestPasskeyPublicKey(publicKey, domain =
|
|
409
|
+
export function getEip712BrowserRequestPasskeyPublicKey(publicKey, domain = EIP712_DOMAIN_MAINNET) {
|
|
412
410
|
const message = createPasskeyPublicKey(publicKey);
|
|
413
411
|
const normalized = normalizePayload(message);
|
|
414
412
|
return createEip712Payload(PASSKEY_PUBLIC_KEY_DEFINITION, message.type, domain, normalized);
|
|
@@ -421,7 +419,7 @@ export function getEip712BrowserRequestPasskeyPublicKey(publicKey, domain = EIP7
|
|
|
421
419
|
* @param userIdentifierAdminUrl Only used for custom integration situations.
|
|
422
420
|
* @param domain
|
|
423
421
|
*/
|
|
424
|
-
export function getEip712BrowserRequestSiwfSignedRequestPayload(callback, permissions, userIdentifierAdminUrl, domain =
|
|
422
|
+
export function getEip712BrowserRequestSiwfSignedRequestPayload(callback, permissions, userIdentifierAdminUrl, domain = EIP712_DOMAIN_MAINNET) {
|
|
425
423
|
const message = createSiwfSignedRequestPayload(callback, permissions, userIdentifierAdminUrl);
|
|
426
424
|
const normalized = normalizePayload(message);
|
|
427
425
|
return createEip712Payload(SIWF_SIGNED_REQUEST_PAYLOAD_DEFINITION, message.type, domain, normalized);
|
package/index.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export * from './signature.js';
|
|
|
4
4
|
export * from './signature.definitions.js';
|
|
5
5
|
export * from './address.js';
|
|
6
6
|
declare const _default: {
|
|
7
|
-
sign(secretKey: payloads.HexString, payload: payloads.SupportedPayload, chain
|
|
8
|
-
verifySignature(ethereumAddress: payloads.HexString, signature: payloads.HexString, payload: payloads.SupportedPayload, chain
|
|
7
|
+
sign(secretKey: payloads.HexString, payload: payloads.SupportedPayload, chain: payloads.ChainType): Promise<payloads.EcdsaSignature>;
|
|
8
|
+
verifySignature(ethereumAddress: payloads.HexString, signature: payloads.HexString, payload: payloads.SupportedPayload, chain: payloads.ChainType): boolean;
|
|
9
9
|
createAddKeyData(msaId: string | bigint, newPublicKey: payloads.HexString | Uint8Array, expirationBlock: number): payloads.AddKeyData;
|
|
10
10
|
createAuthorizedKeyData(msaId: string | bigint, newPublicKey: payloads.HexString | Uint8Array, expirationBlock: number): payloads.AuthorizedKeyData;
|
|
11
11
|
createAddProvider(authorizedMsaId: string | bigint, schemaIds: number[], expirationBlock: number): payloads.AddProvider;
|
|
@@ -35,7 +35,8 @@ declare const _default: {
|
|
|
35
35
|
type: string;
|
|
36
36
|
}[];
|
|
37
37
|
};
|
|
38
|
-
|
|
38
|
+
EIP712_DOMAIN_MAINNET: payloads.EipDomainPayload;
|
|
39
|
+
EIP712_DOMAIN_TESTNET: payloads.EipDomainPayload;
|
|
39
40
|
ADD_PROVIDER_DEFINITION: {
|
|
40
41
|
AddProvider: {
|
|
41
42
|
name: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frequency-chain/ethereum-utils",
|
|
3
|
-
"version": "1.17.0
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"bugs": {
|
|
5
5
|
"url": "https://github.com/frequency-chain/frequency/issues"
|
|
6
6
|
},
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"author": "frequency-chain",
|
|
16
16
|
"license": "Apache-2.0",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@polkadot/api": "^16.
|
|
19
|
-
"@polkadot/util": "13.5.
|
|
20
|
-
"ethers": "^6.
|
|
18
|
+
"@polkadot/api": "^16.3.1",
|
|
19
|
+
"@polkadot/util": "13.5.3",
|
|
20
|
+
"ethers": "^6.15.0"
|
|
21
21
|
},
|
|
22
22
|
"optionalDependencies": {
|
|
23
|
-
"@rollup/rollup-linux-x64-gnu": "^4.
|
|
23
|
+
"@rollup/rollup-linux-x64-gnu": "^4.44.1"
|
|
24
24
|
},
|
|
25
25
|
"module": "./esm/index.js",
|
|
26
26
|
"types": "index.d.ts",
|
package/signature.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { Signer } from '@polkadot/types/types';
|
|
|
7
7
|
* @param payload
|
|
8
8
|
* @param chain
|
|
9
9
|
*/
|
|
10
|
-
export declare function sign(secretKey: HexString, payload: SupportedPayload, chain
|
|
10
|
+
export declare function sign(secretKey: HexString, payload: SupportedPayload, chain: ChainType): Promise<EcdsaSignature>;
|
|
11
11
|
/**
|
|
12
12
|
* Verify EIP-712 and ERC-191 signatures based on payload
|
|
13
13
|
* @param ethereumAddress
|
|
@@ -15,7 +15,7 @@ export declare function sign(secretKey: HexString, payload: SupportedPayload, ch
|
|
|
15
15
|
* @param payload
|
|
16
16
|
* @param chain
|
|
17
17
|
*/
|
|
18
|
-
export declare function verifySignature(ethereumAddress: HexString, signature: HexString, payload: SupportedPayload, chain
|
|
18
|
+
export declare function verifySignature(ethereumAddress: HexString, signature: HexString, payload: SupportedPayload, chain: ChainType): boolean;
|
|
19
19
|
/**
|
|
20
20
|
* Build an AddKeyData payload for signature.
|
|
21
21
|
*
|
|
@@ -5,7 +5,8 @@ export declare const EIP712_DOMAIN_DEFINITION: {
|
|
|
5
5
|
type: string;
|
|
6
6
|
}[];
|
|
7
7
|
};
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const EIP712_DOMAIN_MAINNET: EipDomainPayload;
|
|
9
|
+
export declare const EIP712_DOMAIN_TESTNET: EipDomainPayload;
|
|
9
10
|
export declare const ADD_PROVIDER_DEFINITION: {
|
|
10
11
|
AddProvider: {
|
|
11
12
|
name: string;
|