fix(core): update

This commit is contained in:
Philipp Kunz 2022-03-18 22:50:24 +01:00
parent 8b1769d65e
commit 1e6077ce34
25 changed files with 15372 additions and 7452 deletions

4
.snyk
View File

@ -1,4 +0,0 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.13.5
ignore: {}
patch: {}

View File

@ -22,5 +22,6 @@
}
}
}
]
],
"typescript.tsdk": "node_modules/typescript/lib"
}

22
LICENSE
View File

@ -1,22 +0,0 @@
The MIT License (MIT)
Copyright (c) 2014 Maurice Butler
Copyright (c) 2016 Lossless GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

22585
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,9 +5,10 @@
"description": "handle strings in smart ways. TypeScript ready.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild --web)"
"build": "(tsbuild --web --allowimplicitany)"
},
"repository": {
"type": "git",
@ -24,21 +25,24 @@
},
"homepage": "https://gitlab.com/pushrocks/smartstring#readme",
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.14.17",
"@gitzone/tsbuild": "^2.1.59",
"@gitzone/tsrun": "^1.2.31",
"@gitzone/tstest": "^1.0.69",
"@pushrocks/tapbundle": "^5.0.2",
"@types/node": "^17.0.21",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@pushrocks/smartenv": "^4.0.16",
"crypto-random-string": "^3.3.0",
"js-base64": "^2.5.1",
"normalize-newline": "^3.0.0",
"@pushrocks/isounique": "^1.0.5",
"@pushrocks/smartenv": "^5.0.0",
"@types/randomatic": "^3.1.3",
"buffer": "^6.0.3",
"crypto-random-string": "^4.0.0",
"js-base64": "^3.7.2",
"normalize-newline": "^4.1.0",
"randomatic": "^3.1.1",
"strip-indent": "^3.0.0",
"strip-indent": "^4.0.0",
"url": "^0.11.0"
},
"files": [

View File

@ -1,16 +1,16 @@
import * as smartstring from '../ts/index';
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@pushrocks/tapbundle';
// Base64
let testBase64: smartstring.Base64;
tap.test('expect create a valid instance of Base64', async () => {
testBase64 = new smartstring.Base64('somestring', 'string');
expect(testBase64).be.instanceOf(smartstring.Base64);
expect(testBase64).toBeInstanceOf(smartstring.Base64);
});
tap.test('expect read output a file as base64 and base64uri', async () => {
expect(testBase64.base64String).not.equal(testBase64.base64UriString);
expect(testBase64.base64String).not.toEqual(testBase64.base64UriString);
let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri');
expect(testBase64_2.simpleString).equal(testBase64.simpleString);
expect(testBase64_2.simpleString).toEqual(testBase64.simpleString);
});
tap.start();

View File

@ -1,12 +1,12 @@
import * as smartstring from '../ts/index';
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@pushrocks/tapbundle';
// Docker
tap.test('expect create a Env Object', async () => {
let envStringArray = ['VIRTUAL_HOST=sub.domain.tld', 'DEFAULT_HOST=some.domain.com'];
let envObject: any = smartstring.docker.makeEnvObject(envStringArray);
expect(envObject.VIRTUAL_HOST).to.equal('sub.domain.tld');
expect(envObject.DEFAULT_HOST).to.equal('some.domain.com');
expect(envObject.VIRTUAL_HOST).toEqual('sub.domain.tld');
expect(envObject.DEFAULT_HOST).toEqual('some.domain.com');
});
tap.start();

View File

@ -1,4 +1,4 @@
import * as smartstring from '../ts/index';
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@pushrocks/tapbundle';
// Domain
@ -6,23 +6,23 @@ let testDomain: smartstring.Domain;
let testDomain2: smartstring.Domain;
tap.test('expect create a new Domain object', async () => {
testDomain = new smartstring.Domain('https://level3D.level2D.level1D');
expect(testDomain).be.instanceof(smartstring.Domain);
expect(testDomain).toBeInstanceOf(smartstring.Domain);
console.log(testDomain);
});
tap.test('expect have a .topLevel', async () => {
expect(testDomain.topLevel).equal('level1D');
expect(testDomain.topLevel).toEqual('level1D');
});
tap.test('expect have a .level2', async () => {
expect(testDomain.level2).equal('level2D');
expect(testDomain.level2).toEqual('level2D');
});
tap.test('expect have a .level3', async () => {
expect(testDomain.level3).equal('level3D');
expect(testDomain.level3).toEqual('level3D');
});
tap.test('expect have the correct dns zone name', async () => {
expect(testDomain.zoneName).equal('level2D.level1D');
expect(testDomain.zoneName).toEqual('level2D.level1D');
});
tap.test('expect have the correct protocol', async () => {
expect(testDomain.protocol).equal('https');
expect(testDomain.protocol).toEqual('https');
});
tap.test('testDomain2 expect be a basic domain', async () => {
testDomain2 = new smartstring.Domain('testing.bleu.de');

View File

@ -1,26 +1,26 @@
import * as smartstring from '../ts/index';
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@pushrocks/tapbundle';
// git
let testGit: smartstring.GitRepo;
tap.test('expect create a new Git class GitRepo', async () => {
testGit = new smartstring.GitRepo('git+https://github.com/pushrocks/smartstring.git');
expect(testGit).be.instanceof(smartstring.GitRepo);
expect(testGit).toBeInstanceOf(smartstring.GitRepo);
});
tap.test('expect return a .host', async () => {
expect(testGit.host).equal('github.com');
expect(testGit.host).toEqual('github.com');
});
tap.test('expect return a .user', async () => {
expect(testGit.user).equal('pushrocks');
expect(testGit.user).toEqual('pushrocks');
});
tap.test('expect return a .repo', async () => {
expect(testGit.repo).equal('smartstring');
expect(testGit.repo).toEqual('smartstring');
});
tap.test('expect return a .httpsUrl', async () => {
expect(testGit.httpsUrl).equal('https://github.com/pushrocks/smartstring.git');
expect(testGit.httpsUrl).toEqual('https://github.com/pushrocks/smartstring.git');
});
tap.test('expect return a .sshUrl', async () => {
expect(testGit.sshUrl).equal('git@github.com:pushrocks/smartstring.git');
expect(testGit.sshUrl).toEqual('git@github.com:pushrocks/smartstring.git');
});
tap.start();

View File

@ -1,4 +1,4 @@
import * as smartstring from '../ts/index';
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@pushrocks/tapbundle';
// indent

View File

@ -1,6 +1,6 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as smartstring from '../ts/index';
import * as smartstring from '../ts/index.js';
tap.test('should normalize a string', async () => {
const testString = `
@ -8,7 +8,7 @@ tap.test('should normalize a string', async () => {
is indented with two spaces
`;
const normalizedString = smartstring.normalize.standard(testString);
expect(normalizedString).to.equal(
expect(normalizedString).toEqual(
`
myawesome string;
is indented with two spaces

View File

@ -1,14 +1,14 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as smartstring from '../ts';
import * as smartstring from '../ts/index.js';
tap.test('should state valuid utf8', async () => {
expect(smartstring.type.isUtf8('hithere')).to.be.true;
expect(smartstring.type.isUtf8('hithere')).toBeTrue();
});
tap.test('should state wether base64 string is valid', async () => {
const base64String = smartstring.base64.encode('hi there');
expect(smartstring.type.isBase64(base64String)).to.be.true;
expect(smartstring.type.isBase64('hi there')).to.be.false;
expect(smartstring.type.isBase64(base64String)).toBeTrue();
expect(smartstring.type.isBase64('hi there')).toBeFalse();
});
tap.start();

View File

@ -1,13 +1,11 @@
import * as create from './smartstring.create';
import * as docker from './smartstring.docker';
import * as indent from './smartstring.indent';
import * as normalize from './smartstring.normalize';
import * as type from './smartstring.type';
import * as create from './smartstring.create.js';
import * as docker from './smartstring.docker.js';
import * as indent from './smartstring.indent.js';
import * as normalize from './smartstring.normalize.js';
import * as type from './smartstring.type.js';
export { create, docker, normalize, indent, type };
export { Base64, base64 } from './smartstring.base64';
export { Domain } from './smartstring.domain';
export { GitRepo } from './smartstring.git';
export { Cryptr } from './smartstring.encryption';
export { Base64, base64 } from './smartstring.base64.js';
export { Domain } from './smartstring.domain.js';
export { GitRepo } from './smartstring.git.js';

View File

@ -1,4 +1,4 @@
import * as plugins from './smartstring.plugins';
import * as plugins from './smartstring.plugins.js';
/**
* the type for base 64

View File

@ -1,4 +1,4 @@
import * as plugins from './smartstring.plugins';
import * as plugins from './smartstring.plugins.js';
/**
* creates a random string
@ -24,6 +24,6 @@ export const createRandomString = (
* creates a crytic string in the speicifed length
* @param lengthArg the length of the crypto string
*/
export const createCryptoRandomString = (lengthArg: number): string => {
return plugins.cryptoRandomString(lengthArg);
export const createCryptoRandomString = (): string => {
return plugins.isounique.uni();
};

View File

@ -1,4 +1,4 @@
import * as plugins from './smartstring.plugins';
import * as plugins from './smartstring.plugins.js';
/**
* converts an erray of env strings from docker remote api to an usable object.

View File

@ -1,4 +1,4 @@
import * as plugins from './smartstring.plugins';
import * as plugins from './smartstring.plugins.js';
export class Domain {
public fullName: string;

View File

@ -1,40 +0,0 @@
import * as plugins from './smartstring.plugins';
const algorithm = 'aes-256-ctr';
export class Cryptr {
private key: Buffer;
constructor(secret) {
if (!secret || typeof secret !== 'string') {
throw new Error('Cryptr: secret must be a non-0-length string');
}
this.key = plugins.crypto.createHash('sha256').update(String(secret)).digest();
}
encrypt(value: string) {
if (value == null) {
throw new Error('value must not be null or undefined');
}
const iv = plugins.crypto.randomBytes(16);
const cipher = plugins.crypto.createCipheriv(algorithm, this.key, iv);
const encrypted = cipher.update(String(value), 'utf8', 'hex') + cipher.final('hex');
return iv.toString('hex') + encrypted;
}
decrypt(value: string) {
if (value == null) {
throw new Error('value must not be null or undefined');
}
const stringValue = String(value);
const iv = Buffer.from(stringValue.slice(0, 32), 'hex');
const encrypted = stringValue.slice(32);
const decipher = plugins.crypto.createDecipheriv(algorithm, this.key, iv);
return decipher.update(encrypted, 'hex', 'utf8') + decipher.final('utf8');
}
}

View File

@ -1,4 +1,4 @@
import * as plugins from './smartstring.plugins';
import * as plugins from './smartstring.plugins.js';
/* ---------------------------------------------- *
* ------------------ classes ------------------- *

View File

@ -1,4 +1,4 @@
import * as plugins from './smartstring.plugins';
import * as plugins from './smartstring.plugins.js';
/**
* splits a string into an array

View File

@ -1,4 +1,4 @@
import * as plugins from './smartstring.plugins';
import * as plugins from './smartstring.plugins.js';
/**
* replaces all occurences of something in a string

View File

@ -1,18 +1,24 @@
// node native
import * as smartenv from '@pushrocks/smartenv';
const smartenvInstance = new smartenv.Smartenv();
const crypto = smartenvInstance.getSafeNodeModule('crypto');
import * as isounique from '@pushrocks/isounique';
export {
isounique
}
import { Buffer } from 'buffer';
if (smartenvInstance.isBrowser) {
globalThis.Buffer = Buffer;
}
import * as url from 'url';
export { crypto, url };
export { url };
// third party
const jsBase64 = require('js-base64').Base64;
import { Base64 as jsBase64 } from 'js-base64';
const stripIndent = require('strip-indent');
const normalizeNewline = require('normalize-newline');
const randomatic = smartenvInstance.getSafeNodeModule('randomatic');
const cryptoRandomString = smartenvInstance.getSafeNodeModule('crypto-random-string');
import stripIndent from 'strip-indent';
import normalizeNewline from 'normalize-newline';
import randomatic from 'randomatic';
export { jsBase64, stripIndent, normalizeNewline, randomatic, cryptoRandomString };
export { jsBase64, stripIndent, normalizeNewline, randomatic };

View File

@ -1,5 +1,5 @@
import * as plugins from './smartstring.plugins';
import * as base64 from './smartstring.base64';
import * as plugins from './smartstring.plugins.js';
import * as base64 from './smartstring.base64.js';
export const isUtf8 = (stringArg: string) => {
const bytes = Buffer.from(stringArg);

7
tsconfig.json Normal file
View File

@ -0,0 +1,7 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext"
}
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}