@enfuce/nextgen-sdk 0.0.6 → 0.0.8

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 (70) hide show
  1. package/README.md +19 -6
  2. package/dist/authorisation-control/client.d.ts +2 -2
  3. package/dist/card/client.d.ts +2 -2
  4. package/dist/cardholder/client.d.ts +2 -2
  5. package/dist/cards/client.d.ts +2 -2
  6. package/dist/config/enfuceUrls.d.ts +20 -0
  7. package/dist/config/enfuceUrls.js +47 -0
  8. package/dist/config/index.d.ts +1 -0
  9. package/dist/config/index.js +22 -0
  10. package/dist/esm/authorisation-control/client.d.ts +2 -2
  11. package/dist/esm/card/client.d.ts +2 -2
  12. package/dist/esm/cardholder/client.d.ts +2 -2
  13. package/dist/esm/cards/client.d.ts +2 -2
  14. package/dist/esm/config/enfuceUrls.d.ts +20 -0
  15. package/dist/esm/config/enfuceUrls.js +40 -0
  16. package/dist/esm/config/index.d.ts +1 -0
  17. package/dist/esm/config/index.js +14 -0
  18. package/dist/esm/exchange-rate/client.d.ts +2 -2
  19. package/dist/esm/index.d.ts +1 -0
  20. package/dist/esm/index.js +1 -0
  21. package/dist/esm/issuer-events/client.d.ts +2 -2
  22. package/dist/esm/oauth/axios.d.ts +3 -3
  23. package/dist/esm/oauth/axios.js +1 -1
  24. package/dist/esm/oauth/clientCredentials.d.ts +17 -3
  25. package/dist/esm/oauth/clientCredentials.js +20 -4
  26. package/dist/esm/oauth/index.d.ts +2 -2
  27. package/dist/esm/oauth/index.js +1 -1
  28. package/dist/esm/oauth/tokenManager.d.ts +2 -2
  29. package/dist/esm/oauth/tokenManager.js +2 -2
  30. package/dist/esm/pin/client.d.ts +2 -2
  31. package/dist/esm/threeds/client.d.ts +2 -2
  32. package/dist/esm/threeds-oob/client.d.ts +2 -2
  33. package/dist/esm/wallet/client.d.ts +2 -2
  34. package/dist/exchange-rate/client.d.ts +2 -2
  35. package/dist/index.d.ts +1 -0
  36. package/dist/index.js +2 -1
  37. package/dist/issuer-events/client.d.ts +2 -2
  38. package/dist/oauth/axios.d.ts +3 -3
  39. package/dist/oauth/axios.js +1 -1
  40. package/dist/oauth/clientCredentials.d.ts +17 -3
  41. package/dist/oauth/clientCredentials.js +19 -3
  42. package/dist/oauth/index.d.ts +2 -2
  43. package/dist/oauth/index.js +2 -2
  44. package/dist/oauth/tokenManager.d.ts +2 -2
  45. package/dist/oauth/tokenManager.js +4 -4
  46. package/dist/pin/client.d.ts +2 -2
  47. package/dist/threeds/client.d.ts +2 -2
  48. package/dist/threeds-oob/client.d.ts +2 -2
  49. package/dist/wallet/client.d.ts +2 -2
  50. package/package.json +1 -1
  51. package/src/authorisation-control/client.ts +3 -3
  52. package/src/card/client.ts +3 -3
  53. package/src/cardholder/client.ts +3 -3
  54. package/src/cards/client.ts +3 -3
  55. package/src/config/enfuceUrls.ts +57 -0
  56. package/src/config/index.ts +21 -0
  57. package/src/exchange-rate/client.ts +3 -3
  58. package/src/index.ts +1 -0
  59. package/src/issuer-events/client.ts +3 -3
  60. package/src/oauth/axios.ts +3 -3
  61. package/src/oauth/clientCredentials.ts +43 -4
  62. package/src/oauth/index.ts +2 -2
  63. package/src/oauth/tokenManager.ts +2 -2
  64. package/src/pin/client.ts +3 -3
  65. package/src/threeds/client.ts +3 -3
  66. package/src/threeds-oob/client.ts +3 -3
  67. package/src/wallet/client.ts +3 -3
  68. package/test/clientCredentials.test.ts +20 -0
  69. package/test/config.test.ts +33 -0
  70. package/test/oauth.test.ts +12 -12
package/README.md CHANGED
@@ -16,19 +16,22 @@ Each API is exposed under its own namespace, and every module ships a fluent `<M
16
16
  instance to the module's configuration and exposes each API:
17
17
 
18
18
  ```typescript
19
- import { oauth, card } from '@enfuce/nextgen-sdk';
19
+ import { oauth, card, config } from '@enfuce/nextgen-sdk';
20
+
21
+ // Identify the host by tenant + environment; the config helper derives every URL from it.
22
+ const te = { tenant: '<tenant>', environment: 'eu.live.prod' };
20
23
 
21
24
  // One token manager (cached client-credentials grant) — reuse it across every module.
22
- const tokens = oauth.clientCredentials({
23
- tokenUrl: 'https://auth.<tenant>.enfuce.com/oauth2/token',
25
+ const clientCredentialsManager = oauth.clientCredentials({
26
+ tokenUrl: config.tokenUrl(te),
24
27
  clientId: '<client-id>',
25
28
  clientSecret: '<client-secret>',
26
29
  scopes: ['issuer/admin.read'],
27
30
  });
28
31
 
29
32
  const client = card.CardClient.builder()
30
- .baseUrl('https://api.<tenant>.eu.live.prod.mycore.enfuce.com/issuer')
31
- .oauth(tokens) // token on every request + reactive 401 retry
33
+ .baseUrl(config.issuerBaseUrl(te))
34
+ .oauth(clientCredentialsManager) // token on every request + reactive 401 retry
32
35
  .configure((http) => { http.defaults.timeout = 10_000; }) // optional: timeout, proxy, headers …
33
36
  .build();
34
37
 
@@ -41,9 +44,19 @@ is available for every module, including ones whose spec declares no security sc
41
44
  (e.g. `exchangeRate.ExchangeRateClient`).
42
45
 
43
46
  Prefer the lower level? Build your own axios and pass it through:
44
- `oauth.createOAuthAxios(tokens, axios.create({ timeout: 10_000 }))`, then
47
+ `oauth.createOAuthAxios(clientCredentialsManager, axios.create({ timeout: 10_000 }))`, then
45
48
  `new card.GetCardApi(new card.Configuration({ basePath }), undefined, http)`.
46
49
 
50
+ Keeping the token URL separate from the client identity? Pass a `ClientCredentials` — e.g. with the
51
+ `config` helper deriving the URL:
52
+ ```typescript
53
+ const clientCredentialsManager = oauth.clientCredentials(config.tokenUrl(te), {
54
+ clientId: '<client-id>',
55
+ clientSecret: '<client-secret>',
56
+ scopes: ['issuer/admin.read'],
57
+ });
58
+ ```
59
+
47
60
  ## Available APIs
48
61
 
49
62
  - `oauth` — OAuth2 `client_credentials` token-management helper
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { AuthorisationRequestAPIApi } from './api';
5
5
  /**
@@ -36,7 +36,7 @@ export declare class AuthorisationControlClientBuilder {
36
36
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
37
37
  baseUrl(baseUrl: string): this;
38
38
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
39
- oauth(tokens: TokenManager): this;
39
+ oauth(tokens: OAuthClientCredentialsManager): this;
40
40
  /**
41
41
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
42
42
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { CreateCardApi, CreatePINControlAccessTokenApi, GetCardApi, GetCardPaymentInfoApi, GetPlasticManufacturingHistoryApi, UpdateCardApi } from './api';
5
5
  /**
@@ -46,7 +46,7 @@ export declare class CardClientBuilder {
46
46
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
47
47
  baseUrl(baseUrl: string): this;
48
48
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
49
- oauth(tokens: TokenManager): this;
49
+ oauth(tokens: OAuthClientCredentialsManager): this;
50
50
  /**
51
51
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
52
52
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { CreateCardholderApi, GetCardholderApi, GetCardsByCardholderIdApi, UpdateCardholderApi } from './api';
5
5
  /**
@@ -42,7 +42,7 @@ export declare class CardholderClientBuilder {
42
42
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
43
43
  baseUrl(baseUrl: string): this;
44
44
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
45
- oauth(tokens: TokenManager): this;
45
+ oauth(tokens: OAuthClientCredentialsManager): this;
46
46
  /**
47
47
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
48
48
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { CardsApi } from './api';
5
5
  /**
@@ -36,7 +36,7 @@ export declare class CardsClientBuilder {
36
36
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
37
37
  baseUrl(baseUrl: string): this;
38
38
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
39
- oauth(tokens: TokenManager): this;
39
+ oauth(tokens: OAuthClientCredentialsManager): this;
40
40
  /**
41
41
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
42
42
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Identifies a single Enfuce deployment by its `tenant` and `environment` — the two variable
3
+ * segments of every Enfuce host, e.g. `api.<tenant>.<environment>.mycore.enfuce.com`.
4
+ */
5
+ export interface TenantEnvironment {
6
+ /** Tenant segment, e.g. `swile`, `shine`, `cad`. */
7
+ tenant: string;
8
+ /** Environment segment, e.g. `ext-uat1-sandbox`, `eu.live.prod`. */
9
+ environment: string;
10
+ }
11
+ /** `https://api.<tenant>.<environment>.mycore.enfuce.com` — the API root, no path. */
12
+ export declare function apiBaseUrl(te: TenantEnvironment): string;
13
+ /** `.../issuer` — issuer domain (cardholder, card, wallet, pin). */
14
+ export declare function issuerBaseUrl(te: TenantEnvironment): string;
15
+ /** `.../processor` — processor domain (transactions, 3DS). */
16
+ export declare function processorBaseUrl(te: TenantEnvironment): string;
17
+ /** `.../exchange-rates-api` — exchange-rate domain. */
18
+ export declare function exchangeRateBaseUrl(te: TenantEnvironment): string;
19
+ /** `https://auth.<tenant>.<environment>.mycore.enfuce.com/oauth2/token` — OAuth2 token endpoint. */
20
+ export declare function tokenUrl(te: TenantEnvironment): string;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ /*
3
+ * Enfuce nextgen SDK — tenant/environment addressing helper.
4
+ *
5
+ * HAND-WRITTEN, NOT GENERATED. This module (src/config) is authored by hand and
6
+ * preserved across SDK regeneration (see scripts/generate.sh). Do not expect
7
+ * OpenAPI Generator to (re)produce it.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.apiBaseUrl = apiBaseUrl;
11
+ exports.issuerBaseUrl = issuerBaseUrl;
12
+ exports.processorBaseUrl = processorBaseUrl;
13
+ exports.exchangeRateBaseUrl = exchangeRateBaseUrl;
14
+ exports.tokenUrl = tokenUrl;
15
+ const DOMAIN_SUFFIX = 'mycore.enfuce.com';
16
+ function hostSuffix(te) {
17
+ var _a, _b;
18
+ const tenant = (_a = te === null || te === void 0 ? void 0 : te.tenant) === null || _a === void 0 ? void 0 : _a.trim();
19
+ const environment = (_b = te === null || te === void 0 ? void 0 : te.environment) === null || _b === void 0 ? void 0 : _b.trim();
20
+ if (!tenant) {
21
+ throw new Error('tenant must not be empty');
22
+ }
23
+ if (!environment) {
24
+ throw new Error('environment must not be empty');
25
+ }
26
+ return `${tenant}.${environment}.${DOMAIN_SUFFIX}`;
27
+ }
28
+ /** `https://api.<tenant>.<environment>.mycore.enfuce.com` — the API root, no path. */
29
+ function apiBaseUrl(te) {
30
+ return `https://api.${hostSuffix(te)}`;
31
+ }
32
+ /** `.../issuer` — issuer domain (cardholder, card, wallet, pin). */
33
+ function issuerBaseUrl(te) {
34
+ return `${apiBaseUrl(te)}/issuer`;
35
+ }
36
+ /** `.../processor` — processor domain (transactions, 3DS). */
37
+ function processorBaseUrl(te) {
38
+ return `${apiBaseUrl(te)}/processor`;
39
+ }
40
+ /** `.../exchange-rates-api` — exchange-rate domain. */
41
+ function exchangeRateBaseUrl(te) {
42
+ return `${apiBaseUrl(te)}/exchange-rates-api`;
43
+ }
44
+ /** `https://auth.<tenant>.<environment>.mycore.enfuce.com/oauth2/token` — OAuth2 token endpoint. */
45
+ function tokenUrl(te) {
46
+ return `https://auth.${hostSuffix(te)}/oauth2/token`;
47
+ }
@@ -0,0 +1 @@
1
+ export { TenantEnvironment, apiBaseUrl, issuerBaseUrl, processorBaseUrl, exchangeRateBaseUrl, tokenUrl, } from './enfuceUrls';
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tokenUrl = exports.exchangeRateBaseUrl = exports.processorBaseUrl = exports.issuerBaseUrl = exports.apiBaseUrl = void 0;
4
+ /*
5
+ * Enfuce nextgen SDK — tenant/environment addressing helper.
6
+ *
7
+ * HAND-WRITTEN, NOT GENERATED. This module (src/config) is authored by hand and
8
+ * preserved across SDK regeneration (see scripts/generate.sh). It is re-exported
9
+ * from the package barrel as `config`:
10
+ *
11
+ * import { config, cardholder, oauth } from '@enfuce/nextgen-sdk';
12
+ *
13
+ * const te = { tenant: 'swile', environment: 'ext-uat1-sandbox' };
14
+ * const conf = new cardholder.Configuration({ basePath: config.issuerBaseUrl(te) });
15
+ * const tokens = oauth.clientCredentials({ tokenUrl: config.tokenUrl(te), clientId, clientSecret });
16
+ */
17
+ var enfuceUrls_1 = require("./enfuceUrls");
18
+ Object.defineProperty(exports, "apiBaseUrl", { enumerable: true, get: function () { return enfuceUrls_1.apiBaseUrl; } });
19
+ Object.defineProperty(exports, "issuerBaseUrl", { enumerable: true, get: function () { return enfuceUrls_1.issuerBaseUrl; } });
20
+ Object.defineProperty(exports, "processorBaseUrl", { enumerable: true, get: function () { return enfuceUrls_1.processorBaseUrl; } });
21
+ Object.defineProperty(exports, "exchangeRateBaseUrl", { enumerable: true, get: function () { return enfuceUrls_1.exchangeRateBaseUrl; } });
22
+ Object.defineProperty(exports, "tokenUrl", { enumerable: true, get: function () { return enfuceUrls_1.tokenUrl; } });
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { AuthorisationRequestAPIApi } from './api';
5
5
  /**
@@ -36,7 +36,7 @@ export declare class AuthorisationControlClientBuilder {
36
36
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
37
37
  baseUrl(baseUrl: string): this;
38
38
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
39
- oauth(tokens: TokenManager): this;
39
+ oauth(tokens: OAuthClientCredentialsManager): this;
40
40
  /**
41
41
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
42
42
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { CreateCardApi, CreatePINControlAccessTokenApi, GetCardApi, GetCardPaymentInfoApi, GetPlasticManufacturingHistoryApi, UpdateCardApi } from './api';
5
5
  /**
@@ -46,7 +46,7 @@ export declare class CardClientBuilder {
46
46
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
47
47
  baseUrl(baseUrl: string): this;
48
48
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
49
- oauth(tokens: TokenManager): this;
49
+ oauth(tokens: OAuthClientCredentialsManager): this;
50
50
  /**
51
51
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
52
52
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { CreateCardholderApi, GetCardholderApi, GetCardsByCardholderIdApi, UpdateCardholderApi } from './api';
5
5
  /**
@@ -42,7 +42,7 @@ export declare class CardholderClientBuilder {
42
42
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
43
43
  baseUrl(baseUrl: string): this;
44
44
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
45
- oauth(tokens: TokenManager): this;
45
+ oauth(tokens: OAuthClientCredentialsManager): this;
46
46
  /**
47
47
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
48
48
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { CardsApi } from './api';
5
5
  /**
@@ -36,7 +36,7 @@ export declare class CardsClientBuilder {
36
36
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
37
37
  baseUrl(baseUrl: string): this;
38
38
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
39
- oauth(tokens: TokenManager): this;
39
+ oauth(tokens: OAuthClientCredentialsManager): this;
40
40
  /**
41
41
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
42
42
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Identifies a single Enfuce deployment by its `tenant` and `environment` — the two variable
3
+ * segments of every Enfuce host, e.g. `api.<tenant>.<environment>.mycore.enfuce.com`.
4
+ */
5
+ export interface TenantEnvironment {
6
+ /** Tenant segment, e.g. `swile`, `shine`, `cad`. */
7
+ tenant: string;
8
+ /** Environment segment, e.g. `ext-uat1-sandbox`, `eu.live.prod`. */
9
+ environment: string;
10
+ }
11
+ /** `https://api.<tenant>.<environment>.mycore.enfuce.com` — the API root, no path. */
12
+ export declare function apiBaseUrl(te: TenantEnvironment): string;
13
+ /** `.../issuer` — issuer domain (cardholder, card, wallet, pin). */
14
+ export declare function issuerBaseUrl(te: TenantEnvironment): string;
15
+ /** `.../processor` — processor domain (transactions, 3DS). */
16
+ export declare function processorBaseUrl(te: TenantEnvironment): string;
17
+ /** `.../exchange-rates-api` — exchange-rate domain. */
18
+ export declare function exchangeRateBaseUrl(te: TenantEnvironment): string;
19
+ /** `https://auth.<tenant>.<environment>.mycore.enfuce.com/oauth2/token` — OAuth2 token endpoint. */
20
+ export declare function tokenUrl(te: TenantEnvironment): string;
@@ -0,0 +1,40 @@
1
+ /*
2
+ * Enfuce nextgen SDK — tenant/environment addressing helper.
3
+ *
4
+ * HAND-WRITTEN, NOT GENERATED. This module (src/config) is authored by hand and
5
+ * preserved across SDK regeneration (see scripts/generate.sh). Do not expect
6
+ * OpenAPI Generator to (re)produce it.
7
+ */
8
+ const DOMAIN_SUFFIX = 'mycore.enfuce.com';
9
+ function hostSuffix(te) {
10
+ var _a, _b;
11
+ const tenant = (_a = te === null || te === void 0 ? void 0 : te.tenant) === null || _a === void 0 ? void 0 : _a.trim();
12
+ const environment = (_b = te === null || te === void 0 ? void 0 : te.environment) === null || _b === void 0 ? void 0 : _b.trim();
13
+ if (!tenant) {
14
+ throw new Error('tenant must not be empty');
15
+ }
16
+ if (!environment) {
17
+ throw new Error('environment must not be empty');
18
+ }
19
+ return `${tenant}.${environment}.${DOMAIN_SUFFIX}`;
20
+ }
21
+ /** `https://api.<tenant>.<environment>.mycore.enfuce.com` — the API root, no path. */
22
+ export function apiBaseUrl(te) {
23
+ return `https://api.${hostSuffix(te)}`;
24
+ }
25
+ /** `.../issuer` — issuer domain (cardholder, card, wallet, pin). */
26
+ export function issuerBaseUrl(te) {
27
+ return `${apiBaseUrl(te)}/issuer`;
28
+ }
29
+ /** `.../processor` — processor domain (transactions, 3DS). */
30
+ export function processorBaseUrl(te) {
31
+ return `${apiBaseUrl(te)}/processor`;
32
+ }
33
+ /** `.../exchange-rates-api` — exchange-rate domain. */
34
+ export function exchangeRateBaseUrl(te) {
35
+ return `${apiBaseUrl(te)}/exchange-rates-api`;
36
+ }
37
+ /** `https://auth.<tenant>.<environment>.mycore.enfuce.com/oauth2/token` — OAuth2 token endpoint. */
38
+ export function tokenUrl(te) {
39
+ return `https://auth.${hostSuffix(te)}/oauth2/token`;
40
+ }
@@ -0,0 +1 @@
1
+ export { TenantEnvironment, apiBaseUrl, issuerBaseUrl, processorBaseUrl, exchangeRateBaseUrl, tokenUrl, } from './enfuceUrls';
@@ -0,0 +1,14 @@
1
+ /*
2
+ * Enfuce nextgen SDK — tenant/environment addressing helper.
3
+ *
4
+ * HAND-WRITTEN, NOT GENERATED. This module (src/config) is authored by hand and
5
+ * preserved across SDK regeneration (see scripts/generate.sh). It is re-exported
6
+ * from the package barrel as `config`:
7
+ *
8
+ * import { config, cardholder, oauth } from '@enfuce/nextgen-sdk';
9
+ *
10
+ * const te = { tenant: 'swile', environment: 'ext-uat1-sandbox' };
11
+ * const conf = new cardholder.Configuration({ basePath: config.issuerBaseUrl(te) });
12
+ * const tokens = oauth.clientCredentials({ tokenUrl: config.tokenUrl(te), clientId, clientSecret });
13
+ */
14
+ export { apiBaseUrl, issuerBaseUrl, processorBaseUrl, exchangeRateBaseUrl, tokenUrl, } from './enfuceUrls';
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { GetECBExchangeRateApi, GetECBSupportedCurrenciesApi, GetFXExchangeRatesApi } from './api';
5
5
  /**
@@ -40,7 +40,7 @@ export declare class ExchangeRateClientBuilder {
40
40
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
41
41
  baseUrl(baseUrl: string): this;
42
42
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
43
- oauth(tokens: TokenManager): this;
43
+ oauth(tokens: OAuthClientCredentialsManager): this;
44
44
  /**
45
45
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
46
46
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
@@ -1,4 +1,5 @@
1
1
  export * as oauth from './oauth';
2
+ export * as config from './config';
2
3
  export * as card from './card';
3
4
  export * as wallet from './wallet';
4
5
  export * as cardholder from './cardholder';
package/dist/esm/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /* AUTO-GENERATED by scripts/generate.sh - do not edit. */
2
2
  /* One namespaced export per API. Usage: import { card } from '@enfuce/nextgen-sdk'; */
3
3
  export * as oauth from './oauth';
4
+ export * as config from './config';
4
5
  export * as card from './card';
5
6
  export * as wallet from './wallet';
6
7
  export * as cardholder from './cardholder';
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { IssuerEventWebhooksApi } from './api';
5
5
  /**
@@ -36,7 +36,7 @@ export declare class IssuerEventsClientBuilder {
36
36
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
37
37
  baseUrl(baseUrl: string): this;
38
38
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
39
- oauth(tokens: TokenManager): this;
39
+ oauth(tokens: OAuthClientCredentialsManager): this;
40
40
  /**
41
41
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
42
42
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
@@ -1,10 +1,10 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { TokenManager } from './tokenManager';
2
+ import { OAuthClientCredentialsManager } from './tokenManager';
3
3
  /**
4
4
  * Returns an {@link AxiosInstance} with OAuth bearer-token handling built in:
5
5
  *
6
6
  * - **Proactive:** a request interceptor attaches a fresh bearer token (from the
7
- * {@link TokenManager}) to *every* request. This authenticates API modules whose spec declares no
7
+ * {@link OAuthClientCredentialsManager}) to *every* request. This authenticates API modules whose spec declares no
8
8
  * security scheme (e.g. exchange-rate), so no `accessToken` on the `Configuration` is required.
9
9
  * - **Reactive:** a response interceptor, on a `401`, forces a token refresh and retries the request
10
10
  * exactly once with the new bearer token.
@@ -17,4 +17,4 @@ import { TokenManager } from './tokenManager';
17
17
  * const api = new card.CardApi(config, undefined, http);
18
18
  * ```
19
19
  */
20
- export declare function createOAuthAxios(manager: TokenManager, instance?: AxiosInstance): AxiosInstance;
20
+ export declare function createOAuthAxios(manager: OAuthClientCredentialsManager, instance?: AxiosInstance): AxiosInstance;
@@ -25,7 +25,7 @@ function stripBearer(header) {
25
25
  * Returns an {@link AxiosInstance} with OAuth bearer-token handling built in:
26
26
  *
27
27
  * - **Proactive:** a request interceptor attaches a fresh bearer token (from the
28
- * {@link TokenManager}) to *every* request. This authenticates API modules whose spec declares no
28
+ * {@link OAuthClientCredentialsManager}) to *every* request. This authenticates API modules whose spec declares no
29
29
  * security scheme (e.g. exchange-rate), so no `accessToken` on the `Configuration` is required.
30
30
  * - **Reactive:** a response interceptor, on a `401`, forces a token refresh and retries the request
31
31
  * exactly once with the new bearer token.
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { TokenFetcher, TokenManager } from './tokenManager';
2
+ import { TokenFetcher, OAuthClientCredentialsManager } from './tokenManager';
3
3
  /** Configuration for the OAuth2 `client_credentials` grant. */
4
4
  export interface OAuthConfig {
5
5
  tokenUrl: string;
@@ -14,11 +14,25 @@ export interface OAuthConfig {
14
14
  /** Axios instance used for the token request. Defaults to a fresh instance. */
15
15
  axiosInstance?: AxiosInstance;
16
16
  }
17
+ /**
18
+ * The OAuth2 client-credentials identity — the client id/secret and requested scopes. It carries
19
+ * no URL: pair it with a token URL (e.g. derived from a `TenantEnvironment`) via the
20
+ * `clientCredentials(tokenUrl, credentials)` overload below.
21
+ */
22
+ export interface ClientCredentials {
23
+ clientId: string;
24
+ /** May be omitted for a public client. */
25
+ clientSecret?: string;
26
+ /** Requested scopes; space-joined into a `scope` parameter. */
27
+ scopes?: string[];
28
+ }
17
29
  /**
18
30
  * Builds a {@link TokenFetcher} that performs the OAuth2 `client_credentials`
19
31
  * grant: a form-encoded POST to `config.tokenUrl`, parsing `access_token` and
20
32
  * `expires_in`. Server-side only — never ship a client secret to a browser.
21
33
  */
22
34
  export declare function clientCredentialsFetcher(config: OAuthConfig): TokenFetcher;
23
- /** Convenience: a caching {@link TokenManager} backed by the client-credentials grant. */
24
- export declare function clientCredentials(config: OAuthConfig, skewSeconds?: number): TokenManager;
35
+ /** Convenience: a caching {@link OAuthClientCredentialsManager} backed by the client-credentials grant. */
36
+ export declare function clientCredentials(config: OAuthConfig, skewSeconds?: number): OAuthClientCredentialsManager;
37
+ /** Convenience overload pairing a token URL with a {@link ClientCredentials} identity. */
38
+ export declare function clientCredentials(tokenUrl: string, credentials: ClientCredentials, skewSeconds?: number): OAuthClientCredentialsManager;
@@ -15,7 +15,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
15
15
  * OpenAPI Generator to (re)produce it.
16
16
  */
17
17
  import axios from 'axios';
18
- import { TokenManager } from './tokenManager';
18
+ import { OAuthClientCredentialsManager } from './tokenManager';
19
19
  /**
20
20
  * Builds a {@link TokenFetcher} that performs the OAuth2 `client_credentials`
21
21
  * grant: a form-encoded POST to `config.tokenUrl`, parsing `access_token` and
@@ -53,7 +53,23 @@ export function clientCredentialsFetcher(config) {
53
53
  return { accessToken: data.access_token, expiresInSeconds: (_b = data.expires_in) !== null && _b !== void 0 ? _b : 0 };
54
54
  });
55
55
  }
56
- /** Convenience: a caching {@link TokenManager} backed by the client-credentials grant. */
57
- export function clientCredentials(config, skewSeconds = 60) {
58
- return new TokenManager(clientCredentialsFetcher(config), skewSeconds);
56
+ export function clientCredentials(configOrUrl, credsOrSkew, skewSeconds = 60) {
57
+ var _a;
58
+ let config;
59
+ let skew;
60
+ if (typeof configOrUrl === 'string') {
61
+ const creds = credsOrSkew;
62
+ config = {
63
+ tokenUrl: configOrUrl,
64
+ clientId: creds.clientId,
65
+ clientSecret: (_a = creds.clientSecret) !== null && _a !== void 0 ? _a : '',
66
+ scopes: creds.scopes,
67
+ };
68
+ skew = skewSeconds;
69
+ }
70
+ else {
71
+ config = configOrUrl;
72
+ skew = typeof credsOrSkew === 'number' ? credsOrSkew : 60;
73
+ }
74
+ return new OAuthClientCredentialsManager(clientCredentialsFetcher(config), skew);
59
75
  }
@@ -1,3 +1,3 @@
1
- export { AccessToken, TokenFetcher, TokenManager } from './tokenManager';
2
- export { OAuthConfig, clientCredentials, clientCredentialsFetcher } from './clientCredentials';
1
+ export { AccessToken, TokenFetcher, OAuthClientCredentialsManager } from './tokenManager';
2
+ export { ClientCredentials, OAuthConfig, clientCredentials, clientCredentialsFetcher } from './clientCredentials';
3
3
  export { createOAuthAxios } from './axios';
@@ -22,6 +22,6 @@
22
22
  *
23
23
  * Server-side only — a client secret must never ship to a browser.
24
24
  */
25
- export { TokenManager } from './tokenManager';
25
+ export { OAuthClientCredentialsManager } from './tokenManager';
26
26
  export { clientCredentials, clientCredentialsFetcher } from './clientCredentials';
27
27
  export { createOAuthAxios } from './axios';
@@ -11,14 +11,14 @@ export type TokenFetcher = () => Promise<AccessToken>;
11
11
  * client's `Configuration`:
12
12
  *
13
13
  * ```ts
14
- * const tokens = new TokenManager(fetcher);
14
+ * const tokens = new OAuthClientCredentialsManager(fetcher);
15
15
  * const config = new card.Configuration({ accessToken: () => tokens.getToken() });
16
16
  * ```
17
17
  *
18
18
  * A token is considered expired once the clock passes `expiry - skew`. Concurrent
19
19
  * refreshes share a single in-flight promise, so the token endpoint is hit once.
20
20
  */
21
- export declare class TokenManager {
21
+ export declare class OAuthClientCredentialsManager {
22
22
  private readonly fetcher;
23
23
  private readonly skewSeconds;
24
24
  private readonly now;
@@ -19,14 +19,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
19
19
  * client's `Configuration`:
20
20
  *
21
21
  * ```ts
22
- * const tokens = new TokenManager(fetcher);
22
+ * const tokens = new OAuthClientCredentialsManager(fetcher);
23
23
  * const config = new card.Configuration({ accessToken: () => tokens.getToken() });
24
24
  * ```
25
25
  *
26
26
  * A token is considered expired once the clock passes `expiry - skew`. Concurrent
27
27
  * refreshes share a single in-flight promise, so the token endpoint is hit once.
28
28
  */
29
- export class TokenManager {
29
+ export class OAuthClientCredentialsManager {
30
30
  constructor(fetcher, skewSeconds = 60, now = Date.now) {
31
31
  this.fetcher = fetcher;
32
32
  this.skewSeconds = skewSeconds;
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { PINOperationsUsingPKIApi, PINOperationsWithPreSharedKeyApi } from './api';
5
5
  /**
@@ -38,7 +38,7 @@ export declare class PinClientBuilder {
38
38
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
39
39
  baseUrl(baseUrl: string): this;
40
40
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
41
- oauth(tokens: TokenManager): this;
41
+ oauth(tokens: OAuthClientCredentialsManager): this;
42
42
  /**
43
43
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
44
44
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { ThreeDSApi } from './api';
5
5
  /**
@@ -36,7 +36,7 @@ export declare class ThreedsClientBuilder {
36
36
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
37
37
  baseUrl(baseUrl: string): this;
38
38
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
39
- oauth(tokens: TokenManager): this;
39
+ oauth(tokens: OAuthClientCredentialsManager): this;
40
40
  /**
41
41
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
42
42
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { OOBAuthenticationChallengeWebhookNotificationApi } from './api';
5
5
  /**
@@ -36,7 +36,7 @@ export declare class ThreedsOobClientBuilder {
36
36
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
37
37
  baseUrl(baseUrl: string): this;
38
38
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
39
- oauth(tokens: TokenManager): this;
39
+ oauth(tokens: OAuthClientCredentialsManager): this;
40
40
  /**
41
41
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
42
42
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple
@@ -1,5 +1,5 @@
1
1
  import { type AxiosInstance } from 'axios';
2
- import { type TokenManager } from '../oauth';
2
+ import { type OAuthClientCredentialsManager } from '../oauth';
3
3
  import { Configuration } from './configuration';
4
4
  import { ActivateTokenApi, DeactivateTokenApi, EligibleTokenRequestorsApi, GetTokensApi, PushCardsApi, PushProvisionApi, SuspendTokenApi, UnsuspendTokenApi } from './api';
5
5
  /**
@@ -50,7 +50,7 @@ export declare class WalletClientBuilder {
50
50
  /** The module's host, e.g. `https://api.<tenant>.../issuer`. */
51
51
  baseUrl(baseUrl: string): this;
52
52
  /** Install OAuth: a fresh bearer token on every request + reactive 401 retry. */
53
- oauth(tokens: TokenManager): this;
53
+ oauth(tokens: OAuthClientCredentialsManager): this;
54
54
  /**
55
55
  * Customize the underlying axios instance — set a timeout (`http.defaults.timeout = ...`), a proxy,
56
56
  * default headers, extra interceptors, etc. Runs after OAuth is installed. Composable: multiple