@ama-sdk/core 11.0.0-next.0 → 11.0.0-next.2

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.
Files changed (268) hide show
  1. package/README.md +4 -1
  2. package/cjs/clients/api-angular-client.js +45 -23
  3. package/cjs/clients/api-beacon-client.js +64 -20
  4. package/cjs/clients/api-fetch-client.js +66 -21
  5. package/cjs/fwk/Reviver.js +7 -7
  6. package/cjs/fwk/api.helper.spec.js +20 -20
  7. package/cjs/fwk/api.helpers.js +14 -14
  8. package/cjs/fwk/core/api-client.js +1 -1
  9. package/cjs/fwk/core/base-api-constructor.js +1 -1
  10. package/cjs/fwk/date.js +9 -9
  11. package/cjs/fwk/date.spec.js +25 -25
  12. package/cjs/fwk/errors.js +3 -3
  13. package/cjs/fwk/mocks/alf-mock-adapter.js +4 -4
  14. package/cjs/fwk/mocks/base-mock-adapter.js +2 -2
  15. package/cjs/fwk/mocks/helpers.js +3 -3
  16. package/cjs/fwk/reviver.spec.js +46 -10
  17. package/cjs/plugins/additional-params/additional-params-sync.request.js +2 -2
  18. package/cjs/plugins/additional-params/additional-params.request.js +3 -3
  19. package/cjs/plugins/additional-params/additional-params.spec.js +30 -30
  20. package/cjs/plugins/api-configuration-override/api-configuration-override.request.js +2 -2
  21. package/cjs/plugins/api-configuration-override/api-configuration-override.spec.js +13 -13
  22. package/cjs/plugins/api-key/api-key.request.js +2 -2
  23. package/cjs/plugins/api-key/api-key.spec.js +11 -11
  24. package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +6 -5
  25. package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +33 -33
  26. package/cjs/plugins/client-facts/client-facts.request.js +3 -3
  27. package/cjs/plugins/client-facts/client-facts.spec.js +27 -27
  28. package/cjs/plugins/concurrent/concurrent.fetch.js +1 -0
  29. package/cjs/plugins/concurrent/concurrent.spec.js +4 -4
  30. package/cjs/plugins/custom-info/custom-info.spec.js +15 -15
  31. package/cjs/plugins/exception/exception.reply.js +2 -2
  32. package/cjs/plugins/exception/exception.spec.js +15 -15
  33. package/cjs/plugins/fetch-cache/fetch-cache.request.js +4 -4
  34. package/cjs/plugins/fetch-cache/fetch-cache.spec.js +20 -20
  35. package/cjs/plugins/fetch-credentials/fetch-credentials.request.js +1 -1
  36. package/cjs/plugins/fetch-credentials/fetch-credentials.spec.js +8 -8
  37. package/cjs/plugins/json-token/json-token.reply.js +5 -5
  38. package/cjs/plugins/json-token/json-token.request.js +4 -4
  39. package/cjs/plugins/json-token/json-token.spec.js +24 -24
  40. package/cjs/plugins/keepalive/keepalive.request.js +2 -2
  41. package/cjs/plugins/keepalive/keepalive.spec.js +4 -4
  42. package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +32 -40
  43. package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +30 -26
  44. package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +3 -3
  45. package/cjs/plugins/mock-intercept/mock-intercept.interface.js +2 -2
  46. package/cjs/plugins/mock-intercept/mock-intercept.request.js +3 -3
  47. package/cjs/plugins/mock-intercept/mock-intercept.spec.js +28 -28
  48. package/cjs/plugins/perf-metric/perf-metric.fetch.js +1 -1
  49. package/cjs/plugins/perf-metric/perf-metric.probe.spec.js +9 -9
  50. package/cjs/plugins/pii-tokenizer/pii-tokenizer.request.js +11 -11
  51. package/cjs/plugins/pii-tokenizer/pii-tokenizer.spec.js +94 -94
  52. package/cjs/plugins/raw-response-info/raw-response-info.spec.js +12 -12
  53. package/cjs/plugins/retry/retry.spec.js +20 -20
  54. package/cjs/plugins/reviver/reviver.reply.js +35 -2
  55. package/cjs/plugins/reviver/reviver.spec.js +6 -6
  56. package/cjs/plugins/session-id/session-id.request.js +7 -6
  57. package/cjs/plugins/session-id/session-id.spec.js +13 -13
  58. package/cjs/plugins/si-token/si-token.spec.js +9 -9
  59. package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +4 -4
  60. package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +44 -44
  61. package/cjs/plugins/timeout/timeout.fetch.js +12 -10
  62. package/cjs/plugins/timeout/timeout.spec.js +13 -13
  63. package/cjs/plugins/url-rewrite/url-rewrite.spec.js +9 -9
  64. package/cjs/plugins/wait-for/wait-for.spec.js +9 -9
  65. package/cjs/utils/crypto.js +14 -14
  66. package/cjs/utils/generic-api.js +253 -0
  67. package/cjs/utils/index.js +1 -0
  68. package/cjs/utils/json-token.js +30 -30
  69. package/cjs/utils/json-token.spec.js +31 -31
  70. package/cli/files-pack.cjs +12 -12
  71. package/cli/files-pack.cjs.map +1 -1
  72. package/esm2015/clients/api-angular-client.js +49 -27
  73. package/esm2015/clients/api-beacon-client.js +65 -21
  74. package/esm2015/clients/api-fetch-client.js +70 -25
  75. package/esm2015/clients/index.js +2 -2
  76. package/esm2015/fwk/Reviver.js +10 -7
  77. package/esm2015/fwk/api.helper.spec.js +21 -21
  78. package/esm2015/fwk/api.helpers.js +14 -14
  79. package/esm2015/fwk/core/api-client.js +1 -1
  80. package/esm2015/fwk/core/base-api-constructor.js +1 -1
  81. package/esm2015/fwk/core/index.js +2 -2
  82. package/esm2015/fwk/date.js +9 -9
  83. package/esm2015/fwk/date.spec.js +26 -26
  84. package/esm2015/fwk/errors.js +3 -3
  85. package/esm2015/fwk/index.js +10 -10
  86. package/esm2015/fwk/mocks/alf-mock-adapter.js +6 -6
  87. package/esm2015/fwk/mocks/base-mock-adapter.js +3 -3
  88. package/esm2015/fwk/mocks/helpers.js +3 -3
  89. package/esm2015/fwk/mocks/index.js +10 -10
  90. package/esm2015/fwk/mocks/random-mock-adapter.js +1 -1
  91. package/esm2015/fwk/mocks/sequential-mock-adapter.js +1 -1
  92. package/esm2015/fwk/reviver.spec.js +47 -11
  93. package/esm2015/plugins/additional-params/additional-params-sync.request.js +3 -3
  94. package/esm2015/plugins/additional-params/additional-params.request.js +3 -3
  95. package/esm2015/plugins/additional-params/additional-params.spec.js +32 -32
  96. package/esm2015/plugins/additional-params/index.js +2 -2
  97. package/esm2015/plugins/api-configuration-override/api-configuration-override.request.js +2 -2
  98. package/esm2015/plugins/api-configuration-override/api-configuration-override.spec.js +14 -14
  99. package/esm2015/plugins/api-configuration-override/index.js +1 -1
  100. package/esm2015/plugins/api-key/api-key.request.js +2 -2
  101. package/esm2015/plugins/api-key/api-key.spec.js +12 -12
  102. package/esm2015/plugins/api-key/index.js +1 -1
  103. package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +6 -6
  104. package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +34 -34
  105. package/esm2015/plugins/bot-protection-fingerprint/index.js +1 -1
  106. package/esm2015/plugins/client-facts/client-facts.request.js +4 -4
  107. package/esm2015/plugins/client-facts/client-facts.spec.js +28 -28
  108. package/esm2015/plugins/client-facts/index.js +1 -1
  109. package/esm2015/plugins/concurrent/concurrent.fetch.js +1 -0
  110. package/esm2015/plugins/concurrent/concurrent.spec.js +5 -5
  111. package/esm2015/plugins/concurrent/index.js +1 -1
  112. package/esm2015/plugins/core/index.js +4 -4
  113. package/esm2015/plugins/custom-info/custom-info.spec.js +17 -17
  114. package/esm2015/plugins/custom-info/index.js +1 -1
  115. package/esm2015/plugins/exception/exception.reply.js +4 -4
  116. package/esm2015/plugins/exception/exception.spec.js +18 -18
  117. package/esm2015/plugins/exception/index.js +1 -1
  118. package/esm2015/plugins/fetch-cache/fetch-cache.request.js +4 -4
  119. package/esm2015/plugins/fetch-cache/fetch-cache.spec.js +21 -21
  120. package/esm2015/plugins/fetch-cache/index.js +1 -1
  121. package/esm2015/plugins/fetch-credentials/fetch-credentials.request.js +1 -1
  122. package/esm2015/plugins/fetch-credentials/fetch-credentials.spec.js +9 -9
  123. package/esm2015/plugins/fetch-credentials/index.js +1 -1
  124. package/esm2015/plugins/index.js +25 -25
  125. package/esm2015/plugins/json-token/index.js +2 -2
  126. package/esm2015/plugins/json-token/json-token.reply.js +5 -5
  127. package/esm2015/plugins/json-token/json-token.request.js +4 -4
  128. package/esm2015/plugins/json-token/json-token.spec.js +27 -27
  129. package/esm2015/plugins/keepalive/index.js +1 -1
  130. package/esm2015/plugins/keepalive/keepalive.request.js +2 -2
  131. package/esm2015/plugins/keepalive/keepalive.spec.js +5 -5
  132. package/esm2015/plugins/mgw-mdw-auth/index.js +1 -1
  133. package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +34 -42
  134. package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +32 -28
  135. package/esm2015/plugins/mock-intercept/index.js +2 -2
  136. package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +5 -5
  137. package/esm2015/plugins/mock-intercept/mock-intercept.interface.js +2 -2
  138. package/esm2015/plugins/mock-intercept/mock-intercept.request.js +4 -4
  139. package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +32 -32
  140. package/esm2015/plugins/perf-metric/index.js +1 -1
  141. package/esm2015/plugins/perf-metric/perf-metric.fetch.js +2 -2
  142. package/esm2015/plugins/perf-metric/perf-metric.probe.spec.js +10 -10
  143. package/esm2015/plugins/pii-tokenizer/index.js +1 -1
  144. package/esm2015/plugins/pii-tokenizer/pii-tokenizer.request.js +12 -12
  145. package/esm2015/plugins/pii-tokenizer/pii-tokenizer.spec.js +96 -96
  146. package/esm2015/plugins/raw-response-info/index.js +1 -1
  147. package/esm2015/plugins/raw-response-info/raw-response-info.spec.js +14 -14
  148. package/esm2015/plugins/retry/index.js +1 -1
  149. package/esm2015/plugins/retry/retry.fetch.js +1 -1
  150. package/esm2015/plugins/retry/retry.spec.js +21 -21
  151. package/esm2015/plugins/reviver/index.js +1 -1
  152. package/esm2015/plugins/reviver/reviver.reply.js +35 -2
  153. package/esm2015/plugins/reviver/reviver.spec.js +8 -8
  154. package/esm2015/plugins/session-id/index.js +1 -1
  155. package/esm2015/plugins/session-id/session-id.request.js +8 -7
  156. package/esm2015/plugins/session-id/session-id.spec.js +14 -14
  157. package/esm2015/plugins/si-token/index.js +1 -1
  158. package/esm2015/plugins/si-token/si-token.request.js +1 -1
  159. package/esm2015/plugins/si-token/si-token.spec.js +10 -10
  160. package/esm2015/plugins/simple-api-key-authentication/index.js +1 -1
  161. package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +5 -5
  162. package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.spec.js +46 -46
  163. package/esm2015/plugins/timeout/index.js +1 -1
  164. package/esm2015/plugins/timeout/timeout.fetch.js +13 -11
  165. package/esm2015/plugins/timeout/timeout.spec.js +15 -15
  166. package/esm2015/plugins/url-rewrite/index.js +1 -1
  167. package/esm2015/plugins/url-rewrite/url-rewrite.spec.js +10 -10
  168. package/esm2015/plugins/wait-for/index.js +1 -1
  169. package/esm2015/plugins/wait-for/wait-for.spec.js +10 -10
  170. package/esm2015/public_api.js +4 -4
  171. package/esm2015/utils/crypto.js +15 -15
  172. package/esm2015/utils/generic-api.js +245 -0
  173. package/esm2015/utils/index.js +6 -5
  174. package/esm2015/utils/json-token.js +32 -32
  175. package/esm2015/utils/json-token.spec.js +32 -32
  176. package/package.json +67 -40
  177. package/schematics/ng-add/index.d.ts +4 -2
  178. package/schematics/ng-add/index.d.ts.map +1 -1
  179. package/schematics/ng-add/index.js +58 -40
  180. package/schematics/ng-add/index.js.map +1 -1
  181. package/src/clients/api-angular-client.d.ts +6 -3
  182. package/src/clients/api-angular-client.d.ts.map +1 -1
  183. package/src/clients/api-angular-client.js +31 -16
  184. package/src/clients/api-angular-client.js.map +1 -1
  185. package/src/clients/api-beacon-client.d.ts +7 -5
  186. package/src/clients/api-beacon-client.d.ts.map +1 -1
  187. package/src/clients/api-beacon-client.js +24 -14
  188. package/src/clients/api-beacon-client.js.map +1 -1
  189. package/src/clients/api-fetch-client.d.ts +5 -3
  190. package/src/clients/api-fetch-client.d.ts.map +1 -1
  191. package/src/clients/api-fetch-client.js +26 -14
  192. package/src/clients/api-fetch-client.js.map +1 -1
  193. package/src/fwk/Reviver.d.ts +16 -4
  194. package/src/fwk/Reviver.d.ts.map +1 -1
  195. package/src/fwk/Reviver.js +9 -6
  196. package/src/fwk/Reviver.js.map +1 -1
  197. package/src/fwk/api.helpers.d.ts +1 -1
  198. package/src/fwk/api.helpers.d.ts.map +1 -1
  199. package/src/fwk/api.helpers.js +1 -1
  200. package/src/fwk/api.helpers.js.map +1 -1
  201. package/src/fwk/core/api-client.d.ts +36 -1
  202. package/src/fwk/core/api-client.d.ts.map +1 -1
  203. package/src/fwk/core/api-client.js.map +1 -1
  204. package/src/fwk/date.js.map +1 -1
  205. package/src/fwk/mocks/alf-mock-adapter.js.map +1 -1
  206. package/src/fwk/mocks/base-mock-adapter.js.map +1 -1
  207. package/src/fwk/mocks/helpers.js.map +1 -1
  208. package/src/fwk/mocks/random-mock-adapter.js.map +1 -1
  209. package/src/fwk/mocks/sequential-mock-adapter.js.map +1 -1
  210. package/src/plugins/additional-params/additional-params-sync.request.js.map +1 -1
  211. package/src/plugins/additional-params/additional-params.request.js.map +1 -1
  212. package/src/plugins/api-configuration-override/api-configuration-override.request.js.map +1 -1
  213. package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.d.ts +1 -1
  214. package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.d.ts.map +1 -1
  215. package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +1 -1
  216. package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js.map +1 -1
  217. package/src/plugins/client-facts/client-facts.request.js.map +1 -1
  218. package/src/plugins/concurrent/concurrent.fetch.d.ts.map +1 -1
  219. package/src/plugins/concurrent/concurrent.fetch.js +1 -0
  220. package/src/plugins/concurrent/concurrent.fetch.js.map +1 -1
  221. package/src/plugins/core/plugin.d.ts +6 -1
  222. package/src/plugins/core/plugin.d.ts.map +1 -1
  223. package/src/plugins/core/reply-plugin.d.ts +0 -2
  224. package/src/plugins/core/reply-plugin.d.ts.map +1 -1
  225. package/src/plugins/core/request-plugin.d.ts +2 -0
  226. package/src/plugins/core/request-plugin.d.ts.map +1 -1
  227. package/src/plugins/exception/exception.reply.js.map +1 -1
  228. package/src/plugins/fetch-cache/fetch-cache.request.js.map +1 -1
  229. package/src/plugins/json-token/json-token.reply.js.map +1 -1
  230. package/src/plugins/json-token/json-token.request.js.map +1 -1
  231. package/src/plugins/keepalive/keepalive.request.js.map +1 -1
  232. package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.d.ts +2 -2
  233. package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.d.ts.map +1 -1
  234. package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +26 -28
  235. package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js.map +1 -1
  236. package/src/plugins/mock-intercept/mock-intercept.fetch.js.map +1 -1
  237. package/src/plugins/mock-intercept/mock-intercept.request.js.map +1 -1
  238. package/src/plugins/perf-metric/perf-metric.fetch.js.map +1 -1
  239. package/src/plugins/pii-tokenizer/pii-tokenizer.request.d.ts.map +1 -1
  240. package/src/plugins/pii-tokenizer/pii-tokenizer.request.js.map +1 -1
  241. package/src/plugins/raw-response-info/raw-response-info.reply.js.map +1 -1
  242. package/src/plugins/retry/retry.fetch.js.map +1 -1
  243. package/src/plugins/reviver/reviver.reply.d.ts +7 -0
  244. package/src/plugins/reviver/reviver.reply.d.ts.map +1 -1
  245. package/src/plugins/reviver/reviver.reply.js +12 -1
  246. package/src/plugins/reviver/reviver.reply.js.map +1 -1
  247. package/src/plugins/session-id/session-id.request.d.ts +1 -0
  248. package/src/plugins/session-id/session-id.request.d.ts.map +1 -1
  249. package/src/plugins/session-id/session-id.request.js +1 -0
  250. package/src/plugins/session-id/session-id.request.js.map +1 -1
  251. package/src/plugins/si-token/si-token.request.js.map +1 -1
  252. package/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js.map +1 -1
  253. package/src/plugins/timeout/timeout.fetch.d.ts.map +1 -1
  254. package/src/plugins/timeout/timeout.fetch.js +2 -0
  255. package/src/plugins/timeout/timeout.fetch.js.map +1 -1
  256. package/src/plugins/wait-for/wait-for.fetch.js.map +1 -1
  257. package/src/utils/crypto.js.map +1 -1
  258. package/src/utils/encoder.js.map +1 -1
  259. package/src/utils/generic-api.d.ts +39 -0
  260. package/src/utils/generic-api.d.ts.map +1 -0
  261. package/src/utils/generic-api.js +43 -0
  262. package/src/utils/generic-api.js.map +1 -0
  263. package/src/utils/index.d.ts +1 -0
  264. package/src/utils/index.d.ts.map +1 -1
  265. package/src/utils/index.js +1 -0
  266. package/src/utils/index.js.map +1 -1
  267. package/src/utils/json-token.d.ts.map +1 -1
  268. package/src/utils/json-token.js.map +1 -1
@@ -43,7 +43,7 @@ function _define_property(obj, key, value) {
43
43
  var JsonTokenRequest = /*#__PURE__*/ function() {
44
44
  "use strict";
45
45
  function JsonTokenRequest() {
46
- var storageTokenKey = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "DP_SDK_AUTH_TOKEN", sharedMemory = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
46
+ var storageTokenKey = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 'DP_SDK_AUTH_TOKEN', sharedMemory = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
47
47
  _class_call_check(this, JsonTokenRequest);
48
48
  _define_property(this, "storageTokenKey", void 0);
49
49
  _define_property(this, "sharedMemory", void 0);
@@ -58,10 +58,10 @@ var JsonTokenRequest = /*#__PURE__*/ function() {
58
58
  return {
59
59
  transform: function(data) {
60
60
  // Handle Authorization Tokens
61
- var token = typeof sessionStorage !== "undefined" ? sessionStorage.getItem(_this.storageTokenKey) : _this.sharedMemory[_this.storageTokenKey];
61
+ var token = typeof sessionStorage !== 'undefined' ? sessionStorage.getItem(_this.storageTokenKey) : _this.sharedMemory[_this.storageTokenKey];
62
62
  if (token) {
63
- data.credentials = "same-origin";
64
- data.headers.append("Authorization", token);
63
+ data.credentials = 'same-origin';
64
+ data.headers.append('Authorization', token);
65
65
  }
66
66
  return data;
67
67
  }
@@ -129,25 +129,25 @@ function _ts_generator(thisArg, body) {
129
129
  };
130
130
  }
131
131
  }
132
- describe("Json Token", function() {
133
- var tokenValue = "tokenValue";
134
- var tokenKey = "testToken";
135
- describe("request plugin", function() {
132
+ describe('Json Token', function() {
133
+ var tokenValue = 'tokenValue';
134
+ var tokenKey = 'testToken';
135
+ describe('request plugin', function() {
136
136
  var defaultGetParams = {
137
- defaultTest: "ok"
137
+ defaultTest: 'ok'
138
138
  };
139
- var defaultBody = "default";
139
+ var defaultBody = 'default';
140
140
  var options;
141
141
  beforeEach(function() {
142
142
  options = {
143
- method: "get",
143
+ method: 'get',
144
144
  queryParams: defaultGetParams,
145
145
  headers: new Headers(),
146
146
  body: defaultBody,
147
- basePath: "http://test.com/truc"
147
+ basePath: 'http://test.com/truc'
148
148
  };
149
149
  });
150
- it("should add Authorization header", /*#__PURE__*/ _async_to_generator(function() {
150
+ it('should add Authorization header', /*#__PURE__*/ _async_to_generator(function() {
151
151
  var memory, plugin, runner, result;
152
152
  return _ts_generator(this, function(_state) {
153
153
  switch(_state.label){
@@ -157,8 +157,8 @@ describe("Json Token", function() {
157
157
  };
158
158
  plugin = new _jsontokenrequest.JsonTokenRequest(tokenKey, memory);
159
159
  runner = plugin.load();
160
- if (typeof window !== "undefined" && typeof window.sessionStorage !== "undefined") {
161
- jest.spyOn(window.sessionStorage, "getItem").mockImplementation(function() {
160
+ if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
161
+ jest.spyOn(window.sessionStorage, 'getItem').mockImplementation(function() {
162
162
  return tokenValue;
163
163
  });
164
164
  }
@@ -168,18 +168,18 @@ describe("Json Token", function() {
168
168
  ];
169
169
  case 1:
170
170
  result = _state.sent();
171
- if (typeof window !== "undefined" && typeof window.sessionStorage !== "undefined") {
171
+ if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
172
172
  expect(window.sessionStorage.getItem).toHaveBeenCalledWith(tokenKey);
173
173
  }
174
- expect(result.credentials).toBe("same-origin");
175
- expect(result.headers.get("Authorization")).toBe(tokenValue);
174
+ expect(result.credentials).toBe('same-origin');
175
+ expect(result.headers.get('Authorization')).toBe(tokenValue);
176
176
  return [
177
177
  2
178
178
  ];
179
179
  }
180
180
  });
181
181
  }));
182
- it("should not add Authorization if no token", /*#__PURE__*/ _async_to_generator(function() {
182
+ it('should not add Authorization if no token', /*#__PURE__*/ _async_to_generator(function() {
183
183
  var memory, plugin, runner, result;
184
184
  return _ts_generator(this, function(_state) {
185
185
  switch(_state.label){
@@ -189,8 +189,8 @@ describe("Json Token", function() {
189
189
  };
190
190
  plugin = new _jsontokenrequest.JsonTokenRequest(tokenKey, memory);
191
191
  runner = plugin.load();
192
- if (typeof window !== "undefined" && typeof window.sessionStorage !== "undefined") {
193
- jest.spyOn(window.sessionStorage, "getItem").mockImplementation();
192
+ if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
193
+ jest.spyOn(window.sessionStorage, 'getItem').mockImplementation();
194
194
  }
195
195
  return [
196
196
  4,
@@ -198,11 +198,11 @@ describe("Json Token", function() {
198
198
  ];
199
199
  case 1:
200
200
  result = _state.sent();
201
- if (typeof window !== "undefined" && typeof window.sessionStorage !== "undefined") {
201
+ if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
202
202
  expect(window.sessionStorage.getItem).toHaveBeenCalledWith(tokenKey);
203
203
  }
204
204
  expect(result.credentials).toBeUndefined();
205
- expect(result.headers.get("Authorization")).toBeNull();
205
+ expect(result.headers.get('Authorization')).toBeNull();
206
206
  return [
207
207
  2
208
208
  ];
@@ -210,9 +210,9 @@ describe("Json Token", function() {
210
210
  });
211
211
  }));
212
212
  });
213
- describe("reply plugin", function() {
213
+ describe('reply plugin', function() {
214
214
  var reviver = jest.fn();
215
- it("should store the received token", /*#__PURE__*/ _async_to_generator(function() {
215
+ it('should store the received token', /*#__PURE__*/ _async_to_generator(function() {
216
216
  var memory, plugin, runner, data;
217
217
  return _ts_generator(this, function(_state) {
218
218
  switch(_state.label){
@@ -232,8 +232,8 @@ describe("Json Token", function() {
232
232
  }
233
233
  });
234
234
  data = {};
235
- if (typeof window !== "undefined" && typeof window.sessionStorage !== "undefined") {
236
- jest.spyOn(window.sessionStorage, "setItem").mockImplementation();
235
+ if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
236
+ jest.spyOn(window.sessionStorage, 'setItem').mockImplementation();
237
237
  }
238
238
  return [
239
239
  4,
@@ -241,7 +241,7 @@ describe("Json Token", function() {
241
241
  ];
242
242
  case 1:
243
243
  _state.sent();
244
- if (typeof window !== "undefined" && typeof window.sessionStorage !== "undefined") {
244
+ if (typeof window !== 'undefined' && typeof window.sessionStorage !== 'undefined') {
245
245
  expect(window.sessionStorage.setItem).toHaveBeenCalledWith(tokenKey, tokenValue);
246
246
  } else {
247
247
  expect(memory.testToken).toBe(tokenValue);
@@ -232,7 +232,7 @@ var KeepaliveRequest = /*#__PURE__*/ function() {
232
232
  switch(_state.label){
233
233
  case 0:
234
234
  customHeaders = new Headers();
235
- customHeaders.set("Content-Type", "application/json");
235
+ customHeaders.set('Content-Type', 'application/json');
236
236
  _state.label = 1;
237
237
  case 1:
238
238
  _state.trys.push([
@@ -243,7 +243,7 @@ var KeepaliveRequest = /*#__PURE__*/ function() {
243
243
  ]);
244
244
  return [
245
245
  4,
246
- fetch("", {
246
+ fetch('', {
247
247
  headers: customHeaders,
248
248
  keepalive: true
249
249
  })
@@ -127,13 +127,13 @@ function _ts_generator(thisArg, body) {
127
127
  };
128
128
  }
129
129
  }
130
- describe("Keepalive Request Plugin", function() {
130
+ describe('Keepalive Request Plugin', function() {
131
131
  var options = {
132
132
  headers: new Headers(),
133
- basePath: "http://test.com/truc",
134
- method: "get"
133
+ basePath: 'http://test.com/truc',
134
+ method: 'get'
135
135
  };
136
- it("keepalive should be set to true", /*#__PURE__*/ _async_to_generator(function() {
136
+ it('keepalive should be set to true', /*#__PURE__*/ _async_to_generator(function() {
137
137
  var plugin, runner, keepalive;
138
138
  return _ts_generator(this, function(_state) {
139
139
  switch(_state.label){
@@ -20,7 +20,6 @@ _export(exports, {
20
20
  }
21
21
  });
22
22
  var _uuid = require("uuid");
23
- var _crypto = require("../../utils/crypto");
24
23
  var _jsontoken = require("../../utils/json-token");
25
24
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
26
25
  try {
@@ -183,36 +182,24 @@ function sha256(value) {
183
182
  }
184
183
  function _sha256() {
185
184
  _sha256 = _async_to_generator(function(value) {
185
+ var utf8, hashBuffer, hashArray, hashHex;
186
186
  return _ts_generator(this, function(_state) {
187
187
  switch(_state.label){
188
188
  case 0:
189
- if (!(typeof window !== "undefined" && typeof window.crypto !== "undefined")) return [
190
- 3,
191
- 2
192
- ];
189
+ utf8 = new TextEncoder().encode(value);
193
190
  return [
194
191
  4,
195
- crypto.subtle.digest("SHA-256", (0, _crypto.str2ab)(value))
192
+ (globalThis.crypto || require('node:crypto').webcrypto).subtle.digest('SHA-256', utf8)
196
193
  ];
197
194
  case 1:
195
+ hashBuffer = _state.sent();
196
+ hashArray = Array.from(new Uint8Array(hashBuffer));
197
+ hashHex = hashArray.map(function(bytes) {
198
+ return bytes.toString(16).padStart(2, '0');
199
+ }).join('');
198
200
  return [
199
201
  2,
200
- _crypto.ab2str.apply(void 0, [
201
- _state.sent()
202
- ])
203
- ];
204
- case 2:
205
- // NodeJS
206
- try {
207
- return [
208
- 2,
209
- (0, _crypto.ab2str)(require("node:crypto").createHash("sha256").update(value).digest("latin1"))
210
- ];
211
- } catch (err) {
212
- throw new Error("Crypto module is not available.");
213
- }
214
- return [
215
- 2
202
+ hashHex
216
203
  ];
217
204
  }
218
205
  });
@@ -221,16 +208,17 @@ function _sha256() {
221
208
  }
222
209
  function hmacSHA256(value, secretKey) {
223
210
  try {
224
- return (0, _crypto.ab2str)(require("node:crypto").createHmac("sha256", secretKey).update(value).digest("latin1"));
211
+ var createHmac = require('node:crypto').createHmac;
212
+ return createHmac('sha256', secretKey).update(value, 'latin1').digest('base64');
225
213
  } catch (err) {
226
- throw new Error("Crypto module is not available.");
214
+ throw new Error('Crypto module is not available.');
227
215
  }
228
216
  }
229
217
  /**
230
218
  * Header definition of the JWS used for the API Manager authentication
231
219
  */ var jwsHeader = {
232
- alg: "HS256",
233
- typ: "JWT"
220
+ alg: 'HS256',
221
+ typ: 'JWT'
234
222
  };
235
223
  var MicroGatewayMiddlewareAuthenticationRequest = /*#__PURE__*/ function() {
236
224
  "use strict";
@@ -265,8 +253,8 @@ var MicroGatewayMiddlewareAuthenticationRequest = /*#__PURE__*/ function() {
265
253
  /**
266
254
  * Method used to encode a string in base64
267
255
  */ _define_property(this, "base64Encoder", void 0);
268
- if (typeof window !== "undefined") {
269
- throw new Error("The plugin can only be used in a NodeJS context");
256
+ if (typeof window !== 'undefined') {
257
+ throw new Error('The plugin can only be used in a NodeJS context');
270
258
  }
271
259
  this.applicationId = options.applicationId;
272
260
  this.expIntervalInSec = options.expIntervalInSec;
@@ -282,14 +270,16 @@ var MicroGatewayMiddlewareAuthenticationRequest = /*#__PURE__*/ function() {
282
270
  value: /**
283
271
  * Generates payload with minimal information
284
272
  */ function generatePayload() {
285
- var iatTime = Math.floor(Date.now() / 1000);
286
- var expTime = iatTime + this.expIntervalInSec;
273
+ var nonce = this.base64Encoder((0, _uuid.v4)().toString());
274
+ var nowInSeconds = Math.floor(Date.now() / 1000);
275
+ var expTime = nowInSeconds + this.expIntervalInSec;
276
+ var context = this.base64Encoder(JSON.stringify(this.context));
287
277
  return {
288
278
  iss: this.applicationId,
289
- jti: this.base64Encoder((0, _uuid.v4)().toString()),
290
- iat: iatTime,
291
- exp: expTime,
292
- context: this.base64Encoder(JSON.stringify(this.context))
279
+ exp: "".concat(expTime),
280
+ jti: nonce,
281
+ iat: "".concat(nowInSeconds),
282
+ context: context
293
283
  };
294
284
  }
295
285
  },
@@ -302,20 +292,21 @@ var MicroGatewayMiddlewareAuthenticationRequest = /*#__PURE__*/ function() {
302
292
  */ function generateMicroGatewayAuthenticationSignatureKey(payload, basePath) {
303
293
  var _this = this;
304
294
  return _async_to_generator(function() {
305
- var subString, _;
295
+ var subKeyString, keyString, _;
306
296
  return _ts_generator(this, function(_state) {
307
297
  switch(_state.label){
308
298
  case 0:
299
+ subKeyString = _this.secret + payload.jti + payload.iat + basePath;
309
300
  _ = _this.apiKey;
310
301
  return [
311
302
  4,
312
- sha256(_this.secret + payload.jti + payload.iat.toString() + basePath)
303
+ sha256(subKeyString)
313
304
  ];
314
305
  case 1:
315
- subString = _ + _state.sent();
306
+ keyString = _ + _state.sent();
316
307
  return [
317
308
  2,
318
- sha256(subString)
309
+ sha256(keyString)
319
310
  ];
320
311
  }
321
312
  });
@@ -331,7 +322,8 @@ var MicroGatewayMiddlewareAuthenticationRequest = /*#__PURE__*/ function() {
331
322
  */ function sign(payload, secretKey) {
332
323
  var message = "".concat(this.base64UrlEncoder(JSON.stringify(jwsHeader)), ".").concat(this.base64UrlEncoder(JSON.stringify(payload)));
333
324
  var signature = hmacSHA256(message, secretKey);
334
- return "".concat(message, ".").concat(this.base64UrlEncoder(signature));
325
+ var encodedSignature = (0, _jsontoken.base64EncodeUrl)(signature);
326
+ return "".concat(message, ".").concat(encodedSignature);
335
327
  }
336
328
  },
337
329
  {
@@ -381,7 +373,7 @@ var MicroGatewayMiddlewareAuthenticationRequest = /*#__PURE__*/ function() {
381
373
  ];
382
374
  case 1:
383
375
  token = _state.sent();
384
- data.headers.append("Bearer ", token);
376
+ data.headers.append('Authorization', "Bearer ".concat(token));
385
377
  return [
386
378
  2,
387
379
  data
@@ -146,7 +146,10 @@ function _ts_generator(thisArg, body) {
146
146
  };
147
147
  }
148
148
  }
149
- var authHeaderKey = "Bearer ";
149
+ var authHeaderKey = 'Authorization';
150
+ var authHeaderPrefix = 'Bearer ';
151
+ var baseUrl = 'https://domain.com';
152
+ var routePath = '/v2/shopping/air-offers';
150
153
  var options;
151
154
  var FakeHeader = function FakeHeader() {
152
155
  "use strict";
@@ -164,27 +167,27 @@ var FakeHeader = function FakeHeader() {
164
167
  });
165
168
  };
166
169
  var jsonAuthTokenOptions = {
167
- applicationId: "6X_MG__tester@test.com__PDT",
168
- apiKey: "dummy4P1K3Y",
170
+ applicationId: '6X_MG__tester@test.com__PDT',
171
+ apiKey: 'dummy4P1K3Y',
169
172
  expIntervalInSec: 60,
170
- secret: "super-secret",
173
+ secret: 'super-secret',
171
174
  context: {
172
- oid: "NCE1A0955"
175
+ oid: 'NCE1A0955'
173
176
  }
174
177
  };
175
- describe("JSON auth token request plugin", function() {
178
+ describe('JSON auth token request plugin', function() {
176
179
  beforeEach(function() {
177
180
  options = {
178
- basePath: "https://domain.com/v2/shopping/air-offers",
181
+ basePath: "".concat(baseUrl).concat(routePath),
179
182
  headers: new FakeHeader(),
180
- method: "GET"
183
+ method: 'GET'
181
184
  };
182
185
  });
183
186
  afterAll(function() {
184
187
  global.sessionStorage = undefined;
185
188
  });
186
- it("should add a Bearer in the header", /*#__PURE__*/ _async_to_generator(function() {
187
- var plugin, result;
189
+ it('should add a Bearer in the header', /*#__PURE__*/ _async_to_generator(function() {
190
+ var _result_headers_get, plugin, result;
188
191
  return _ts_generator(this, function(_state) {
189
192
  switch(_state.label){
190
193
  case 0:
@@ -196,13 +199,14 @@ describe("JSON auth token request plugin", function() {
196
199
  case 1:
197
200
  result = _state.sent();
198
201
  expect(result.headers.has(authHeaderKey)).toBeTruthy();
202
+ expect((_result_headers_get = result.headers.get(authHeaderKey)) === null || _result_headers_get === void 0 ? void 0 : _result_headers_get.startsWith(authHeaderPrefix)).toBeTruthy();
199
203
  return [
200
204
  2
201
205
  ];
202
206
  }
203
207
  });
204
208
  }));
205
- it("should check that the jws token is well formatted", /*#__PURE__*/ _async_to_generator(function() {
209
+ it('should check that the jws token is well formatted', /*#__PURE__*/ _async_to_generator(function() {
206
210
  var plugin, result, token, tokenParts;
207
211
  return _ts_generator(this, function(_state) {
208
212
  switch(_state.label){
@@ -214,8 +218,8 @@ describe("JSON auth token request plugin", function() {
214
218
  ];
215
219
  case 1:
216
220
  result = _state.sent();
217
- token = result.headers.get(authHeaderKey);
218
- tokenParts = token.split(".");
221
+ token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
222
+ tokenParts = token.split('.');
219
223
  expect(token).toBeDefined();
220
224
  expect(tokenParts.length).toEqual(3);
221
225
  return [
@@ -224,7 +228,7 @@ describe("JSON auth token request plugin", function() {
224
228
  }
225
229
  });
226
230
  }));
227
- it("should check that the header is properly set", /*#__PURE__*/ _async_to_generator(function() {
231
+ it('should check that the header is properly set', /*#__PURE__*/ _async_to_generator(function() {
228
232
  var base64URLDecoder, plugin, result, token, tokenParts, header;
229
233
  return _ts_generator(this, function(_state) {
230
234
  switch(_state.label){
@@ -237,21 +241,21 @@ describe("JSON auth token request plugin", function() {
237
241
  ];
238
242
  case 1:
239
243
  result = _state.sent();
240
- token = result.headers.get(authHeaderKey);
244
+ token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
241
245
  expect(token).toBeDefined();
242
- tokenParts = token.split(".");
246
+ tokenParts = token.split('.');
243
247
  header = JSON.parse(base64URLDecoder(tokenParts[0]));
244
248
  expect(header.alg).toBeDefined();
245
- expect(header.alg).toEqual("HS256");
249
+ expect(header.alg).toEqual('HS256');
246
250
  expect(header.typ).toBeDefined();
247
- expect(header.typ).toEqual("JWT");
251
+ expect(header.typ).toEqual('JWT');
248
252
  return [
249
253
  2
250
254
  ];
251
255
  }
252
256
  });
253
257
  }));
254
- it("should check that the payload is properly set", /*#__PURE__*/ _async_to_generator(function() {
258
+ it('should check that the payload is properly set', /*#__PURE__*/ _async_to_generator(function() {
255
259
  var base64URLDecoder, base64Decoder, plugin, result, token, tokenParts, payload, context;
256
260
  return _ts_generator(this, function(_state) {
257
261
  switch(_state.label){
@@ -265,9 +269,9 @@ describe("JSON auth token request plugin", function() {
265
269
  ];
266
270
  case 1:
267
271
  result = _state.sent();
268
- token = result.headers.get(authHeaderKey);
272
+ token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
269
273
  expect(token).toBeDefined();
270
- tokenParts = token.split(".");
274
+ tokenParts = token.split('.');
271
275
  payload = JSON.parse(base64URLDecoder(tokenParts[1]));
272
276
  expect(payload.jti).toBeDefined();
273
277
  expect(payload.iat).toBeDefined();
@@ -284,7 +288,7 @@ describe("JSON auth token request plugin", function() {
284
288
  }
285
289
  });
286
290
  }));
287
- it("should check the signature validity", /*#__PURE__*/ _async_to_generator(function() {
291
+ it('should check the signature validity', /*#__PURE__*/ _async_to_generator(function() {
288
292
  var base64URLDecoder, base64UrlEncoder, plugin, result, token, tokenParts, header, payload, signature, secretKey, _, message, signCheck;
289
293
  return _ts_generator(this, function(_state) {
290
294
  switch(_state.label){
@@ -298,15 +302,15 @@ describe("JSON auth token request plugin", function() {
298
302
  ];
299
303
  case 1:
300
304
  result = _state.sent();
301
- token = result.headers.get(authHeaderKey);
302
- tokenParts = token.split(".");
305
+ token = result.headers.get(authHeaderKey).replace(authHeaderPrefix, '');
306
+ tokenParts = token.split('.');
303
307
  header = JSON.parse(base64URLDecoder(tokenParts[0]));
304
308
  payload = JSON.parse(base64URLDecoder(tokenParts[1]));
305
309
  signature = tokenParts[2];
306
310
  _ = jsonAuthTokenOptions.apiKey;
307
311
  return [
308
312
  4,
309
- (0, _mgwmdwauthrequest.sha256)(jsonAuthTokenOptions.secret + payload.jti + payload.iat.toString() + options.basePath)
313
+ (0, _mgwmdwauthrequest.sha256)(jsonAuthTokenOptions.secret + payload.jti + payload.iat + routePath)
310
314
  ];
311
315
  case 2:
312
316
  return [
@@ -319,7 +323,7 @@ describe("JSON auth token request plugin", function() {
319
323
  secretKey = _state.sent();
320
324
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
321
325
  message = "".concat(base64UrlEncoder(JSON.stringify(header)), ".").concat(base64UrlEncoder(JSON.stringify(payload)));
322
- signCheck = base64UrlEncoder((0, _mgwmdwauthrequest.hmacSHA256)(message, secretKey));
326
+ signCheck = (0, _jsontoken.base64EncodeUrl)((0, _mgwmdwauthrequest.hmacSHA256)(message, secretKey));
323
327
  expect(signature).toEqual(signCheck);
324
328
  return [
325
329
  2
@@ -187,7 +187,7 @@ var MockInterceptFetch = /*#__PURE__*/ function() {
187
187
  if (!context.apiClient.options.requestPlugins.some(function(plugin) {
188
188
  return _instanceof(plugin, _mockinterceptrequest.MockInterceptRequest);
189
189
  })) {
190
- throw new Error("MockInterceptFetch plugin should be used only with the MockInterceptRequest plugin");
190
+ throw new Error('MockInterceptFetch plugin should be used only with the MockInterceptRequest plugin');
191
191
  }
192
192
  var _this = this;
193
193
  return {
@@ -211,11 +211,11 @@ var MockInterceptFetch = /*#__PURE__*/ function() {
211
211
  responsePromise
212
212
  ];
213
213
  }
214
- if (!(typeof _this.options.delayTiming !== "undefined")) return [
214
+ if (!(typeof _this.options.delayTiming !== 'undefined')) return [
215
215
  3,
216
216
  6
217
217
  ];
218
- if (!(typeof _this.options.delayTiming === "number")) return [
218
+ if (!(typeof _this.options.delayTiming === 'number')) return [
219
219
  3,
220
220
  2
221
221
  ];
@@ -16,5 +16,5 @@ _export(exports, {
16
16
  return CUSTOM_MOCK_REQUEST_HEADER;
17
17
  }
18
18
  });
19
- var CUSTOM_MOCK_OPERATION_ID_HEADER = "X-mock-operation-id";
20
- var CUSTOM_MOCK_REQUEST_HEADER = "X-mock-request";
19
+ var CUSTOM_MOCK_OPERATION_ID_HEADER = 'X-mock-operation-id';
20
+ var CUSTOM_MOCK_REQUEST_HEADER = 'X-mock-request';
@@ -241,7 +241,7 @@ var MockInterceptRequest = /*#__PURE__*/ function() {
241
241
  ];
242
242
  }
243
243
  requestOption = _object_spread_props(_object_spread({}, data), {
244
- method: data.method || "GET"
244
+ method: data.method || 'GET'
245
245
  });
246
246
  return [
247
247
  4,
@@ -254,7 +254,7 @@ var MockInterceptRequest = /*#__PURE__*/ function() {
254
254
  blob = new Blob([
255
255
  text
256
256
  ], {
257
- type: "application/json"
257
+ type: 'application/json'
258
258
  });
259
259
  basePath = URL.createObjectURL(blob);
260
260
  headers = data.headers || new Headers();
@@ -263,7 +263,7 @@ var MockInterceptRequest = /*#__PURE__*/ function() {
263
263
  return [
264
264
  2,
265
265
  {
266
- method: "GET",
266
+ method: 'GET',
267
267
  basePath: basePath,
268
268
  headers: headers
269
269
  }