@privateaim/kit 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE +202 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/domains/index.d.ts +2 -0
- package/dist/domains/index.d.ts.map +1 -0
- package/dist/domains/permission/constants.d.ts +88 -0
- package/dist/domains/permission/constants.d.ts.map +1 -0
- package/dist/domains/permission/index.d.ts +2 -0
- package/dist/domains/permission/index.d.ts.map +1 -0
- package/dist/index.cjs +243 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +225 -0
- package/dist/index.mjs.map +1 -0
- package/dist/utils/boolean.d.ts +4 -0
- package/dist/utils/boolean.d.ts.map +1 -0
- package/dist/utils/error.d.ts +2 -0
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/has-own-property.d.ts +3 -0
- package/dist/utils/has-own-property.d.ts.map +1 -0
- package/dist/utils/hex-checker.d.ts +3 -0
- package/dist/utils/hex-checker.d.ts.map +1 -0
- package/dist/utils/hostname.d.ts +2 -0
- package/dist/utils/hostname.d.ts.map +1 -0
- package/dist/utils/index.d.ts +10 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/nanoid.d.ts +4 -0
- package/dist/utils/nanoid.d.ts.map +1 -0
- package/dist/utils/object-properties.d.ts +3 -0
- package/dist/utils/object-properties.d.ts.map +1 -0
- package/dist/utils/proxy-connection-string.d.ts +12 -0
- package/dist/utils/proxy-connection-string.d.ts.map +1 -0
- package/dist/utils/regex-patterns.d.ts +3 -0
- package/dist/utils/regex-patterns.d.ts.map +1 -0
- package/package.json +41 -0
- package/rollup.config.mjs +19 -0
- package/src/constants.ts +12 -0
- package/src/domains/index.ts +8 -0
- package/src/domains/permission/constants.ts +46 -0
- package/src/domains/permission/index.ts +8 -0
- package/src/index.ts +10 -0
- package/src/utils/boolean.ts +18 -0
- package/src/utils/error.ts +12 -0
- package/src/utils/has-own-property.ts +19 -0
- package/src/utils/hex-checker.ts +22 -0
- package/src/utils/hostname.ts +18 -0
- package/src/utils/index.ts +16 -0
- package/src/utils/nanoid.ts +23 -0
- package/src/utils/object-properties.ts +31 -0
- package/src/utils/proxy-connection-string.ts +64 -0
- package/src/utils/regex-patterns.ts +9 -0
- package/tsconfig.build.json +11 -0
- package/tsconfig.json +3 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { PermissionName } from '@authup/core-kit';
|
|
2
|
+
import { customAlphabet } from 'nanoid';
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright (c) 2021-2024.
|
|
6
|
+
* Author Peter Placzek (tada5hi)
|
|
7
|
+
* For the full copyright and license information,
|
|
8
|
+
* view the LICENSE file that was distributed with this source code.
|
|
9
|
+
*/ function _define_property(obj, key, value) {
|
|
10
|
+
if (key in obj) {
|
|
11
|
+
Object.defineProperty(obj, key, {
|
|
12
|
+
value: value,
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
obj[key] = value;
|
|
19
|
+
}
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
function _object_spread(target) {
|
|
23
|
+
for(var i = 1; i < arguments.length; i++){
|
|
24
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
25
|
+
var ownKeys = Object.keys(source);
|
|
26
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
27
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
28
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
ownKeys.forEach(function(key) {
|
|
32
|
+
_define_property(target, key, source[key]);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
}
|
|
37
|
+
var PermissionKey;
|
|
38
|
+
(function(PermissionKey) {
|
|
39
|
+
PermissionKey["BUCKET_ADD"] = "bucket_add";
|
|
40
|
+
PermissionKey["BUCKET_EDIT"] = "bucket_edit";
|
|
41
|
+
PermissionKey["BUCKET_DROP"] = "bucket_drop";
|
|
42
|
+
PermissionKey["PROJECT_ADD"] = "project_add";
|
|
43
|
+
PermissionKey["PROJECT_DROP"] = "project_drop";
|
|
44
|
+
PermissionKey["PROJECT_EDIT"] = "project_edit";
|
|
45
|
+
PermissionKey["PROJECT_APPROVE"] = "project_approve";
|
|
46
|
+
PermissionKey["REGISTRY_MANAGE"] = "registry_manage";
|
|
47
|
+
PermissionKey["REGISTRY_PROJECT_MANAGE"] = "registry_project_manage";
|
|
48
|
+
PermissionKey["NODE_ADD"] = "node_add";
|
|
49
|
+
PermissionKey["NODE_DROP"] = "node_drop";
|
|
50
|
+
PermissionKey["NODE_EDIT"] = "node_edit";
|
|
51
|
+
PermissionKey["ANALYSIS_APPROVE"] = "analysis_approve";
|
|
52
|
+
PermissionKey["ANALYSIS_EDIT"] = "analysis_edit";
|
|
53
|
+
PermissionKey["ANALYSIS_ADD"] = "analysis_add";
|
|
54
|
+
PermissionKey["ANALYSIS_EXECUTION_START"] = "analysis_execution_start";
|
|
55
|
+
PermissionKey["ANALYSIS_EXECUTION_STOP"] = "analysis_execution_stop";
|
|
56
|
+
PermissionKey["ANALYSIS_DROP"] = "analysis_drop";
|
|
57
|
+
PermissionKey["ANALYSIS_RESULT_READ"] = "analysis_result_read";
|
|
58
|
+
PermissionKey["MASTER_IMAGE_MANAGE"] = "master_image_manage";
|
|
59
|
+
PermissionKey["MASTER_IMAGE_GROUP_MANAGE"] = "master_image_group_manage";
|
|
60
|
+
PermissionKey["SERVICE_MANAGE"] = "service_manage";
|
|
61
|
+
})(PermissionKey || (PermissionKey = {}));
|
|
62
|
+
const PermissionID = _object_spread({}, PermissionKey, PermissionName);
|
|
63
|
+
|
|
64
|
+
/*
|
|
65
|
+
* Copyright (c) 2024.
|
|
66
|
+
* Author Peter Placzek (tada5hi)
|
|
67
|
+
* For the full copyright and license information,
|
|
68
|
+
* view the LICENSE file that was distributed with this source code.
|
|
69
|
+
*/ function isBoolTrue(input) {
|
|
70
|
+
return typeof input === 'boolean' && !!input;
|
|
71
|
+
}
|
|
72
|
+
function isBoolFalse(input) {
|
|
73
|
+
return typeof input === 'boolean' && !input;
|
|
74
|
+
}
|
|
75
|
+
function isBool(input) {
|
|
76
|
+
return typeof input === 'boolean';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
* Copyright (c) 2021-2024.
|
|
81
|
+
* Author Peter Placzek (tada5hi)
|
|
82
|
+
* For the full copyright and license information,
|
|
83
|
+
* view the LICENSE file that was distributed with this source code.
|
|
84
|
+
*/ // eslint-disable-next-line @typescript-eslint/ban-types
|
|
85
|
+
function hasOwnProperty(obj, prop) {
|
|
86
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
87
|
+
}
|
|
88
|
+
function isObject(item) {
|
|
89
|
+
return !!item && typeof item === 'object' && !Array.isArray(item);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function isError(e) {
|
|
93
|
+
return typeof e === 'object' && e && hasOwnProperty(e, 'message');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/*
|
|
97
|
+
* Copyright (c) 2021-2024.
|
|
98
|
+
* Author Peter Placzek (tada5hi)
|
|
99
|
+
* For the full copyright and license information,
|
|
100
|
+
* view the LICENSE file that was distributed with this source code.
|
|
101
|
+
*/ function isHex(value) {
|
|
102
|
+
return /^[A-Fa-f0-9]+$/i.test(value);
|
|
103
|
+
}
|
|
104
|
+
function hexToUTF8(value) {
|
|
105
|
+
try {
|
|
106
|
+
return decodeURIComponent(`%${value.match(/.{1,2}/g).join('%')}`);
|
|
107
|
+
} catch (e) {
|
|
108
|
+
if (e instanceof URIError) {
|
|
109
|
+
return value;
|
|
110
|
+
}
|
|
111
|
+
throw e;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/*
|
|
116
|
+
* Copyright (c) 2022-2024.
|
|
117
|
+
* Author Peter Placzek (tada5hi)
|
|
118
|
+
* For the full copyright and license information,
|
|
119
|
+
* view the LICENSE file that was distributed with this source code.
|
|
120
|
+
*/ function getHostNameFromString(value) {
|
|
121
|
+
if (value.startsWith('http://') || value.startsWith('https://')) {
|
|
122
|
+
const url = new URL(value);
|
|
123
|
+
value = url.hostname;
|
|
124
|
+
}
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function createNanoID(alphabetOrLen, len) {
|
|
129
|
+
if (typeof alphabetOrLen === 'string') {
|
|
130
|
+
return customAlphabet(alphabetOrLen, len || 21)();
|
|
131
|
+
}
|
|
132
|
+
if (typeof alphabetOrLen === 'number') {
|
|
133
|
+
return customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', alphabetOrLen)();
|
|
134
|
+
}
|
|
135
|
+
return customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', len || 21)();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/*
|
|
139
|
+
* Copyright (c) 2021-2024.
|
|
140
|
+
* Author Peter Placzek (tada5hi)
|
|
141
|
+
* For the full copyright and license information,
|
|
142
|
+
* view the LICENSE file that was distributed with this source code.
|
|
143
|
+
*/ function nullifyEmptyObjectProperties(data) {
|
|
144
|
+
const keys = Object.keys(data);
|
|
145
|
+
for(let i = 0; i < keys.length; i++){
|
|
146
|
+
const key = keys[i];
|
|
147
|
+
if (data[key] === '') {
|
|
148
|
+
data[key] = null;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return data;
|
|
152
|
+
}
|
|
153
|
+
function deleteUndefinedObjectProperties(data) {
|
|
154
|
+
const keys = Object.keys(data);
|
|
155
|
+
for(let i = 0; i < keys.length; i++){
|
|
156
|
+
if (typeof data[keys[i]] === 'undefined') {
|
|
157
|
+
delete data[keys[i]];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return data;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/*
|
|
164
|
+
* Copyright (c) 2021-2024.
|
|
165
|
+
* Author Peter Placzek (tada5hi)
|
|
166
|
+
* For the full copyright and license information,
|
|
167
|
+
* view the LICENSE file that was distributed with this source code.
|
|
168
|
+
*/ function parseProxyConnectionString(connectionStr) {
|
|
169
|
+
const match = connectionStr.match(/(?:(https|http):\/\/)(?:(\w+)(?::(\w+))?@)?(?:([^:]+))(?::(\d{1,5}))?$/);
|
|
170
|
+
if (!match) {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
protocol: match[1],
|
|
175
|
+
host: match[4],
|
|
176
|
+
port: parseInt(match[5], 10),
|
|
177
|
+
auth: {
|
|
178
|
+
username: match[2],
|
|
179
|
+
password: match[3]
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
function detectProxyConnectionConfig() {
|
|
184
|
+
const envKeys = [
|
|
185
|
+
'https_proxy',
|
|
186
|
+
'HTTPS_PROXY',
|
|
187
|
+
'http_proxy',
|
|
188
|
+
'HTTP_PROXY'
|
|
189
|
+
];
|
|
190
|
+
let result;
|
|
191
|
+
for(let i = 0; i < envKeys.length; i++){
|
|
192
|
+
const envKey = envKeys[i];
|
|
193
|
+
const envVal = process.env[envKey];
|
|
194
|
+
if (envVal !== undefined && envVal !== null) {
|
|
195
|
+
result = result || envVal;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (!result) {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
return parseProxyConnectionString(result);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/*
|
|
205
|
+
* Copyright (c) 2023-2024.
|
|
206
|
+
* Author Peter Placzek (tada5hi)
|
|
207
|
+
* For the full copyright and license information,
|
|
208
|
+
* view the LICENSE file that was distributed with this source code.
|
|
209
|
+
*/ const alphaNumHyphenUnderscoreRegex = /^[a-z0-9-_]*$/;
|
|
210
|
+
const registryRobotSecretRegex = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d).{8,}$/;
|
|
211
|
+
|
|
212
|
+
/*
|
|
213
|
+
* Copyright (c) 2024.
|
|
214
|
+
* Author Peter Placzek (tada5hi)
|
|
215
|
+
* For the full copyright and license information,
|
|
216
|
+
* view the LICENSE file that was distributed with this source code.
|
|
217
|
+
*/ var EnvironmentName;
|
|
218
|
+
(function(EnvironmentName) {
|
|
219
|
+
EnvironmentName["TEST"] = "test";
|
|
220
|
+
EnvironmentName["DEVELOPMENT"] = "development";
|
|
221
|
+
EnvironmentName["PRODUCTION"] = "production";
|
|
222
|
+
})(EnvironmentName || (EnvironmentName = {}));
|
|
223
|
+
|
|
224
|
+
export { EnvironmentName, PermissionID, PermissionKey, alphaNumHyphenUnderscoreRegex, createNanoID, deleteUndefinedObjectProperties, detectProxyConnectionConfig, getHostNameFromString, hasOwnProperty, hexToUTF8, isBool, isBoolFalse, isBoolTrue, isError, isHex, isObject, nullifyEmptyObjectProperties, parseProxyConnectionString, registryRobotSecretRegex };
|
|
225
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/domains/permission/constants.ts","../src/utils/boolean.ts","../src/utils/has-own-property.ts","../src/utils/error.ts","../src/utils/hex-checker.ts","../src/utils/hostname.ts","../src/utils/nanoid.ts","../src/utils/object-properties.ts","../src/utils/proxy-connection-string.ts","../src/utils/regex-patterns.ts","../src/constants.ts"],"sourcesContent":["/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { PermissionName as AuthPermissionName } from '@authup/core-kit';\n\nexport enum PermissionKey {\n BUCKET_ADD = 'bucket_add',\n BUCKET_EDIT = 'bucket_edit',\n BUCKET_DROP = 'bucket_drop',\n\n PROJECT_ADD = 'project_add',\n PROJECT_DROP = 'project_drop',\n PROJECT_EDIT = 'project_edit',\n PROJECT_APPROVE = 'project_approve',\n\n REGISTRY_MANAGE = 'registry_manage',\n REGISTRY_PROJECT_MANAGE = 'registry_project_manage',\n\n NODE_ADD = 'node_add',\n NODE_DROP = 'node_drop',\n NODE_EDIT = 'node_edit',\n\n ANALYSIS_APPROVE = 'analysis_approve',\n ANALYSIS_EDIT = 'analysis_edit',\n ANALYSIS_ADD = 'analysis_add',\n ANALYSIS_EXECUTION_START = 'analysis_execution_start',\n ANALYSIS_EXECUTION_STOP = 'analysis_execution_stop',\n ANALYSIS_DROP = 'analysis_drop',\n ANALYSIS_RESULT_READ = 'analysis_result_read', // todo: this is maybe not required anymore\n\n MASTER_IMAGE_MANAGE = 'master_image_manage',\n MASTER_IMAGE_GROUP_MANAGE = 'master_image_group_manage',\n\n SERVICE_MANAGE = 'service_manage',\n}\n\nexport const PermissionID = {\n ...PermissionKey,\n ...AuthPermissionName,\n};\n\nexport type PermissionIDType = typeof PermissionID[keyof typeof PermissionID];\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isBoolTrue<T = any>(input: T | boolean) : input is true {\n return typeof input === 'boolean' && !!input;\n}\n\nexport function isBoolFalse<T = any>(input: T | boolean) : input is false {\n return typeof input === 'boolean' && !input;\n}\n\nexport function isBool<T = any>(input: T | boolean) : input is boolean {\n return typeof input === 'boolean';\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n// eslint-disable-next-line @typescript-eslint/ban-types\nexport function hasOwnProperty<X extends {}, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nexport function isObject(item: unknown) : item is Record<string, any> {\n return (\n !!item &&\n typeof item === 'object' &&\n !Array.isArray(item)\n );\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hasOwnProperty } from './has-own-property';\n\nexport function isError(e: unknown) {\n return typeof e === 'object' && e && hasOwnProperty(e, 'message');\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isHex(value: string) : boolean {\n return /^[A-Fa-f0-9]+$/i.test(value);\n}\n\nexport function hexToUTF8(value: string) {\n try {\n return decodeURIComponent(`%${value.match(/.{1,2}/g).join('%')}`);\n } catch (e) {\n if (e instanceof URIError) {\n return value;\n }\n\n throw e;\n }\n}\n","/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function getHostNameFromString(value: string) : string {\n if (\n value.startsWith('http://') ||\n value.startsWith('https://')\n ) {\n const url = new URL(value);\n value = url.hostname;\n }\n\n return value;\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { customAlphabet } from 'nanoid';\n\nexport function createNanoID(alphabet?: string) : string;\nexport function createNanoID(len?: number) : string;\nexport function createNanoID(alphabet?: string, len?: number) : string;\nexport function createNanoID(alphabetOrLen?: string | number, len?: number) : string {\n if (typeof alphabetOrLen === 'string') {\n return customAlphabet(alphabetOrLen, len || 21)();\n }\n\n if (typeof alphabetOrLen === 'number') {\n return customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', alphabetOrLen)();\n }\n\n return customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', len || 21)();\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function nullifyEmptyObjectProperties<T extends Record<string, any>>(data: T) : T {\n const keys : (keyof T)[] = Object.keys(data);\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (data[key] === '') {\n data[key] = null as T[keyof T];\n }\n }\n\n return data as T;\n}\n\nexport function deleteUndefinedObjectProperties<T extends Record<string, any>>(data: T) : T {\n const keys : string[] = Object.keys(data);\n\n for (let i = 0; i < keys.length; i++) {\n if (typeof data[keys[i]] === 'undefined') {\n delete data[keys[i]];\n }\n }\n\n return data;\n}\n","/*\n * Copyright (c) 2021-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport type ProxyConnectionConfig = {\n protocol: 'http' | 'https',\n host: string,\n port: number,\n auth: {\n username: string,\n password: string,\n }\n};\n\nexport function parseProxyConnectionString(connectionStr: string) : ProxyConnectionConfig | undefined {\n const match = connectionStr\n .match(/(?:(https|http):\\/\\/)(?:(\\w+)(?::(\\w+))?@)?(?:([^:]+))(?::(\\d{1,5}))?$/);\n\n if (!match) {\n return undefined;\n }\n\n return {\n protocol: match[1] as 'http' | 'https',\n host: match[4],\n port: parseInt(match[5], 10),\n auth: {\n username: match[2],\n password: match[3],\n },\n };\n}\n\nexport function detectProxyConnectionConfig() : ProxyConnectionConfig | undefined {\n const envKeys = [\n 'https_proxy',\n 'HTTPS_PROXY',\n 'http_proxy',\n 'HTTP_PROXY',\n ];\n\n let result : string | undefined;\n\n for (let i = 0; i < envKeys.length; i++) {\n const envKey = envKeys[i];\n const envVal = process.env[envKey];\n\n if (\n envVal !== undefined &&\n envVal !== null\n ) {\n result = result || envVal;\n }\n }\n\n if (!result) {\n return undefined;\n }\n\n return parseProxyConnectionString(result);\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport const alphaNumHyphenUnderscoreRegex = /^[a-z0-9-_]*$/;\nexport const registryRobotSecretRegex = /^(?=.*[A-Z])(?=.*[a-z])(?=.*\\d).{8,}$/;\n","/*\n * Copyright (c) 2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum EnvironmentName {\n TEST = 'test',\n DEVELOPMENT = 'development',\n PRODUCTION = 'production',\n}\n"],"names":["PermissionKey","PermissionID","AuthPermissionName","isBoolTrue","input","isBoolFalse","isBool","hasOwnProperty","obj","prop","Object","prototype","call","isObject","item","Array","isArray","isError","e","isHex","value","test","hexToUTF8","decodeURIComponent","match","join","URIError","getHostNameFromString","startsWith","url","URL","hostname","createNanoID","alphabetOrLen","len","customAlphabet","nullifyEmptyObjectProperties","data","keys","i","length","key","deleteUndefinedObjectProperties","parseProxyConnectionString","connectionStr","undefined","protocol","host","port","parseInt","auth","username","password","detectProxyConnectionConfig","envKeys","result","envKey","envVal","process","env","alphaNumHyphenUnderscoreRegex","registryRobotSecretRegex","EnvironmentName"],"mappings":";;;AAAA;;;;;AAKC,IAAA,SAAA,gBAAA,CAAA,GAAA,EAAA,GAAA,EAAA,KAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIWA,CAAAA,SAAAA,aAAAA,EAAAA;;;;;;;;;;;;;;;;;;;;;;;GAAAA,aAAAA,KAAAA,aAAAA,GAAAA,EAAAA,CAAAA,CAAAA,CAAAA;AA+BCC,MAAAA,YAAAA,GAAe,cACrBD,CAAAA,EAAAA,EAAAA,aAAAA,EACAE,cACL;;AC3CF;;;;;IAOO,SAASC,UAAAA,CAAoBC,KAAkB,EAAA;AAClD,IAAA,OAAO,OAAOA,KAAAA,KAAU,SAAa,IAAA,CAAC,CAACA,KAAAA,CAAAA;AAC3C,CAAA;AAEO,SAASC,YAAqBD,KAAkB,EAAA;IACnD,OAAO,OAAOA,KAAU,KAAA,SAAA,IAAa,CAACA,KAAAA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IAAAA,MAAAA,CAAAA;AACvB,SAAA;AACJ,KAAA;AAEA,IAAA,IAAI,CAACF,MAAQ,EAAA;QACT,OAAOV,SAAAA,CAAAA;AACX,KAAA;AAEA,IAAA,OAAOF,0BAA2BY,CAAAA,MAAAA,CAAAA,CAAAA;AACtC;;AC/DA;;;;;IAOaK,MAAAA,6BAAAA,GAAgC,gBAAgB;AACtD,MAAMC,2BAA2B;;ACRxC;;;;;AAKC,IAAA,IAAA,gBAAA;AAEWC,CAAAA,SAAAA,eAAAA,EAAAA;;;;GAAAA,eAAAA,KAAAA,eAAAA,GAAAA,EAAAA,CAAAA,CAAAA;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function isBoolTrue<T = any>(input: T | boolean): input is true;
|
|
2
|
+
export declare function isBoolFalse<T = any>(input: T | boolean): input is false;
|
|
3
|
+
export declare function isBool<T = any>(input: T | boolean): input is boolean;
|
|
4
|
+
//# sourceMappingURL=boolean.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/utils/boolean.ts"],"names":[],"mappings":"AAOA,wBAAgB,UAAU,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,GAAI,KAAK,IAAI,IAAI,CAEtE;AAED,wBAAgB,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,GAAI,KAAK,IAAI,KAAK,CAExE;AAED,wBAAgB,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,GAAI,KAAK,IAAI,OAAO,CAErE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"AASA,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,WAEjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-own-property.d.ts","sourceRoot":"","sources":["../../src/utils/has-own-property.ts"],"names":[],"mappings":"AAQA,wBAAgB,cAAc,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAElH;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAI,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAMpE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex-checker.d.ts","sourceRoot":"","sources":["../../src/utils/hex-checker.ts"],"names":[],"mappings":"AAOA,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAI,OAAO,CAE7C;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,UAUtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostname.d.ts","sourceRoot":"","sources":["../../src/utils/hostname.ts"],"names":[],"mappings":"AAOA,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAI,MAAM,CAU5D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './boolean';
|
|
2
|
+
export * from './error';
|
|
3
|
+
export * from './has-own-property';
|
|
4
|
+
export * from './hex-checker';
|
|
5
|
+
export * from './hostname';
|
|
6
|
+
export * from './nanoid';
|
|
7
|
+
export * from './object-properties';
|
|
8
|
+
export * from './proxy-connection-string';
|
|
9
|
+
export * from './regex-patterns';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAOA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nanoid.d.ts","sourceRoot":"","sources":["../../src/utils/nanoid.ts"],"names":[],"mappings":"AASA,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAI,MAAM,CAAC;AACzD,wBAAgB,YAAY,CAAC,GAAG,CAAC,EAAE,MAAM,GAAI,MAAM,CAAC;AACpD,wBAAgB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAI,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-properties.d.ts","sourceRoot":"","sources":["../../src/utils/object-properties.ts"],"names":[],"mappings":"AAOA,wBAAgB,4BAA4B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,GAAI,CAAC,CAWvF;AAED,wBAAgB,+BAA+B,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,GAAI,CAAC,CAU1F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type ProxyConnectionConfig = {
|
|
2
|
+
protocol: 'http' | 'https';
|
|
3
|
+
host: string;
|
|
4
|
+
port: number;
|
|
5
|
+
auth: {
|
|
6
|
+
username: string;
|
|
7
|
+
password: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function parseProxyConnectionString(connectionStr: string): ProxyConnectionConfig | undefined;
|
|
11
|
+
export declare function detectProxyConnectionConfig(): ProxyConnectionConfig | undefined;
|
|
12
|
+
//# sourceMappingURL=proxy-connection-string.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy-connection-string.d.ts","sourceRoot":"","sources":["../../src/utils/proxy-connection-string.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,qBAAqB,GAAG;IAChC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACF,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;KACpB,CAAA;CACJ,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAI,qBAAqB,GAAG,SAAS,CAiBpG;AAED,wBAAgB,2BAA2B,IAAK,qBAAqB,GAAG,SAAS,CA2BhF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regex-patterns.d.ts","sourceRoot":"","sources":["../../src/utils/regex-patterns.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,6BAA6B,QAAkB,CAAC;AAC7D,eAAO,MAAM,wBAAwB,QAA0C,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@privateaim/kit",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./package.json": "./package.json",
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/index.cjs",
|
|
15
|
+
"module": "./dist/index.mjs",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"author": {
|
|
18
|
+
"name": "Peter Placzek",
|
|
19
|
+
"email": "admin@tada5hi.net",
|
|
20
|
+
"url": "https://github.com/tada5hi"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build:types": "tsc --emitDeclarationOnly -p tsconfig.build.json",
|
|
24
|
+
"build:js": "rollup -c",
|
|
25
|
+
"build": "rimraf ./dist && cross-env NODE_ENV=production npm run build:js && npm run build:types",
|
|
26
|
+
"build-watch": "rimraf ./dist && tsc -p tsconfig.build.json --watch"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@authup/core-kit": "^1.0.0-beta.13"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@authup/core-kit": "^1.0.0-beta.13"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"nanoid": "^3.3.4"
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "5d3b6f4ce1edf2383bdfbf66e913a08c8a3a2e40",
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
3
|
+
* Author Peter Placzek (tada5hi)
|
|
4
|
+
* For the full copyright and license information,
|
|
5
|
+
* view the LICENSE file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import fs from 'node:fs';
|
|
9
|
+
|
|
10
|
+
import { createConfig } from '../../rollup.config.mjs';
|
|
11
|
+
|
|
12
|
+
export default createConfig({
|
|
13
|
+
pkg: JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), {encoding: 'utf-8'})),
|
|
14
|
+
swc: {
|
|
15
|
+
jsc: {
|
|
16
|
+
target: 'es2016'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024.
|
|
3
|
+
* Author Peter Placzek (tada5hi)
|
|
4
|
+
* For the full copyright and license information,
|
|
5
|
+
* view the LICENSE file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export enum EnvironmentName {
|
|
9
|
+
TEST = 'test',
|
|
10
|
+
DEVELOPMENT = 'development',
|
|
11
|
+
PRODUCTION = 'production',
|
|
12
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-2024.
|
|
3
|
+
* Author Peter Placzek (tada5hi)
|
|
4
|
+
* For the full copyright and license information,
|
|
5
|
+
* view the LICENSE file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { PermissionName as AuthPermissionName } from '@authup/core-kit';
|
|
9
|
+
|
|
10
|
+
export enum PermissionKey {
|
|
11
|
+
BUCKET_ADD = 'bucket_add',
|
|
12
|
+
BUCKET_EDIT = 'bucket_edit',
|
|
13
|
+
BUCKET_DROP = 'bucket_drop',
|
|
14
|
+
|
|
15
|
+
PROJECT_ADD = 'project_add',
|
|
16
|
+
PROJECT_DROP = 'project_drop',
|
|
17
|
+
PROJECT_EDIT = 'project_edit',
|
|
18
|
+
PROJECT_APPROVE = 'project_approve',
|
|
19
|
+
|
|
20
|
+
REGISTRY_MANAGE = 'registry_manage',
|
|
21
|
+
REGISTRY_PROJECT_MANAGE = 'registry_project_manage',
|
|
22
|
+
|
|
23
|
+
NODE_ADD = 'node_add',
|
|
24
|
+
NODE_DROP = 'node_drop',
|
|
25
|
+
NODE_EDIT = 'node_edit',
|
|
26
|
+
|
|
27
|
+
ANALYSIS_APPROVE = 'analysis_approve',
|
|
28
|
+
ANALYSIS_EDIT = 'analysis_edit',
|
|
29
|
+
ANALYSIS_ADD = 'analysis_add',
|
|
30
|
+
ANALYSIS_EXECUTION_START = 'analysis_execution_start',
|
|
31
|
+
ANALYSIS_EXECUTION_STOP = 'analysis_execution_stop',
|
|
32
|
+
ANALYSIS_DROP = 'analysis_drop',
|
|
33
|
+
ANALYSIS_RESULT_READ = 'analysis_result_read', // todo: this is maybe not required anymore
|
|
34
|
+
|
|
35
|
+
MASTER_IMAGE_MANAGE = 'master_image_manage',
|
|
36
|
+
MASTER_IMAGE_GROUP_MANAGE = 'master_image_group_manage',
|
|
37
|
+
|
|
38
|
+
SERVICE_MANAGE = 'service_manage',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const PermissionID = {
|
|
42
|
+
...PermissionKey,
|
|
43
|
+
...AuthPermissionName,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export type PermissionIDType = typeof PermissionID[keyof typeof PermissionID];
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-2024.
|
|
3
|
+
* Author Peter Placzek (tada5hi)
|
|
4
|
+
* For the full copyright and license information,
|
|
5
|
+
* view the LICENSE file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export * from './domains';
|
|
9
|
+
export * from './utils';
|
|
10
|
+
export * from './constants';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024.
|
|
3
|
+
* Author Peter Placzek (tada5hi)
|
|
4
|
+
* For the full copyright and license information,
|
|
5
|
+
* view the LICENSE file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function isBoolTrue<T = any>(input: T | boolean) : input is true {
|
|
9
|
+
return typeof input === 'boolean' && !!input;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function isBoolFalse<T = any>(input: T | boolean) : input is false {
|
|
13
|
+
return typeof input === 'boolean' && !input;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function isBool<T = any>(input: T | boolean) : input is boolean {
|
|
17
|
+
return typeof input === 'boolean';
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2024.
|
|
3
|
+
* Author Peter Placzek (tada5hi)
|
|
4
|
+
* For the full copyright and license information,
|
|
5
|
+
* view the LICENSE file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { hasOwnProperty } from './has-own-property';
|
|
9
|
+
|
|
10
|
+
export function isError(e: unknown) {
|
|
11
|
+
return typeof e === 'object' && e && hasOwnProperty(e, 'message');
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-2024.
|
|
3
|
+
* Author Peter Placzek (tada5hi)
|
|
4
|
+
* For the full copyright and license information,
|
|
5
|
+
* view the LICENSE file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
9
|
+
export function hasOwnProperty<X extends {}, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown> {
|
|
10
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function isObject(item: unknown) : item is Record<string, any> {
|
|
14
|
+
return (
|
|
15
|
+
!!item &&
|
|
16
|
+
typeof item === 'object' &&
|
|
17
|
+
!Array.isArray(item)
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-2024.
|
|
3
|
+
* Author Peter Placzek (tada5hi)
|
|
4
|
+
* For the full copyright and license information,
|
|
5
|
+
* view the LICENSE file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function isHex(value: string) : boolean {
|
|
9
|
+
return /^[A-Fa-f0-9]+$/i.test(value);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function hexToUTF8(value: string) {
|
|
13
|
+
try {
|
|
14
|
+
return decodeURIComponent(`%${value.match(/.{1,2}/g).join('%')}`);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
if (e instanceof URIError) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
throw e;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2024.
|
|
3
|
+
* Author Peter Placzek (tada5hi)
|
|
4
|
+
* For the full copyright and license information,
|
|
5
|
+
* view the LICENSE file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export function getHostNameFromString(value: string) : string {
|
|
9
|
+
if (
|
|
10
|
+
value.startsWith('http://') ||
|
|
11
|
+
value.startsWith('https://')
|
|
12
|
+
) {
|
|
13
|
+
const url = new URL(value);
|
|
14
|
+
value = url.hostname;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021-2024.
|
|
3
|
+
* Author Peter Placzek (tada5hi)
|
|
4
|
+
* For the full copyright and license information,
|
|
5
|
+
* view the LICENSE file that was distributed with this source code.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export * from './boolean';
|
|
9
|
+
export * from './error';
|
|
10
|
+
export * from './has-own-property';
|
|
11
|
+
export * from './hex-checker';
|
|
12
|
+
export * from './hostname';
|
|
13
|
+
export * from './nanoid';
|
|
14
|
+
export * from './object-properties';
|
|
15
|
+
export * from './proxy-connection-string';
|
|
16
|
+
export * from './regex-patterns';
|