hive-keychain-commons 1.1.0 → 1.2.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 +2 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/interfaces/keychain.d.ts +9 -1
- package/lib/interfaces/keychain.js +1 -0
- package/lib/swaps/config.interface.d.ts +0 -2
- package/lib/utils/keys.utils.d.ts +1 -0
- package/lib/utils/keys.utils.js +15 -0
- package/lib/utils/transfer.utils.d.ts +1 -0
- package/lib/utils/transfer.utils.js +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/index.d.ts
CHANGED
|
@@ -4,3 +4,5 @@ export { AcceptRequestJSON, CancelDelegationJSON, CancelRequestJSON, PaymentJSON
|
|
|
4
4
|
export * from './swaps/config.interface';
|
|
5
5
|
export * from './swaps/swap-api.interface';
|
|
6
6
|
export * from './swaps/swap.interface';
|
|
7
|
+
export * from './utils/keys.utils';
|
|
8
|
+
export * from './utils/transfer.utils';
|
package/lib/index.js
CHANGED
|
@@ -17,3 +17,5 @@ Object.defineProperty(exports, "LeaseKeys", { enumerable: true, get: function ()
|
|
|
17
17
|
__exportStar(require("./swaps/config.interface"), exports);
|
|
18
18
|
__exportStar(require("./swaps/swap-api.interface"), exports);
|
|
19
19
|
__exportStar(require("./swaps/swap.interface"), exports);
|
|
20
|
+
__exportStar(require("./utils/keys.utils"), exports);
|
|
21
|
+
__exportStar(require("./utils/transfer.utils"), exports);
|
|
@@ -2,6 +2,7 @@ import { Operation, Transaction } from '@hiveio/dhive';
|
|
|
2
2
|
export declare enum KeychainRequestTypes {
|
|
3
3
|
decode = "decode",
|
|
4
4
|
encode = "encode",
|
|
5
|
+
encodeMultisig = "encodeMultisig",
|
|
5
6
|
signBuffer = "signBuffer",
|
|
6
7
|
broadcast = "broadcast",
|
|
7
8
|
addAccountAuthority = "addAccountAuthority",
|
|
@@ -56,6 +57,13 @@ export declare type RequestEncode = CommonRequestParams & {
|
|
|
56
57
|
message: string;
|
|
57
58
|
method: KeychainKeyTypes;
|
|
58
59
|
};
|
|
60
|
+
export declare type RequestEncodeMultisig = CommonRequestParams & {
|
|
61
|
+
type: KeychainRequestTypes.encodeMultisig;
|
|
62
|
+
username: string;
|
|
63
|
+
publicKeys: string[];
|
|
64
|
+
message: string;
|
|
65
|
+
method: KeychainKeyTypes;
|
|
66
|
+
};
|
|
59
67
|
export declare type ExcludeCommonParams<T> = Omit<T, 'rpc' | 'type' | 'key' | 'domain'>;
|
|
60
68
|
export declare type RequestSignBuffer = CommonRequestParams & {
|
|
61
69
|
type: KeychainRequestTypes.signBuffer;
|
|
@@ -240,7 +248,7 @@ export declare type RequestRecurrentTransfer = CommonRequestParams & {
|
|
|
240
248
|
recurrence: number;
|
|
241
249
|
executions: number;
|
|
242
250
|
};
|
|
243
|
-
export declare type KeychainRequestData = (RequestDecode | RequestEncode | RequestSignBuffer | RequestBroadcast | RequestAddAccountAuthority | RequestRemoveAccountAuthority | RequestAddKeyAuthority | RequestRemoveKeyAuthority | RequestSignTx | RequestPost | RequestVote | RequestCustomJSON | RequestSignedCall | RequestTransfer | RequestSendToken | RequestDelegation | RequestWitnessVote | RequestProxy | RequestPowerUp | RequestPowerDown | RequestCreateClaimedAccount | RequestUpdateProposalVote | RequestCreateProposal | RequestRemoveProposal | RequestAddAccount | RequestConvert | RequestRecurrentTransfer) & {
|
|
251
|
+
export declare type KeychainRequestData = (RequestDecode | RequestEncodeMultisig | RequestEncode | RequestSignBuffer | RequestBroadcast | RequestAddAccountAuthority | RequestRemoveAccountAuthority | RequestAddKeyAuthority | RequestRemoveKeyAuthority | RequestSignTx | RequestPost | RequestVote | RequestCustomJSON | RequestSignedCall | RequestTransfer | RequestSendToken | RequestDelegation | RequestWitnessVote | RequestProxy | RequestPowerUp | RequestPowerDown | RequestCreateClaimedAccount | RequestUpdateProposalVote | RequestCreateProposal | RequestRemoveProposal | RequestAddAccount | RequestConvert | RequestRecurrentTransfer) & {
|
|
244
252
|
redirect_uri?: string;
|
|
245
253
|
};
|
|
246
254
|
export declare type RequestId = {
|
|
@@ -5,6 +5,7 @@ var KeychainRequestTypes;
|
|
|
5
5
|
(function (KeychainRequestTypes) {
|
|
6
6
|
KeychainRequestTypes["decode"] = "decode";
|
|
7
7
|
KeychainRequestTypes["encode"] = "encode";
|
|
8
|
+
KeychainRequestTypes["encodeMultisig"] = "encodeMultisig";
|
|
8
9
|
KeychainRequestTypes["signBuffer"] = "signBuffer";
|
|
9
10
|
KeychainRequestTypes["broadcast"] = "broadcast";
|
|
10
11
|
KeychainRequestTypes["addAccountAuthority"] = "addAccountAuthority";
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { LoggerConfig } from '../logger/logger';
|
|
2
1
|
import { Provider } from './swap.interface';
|
|
3
2
|
export interface SwapServerConfig {
|
|
4
3
|
rpc: string[];
|
|
5
4
|
hiveEngineRpc: string[];
|
|
6
|
-
logger?: LoggerConfig;
|
|
7
5
|
swaps: SwapConfig;
|
|
8
6
|
priceRefreshIntervalInMinutes: number;
|
|
9
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getPublicKeyFromPrivateKeyString: (privateKeyS: string) => string | null;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPublicKeyFromPrivateKeyString = void 0;
|
|
4
|
+
const dhive_1 = require("@hiveio/dhive");
|
|
5
|
+
const getPublicKeyFromPrivateKeyString = (privateKeyS) => {
|
|
6
|
+
try {
|
|
7
|
+
const privateKey = dhive_1.PrivateKey.fromString(privateKeyS);
|
|
8
|
+
const publicKey = privateKey.createPublic();
|
|
9
|
+
return publicKey.toString();
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
exports.getPublicKeyFromPrivateKeyString = getPublicKeyFromPrivateKeyString;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getPrivateKeysMemoValidationWarning: (memo: string) => boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPrivateKeysMemoValidationWarning = void 0;
|
|
4
|
+
const dhive_1 = require("@hiveio/dhive");
|
|
5
|
+
const keys_utils_1 = require("./keys.utils");
|
|
6
|
+
const getPrivateKeysMemoValidationWarning = (memo) => {
|
|
7
|
+
const memoTemp = memo.startsWith('#')
|
|
8
|
+
? memo.substring(1, memo.length)
|
|
9
|
+
: memo;
|
|
10
|
+
let found;
|
|
11
|
+
found = memoTemp.match(/[\w\d]{51,52}/g);
|
|
12
|
+
if (found) {
|
|
13
|
+
for (const word of found) {
|
|
14
|
+
if (dhive_1.cryptoUtils.isWif(word) && word.length === 51) {
|
|
15
|
+
if ((0, keys_utils_1.getPublicKeyFromPrivateKeyString)(word))
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
else if (word.startsWith('P') && word.length === 52) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
};
|
|
25
|
+
exports.getPrivateKeysMemoValidationWarning = getPrivateKeysMemoValidationWarning;
|