Merged 1.3.x_branch into master
This commit is contained in:
4
.babelrc
4
.babelrc
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"presets": ["@babel/preset-env"],
|
|
||||||
"plugins": ["@babel/plugin-proposal-class-properties", "@babel/transform-runtime"]
|
|
||||||
}
|
|
||||||
4
.eslintignore
Normal file
4
.eslintignore
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules
|
||||||
|
.vscode
|
||||||
|
dist
|
||||||
|
backup
|
||||||
17
.eslintrc
Normal file
17
.eslintrc
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"node": true,
|
||||||
|
"jquery": true,
|
||||||
|
"jest/globals": true,
|
||||||
|
"es6": true
|
||||||
|
},
|
||||||
|
"parserOptions": {
|
||||||
|
"sourceType": "module",
|
||||||
|
"allowImportExportEverywhere": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended"
|
||||||
|
],
|
||||||
|
"parser": "babel-eslint"
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"env": {
|
|
||||||
"browser": true,
|
|
||||||
"es2021": true,
|
|
||||||
"jest/globals": true
|
|
||||||
},
|
|
||||||
"extends": "eslint:recommended",
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 12,
|
|
||||||
"sourceType": "module"
|
|
||||||
},
|
|
||||||
"plugins": {
|
|
||||||
"jest"
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,4 +1,6 @@
|
|||||||
package-lock.json
|
|
||||||
.idea/
|
|
||||||
node_modules/
|
node_modules/
|
||||||
coverage/
|
.vscode/
|
||||||
|
dist/
|
||||||
|
backup/
|
||||||
|
.idea/
|
||||||
|
/package-lock.json
|
||||||
|
|||||||
4
.npmignore
Normal file
4
.npmignore
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules
|
||||||
|
.vscode
|
||||||
|
dist
|
||||||
|
backup
|
||||||
@@ -5,3 +5,4 @@
|
|||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"jsxBracketSameLine": true
|
"jsxBracketSameLine": true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ also be set to a strong, random password.
|
|||||||
## Example API Usage
|
## Example API Usage
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
const rep = require('@blockstorage/repertory-js');
|
import * as rep from 'repertory-js';
|
||||||
|
|
||||||
|
|
||||||
// Repertory host settings
|
// Repertory host settings
|
||||||
|
|||||||
15
babel.config.js
Normal file
15
babel.config.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
module.exports = function (api) {
|
||||||
|
api.cache(true);
|
||||||
|
return {
|
||||||
|
presets: [
|
||||||
|
'@babel/preset-env'
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
'@babel/plugin-proposal-class-properties',
|
||||||
|
'@babel/plugin-proposal-private-methods',
|
||||||
|
'@babel/plugin-transform-runtime',
|
||||||
|
'@babel/plugin-transform-regenerator',
|
||||||
|
'@babel/plugin-transform-async-to-generator'
|
||||||
|
]
|
||||||
|
};
|
||||||
|
};
|
||||||
72
package.json
72
package.json
@@ -2,9 +2,12 @@
|
|||||||
"name": "@blockstorage/repertory-js",
|
"name": "@blockstorage/repertory-js",
|
||||||
"version": "1.3.1-r1",
|
"version": "1.3.1-r1",
|
||||||
"description": "A Node.js module for interfacing with Repertory's remote mount API",
|
"description": "A Node.js module for interfacing with Repertory's remote mount API",
|
||||||
"scripts": {
|
"author": "scott.e.graves@protonmail.com",
|
||||||
"test": "jest",
|
"license": "MIT",
|
||||||
"coverage": "jest --collect-coverage"
|
"homepage": "https://bitbucket.org/blockstorage/repertory-js",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://bitbucket.org/blockstorage/repertory-js.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"repertory",
|
"repertory",
|
||||||
@@ -20,47 +23,40 @@
|
|||||||
"altcoin",
|
"altcoin",
|
||||||
"cryptocurrency"
|
"cryptocurrency"
|
||||||
],
|
],
|
||||||
"author": "scott.e.graves@protonmail.com",
|
"main": "dist/mjs/repertory-js.mjs",
|
||||||
"homepage": "https://bitbucket.org/blockstorage/repertory-js",
|
"module": "dist/mjs/repertory-js.mjs",
|
||||||
"license": "MIT",
|
"files": [
|
||||||
|
"dist/mjs"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"build": "rollup -c",
|
||||||
|
"test": "jest",
|
||||||
|
"prepublish": "rollup -c --silent"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.13.9",
|
|
||||||
"int64-buffer": "^1.0.0",
|
"int64-buffer": "^1.0.0",
|
||||||
"js-sha256": "^0.9.0",
|
|
||||||
"socket-pool": "^1.2.3",
|
"socket-pool": "^1.2.3",
|
||||||
"text-encoding": "^0.7.0",
|
"text-encoding": "^0.7.0",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/plugin-transform-runtime": "^7.13.9",
|
"@babel/core": "^7.14.3",
|
||||||
"@babel/preset-env": "^7.13.9",
|
"@babel/plugin-proposal-class-properties": "^7.13.0",
|
||||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
"@babel/plugin-proposal-private-methods": "^7.13.0",
|
||||||
"eslint": "^7.22.0",
|
"@babel/plugin-transform-async-to-generator": "^7.13.0",
|
||||||
"eslint-plugin-jest": "^24.3.2",
|
"@babel/plugin-transform-regenerator": "^7.13.15",
|
||||||
"jest": "^26.6.3"
|
"@babel/plugin-transform-runtime": "^7.14.3",
|
||||||
},
|
"@babel/preset-env": "^7.14.2",
|
||||||
"type": "module",
|
"@rollup/plugin-babel": "^5.3.0",
|
||||||
"jest": {
|
"@rollup/plugin-commonjs": "^15.1.0",
|
||||||
"roots": [
|
"@rollup/plugin-json": "^4.0.0",
|
||||||
"src"
|
"@rollup/plugin-node-resolve": "^9.0.0",
|
||||||
],
|
"@types/jest": "^26.0.23",
|
||||||
"modulePaths": [
|
"babel-eslint": "^10.1.0",
|
||||||
"src"
|
"jest": "^26.6.3",
|
||||||
],
|
"rollup": "^2.50.0",
|
||||||
"moduleDirectories": [
|
"rollup-plugin-eslint": "^7.0.0",
|
||||||
"node_modules"
|
"rollup-plugin-node-polyfills": "^0.2.1",
|
||||||
],
|
"rollup-plugin-terser": "^7.0.2"
|
||||||
"testMatch": [
|
|
||||||
"**/__tests__/**/*.[jt]s?(x)",
|
|
||||||
"**/?(*.)+(spec|test).[jt]s?(x)"
|
|
||||||
],
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.js?$": "babel-jest"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"main": "src/index.js",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://bitbucket.org/blockstorage/repertory-js.git"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
52
rollup.config.js
Normal file
52
rollup.config.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import resolve from "@rollup/plugin-node-resolve";
|
||||||
|
import commonjs from "@rollup/plugin-commonjs";
|
||||||
|
import babel from "@rollup/plugin-babel";
|
||||||
|
import { terser } from "rollup-plugin-terser";
|
||||||
|
import json from '@rollup/plugin-json';
|
||||||
|
|
||||||
|
const commonConfig = {
|
||||||
|
input: 'src/index.js',
|
||||||
|
output: {
|
||||||
|
name: 'repertory-js',
|
||||||
|
sourcemap: true
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
resolve({
|
||||||
|
customResolveOptions: {
|
||||||
|
moduleDirectory: 'node_modules'
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
babel({
|
||||||
|
exclude: 'node_modules/**',
|
||||||
|
babelHelpers: 'runtime'
|
||||||
|
}),
|
||||||
|
commonjs(),
|
||||||
|
json()
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
// ESM config
|
||||||
|
const esmConfig = Object.assign({}, commonConfig);
|
||||||
|
esmConfig.output = Object.assign({}, commonConfig.output, {
|
||||||
|
file: 'dist/mjs/repertory-js.mjs',
|
||||||
|
format: 'esm'
|
||||||
|
});
|
||||||
|
|
||||||
|
// ESM prod config
|
||||||
|
const esmProdConfig = Object.assign({}, esmConfig);
|
||||||
|
esmProdConfig.output = Object.assign({}, esmConfig.output, {
|
||||||
|
file: 'dist/mjs/repertory-js.min.mjs',
|
||||||
|
sourcemap: false
|
||||||
|
});
|
||||||
|
esmProdConfig.plugins = [
|
||||||
|
...esmConfig.plugins,
|
||||||
|
terser()
|
||||||
|
];
|
||||||
|
|
||||||
|
let configurations = [];
|
||||||
|
configurations.push(
|
||||||
|
esmConfig,
|
||||||
|
esmProdConfig
|
||||||
|
)
|
||||||
|
|
||||||
|
export default configurations;
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
import connection from '../networking/connection';
|
import connection from '../networking/connection';
|
||||||
import packet from '../networking/packet';
|
import packet from '../networking/packet';
|
||||||
|
import Socket from 'net';
|
||||||
const Socket = require('net');
|
|
||||||
|
|
||||||
test(`connect fails when error occurs during createConnection`, async () => {
|
test(`connect fails when error occurs during createConnection`, async () => {
|
||||||
const mock_create = (port, host, cb) => {
|
const mock_create = (port, host, cb) => {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { get_version, instance_id, package_json } from '../utils/constants';
|
import {get_version, instance_id, package_json} from '../utils/constants';
|
||||||
|
import * as uuid from 'uuid';
|
||||||
const uuid = require('uuid');
|
|
||||||
|
|
||||||
test(`can read 'package.json'`, () => {
|
test(`can read 'package.json'`, () => {
|
||||||
console.log(package_json);
|
console.log(package_json);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { randomBytes } from 'crypto';
|
import { randomBytes } from 'crypto';
|
||||||
import { Int64BE, Uint64BE } from 'int64-buffer';
|
import {Int64BE, Uint64BE} from 'int64-buffer';
|
||||||
import { sha256 } from 'js-sha256';
|
import crypto from 'crypto';
|
||||||
import { TextEncoder } from 'text-encoding';
|
import {TextEncoder} from 'text-encoding';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
be_ui8_array_to_i16,
|
be_ui8_array_to_i16,
|
||||||
@@ -158,10 +158,10 @@ export default class packet {
|
|||||||
|
|
||||||
decrypt = async () => {
|
decrypt = async () => {
|
||||||
try {
|
try {
|
||||||
const hash = sha256.create();
|
let hash = crypto.createHash('sha256');
|
||||||
hash.update(new TextEncoder().encode(this.token));
|
hash = hash.update(new TextEncoder().encode(this.token));
|
||||||
|
|
||||||
const key = Uint8Array.from(hash.array());
|
const key = Uint8Array.from(hash.digest());
|
||||||
const nonce = this.buffer.slice(0, 12);
|
const nonce = this.buffer.slice(0, 12);
|
||||||
|
|
||||||
this.buffer = new JSChaCha20(key, nonce, 0).decrypt(
|
this.buffer = new JSChaCha20(key, nonce, 0).decrypt(
|
||||||
@@ -270,10 +270,10 @@ export default class packet {
|
|||||||
encrypt = async (nonce) => {
|
encrypt = async (nonce) => {
|
||||||
try {
|
try {
|
||||||
this.push_buffer(packet.HEADER);
|
this.push_buffer(packet.HEADER);
|
||||||
const hash = sha256.create();
|
let hash = crypto.createHash('sha256');
|
||||||
hash.update(new TextEncoder().encode(this.token));
|
hash = hash.update(new TextEncoder().encode(this.token));
|
||||||
|
|
||||||
const key = Uint8Array.from(hash.array());
|
const key = Uint8Array.from(hash.digest());
|
||||||
if (!nonce) {
|
if (!nonce) {
|
||||||
nonce = Uint8Array.from(randomBytes(12));
|
nonce = Uint8Array.from(randomBytes(12));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const { v4: uuidv4 } = require('uuid');
|
import {v4 as uuidv4} from 'uuid';
|
||||||
import _package_json from '../../package.json';
|
import _package_json from '../../package.json';
|
||||||
|
|
||||||
export const instance_id = uuidv4();
|
export const instance_id = uuidv4();
|
||||||
|
|||||||
Reference in New Issue
Block a user