Socket
Socket
Sign inDemoInstall

@near-js/keystores

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@near-js/keystores - npm Package Compare versions

Comparing version 0.0.12 to 0.1.0-next.0

lib/multi_contract_keystore.d.ts

85

lib/in_memory_key_store.js

@@ -1,15 +0,3 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InMemoryKeyStore = void 0;
const crypto_1 = require("@near-js/crypto");
const keystore_1 = require("./keystore");
import { KeyPair } from '@near-js/crypto';
import { KeyStore } from './keystore';
/**

@@ -42,3 +30,5 @@ * Simple in-memory keystore for mainly for testing purposes.

*/
class InMemoryKeyStore extends keystore_1.KeyStore {
export class InMemoryKeyStore extends KeyStore {
/** @hidden */
keys;
constructor() {

@@ -54,6 +44,4 @@ super();

*/
setKey(networkId, accountId, keyPair) {
return __awaiter(this, void 0, void 0, function* () {
this.keys[`${accountId}:${networkId}`] = keyPair.toString();
});
async setKey(networkId, accountId, keyPair) {
this.keys[`${accountId}:${networkId}`] = keyPair.toString();
}

@@ -66,10 +54,8 @@ /**

*/
getKey(networkId, accountId) {
return __awaiter(this, void 0, void 0, function* () {
const value = this.keys[`${accountId}:${networkId}`];
if (!value) {
return null;
}
return crypto_1.KeyPair.fromString(value);
});
async getKey(networkId, accountId) {
const value = this.keys[`${accountId}:${networkId}`];
if (!value) {
return null;
}
return KeyPair.fromString(value);
}

@@ -81,6 +67,4 @@ /**

*/
removeKey(networkId, accountId) {
return __awaiter(this, void 0, void 0, function* () {
delete this.keys[`${accountId}:${networkId}`];
});
async removeKey(networkId, accountId) {
delete this.keys[`${accountId}:${networkId}`];
}

@@ -90,6 +74,4 @@ /**

*/
clear() {
return __awaiter(this, void 0, void 0, function* () {
this.keys = {};
});
async clear() {
this.keys = {};
}

@@ -100,11 +82,9 @@ /**

*/
getNetworks() {
return __awaiter(this, void 0, void 0, function* () {
const result = new Set();
Object.keys(this.keys).forEach((key) => {
const parts = key.split(':');
result.add(parts[1]);
});
return Array.from(result.values());
async getNetworks() {
const result = new Set();
Object.keys(this.keys).forEach((key) => {
const parts = key.split(':');
result.add(parts[1]);
});
return Array.from(result.values());
}

@@ -115,13 +95,11 @@ /**

*/
getAccounts(networkId) {
return __awaiter(this, void 0, void 0, function* () {
const result = new Array();
Object.keys(this.keys).forEach((key) => {
const parts = key.split(':');
if (parts[parts.length - 1] === networkId) {
result.push(parts.slice(0, parts.length - 1).join(':'));
}
});
return result;
async getAccounts(networkId) {
const result = new Array();
Object.keys(this.keys).forEach((key) => {
const parts = key.split(':');
if (parts[parts.length - 1] === networkId) {
result.push(parts.slice(0, parts.length - 1).join(':'));
}
});
return result;
}

@@ -133,2 +111,1 @@ /** @hidden */

}
exports.InMemoryKeyStore = InMemoryKeyStore;
export { InMemoryKeyStore } from './in_memory_key_store';
export { KeyStore } from './keystore';
export { MergeKeyStore } from './merge_key_store';
export { MultiContractKeyStore } from './multi_contract_keystore';
//# sourceMappingURL=index.d.ts.map

@@ -1,9 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MergeKeyStore = exports.KeyStore = exports.InMemoryKeyStore = void 0;
var in_memory_key_store_1 = require("./in_memory_key_store");
Object.defineProperty(exports, "InMemoryKeyStore", { enumerable: true, get: function () { return in_memory_key_store_1.InMemoryKeyStore; } });
var keystore_1 = require("./keystore");
Object.defineProperty(exports, "KeyStore", { enumerable: true, get: function () { return keystore_1.KeyStore; } });
var merge_key_store_1 = require("./merge_key_store");
Object.defineProperty(exports, "MergeKeyStore", { enumerable: true, get: function () { return merge_key_store_1.MergeKeyStore; } });
export { InMemoryKeyStore } from './in_memory_key_store';
export { KeyStore } from './keystore';
export { MergeKeyStore } from './merge_key_store';
export { MultiContractKeyStore } from './multi_contract_keystore';

@@ -1,4 +0,1 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyStore = void 0;
/**

@@ -9,4 +6,3 @@ * KeyStores are passed to {@link "@near-js/wallet-account".near.Near | Near} via {@link "@near-js/wallet-account".near.NearConfig | NearConfig}

*/
class KeyStore {
export class KeyStore {
}
exports.KeyStore = KeyStore;

@@ -1,15 +0,5 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MergeKeyStore = void 0;
const keystore_1 = require("./keystore");
class MergeKeyStore extends keystore_1.KeyStore {
import { KeyStore } from './keystore';
export class MergeKeyStore extends KeyStore {
options;
keyStores;
/**

@@ -31,6 +21,4 @@ * @param keyStores read calls are attempted from start to end of array

*/
setKey(networkId, accountId, keyPair) {
return __awaiter(this, void 0, void 0, function* () {
yield this.keyStores[this.options.writeKeyStoreIndex].setKey(networkId, accountId, keyPair);
});
async setKey(networkId, accountId, keyPair) {
await this.keyStores[this.options.writeKeyStoreIndex].setKey(networkId, accountId, keyPair);
}

@@ -43,12 +31,10 @@ /**

*/
getKey(networkId, accountId) {
return __awaiter(this, void 0, void 0, function* () {
for (const keyStore of this.keyStores) {
const keyPair = yield keyStore.getKey(networkId, accountId);
if (keyPair) {
return keyPair;
}
async getKey(networkId, accountId) {
for (const keyStore of this.keyStores) {
const keyPair = await keyStore.getKey(networkId, accountId);
if (keyPair) {
return keyPair;
}
return null;
});
}
return null;
}

@@ -60,8 +46,6 @@ /**

*/
removeKey(networkId, accountId) {
return __awaiter(this, void 0, void 0, function* () {
for (const keyStore of this.keyStores) {
yield keyStore.removeKey(networkId, accountId);
}
});
async removeKey(networkId, accountId) {
for (const keyStore of this.keyStores) {
await keyStore.removeKey(networkId, accountId);
}
}

@@ -71,8 +55,6 @@ /**

*/
clear() {
return __awaiter(this, void 0, void 0, function* () {
for (const keyStore of this.keyStores) {
yield keyStore.clear();
}
});
async clear() {
for (const keyStore of this.keyStores) {
await keyStore.clear();
}
}

@@ -83,12 +65,10 @@ /**

*/
getNetworks() {
return __awaiter(this, void 0, void 0, function* () {
const result = new Set();
for (const keyStore of this.keyStores) {
for (const network of yield keyStore.getNetworks()) {
result.add(network);
}
async getNetworks() {
const result = new Set();
for (const keyStore of this.keyStores) {
for (const network of await keyStore.getNetworks()) {
result.add(network);
}
return Array.from(result);
});
}
return Array.from(result);
}

@@ -99,12 +79,10 @@ /**

*/
getAccounts(networkId) {
return __awaiter(this, void 0, void 0, function* () {
const result = new Set();
for (const keyStore of this.keyStores) {
for (const account of yield keyStore.getAccounts(networkId)) {
result.add(account);
}
async getAccounts(networkId) {
const result = new Set();
for (const keyStore of this.keyStores) {
for (const account of await keyStore.getAccounts(networkId)) {
result.add(account);
}
return Array.from(result);
});
}
return Array.from(result);
}

@@ -116,2 +94,1 @@ /** @hidden */

}
exports.MergeKeyStore = MergeKeyStore;
{
"name": "@near-js/keystores",
"version": "0.0.12",
"version": "0.1.0-next.0",
"description": "Key storage and management implementations",
"main": "lib/index.js",
"type": "module",
"keywords": [],

@@ -10,10 +11,12 @@ "author": "",

"dependencies": {
"@near-js/crypto": "1.2.4",
"@near-js/types": "0.2.1"
"@near-js/crypto": "1.3.0-next.0",
"@near-js/types": "0.3.0-next.0"
},
"devDependencies": {
"@types/node": "18.11.18",
"jest": "26.0.1",
"ts-jest": "26.5.6",
"typescript": "4.9.4"
"@jest/globals": "^29.7.0",
"@types/node": "20.0.0",
"jest": "29.7.0",
"ts-jest": "29.1.5",
"typescript": "5.4.5",
"tsconfig": "0.0.0"
},

@@ -26,8 +29,6 @@ "files": [

"compile": "tsc -p tsconfig.json",
"lint:js": "eslint -c ../../.eslintrc.js.yml test/**/*.js --no-eslintrc",
"lint:js:fix": "eslint -c ../../.eslintrc.js.yml test/**/*.js --no-eslintrc --fix",
"lint:ts": "eslint -c ../../.eslintrc.ts.yml src/**/*.ts --no-eslintrc",
"lint:ts:fix": "eslint -c ../../.eslintrc.ts.yml src/**/*.ts --no-eslintrc --fix",
"test": "jest test"
"lint": "eslint -c ../../.eslintrc.ts.yml src/**/*.ts test/**/*.ts --no-eslintrc",
"lint:fix": "eslint -c ../../.eslintrc.ts.yml src/**/*.ts test/**/*.ts --no-eslintrc --fix",
"test": "jest"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc