@tezos-x/octez.connect-dapp 5.0.6-rc.0 → 5.0.6-rc.2
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.
|
@@ -1551,28 +1551,29 @@ class DAppClient extends octez_connect_core_1.Client {
|
|
|
1551
1551
|
if (typeof payload !== 'string') {
|
|
1552
1552
|
throw new Error('Payload must be a string');
|
|
1553
1553
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
return octez_connect_types_1.SigningType.MICHELINE;
|
|
1566
|
-
case octez_connect_types_1.SigningType.RAW:
|
|
1567
|
-
default:
|
|
1568
|
-
return octez_connect_types_1.SigningType.RAW;
|
|
1554
|
+
// An omitted signing type keeps its historical default (RAW); a value that is
|
|
1555
|
+
// present but unknown is an error rather than a silent RAW.
|
|
1556
|
+
const signingType = input.signingType === undefined ? octez_connect_types_1.SigningType.RAW : input.signingType;
|
|
1557
|
+
try {
|
|
1558
|
+
(0, octez_connect_utils_1.assertSignPayloadConsistent)(signingType, payload, {
|
|
1559
|
+
onWarning: (warning) => logger.warn('requestSignPayload', warning)
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
catch (error) {
|
|
1563
|
+
if (error instanceof octez_connect_utils_1.SignPayloadConsistencyError) {
|
|
1564
|
+
throw new Error(error.message);
|
|
1569
1565
|
}
|
|
1570
|
-
|
|
1566
|
+
throw error;
|
|
1567
|
+
}
|
|
1571
1568
|
this.analytics.track('event', 'DAppClient', 'Signature requested');
|
|
1569
|
+
// The check accepts a "0x" prefix on hex payloads. Wallets expect bare hex, so it is
|
|
1570
|
+
// removed for operation and micheline (already verified to be hex). RAW is text or
|
|
1571
|
+
// opaque data and is forwarded unchanged.
|
|
1572
|
+
const forwardedPayload = signingType !== octez_connect_types_1.SigningType.RAW && /^0x/i.test(payload) ? payload.slice(2) : payload;
|
|
1572
1573
|
const request = {
|
|
1573
1574
|
type: octez_connect_types_1.BeaconMessageType.SignPayloadRequest,
|
|
1574
1575
|
signingType,
|
|
1575
|
-
payload,
|
|
1576
|
+
payload: forwardedPayload,
|
|
1576
1577
|
sourceAddress: input.sourceAddress || activeAccount.address
|
|
1577
1578
|
};
|
|
1578
1579
|
this.sendMetrics('performance-metrics/save', yield this.buildPayload('message', 'start'));
|
|
@@ -2505,8 +2506,9 @@ class DAppClient extends octez_connect_core_1.Client {
|
|
|
2505
2506
|
timestamp,
|
|
2506
2507
|
payload
|
|
2507
2508
|
].join(' ');
|
|
2508
|
-
|
|
2509
|
-
|
|
2509
|
+
// 05 01 + 4-byte BYTE length + utf8 hex. The previous hand-built form used
|
|
2510
|
+
// the hex-character count (twice the byte count) as the length.
|
|
2511
|
+
const payloadBytes = (0, octez_connect_utils_1.encodeTezosSignedMessage)(constructedString);
|
|
2510
2512
|
const signature = yield (0, octez_connect_utils_1.signMessage)(payloadBytes, {
|
|
2511
2513
|
secretKey: Buffer.from(keypair.secretKey)
|
|
2512
2514
|
});
|