Добавлены пакеты base-x, pako, safe-buffer
This commit is contained in:
@@ -6,9 +6,11 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
import Vue from 'vue';
|
||||
import Component from 'vue-class-component';
|
||||
import {Buffer} from 'safe-buffer';
|
||||
|
||||
import bookManager from '../share/bookManager';
|
||||
import readerApi from '../../../api/reader';
|
||||
import * as utils from '../../../share/utils';
|
||||
|
||||
export default @Component({
|
||||
})
|
||||
@@ -18,10 +20,6 @@ class ServerStorage extends Vue {
|
||||
}
|
||||
|
||||
async init() {
|
||||
/*const items = {
|
||||
'1': {rev: 1, data: 1},
|
||||
};
|
||||
console.log(await readerApi.storageSet(items));*/
|
||||
}
|
||||
|
||||
get settings() {
|
||||
|
||||
@@ -1,21 +1,34 @@
|
||||
import baseX from 'base-x';
|
||||
import PAKO from 'pako';
|
||||
import {Buffer} from 'safe-buffer';
|
||||
|
||||
export const pako = PAKO;
|
||||
|
||||
const BASE58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
||||
const BASE64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||
const bs58 = baseX(BASE58);
|
||||
const bs64 = baseX(BASE64);
|
||||
|
||||
export function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
export function stringToHex(str) {
|
||||
let result = '';
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
result += str.charCodeAt(i).toString(16);
|
||||
}
|
||||
return result;
|
||||
return Buffer.from(str).toString('hex');
|
||||
}
|
||||
|
||||
export function hexToString(str) {
|
||||
let result = '';
|
||||
for (let i = 0; i < str.length; i += 2) {
|
||||
result += String.fromCharCode(parseInt(str.substr(i, 2), 16));
|
||||
}
|
||||
return result;
|
||||
return Buffer.from(str, 'hex').toString();
|
||||
}
|
||||
|
||||
export function randomArray(len) {
|
||||
const a = new Uint8Array(len);
|
||||
crypto.getRandomValues(a);
|
||||
return a;
|
||||
}
|
||||
|
||||
export function randomHexString(len) {
|
||||
return Buffer.from(randomArray(len)).toString('hex');
|
||||
}
|
||||
|
||||
export function formatDate(d, format) {
|
||||
@@ -63,3 +76,19 @@ export async function copyTextToClipboard(text) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export function toBase58(data) {
|
||||
return bs58.encode(data);
|
||||
}
|
||||
|
||||
export function fromBase58(data) {
|
||||
return bs58.decode(data);
|
||||
}
|
||||
|
||||
export function toBase64(data) {
|
||||
return bs64.encode(data);
|
||||
}
|
||||
|
||||
export function fromBase64(data) {
|
||||
return bs64.decode(data);
|
||||
}
|
||||
|
||||
17
package-lock.json
generated
17
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Liberama",
|
||||
"version": "0.5.2",
|
||||
"version": "0.5.6",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@@ -1596,6 +1596,14 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"base-x": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.5.tgz",
|
||||
"integrity": "sha512-C3picSgzPSLE+jW3tcBzJoGwitOtazb5B+5YmAxZm2ybmTi9LNgAtDO/jjVEBZwHoXmDBZ9m/IELj3elJVRBcA==",
|
||||
"requires": {
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"base64-js": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
|
||||
@@ -7144,10 +7152,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"pako": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.7.tgz",
|
||||
"integrity": "sha512-3HNK5tW4x8o5mO8RuHZp3Ydw9icZXx0RANAOMzlMzx7LVXhMJ4mo3MOBpzyd7r/+RUu8BmndP47LXT+vzjtWcQ==",
|
||||
"dev": true
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/pako/-/pako-1.0.10.tgz",
|
||||
"integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw=="
|
||||
},
|
||||
"parallel-transform": {
|
||||
"version": "1.1.0",
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0",
|
||||
"base-x": "^3.0.5",
|
||||
"chardet": "^0.7.0",
|
||||
"compression": "^1.7.3",
|
||||
"element-ui": "^2.4.11",
|
||||
@@ -70,7 +71,9 @@
|
||||
"lodash": "^4.17.11",
|
||||
"minimist": "^1.2.0",
|
||||
"multer": "^1.4.1",
|
||||
"pako": "^1.0.10",
|
||||
"path-browserify": "^1.0.0",
|
||||
"safe-buffer": "^5.1.2",
|
||||
"sql-template-strings": "^2.2.2",
|
||||
"sqlite": "^3.0.0",
|
||||
"tar-fs": "^2.0.0",
|
||||
|
||||
Reference in New Issue
Block a user