@edirect/tokenization 0.0.9 → 0.0.10
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/dist/index.js +83 -73
- package/dist/index.mjs +73 -73
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -228,6 +238,7 @@ var TokenizationApp = class {
|
|
|
228
238
|
|
|
229
239
|
// src/core/services/configuration.ts
|
|
230
240
|
var import_lru_cache2 = require("lru-cache");
|
|
241
|
+
var import_axios = __toESM(require("axios"));
|
|
231
242
|
var ConfigurationService = class {
|
|
232
243
|
constructor(baseUrl) {
|
|
233
244
|
this.baseUrl = baseUrl;
|
|
@@ -249,76 +260,77 @@ var ConfigurationService = class {
|
|
|
249
260
|
if (cached) {
|
|
250
261
|
return cached;
|
|
251
262
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
263
|
+
try {
|
|
264
|
+
const resp = await import_axios.default.get(
|
|
265
|
+
`${this.baseUrl}/api/v1/${tenant}/${config}/config`,
|
|
266
|
+
{
|
|
267
|
+
headers: {
|
|
268
|
+
Authorization: `Bearer ${auth}`
|
|
269
|
+
}
|
|
258
270
|
}
|
|
271
|
+
);
|
|
272
|
+
const data = resp.data;
|
|
273
|
+
this.cache.set(`${tenant}/${config}`, data);
|
|
274
|
+
return data;
|
|
275
|
+
} catch (error) {
|
|
276
|
+
if (import_axios.default.isAxiosError(error) && error.response?.status === 404) {
|
|
277
|
+
return void 0;
|
|
259
278
|
}
|
|
260
|
-
);
|
|
261
|
-
if (resp.status === 404) {
|
|
262
|
-
return void 0;
|
|
263
|
-
}
|
|
264
|
-
if (resp.status !== 200) {
|
|
265
279
|
throw new Error("Failed to get configuration");
|
|
266
280
|
}
|
|
267
|
-
const data = await resp.json();
|
|
268
|
-
this.cache.set(`${tenant}/${config}`, data);
|
|
269
|
-
return data;
|
|
270
281
|
}
|
|
271
282
|
async create(auth, tenant, config) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
283
|
+
try {
|
|
284
|
+
await import_axios.default.post(
|
|
285
|
+
`${this.baseUrl}/api/v1/${tenant}/${config.key}/config`,
|
|
286
|
+
config,
|
|
287
|
+
{
|
|
288
|
+
headers: {
|
|
289
|
+
Authorization: `Bearer ${auth}`,
|
|
290
|
+
"Content-Type": "application/json"
|
|
291
|
+
}
|
|
280
292
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
293
|
+
);
|
|
294
|
+
return config;
|
|
295
|
+
} catch (error) {
|
|
284
296
|
throw new Error("Failed to create configuration");
|
|
285
297
|
}
|
|
286
|
-
return config;
|
|
287
298
|
}
|
|
288
299
|
async update(auth, tenant, config) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
300
|
+
try {
|
|
301
|
+
await import_axios.default.put(
|
|
302
|
+
`${this.baseUrl}/api/v1/${tenant}/${config.key}/config`,
|
|
303
|
+
config,
|
|
304
|
+
{
|
|
305
|
+
headers: {
|
|
306
|
+
Authorization: `Bearer ${auth}`,
|
|
307
|
+
"Content-Type": "application/json"
|
|
308
|
+
}
|
|
297
309
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
310
|
+
);
|
|
311
|
+
return config;
|
|
312
|
+
} catch (error) {
|
|
301
313
|
throw new Error("Failed to update configuration");
|
|
302
314
|
}
|
|
303
|
-
return config;
|
|
304
315
|
}
|
|
305
316
|
async delete(auth, tenant, config) {
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
317
|
+
try {
|
|
318
|
+
await import_axios.default.delete(
|
|
319
|
+
`${this.baseUrl}/api/v1/${tenant}/${config}/config`,
|
|
320
|
+
{
|
|
321
|
+
headers: {
|
|
322
|
+
Authorization: `Bearer ${auth}`
|
|
323
|
+
}
|
|
312
324
|
}
|
|
313
|
-
|
|
314
|
-
)
|
|
315
|
-
if (resp.status !== 204) {
|
|
325
|
+
);
|
|
326
|
+
} catch (error) {
|
|
316
327
|
throw new Error("Failed to delete configuration");
|
|
317
328
|
}
|
|
318
329
|
}
|
|
319
330
|
};
|
|
320
331
|
|
|
321
332
|
// src/core/services/tokenization.ts
|
|
333
|
+
var import_axios2 = __toESM(require("axios"));
|
|
322
334
|
var TokenizationService = class {
|
|
323
335
|
constructor(baseUrl) {
|
|
324
336
|
this.baseUrl = baseUrl;
|
|
@@ -327,40 +339,38 @@ var TokenizationService = class {
|
|
|
327
339
|
}
|
|
328
340
|
}
|
|
329
341
|
async tokenize(auth, tenant, config, payload) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
342
|
+
try {
|
|
343
|
+
const resp = await import_axios2.default.post(
|
|
344
|
+
`${this.baseUrl}/api/v1/${tenant}/${config}/token/tokenize`,
|
|
345
|
+
payload,
|
|
346
|
+
{
|
|
347
|
+
headers: {
|
|
348
|
+
"Authorization": `Bearer ${auth}`,
|
|
349
|
+
"Content-Type": "application/json"
|
|
350
|
+
}
|
|
338
351
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
352
|
+
);
|
|
353
|
+
return resp.data;
|
|
354
|
+
} catch (error) {
|
|
342
355
|
throw new Error("Failed to tokenize payload");
|
|
343
356
|
}
|
|
344
|
-
const data = await resp.json();
|
|
345
|
-
return data;
|
|
346
357
|
}
|
|
347
358
|
async detokenize(auth, tenant, config, payload) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
359
|
+
try {
|
|
360
|
+
const resp = await import_axios2.default.post(
|
|
361
|
+
`${this.baseUrl}/api/v1/${tenant}/${config}/token/detokenize`,
|
|
362
|
+
payload,
|
|
363
|
+
{
|
|
364
|
+
headers: {
|
|
365
|
+
"Authorization": `Bearer ${auth}`,
|
|
366
|
+
"Content-Type": "application/json"
|
|
367
|
+
}
|
|
356
368
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
369
|
+
);
|
|
370
|
+
return resp.data;
|
|
371
|
+
} catch (error) {
|
|
360
372
|
throw new Error("Failed to detokenize payload");
|
|
361
373
|
}
|
|
362
|
-
const data = await resp.json();
|
|
363
|
-
return data;
|
|
364
374
|
}
|
|
365
375
|
};
|
|
366
376
|
|
package/dist/index.mjs
CHANGED
|
@@ -202,6 +202,7 @@ var TokenizationApp = class {
|
|
|
202
202
|
|
|
203
203
|
// src/core/services/configuration.ts
|
|
204
204
|
import { LRUCache as LRUCache2 } from "lru-cache";
|
|
205
|
+
import axios from "axios";
|
|
205
206
|
var ConfigurationService = class {
|
|
206
207
|
constructor(baseUrl) {
|
|
207
208
|
this.baseUrl = baseUrl;
|
|
@@ -223,76 +224,77 @@ var ConfigurationService = class {
|
|
|
223
224
|
if (cached) {
|
|
224
225
|
return cached;
|
|
225
226
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
227
|
+
try {
|
|
228
|
+
const resp = await axios.get(
|
|
229
|
+
`${this.baseUrl}/api/v1/${tenant}/${config}/config`,
|
|
230
|
+
{
|
|
231
|
+
headers: {
|
|
232
|
+
Authorization: `Bearer ${auth}`
|
|
233
|
+
}
|
|
232
234
|
}
|
|
235
|
+
);
|
|
236
|
+
const data = resp.data;
|
|
237
|
+
this.cache.set(`${tenant}/${config}`, data);
|
|
238
|
+
return data;
|
|
239
|
+
} catch (error) {
|
|
240
|
+
if (axios.isAxiosError(error) && error.response?.status === 404) {
|
|
241
|
+
return void 0;
|
|
233
242
|
}
|
|
234
|
-
);
|
|
235
|
-
if (resp.status === 404) {
|
|
236
|
-
return void 0;
|
|
237
|
-
}
|
|
238
|
-
if (resp.status !== 200) {
|
|
239
243
|
throw new Error("Failed to get configuration");
|
|
240
244
|
}
|
|
241
|
-
const data = await resp.json();
|
|
242
|
-
this.cache.set(`${tenant}/${config}`, data);
|
|
243
|
-
return data;
|
|
244
245
|
}
|
|
245
246
|
async create(auth, tenant, config) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
247
|
+
try {
|
|
248
|
+
await axios.post(
|
|
249
|
+
`${this.baseUrl}/api/v1/${tenant}/${config.key}/config`,
|
|
250
|
+
config,
|
|
251
|
+
{
|
|
252
|
+
headers: {
|
|
253
|
+
Authorization: `Bearer ${auth}`,
|
|
254
|
+
"Content-Type": "application/json"
|
|
255
|
+
}
|
|
254
256
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
257
|
+
);
|
|
258
|
+
return config;
|
|
259
|
+
} catch (error) {
|
|
258
260
|
throw new Error("Failed to create configuration");
|
|
259
261
|
}
|
|
260
|
-
return config;
|
|
261
262
|
}
|
|
262
263
|
async update(auth, tenant, config) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
264
|
+
try {
|
|
265
|
+
await axios.put(
|
|
266
|
+
`${this.baseUrl}/api/v1/${tenant}/${config.key}/config`,
|
|
267
|
+
config,
|
|
268
|
+
{
|
|
269
|
+
headers: {
|
|
270
|
+
Authorization: `Bearer ${auth}`,
|
|
271
|
+
"Content-Type": "application/json"
|
|
272
|
+
}
|
|
271
273
|
}
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
274
|
+
);
|
|
275
|
+
return config;
|
|
276
|
+
} catch (error) {
|
|
275
277
|
throw new Error("Failed to update configuration");
|
|
276
278
|
}
|
|
277
|
-
return config;
|
|
278
279
|
}
|
|
279
280
|
async delete(auth, tenant, config) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
281
|
+
try {
|
|
282
|
+
await axios.delete(
|
|
283
|
+
`${this.baseUrl}/api/v1/${tenant}/${config}/config`,
|
|
284
|
+
{
|
|
285
|
+
headers: {
|
|
286
|
+
Authorization: `Bearer ${auth}`
|
|
287
|
+
}
|
|
286
288
|
}
|
|
287
|
-
|
|
288
|
-
)
|
|
289
|
-
if (resp.status !== 204) {
|
|
289
|
+
);
|
|
290
|
+
} catch (error) {
|
|
290
291
|
throw new Error("Failed to delete configuration");
|
|
291
292
|
}
|
|
292
293
|
}
|
|
293
294
|
};
|
|
294
295
|
|
|
295
296
|
// src/core/services/tokenization.ts
|
|
297
|
+
import axios2 from "axios";
|
|
296
298
|
var TokenizationService = class {
|
|
297
299
|
constructor(baseUrl) {
|
|
298
300
|
this.baseUrl = baseUrl;
|
|
@@ -301,40 +303,38 @@ var TokenizationService = class {
|
|
|
301
303
|
}
|
|
302
304
|
}
|
|
303
305
|
async tokenize(auth, tenant, config, payload) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
306
|
+
try {
|
|
307
|
+
const resp = await axios2.post(
|
|
308
|
+
`${this.baseUrl}/api/v1/${tenant}/${config}/token/tokenize`,
|
|
309
|
+
payload,
|
|
310
|
+
{
|
|
311
|
+
headers: {
|
|
312
|
+
"Authorization": `Bearer ${auth}`,
|
|
313
|
+
"Content-Type": "application/json"
|
|
314
|
+
}
|
|
312
315
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
+
);
|
|
317
|
+
return resp.data;
|
|
318
|
+
} catch (error) {
|
|
316
319
|
throw new Error("Failed to tokenize payload");
|
|
317
320
|
}
|
|
318
|
-
const data = await resp.json();
|
|
319
|
-
return data;
|
|
320
321
|
}
|
|
321
322
|
async detokenize(auth, tenant, config, payload) {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
323
|
+
try {
|
|
324
|
+
const resp = await axios2.post(
|
|
325
|
+
`${this.baseUrl}/api/v1/${tenant}/${config}/token/detokenize`,
|
|
326
|
+
payload,
|
|
327
|
+
{
|
|
328
|
+
headers: {
|
|
329
|
+
"Authorization": `Bearer ${auth}`,
|
|
330
|
+
"Content-Type": "application/json"
|
|
331
|
+
}
|
|
330
332
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
333
|
+
);
|
|
334
|
+
return resp.data;
|
|
335
|
+
} catch (error) {
|
|
334
336
|
throw new Error("Failed to detokenize payload");
|
|
335
337
|
}
|
|
336
|
-
const data = await resp.json();
|
|
337
|
-
return data;
|
|
338
338
|
}
|
|
339
339
|
};
|
|
340
340
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edirect/tokenization",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Javascript library for tokenization service",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"vitest": "^2.1.8"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
+
"axios": "^1.7.9",
|
|
37
38
|
"lru-cache": "^11.0.2"
|
|
38
39
|
}
|
|
39
40
|
}
|