@ama-sdk/core 11.0.0-next.0 → 11.0.0-next.1
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 +4 -1
- package/cjs/clients/api-angular-client.js +45 -23
- package/cjs/clients/api-beacon-client.js +64 -20
- package/cjs/clients/api-fetch-client.js +66 -21
- package/cjs/fwk/Reviver.js +7 -7
- package/cjs/fwk/api.helper.spec.js +20 -20
- package/cjs/fwk/api.helpers.js +14 -14
- package/cjs/fwk/core/api-client.js +1 -1
- package/cjs/fwk/core/base-api-constructor.js +1 -1
- package/cjs/fwk/date.js +9 -9
- package/cjs/fwk/date.spec.js +25 -25
- package/cjs/fwk/errors.js +3 -3
- package/cjs/fwk/mocks/alf-mock-adapter.js +4 -4
- package/cjs/fwk/mocks/base-mock-adapter.js +2 -2
- package/cjs/fwk/mocks/helpers.js +3 -3
- package/cjs/fwk/reviver.spec.js +46 -10
- package/cjs/plugins/additional-params/additional-params-sync.request.js +2 -2
- package/cjs/plugins/additional-params/additional-params.request.js +3 -3
- package/cjs/plugins/additional-params/additional-params.spec.js +30 -30
- package/cjs/plugins/api-configuration-override/api-configuration-override.request.js +2 -2
- package/cjs/plugins/api-configuration-override/api-configuration-override.spec.js +13 -13
- package/cjs/plugins/api-key/api-key.request.js +2 -2
- package/cjs/plugins/api-key/api-key.spec.js +11 -11
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +6 -5
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +33 -33
- package/cjs/plugins/client-facts/client-facts.request.js +3 -3
- package/cjs/plugins/client-facts/client-facts.spec.js +27 -27
- package/cjs/plugins/concurrent/concurrent.fetch.js +1 -0
- package/cjs/plugins/concurrent/concurrent.spec.js +4 -4
- package/cjs/plugins/custom-info/custom-info.spec.js +15 -15
- package/cjs/plugins/exception/exception.reply.js +2 -2
- package/cjs/plugins/exception/exception.spec.js +15 -15
- package/cjs/plugins/fetch-cache/fetch-cache.request.js +4 -4
- package/cjs/plugins/fetch-cache/fetch-cache.spec.js +20 -20
- package/cjs/plugins/fetch-credentials/fetch-credentials.request.js +1 -1
- package/cjs/plugins/fetch-credentials/fetch-credentials.spec.js +8 -8
- package/cjs/plugins/json-token/json-token.reply.js +5 -5
- package/cjs/plugins/json-token/json-token.request.js +4 -4
- package/cjs/plugins/json-token/json-token.spec.js +24 -24
- package/cjs/plugins/keepalive/keepalive.request.js +2 -2
- package/cjs/plugins/keepalive/keepalive.spec.js +4 -4
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +32 -40
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +30 -26
- package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +3 -3
- package/cjs/plugins/mock-intercept/mock-intercept.interface.js +2 -2
- package/cjs/plugins/mock-intercept/mock-intercept.request.js +3 -3
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +28 -28
- package/cjs/plugins/perf-metric/perf-metric.fetch.js +1 -1
- package/cjs/plugins/perf-metric/perf-metric.probe.spec.js +9 -9
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.request.js +11 -11
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.spec.js +94 -94
- package/cjs/plugins/raw-response-info/raw-response-info.spec.js +12 -12
- package/cjs/plugins/retry/retry.spec.js +20 -20
- package/cjs/plugins/reviver/reviver.reply.js +35 -2
- package/cjs/plugins/reviver/reviver.spec.js +6 -6
- package/cjs/plugins/session-id/session-id.request.js +7 -6
- package/cjs/plugins/session-id/session-id.spec.js +13 -13
- package/cjs/plugins/si-token/si-token.spec.js +9 -9
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +4 -4
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +44 -44
- package/cjs/plugins/timeout/timeout.fetch.js +12 -10
- package/cjs/plugins/timeout/timeout.spec.js +13 -13
- package/cjs/plugins/url-rewrite/url-rewrite.spec.js +9 -9
- package/cjs/plugins/wait-for/wait-for.spec.js +9 -9
- package/cjs/utils/crypto.js +14 -14
- package/cjs/utils/generic-api.js +253 -0
- package/cjs/utils/index.js +1 -0
- package/cjs/utils/json-token.js +30 -30
- package/cjs/utils/json-token.spec.js +31 -31
- package/cli/files-pack.cjs +12 -12
- package/cli/files-pack.cjs.map +1 -1
- package/esm2015/clients/api-angular-client.js +49 -27
- package/esm2015/clients/api-beacon-client.js +65 -21
- package/esm2015/clients/api-fetch-client.js +70 -25
- package/esm2015/clients/index.js +2 -2
- package/esm2015/fwk/Reviver.js +10 -7
- package/esm2015/fwk/api.helper.spec.js +21 -21
- package/esm2015/fwk/api.helpers.js +14 -14
- package/esm2015/fwk/core/api-client.js +1 -1
- package/esm2015/fwk/core/base-api-constructor.js +1 -1
- package/esm2015/fwk/core/index.js +2 -2
- package/esm2015/fwk/date.js +9 -9
- package/esm2015/fwk/date.spec.js +26 -26
- package/esm2015/fwk/errors.js +3 -3
- package/esm2015/fwk/index.js +10 -10
- package/esm2015/fwk/mocks/alf-mock-adapter.js +6 -6
- package/esm2015/fwk/mocks/base-mock-adapter.js +3 -3
- package/esm2015/fwk/mocks/helpers.js +3 -3
- package/esm2015/fwk/mocks/index.js +10 -10
- package/esm2015/fwk/mocks/random-mock-adapter.js +1 -1
- package/esm2015/fwk/mocks/sequential-mock-adapter.js +1 -1
- package/esm2015/fwk/reviver.spec.js +47 -11
- package/esm2015/plugins/additional-params/additional-params-sync.request.js +3 -3
- package/esm2015/plugins/additional-params/additional-params.request.js +3 -3
- package/esm2015/plugins/additional-params/additional-params.spec.js +32 -32
- package/esm2015/plugins/additional-params/index.js +2 -2
- package/esm2015/plugins/api-configuration-override/api-configuration-override.request.js +2 -2
- package/esm2015/plugins/api-configuration-override/api-configuration-override.spec.js +14 -14
- package/esm2015/plugins/api-configuration-override/index.js +1 -1
- package/esm2015/plugins/api-key/api-key.request.js +2 -2
- package/esm2015/plugins/api-key/api-key.spec.js +12 -12
- package/esm2015/plugins/api-key/index.js +1 -1
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +6 -6
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +34 -34
- package/esm2015/plugins/bot-protection-fingerprint/index.js +1 -1
- package/esm2015/plugins/client-facts/client-facts.request.js +4 -4
- package/esm2015/plugins/client-facts/client-facts.spec.js +28 -28
- package/esm2015/plugins/client-facts/index.js +1 -1
- package/esm2015/plugins/concurrent/concurrent.fetch.js +1 -0
- package/esm2015/plugins/concurrent/concurrent.spec.js +5 -5
- package/esm2015/plugins/concurrent/index.js +1 -1
- package/esm2015/plugins/core/index.js +4 -4
- package/esm2015/plugins/custom-info/custom-info.spec.js +17 -17
- package/esm2015/plugins/custom-info/index.js +1 -1
- package/esm2015/plugins/exception/exception.reply.js +4 -4
- package/esm2015/plugins/exception/exception.spec.js +18 -18
- package/esm2015/plugins/exception/index.js +1 -1
- package/esm2015/plugins/fetch-cache/fetch-cache.request.js +4 -4
- package/esm2015/plugins/fetch-cache/fetch-cache.spec.js +21 -21
- package/esm2015/plugins/fetch-cache/index.js +1 -1
- package/esm2015/plugins/fetch-credentials/fetch-credentials.request.js +1 -1
- package/esm2015/plugins/fetch-credentials/fetch-credentials.spec.js +9 -9
- package/esm2015/plugins/fetch-credentials/index.js +1 -1
- package/esm2015/plugins/index.js +25 -25
- package/esm2015/plugins/json-token/index.js +2 -2
- package/esm2015/plugins/json-token/json-token.reply.js +5 -5
- package/esm2015/plugins/json-token/json-token.request.js +4 -4
- package/esm2015/plugins/json-token/json-token.spec.js +27 -27
- package/esm2015/plugins/keepalive/index.js +1 -1
- package/esm2015/plugins/keepalive/keepalive.request.js +2 -2
- package/esm2015/plugins/keepalive/keepalive.spec.js +5 -5
- package/esm2015/plugins/mgw-mdw-auth/index.js +1 -1
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +34 -42
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +32 -28
- package/esm2015/plugins/mock-intercept/index.js +2 -2
- package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +5 -5
- package/esm2015/plugins/mock-intercept/mock-intercept.interface.js +2 -2
- package/esm2015/plugins/mock-intercept/mock-intercept.request.js +4 -4
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +32 -32
- package/esm2015/plugins/perf-metric/index.js +1 -1
- package/esm2015/plugins/perf-metric/perf-metric.fetch.js +2 -2
- package/esm2015/plugins/perf-metric/perf-metric.probe.spec.js +10 -10
- package/esm2015/plugins/pii-tokenizer/index.js +1 -1
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.request.js +12 -12
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.spec.js +96 -96
- package/esm2015/plugins/raw-response-info/index.js +1 -1
- package/esm2015/plugins/raw-response-info/raw-response-info.spec.js +14 -14
- package/esm2015/plugins/retry/index.js +1 -1
- package/esm2015/plugins/retry/retry.fetch.js +1 -1
- package/esm2015/plugins/retry/retry.spec.js +21 -21
- package/esm2015/plugins/reviver/index.js +1 -1
- package/esm2015/plugins/reviver/reviver.reply.js +35 -2
- package/esm2015/plugins/reviver/reviver.spec.js +8 -8
- package/esm2015/plugins/session-id/index.js +1 -1
- package/esm2015/plugins/session-id/session-id.request.js +8 -7
- package/esm2015/plugins/session-id/session-id.spec.js +14 -14
- package/esm2015/plugins/si-token/index.js +1 -1
- package/esm2015/plugins/si-token/si-token.request.js +1 -1
- package/esm2015/plugins/si-token/si-token.spec.js +10 -10
- package/esm2015/plugins/simple-api-key-authentication/index.js +1 -1
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +5 -5
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +46 -46
- package/esm2015/plugins/timeout/index.js +1 -1
- package/esm2015/plugins/timeout/timeout.fetch.js +13 -11
- package/esm2015/plugins/timeout/timeout.spec.js +15 -15
- package/esm2015/plugins/url-rewrite/index.js +1 -1
- package/esm2015/plugins/url-rewrite/url-rewrite.spec.js +10 -10
- package/esm2015/plugins/wait-for/index.js +1 -1
- package/esm2015/plugins/wait-for/wait-for.spec.js +10 -10
- package/esm2015/public_api.js +4 -4
- package/esm2015/utils/crypto.js +15 -15
- package/esm2015/utils/generic-api.js +245 -0
- package/esm2015/utils/index.js +6 -5
- package/esm2015/utils/json-token.js +32 -32
- package/esm2015/utils/json-token.spec.js +32 -32
- package/package.json +67 -40
- package/schematics/ng-add/index.d.ts +4 -2
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +58 -40
- package/schematics/ng-add/index.js.map +1 -1
- package/src/clients/api-angular-client.d.ts +6 -3
- package/src/clients/api-angular-client.d.ts.map +1 -1
- package/src/clients/api-angular-client.js +31 -16
- package/src/clients/api-angular-client.js.map +1 -1
- package/src/clients/api-beacon-client.d.ts +7 -5
- package/src/clients/api-beacon-client.d.ts.map +1 -1
- package/src/clients/api-beacon-client.js +24 -14
- package/src/clients/api-beacon-client.js.map +1 -1
- package/src/clients/api-fetch-client.d.ts +5 -3
- package/src/clients/api-fetch-client.d.ts.map +1 -1
- package/src/clients/api-fetch-client.js +26 -14
- package/src/clients/api-fetch-client.js.map +1 -1
- package/src/fwk/Reviver.d.ts +16 -4
- package/src/fwk/Reviver.d.ts.map +1 -1
- package/src/fwk/Reviver.js +9 -6
- package/src/fwk/Reviver.js.map +1 -1
- package/src/fwk/api.helpers.d.ts +1 -1
- package/src/fwk/api.helpers.d.ts.map +1 -1
- package/src/fwk/api.helpers.js +1 -1
- package/src/fwk/api.helpers.js.map +1 -1
- package/src/fwk/core/api-client.d.ts +36 -1
- package/src/fwk/core/api-client.d.ts.map +1 -1
- package/src/fwk/core/api-client.js.map +1 -1
- package/src/fwk/date.js.map +1 -1
- package/src/fwk/mocks/alf-mock-adapter.js.map +1 -1
- package/src/fwk/mocks/base-mock-adapter.js.map +1 -1
- package/src/fwk/mocks/helpers.js.map +1 -1
- package/src/fwk/mocks/random-mock-adapter.js.map +1 -1
- package/src/fwk/mocks/sequential-mock-adapter.js.map +1 -1
- package/src/plugins/additional-params/additional-params-sync.request.js.map +1 -1
- package/src/plugins/additional-params/additional-params.request.js.map +1 -1
- package/src/plugins/api-configuration-override/api-configuration-override.request.js.map +1 -1
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.d.ts +1 -1
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.d.ts.map +1 -1
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +1 -1
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js.map +1 -1
- package/src/plugins/client-facts/client-facts.request.js.map +1 -1
- package/src/plugins/concurrent/concurrent.fetch.d.ts.map +1 -1
- package/src/plugins/concurrent/concurrent.fetch.js +1 -0
- package/src/plugins/concurrent/concurrent.fetch.js.map +1 -1
- package/src/plugins/core/plugin.d.ts +6 -1
- package/src/plugins/core/plugin.d.ts.map +1 -1
- package/src/plugins/core/reply-plugin.d.ts +0 -2
- package/src/plugins/core/reply-plugin.d.ts.map +1 -1
- package/src/plugins/core/request-plugin.d.ts +2 -0
- package/src/plugins/core/request-plugin.d.ts.map +1 -1
- package/src/plugins/exception/exception.reply.js.map +1 -1
- package/src/plugins/fetch-cache/fetch-cache.request.js.map +1 -1
- package/src/plugins/json-token/json-token.reply.js.map +1 -1
- package/src/plugins/json-token/json-token.request.js.map +1 -1
- package/src/plugins/keepalive/keepalive.request.js.map +1 -1
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.d.ts +2 -2
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.d.ts.map +1 -1
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +26 -28
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.fetch.js.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.request.js.map +1 -1
- package/src/plugins/perf-metric/perf-metric.fetch.js.map +1 -1
- package/src/plugins/pii-tokenizer/pii-tokenizer.request.d.ts.map +1 -1
- package/src/plugins/pii-tokenizer/pii-tokenizer.request.js.map +1 -1
- package/src/plugins/raw-response-info/raw-response-info.reply.js.map +1 -1
- package/src/plugins/retry/retry.fetch.js.map +1 -1
- package/src/plugins/reviver/reviver.reply.d.ts +7 -0
- package/src/plugins/reviver/reviver.reply.d.ts.map +1 -1
- package/src/plugins/reviver/reviver.reply.js +12 -1
- package/src/plugins/reviver/reviver.reply.js.map +1 -1
- package/src/plugins/session-id/session-id.request.d.ts +1 -0
- package/src/plugins/session-id/session-id.request.d.ts.map +1 -1
- package/src/plugins/session-id/session-id.request.js +1 -0
- package/src/plugins/session-id/session-id.request.js.map +1 -1
- package/src/plugins/si-token/si-token.request.js.map +1 -1
- package/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js.map +1 -1
- package/src/plugins/timeout/timeout.fetch.d.ts.map +1 -1
- package/src/plugins/timeout/timeout.fetch.js +2 -0
- package/src/plugins/timeout/timeout.fetch.js.map +1 -1
- package/src/plugins/wait-for/wait-for.fetch.js.map +1 -1
- package/src/utils/crypto.js.map +1 -1
- package/src/utils/encoder.js.map +1 -1
- package/src/utils/generic-api.d.ts +39 -0
- package/src/utils/generic-api.d.ts.map +1 -0
- package/src/utils/generic-api.js +43 -0
- package/src/utils/generic-api.js.map +1 -0
- package/src/utils/index.d.ts +1 -0
- package/src/utils/index.d.ts.map +1 -1
- package/src/utils/index.js +1 -0
- package/src/utils/index.js.map +1 -1
- package/src/utils/json-token.d.ts.map +1 -1
- package/src/utils/json-token.js.map +1 -1
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "GenericApi", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return GenericApi;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _fwk = require("../fwk");
|
|
12
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13
|
+
try {
|
|
14
|
+
var info = gen[key](arg);
|
|
15
|
+
var value = info.value;
|
|
16
|
+
} catch (error) {
|
|
17
|
+
reject(error);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (info.done) {
|
|
21
|
+
resolve(value);
|
|
22
|
+
} else {
|
|
23
|
+
Promise.resolve(value).then(_next, _throw);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function _async_to_generator(fn) {
|
|
27
|
+
return function() {
|
|
28
|
+
var self = this, args = arguments;
|
|
29
|
+
return new Promise(function(resolve, reject) {
|
|
30
|
+
var gen = fn.apply(self, args);
|
|
31
|
+
function _next(value) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
33
|
+
}
|
|
34
|
+
function _throw(err) {
|
|
35
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
36
|
+
}
|
|
37
|
+
_next(undefined);
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function _class_call_check(instance, Constructor) {
|
|
42
|
+
if (!(instance instanceof Constructor)) {
|
|
43
|
+
throw new TypeError("Cannot call a class as a function");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function _defineProperties(target, props) {
|
|
47
|
+
for(var i = 0; i < props.length; i++){
|
|
48
|
+
var descriptor = props[i];
|
|
49
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
50
|
+
descriptor.configurable = true;
|
|
51
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
52
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
56
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
57
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
58
|
+
return Constructor;
|
|
59
|
+
}
|
|
60
|
+
function _define_property(obj, key, value) {
|
|
61
|
+
if (key in obj) {
|
|
62
|
+
Object.defineProperty(obj, key, {
|
|
63
|
+
value: value,
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
obj[key] = value;
|
|
70
|
+
}
|
|
71
|
+
return obj;
|
|
72
|
+
}
|
|
73
|
+
function _object_spread(target) {
|
|
74
|
+
for(var i = 1; i < arguments.length; i++){
|
|
75
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
76
|
+
var ownKeys = Object.keys(source);
|
|
77
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
78
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
79
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
ownKeys.forEach(function(key) {
|
|
83
|
+
_define_property(target, key, source[key]);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return target;
|
|
87
|
+
}
|
|
88
|
+
function _ts_generator(thisArg, body) {
|
|
89
|
+
var f, y, t, g, _ = {
|
|
90
|
+
label: 0,
|
|
91
|
+
sent: function() {
|
|
92
|
+
if (t[0] & 1) throw t[1];
|
|
93
|
+
return t[1];
|
|
94
|
+
},
|
|
95
|
+
trys: [],
|
|
96
|
+
ops: []
|
|
97
|
+
};
|
|
98
|
+
return g = {
|
|
99
|
+
next: verb(0),
|
|
100
|
+
"throw": verb(1),
|
|
101
|
+
"return": verb(2)
|
|
102
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
103
|
+
return this;
|
|
104
|
+
}), g;
|
|
105
|
+
function verb(n) {
|
|
106
|
+
return function(v) {
|
|
107
|
+
return step([
|
|
108
|
+
n,
|
|
109
|
+
v
|
|
110
|
+
]);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function step(op) {
|
|
114
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
115
|
+
while(_)try {
|
|
116
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
117
|
+
if (y = 0, t) op = [
|
|
118
|
+
op[0] & 2,
|
|
119
|
+
t.value
|
|
120
|
+
];
|
|
121
|
+
switch(op[0]){
|
|
122
|
+
case 0:
|
|
123
|
+
case 1:
|
|
124
|
+
t = op;
|
|
125
|
+
break;
|
|
126
|
+
case 4:
|
|
127
|
+
_.label++;
|
|
128
|
+
return {
|
|
129
|
+
value: op[1],
|
|
130
|
+
done: false
|
|
131
|
+
};
|
|
132
|
+
case 5:
|
|
133
|
+
_.label++;
|
|
134
|
+
y = op[1];
|
|
135
|
+
op = [
|
|
136
|
+
0
|
|
137
|
+
];
|
|
138
|
+
continue;
|
|
139
|
+
case 7:
|
|
140
|
+
op = _.ops.pop();
|
|
141
|
+
_.trys.pop();
|
|
142
|
+
continue;
|
|
143
|
+
default:
|
|
144
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
145
|
+
_ = 0;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
149
|
+
_.label = op[1];
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
153
|
+
_.label = t[1];
|
|
154
|
+
t = op;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
if (t && _.label < t[2]) {
|
|
158
|
+
_.label = t[2];
|
|
159
|
+
_.ops.push(op);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
if (t[2]) _.ops.pop();
|
|
163
|
+
_.trys.pop();
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
op = body.call(thisArg, _);
|
|
167
|
+
} catch (e) {
|
|
168
|
+
op = [
|
|
169
|
+
6,
|
|
170
|
+
e
|
|
171
|
+
];
|
|
172
|
+
y = 0;
|
|
173
|
+
} finally{
|
|
174
|
+
f = t = 0;
|
|
175
|
+
}
|
|
176
|
+
if (op[0] & 5) throw op[1];
|
|
177
|
+
return {
|
|
178
|
+
value: op[0] ? op[1] : void 0,
|
|
179
|
+
done: true
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
var GenericApi = /*#__PURE__*/ function() {
|
|
184
|
+
"use strict";
|
|
185
|
+
function GenericApi(apiClient) {
|
|
186
|
+
_class_call_check(this, GenericApi);
|
|
187
|
+
/** @inheritDoc */ _define_property(this, "apiName", GenericApi.apiName);
|
|
188
|
+
/** @inheritDoc */ _define_property(this, "client", void 0);
|
|
189
|
+
this.client = apiClient;
|
|
190
|
+
}
|
|
191
|
+
_create_class(GenericApi, [
|
|
192
|
+
{
|
|
193
|
+
key: "request",
|
|
194
|
+
value: /**
|
|
195
|
+
* Process to request to the API in the context of the SDK
|
|
196
|
+
* @param requestOptions Option to provide to process to the call
|
|
197
|
+
*/ function request(requestOptions) {
|
|
198
|
+
var _this = this;
|
|
199
|
+
return _async_to_generator(function() {
|
|
200
|
+
var _requestOptions_metadata, _requestOptions_metadata1, metadataHeaderAccept, headers, requestParameters, options, _tmp, url, ret;
|
|
201
|
+
return _ts_generator(this, function(_state) {
|
|
202
|
+
switch(_state.label){
|
|
203
|
+
case 0:
|
|
204
|
+
metadataHeaderAccept = ((_requestOptions_metadata = requestOptions.metadata) === null || _requestOptions_metadata === void 0 ? void 0 : _requestOptions_metadata.headerAccept) || 'application/json';
|
|
205
|
+
headers = _object_spread({
|
|
206
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
207
|
+
'Content-Type': ((_requestOptions_metadata1 = requestOptions.metadata) === null || _requestOptions_metadata1 === void 0 ? void 0 : _requestOptions_metadata1.headerContentType) || 'application/json'
|
|
208
|
+
}, metadataHeaderAccept ? {
|
|
209
|
+
'Accept': metadataHeaderAccept
|
|
210
|
+
} : {});
|
|
211
|
+
requestParameters = _object_spread({
|
|
212
|
+
api: _this,
|
|
213
|
+
headers: headers
|
|
214
|
+
}, requestOptions);
|
|
215
|
+
if (!_this.client.getRequestOptions) return [
|
|
216
|
+
3,
|
|
217
|
+
2
|
|
218
|
+
];
|
|
219
|
+
return [
|
|
220
|
+
4,
|
|
221
|
+
_this.client.getRequestOptions(requestParameters)
|
|
222
|
+
];
|
|
223
|
+
case 1:
|
|
224
|
+
_tmp = _state.sent();
|
|
225
|
+
return [
|
|
226
|
+
3,
|
|
227
|
+
4
|
|
228
|
+
];
|
|
229
|
+
case 2:
|
|
230
|
+
return [
|
|
231
|
+
4,
|
|
232
|
+
_this.client.prepareOptions(requestParameters.basePath, requestParameters.method, requestParameters.queryParams || {}, requestParameters.headers)
|
|
233
|
+
];
|
|
234
|
+
case 3:
|
|
235
|
+
_tmp = _state.sent();
|
|
236
|
+
_state.label = 4;
|
|
237
|
+
case 4:
|
|
238
|
+
options = _tmp;
|
|
239
|
+
url = _this.client.prepareUrl(options.basePath, options.queryParams);
|
|
240
|
+
ret = _this.client.processCall(url, options, _fwk.ApiTypes.DEFAULT, requestOptions.api.apiName, requestOptions.revivers, requestOptions.operationId);
|
|
241
|
+
return [
|
|
242
|
+
2,
|
|
243
|
+
ret
|
|
244
|
+
];
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
})();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
]);
|
|
251
|
+
return GenericApi;
|
|
252
|
+
}();
|
|
253
|
+
/** API name */ _define_property(GenericApi, "apiName", 'GenericApi');
|
package/cjs/utils/index.js
CHANGED
|
@@ -7,6 +7,7 @@ _export_star(require("./encoder"), exports);
|
|
|
7
7
|
_export_star(require("./ie11"), exports);
|
|
8
8
|
_export_star(require("./json-token"), exports);
|
|
9
9
|
_export_star(require("./mime-types"), exports);
|
|
10
|
+
_export_star(require("./generic-api"), exports);
|
|
10
11
|
function _export_star(from, to) {
|
|
11
12
|
Object.keys(from).forEach(function(k) {
|
|
12
13
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
package/cjs/utils/json-token.js
CHANGED
|
@@ -169,11 +169,11 @@ function _ts_generator(thisArg, body) {
|
|
|
169
169
|
// encodeURI escape all non-ASCII characters but we don't want to escape latin non-ascii characters
|
|
170
170
|
// (charCode between 128 and 255).
|
|
171
171
|
return window.btoa(encodeURI(str).replace(/%C2%([89AB][0-9A-F])/g, function(_match, p1) {
|
|
172
|
-
return String.fromCharCode(parseInt(
|
|
172
|
+
return String.fromCharCode(parseInt('0x' + p1, 16));
|
|
173
173
|
}).replace(/%C3%([89AB][0-9A-F])/g, function(_match, p1) {
|
|
174
|
-
return String.fromCharCode(parseInt(
|
|
174
|
+
return String.fromCharCode(parseInt('0xc0', 16) + parseInt('0x' + p1, 16) - parseInt('0x80', 16));
|
|
175
175
|
}).replace(/%([0-9A-F]{2})/g, function(_match, p1) {
|
|
176
|
-
return String.fromCharCode(parseInt(
|
|
176
|
+
return String.fromCharCode(parseInt('0x' + p1, 16));
|
|
177
177
|
}));
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
@@ -183,83 +183,83 @@ function _ts_generator(thisArg, body) {
|
|
|
183
183
|
// Once the provided string is decoded from based64, we convert each character in its hexadecimal
|
|
184
184
|
// value prefixed with the % character to make it URI compatible.
|
|
185
185
|
var hexString = window.atob(str).replace(/./g, function(match) {
|
|
186
|
-
return
|
|
186
|
+
return '%' + match.charCodeAt(0).toString(16);
|
|
187
187
|
});
|
|
188
188
|
return decodeURI(hexString);
|
|
189
189
|
}
|
|
190
190
|
function base64EncodeUrl(str) {
|
|
191
|
-
return str.replace(/\+/g,
|
|
191
|
+
return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
192
192
|
}
|
|
193
193
|
function base64DecodeUrl(str) {
|
|
194
194
|
// Pad out with standard base64 required padding characters
|
|
195
|
-
str = (str +
|
|
196
|
-
return str.replace(/-/g,
|
|
195
|
+
str = (str + '===').slice(0, str.length + str.length % 4);
|
|
196
|
+
return str.replace(/-/g, '+').replace(/_/g, '/');
|
|
197
197
|
}
|
|
198
198
|
function createBase64Encoder() {
|
|
199
199
|
// Web browsers
|
|
200
|
-
if (typeof window !==
|
|
200
|
+
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
201
201
|
return function(data) {
|
|
202
202
|
return base64EncodeUnicode(data);
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
205
|
// NodeJS
|
|
206
|
-
if (typeof Buffer ===
|
|
206
|
+
if (typeof Buffer === 'function') {
|
|
207
207
|
return function(data) {
|
|
208
|
-
return Buffer.from(data).toString(
|
|
208
|
+
return Buffer.from(data).toString('base64');
|
|
209
209
|
};
|
|
210
210
|
}
|
|
211
|
-
throw new Error(
|
|
211
|
+
throw new Error('Cannot convert string to base64, both btoa and Buffer are undefined.');
|
|
212
212
|
}
|
|
213
213
|
function createBase64Decoder() {
|
|
214
214
|
// Web browsers
|
|
215
|
-
if (typeof window !==
|
|
215
|
+
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
216
216
|
return function(data) {
|
|
217
217
|
return base64DecodeUnicode(data);
|
|
218
218
|
};
|
|
219
219
|
}
|
|
220
220
|
// NodeJS
|
|
221
|
-
if (typeof Buffer ===
|
|
221
|
+
if (typeof Buffer === 'function') {
|
|
222
222
|
return function(data) {
|
|
223
|
-
return Buffer.from(data,
|
|
223
|
+
return Buffer.from(data, 'base64').toString();
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
|
-
throw new Error(
|
|
226
|
+
throw new Error('Cannot convert base64 to string, both atob and Buffer are undefined.');
|
|
227
227
|
}
|
|
228
228
|
function createBase64UrlEncoder() {
|
|
229
229
|
// Web browsers
|
|
230
|
-
if (typeof window !==
|
|
230
|
+
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
231
231
|
return function(data) {
|
|
232
232
|
return base64EncodeUrl(base64EncodeUnicode(data));
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
235
|
// NodeJS
|
|
236
|
-
if (typeof Buffer ===
|
|
236
|
+
if (typeof Buffer === 'function') {
|
|
237
237
|
return function(data) {
|
|
238
|
-
return base64EncodeUrl(Buffer.from(data).toString(
|
|
238
|
+
return base64EncodeUrl(Buffer.from(data).toString('base64'));
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
|
-
throw new Error(
|
|
241
|
+
throw new Error('Cannot convert string to base64, both btoa and Buffer are undefined.');
|
|
242
242
|
}
|
|
243
243
|
function createBase64UrlDecoder() {
|
|
244
244
|
// Web browsers
|
|
245
|
-
if (typeof window !==
|
|
245
|
+
if (typeof window !== 'undefined' && typeof window.btoa === 'function') {
|
|
246
246
|
return function(data) {
|
|
247
247
|
return base64DecodeUnicode(base64DecodeUrl(data));
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
250
|
// NodeJS
|
|
251
|
-
if (typeof Buffer ===
|
|
251
|
+
if (typeof Buffer === 'function') {
|
|
252
252
|
return function(data) {
|
|
253
|
-
return Buffer.from(base64DecodeUrl(data),
|
|
253
|
+
return Buffer.from(base64DecodeUrl(data), 'base64').toString();
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
|
-
throw new Error(
|
|
256
|
+
throw new Error('Cannot convert base64 to string, both atob and Buffer are undefined.');
|
|
257
257
|
}
|
|
258
258
|
function createJwtEncoder() {
|
|
259
259
|
var encoder = createBase64UrlEncoder();
|
|
260
260
|
var jwtHeader = {
|
|
261
|
-
alg:
|
|
262
|
-
typ:
|
|
261
|
+
alg: 'none',
|
|
262
|
+
typ: 'JWT'
|
|
263
263
|
};
|
|
264
264
|
return function(jwtPayload) {
|
|
265
265
|
return "".concat(encoder(JSON.stringify(jwtHeader)), ".").concat(encoder(JSON.stringify(jwtPayload)), ".");
|
|
@@ -268,7 +268,7 @@ function createJwtEncoder() {
|
|
|
268
268
|
function createJweEncoder() {
|
|
269
269
|
var aesTagLengthInBits = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 128, useHeaderAsAAD = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
270
270
|
var base64Encoder = createBase64UrlEncoder();
|
|
271
|
-
var stringEncoder = typeof window.TextEncoder !==
|
|
271
|
+
var stringEncoder = typeof window.TextEncoder !== 'undefined' ? new TextEncoder() : new _encoder.Encoder();
|
|
272
272
|
return function() {
|
|
273
273
|
var _ref = _async_to_generator(function(param, jwePayload, publicProperties) {
|
|
274
274
|
var publicKey, keyId, jweHeader, cek, wrappedCek, iv, serializedHeader, _ref, ciphertext, authenticationTag;
|
|
@@ -277,9 +277,9 @@ function createJweEncoder() {
|
|
|
277
277
|
case 0:
|
|
278
278
|
publicKey = param.publicKey, keyId = param.keyId;
|
|
279
279
|
jweHeader = {
|
|
280
|
-
alg:
|
|
281
|
-
enc:
|
|
282
|
-
typ:
|
|
280
|
+
alg: 'RSA-OAEP-256',
|
|
281
|
+
enc: 'A256GCM',
|
|
282
|
+
typ: 'JWE',
|
|
283
283
|
kid: keyId
|
|
284
284
|
};
|
|
285
285
|
publicProperties.forEach(function(property) {
|
|
@@ -317,7 +317,7 @@ function createJweEncoder() {
|
|
|
317
317
|
_ref = _state.sent(), ciphertext = _ref.ciphertext, authenticationTag = _ref.authenticationTag;
|
|
318
318
|
return [
|
|
319
319
|
2,
|
|
320
|
-
serializedHeader +
|
|
320
|
+
serializedHeader + '.' + base64Encoder((0, _crypto.ab2str)(wrappedCek)) + '.' + base64Encoder((0, _crypto.ab2str)(iv.buffer)) + '.' + base64Encoder((0, _crypto.ab2str)(ciphertext)) + '.' + base64Encoder((0, _crypto.ab2str)(authenticationTag))
|
|
321
321
|
];
|
|
322
322
|
}
|
|
323
323
|
});
|
|
@@ -173,27 +173,27 @@ function _ts_generator(thisArg, body) {
|
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
var crypto = require(
|
|
177
|
-
describe(
|
|
178
|
-
it(
|
|
176
|
+
var crypto = require('node:crypto');
|
|
177
|
+
describe('JSON token utils', function() {
|
|
178
|
+
it('should encode and decode in base64 properly a string that contains characters occupying more than 1 byte', function() {
|
|
179
179
|
var base64Encoder = (0, _jsontoken.createBase64Encoder)();
|
|
180
180
|
var base64Decoder = (0, _jsontoken.createBase64Decoder)();
|
|
181
|
-
var myString =
|
|
181
|
+
var myString = '☸☹☺☻☼☾☿';
|
|
182
182
|
var converted = base64Encoder(myString);
|
|
183
183
|
var original = base64Decoder(converted);
|
|
184
184
|
expect(original).toEqual(myString);
|
|
185
185
|
});
|
|
186
|
-
it(
|
|
186
|
+
it('should encode and decode in base64Url properly a string that contains characters occupying more than 1 byte', function() {
|
|
187
187
|
var base64UrlEncoder = (0, _jsontoken.createBase64UrlEncoder)();
|
|
188
188
|
var base64UrlDecoder = (0, _jsontoken.createBase64UrlDecoder)();
|
|
189
|
-
var myString =
|
|
189
|
+
var myString = '☸☹☺☻☼☾☿';
|
|
190
190
|
var converted = base64UrlEncoder(myString);
|
|
191
191
|
var original = base64UrlDecoder(converted);
|
|
192
192
|
expect(original).toEqual(myString);
|
|
193
193
|
});
|
|
194
194
|
});
|
|
195
|
-
describe(
|
|
196
|
-
it(
|
|
195
|
+
describe('JSON Web Encryption Token', function() {
|
|
196
|
+
it('should generate a proper JWE Token', /*#__PURE__*/ _async_to_generator(function() {
|
|
197
197
|
var expectedJwePayload, expectedJweHeader, expectedIv, cek, expectedJweEncryptedKey, outputAesGcm, jweToken, _jweToken_split, jweHeader, jweEncryptedKey, iv, cipherContent, authenticationTag, decipher, decrypted;
|
|
198
198
|
return _ts_generator(this, function(_state) {
|
|
199
199
|
switch(_state.label){
|
|
@@ -201,20 +201,20 @@ describe("JSON Web Encryption Token", function() {
|
|
|
201
201
|
/* eslint-disable @typescript-eslint/naming-convention */ expectedJwePayload = {
|
|
202
202
|
iat: 0,
|
|
203
203
|
exp: 3600,
|
|
204
|
-
iss:
|
|
205
|
-
sub:
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
iss: 'DEMO_JWE',
|
|
205
|
+
sub: 'pii',
|
|
206
|
+
'ama-tokens': {
|
|
207
|
+
'{orderId}': 'RG287F',
|
|
208
|
+
'{lastName}': 'Doe'
|
|
209
209
|
}
|
|
210
210
|
};
|
|
211
211
|
/* eslint-enable @typescript-eslint/naming-convention */ expectedJweHeader = {
|
|
212
|
-
alg:
|
|
213
|
-
enc:
|
|
214
|
-
typ:
|
|
215
|
-
kid:
|
|
216
|
-
iss:
|
|
217
|
-
sub:
|
|
212
|
+
alg: 'RSA-OAEP-256',
|
|
213
|
+
enc: 'A256GCM',
|
|
214
|
+
typ: 'JWE',
|
|
215
|
+
kid: 'TEST',
|
|
216
|
+
iss: 'DEMO_JWE',
|
|
217
|
+
sub: 'pii'
|
|
218
218
|
};
|
|
219
219
|
expectedIv = new Uint8Array([
|
|
220
220
|
21,
|
|
@@ -644,7 +644,7 @@ describe("JSON Web Encryption Token", function() {
|
|
|
644
644
|
]);
|
|
645
645
|
global.window = {
|
|
646
646
|
btoa: function(data) {
|
|
647
|
-
return Buffer.from(data,
|
|
647
|
+
return Buffer.from(data, 'ascii').toString('base64');
|
|
648
648
|
},
|
|
649
649
|
crypto: {
|
|
650
650
|
getRandomValues: jest.fn().mockReturnValue(expectedIv),
|
|
@@ -658,25 +658,25 @@ describe("JSON Web Encryption Token", function() {
|
|
|
658
658
|
return [
|
|
659
659
|
4,
|
|
660
660
|
(0, _jsontoken.createJweEncoder)(96)({
|
|
661
|
-
publicKey:
|
|
662
|
-
keyId:
|
|
661
|
+
publicKey: 'myPublicKey',
|
|
662
|
+
keyId: 'TEST'
|
|
663
663
|
}, expectedJwePayload, [
|
|
664
|
-
|
|
665
|
-
|
|
664
|
+
'iss',
|
|
665
|
+
'sub'
|
|
666
666
|
])
|
|
667
667
|
];
|
|
668
668
|
case 1:
|
|
669
669
|
jweToken = _state.sent();
|
|
670
670
|
global.window = undefined;
|
|
671
|
-
_jweToken_split = _sliced_to_array(jweToken.split(
|
|
672
|
-
expect(decodeURI(Buffer.from((0, _jsontoken.base64DecodeUrl)(jweHeader),
|
|
673
|
-
expect(Buffer.from((0, _jsontoken.base64DecodeUrl)(jweEncryptedKey),
|
|
674
|
-
expect(Buffer.from((0, _jsontoken.base64DecodeUrl)(iv),
|
|
675
|
-
decipher = crypto.createDecipheriv(
|
|
671
|
+
_jweToken_split = _sliced_to_array(jweToken.split('.'), 5), jweHeader = _jweToken_split[0], jweEncryptedKey = _jweToken_split[1], iv = _jweToken_split[2], cipherContent = _jweToken_split[3], authenticationTag = _jweToken_split[4];
|
|
672
|
+
expect(decodeURI(Buffer.from((0, _jsontoken.base64DecodeUrl)(jweHeader), 'base64').toString())).toEqual(JSON.stringify(expectedJweHeader));
|
|
673
|
+
expect(Buffer.from((0, _jsontoken.base64DecodeUrl)(jweEncryptedKey), 'base64')).toEqual(Buffer.from(expectedJweEncryptedKey));
|
|
674
|
+
expect(Buffer.from((0, _jsontoken.base64DecodeUrl)(iv), 'base64')).toEqual(Buffer.from(expectedIv));
|
|
675
|
+
decipher = crypto.createDecipheriv('aes-256-gcm', cek, Buffer.from((0, _jsontoken.base64DecodeUrl)(iv), 'base64'), {
|
|
676
676
|
authTagLength: 12
|
|
677
677
|
});
|
|
678
|
-
decipher.setAuthTag(Buffer.from((0, _jsontoken.base64DecodeUrl)(authenticationTag),
|
|
679
|
-
decrypted = decipher.update(Buffer.from((0, _jsontoken.base64DecodeUrl)(cipherContent),
|
|
678
|
+
decipher.setAuthTag(Buffer.from((0, _jsontoken.base64DecodeUrl)(authenticationTag), 'base64'));
|
|
679
|
+
decrypted = decipher.update(Buffer.from((0, _jsontoken.base64DecodeUrl)(cipherContent), 'base64'));
|
|
680
680
|
decrypted += decipher.final();
|
|
681
681
|
expect(decrypted.toString()).toEqual(JSON.stringify(expectedJwePayload));
|
|
682
682
|
return [
|
package/cli/files-pack.cjs
CHANGED
|
@@ -14,15 +14,15 @@ const distFolder = argv.dist || 'dist';
|
|
|
14
14
|
const baseDir = argv.cwd && path.resolve(process.cwd(), argv.cwd) || process.cwd();
|
|
15
15
|
const { watch, noExports } = argv;
|
|
16
16
|
const files = [
|
|
17
|
-
'README.md',
|
|
18
|
-
'LICENSE',
|
|
19
|
-
'package.json',
|
|
20
|
-
'src/**/package.json'
|
|
17
|
+
{ glob: 'README.md', cwdForCopy: baseDir },
|
|
18
|
+
{ glob: 'LICENSE', cwdForCopy: baseDir },
|
|
19
|
+
{ glob: 'package.json', cwdForCopy: baseDir },
|
|
20
|
+
{ glob: 'src/**/package.json', cwdForCopy: path.join(baseDir, 'src') }
|
|
21
21
|
];
|
|
22
22
|
/** Update package.json exports */
|
|
23
23
|
const updateExports = async () => {
|
|
24
24
|
const packageJson = JSON.parse(await node_fs_2.promises.readFile(path.join(baseDir, 'package.json'), { encoding: 'utf8' }));
|
|
25
|
-
const packageJsonFiles = globby.sync(path.join(
|
|
25
|
+
const packageJsonFiles = globby.sync(path.posix.join(distFolder, '*', '**', 'package.json'), { absolute: true });
|
|
26
26
|
packageJson.exports = packageJson.exports || {};
|
|
27
27
|
for (const packageJsonFile of packageJsonFiles) {
|
|
28
28
|
try {
|
|
@@ -52,8 +52,8 @@ const updateExports = async () => {
|
|
|
52
52
|
await node_fs_2.promises.writeFile(path.join(baseDir, distFolder, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
53
53
|
};
|
|
54
54
|
void (async () => {
|
|
55
|
-
const copyToDist = (file) => {
|
|
56
|
-
const distFile = path.resolve(baseDir, distFolder, path.relative(
|
|
55
|
+
const copyToDist = (file, cwdForCopy) => {
|
|
56
|
+
const distFile = path.resolve(baseDir, distFolder, path.relative(cwdForCopy, file));
|
|
57
57
|
// eslint-disable-next-line no-console
|
|
58
58
|
console.log(`${file} copied to ${distFile}`);
|
|
59
59
|
try {
|
|
@@ -63,17 +63,17 @@ void (async () => {
|
|
|
63
63
|
return (0, node_fs_1.copyFileSync)(file, distFile);
|
|
64
64
|
};
|
|
65
65
|
// Move files into the dist folder
|
|
66
|
-
const copies = files.map(async (glob) => {
|
|
66
|
+
const copies = files.map(async ({ glob, cwdForCopy }) => {
|
|
67
67
|
return watch ?
|
|
68
|
-
Promise.resolve().then(() => require('chokidar')).then((chokidar) => chokidar.watch(
|
|
68
|
+
Promise.resolve().then(() => require('chokidar')).then((chokidar) => chokidar.watch(glob, { cwd: baseDir }))
|
|
69
69
|
.then((watcher) => watcher.on('all', (event, file) => {
|
|
70
70
|
if (event !== 'unlink' && event !== 'unlinkDir') {
|
|
71
|
-
copyToDist(file);
|
|
71
|
+
copyToDist(file, cwdForCopy);
|
|
72
72
|
return updateExports();
|
|
73
73
|
}
|
|
74
74
|
})) :
|
|
75
|
-
globby.sync(
|
|
76
|
-
.forEach((file) => copyToDist(file));
|
|
75
|
+
globby.sync(glob)
|
|
76
|
+
.forEach((file) => copyToDist(file, cwdForCopy));
|
|
77
77
|
});
|
|
78
78
|
await Promise.all(copies);
|
|
79
79
|
// Edit package.json exports
|
package/cli/files-pack.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files-pack.cjs","sourceRoot":"","sources":["../../cli/files-pack.cts"],"names":[],"mappings":";;AAEA;;GAEG;;AAEH,qCAAkD;AAClD,qCAAqC;AACrC,kCAAkC;AAClC,qCAAyC;AACzC,iCAAiC;AAGjC,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC;AACvC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC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