@edirect/tokenization 0.0.6 → 0.0.7
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 +25 -0
- package/dist/index.mjs +25 -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
|
@@ -397,6 +397,31 @@ var Tokenization = class {
|
|
|
397
397
|
detokenize(auth, tenant, config, payload) {
|
|
398
398
|
return this.app.detokenize(auth, tenant, config, payload);
|
|
399
399
|
}
|
|
400
|
+
static parseToken(token) {
|
|
401
|
+
const parts = token.split(":");
|
|
402
|
+
if (parts.length !== 4) {
|
|
403
|
+
return {
|
|
404
|
+
isToken: false,
|
|
405
|
+
tenant: "",
|
|
406
|
+
type: "",
|
|
407
|
+
hash: ""
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
if (parts[0] !== "token") {
|
|
411
|
+
return {
|
|
412
|
+
isToken: false,
|
|
413
|
+
tenant: "",
|
|
414
|
+
type: "",
|
|
415
|
+
hash: ""
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
return {
|
|
419
|
+
isToken: true,
|
|
420
|
+
tenant: parts[1],
|
|
421
|
+
type: parts[2],
|
|
422
|
+
hash: parts[3]
|
|
423
|
+
};
|
|
424
|
+
}
|
|
400
425
|
};
|
|
401
426
|
// Annotate the CommonJS export names for ESM import in node:
|
|
402
427
|
0 && (module.exports = {
|
package/dist/index.mjs
CHANGED
|
@@ -371,6 +371,31 @@ var Tokenization = class {
|
|
|
371
371
|
detokenize(auth, tenant, config, payload) {
|
|
372
372
|
return this.app.detokenize(auth, tenant, config, payload);
|
|
373
373
|
}
|
|
374
|
+
static parseToken(token) {
|
|
375
|
+
const parts = token.split(":");
|
|
376
|
+
if (parts.length !== 4) {
|
|
377
|
+
return {
|
|
378
|
+
isToken: false,
|
|
379
|
+
tenant: "",
|
|
380
|
+
type: "",
|
|
381
|
+
hash: ""
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
if (parts[0] !== "token") {
|
|
385
|
+
return {
|
|
386
|
+
isToken: false,
|
|
387
|
+
tenant: "",
|
|
388
|
+
type: "",
|
|
389
|
+
hash: ""
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
return {
|
|
393
|
+
isToken: true,
|
|
394
|
+
tenant: parts[1],
|
|
395
|
+
type: parts[2],
|
|
396
|
+
hash: parts[3]
|
|
397
|
+
};
|
|
398
|
+
}
|
|
374
399
|
};
|
|
375
400
|
export {
|
|
376
401
|
Tokenization
|