near-api-js
Advanced tools
Comparing version 2.1.4 to 3.0.0
/** | ||
* Connect to NEAR using the provided configuration. | ||
* | ||
* {@link ConnectConfig.networkId} and {@link ConnectConfig.nodeUrl} are required. | ||
* {@link ConnectConfig#networkId} and {@link ConnectConfig#nodeUrl} are required. | ||
* | ||
* To sign transactions you can also pass: {@link ConnectConfig.keyStore} | ||
* To sign transactions you can also pass: {@link ConnectConfig#keyStore} | ||
* | ||
@@ -8,0 +8,0 @@ * Both are passed they are prioritize in that order. |
@@ -16,5 +16,5 @@ "use strict"; | ||
* | ||
* {@link ConnectConfig.networkId} and {@link ConnectConfig.nodeUrl} are required. | ||
* {@link ConnectConfig#networkId} and {@link ConnectConfig#nodeUrl} are required. | ||
* | ||
* To sign transactions you can also pass: {@link ConnectConfig.keyStore} | ||
* To sign transactions you can also pass: {@link ConnectConfig#keyStore} | ||
* | ||
@@ -21,0 +21,0 @@ * Both are passed they are prioritize in that order. |
import { Near, NearConfig } from './near'; | ||
export interface ConnectConfig extends NearConfig { | ||
/** | ||
* Initialize an {@link key_stores/in_memory_key_store!InMemoryKeyStore} by reading the file at keyPath. | ||
* Initialize an {@link InMemoryKeyStore} by reading the file at keyPath. | ||
*/ | ||
@@ -6,0 +6,0 @@ keyPath?: string; |
@@ -11,5 +11,2 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -20,8 +17,8 @@ exports.connect = void 0; | ||
* | ||
* {@link ConnectConfig.networkId} and {@link ConnectConfig.nodeUrl} are required. | ||
* {@link ConnectConfig#networkId} and {@link ConnectConfig#nodeUrl} are required. | ||
* | ||
* To sign transactions you can also pass: | ||
* 1. {@link ConnectConfig.keyStore} | ||
* 2. {@link ConnectConfig.keyPath} | ||
* 3. {@link ConnectConfig.deps.keyStore} (deprecated, only for use in legacy applications) | ||
* 1. {@link ConnectConfig#keyStore} | ||
* 2. {@link ConnectConfig#keyPath} | ||
* 3. {@link ConnectConfig#deps.keyStore} (deprecated, only for use in legacy applications) | ||
* | ||
@@ -40,2 +37,11 @@ * If all three are passed they are prioritize in that order. | ||
* ``` | ||
* @example disable library logs | ||
* ```js | ||
* async function initNear() { | ||
* const near = await connect({ | ||
* networkId: 'testnet', | ||
* nodeUrl: 'https://rpc.testnet.near.org', | ||
* logger: false | ||
* }) | ||
* } | ||
* @module connect | ||
@@ -46,5 +52,3 @@ */ | ||
const near_1 = require("./near"); | ||
const setup_node_fetch_1 = __importDefault(require("./utils/setup-node-fetch")); | ||
const utils_1 = require("./utils"); | ||
global.fetch = setup_node_fetch_1.default; | ||
const utils_1 = require("@near-js/utils"); | ||
/** | ||
@@ -56,2 +60,9 @@ * Initialize connection to Near network. | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (config.logger === false) { | ||
// disables logging | ||
utils_1.Logger.overrideLogger(undefined); | ||
} | ||
else if (config.logger !== undefined && config.logger !== null) { | ||
utils_1.Logger.overrideLogger(config.logger); | ||
} | ||
// Try to find extra key in `KeyPath` if provided. | ||
@@ -73,9 +84,7 @@ if (config.keyPath && (config.keyStore || ((_a = config.deps) === null || _a === void 0 ? void 0 : _a.keyStore))) { | ||
], { writeKeyStoreIndex: 1 }); | ||
if (!process.env['NEAR_NO_LOGS']) { | ||
console.log(`Loaded master account ${accountKeyFile[0]} key from ${config.keyPath} with public key = ${keyPair.getPublicKey()}`); | ||
} | ||
utils_1.Logger.log(`Loaded master account ${accountKeyFile[0]} key from ${config.keyPath} with public key = ${keyPair.getPublicKey()}`); | ||
} | ||
} | ||
catch (error) { | ||
(0, utils_1.logWarning)(`Failed to load master account key from ${config.keyPath}: ${error}`); | ||
utils_1.Logger.warn(`Failed to load master account key from ${config.keyPath}: ${error}`); | ||
} | ||
@@ -82,0 +91,0 @@ } |
@@ -9,2 +9,3 @@ import * as key_pair from './key_pair'; | ||
import { logWarning } from './errors'; | ||
export { key_pair, serialize, web, enums, format, PublicKey, KeyPair, KeyPairEd25519, rpc_errors, logWarning, }; | ||
import { Logger } from './logger'; | ||
export { key_pair, serialize, web, enums, format, PublicKey, KeyPair, KeyPairEd25519, rpc_errors, logWarning, Logger }; |
@@ -26,3 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.logWarning = exports.rpc_errors = exports.KeyPairEd25519 = exports.KeyPair = exports.PublicKey = exports.format = exports.enums = exports.web = exports.serialize = exports.key_pair = void 0; | ||
exports.Logger = exports.logWarning = exports.rpc_errors = exports.KeyPairEd25519 = exports.KeyPair = exports.PublicKey = exports.format = exports.enums = exports.web = exports.serialize = exports.key_pair = void 0; | ||
const key_pair = __importStar(require("./key_pair")); | ||
@@ -46,1 +46,3 @@ exports.key_pair = key_pair; | ||
Object.defineProperty(exports, "logWarning", { enumerable: true, get: function () { return errors_1.logWarning; } }); | ||
const logger_1 = require("./logger"); | ||
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } }); |
@@ -1,1 +0,2 @@ | ||
export { baseEncode as base_encode, baseDecode as base_decode, serialize, deserialize, Schema, BorshError, BinaryWriter, BinaryReader, } from 'borsh'; | ||
export { serialize, deserialize, Schema, } from 'borsh'; | ||
export { baseEncode as base_encode, baseDecode as base_decode, } from '@near-js/utils'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BinaryReader = exports.BinaryWriter = exports.BorshError = exports.deserialize = exports.serialize = exports.base_decode = exports.base_encode = void 0; | ||
exports.base_decode = exports.base_encode = exports.deserialize = exports.serialize = void 0; | ||
var borsh_1 = require("borsh"); | ||
Object.defineProperty(exports, "base_encode", { enumerable: true, get: function () { return borsh_1.baseEncode; } }); | ||
Object.defineProperty(exports, "base_decode", { enumerable: true, get: function () { return borsh_1.baseDecode; } }); | ||
Object.defineProperty(exports, "serialize", { enumerable: true, get: function () { return borsh_1.serialize; } }); | ||
Object.defineProperty(exports, "deserialize", { enumerable: true, get: function () { return borsh_1.deserialize; } }); | ||
Object.defineProperty(exports, "BorshError", { enumerable: true, get: function () { return borsh_1.BorshError; } }); | ||
Object.defineProperty(exports, "BinaryWriter", { enumerable: true, get: function () { return borsh_1.BinaryWriter; } }); | ||
Object.defineProperty(exports, "BinaryReader", { enumerable: true, get: function () { return borsh_1.BinaryReader; } }); | ||
var utils_1 = require("@near-js/utils"); | ||
Object.defineProperty(exports, "base_encode", { enumerable: true, get: function () { return utils_1.baseEncode; } }); | ||
Object.defineProperty(exports, "base_decode", { enumerable: true, get: function () { return utils_1.baseDecode; } }); |
{ | ||
"name": "near-api-js", | ||
"description": "JavaScript library to interact with NEAR Protocol via RPC API", | ||
"version": "2.1.4", | ||
"version": "3.0.0", | ||
"repository": { | ||
@@ -14,42 +14,42 @@ "type": "git", | ||
"dependencies": { | ||
"ajv": "^8.11.2", | ||
"ajv-formats": "^2.1.1", | ||
"ajv": "8.11.2", | ||
"ajv-formats": "2.1.1", | ||
"bn.js": "5.2.1", | ||
"borsh": "^0.7.0", | ||
"depd": "^2.0.0", | ||
"error-polyfill": "^0.1.3", | ||
"http-errors": "^1.7.2", | ||
"borsh": "1.0.0", | ||
"depd": "2.0.0", | ||
"error-polyfill": "0.1.3", | ||
"http-errors": "1.7.2", | ||
"near-abi": "0.1.1", | ||
"node-fetch": "^2.6.1", | ||
"tweetnacl": "^1.0.1", | ||
"@near-js/accounts": "0.1.4", | ||
"@near-js/crypto": "0.0.5", | ||
"@near-js/keystores": "0.0.5", | ||
"@near-js/keystores-browser": "0.0.5", | ||
"@near-js/keystores-node": "0.0.5", | ||
"@near-js/providers": "0.0.7", | ||
"@near-js/signers": "0.0.5", | ||
"@near-js/transactions": "0.2.1", | ||
"node-fetch": "2.6.7", | ||
"@noble/curves": "1.2.0", | ||
"@near-js/accounts": "1.0.0", | ||
"@near-js/crypto": "1.0.0", | ||
"@near-js/keystores": "0.0.6", | ||
"@near-js/keystores-browser": "0.0.6", | ||
"@near-js/keystores-node": "0.0.6", | ||
"@near-js/providers": "0.0.8", | ||
"@near-js/signers": "0.0.6", | ||
"@near-js/transactions": "1.0.0", | ||
"@near-js/types": "0.0.4", | ||
"@near-js/utils": "0.0.4", | ||
"@near-js/wallet-account": "0.0.7" | ||
"@near-js/utils": "0.0.5", | ||
"@near-js/wallet-account": "1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/bn.js": "^5.1.0", | ||
"@types/http-errors": "^1.6.1", | ||
"@types/node": "^18.11.18", | ||
"browserify": "^16.2.3", | ||
"bs58": "^4.0.0", | ||
"bundlewatch": "^0.3.1", | ||
"concurrently": "^7.3.0", | ||
"danger": "^11.1.1", | ||
"danger-plugin-yarn": "^1.3.2", | ||
"in-publish": "^2.0.0", | ||
"jest": "^26.0.1", | ||
"localstorage-memory": "^1.0.3", | ||
"near-hello": "^0.5.1", | ||
"rimraf": "^3.0.0", | ||
"semver": "^7.1.1", | ||
"ts-jest": "^26.5.6", | ||
"uglifyify": "^5.0.1" | ||
"@types/bn.js": "5.1.0", | ||
"@types/http-errors": "1.6.1", | ||
"@types/node": "18.11.18", | ||
"browserify": "16.2.3", | ||
"bs58": "4.0.0", | ||
"bundlewatch": "0.3.1", | ||
"concurrently": "7.3.0", | ||
"danger": "11.1.1", | ||
"danger-plugin-yarn": "1.3.2", | ||
"in-publish": "2.0.0", | ||
"jest": "26.0.1", | ||
"localstorage-memory": "1.0.3", | ||
"near-hello": "0.5.1", | ||
"rimraf": "3.0.2", | ||
"semver": "7.1.1", | ||
"ts-jest": "26.5.6", | ||
"uglifyify": "5.0.1" | ||
}, | ||
@@ -56,0 +56,0 @@ "keywords": [], |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
2642717
50684
6
9
+ Added@noble/curves@1.2.0
+ Added@near-js/accounts@1.0.0(transitive)
+ Added@near-js/crypto@1.0.0(transitive)
+ Added@near-js/keystores@0.0.6(transitive)
+ Added@near-js/keystores-browser@0.0.6(transitive)
+ Added@near-js/keystores-node@0.0.6(transitive)
+ Added@near-js/providers@0.0.8(transitive)
+ Added@near-js/signers@0.0.6(transitive)
+ Added@near-js/transactions@1.0.0(transitive)
+ Added@near-js/types@0.0.4(transitive)
+ Added@near-js/utils@0.0.5(transitive)
+ Added@near-js/wallet-account@1.0.0(transitive)
+ Added@noble/curves@1.2.0(transitive)
+ Added@noble/hashes@1.3.2(transitive)
+ Added@types/json-schema@7.0.15(transitive)
+ Addedajv@8.11.2(transitive)
+ Addedajv-formats@2.1.1(transitive)
+ Addedbase-x@2.0.6(transitive)
+ Addedbn.js@5.2.1(transitive)
+ Addedborsh@1.0.0(transitive)
+ Addedbs58@4.0.0(transitive)
+ Addedcapability@0.2.5(transitive)
+ Addeddepd@1.1.22.0.0(transitive)
+ Addederror-polyfill@0.1.3(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedhttp-errors@1.7.2(transitive)
+ Addedinherits@2.0.3(transitive)
+ Addedjs-sha256@0.9.0(transitive)
+ Addedjson-schema-traverse@1.0.0(transitive)
+ Addedlru_map@0.4.1(transitive)
+ Addedmustache@4.0.0(transitive)
+ Addednear-abi@0.1.1(transitive)
+ Addednode-fetch@2.6.7(transitive)
+ Addedo3@1.0.3(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedrequire-from-string@2.0.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsetprototypeof@1.1.1(transitive)
+ Addedstatuses@1.5.0(transitive)
+ Addedtoidentifier@1.0.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedu3@0.1.1(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedtweetnacl@^1.0.1
Updated@near-js/accounts@1.0.0
Updated@near-js/crypto@1.0.0
Updated@near-js/keystores@0.0.6
Updated@near-js/providers@0.0.8
Updated@near-js/signers@0.0.6
Updated@near-js/transactions@1.0.0
Updated@near-js/utils@0.0.5
Updatedajv@8.11.2
Updatedajv-formats@2.1.1
Updatedborsh@1.0.0
Updateddepd@2.0.0
Updatederror-polyfill@0.1.3
Updatedhttp-errors@1.7.2
Updatednode-fetch@2.6.7