@yuants/utils
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -10,4 +10,5 @@ /** | ||
export * from './async-iterator-interop'; | ||
export * from './crypto'; | ||
export * from './order-utils'; | ||
export * from './rx-utils'; | ||
//# sourceMappingURL=index.js.map |
@@ -23,2 +23,26 @@ /** | ||
/** | ||
* create a new key pair | ||
* | ||
* - ED25519 key pair | ||
* - base58 encoded | ||
* | ||
* @public | ||
*/ | ||
export declare const createKeyPair: () => { | ||
public_key: string; | ||
private_key: string; | ||
}; | ||
/** | ||
* create a key pair from a secret key | ||
* @param privateKey - the private key to create the key pair from (base58 encoded) | ||
* @returns the public key and the private key (both base58 encoded) | ||
* @public | ||
*/ | ||
export declare const fromPrivateKey: (privateKey: string) => { | ||
public_key: string; | ||
private_key: string; | ||
}; | ||
/** | ||
* NativeSubject is native version of rx's Subject, which can be used in async generator. | ||
@@ -77,2 +101,12 @@ * | ||
/** | ||
* sign a message with a private key | ||
* | ||
* @param message - the message to sign | ||
* @param privateKey - the private key to sign the message with (base58 encoded) | ||
* @returns the signature (base58 encoded) | ||
* @public | ||
*/ | ||
export declare const signMessage: (message: string, privateKey: string) => string; | ||
/** | ||
* convert a rx's Subject to a NativeSubject. | ||
@@ -93,2 +127,12 @@ * | ||
/** | ||
* verify a message with a public key | ||
* @param message - the message to verify | ||
* @param signature - the signature to verify (base58 encoded) | ||
* @param publicKey - the public key to verify the message with (base58 encoded) | ||
* @returns true if the signature is valid, false otherwise, maybe throw an error if public key is invalid | ||
* @public | ||
*/ | ||
export declare const verifyMessage: (message: string, signature: string, publicKey: string) => boolean; | ||
export { } |
@@ -10,4 +10,5 @@ /** | ||
export * from './async-iterator-interop'; | ||
export * from './crypto'; | ||
export * from './order-utils'; | ||
export * from './rx-utils'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -26,4 +26,5 @@ "use strict"; | ||
__exportStar(require("./async-iterator-interop"), exports); | ||
__exportStar(require("./crypto"), exports); | ||
__exportStar(require("./order-utils"), exports); | ||
__exportStar(require("./rx-utils"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@yuants/utils", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"main": "lib/index.js", | ||
@@ -26,3 +26,5 @@ "module": "dist/index.js", | ||
"dependencies": { | ||
"rxjs": "~7.5.6" | ||
"rxjs": "~7.5.6", | ||
"tweetnacl": "~1.0.3", | ||
"bs58": "~6.0.0" | ||
}, | ||
@@ -29,0 +31,0 @@ "scripts": { |
{ | ||
"libraries/utils/CHANGELOG.json": "f4c1970460ee18d9da69a284be927793db7d81d5", | ||
"libraries/utils/CHANGELOG.md": "d4b5d9d906cc323f980a0108ff3c9fe1cfbf9a35", | ||
"libraries/utils/CHANGELOG.json": "6f8d907580ee4aa348aa20541d6a7d1eb219a669", | ||
"libraries/utils/CHANGELOG.md": "ed843b09a9841500251f5566f4f49844bd5c8f3c", | ||
"libraries/utils/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c", | ||
@@ -8,7 +8,8 @@ "libraries/utils/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd", | ||
"libraries/utils/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348", | ||
"libraries/utils/etc/utils.api.md": "76194b141694e7177037d32bfd3eaed50d52ce2d", | ||
"libraries/utils/package.json": "90c83275b345d920deb1c2bb7a18f57d1ccc4519", | ||
"libraries/utils/etc/utils.api.md": "22548b4cf52d3f6eba3546e135026e7e959baf9f", | ||
"libraries/utils/package.json": "4f916879d412556f288b22e62a5c0db9fc2c7b39", | ||
"libraries/utils/src/async-iterator-interop.test.ts": "ec6e2470d1ace812d5fac14450a2568ff8a4dfd5", | ||
"libraries/utils/src/async-iterator-interop.ts": "8dbb6150c1d75ed4d5c11be6fec6290fd8c0a561", | ||
"libraries/utils/src/index.ts": "1a51eaf7d7090e909486f3f7b838208f1ffa6693", | ||
"libraries/utils/src/crypto.ts": "e037ef3330dcd764d52ba24a280c78c336dc7faa", | ||
"libraries/utils/src/index.ts": "72bc55afb3398495923a188333996788753db7f5", | ||
"libraries/utils/src/order-utils.ts": "e0340bdfd925c6a1943871f37638947657dd0e4c", | ||
@@ -18,4 +19,4 @@ "libraries/utils/src/rx-utils.test.ts": "55617b7d55f406f8554c5fba24b34cf51a50270e", | ||
"libraries/utils/tsconfig.json": "22f94ca28b507f8ddcc21b9053158eefd3f726a9", | ||
"libraries/utils/.rush/temp/shrinkwrap-deps.json": "e49fb137e933cde3ad44d1fe0faadf984a8618a2", | ||
"libraries/utils/.rush/temp/shrinkwrap-deps.json": "8d996dfb7035599ac88abb7ce75c4f9ee4695181", | ||
"tools/toolkit/temp/package-deps.json": "2875da6fe1d56cb58277b3dc53a29322a6f73957" | ||
} |
@@ -225,2 +225,46 @@ { | ||
{ | ||
"kind": "Variable", | ||
"canonicalReference": "@yuants/utils!createKeyPair:var", | ||
"docComment": "/**\n * create a new key pair\n *\n * - ED25519 key pair - base58 encoded\n *\n * @public\n */\n", | ||
"excerptTokens": [ | ||
{ | ||
"kind": "Content", | ||
"text": "createKeyPair: " | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": "() => {\n public_key: string;\n private_key: string;\n}" | ||
} | ||
], | ||
"isReadonly": true, | ||
"releaseTag": "Public", | ||
"name": "createKeyPair", | ||
"variableTypeTokenRange": { | ||
"startIndex": 1, | ||
"endIndex": 2 | ||
} | ||
}, | ||
{ | ||
"kind": "Variable", | ||
"canonicalReference": "@yuants/utils!fromPrivateKey:var", | ||
"docComment": "/**\n * create a key pair from a secret key\n *\n * @param privateKey - the private key to create the key pair from (base58 encoded)\n *\n * @returns the public key and the private key (both base58 encoded)\n *\n * @public\n */\n", | ||
"excerptTokens": [ | ||
{ | ||
"kind": "Content", | ||
"text": "fromPrivateKey: " | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": "(privateKey: string) => {\n public_key: string;\n private_key: string;\n}" | ||
} | ||
], | ||
"isReadonly": true, | ||
"releaseTag": "Public", | ||
"name": "fromPrivateKey", | ||
"variableTypeTokenRange": { | ||
"startIndex": 1, | ||
"endIndex": 2 | ||
} | ||
}, | ||
{ | ||
"kind": "TypeAlias", | ||
@@ -502,2 +546,24 @@ "canonicalReference": "@yuants/utils!NativeSubject:type", | ||
"kind": "Variable", | ||
"canonicalReference": "@yuants/utils!signMessage:var", | ||
"docComment": "/**\n * sign a message with a private key\n *\n * @param message - the message to sign\n *\n * @param privateKey - the private key to sign the message with (base58 encoded)\n *\n * @returns the signature (base58 encoded)\n *\n * @public\n */\n", | ||
"excerptTokens": [ | ||
{ | ||
"kind": "Content", | ||
"text": "signMessage: " | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": "(message: string, privateKey: string) => string" | ||
} | ||
], | ||
"isReadonly": true, | ||
"releaseTag": "Public", | ||
"name": "signMessage", | ||
"variableTypeTokenRange": { | ||
"startIndex": 1, | ||
"endIndex": 2 | ||
} | ||
}, | ||
{ | ||
"kind": "Variable", | ||
"canonicalReference": "@yuants/utils!subjectToNativeSubject:var", | ||
@@ -589,2 +655,24 @@ "docComment": "/**\n * convert a rx's Subject to a NativeSubject.\n *\n * @param subject$ - the rx's Subject to convert\n *\n * @returns a NativeSubject\n *\n * @public\n */\n", | ||
} | ||
}, | ||
{ | ||
"kind": "Variable", | ||
"canonicalReference": "@yuants/utils!verifyMessage:var", | ||
"docComment": "/**\n * verify a message with a public key\n *\n * @param message - the message to verify\n *\n * @param signature - the signature to verify (base58 encoded)\n *\n * @param publicKey - the public key to verify the message with (base58 encoded)\n *\n * @returns true if the signature is valid, false otherwise, maybe throw an error if public key is invalid\n *\n * @public\n */\n", | ||
"excerptTokens": [ | ||
{ | ||
"kind": "Content", | ||
"text": "verifyMessage: " | ||
}, | ||
{ | ||
"kind": "Content", | ||
"text": "(message: string, signature: string, publicKey: string) => boolean" | ||
} | ||
], | ||
"isReadonly": true, | ||
"releaseTag": "Public", | ||
"name": "verifyMessage", | ||
"variableTypeTokenRange": { | ||
"startIndex": 1, | ||
"endIndex": 2 | ||
} | ||
} | ||
@@ -591,0 +679,0 @@ ] |
@@ -17,2 +17,14 @@ ## API Report File for "@yuants/utils" | ||
// @public | ||
export const createKeyPair: () => { | ||
public_key: string; | ||
private_key: string; | ||
}; | ||
// @public | ||
export const fromPrivateKey: (privateKey: string) => { | ||
public_key: string; | ||
private_key: string; | ||
}; | ||
// @public | ||
export type NativeSubject<T> = AsyncIterable<T> & AsyncIterator<T, void, T>; | ||
@@ -37,2 +49,5 @@ | ||
// @public | ||
export const signMessage: (message: string, privateKey: string) => string; | ||
// @public | ||
export const subjectToNativeSubject: <T>(subject$: Subject<T>) => NativeSubject<T>; | ||
@@ -43,2 +58,5 @@ | ||
// @public | ||
export const verifyMessage: (message: string, signature: string, publicKey: string) => boolean; | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
130195
48
1980
3
+ Addedbs58@~6.0.0
+ Addedtweetnacl@~1.0.3
+ Addedbase-x@5.0.0(transitive)
+ Addedbs58@6.0.0(transitive)
+ Addedtweetnacl@1.0.3(transitive)