@edirect/tokenization 0.0.6 → 0.0.8
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 +12 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +28 -0
- package/dist/index.mjs +28 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,6 +67,18 @@ const detokenizedData = await tokenization.detokenize(auth, tenant, config, payl
|
|
|
67
67
|
console.log("Detokenized Payload:", detokenizedData);
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
### Parsing the Token
|
|
71
|
+
|
|
72
|
+
The tokenized payload is a string that contains the tokenized values. To parse the tokenized payload, you can use the `parseToken` method.
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
const token = Tokenization.parseToken("token:tenant1:str:asdf1234");
|
|
76
|
+
console.log(`Is Token: ${token.isToken}`);
|
|
77
|
+
console.log(`Tenant: ${token.tenant}`);
|
|
78
|
+
console.log(`Type: ${token.type}`);
|
|
79
|
+
console.log(`Hash: ${token.Hash}`);
|
|
80
|
+
```
|
|
81
|
+
|
|
70
82
|
## API
|
|
71
83
|
|
|
72
84
|
### `Tokenization`
|
package/dist/index.d.mts
CHANGED
|
@@ -7,6 +7,12 @@ interface ITokenizationApp {
|
|
|
7
7
|
tokenize(auth: string, tenant: string, config: string, payload: TokenPayload): Promise<TokenPayload>;
|
|
8
8
|
detokenize(auth: string, tenant: string, config: string, payload: TokenPayload): Promise<TokenPayload>;
|
|
9
9
|
}
|
|
10
|
+
type Token = {
|
|
11
|
+
isToken: boolean;
|
|
12
|
+
tenant: string;
|
|
13
|
+
type: string;
|
|
14
|
+
hash: string;
|
|
15
|
+
};
|
|
10
16
|
|
|
11
17
|
/**
|
|
12
18
|
* The TokenizationClient class.
|
|
@@ -32,6 +38,7 @@ declare class Tokenization {
|
|
|
32
38
|
* @returns The detokenized payload.
|
|
33
39
|
*/
|
|
34
40
|
detokenize(auth: string, tenant: string, config: string, payload: TokenPayload): Promise<TokenPayload>;
|
|
41
|
+
static parseToken(token: string): Token;
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
export { Tokenization };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,12 @@ interface ITokenizationApp {
|
|
|
7
7
|
tokenize(auth: string, tenant: string, config: string, payload: TokenPayload): Promise<TokenPayload>;
|
|
8
8
|
detokenize(auth: string, tenant: string, config: string, payload: TokenPayload): Promise<TokenPayload>;
|
|
9
9
|
}
|
|
10
|
+
type Token = {
|
|
11
|
+
isToken: boolean;
|
|
12
|
+
tenant: string;
|
|
13
|
+
type: string;
|
|
14
|
+
hash: string;
|
|
15
|
+
};
|
|
10
16
|
|
|
11
17
|
/**
|
|
12
18
|
* The TokenizationClient class.
|
|
@@ -32,6 +38,7 @@ declare class Tokenization {
|
|
|
32
38
|
* @returns The detokenized payload.
|
|
33
39
|
*/
|
|
34
40
|
detokenize(auth: string, tenant: string, config: string, payload: TokenPayload): Promise<TokenPayload>;
|
|
41
|
+
static parseToken(token: string): Token;
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
export { Tokenization };
|
package/dist/index.js
CHANGED
|
@@ -107,6 +107,9 @@ var TokenEvaluator = class {
|
|
|
107
107
|
return config.defaultClassification > 0;
|
|
108
108
|
}
|
|
109
109
|
const ret = config.fields.map((field) => {
|
|
110
|
+
if (!field.classification) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
110
113
|
return this.evaluator.Evaluate(field.path, ...path);
|
|
111
114
|
});
|
|
112
115
|
return ret.some((r) => r) || config.defaultClassification > 0;
|
|
@@ -397,6 +400,31 @@ var Tokenization = class {
|
|
|
397
400
|
detokenize(auth, tenant, config, payload) {
|
|
398
401
|
return this.app.detokenize(auth, tenant, config, payload);
|
|
399
402
|
}
|
|
403
|
+
static parseToken(token) {
|
|
404
|
+
const parts = token.split(":");
|
|
405
|
+
if (parts.length !== 4) {
|
|
406
|
+
return {
|
|
407
|
+
isToken: false,
|
|
408
|
+
tenant: "",
|
|
409
|
+
type: "",
|
|
410
|
+
hash: ""
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
if (parts[0] !== "token") {
|
|
414
|
+
return {
|
|
415
|
+
isToken: false,
|
|
416
|
+
tenant: "",
|
|
417
|
+
type: "",
|
|
418
|
+
hash: ""
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
return {
|
|
422
|
+
isToken: true,
|
|
423
|
+
tenant: parts[1],
|
|
424
|
+
type: parts[2],
|
|
425
|
+
hash: parts[3]
|
|
426
|
+
};
|
|
427
|
+
}
|
|
400
428
|
};
|
|
401
429
|
// Annotate the CommonJS export names for ESM import in node:
|
|
402
430
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -81,6 +81,9 @@ var TokenEvaluator = class {
|
|
|
81
81
|
return config.defaultClassification > 0;
|
|
82
82
|
}
|
|
83
83
|
const ret = config.fields.map((field) => {
|
|
84
|
+
if (!field.classification) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
84
87
|
return this.evaluator.Evaluate(field.path, ...path);
|
|
85
88
|
});
|
|
86
89
|
return ret.some((r) => r) || config.defaultClassification > 0;
|
|
@@ -371,6 +374,31 @@ var Tokenization = class {
|
|
|
371
374
|
detokenize(auth, tenant, config, payload) {
|
|
372
375
|
return this.app.detokenize(auth, tenant, config, payload);
|
|
373
376
|
}
|
|
377
|
+
static parseToken(token) {
|
|
378
|
+
const parts = token.split(":");
|
|
379
|
+
if (parts.length !== 4) {
|
|
380
|
+
return {
|
|
381
|
+
isToken: false,
|
|
382
|
+
tenant: "",
|
|
383
|
+
type: "",
|
|
384
|
+
hash: ""
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
if (parts[0] !== "token") {
|
|
388
|
+
return {
|
|
389
|
+
isToken: false,
|
|
390
|
+
tenant: "",
|
|
391
|
+
type: "",
|
|
392
|
+
hash: ""
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
return {
|
|
396
|
+
isToken: true,
|
|
397
|
+
tenant: parts[1],
|
|
398
|
+
type: parts[2],
|
|
399
|
+
hash: parts[3]
|
|
400
|
+
};
|
|
401
|
+
}
|
|
374
402
|
};
|
|
375
403
|
export {
|
|
376
404
|
Tokenization
|