@enfuce/nextgen-sdk 0.0.4 → 0.0.6

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 (112) hide show
  1. package/README.md +28 -3
  2. package/dist/authorisation-control/client.d.ts +47 -0
  3. package/dist/authorisation-control/client.js +80 -0
  4. package/dist/authorisation-control/index.d.ts +1 -0
  5. package/dist/authorisation-control/index.js +1 -0
  6. package/dist/card/client.d.ts +57 -0
  7. package/dist/card/client.js +100 -0
  8. package/dist/card/index.d.ts +1 -0
  9. package/dist/card/index.js +1 -0
  10. package/dist/cardholder/client.d.ts +53 -0
  11. package/dist/cardholder/client.js +92 -0
  12. package/dist/cardholder/index.d.ts +1 -0
  13. package/dist/cardholder/index.js +1 -0
  14. package/dist/cards/client.d.ts +47 -0
  15. package/dist/cards/client.js +80 -0
  16. package/dist/cards/index.d.ts +1 -0
  17. package/dist/cards/index.js +1 -0
  18. package/dist/esm/authorisation-control/client.d.ts +47 -0
  19. package/dist/esm/authorisation-control/client.js +75 -0
  20. package/dist/esm/authorisation-control/index.d.ts +1 -0
  21. package/dist/esm/authorisation-control/index.js +1 -0
  22. package/dist/esm/card/client.d.ts +57 -0
  23. package/dist/esm/card/client.js +95 -0
  24. package/dist/esm/card/index.d.ts +1 -0
  25. package/dist/esm/card/index.js +1 -0
  26. package/dist/esm/cardholder/client.d.ts +53 -0
  27. package/dist/esm/cardholder/client.js +87 -0
  28. package/dist/esm/cardholder/index.d.ts +1 -0
  29. package/dist/esm/cardholder/index.js +1 -0
  30. package/dist/esm/cards/client.d.ts +47 -0
  31. package/dist/esm/cards/client.js +75 -0
  32. package/dist/esm/cards/index.d.ts +1 -0
  33. package/dist/esm/cards/index.js +1 -0
  34. package/dist/esm/exchange-rate/client.d.ts +51 -0
  35. package/dist/esm/exchange-rate/client.js +83 -0
  36. package/dist/esm/exchange-rate/index.d.ts +1 -0
  37. package/dist/esm/exchange-rate/index.js +1 -0
  38. package/dist/esm/issuer-events/client.d.ts +47 -0
  39. package/dist/esm/issuer-events/client.js +75 -0
  40. package/dist/esm/issuer-events/index.d.ts +1 -0
  41. package/dist/esm/issuer-events/index.js +1 -0
  42. package/dist/esm/oauth/axios.d.ts +10 -4
  43. package/dist/esm/oauth/axios.js +15 -4
  44. package/dist/esm/oauth/index.js +5 -2
  45. package/dist/esm/pin/client.d.ts +49 -0
  46. package/dist/esm/pin/client.js +79 -0
  47. package/dist/esm/pin/index.d.ts +1 -0
  48. package/dist/esm/pin/index.js +1 -0
  49. package/dist/esm/threeds/client.d.ts +47 -0
  50. package/dist/esm/threeds/client.js +75 -0
  51. package/dist/esm/threeds/index.d.ts +1 -0
  52. package/dist/esm/threeds/index.js +1 -0
  53. package/dist/esm/threeds-oob/client.d.ts +47 -0
  54. package/dist/esm/threeds-oob/client.js +75 -0
  55. package/dist/esm/threeds-oob/index.d.ts +1 -0
  56. package/dist/esm/threeds-oob/index.js +1 -0
  57. package/dist/esm/wallet/client.d.ts +61 -0
  58. package/dist/esm/wallet/client.js +103 -0
  59. package/dist/esm/wallet/index.d.ts +1 -0
  60. package/dist/esm/wallet/index.js +1 -0
  61. package/dist/exchange-rate/client.d.ts +51 -0
  62. package/dist/exchange-rate/client.js +88 -0
  63. package/dist/exchange-rate/index.d.ts +1 -0
  64. package/dist/exchange-rate/index.js +1 -0
  65. package/dist/issuer-events/client.d.ts +47 -0
  66. package/dist/issuer-events/client.js +80 -0
  67. package/dist/issuer-events/index.d.ts +1 -0
  68. package/dist/issuer-events/index.js +1 -0
  69. package/dist/oauth/axios.d.ts +10 -4
  70. package/dist/oauth/axios.js +15 -4
  71. package/dist/oauth/index.js +5 -2
  72. package/dist/pin/client.d.ts +49 -0
  73. package/dist/pin/client.js +84 -0
  74. package/dist/pin/index.d.ts +1 -0
  75. package/dist/pin/index.js +1 -0
  76. package/dist/threeds/client.d.ts +47 -0
  77. package/dist/threeds/client.js +80 -0
  78. package/dist/threeds/index.d.ts +1 -0
  79. package/dist/threeds/index.js +1 -0
  80. package/dist/threeds-oob/client.d.ts +47 -0
  81. package/dist/threeds-oob/client.js +80 -0
  82. package/dist/threeds-oob/index.d.ts +1 -0
  83. package/dist/threeds-oob/index.js +1 -0
  84. package/dist/wallet/client.d.ts +61 -0
  85. package/dist/wallet/client.js +108 -0
  86. package/dist/wallet/index.d.ts +1 -0
  87. package/dist/wallet/index.js +1 -0
  88. package/package.json +1 -1
  89. package/src/authorisation-control/client.ts +86 -0
  90. package/src/authorisation-control/index.ts +2 -0
  91. package/src/card/client.ts +116 -0
  92. package/src/card/index.ts +2 -0
  93. package/src/cardholder/client.ts +104 -0
  94. package/src/cardholder/index.ts +2 -0
  95. package/src/cards/client.ts +86 -0
  96. package/src/cards/index.ts +2 -0
  97. package/src/exchange-rate/client.ts +98 -0
  98. package/src/exchange-rate/index.ts +2 -0
  99. package/src/issuer-events/client.ts +86 -0
  100. package/src/issuer-events/index.ts +2 -0
  101. package/src/oauth/axios.ts +16 -4
  102. package/src/oauth/index.ts +5 -2
  103. package/src/pin/client.ts +92 -0
  104. package/src/pin/index.ts +2 -0
  105. package/src/threeds/client.ts +86 -0
  106. package/src/threeds/index.ts +2 -0
  107. package/src/threeds-oob/client.ts +86 -0
  108. package/src/threeds-oob/index.ts +2 -0
  109. package/src/wallet/client.ts +128 -0
  110. package/src/wallet/index.ts +2 -0
  111. package/test/exchange-rate-client.test.ts +36 -0
  112. package/test/oauth.test.ts +19 -0
@@ -0,0 +1,92 @@
1
+ /*
2
+ * Enfuce nextgen SDK — fluent module client.
3
+ *
4
+ * GENERATED by scripts/generate.sh from a custom template (generator-templates/typescript). One per
5
+ * API module: wires an OAuth-enabled axios instance (bearer token on every request + reactive 401
6
+ * retry) to the module's Configuration and exposes each API. Nothing is shared across modules.
7
+ */
8
+ import globalAxios, { type AxiosInstance } from 'axios';
9
+ import { createOAuthAxios, type TokenManager } from '../oauth';
10
+ import { Configuration } from './configuration';
11
+ import {
12
+ PINOperationsUsingPKIApi,
13
+ PINOperationsWithPreSharedKeyApi,
14
+ } from './api';
15
+
16
+ /**
17
+ * Fluent entry point for this module. Build one with {@link PinClient.builder}:
18
+ *
19
+ * ```ts
20
+ * const client = PinClient.builder()
21
+ * .baseUrl('https://api.example.com/...')
22
+ * .oauth(tokens)
23
+ * .build();
24
+ * ```
25
+ */
26
+ export class PinClient {
27
+
28
+ constructor(
29
+ /** The axios instance — OAuth interceptors and any customizations already applied. */
30
+ readonly http: AxiosInstance,
31
+ /** The module configuration — base path applied. */
32
+ readonly configuration: Configuration,
33
+ ) {}
34
+
35
+ /** Build any API in this module bound to this client (for APIs without a named getter). */
36
+ api<T>(factory: (configuration: Configuration, http: AxiosInstance) => T): T {
37
+ return factory(this.configuration, this.http);
38
+ }
39
+
40
+ /** {@link PINOperationsUsingPKIApi} bound to this client. */
41
+ pINOperationsUsingPKIApi(): PINOperationsUsingPKIApi {
42
+ return new PINOperationsUsingPKIApi(this.configuration, undefined, this.http);
43
+ }
44
+
45
+ /** {@link PINOperationsWithPreSharedKeyApi} bound to this client. */
46
+ pINOperationsWithPreSharedKeyApi(): PINOperationsWithPreSharedKeyApi {
47
+ return new PINOperationsWithPreSharedKeyApi(this.configuration, undefined, this.http);
48
+ }
49
+
50
+ static builder(): PinClientBuilder {
51
+ return new PinClientBuilder();
52
+ }
53
+ }
54
+
55
+ /** Builds a {@link PinClient}: base URL + optional OAuth + transport customization. */
56
+ export class PinClientBuilder {
57
+
58
+ private _baseUrl?: string;
59
+ private _tokens?: TokenManager;
60
+ private _customizers: Array<(http: AxiosInstance) => void> = [];
61
+
62
+ /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
63
+ baseUrl(baseUrl: string): this {
64
+ this._baseUrl = baseUrl;
65
+ return this;
66
+ }
67
+
68
+ /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
69
+ oauth(tokens: TokenManager): this {
70
+ this._tokens = tokens;
71
+ return this;
72
+ }
73
+
74
+ /**
75
+ * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
76
+ * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
77
+ * calls run in order.
78
+ */
79
+ configure(customizer: (http: AxiosInstance) => void): this {
80
+ this._customizers.push(customizer);
81
+ return this;
82
+ }
83
+
84
+ build(): PinClient {
85
+ const http = this._tokens ? createOAuthAxios(this._tokens) : globalAxios.create();
86
+ for (const customizer of this._customizers) {
87
+ customizer(http);
88
+ }
89
+ const configuration = new Configuration({ basePath: this._baseUrl });
90
+ return new PinClient(http, configuration);
91
+ }
92
+ }
package/src/pin/index.ts CHANGED
@@ -16,3 +16,5 @@
16
16
  export * from "./api";
17
17
  export * from "./configuration";
18
18
 
19
+
20
+ export * from './client';
@@ -0,0 +1,86 @@
1
+ /*
2
+ * Enfuce nextgen SDK — fluent module client.
3
+ *
4
+ * GENERATED by scripts/generate.sh from a custom template (generator-templates/typescript). One per
5
+ * API module: wires an OAuth-enabled axios instance (bearer token on every request + reactive 401
6
+ * retry) to the module's Configuration and exposes each API. Nothing is shared across modules.
7
+ */
8
+ import globalAxios, { type AxiosInstance } from 'axios';
9
+ import { createOAuthAxios, type TokenManager } from '../oauth';
10
+ import { Configuration } from './configuration';
11
+ import {
12
+ ThreeDSApi,
13
+ } from './api';
14
+
15
+ /**
16
+ * Fluent entry point for this module. Build one with {@link ThreedsClient.builder}:
17
+ *
18
+ * ```ts
19
+ * const client = ThreedsClient.builder()
20
+ * .baseUrl('https://api.example.com/...')
21
+ * .oauth(tokens)
22
+ * .build();
23
+ * ```
24
+ */
25
+ export class ThreedsClient {
26
+
27
+ constructor(
28
+ /** The axios instance — OAuth interceptors and any customizations already applied. */
29
+ readonly http: AxiosInstance,
30
+ /** The module configuration — base path applied. */
31
+ readonly configuration: Configuration,
32
+ ) {}
33
+
34
+ /** Build any API in this module bound to this client (for APIs without a named getter). */
35
+ api<T>(factory: (configuration: Configuration, http: AxiosInstance) => T): T {
36
+ return factory(this.configuration, this.http);
37
+ }
38
+
39
+ /** {@link ThreeDSApi} bound to this client. */
40
+ threeDSApi(): ThreeDSApi {
41
+ return new ThreeDSApi(this.configuration, undefined, this.http);
42
+ }
43
+
44
+ static builder(): ThreedsClientBuilder {
45
+ return new ThreedsClientBuilder();
46
+ }
47
+ }
48
+
49
+ /** Builds a {@link ThreedsClient}: base URL + optional OAuth + transport customization. */
50
+ export class ThreedsClientBuilder {
51
+
52
+ private _baseUrl?: string;
53
+ private _tokens?: TokenManager;
54
+ private _customizers: Array<(http: AxiosInstance) => void> = [];
55
+
56
+ /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
57
+ baseUrl(baseUrl: string): this {
58
+ this._baseUrl = baseUrl;
59
+ return this;
60
+ }
61
+
62
+ /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
63
+ oauth(tokens: TokenManager): this {
64
+ this._tokens = tokens;
65
+ return this;
66
+ }
67
+
68
+ /**
69
+ * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
70
+ * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
71
+ * calls run in order.
72
+ */
73
+ configure(customizer: (http: AxiosInstance) => void): this {
74
+ this._customizers.push(customizer);
75
+ return this;
76
+ }
77
+
78
+ build(): ThreedsClient {
79
+ const http = this._tokens ? createOAuthAxios(this._tokens) : globalAxios.create();
80
+ for (const customizer of this._customizers) {
81
+ customizer(http);
82
+ }
83
+ const configuration = new Configuration({ basePath: this._baseUrl });
84
+ return new ThreedsClient(http, configuration);
85
+ }
86
+ }
@@ -16,3 +16,5 @@
16
16
  export * from "./api";
17
17
  export * from "./configuration";
18
18
 
19
+
20
+ export * from './client';
@@ -0,0 +1,86 @@
1
+ /*
2
+ * Enfuce nextgen SDK — fluent module client.
3
+ *
4
+ * GENERATED by scripts/generate.sh from a custom template (generator-templates/typescript). One per
5
+ * API module: wires an OAuth-enabled axios instance (bearer token on every request + reactive 401
6
+ * retry) to the module's Configuration and exposes each API. Nothing is shared across modules.
7
+ */
8
+ import globalAxios, { type AxiosInstance } from 'axios';
9
+ import { createOAuthAxios, type TokenManager } from '../oauth';
10
+ import { Configuration } from './configuration';
11
+ import {
12
+ OOBAuthenticationChallengeWebhookNotificationApi,
13
+ } from './api';
14
+
15
+ /**
16
+ * Fluent entry point for this module. Build one with {@link ThreedsOobClient.builder}:
17
+ *
18
+ * ```ts
19
+ * const client = ThreedsOobClient.builder()
20
+ * .baseUrl('https://api.example.com/...')
21
+ * .oauth(tokens)
22
+ * .build();
23
+ * ```
24
+ */
25
+ export class ThreedsOobClient {
26
+
27
+ constructor(
28
+ /** The axios instance — OAuth interceptors and any customizations already applied. */
29
+ readonly http: AxiosInstance,
30
+ /** The module configuration — base path applied. */
31
+ readonly configuration: Configuration,
32
+ ) {}
33
+
34
+ /** Build any API in this module bound to this client (for APIs without a named getter). */
35
+ api<T>(factory: (configuration: Configuration, http: AxiosInstance) => T): T {
36
+ return factory(this.configuration, this.http);
37
+ }
38
+
39
+ /** {@link OOBAuthenticationChallengeWebhookNotificationApi} bound to this client. */
40
+ oOBAuthenticationChallengeWebhookNotificationApi(): OOBAuthenticationChallengeWebhookNotificationApi {
41
+ return new OOBAuthenticationChallengeWebhookNotificationApi(this.configuration, undefined, this.http);
42
+ }
43
+
44
+ static builder(): ThreedsOobClientBuilder {
45
+ return new ThreedsOobClientBuilder();
46
+ }
47
+ }
48
+
49
+ /** Builds a {@link ThreedsOobClient}: base URL + optional OAuth + transport customization. */
50
+ export class ThreedsOobClientBuilder {
51
+
52
+ private _baseUrl?: string;
53
+ private _tokens?: TokenManager;
54
+ private _customizers: Array<(http: AxiosInstance) => void> = [];
55
+
56
+ /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
57
+ baseUrl(baseUrl: string): this {
58
+ this._baseUrl = baseUrl;
59
+ return this;
60
+ }
61
+
62
+ /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
63
+ oauth(tokens: TokenManager): this {
64
+ this._tokens = tokens;
65
+ return this;
66
+ }
67
+
68
+ /**
69
+ * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
70
+ * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
71
+ * calls run in order.
72
+ */
73
+ configure(customizer: (http: AxiosInstance) => void): this {
74
+ this._customizers.push(customizer);
75
+ return this;
76
+ }
77
+
78
+ build(): ThreedsOobClient {
79
+ const http = this._tokens ? createOAuthAxios(this._tokens) : globalAxios.create();
80
+ for (const customizer of this._customizers) {
81
+ customizer(http);
82
+ }
83
+ const configuration = new Configuration({ basePath: this._baseUrl });
84
+ return new ThreedsOobClient(http, configuration);
85
+ }
86
+ }
@@ -16,3 +16,5 @@
16
16
  export * from "./api";
17
17
  export * from "./configuration";
18
18
 
19
+
20
+ export * from './client';
@@ -0,0 +1,128 @@
1
+ /*
2
+ * Enfuce nextgen SDK — fluent module client.
3
+ *
4
+ * GENERATED by scripts/generate.sh from a custom template (generator-templates/typescript). One per
5
+ * API module: wires an OAuth-enabled axios instance (bearer token on every request + reactive 401
6
+ * retry) to the module's Configuration and exposes each API. Nothing is shared across modules.
7
+ */
8
+ import globalAxios, { type AxiosInstance } from 'axios';
9
+ import { createOAuthAxios, type TokenManager } from '../oauth';
10
+ import { Configuration } from './configuration';
11
+ import {
12
+ ActivateTokenApi,
13
+ DeactivateTokenApi,
14
+ EligibleTokenRequestorsApi,
15
+ GetTokensApi,
16
+ PushCardsApi,
17
+ PushProvisionApi,
18
+ SuspendTokenApi,
19
+ UnsuspendTokenApi,
20
+ } from './api';
21
+
22
+ /**
23
+ * Fluent entry point for this module. Build one with {@link WalletClient.builder}:
24
+ *
25
+ * ```ts
26
+ * const client = WalletClient.builder()
27
+ * .baseUrl('https://api.example.com/...')
28
+ * .oauth(tokens)
29
+ * .build();
30
+ * ```
31
+ */
32
+ export class WalletClient {
33
+
34
+ constructor(
35
+ /** The axios instance — OAuth interceptors and any customizations already applied. */
36
+ readonly http: AxiosInstance,
37
+ /** The module configuration — base path applied. */
38
+ readonly configuration: Configuration,
39
+ ) {}
40
+
41
+ /** Build any API in this module bound to this client (for APIs without a named getter). */
42
+ api<T>(factory: (configuration: Configuration, http: AxiosInstance) => T): T {
43
+ return factory(this.configuration, this.http);
44
+ }
45
+
46
+ /** {@link ActivateTokenApi} bound to this client. */
47
+ activateTokenApi(): ActivateTokenApi {
48
+ return new ActivateTokenApi(this.configuration, undefined, this.http);
49
+ }
50
+
51
+ /** {@link DeactivateTokenApi} bound to this client. */
52
+ deactivateTokenApi(): DeactivateTokenApi {
53
+ return new DeactivateTokenApi(this.configuration, undefined, this.http);
54
+ }
55
+
56
+ /** {@link EligibleTokenRequestorsApi} bound to this client. */
57
+ eligibleTokenRequestorsApi(): EligibleTokenRequestorsApi {
58
+ return new EligibleTokenRequestorsApi(this.configuration, undefined, this.http);
59
+ }
60
+
61
+ /** {@link GetTokensApi} bound to this client. */
62
+ getTokensApi(): GetTokensApi {
63
+ return new GetTokensApi(this.configuration, undefined, this.http);
64
+ }
65
+
66
+ /** {@link PushCardsApi} bound to this client. */
67
+ pushCardsApi(): PushCardsApi {
68
+ return new PushCardsApi(this.configuration, undefined, this.http);
69
+ }
70
+
71
+ /** {@link PushProvisionApi} bound to this client. */
72
+ pushProvisionApi(): PushProvisionApi {
73
+ return new PushProvisionApi(this.configuration, undefined, this.http);
74
+ }
75
+
76
+ /** {@link SuspendTokenApi} bound to this client. */
77
+ suspendTokenApi(): SuspendTokenApi {
78
+ return new SuspendTokenApi(this.configuration, undefined, this.http);
79
+ }
80
+
81
+ /** {@link UnsuspendTokenApi} bound to this client. */
82
+ unsuspendTokenApi(): UnsuspendTokenApi {
83
+ return new UnsuspendTokenApi(this.configuration, undefined, this.http);
84
+ }
85
+
86
+ static builder(): WalletClientBuilder {
87
+ return new WalletClientBuilder();
88
+ }
89
+ }
90
+
91
+ /** Builds a {@link WalletClient}: base URL + optional OAuth + transport customization. */
92
+ export class WalletClientBuilder {
93
+
94
+ private _baseUrl?: string;
95
+ private _tokens?: TokenManager;
96
+ private _customizers: Array<(http: AxiosInstance) => void> = [];
97
+
98
+ /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
99
+ baseUrl(baseUrl: string): this {
100
+ this._baseUrl = baseUrl;
101
+ return this;
102
+ }
103
+
104
+ /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
105
+ oauth(tokens: TokenManager): this {
106
+ this._tokens = tokens;
107
+ return this;
108
+ }
109
+
110
+ /**
111
+ * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
112
+ * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
113
+ * calls run in order.
114
+ */
115
+ configure(customizer: (http: AxiosInstance) => void): this {
116
+ this._customizers.push(customizer);
117
+ return this;
118
+ }
119
+
120
+ build(): WalletClient {
121
+ const http = this._tokens ? createOAuthAxios(this._tokens) : globalAxios.create();
122
+ for (const customizer of this._customizers) {
123
+ customizer(http);
124
+ }
125
+ const configuration = new Configuration({ basePath: this._baseUrl });
126
+ return new WalletClient(http, configuration);
127
+ }
128
+ }
@@ -16,3 +16,5 @@
16
16
  export * from "./api";
17
17
  export * from "./configuration";
18
18
 
19
+
20
+ export * from './client';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The generated fluent module client (exchangeRate.ExchangeRateClient) — a representative check that
3
+ * the client.mustache template wires the builder, base path, API getters and the configure() seam.
4
+ * Built without OAuth (no token manager) so the test needs no network.
5
+ */
6
+ import { describe, expect, it } from 'vitest';
7
+ import { exchangeRate } from '../src';
8
+
9
+ describe('ExchangeRateClient (generated facade)', () => {
10
+ it('builder applies the base path and exposes the module APIs', () => {
11
+ const client = exchangeRate.ExchangeRateClient.builder()
12
+ .baseUrl('http://localhost/exchange-rate')
13
+ .build();
14
+
15
+ expect(client.configuration.basePath).toBe('http://localhost/exchange-rate');
16
+ expect(client.getECBExchangeRateApi()).toBeInstanceOf(exchangeRate.GetECBExchangeRateApi);
17
+ expect(client.getECBSupportedCurrenciesApi()).toBeInstanceOf(exchangeRate.GetECBSupportedCurrenciesApi);
18
+ expect(client.getFXExchangeRatesApi()).toBeInstanceOf(exchangeRate.GetFXExchangeRatesApi);
19
+
20
+ // Generic escape hatch for any API bound to the same client.
21
+ expect(client.api((c, http) => new exchangeRate.GetECBExchangeRateApi(c, undefined, http)))
22
+ .toBeInstanceOf(exchangeRate.GetECBExchangeRateApi);
23
+ });
24
+
25
+ it('configure() runs against the axios instance and composes (e.g. a timeout)', () => {
26
+ let calls = 0;
27
+ const client = exchangeRate.ExchangeRateClient.builder()
28
+ .baseUrl('http://x')
29
+ .configure(() => { calls += 1; })
30
+ .configure((http) => { http.defaults.timeout = 1234; })
31
+ .build();
32
+
33
+ expect(calls).toBe(1);
34
+ expect(client.http.defaults.timeout).toBe(1234);
35
+ });
36
+ });
@@ -139,6 +139,25 @@ describe('clientCredentialsFetcher', () => {
139
139
  });
140
140
 
141
141
  describe('createOAuthAxios', () => {
142
+ it('proactively attaches a bearer token to a request that has no Authorization header', async () => {
143
+ const { fetch, calls } = countingFetcher();
144
+ const mgr = new TokenManager(fetch, 60, makeClock().now);
145
+
146
+ const seenAuth: (string | undefined)[] = [];
147
+ const adapter: AxiosAdapter = async (config) => {
148
+ seenAuth.push(config.headers?.Authorization as string | undefined);
149
+ return { data: { ok: true }, status: 200, statusText: 'OK', headers: {}, config };
150
+ };
151
+ const http = createOAuthAxios(mgr, axios.create({ adapter }));
152
+
153
+ // No Authorization header supplied — the SDK must attach one (as for a no-security-scheme spec).
154
+ const response = await http.request({ url: 'http://localhost/v1/ecb/currencies', method: 'get' });
155
+
156
+ expect(response.status).toBe(200);
157
+ expect(seenAuth).toEqual(['Bearer token-1']);
158
+ expect(calls.n).toBe(1);
159
+ });
160
+
142
161
  it('retries the request with a refreshed token when the first call rejects with 401', async () => {
143
162
  const { fetch } = countingFetcher();
144
163
  const mgr = new TokenManager(fetch, 60, makeClock().now);