@edirect/tokenization 0.0.10 → 11.0.25
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/README.md +10 -5
- package/dist/README.md +113 -0
- package/dist/package.json +36 -0
- package/dist/src/core/app.d.ts +17 -0
- package/dist/src/core/app.d.ts.map +1 -0
- package/dist/src/core/app.js +114 -0
- package/dist/src/core/domain.d.ts +25 -0
- package/dist/src/core/domain.d.ts.map +1 -0
- package/dist/src/core/domain.js +2 -0
- package/dist/src/core/evaluator/basic.d.ts +5 -0
- package/dist/src/core/evaluator/basic.d.ts.map +1 -0
- package/dist/src/core/evaluator/basic.js +32 -0
- package/dist/src/core/evaluator/index.d.ts +8 -0
- package/dist/src/core/evaluator/index.d.ts.map +1 -0
- package/dist/src/core/evaluator/index.js +26 -0
- package/dist/src/core/services/configuration.d.ts +12 -0
- package/dist/src/core/services/configuration.d.ts.map +1 -0
- package/dist/src/core/services/configuration.js +82 -0
- package/dist/src/core/services/tokenization.d.ts +9 -0
- package/dist/src/core/services/tokenization.d.ts.map +1 -0
- package/dist/src/core/services/tokenization.js +43 -0
- package/dist/src/core/traverser/index.d.ts +4 -0
- package/dist/src/core/traverser/index.d.ts.map +1 -0
- package/dist/src/core/traverser/index.js +19 -0
- package/dist/src/core/utils/object.d.ts +7 -0
- package/dist/src/core/utils/object.d.ts.map +1 -0
- package/dist/src/core/utils/object.js +33 -0
- package/dist/{index.d.ts → src/index.d.ts} +4 -19
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +70 -0
- package/dist/src/types.d.ts +56 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +5 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +44 -24
- package/dist/index.d.mts +0 -44
- package/dist/index.js +0 -443
- package/dist/index.mjs +0 -406
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.set = exports.get = void 0;
|
|
4
|
+
const get = (obj, path) => {
|
|
5
|
+
let currentObj = obj;
|
|
6
|
+
for (let i = 0; i < path.length; i++) {
|
|
7
|
+
const key = path[i];
|
|
8
|
+
if (currentObj[key] !== undefined) {
|
|
9
|
+
currentObj = currentObj[key];
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return currentObj;
|
|
16
|
+
};
|
|
17
|
+
exports.get = get;
|
|
18
|
+
const set = (obj, path, value) => {
|
|
19
|
+
let currentObj = obj;
|
|
20
|
+
for (let i = 0; i < path.length; i++) {
|
|
21
|
+
const key = path[i];
|
|
22
|
+
if (i === path.length - 1) {
|
|
23
|
+
currentObj[key] = value;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
if (!currentObj[key] || typeof currentObj[key] !== 'object') {
|
|
27
|
+
currentObj[key] = isNaN(Number(path[i + 1])) ? {} : [];
|
|
28
|
+
}
|
|
29
|
+
currentObj = currentObj[key];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.set = set;
|
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
type TokenPayload = Record<string, unknown>;
|
|
5
|
-
|
|
6
|
-
interface ITokenizationApp {
|
|
7
|
-
tokenize(auth: string, tenant: string, config: string, payload: TokenPayload): Promise<TokenPayload>;
|
|
8
|
-
detokenize(auth: string, tenant: string, config: string, payload: TokenPayload): Promise<TokenPayload>;
|
|
9
|
-
}
|
|
10
|
-
type Token = {
|
|
11
|
-
isToken: boolean;
|
|
12
|
-
tenant: string;
|
|
13
|
-
type: string;
|
|
14
|
-
hash: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
1
|
+
import { ITokenizationApp, Token } from './core/domain';
|
|
2
|
+
import { TokenPayload } from './types';
|
|
17
3
|
/**
|
|
18
4
|
* The TokenizationClient class.
|
|
19
5
|
*/
|
|
20
|
-
declare class Tokenization {
|
|
6
|
+
export declare class Tokenization {
|
|
21
7
|
private app;
|
|
22
8
|
/**
|
|
23
9
|
* The constructor of the TokenizationClient class.
|
|
@@ -40,5 +26,4 @@ declare class Tokenization {
|
|
|
40
26
|
detokenize(auth: string, tenant: string, config: string, payload: TokenPayload): Promise<TokenPayload>;
|
|
41
27
|
static parseToken(token: string): Token;
|
|
42
28
|
}
|
|
43
|
-
|
|
44
|
-
export { Tokenization };
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGxD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,GAAG,CAAmB;IAE9B;;;OAGG;gBACS,YAAY,CAAC,EAAE,MAAM,GAAG,gBAAgB;IAcpD;;;;;OAKG;IACI,QAAQ,CACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,YAAY,CAAC;IAIxB;;;;;OAKG;IACI,UAAU,CACf,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,YAAY,CAAC;WAIV,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK;CA2B/C"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tokenization = void 0;
|
|
4
|
+
const app_1 = require("./core/app");
|
|
5
|
+
const configuration_1 = require("./core/services/configuration");
|
|
6
|
+
const tokenization_1 = require("./core/services/tokenization");
|
|
7
|
+
/**
|
|
8
|
+
* The TokenizationClient class.
|
|
9
|
+
*/
|
|
10
|
+
class Tokenization {
|
|
11
|
+
app;
|
|
12
|
+
/**
|
|
13
|
+
* The constructor of the TokenizationClient class.
|
|
14
|
+
* @param url The URL of the tokenization server.
|
|
15
|
+
*/
|
|
16
|
+
constructor(baseUrlOrApp) {
|
|
17
|
+
if (baseUrlOrApp && typeof baseUrlOrApp !== 'string') {
|
|
18
|
+
this.app = baseUrlOrApp;
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const tokenizationService = new tokenization_1.TokenizationService(baseUrlOrApp);
|
|
22
|
+
const configurationService = new configuration_1.ConfigurationService(baseUrlOrApp);
|
|
23
|
+
this.app = new app_1.TokenizationApp(tokenizationService, configurationService);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Tokenizes the given payload.
|
|
28
|
+
* @param tenant The tenant to tokenize the payload for.
|
|
29
|
+
* @param payload The payload to tokenize.
|
|
30
|
+
* @returns The tokenized payload.
|
|
31
|
+
*/
|
|
32
|
+
tokenize(auth, tenant, config, payload) {
|
|
33
|
+
return this.app.tokenize(auth, tenant, config, payload);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Detokenizes the given payload.
|
|
37
|
+
* @param tenant The tenant to detokenize the payload for.
|
|
38
|
+
* @param payload The payload to detokenize.
|
|
39
|
+
* @returns The detokenized payload.
|
|
40
|
+
*/
|
|
41
|
+
detokenize(auth, tenant, config, payload) {
|
|
42
|
+
return this.app.detokenize(auth, tenant, config, payload);
|
|
43
|
+
}
|
|
44
|
+
static parseToken(token) {
|
|
45
|
+
const parts = token.split(':');
|
|
46
|
+
if (parts.length !== 4) {
|
|
47
|
+
return {
|
|
48
|
+
isToken: false,
|
|
49
|
+
tenant: '',
|
|
50
|
+
type: '',
|
|
51
|
+
hash: '',
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (parts[0] !== 'token') {
|
|
55
|
+
return {
|
|
56
|
+
isToken: false,
|
|
57
|
+
tenant: '',
|
|
58
|
+
type: '',
|
|
59
|
+
hash: '',
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
isToken: true,
|
|
64
|
+
tenant: parts[1],
|
|
65
|
+
type: parts[2],
|
|
66
|
+
hash: parts[3],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.Tokenization = Tokenization;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file This file contains the models used in the application.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* The classification of a field.
|
|
6
|
+
* 0: The field is not sensitive.
|
|
7
|
+
* 1: The field is sensitive.
|
|
8
|
+
*/
|
|
9
|
+
export type Classification = 0 | 1;
|
|
10
|
+
/**
|
|
11
|
+
* The model of a field classification.
|
|
12
|
+
* @property path The path of the field.
|
|
13
|
+
* @property classification The classification of the field.
|
|
14
|
+
* @example
|
|
15
|
+
* {
|
|
16
|
+
* path: "data.*.name",
|
|
17
|
+
* classification: 1
|
|
18
|
+
* }
|
|
19
|
+
* @see Classification
|
|
20
|
+
*/
|
|
21
|
+
export type FieldClassification = {
|
|
22
|
+
path: string;
|
|
23
|
+
classification: Classification;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The model of a configuration.
|
|
27
|
+
* @property key The key of the configuration.
|
|
28
|
+
* @property tenant The tenant of the configuration.
|
|
29
|
+
* @property defaultClassification The default classification of the configuration.
|
|
30
|
+
* @property fields The fields of the configuration.
|
|
31
|
+
* @example
|
|
32
|
+
* {
|
|
33
|
+
* key: "configuration",
|
|
34
|
+
* tenant: "tenant",
|
|
35
|
+
* defaultClassification: 0,
|
|
36
|
+
* fields: [
|
|
37
|
+
* {
|
|
38
|
+
* path: "data.*.name",
|
|
39
|
+
* classification: 1
|
|
40
|
+
* }
|
|
41
|
+
* ]
|
|
42
|
+
* }
|
|
43
|
+
* @see FieldClassification
|
|
44
|
+
* @see Classification
|
|
45
|
+
*/
|
|
46
|
+
export type Configuration = {
|
|
47
|
+
key: string;
|
|
48
|
+
tenant: string;
|
|
49
|
+
defaultClassification: Classification;
|
|
50
|
+
fields: FieldClassification[];
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* The model of a token payload.
|
|
54
|
+
*/
|
|
55
|
+
export type TokenPayload = Record<string, unknown>;
|
|
56
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,CAAC,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,cAAc,CAAC;CAChC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB,EAAE,cAAc,CAAC;IACtC,MAAM,EAAE,mBAAmB,EAAE,CAAC;CAC/B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":"5.9.2"}
|
package/package.json
CHANGED
|
@@ -1,40 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edirect/tokenization",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.25",
|
|
4
4
|
"description": "Javascript library for tokenization service",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
5
|
+
"packageScope": "@edirect",
|
|
6
|
+
"main": "./dist/src/index.js",
|
|
7
|
+
"types": "./dist/src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"development": "./src/index.ts",
|
|
11
|
+
"default": "./dist/src/index.js",
|
|
12
|
+
"require": "./dist/src/index.js",
|
|
13
|
+
"types": "./dist/src/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
16
|
+
},
|
|
8
17
|
"files": [
|
|
9
18
|
"dist"
|
|
10
19
|
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsup",
|
|
13
|
-
"dev": "tsup --watch",
|
|
14
|
-
"test": "vitest run",
|
|
15
|
-
"test:watch": "vitest",
|
|
16
|
-
"coverage": "vitest run --coverage"
|
|
17
|
-
},
|
|
18
20
|
"keywords": [
|
|
19
21
|
"typescript",
|
|
20
22
|
"library"
|
|
21
23
|
],
|
|
22
24
|
"author": "Igor Quirino <igor.quirino@bolttech.com>",
|
|
23
25
|
"license": "MIT",
|
|
24
|
-
"repository": {
|
|
25
|
-
"type": "git",
|
|
26
|
-
"url": "git+https://bitbucket.org/gofrank/tokenization-service-nodejs.git"
|
|
27
|
-
},
|
|
28
26
|
"homepage": "https://bolttech.io",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"lru-cache": "^11.1.0",
|
|
29
|
+
"vitest": "3.2.4",
|
|
30
|
+
"tslib": "^2.8.1"
|
|
31
|
+
},
|
|
29
32
|
"devDependencies": {
|
|
30
|
-
"@types/node": "^
|
|
31
|
-
"@vitest/coverage-istanbul": "^2.
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"vitest": "^2.1.8"
|
|
33
|
+
"@types/node": "^24.3.0",
|
|
34
|
+
"@vitest/coverage-istanbul": "^3.2.4",
|
|
35
|
+
"typescript": "^5.9.2",
|
|
36
|
+
"vitest": "^3.2.4"
|
|
35
37
|
},
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
38
|
+
"nx": {
|
|
39
|
+
"name": "@edirect/tokenization",
|
|
40
|
+
"targets": {
|
|
41
|
+
"build": {
|
|
42
|
+
"executor": "@nx/js:tsc",
|
|
43
|
+
"options": {
|
|
44
|
+
"main": "{workspaceRoot}/packages/edirect-tokenization/src/index.ts",
|
|
45
|
+
"tsConfig": "{workspaceRoot}/packages/edirect-tokenization/tsconfig.lib.json",
|
|
46
|
+
"outputPath": "{workspaceRoot}/packages/edirect-tokenization/dist",
|
|
47
|
+
"assets": [
|
|
48
|
+
"{workspaceRoot}/packages/edirect-tokenization/package.json",
|
|
49
|
+
"{workspaceRoot}/packages/edirect-tokenization/README.md"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"scripts": {
|
|
56
|
+
"test": "vitest run",
|
|
57
|
+
"test:watch": "vitest",
|
|
58
|
+
"coverage": "vitest run --coverage"
|
|
39
59
|
}
|
|
40
|
-
}
|
|
60
|
+
}
|
package/dist/index.d.mts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The model of a token payload.
|
|
3
|
-
*/
|
|
4
|
-
type TokenPayload = Record<string, unknown>;
|
|
5
|
-
|
|
6
|
-
interface ITokenizationApp {
|
|
7
|
-
tokenize(auth: string, tenant: string, config: string, payload: TokenPayload): Promise<TokenPayload>;
|
|
8
|
-
detokenize(auth: string, tenant: string, config: string, payload: TokenPayload): Promise<TokenPayload>;
|
|
9
|
-
}
|
|
10
|
-
type Token = {
|
|
11
|
-
isToken: boolean;
|
|
12
|
-
tenant: string;
|
|
13
|
-
type: string;
|
|
14
|
-
hash: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The TokenizationClient class.
|
|
19
|
-
*/
|
|
20
|
-
declare class Tokenization {
|
|
21
|
-
private app;
|
|
22
|
-
/**
|
|
23
|
-
* The constructor of the TokenizationClient class.
|
|
24
|
-
* @param url The URL of the tokenization server.
|
|
25
|
-
*/
|
|
26
|
-
constructor(baseUrlOrApp?: string | ITokenizationApp);
|
|
27
|
-
/**
|
|
28
|
-
* Tokenizes the given payload.
|
|
29
|
-
* @param tenant The tenant to tokenize the payload for.
|
|
30
|
-
* @param payload The payload to tokenize.
|
|
31
|
-
* @returns The tokenized payload.
|
|
32
|
-
*/
|
|
33
|
-
tokenize(auth: string, tenant: string, config: string, payload: TokenPayload): Promise<TokenPayload>;
|
|
34
|
-
/**
|
|
35
|
-
* Detokenizes the given payload.
|
|
36
|
-
* @param tenant The tenant to detokenize the payload for.
|
|
37
|
-
* @param payload The payload to detokenize.
|
|
38
|
-
* @returns The detokenized payload.
|
|
39
|
-
*/
|
|
40
|
-
detokenize(auth: string, tenant: string, config: string, payload: TokenPayload): Promise<TokenPayload>;
|
|
41
|
-
static parseToken(token: string): Token;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { Tokenization };
|