@parity/product-sdk-host 0.19.1 → 0.21.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/dist/index.d.ts +19 -0
- package/dist/index.js +27 -3
- package/dist/index.js.map +1 -1
- package/dist/testing.js +4 -0
- package/dist/testing.js.map +1 -1
- package/package.json +4 -4
- package/src/accounts.ts +108 -3
- package/src/testing.ts +4 -0
- package/src/truapi.ts +34 -0
package/dist/index.d.ts
CHANGED
|
@@ -409,6 +409,14 @@ interface ResultAsync<T, E> {
|
|
|
409
409
|
* bridge is involved, so opaque signed extensions (e.g. Paseo Next's `AsPgas`)
|
|
410
410
|
* survive end-to-end.
|
|
411
411
|
*
|
|
412
|
+
* Every one of those raw-signing paths `<Bytes>`-wraps the payload before the
|
|
413
|
+
* key touches it. A runtime that verifies a bare-byte ownership proof — today
|
|
414
|
+
* People chain's `Resources.register_person` — therefore rejects them, so the
|
|
415
|
+
* provider also exposes the deprecated `signRawUnwatermarkedDeprecated` pair,
|
|
416
|
+
* which signs the bytes exactly as given. Reach for those two only when a
|
|
417
|
+
* runtime check leaves no alternative; they are temporary on the host side too
|
|
418
|
+
* (paritytech/host-rust-core#612).
|
|
419
|
+
*
|
|
412
420
|
* @module
|
|
413
421
|
*/
|
|
414
422
|
|
|
@@ -607,6 +615,17 @@ interface AccountsProvider {
|
|
|
607
615
|
publicKey: Uint8Array;
|
|
608
616
|
name?: string;
|
|
609
617
|
}): PolkadotSigner;
|
|
618
|
+
/**
|
|
619
|
+
* @deprecated Temporary — signs `data` with NO `<Bytes>` watermark so a
|
|
620
|
+
* People-chain runtime that verifies a raw-byte proof accepts it
|
|
621
|
+
* (paritytech/host-rust-core#612). Removed once the runtime accepts
|
|
622
|
+
* watermarked proofs. Hosts show a stronger warning for this call.
|
|
623
|
+
*/
|
|
624
|
+
signRawUnwatermarkedDeprecated(account: ProductAccount, data: Uint8Array): Promise<Uint8Array>;
|
|
625
|
+
/** @deprecated Same as {@link signRawUnwatermarkedDeprecated} for a legacy (wallet) account. */
|
|
626
|
+
signRawUnwatermarkedDeprecatedWithLegacyAccount(account: {
|
|
627
|
+
publicKey: Uint8Array;
|
|
628
|
+
}, data: Uint8Array): Promise<Uint8Array>;
|
|
610
629
|
subscribeAccountConnectionStatus(callback: (status: HostAccountConnectionStatusSubscribeItem) => void): HostSubscription;
|
|
611
630
|
}
|
|
612
631
|
/**
|
package/dist/index.js
CHANGED
|
@@ -835,6 +835,10 @@ function toWireProductAccountId({
|
|
|
835
835
|
}) {
|
|
836
836
|
return { dotNsIdentifier, derivationIndex: { tag: "Index", value: derivationIndex } };
|
|
837
837
|
}
|
|
838
|
+
var accountIdCodec = AccountId();
|
|
839
|
+
function toBytesPayload(data) {
|
|
840
|
+
return { tag: "Bytes", value: { bytes: toHex(data) } };
|
|
841
|
+
}
|
|
838
842
|
function guardDecode(call, result) {
|
|
839
843
|
return ResultAsync.fromPromise(
|
|
840
844
|
Promise.resolve(result),
|
|
@@ -982,7 +986,7 @@ function adaptAccountsProvider(client) {
|
|
|
982
986
|
const response = await unwrapHostResult(
|
|
983
987
|
signing.signRaw({
|
|
984
988
|
account: productAccountId,
|
|
985
|
-
payload:
|
|
989
|
+
payload: toBytesPayload(data)
|
|
986
990
|
}),
|
|
987
991
|
"signRaw failed"
|
|
988
992
|
);
|
|
@@ -992,7 +996,7 @@ function adaptAccountsProvider(client) {
|
|
|
992
996
|
},
|
|
993
997
|
getLegacyAccountSigner(account_) {
|
|
994
998
|
const signerHex = toHex(account_.publicKey);
|
|
995
|
-
const ss58Address =
|
|
999
|
+
const ss58Address = accountIdCodec.dec(account_.publicKey);
|
|
996
1000
|
return {
|
|
997
1001
|
publicKey: account_.publicKey,
|
|
998
1002
|
async signTx(callData, signedExtensions, metadata) {
|
|
@@ -1016,7 +1020,7 @@ function adaptAccountsProvider(client) {
|
|
|
1016
1020
|
const response = await unwrapHostResult(
|
|
1017
1021
|
signing.signRawWithLegacyAccount({
|
|
1018
1022
|
signer: ss58Address,
|
|
1019
|
-
payload:
|
|
1023
|
+
payload: toBytesPayload(data)
|
|
1020
1024
|
}),
|
|
1021
1025
|
"signRawWithLegacyAccount failed"
|
|
1022
1026
|
);
|
|
@@ -1024,6 +1028,26 @@ function adaptAccountsProvider(client) {
|
|
|
1024
1028
|
}
|
|
1025
1029
|
};
|
|
1026
1030
|
},
|
|
1031
|
+
async signRawUnwatermarkedDeprecated(account_, data) {
|
|
1032
|
+
const response = await unwrapHostResult(
|
|
1033
|
+
signing.signRawUnwatermarkedDeprecated({
|
|
1034
|
+
account: toWireProductAccountId(account_),
|
|
1035
|
+
payload: toBytesPayload(data)
|
|
1036
|
+
}),
|
|
1037
|
+
"signRawUnwatermarkedDeprecated failed"
|
|
1038
|
+
);
|
|
1039
|
+
return fromHex(response.signature);
|
|
1040
|
+
},
|
|
1041
|
+
async signRawUnwatermarkedDeprecatedWithLegacyAccount(account_, data) {
|
|
1042
|
+
const response = await unwrapHostResult(
|
|
1043
|
+
signing.signRawUnwatermarkedDeprecatedWithLegacyAccount({
|
|
1044
|
+
signer: accountIdCodec.dec(account_.publicKey),
|
|
1045
|
+
payload: toBytesPayload(data)
|
|
1046
|
+
}),
|
|
1047
|
+
"signRawUnwatermarkedDeprecatedWithLegacyAccount failed"
|
|
1048
|
+
);
|
|
1049
|
+
return fromHex(response.signature);
|
|
1050
|
+
},
|
|
1027
1051
|
subscribeAccountConnectionStatus(callback) {
|
|
1028
1052
|
return subscribeWithInterrupt(account.connectionStatusSubscribe(), callback);
|
|
1029
1053
|
}
|