@ama-sdk/core 10.0.0-next.8 → 11.0.0-next.0
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 +51 -31
- package/cjs/clients/api-angular-client.js +6 -2
- package/cjs/clients/api-beacon-client.js +3 -2
- package/cjs/clients/api-fetch-client.js +9 -4
- package/cjs/fwk/Reviver.js +3 -3
- package/cjs/fwk/api.helpers.js +9 -10
- package/cjs/fwk/api.js +2 -2
- package/cjs/fwk/date.js +4 -39
- package/cjs/fwk/errors.js +10 -11
- package/cjs/fwk/index.js +1 -0
- package/cjs/fwk/logger.js +9 -0
- package/cjs/fwk/mocks/alf-mock-adapter.js +1 -8
- package/cjs/fwk/mocks/base-mock-adapter.js +0 -12
- package/cjs/plugins/additional-params/additional-params.request.js +5 -5
- package/cjs/plugins/api-configuration-override/api-configuration-override.request.js +2 -2
- package/cjs/plugins/api-key/api-key.request.js +2 -2
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +77 -105
- package/cjs/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +9 -98
- package/cjs/plugins/client-facts/client-facts.request.js +5 -7
- package/cjs/plugins/concurrent/concurrent.fetch.js +2 -2
- package/cjs/plugins/core/plugin.js +1 -3
- package/cjs/plugins/custom-info/custom-info.reply.js +0 -1
- package/cjs/plugins/index.js +0 -21
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +7 -9
- package/cjs/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +1 -0
- package/cjs/plugins/mock-intercept/mock-intercept.fetch.js +5 -4
- package/cjs/plugins/mock-intercept/mock-intercept.request.js +3 -3
- package/cjs/plugins/mock-intercept/mock-intercept.spec.js +1 -3
- package/cjs/plugins/perf-metric/perf-metric.fetch.js +2 -5
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.request.js +12 -14
- package/cjs/plugins/pii-tokenizer/pii-tokenizer.spec.js +3 -1
- package/cjs/plugins/retry/retry.fetch.js +2 -3
- package/cjs/plugins/session-id/session-id.request.js +10 -11
- package/cjs/plugins/session-id/session-id.spec.js +12 -8
- package/cjs/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +2 -4
- package/cjs/plugins/timeout/timeout.fetch.js +75 -15
- package/cjs/plugins/timeout/timeout.spec.js +102 -3
- package/cjs/plugins/url-rewrite/url-rewrite.request.js +2 -2
- package/cjs/plugins/wait-for/wait-for.fetch.js +2 -2
- package/cjs/public_api.js +1 -0
- package/cjs/utils/crypto.js +5 -5
- package/cjs/utils/encoder.js +0 -5
- package/cjs/{plugins/gateway-token → utils}/index.js +5 -2
- package/cjs/utils/json-token.js +11 -13
- package/cjs/utils/json-token.spec.js +4 -2
- package/cjs/utils/mime-types.js +22 -0
- package/cli/clear-index.cjs +25 -0
- package/cli/clear-index.cjs.map +1 -0
- package/cli/clear-index.d.cts +3 -0
- package/cli/clear-index.d.cts.map +1 -0
- package/cli/files-pack.cjs +84 -0
- package/cli/files-pack.cjs.map +1 -0
- package/cli/files-pack.d.cts +3 -0
- package/cli/files-pack.d.cts.map +1 -0
- package/cli/package.json +3 -0
- package/esm2015/clients/api-angular-client.js +6 -2
- package/esm2015/clients/api-beacon-client.js +3 -2
- package/esm2015/clients/api-fetch-client.js +9 -4
- package/esm2015/fwk/Reviver.js +0 -3
- package/esm2015/fwk/api.helpers.js +3 -3
- package/esm2015/fwk/api.interface.js +1 -1
- package/esm2015/fwk/api.js +2 -2
- package/esm2015/fwk/core/api-client.js +0 -1
- package/esm2015/fwk/core/base-api-constructor.js +0 -1
- package/esm2015/fwk/date.js +1 -38
- package/esm2015/fwk/errors.js +2 -3
- package/esm2015/fwk/index.js +1 -0
- package/esm2015/fwk/logger.js +6 -0
- package/esm2015/fwk/mocks/alf-mock-adapter.js +1 -9
- package/esm2015/fwk/mocks/base-mock-adapter.js +0 -12
- package/esm2015/fwk/mocks/encoded-api-request.js +3 -1
- package/esm2015/fwk/mocks/helpers.js +0 -2
- package/esm2015/fwk/mocks/mock-adapter.js +1 -1
- package/esm2015/fwk/mocks/path-object.js +1 -1
- package/esm2015/plugins/additional-params/additional-params.request.js +2 -3
- package/esm2015/plugins/api-configuration-override/api-configuration-override.request.js +2 -3
- package/esm2015/plugins/api-key/api-key.request.js +2 -2
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js +84 -118
- package/esm2015/plugins/bot-protection-fingerprint/bot-protection-fingerprint.spec.js +10 -99
- package/esm2015/plugins/client-facts/client-facts.request.js +14 -7
- package/esm2015/plugins/concurrent/concurrent.fetch.js +2 -2
- package/esm2015/plugins/core/fetch-plugin.js +4 -1
- package/esm2015/plugins/core/plugin.js +1 -1
- package/esm2015/plugins/core/reply-plugin.js +4 -1
- package/esm2015/plugins/core/request-plugin.js +4 -1
- package/esm2015/plugins/custom-info/custom-info.reply.js +0 -1
- package/esm2015/plugins/index.js +0 -4
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js +3 -7
- package/esm2015/plugins/mgw-mdw-auth/mgw-mdw-auth.spec.js +1 -0
- package/esm2015/plugins/mock-intercept/mock-intercept.fetch.js +5 -4
- package/esm2015/plugins/mock-intercept/mock-intercept.request.js +3 -3
- package/esm2015/plugins/mock-intercept/mock-intercept.spec.js +1 -3
- package/esm2015/plugins/perf-metric/perf-metric.fetch.js +2 -5
- package/esm2015/plugins/pii-tokenizer/pii-tokenizer.request.js +19 -21
- package/esm2015/plugins/retry/retry.fetch.js +2 -3
- package/esm2015/plugins/session-id/session-id.request.js +10 -11
- package/esm2015/plugins/session-id/session-id.spec.js +12 -8
- package/esm2015/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +10 -10
- package/esm2015/plugins/timeout/timeout.fetch.js +70 -12
- package/esm2015/plugins/timeout/timeout.spec.js +102 -3
- package/esm2015/plugins/url-rewrite/url-rewrite.request.js +2 -2
- package/esm2015/plugins/wait-for/wait-for.fetch.js +4 -3
- package/esm2015/public_api.js +1 -0
- package/esm2015/utils/crypto.js +0 -4
- package/esm2015/utils/encoder.js +0 -5
- package/esm2015/utils/ie11.js +0 -1
- package/esm2015/utils/index.js +5 -0
- package/esm2015/utils/json-token.js +2 -7
- package/esm2015/utils/json-token.spec.js +4 -2
- package/esm2015/utils/mime-types.js +7 -0
- package/package.json +51 -36
- package/schematics/ng-add/index.d.ts.map +1 -1
- package/schematics/ng-add/index.js +38 -20
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.json +2 -2
- package/src/clients/api-angular-client.d.ts.map +1 -1
- package/src/clients/api-angular-client.js +3 -2
- package/src/clients/api-angular-client.js.map +1 -1
- package/src/clients/api-beacon-client.d.ts +0 -1
- package/src/clients/api-beacon-client.d.ts.map +1 -1
- package/src/clients/api-beacon-client.js +1 -3
- package/src/clients/api-beacon-client.js.map +1 -1
- package/src/clients/api-fetch-client.d.ts +0 -1
- package/src/clients/api-fetch-client.d.ts.map +1 -1
- package/src/clients/api-fetch-client.js +5 -5
- package/src/clients/api-fetch-client.js.map +1 -1
- package/src/fwk/Reviver.d.ts +0 -3
- package/src/fwk/Reviver.d.ts.map +1 -1
- package/src/fwk/Reviver.js +0 -3
- package/src/fwk/Reviver.js.map +1 -1
- package/src/fwk/api.helpers.d.ts +2 -1
- package/src/fwk/api.helpers.d.ts.map +1 -1
- package/src/fwk/api.helpers.js +2 -1
- package/src/fwk/api.helpers.js.map +1 -1
- package/src/fwk/core/api-client.d.ts +0 -4
- package/src/fwk/core/api-client.d.ts.map +1 -1
- package/src/fwk/core/api-client.js +0 -1
- package/src/fwk/core/api-client.js.map +1 -1
- package/src/fwk/core/base-api-constructor.d.ts +3 -2
- package/src/fwk/core/base-api-constructor.d.ts.map +1 -1
- package/src/fwk/core/base-api-constructor.js +0 -1
- package/src/fwk/core/base-api-constructor.js.map +1 -1
- package/src/fwk/date.d.ts +0 -15
- package/src/fwk/date.d.ts.map +1 -1
- package/src/fwk/date.js +0 -36
- package/src/fwk/date.js.map +1 -1
- package/src/fwk/index.d.ts +1 -0
- package/src/fwk/index.d.ts.map +1 -1
- package/src/fwk/index.js +1 -0
- package/src/fwk/index.js.map +1 -1
- package/src/fwk/logger.d.ts +39 -0
- package/src/fwk/logger.d.ts.map +1 -0
- package/src/fwk/logger.js +2 -0
- package/src/fwk/logger.js.map +1 -0
- package/src/fwk/mocks/alf-mock-adapter.d.ts +0 -1
- package/src/fwk/mocks/alf-mock-adapter.d.ts.map +1 -1
- package/src/fwk/mocks/alf-mock-adapter.js +0 -7
- package/src/fwk/mocks/alf-mock-adapter.js.map +1 -1
- package/src/fwk/mocks/base-mock-adapter.d.ts +0 -4
- package/src/fwk/mocks/base-mock-adapter.d.ts.map +1 -1
- package/src/fwk/mocks/base-mock-adapter.js +0 -10
- package/src/fwk/mocks/base-mock-adapter.js.map +1 -1
- package/src/fwk/mocks/helpers.d.ts +0 -2
- package/src/fwk/mocks/helpers.d.ts.map +1 -1
- package/src/fwk/mocks/helpers.js +0 -2
- package/src/fwk/mocks/helpers.js.map +1 -1
- package/src/fwk/mocks/mock-adapter.d.ts +0 -10
- package/src/fwk/mocks/mock-adapter.d.ts.map +1 -1
- package/src/fwk/mocks/random-mock-adapter.d.ts +1 -1
- package/src/fwk/mocks/random-mock-adapter.d.ts.map +1 -1
- package/src/fwk/mocks/random-mock-adapter.js.map +1 -1
- package/src/plugins/additional-params/additional-params-sync.request.d.ts +1 -2
- package/src/plugins/additional-params/additional-params-sync.request.d.ts.map +1 -1
- package/src/plugins/additional-params/additional-params-sync.request.js +0 -1
- package/src/plugins/additional-params/additional-params-sync.request.js.map +1 -1
- package/src/plugins/additional-params/additional-params.request.d.ts +1 -3
- package/src/plugins/additional-params/additional-params.request.d.ts.map +1 -1
- package/src/plugins/additional-params/additional-params.request.js +0 -2
- package/src/plugins/additional-params/additional-params.request.js.map +1 -1
- package/src/plugins/api-configuration-override/api-configuration-override.request.d.ts +2 -4
- package/src/plugins/api-configuration-override/api-configuration-override.request.d.ts.map +1 -1
- package/src/plugins/api-configuration-override/api-configuration-override.request.js +0 -2
- package/src/plugins/api-configuration-override/api-configuration-override.request.js.map +1 -1
- package/src/plugins/api-key/api-key.request.d.ts +2 -3
- package/src/plugins/api-key/api-key.request.d.ts.map +1 -1
- package/src/plugins/api-key/api-key.request.js +0 -1
- package/src/plugins/api-key/api-key.request.js.map +1 -1
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.d.ts +16 -31
- 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 +20 -61
- package/src/plugins/bot-protection-fingerprint/bot-protection-fingerprint.request.js.map +1 -1
- package/src/plugins/client-facts/client-facts.request.d.ts +15 -8
- package/src/plugins/client-facts/client-facts.request.d.ts.map +1 -1
- package/src/plugins/client-facts/client-facts.request.js +12 -5
- package/src/plugins/client-facts/client-facts.request.js.map +1 -1
- package/src/plugins/concurrent/concurrent.fetch.d.ts +1 -2
- package/src/plugins/concurrent/concurrent.fetch.d.ts.map +1 -1
- package/src/plugins/concurrent/concurrent.fetch.js +0 -1
- package/src/plugins/concurrent/concurrent.fetch.js.map +1 -1
- package/src/plugins/core/fetch-plugin.d.ts +7 -4
- package/src/plugins/core/fetch-plugin.d.ts.map +1 -1
- package/src/plugins/core/plugin.d.ts +15 -2
- package/src/plugins/core/plugin.d.ts.map +1 -1
- package/src/plugins/core/reply-plugin.d.ts +8 -5
- package/src/plugins/core/reply-plugin.d.ts.map +1 -1
- package/src/plugins/core/request-plugin.d.ts +11 -3
- package/src/plugins/core/request-plugin.d.ts.map +1 -1
- package/src/plugins/custom-info/custom-info.reply.d.ts +1 -3
- package/src/plugins/custom-info/custom-info.reply.d.ts.map +1 -1
- package/src/plugins/custom-info/custom-info.reply.js +0 -2
- package/src/plugins/custom-info/custom-info.reply.js.map +1 -1
- package/src/plugins/exception/exception.reply.d.ts +1 -1
- package/src/plugins/exception/exception.reply.d.ts.map +1 -1
- package/src/plugins/exception/exception.reply.js.map +1 -1
- package/src/plugins/fetch-cache/fetch-cache.request.d.ts +3 -3
- package/src/plugins/fetch-cache/fetch-cache.request.d.ts.map +1 -1
- package/src/plugins/fetch-credentials/fetch-credentials.request.d.ts +1 -1
- package/src/plugins/fetch-credentials/fetch-credentials.request.d.ts.map +1 -1
- package/src/plugins/index.d.ts +0 -4
- package/src/plugins/index.d.ts.map +1 -1
- package/src/plugins/index.js +0 -4
- package/src/plugins/index.js.map +1 -1
- package/src/plugins/json-token/json-token.reply.d.ts +0 -1
- package/src/plugins/json-token/json-token.reply.d.ts.map +1 -1
- package/src/plugins/json-token/json-token.reply.js +0 -1
- package/src/plugins/json-token/json-token.reply.js.map +1 -1
- package/src/plugins/json-token/json-token.request.d.ts +2 -3
- package/src/plugins/json-token/json-token.request.d.ts.map +1 -1
- package/src/plugins/json-token/json-token.request.js +0 -1
- package/src/plugins/json-token/json-token.request.js.map +1 -1
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.d.ts +2 -8
- 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 +0 -6
- package/src/plugins/mgw-mdw-auth/mgw-mdw-auth.request.js.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.fetch.d.ts.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.fetch.js +3 -2
- package/src/plugins/mock-intercept/mock-intercept.fetch.js.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.request.d.ts +1 -1
- package/src/plugins/mock-intercept/mock-intercept.request.d.ts.map +1 -1
- package/src/plugins/mock-intercept/mock-intercept.request.js +1 -1
- package/src/plugins/mock-intercept/mock-intercept.request.js.map +1 -1
- package/src/plugins/perf-metric/perf-metric.fetch.d.ts +0 -3
- package/src/plugins/perf-metric/perf-metric.fetch.d.ts.map +1 -1
- package/src/plugins/perf-metric/perf-metric.fetch.js +0 -3
- package/src/plugins/perf-metric/perf-metric.fetch.js.map +1 -1
- package/src/plugins/pii-tokenizer/pii-tokenizer.request.d.ts +19 -21
- package/src/plugins/pii-tokenizer/pii-tokenizer.request.d.ts.map +1 -1
- package/src/plugins/pii-tokenizer/pii-tokenizer.request.js +18 -20
- package/src/plugins/pii-tokenizer/pii-tokenizer.request.js.map +1 -1
- package/src/plugins/retry/retry.fetch.d.ts +8 -7
- package/src/plugins/retry/retry.fetch.d.ts.map +1 -1
- package/src/plugins/retry/retry.fetch.js +0 -2
- package/src/plugins/retry/retry.fetch.js.map +1 -1
- package/src/plugins/session-id/session-id.request.d.ts +7 -6
- package/src/plugins/session-id/session-id.request.d.ts.map +1 -1
- package/src/plugins/session-id/session-id.request.js +11 -12
- package/src/plugins/session-id/session-id.request.js.map +1 -1
- package/src/plugins/si-token/si-token.request.d.ts +0 -1
- package/src/plugins/si-token/si-token.request.d.ts.map +1 -1
- package/src/plugins/si-token/si-token.request.js +0 -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.d.ts +10 -11
- package/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.d.ts.map +1 -1
- package/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js +8 -9
- package/src/plugins/simple-api-key-authentication/simple-api-key-authentication.request.js.map +1 -1
- package/src/plugins/timeout/timeout.fetch.d.ts +31 -2
- package/src/plugins/timeout/timeout.fetch.d.ts.map +1 -1
- package/src/plugins/timeout/timeout.fetch.js +62 -10
- package/src/plugins/timeout/timeout.fetch.js.map +1 -1
- package/src/plugins/url-rewrite/url-rewrite.request.d.ts +1 -2
- package/src/plugins/url-rewrite/url-rewrite.request.d.ts.map +1 -1
- package/src/plugins/url-rewrite/url-rewrite.request.js +0 -1
- package/src/plugins/url-rewrite/url-rewrite.request.js.map +1 -1
- package/src/plugins/wait-for/wait-for.fetch.d.ts +2 -3
- package/src/plugins/wait-for/wait-for.fetch.d.ts.map +1 -1
- package/src/plugins/wait-for/wait-for.fetch.js +2 -2
- package/src/plugins/wait-for/wait-for.fetch.js.map +1 -1
- package/src/public_api.d.ts +1 -0
- package/src/public_api.d.ts.map +1 -1
- package/src/public_api.js +1 -0
- package/src/public_api.js.map +1 -1
- package/src/utils/crypto.d.ts +0 -4
- package/src/utils/crypto.d.ts.map +1 -1
- package/src/utils/crypto.js +0 -4
- package/src/utils/crypto.js.map +1 -1
- package/src/utils/encoder.d.ts +0 -1
- package/src/utils/encoder.d.ts.map +1 -1
- package/src/utils/encoder.js +0 -5
- package/src/utils/encoder.js.map +1 -1
- package/src/utils/ie11.d.ts +0 -1
- package/src/utils/ie11.d.ts.map +1 -1
- package/src/utils/ie11.js +0 -1
- package/src/utils/ie11.js.map +1 -1
- package/src/utils/index.d.ts +6 -0
- package/src/utils/index.d.ts.map +1 -0
- package/src/utils/index.js +6 -0
- package/src/utils/index.js.map +1 -0
- package/src/utils/json-token.d.ts +0 -3
- package/src/utils/json-token.d.ts.map +1 -1
- package/src/utils/json-token.js +0 -5
- package/src/utils/json-token.js.map +1 -1
- package/src/utils/mime-types.d.ts +7 -0
- package/src/utils/mime-types.d.ts.map +1 -0
- package/src/utils/mime-types.js +9 -0
- package/src/utils/mime-types.js.map +1 -0
- package/cjs/plugins/fetch-options/fetch-options.request.js +0 -87
- package/cjs/plugins/fetch-options/fetch-options.spec.js +0 -280
- package/cjs/plugins/fetch-options/index.js +0 -18
- package/cjs/plugins/gateway-token/gateway-authentication.js +0 -275
- package/cjs/plugins/gateway-token/gateway-token.request.js +0 -388
- package/cjs/plugins/gateway-token/gateway-token.spec.js +0 -360
- package/cjs/plugins/imperva/imperva.fetch.js +0 -307
- package/cjs/plugins/imperva/imperva.spec.js +0 -347
- package/cjs/plugins/imperva/index.js +0 -18
- package/cjs/plugins/public-facts/index.js +0 -18
- package/cjs/plugins/public-facts/public-facts.request.js +0 -101
- package/cjs/plugins/public-facts/public-facts.spec.js +0 -367
- package/esm2015/plugins/fetch-options/fetch-options.request.js +0 -81
- package/esm2015/plugins/fetch-options/fetch-options.spec.js +0 -276
- package/esm2015/plugins/fetch-options/index.js +0 -1
- package/esm2015/plugins/gateway-token/gateway-authentication.js +0 -262
- package/esm2015/plugins/gateway-token/gateway-token.request.js +0 -406
- package/esm2015/plugins/gateway-token/gateway-token.spec.js +0 -356
- package/esm2015/plugins/gateway-token/index.js +0 -2
- package/esm2015/plugins/imperva/imperva.fetch.js +0 -303
- package/esm2015/plugins/imperva/imperva.spec.js +0 -343
- package/esm2015/plugins/imperva/index.js +0 -1
- package/esm2015/plugins/public-facts/index.js +0 -1
- package/esm2015/plugins/public-facts/public-facts.request.js +0 -138
- package/esm2015/plugins/public-facts/public-facts.spec.js +0 -363
- package/src/plugins/fetch-options/fetch-options.request.d.ts +0 -26
- package/src/plugins/fetch-options/fetch-options.request.d.ts.map +0 -1
- package/src/plugins/fetch-options/fetch-options.request.js +0 -22
- package/src/plugins/fetch-options/fetch-options.request.js.map +0 -1
- package/src/plugins/fetch-options/index.d.ts +0 -2
- package/src/plugins/fetch-options/index.d.ts.map +0 -1
- package/src/plugins/fetch-options/index.js +0 -2
- package/src/plugins/fetch-options/index.js.map +0 -1
- package/src/plugins/gateway-token/gateway-authentication.d.ts +0 -105
- package/src/plugins/gateway-token/gateway-authentication.d.ts.map +0 -1
- package/src/plugins/gateway-token/gateway-authentication.js +0 -74
- package/src/plugins/gateway-token/gateway-authentication.js.map +0 -1
- package/src/plugins/gateway-token/gateway-token.request.d.ts +0 -97
- package/src/plugins/gateway-token/gateway-token.request.d.ts.map +0 -1
- package/src/plugins/gateway-token/gateway-token.request.js +0 -127
- package/src/plugins/gateway-token/gateway-token.request.js.map +0 -1
- package/src/plugins/gateway-token/index.d.ts +0 -3
- package/src/plugins/gateway-token/index.d.ts.map +0 -1
- package/src/plugins/gateway-token/index.js +0 -3
- package/src/plugins/gateway-token/index.js.map +0 -1
- package/src/plugins/imperva/imperva.fetch.d.ts +0 -33
- package/src/plugins/imperva/imperva.fetch.d.ts.map +0 -1
- package/src/plugins/imperva/imperva.fetch.js +0 -41
- package/src/plugins/imperva/imperva.fetch.js.map +0 -1
- package/src/plugins/imperva/index.d.ts +0 -2
- package/src/plugins/imperva/index.d.ts.map +0 -1
- package/src/plugins/imperva/index.js +0 -2
- package/src/plugins/imperva/index.js.map +0 -1
- package/src/plugins/public-facts/index.d.ts +0 -2
- package/src/plugins/public-facts/index.d.ts.map +0 -1
- package/src/plugins/public-facts/index.js +0 -2
- package/src/plugins/public-facts/index.js.map +0 -1
- package/src/plugins/public-facts/public-facts.request.d.ts +0 -89
- package/src/plugins/public-facts/public-facts.request.d.ts.map +0 -1
- package/src/plugins/public-facts/public-facts.request.js +0 -62
- package/src/plugins/public-facts/public-facts.request.js.map +0 -1
|
@@ -119,13 +119,13 @@ function _ts_generator(thisArg, body) {
|
|
|
119
119
|
trys: [],
|
|
120
120
|
ops: []
|
|
121
121
|
};
|
|
122
|
-
return
|
|
122
|
+
return g = {
|
|
123
123
|
next: verb(0),
|
|
124
124
|
"throw": verb(1),
|
|
125
125
|
"return": verb(2)
|
|
126
126
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
127
127
|
return this;
|
|
128
|
-
}), g
|
|
128
|
+
}), g;
|
|
129
129
|
function verb(n) {
|
|
130
130
|
return function(v) {
|
|
131
131
|
return step([
|
|
@@ -219,7 +219,7 @@ var MockInterceptRequest = /*#__PURE__*/ function() {
|
|
|
219
219
|
_create_class(MockInterceptRequest, [
|
|
220
220
|
{
|
|
221
221
|
key: "load",
|
|
222
|
-
value: function load() {
|
|
222
|
+
value: /** @inheritdoc */ function load() {
|
|
223
223
|
var _this = this;
|
|
224
224
|
return {
|
|
225
225
|
transform: function() {
|
|
@@ -148,13 +148,11 @@ var testMock = {
|
|
|
148
148
|
};
|
|
149
149
|
var getMockSpy = jest.fn().mockReturnValue(testMock);
|
|
150
150
|
var getLatestMockSpy = jest.fn().mockReturnValue(testMock);
|
|
151
|
-
var getOperationIdSpy = jest.fn().mockReturnValue("testOperation");
|
|
152
151
|
var retrieveOperationIdSpy = jest.fn().mockReturnValue(Promise.resolve("testOperation"));
|
|
153
152
|
var initializeSpy = jest.fn().mockReturnValue(Promise.resolve());
|
|
154
153
|
var testMockAdapter = {
|
|
155
154
|
getMock: getMockSpy,
|
|
156
155
|
getLatestMock: getLatestMockSpy,
|
|
157
|
-
getOperationId: getOperationIdSpy,
|
|
158
156
|
initialize: initializeSpy,
|
|
159
157
|
retrieveOperationId: retrieveOperationIdSpy
|
|
160
158
|
};
|
|
@@ -209,6 +207,7 @@ describe("Mock intercept", function() {
|
|
|
209
207
|
return _ts_generator(this, function(_state) {
|
|
210
208
|
switch(_state.label){
|
|
211
209
|
case 0:
|
|
210
|
+
// Disabled because Blob URL is not supported on NodeJS
|
|
212
211
|
plugin = new _mockinterceptrequest.MockInterceptRequest({
|
|
213
212
|
adapter: testMockAdapter
|
|
214
213
|
});
|
|
@@ -246,7 +245,6 @@ describe("Mock intercept", function() {
|
|
|
246
245
|
initialize: initializeSpy,
|
|
247
246
|
getMock: getMockSpy,
|
|
248
247
|
getLatestMock: getLatestMockSpy,
|
|
249
|
-
getOperationId: getOperationIdSpy,
|
|
250
248
|
retrieveOperationId: retrieveOperationIdSpy
|
|
251
249
|
};
|
|
252
250
|
plugin = new _mockinterceptfetch.MockInterceptFetch({
|
|
@@ -119,13 +119,13 @@ function _ts_generator(thisArg, body) {
|
|
|
119
119
|
trys: [],
|
|
120
120
|
ops: []
|
|
121
121
|
};
|
|
122
|
-
return
|
|
122
|
+
return g = {
|
|
123
123
|
next: verb(0),
|
|
124
124
|
"throw": verb(1),
|
|
125
125
|
"return": verb(2)
|
|
126
126
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
127
127
|
return this;
|
|
128
|
-
}), g
|
|
128
|
+
}), g;
|
|
129
129
|
function verb(n) {
|
|
130
130
|
return function(v) {
|
|
131
131
|
return step([
|
|
@@ -234,7 +234,6 @@ var PerformanceMetricPlugin = /*#__PURE__*/ function() {
|
|
|
234
234
|
key: "openMark",
|
|
235
235
|
value: /**
|
|
236
236
|
* Opens a mark associated to a call.
|
|
237
|
-
*
|
|
238
237
|
* @param url URL of the call associated to the mark to open
|
|
239
238
|
* @param requestOptions Options of the call associated to the mark to open
|
|
240
239
|
*/ function openMark(url, requestOptions) {
|
|
@@ -252,7 +251,6 @@ var PerformanceMetricPlugin = /*#__PURE__*/ function() {
|
|
|
252
251
|
key: "closeMark",
|
|
253
252
|
value: /**
|
|
254
253
|
* Closes the mark matching the given mark id.
|
|
255
|
-
*
|
|
256
254
|
* @param markId Id of the mark to close
|
|
257
255
|
* @param response Response of the call associated to the mark to close
|
|
258
256
|
*/ function closeMark(markId, response) {
|
|
@@ -273,7 +271,6 @@ var PerformanceMetricPlugin = /*#__PURE__*/ function() {
|
|
|
273
271
|
key: "closeMarkWithError",
|
|
274
272
|
value: /**
|
|
275
273
|
* Closes the mark matching the given mark id with an error.
|
|
276
|
-
*
|
|
277
274
|
* @param markId Id of the mark to close
|
|
278
275
|
* @param error Optional error of the call associated to the mark to close
|
|
279
276
|
*/ function closeMarkWithError(markId, error) {
|
|
@@ -9,14 +9,14 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
|
|
13
|
-
return
|
|
12
|
+
PiiTokenizerRequest: function() {
|
|
13
|
+
return PiiTokenizerRequest;
|
|
14
14
|
},
|
|
15
15
|
createJwePiiEncoder: function() {
|
|
16
16
|
return createJwePiiEncoder;
|
|
17
17
|
},
|
|
18
|
-
|
|
19
|
-
return
|
|
18
|
+
createJwtPiiEncoder: function() {
|
|
19
|
+
return createJwtPiiEncoder;
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
var _jsontoken = require("../../utils/json-token");
|
|
@@ -106,13 +106,13 @@ function _ts_generator(thisArg, body) {
|
|
|
106
106
|
trys: [],
|
|
107
107
|
ops: []
|
|
108
108
|
};
|
|
109
|
-
return
|
|
109
|
+
return g = {
|
|
110
110
|
next: verb(0),
|
|
111
111
|
"throw": verb(1),
|
|
112
112
|
"return": verb(2)
|
|
113
113
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
114
114
|
return this;
|
|
115
|
-
}), g
|
|
115
|
+
}), g;
|
|
116
116
|
function verb(n) {
|
|
117
117
|
return function(v) {
|
|
118
118
|
return step([
|
|
@@ -252,9 +252,9 @@ var PiiTokenizerRequest = /*#__PURE__*/ function() {
|
|
|
252
252
|
key: "appendEncodedToken",
|
|
253
253
|
value: /**
|
|
254
254
|
* Append the generated token based on the request options to the tokens header
|
|
255
|
-
*
|
|
256
255
|
* @param requestOptions Request options to generate the token
|
|
257
|
-
|
|
256
|
+
* @param logger Logger (optional, fallback to console logger if undefined)
|
|
257
|
+
*/ function appendEncodedToken(requestOptions, logger) {
|
|
258
258
|
var _this = this;
|
|
259
259
|
return _async_to_generator(function() {
|
|
260
260
|
var e;
|
|
@@ -279,8 +279,7 @@ var PiiTokenizerRequest = /*#__PURE__*/ function() {
|
|
|
279
279
|
case 2:
|
|
280
280
|
e = _state.sent();
|
|
281
281
|
if (_this.silent) {
|
|
282
|
-
|
|
283
|
-
console.error("Couldn't encode the token");
|
|
282
|
+
(logger || console).error("Couldn't encode the token");
|
|
284
283
|
} else {
|
|
285
284
|
throw new Error("Couldn't encode the token");
|
|
286
285
|
}
|
|
@@ -299,7 +298,7 @@ var PiiTokenizerRequest = /*#__PURE__*/ function() {
|
|
|
299
298
|
},
|
|
300
299
|
{
|
|
301
300
|
key: "load",
|
|
302
|
-
value: function load() {
|
|
301
|
+
value: /** @inheritdoc */ function load(context) {
|
|
303
302
|
var _this = this;
|
|
304
303
|
return {
|
|
305
304
|
transform: function() {
|
|
@@ -326,8 +325,7 @@ var PiiTokenizerRequest = /*#__PURE__*/ function() {
|
|
|
326
325
|
3,
|
|
327
326
|
2
|
|
328
327
|
];
|
|
329
|
-
|
|
330
|
-
console.error("No tokenized options found. Please make sure tokenization is enabled on your ApiClient");
|
|
328
|
+
((context === null || context === void 0 ? void 0 : context.logger) || console).error("No tokenized options found. Please make sure tokenization is enabled on your ApiClient");
|
|
331
329
|
return [
|
|
332
330
|
3,
|
|
333
331
|
4
|
|
@@ -341,7 +339,7 @@ var PiiTokenizerRequest = /*#__PURE__*/ function() {
|
|
|
341
339
|
data.queryParams = _object_spread({}, data.queryParams, data.tokenizedOptions.queryParams);
|
|
342
340
|
return [
|
|
343
341
|
4,
|
|
344
|
-
_this.appendEncodedToken(data)
|
|
342
|
+
_this.appendEncodedToken(data, context === null || context === void 0 ? void 0 : context.logger)
|
|
345
343
|
];
|
|
346
344
|
case 3:
|
|
347
345
|
token1 = _state.sent();
|
|
@@ -67,7 +67,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
67
67
|
if (cache && cache.has(obj)) {
|
|
68
68
|
return cache.get(obj);
|
|
69
69
|
}
|
|
70
|
-
var newObj = {
|
|
70
|
+
var newObj = {
|
|
71
|
+
__proto__: null
|
|
72
|
+
};
|
|
71
73
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
72
74
|
for(var key in obj){
|
|
73
75
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -87,13 +87,13 @@ function _ts_generator(thisArg, body) {
|
|
|
87
87
|
trys: [],
|
|
88
88
|
ops: []
|
|
89
89
|
};
|
|
90
|
-
return
|
|
90
|
+
return g = {
|
|
91
91
|
next: verb(0),
|
|
92
92
|
"throw": verb(1),
|
|
93
93
|
"return": verb(2)
|
|
94
94
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
95
95
|
return this;
|
|
96
|
-
}), g
|
|
96
|
+
}), g;
|
|
97
97
|
function verb(n) {
|
|
98
98
|
return function(v) {
|
|
99
99
|
return step([
|
|
@@ -193,7 +193,6 @@ var RetryFetch = /*#__PURE__*/ function() {
|
|
|
193
193
|
key: "retry",
|
|
194
194
|
value: /**
|
|
195
195
|
* Launch a retry
|
|
196
|
-
*
|
|
197
196
|
* @param context
|
|
198
197
|
*/ function retry(context) {
|
|
199
198
|
var asyncResponse = fetch(context.url, context.options);
|
|
@@ -56,27 +56,26 @@ var SessionIdRequest = /*#__PURE__*/ function() {
|
|
|
56
56
|
/**
|
|
57
57
|
* The session ID used to track API calls
|
|
58
58
|
*/ _define_property(this, "sessionId", void 0);
|
|
59
|
+
// Declaration done first since generateSessionId uses the logger
|
|
59
60
|
this.sessionIdHeader = sessionIdHeader;
|
|
60
61
|
this.requestIdActivated = activateRequestId;
|
|
61
|
-
this.sessionId = this.generateSessionId();
|
|
62
62
|
}
|
|
63
63
|
_create_class(SessionIdRequest, [
|
|
64
64
|
{
|
|
65
65
|
key: "logSessionId",
|
|
66
|
-
value: function logSessionId(sessionId, date) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// eslint-disable-next-line no-console, no-restricted-syntax
|
|
70
|
-
console.info("Generated at: ".concat(date));
|
|
66
|
+
value: function logSessionId(sessionId, date, logger) {
|
|
67
|
+
((logger === null || logger === void 0 ? void 0 : logger.info) || (logger === null || logger === void 0 ? void 0 : logger.log) || console.info).bind(logger || console)('Your debug ID associated to the header "'.concat(this.sessionIdHeader, '" is: ').concat(sessionId, "."));
|
|
68
|
+
((logger === null || logger === void 0 ? void 0 : logger.info) || (logger === null || logger === void 0 ? void 0 : logger.log) || console.info).bind(logger || console)("Generated at: ".concat(date));
|
|
71
69
|
}
|
|
72
70
|
},
|
|
73
71
|
{
|
|
74
72
|
key: "load",
|
|
75
|
-
value: function load() {
|
|
73
|
+
value: /** @inheritdoc */ function load(context) {
|
|
76
74
|
var _this = this;
|
|
75
|
+
var sessionId = this.sessionId || (this.sessionId = this.generateSessionId(context === null || context === void 0 ? void 0 : context.logger));
|
|
77
76
|
return {
|
|
78
77
|
transform: function(data) {
|
|
79
|
-
data.headers.append(_this.sessionIdHeader, _this.requestIdActivated ? "".concat(
|
|
78
|
+
data.headers.append(_this.sessionIdHeader, _this.requestIdActivated ? "".concat(sessionId, ":").concat(_this.generateRequestId()) : sessionId);
|
|
80
79
|
return data;
|
|
81
80
|
}
|
|
82
81
|
};
|
|
@@ -86,7 +85,7 @@ var SessionIdRequest = /*#__PURE__*/ function() {
|
|
|
86
85
|
key: "generateSessionId",
|
|
87
86
|
value: /**
|
|
88
87
|
* Generates a session ID and stores it in session / backup storage.
|
|
89
|
-
*/ function generateSessionId() {
|
|
88
|
+
*/ function generateSessionId(logger) {
|
|
90
89
|
// Check if we already have a session ID in the shared memory
|
|
91
90
|
if (SessionIdRequest.sharedMemory[this.sessionIdHeader]) {
|
|
92
91
|
return SessionIdRequest.sharedMemory[this.sessionIdHeader];
|
|
@@ -99,7 +98,7 @@ var SessionIdRequest = /*#__PURE__*/ function() {
|
|
|
99
98
|
var parsedSessionIdObject = JSON.parse(sessionIdObjectFromStorage);
|
|
100
99
|
// update the shared memory and log the ID to the user
|
|
101
100
|
SessionIdRequest.sharedMemory[this.sessionIdHeader] = parsedSessionIdObject.id;
|
|
102
|
-
this.logSessionId(parsedSessionIdObject.id, parsedSessionIdObject.generatedTime);
|
|
101
|
+
this.logSessionId(parsedSessionIdObject.id, parsedSessionIdObject.generatedTime, logger);
|
|
103
102
|
return parsedSessionIdObject.id;
|
|
104
103
|
} catch (e) {}
|
|
105
104
|
}
|
|
@@ -108,7 +107,7 @@ var SessionIdRequest = /*#__PURE__*/ function() {
|
|
|
108
107
|
var sessionId = (0, _uuid.v4)();
|
|
109
108
|
var generatedTime = new Date().toJSON();
|
|
110
109
|
// log it
|
|
111
|
-
this.logSessionId(sessionId, generatedTime);
|
|
110
|
+
this.logSessionId(sessionId, generatedTime, logger);
|
|
112
111
|
// and store it
|
|
113
112
|
SessionIdRequest.sharedMemory[this.sessionIdHeader] = sessionId;
|
|
114
113
|
if (typeof sessionStorage !== "undefined") {
|
|
@@ -139,13 +139,13 @@ describe("Session ID Request Plugin", function() {
|
|
|
139
139
|
};
|
|
140
140
|
});
|
|
141
141
|
it("should have the default id to Ama-Client-Ref", /*#__PURE__*/ _async_to_generator(function() {
|
|
142
|
-
var plugin,
|
|
142
|
+
var plugin, runner, sessionId;
|
|
143
143
|
return _ts_generator(this, function(_state) {
|
|
144
144
|
switch(_state.label){
|
|
145
145
|
case 0:
|
|
146
146
|
plugin = new _sessionidrequest.SessionIdRequest();
|
|
147
|
-
sessionId = plugin.sessionId;
|
|
148
147
|
runner = plugin.load();
|
|
148
|
+
sessionId = plugin.sessionId;
|
|
149
149
|
return [
|
|
150
150
|
4,
|
|
151
151
|
runner.transform(options)
|
|
@@ -160,13 +160,13 @@ describe("Session ID Request Plugin", function() {
|
|
|
160
160
|
});
|
|
161
161
|
}));
|
|
162
162
|
it("should add the session ID to the headers", /*#__PURE__*/ _async_to_generator(function() {
|
|
163
|
-
var plugin,
|
|
163
|
+
var plugin, runner, sessionId;
|
|
164
164
|
return _ts_generator(this, function(_state) {
|
|
165
165
|
switch(_state.label){
|
|
166
166
|
case 0:
|
|
167
167
|
plugin = new _sessionidrequest.SessionIdRequest(TEST_KEY);
|
|
168
|
-
sessionId = plugin.sessionId;
|
|
169
168
|
runner = plugin.load();
|
|
169
|
+
sessionId = plugin.sessionId;
|
|
170
170
|
return [
|
|
171
171
|
4,
|
|
172
172
|
runner.transform(options)
|
|
@@ -183,21 +183,25 @@ describe("Session ID Request Plugin", function() {
|
|
|
183
183
|
it("second plugin with same header should use the ID that's already in memory", function() {
|
|
184
184
|
var plugin = new _sessionidrequest.SessionIdRequest(TEST_KEY);
|
|
185
185
|
var plugin2 = new _sessionidrequest.SessionIdRequest(TEST_KEY);
|
|
186
|
+
plugin.load();
|
|
187
|
+
plugin2.load();
|
|
186
188
|
expect(plugin.sessionId).toBe(plugin2.sessionId);
|
|
187
189
|
});
|
|
188
190
|
it("second plugin with different header should generate a new session ID", function() {
|
|
189
191
|
var plugin = new _sessionidrequest.SessionIdRequest(TEST_KEY);
|
|
190
192
|
var plugin2 = new _sessionidrequest.SessionIdRequest(TEST_KEY2);
|
|
193
|
+
plugin.load();
|
|
194
|
+
plugin2.load();
|
|
191
195
|
expect(plugin.sessionId).not.toBe(plugin2.sessionId);
|
|
192
196
|
});
|
|
193
197
|
it("should generate a correctly formatted ID", /*#__PURE__*/ _async_to_generator(function() {
|
|
194
|
-
var plugin,
|
|
198
|
+
var plugin, runner, sessionId;
|
|
195
199
|
return _ts_generator(this, function(_state) {
|
|
196
200
|
switch(_state.label){
|
|
197
201
|
case 0:
|
|
198
202
|
plugin = new _sessionidrequest.SessionIdRequest();
|
|
199
|
-
sessionId = plugin.sessionId;
|
|
200
203
|
runner = plugin.load();
|
|
204
|
+
sessionId = plugin.sessionId;
|
|
201
205
|
return [
|
|
202
206
|
4,
|
|
203
207
|
runner.transform(options)
|
|
@@ -213,13 +217,13 @@ describe("Session ID Request Plugin", function() {
|
|
|
213
217
|
});
|
|
214
218
|
}));
|
|
215
219
|
it("should be possible to deactivate the request ID part", /*#__PURE__*/ _async_to_generator(function() {
|
|
216
|
-
var plugin,
|
|
220
|
+
var plugin, runner, sessionId;
|
|
217
221
|
return _ts_generator(this, function(_state) {
|
|
218
222
|
switch(_state.label){
|
|
219
223
|
case 0:
|
|
220
224
|
plugin = new _sessionidrequest.SessionIdRequest(TEST_KEY, false);
|
|
221
|
-
sessionId = plugin.sessionId;
|
|
222
225
|
runner = plugin.load();
|
|
226
|
+
sessionId = plugin.sessionId;
|
|
223
227
|
return [
|
|
224
228
|
4,
|
|
225
229
|
runner.transform(options)
|
|
@@ -95,13 +95,13 @@ function _ts_generator(thisArg, body) {
|
|
|
95
95
|
trys: [],
|
|
96
96
|
ops: []
|
|
97
97
|
};
|
|
98
|
-
return
|
|
98
|
+
return g = {
|
|
99
99
|
next: verb(0),
|
|
100
100
|
"throw": verb(1),
|
|
101
101
|
"return": verb(2)
|
|
102
102
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
103
103
|
return this;
|
|
104
|
-
}), g
|
|
104
|
+
}), g;
|
|
105
105
|
function verb(n) {
|
|
106
106
|
return function(v) {
|
|
107
107
|
return step([
|
|
@@ -202,7 +202,6 @@ var SimpleApiKeyAuthenticationRequest = /*#__PURE__*/ function() {
|
|
|
202
202
|
key: "setApiKey",
|
|
203
203
|
value: /**
|
|
204
204
|
* Change the API key used for authentication
|
|
205
|
-
*
|
|
206
205
|
* @param apiKey The API key to use for authentication
|
|
207
206
|
*/ function setApiKey(apiKey) {
|
|
208
207
|
this.apiKey = apiKey;
|
|
@@ -212,7 +211,6 @@ var SimpleApiKeyAuthenticationRequest = /*#__PURE__*/ function() {
|
|
|
212
211
|
key: "setOfficeId",
|
|
213
212
|
value: /**
|
|
214
213
|
* Change the Office ID override
|
|
215
|
-
*
|
|
216
214
|
* @param officeId The Office ID to use as override
|
|
217
215
|
*/ function setOfficeId(officeId) {
|
|
218
216
|
this.options.officeId = officeId;
|
|
@@ -2,10 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
TimeoutFetch: function() {
|
|
8
13
|
return TimeoutFetch;
|
|
14
|
+
},
|
|
15
|
+
impervaCaptchaEventHandlerFactory: function() {
|
|
16
|
+
return impervaCaptchaEventHandlerFactory;
|
|
9
17
|
}
|
|
10
18
|
});
|
|
11
19
|
var _errors = require("../../fwk/errors");
|
|
@@ -80,13 +88,13 @@ function _ts_generator(thisArg, body) {
|
|
|
80
88
|
trys: [],
|
|
81
89
|
ops: []
|
|
82
90
|
};
|
|
83
|
-
return
|
|
91
|
+
return g = {
|
|
84
92
|
next: verb(0),
|
|
85
93
|
"throw": verb(1),
|
|
86
94
|
"return": verb(2)
|
|
87
95
|
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
88
96
|
return this;
|
|
89
|
-
}), g
|
|
97
|
+
}), g;
|
|
90
98
|
function verb(n) {
|
|
91
99
|
return function(v) {
|
|
92
100
|
return step([
|
|
@@ -165,13 +173,52 @@ function _ts_generator(thisArg, body) {
|
|
|
165
173
|
};
|
|
166
174
|
}
|
|
167
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Check if a message can be cast as an {@link ImpervaCaptchaMessage}
|
|
178
|
+
* @param message
|
|
179
|
+
*/ function isImpervaCaptchaMessage(message) {
|
|
180
|
+
return Object.prototype.hasOwnProperty.call(message, "impervaChallenge") && Object.prototype.hasOwnProperty.call(message.impervaChallenge, "status") && Object.prototype.hasOwnProperty.call(message.impervaChallenge, "type") && message.impervaChallenge.type === "captcha";
|
|
181
|
+
}
|
|
182
|
+
var impervaCaptchaEventHandlerFactory = function(config) {
|
|
183
|
+
return function(timeoutPauseCallback) {
|
|
184
|
+
var onImpervaCaptcha = function(event) {
|
|
185
|
+
var originHostname = new URL(event.origin).hostname;
|
|
186
|
+
if (originHostname !== location.hostname && ((config === null || config === void 0 ? void 0 : config.whiteListedHostNames) || []).indexOf(originHostname) === -1) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
var message = typeof event.data === "string" ? JSON.parse(event.data) : event.data;
|
|
190
|
+
if (message && isImpervaCaptchaMessage(message)) {
|
|
191
|
+
timeoutPauseCallback(message.impervaChallenge.status === "started" ? "timeoutStopped" : "timeoutStarted");
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
addEventListener("message", onImpervaCaptcha);
|
|
195
|
+
return function() {
|
|
196
|
+
removeEventListener("message", onImpervaCaptcha);
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
};
|
|
168
200
|
var TimeoutFetch = /*#__PURE__*/ function() {
|
|
169
201
|
"use strict";
|
|
170
202
|
function TimeoutFetch() {
|
|
171
|
-
var timeout = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 60000;
|
|
203
|
+
var timeout = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 60000, timeoutPauseEvent = arguments.length > 1 ? arguments[1] : void 0;
|
|
204
|
+
var _this = this;
|
|
172
205
|
_class_call_check(this, TimeoutFetch);
|
|
206
|
+
_define_property(this, "timeoutPauseEvent", void 0);
|
|
173
207
|
/** Fetch timeout (in millisecond) */ _define_property(this, "timeout", void 0);
|
|
208
|
+
_define_property(this, "timerSubscription", void 0);
|
|
209
|
+
_define_property(this, "timerPauseState", void 0);
|
|
210
|
+
this.timeoutPauseEvent = timeoutPauseEvent;
|
|
211
|
+
this.timerSubscription = [];
|
|
212
|
+
this.timerPauseState = "timeoutStarted";
|
|
174
213
|
this.timeout = timeout;
|
|
214
|
+
if (this.timeoutPauseEvent) {
|
|
215
|
+
this.timeoutPauseEvent(function(pausedStatus) {
|
|
216
|
+
_this.timerPauseState = pausedStatus;
|
|
217
|
+
_this.timerSubscription.forEach(function(timer) {
|
|
218
|
+
return timer.call(_this, pausedStatus);
|
|
219
|
+
});
|
|
220
|
+
}, this);
|
|
221
|
+
}
|
|
175
222
|
}
|
|
176
223
|
_create_class(TimeoutFetch, [
|
|
177
224
|
{
|
|
@@ -183,18 +230,26 @@ var TimeoutFetch = /*#__PURE__*/ function() {
|
|
|
183
230
|
return(// eslint-disable-next-line no-async-promise-executor
|
|
184
231
|
new Promise(function() {
|
|
185
232
|
var _ref = _async_to_generator(function(resolve, reject) {
|
|
186
|
-
var
|
|
233
|
+
var timeoutCallback, timer, timerCallback, _context_controller, response, ex;
|
|
187
234
|
return _ts_generator(this, function(_state) {
|
|
188
235
|
switch(_state.label){
|
|
189
236
|
case 0:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
237
|
+
timeoutCallback = function() {
|
|
238
|
+
var // Fetch abort controller is now supported by all modern browser and node 15+. It should always be defined
|
|
239
|
+
_context_controller;
|
|
193
240
|
reject(new _errors.ResponseTimeoutError("in ".concat(_this.timeout, "ms")));
|
|
194
|
-
|
|
195
|
-
|
|
241
|
+
(_context_controller = context.controller) === null || _context_controller === void 0 ? void 0 : _context_controller.abort();
|
|
242
|
+
};
|
|
243
|
+
timer = _this.timerPauseState === "timeoutStopped" ? undefined : setTimeout(timeoutCallback, _this.timeout);
|
|
244
|
+
timerCallback = function(pauseStatus) {
|
|
245
|
+
if (timer && pauseStatus === "timeoutStopped") {
|
|
246
|
+
clearTimeout(timer);
|
|
247
|
+
timer = undefined;
|
|
248
|
+
} else if (!timer && pauseStatus === "timeoutStarted") {
|
|
249
|
+
timer = setTimeout(timeoutCallback, _this.timeout);
|
|
196
250
|
}
|
|
197
|
-
}
|
|
251
|
+
};
|
|
252
|
+
_this.timerSubscription.push(timerCallback);
|
|
198
253
|
_state.label = 1;
|
|
199
254
|
case 1:
|
|
200
255
|
_state.trys.push([
|
|
@@ -209,7 +264,7 @@ var TimeoutFetch = /*#__PURE__*/ function() {
|
|
|
209
264
|
];
|
|
210
265
|
case 2:
|
|
211
266
|
response = _state.sent();
|
|
212
|
-
if (!
|
|
267
|
+
if (!((_context_controller = context.controller) === null || _context_controller === void 0 ? void 0 : _context_controller.signal.aborted)) {
|
|
213
268
|
resolve(response);
|
|
214
269
|
}
|
|
215
270
|
return [
|
|
@@ -224,7 +279,12 @@ var TimeoutFetch = /*#__PURE__*/ function() {
|
|
|
224
279
|
5
|
|
225
280
|
];
|
|
226
281
|
case 4:
|
|
227
|
-
|
|
282
|
+
if (timer) {
|
|
283
|
+
clearTimeout(timer);
|
|
284
|
+
}
|
|
285
|
+
_this.timerSubscription = _this.timerSubscription.filter(function(callback) {
|
|
286
|
+
return timerCallback !== callback;
|
|
287
|
+
});
|
|
228
288
|
return [
|
|
229
289
|
7
|
|
230
290
|
];
|
|
@@ -135,7 +135,9 @@ describe("Timeout Fetch Plugin", function() {
|
|
|
135
135
|
switch(_state.label){
|
|
136
136
|
case 0:
|
|
137
137
|
plugin = new _timeoutfetch.TimeoutFetch(100);
|
|
138
|
-
runner = plugin.load({
|
|
138
|
+
runner = plugin.load({
|
|
139
|
+
controller: new AbortController()
|
|
140
|
+
});
|
|
139
141
|
call = new Promise(function(resolve) {
|
|
140
142
|
return setTimeout(function() {
|
|
141
143
|
return resolve(undefined);
|
|
@@ -169,7 +171,9 @@ describe("Timeout Fetch Plugin", function() {
|
|
|
169
171
|
switch(_state.label){
|
|
170
172
|
case 0:
|
|
171
173
|
plugin = new _timeoutfetch.TimeoutFetch(6000);
|
|
172
|
-
runner = plugin.load({
|
|
174
|
+
runner = plugin.load({
|
|
175
|
+
controller: new AbortController()
|
|
176
|
+
});
|
|
173
177
|
call = new Promise(function(_resolve, reject) {
|
|
174
178
|
return setTimeout(function() {
|
|
175
179
|
return reject(new _errors.EmptyResponseError(""));
|
|
@@ -196,7 +200,9 @@ describe("Timeout Fetch Plugin", function() {
|
|
|
196
200
|
switch(_state.label){
|
|
197
201
|
case 0:
|
|
198
202
|
plugin = new _timeoutfetch.TimeoutFetch(2000);
|
|
199
|
-
runner = plugin.load({
|
|
203
|
+
runner = plugin.load({
|
|
204
|
+
controller: new AbortController()
|
|
205
|
+
});
|
|
200
206
|
call = new Promise(function(resolve) {
|
|
201
207
|
return setTimeout(function() {
|
|
202
208
|
return resolve({
|
|
@@ -227,4 +233,97 @@ describe("Timeout Fetch Plugin", function() {
|
|
|
227
233
|
}
|
|
228
234
|
});
|
|
229
235
|
}));
|
|
236
|
+
it("should not reject if the timeout has been paused and reject if restarted", /*#__PURE__*/ _async_to_generator(function() {
|
|
237
|
+
var timeoutPauseEvent, plugin, runner, call, callback;
|
|
238
|
+
return _ts_generator(this, function(_state) {
|
|
239
|
+
switch(_state.label){
|
|
240
|
+
case 0:
|
|
241
|
+
timeoutPauseEvent = {
|
|
242
|
+
emitEvent: function(_status) {},
|
|
243
|
+
handler: function(timeoutPauseCallback) {
|
|
244
|
+
timeoutPauseEvent.emitEvent = timeoutPauseCallback;
|
|
245
|
+
return function() {};
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
plugin = new _timeoutfetch.TimeoutFetch(100, timeoutPauseEvent.handler);
|
|
249
|
+
runner = plugin.load({
|
|
250
|
+
controller: new AbortController()
|
|
251
|
+
});
|
|
252
|
+
call = new Promise(function(resolve) {
|
|
253
|
+
return setTimeout(function() {
|
|
254
|
+
return resolve({
|
|
255
|
+
test: true
|
|
256
|
+
});
|
|
257
|
+
}, 500);
|
|
258
|
+
});
|
|
259
|
+
callback = jest.fn();
|
|
260
|
+
runner.transform(call).catch(callback);
|
|
261
|
+
timeoutPauseEvent.emitEvent("timeoutStopped");
|
|
262
|
+
return [
|
|
263
|
+
4,
|
|
264
|
+
jest.advanceTimersByTimeAsync(200)
|
|
265
|
+
];
|
|
266
|
+
case 1:
|
|
267
|
+
_state.sent();
|
|
268
|
+
timeoutPauseEvent.emitEvent("timeoutStarted");
|
|
269
|
+
return [
|
|
270
|
+
4,
|
|
271
|
+
jest.advanceTimersByTimeAsync(200)
|
|
272
|
+
];
|
|
273
|
+
case 2:
|
|
274
|
+
_state.sent();
|
|
275
|
+
expect(callback).toHaveBeenCalledWith(new _errors.ResponseTimeoutError("in 100ms"));
|
|
276
|
+
return [
|
|
277
|
+
2
|
|
278
|
+
];
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
}));
|
|
282
|
+
it("should take into account pause events triggered before the call", /*#__PURE__*/ _async_to_generator(function() {
|
|
283
|
+
var timeoutPauseEvent, plugin, runner, call, promise;
|
|
284
|
+
return _ts_generator(this, function(_state) {
|
|
285
|
+
switch(_state.label){
|
|
286
|
+
case 0:
|
|
287
|
+
timeoutPauseEvent = {
|
|
288
|
+
emitEvent: function(_status) {},
|
|
289
|
+
handler: function(timeoutPauseCallback) {
|
|
290
|
+
timeoutPauseEvent.emitEvent = timeoutPauseCallback;
|
|
291
|
+
return function() {};
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
plugin = new _timeoutfetch.TimeoutFetch(250, timeoutPauseEvent.handler);
|
|
295
|
+
runner = plugin.load({
|
|
296
|
+
controller: new AbortController()
|
|
297
|
+
});
|
|
298
|
+
call = new Promise(function(resolve) {
|
|
299
|
+
return setTimeout(function() {
|
|
300
|
+
return resolve({
|
|
301
|
+
test: true
|
|
302
|
+
});
|
|
303
|
+
}, 500);
|
|
304
|
+
});
|
|
305
|
+
timeoutPauseEvent.emitEvent("timeoutStopped");
|
|
306
|
+
promise = runner.transform(call);
|
|
307
|
+
return [
|
|
308
|
+
4,
|
|
309
|
+
jest.runAllTimersAsync()
|
|
310
|
+
];
|
|
311
|
+
case 1:
|
|
312
|
+
_state.sent();
|
|
313
|
+
return [
|
|
314
|
+
4,
|
|
315
|
+
promise
|
|
316
|
+
];
|
|
317
|
+
case 2:
|
|
318
|
+
expect.apply(void 0, [
|
|
319
|
+
_state.sent()
|
|
320
|
+
]).toEqual({
|
|
321
|
+
test: true
|
|
322
|
+
});
|
|
323
|
+
return [
|
|
324
|
+
2
|
|
325
|
+
];
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}));
|
|
230
329
|
});
|