Compare commits

..

24 Commits

Author SHA1 Message Date
64d85e711a 4.0.7 2023-06-26 10:01:24 +02:00
34a5cc9862 fix(core): update 2023-06-26 10:01:23 +02:00
d43d1ba212 4.0.6 2023-06-26 09:57:32 +02:00
65e771f1ba fix(core): update 2023-06-26 09:57:32 +02:00
5825a602ed 4.0.5 2022-09-13 19:23:11 +02:00
5e961f7a5b fix(core): update 2022-09-13 19:23:11 +02:00
36bcb9265a 4.0.4 2022-09-13 19:13:04 +02:00
53bf2f3569 fix(core): update 2022-09-13 19:13:04 +02:00
523ab7ee77 4.0.3 2022-09-13 18:47:19 +02:00
d60cc5430f fix(core): update 2022-09-13 18:47:19 +02:00
c0035bb4f3 4.0.2 2022-03-24 19:57:09 +01:00
976f81420f fix(core): update 2022-03-24 19:57:09 +01:00
1be144d099 4.0.1 2022-03-18 23:15:02 +01:00
9d4b7a5292 4.0.0 2022-03-18 23:05:32 +01:00
563d6f0ac3 3.0.26 2022-03-18 22:52:38 +01:00
4da0aeb871 fix(core): update 2022-03-18 22:52:38 +01:00
931defe98a 3.0.25 2022-03-18 22:50:25 +01:00
1e6077ce34 fix(core): update 2022-03-18 22:50:24 +01:00
8b1769d65e 3.0.24 2021-01-22 18:27:51 +00:00
48878c0b38 fix(core): update 2021-01-22 18:27:50 +00:00
76cfc8bec0 3.0.23 2021-01-22 14:46:04 +00:00
7f3118c525 fix(core): update 2021-01-22 14:46:02 +00:00
9d189d1b59 3.0.22 2020-12-31 04:42:47 +00:00
0266afca8e fix(core): update 2020-12-31 04:42:46 +00:00
32 changed files with 4980 additions and 11248 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,109 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @shipzone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm prepare
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @gitzone/tsdoc
npmci command tsdoc
continue-on-error: true

View File

@ -12,20 +12,12 @@ stages:
- release - release
- metadata - metadata
before_script:
- npm install -g @shipzone/npmci
# ==================== # ====================
# security stage # security stage
# ==================== # ====================
mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
auditProductionDependencies: auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
@ -36,6 +28,7 @@ auditProductionDependencies:
- npmci command npm audit --audit-level=high --only=prod --production - npmci command npm audit --audit-level=high --only=prod --production
tags: tags:
- docker - docker
allow_failure: true
auditDevDependencies: auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
@ -96,10 +89,9 @@ codequality:
only: only:
- tags - tags
script: script:
- npmci command npm install -g tslint typescript - npmci command npm install -g typescript
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags: tags:
- lossless - lossless
- docker - docker
@ -119,11 +111,10 @@ trigger:
pages: pages:
stage: metadata stage: metadata
script: script:
- npmci node install lts - npmci node install stable
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command tsdoc - npmci command npm run buildDocs
tags: tags:
- lossless - lossless
- docker - docker

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: {}

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "current file", "command": "npm test",
"type": "node", "name": "Run npm test",
"request": "launch", "request": "launch",
"args": [ "type": "node-terminal"
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
} }
] ]
} }

View File

View File

@ -14,7 +14,7 @@
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "pushrocks",
"gitrepo": "smartstring", "gitrepo": "smartstring",
"shortDescription": "handle strings in smart ways. TypeScript ready.", "description": "handle strings in smart ways. TypeScript ready.",
"npmPackagename": "@pushrocks/smartstring", "npmPackagename": "@pushrocks/smartstring",
"license": "MIT" "license": "MIT"
} }

11050
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,15 @@
{ {
"name": "@pushrocks/smartstring", "name": "@pushrocks/smartstring",
"version": "3.0.21", "version": "4.0.7",
"private": false, "private": false,
"description": "handle strings in smart ways. TypeScript ready.", "description": "handle strings in smart ways. TypeScript ready.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild --web)" "build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -24,22 +26,25 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartstring#readme", "homepage": "https://gitlab.com/pushrocks/smartstring#readme",
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.66",
"@gitzone/tsrun": "^1.2.12", "@gitzone/tsrun": "^1.2.42",
"@gitzone/tstest": "^1.0.52", "@gitzone/tstest": "^1.0.74",
"@pushrocks/tapbundle": "^3.2.9", "@pushrocks/tapbundle": "^5.0.8",
"@types/node": "^14.14.17", "@types/node": "^20.3.1",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/isounique": "^1.0.4", "@pushrocks/isounique": "^1.0.5",
"@pushrocks/smartenv": "^4.0.16", "@pushrocks/smartenv": "^5.0.5",
"js-base64": "^2.5.1", "@types/randomatic": "^3.1.3",
"normalize-newline": "^3.0.0", "buffer": "^6.0.3",
"crypto-random-string": "^5.0.0",
"js-base64": "^3.7.5",
"normalize-newline": "^4.1.0",
"randomatic": "^3.1.1", "randomatic": "^3.1.1",
"strip-indent": "^3.0.0", "strip-indent": "^4.0.0",
"url": "^0.11.0" "url": "^0.11.1"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

4657
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,6 @@ Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](htt
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartstring)](https://lossless.cloud) PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartstring)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartstring)](https://lossless.cloud) PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartstring)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartstring)](https://lossless.cloud) BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartstring)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage ## Usage
@ -71,7 +70,6 @@ We are always happy for code contributions. If you are not the code contributing
For further information read the linked docs at the top of this readme. For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) ## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,16 +1,23 @@
import * as smartstring from '../ts/index'; import * as smartstring from '../ts/index.js';
import { tap, expect } from '@pushrocks/tapbundle'; import { tap, expect } from '@pushrocks/tapbundle';
// Base64 // Base64
let testBase64: smartstring.Base64; let testBase64: smartstring.Base64;
tap.test('expect create a valid instance of Base64', async () => { tap.test('expect create a valid instance of Base64', async () => {
testBase64 = new smartstring.Base64('somestring', 'string'); 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 () => { 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'); let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri');
expect(testBase64_2.simpleString).equal(testBase64.simpleString); expect(testBase64_2.simpleString).toEqual(testBase64.simpleString);
});
tap.test('should test for a valid base64 token', async () => {
const result = smartstring.base64.isBase64('dGVzdA==');
expect(result).toBeTrue();
}); });
tap.start(); 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'; import { tap, expect } from '@pushrocks/tapbundle';
// Docker // Docker
tap.test('expect create a Env Object', async () => { tap.test('expect create a Env Object', async () => {
let envStringArray = ['VIRTUAL_HOST=sub.domain.tld', 'DEFAULT_HOST=some.domain.com']; let envStringArray = ['VIRTUAL_HOST=sub.domain.tld', 'DEFAULT_HOST=some.domain.com'];
let envObject: any = smartstring.docker.makeEnvObject(envStringArray); let envObject: any = smartstring.docker.makeEnvObject(envStringArray);
expect(envObject.VIRTUAL_HOST).to.equal('sub.domain.tld'); expect(envObject.VIRTUAL_HOST).toEqual('sub.domain.tld');
expect(envObject.DEFAULT_HOST).to.equal('some.domain.com'); expect(envObject.DEFAULT_HOST).toEqual('some.domain.com');
}); });
tap.start(); 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'; import { tap, expect } from '@pushrocks/tapbundle';
// Domain // Domain
@ -6,26 +6,31 @@ let testDomain: smartstring.Domain;
let testDomain2: smartstring.Domain; let testDomain2: smartstring.Domain;
tap.test('expect create a new Domain object', async () => { tap.test('expect create a new Domain object', async () => {
testDomain = new smartstring.Domain('https://level3D.level2D.level1D'); testDomain = new smartstring.Domain('https://level3D.level2D.level1D');
expect(testDomain).be.instanceof(smartstring.Domain); expect(testDomain).toBeInstanceOf(smartstring.Domain);
console.log(testDomain); console.log(testDomain);
}); });
tap.test('expect have a .topLevel', async () => { tap.test('expect have a .topLevel', async () => {
expect(testDomain.topLevel).equal('level1D'); expect(testDomain.topLevel).toEqual('level1D');
}); });
tap.test('expect have a .level2', async () => { tap.test('expect have a .level2', async () => {
expect(testDomain.level2).equal('level2D'); expect(testDomain.level2).toEqual('level2D');
}); });
tap.test('expect have a .level3', async () => { 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 () => { 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 () => { 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 () => { tap.test('testDomain2 expect be a basic domain', async () => {
testDomain2 = new smartstring.Domain('bleu.de'); testDomain2 = new smartstring.Domain('testing.bleu.de');
console.log(testDomain2);
});
tap.test('should parse complex domains', async () => {
testDomain2 = new smartstring.Domain('https://sub1.sub2.lossless.com/some/path:5431');
console.log(testDomain2); console.log(testDomain2);
}); });

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'; import { tap, expect } from '@pushrocks/tapbundle';
// git // git
let testGit: smartstring.GitRepo; let testGit: smartstring.GitRepo;
tap.test('expect create a new Git class GitRepo', async () => { tap.test('expect create a new Git class GitRepo', async () => {
testGit = new smartstring.GitRepo('git+https://github.com/pushrocks/smartstring.git'); 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 () => { 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 () => { tap.test('expect return a .user', async () => {
expect(testGit.user).equal('pushrocks'); expect(testGit.user).toEqual('pushrocks');
}); });
tap.test('expect return a .repo', async () => { tap.test('expect return a .repo', async () => {
expect(testGit.repo).equal('smartstring'); expect(testGit.repo).toEqual('smartstring');
}); });
tap.test('expect return a .httpsUrl', async () => { 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 () => { 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(); 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'; import { tap, expect } from '@pushrocks/tapbundle';
// indent // indent

View File

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

View File

@ -1,14 +1,14 @@
import { tap, expect } from '@pushrocks/tapbundle'; 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 () => { 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 () => { tap.test('should state wether base64 string is valid', async () => {
const base64String = smartstring.base64.encode('hi there'); const base64String = smartstring.base64.encode('hi there');
expect(smartstring.type.isBase64(base64String)).to.be.true; expect(smartstring.type.isBase64(base64String)).toBeTrue();
expect(smartstring.type.isBase64('hi there')).to.be.false; expect(smartstring.type.isBase64('hi there')).toBeFalse();
}); });
tap.start(); tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartstring',
version: '4.0.7',
description: 'handle strings in smart ways. TypeScript ready.'
}

View File

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

View File

@ -1,16 +1,16 @@
import * as plugins from './smartstring.plugins'; import * as plugins from './smartstring.plugins.js';
/** /**
* the type for base 64 * the type for base 64
*/ */
export type TBase64Input = 'string' | 'base64' | 'base64uri'; export type TStringInputType = 'string' | 'base64' | 'base64uri';
/** /**
* handle base64 strings * handle base64 strings
*/ */
export class Base64 { export class Base64 {
private refString: string; private refString: string;
constructor(inputStringArg, typeArg: TBase64Input) { constructor(inputStringArg, typeArg: TStringInputType) {
switch (typeArg) { switch (typeArg) {
case 'string': // easiest case case 'string': // easiest case
this.refString = inputStringArg; this.refString = inputStringArg;
@ -66,4 +66,14 @@ export let base64 = {
decode: (stringArg: string) => { decode: (stringArg: string) => {
return plugins.jsBase64.decode(stringArg); return plugins.jsBase64.decode(stringArg);
}, },
/**
*
* @param stringArg
* checks wether the string is base64 encoded
*/
isBase64: (stringArg: string) => {
const regex = /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$/;
return regex.test(stringArg);
},
}; };

View File

@ -1,4 +1,4 @@
import * as plugins from './smartstring.plugins'; import * as plugins from './smartstring.plugins.js';
/** /**
* creates a random string * creates a random string
@ -21,9 +21,9 @@ export const createRandomString = (
}; };
/** /**
* creates a cryptic string in the speicifed length * creates a crytic string in the speicifed length
* @param lengthArg the length of the crypto string * @param lengthArg the length of the crypto string
*/ */
export const createCryptoRandomString = (lengthArg: number): string => { export const createCryptoRandomString = (): string => {
return plugins.isounique.uni(); 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. * 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 { export class Domain {
public fullName: string; public fullName: string;
@ -16,7 +16,18 @@ export class Domain {
public port; public port;
public nodeParsedUrl: plugins.url.UrlWithStringQuery; public nodeParsedUrl: plugins.url.UrlWithStringQuery;
constructor(domainStringArg: string) { constructor(domainStringArg: string) {
const regexMatches = this._domainRegex(domainStringArg); // lets do the node standard stuff first
this.protocol = this._protocolRegex(domainStringArg);
if (!this.protocol) {
domainStringArg = `https://${domainStringArg}`;
}
this.nodeParsedUrl = plugins.url.parse(domainStringArg);
this.port = this.nodeParsedUrl.port;
// lets do the rest after
const regexMatches = this._domainRegex(
domainStringArg.replace(this.nodeParsedUrl.pathname, '')
);
this.fullName = ''; this.fullName = '';
for (let i = 1; i <= 5; i++) { for (let i = 1; i <= 5; i++) {
if (regexMatches[i - 1]) { if (regexMatches[i - 1]) {
@ -31,23 +42,20 @@ export class Domain {
this['level' + i.toString()] = undefined; this['level' + i.toString()] = undefined;
} }
} }
this.protocol = this._protocolRegex(domainStringArg);
this.zoneName = this.level2 + '.' + this.level1; this.zoneName = this.level2 + '.' + this.level1;
// aliases // aliases
this.topLevel = this.level1; this.topLevel = this.level1;
this.domainName = this.level2; this.domainName = this.level2;
this.subDomain = this.level3; this.subDomain = this.level3;
this.nodeParsedUrl = plugins.url.parse(domainStringArg);
this.port = this.nodeParsedUrl.port;
} }
// helper functions // helper functions
/** */ /** */
private _domainRegex(stringArg: string) { private _domainRegex(stringArg: string) {
const regexString = /([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}$/; const regexString =
/([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}$/;
const regexMatches = regexString.exec(stringArg); const regexMatches = regexString.exec(stringArg);
regexMatches.reverse(); //make sure we build the domain from toplevel to subdomain (reversed order) regexMatches.reverse(); //make sure we build the domain from toplevel to subdomain (reversed order)
regexMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements regexMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements

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 ------------------- * * ------------------ classes ------------------- *
@ -25,7 +25,8 @@ export class GitRepo {
* ------------------ helpers ------------------- * * ------------------ helpers ------------------- *
* ---------------------------------------------- */ * ---------------------------------------------- */
const gitRegex = function (stringArg: string) { const gitRegex = function (stringArg: string) {
const regexString = /([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-\.]*)(?:\/)([a-zA-Z0-9\-\.]*)(?:\.git)/; const regexString =
/([a-zA-Z0-9\-_\.]*)(?:\/|\:)([a-zA-Z0-9\-_\.]*)(?:\/)([a-zA-Z0-9\-_\.]*)(?:\.git)/;
let regexMatches = regexString.exec(stringArg); let regexMatches = regexString.exec(stringArg);
return regexMatches; return regexMatches;
}; };

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 * 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 * replaces all occurences of something in a string

View File

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

View File

@ -1,5 +1,5 @@
import * as plugins from './smartstring.plugins'; import * as plugins from './smartstring.plugins.js';
import * as base64 from './smartstring.base64'; import * as base64 from './smartstring.base64.js';
export const isUtf8 = (stringArg: string) => { export const isUtf8 = (stringArg: string) => {
const bytes = Buffer.from(stringArg); 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"
}