@enfuce/nextgen-sdk 0.0.8 → 0.0.10
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 +196 -27
- package/dist/authorisation-control/api.d.ts +0 -56
- package/dist/authorisation-control/api.js +1 -115
- package/dist/authorisation-control/index.d.ts +0 -1
- package/dist/authorisation-control/index.js +0 -1
- package/dist/card/api.js +12 -12
- package/dist/cardholder/api.js +5 -5
- package/dist/esm/authorisation-control/api.d.ts +0 -56
- package/dist/esm/authorisation-control/api.js +0 -110
- package/dist/esm/authorisation-control/index.d.ts +0 -1
- package/dist/esm/authorisation-control/index.js +0 -1
- package/dist/esm/card/api.js +12 -12
- package/dist/esm/cardholder/api.js +5 -5
- package/dist/esm/issuer-events/api.d.ts +0 -120
- package/dist/esm/issuer-events/api.js +0 -241
- package/dist/esm/issuer-events/index.d.ts +0 -1
- package/dist/esm/issuer-events/index.js +0 -1
- package/dist/esm/oauth/clientCredentials.d.ts +14 -0
- package/dist/esm/oauth/clientCredentials.js +39 -0
- package/dist/esm/oauth/index.d.ts +1 -1
- package/dist/esm/oauth/index.js +1 -1
- package/dist/esm/pin/api.d.ts +52 -0
- package/dist/esm/pin/api.js +80 -3
- package/dist/esm/threeds-oob/api.d.ts +0 -56
- package/dist/esm/threeds-oob/api.js +0 -112
- package/dist/esm/threeds-oob/index.d.ts +0 -1
- package/dist/esm/threeds-oob/index.js +0 -1
- package/dist/esm/wallet/api.js +12 -12
- package/dist/issuer-events/api.d.ts +0 -120
- package/dist/issuer-events/api.js +1 -246
- package/dist/issuer-events/index.d.ts +0 -1
- package/dist/issuer-events/index.js +0 -1
- package/dist/oauth/clientCredentials.d.ts +14 -0
- package/dist/oauth/clientCredentials.js +41 -0
- package/dist/oauth/index.d.ts +1 -1
- package/dist/oauth/index.js +3 -1
- package/dist/pin/api.d.ts +52 -0
- package/dist/pin/api.js +80 -3
- package/dist/threeds-oob/api.d.ts +0 -56
- package/dist/threeds-oob/api.js +1 -117
- package/dist/threeds-oob/index.d.ts +0 -1
- package/dist/threeds-oob/index.js +0 -1
- package/dist/wallet/api.js +12 -12
- package/package.json +1 -1
- package/src/authorisation-control/api.ts +0 -102
- package/src/authorisation-control/index.ts +0 -2
- package/src/card/api.ts +12 -12
- package/src/cardholder/api.ts +5 -5
- package/src/issuer-events/api.ts +0 -237
- package/src/issuer-events/index.ts +0 -2
- package/src/oauth/clientCredentials.ts +44 -0
- package/src/oauth/index.ts +8 -1
- package/src/pin/api.ts +99 -3
- package/src/threeds-oob/api.ts +0 -105
- package/src/threeds-oob/index.ts +0 -2
- package/src/wallet/api.ts +12 -12
- package/dist/authorisation-control/client.d.ts +0 -47
- package/dist/authorisation-control/client.js +0 -80
- package/dist/esm/authorisation-control/client.d.ts +0 -47
- package/dist/esm/authorisation-control/client.js +0 -75
- package/dist/esm/issuer-events/client.d.ts +0 -47
- package/dist/esm/issuer-events/client.js +0 -75
- package/dist/esm/threeds-oob/client.d.ts +0 -47
- package/dist/esm/threeds-oob/client.js +0 -75
- package/dist/issuer-events/client.d.ts +0 -47
- package/dist/issuer-events/client.js +0 -80
- package/dist/threeds-oob/client.d.ts +0 -47
- package/dist/threeds-oob/client.js +0 -80
- package/src/authorisation-control/client.ts +0 -86
- package/src/issuer-events/client.ts +0 -86
- package/src/threeds-oob/client.ts +0 -86
- package/test/authorisation-control.test.ts +0 -71
- package/test/issuer-events.test.ts +0 -55
- package/test/threeds-oob.test.ts +0 -90
|
@@ -1,86 +0,0 @@
|
|
|
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 OAuthClientCredentialsManager } 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?: OAuthClientCredentialsManager;
|
|
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: OAuthClientCredentialsManager): 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
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wire-level tests for the authorisation-control API client, asserting the request
|
|
3
|
-
* against an exact JSON payload. A capturing axios adapter intercepts the request
|
|
4
|
-
* instead of hitting the network, so this exercises the real generated client (URL
|
|
5
|
-
* building, Content-Type, body serialization) without a live server or a mock library.
|
|
6
|
-
*/
|
|
7
|
-
import axios, { type InternalAxiosRequestConfig } from 'axios';
|
|
8
|
-
import { describe, expect, it } from 'vitest';
|
|
9
|
-
import { AuthorisationRequestAPIApi, CardApplicationSelectionEnum } from '../src/authorisation-control';
|
|
10
|
-
|
|
11
|
-
function capturingClient() {
|
|
12
|
-
const captured: { config?: InternalAxiosRequestConfig } = {};
|
|
13
|
-
const instance = axios.create({
|
|
14
|
-
adapter: async (config) => {
|
|
15
|
-
captured.config = config;
|
|
16
|
-
return { data: undefined, status: 200, statusText: 'OK', headers: {}, config };
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
return { captured, instance };
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
describe('AuthorisationRequestAPIApi.authPost', () => {
|
|
23
|
-
it('POSTs the exact authorisation-request JSON to the auth endpoint', async () => {
|
|
24
|
-
const { captured, instance } = capturingClient();
|
|
25
|
-
const api = new AuthorisationRequestAPIApi(undefined, 'http://localhost', instance);
|
|
26
|
-
|
|
27
|
-
await api.authPost({
|
|
28
|
-
card: {
|
|
29
|
-
id: '11111111-1111-1111-1111-111111111111',
|
|
30
|
-
applicationSelection: CardApplicationSelectionEnum.Debit,
|
|
31
|
-
},
|
|
32
|
-
merchant: {
|
|
33
|
-
id: 'MERCHANT-0001',
|
|
34
|
-
country: 'FIN',
|
|
35
|
-
},
|
|
36
|
-
transaction: {
|
|
37
|
-
transactionAmount: { amount: 1000, currency: 'EUR' },
|
|
38
|
-
},
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
expect(captured.config?.method?.toUpperCase()).toBe('POST');
|
|
42
|
-
expect(captured.config?.url).toBe('http://localhost/auth');
|
|
43
|
-
expect(captured.config?.headers?.['Content-Type']).toBe('application/json');
|
|
44
|
-
expect(captured.config?.data).toBe(
|
|
45
|
-
'{"card":{"id":"11111111-1111-1111-1111-111111111111","applicationSelection":"DEBIT"},"merchant":{"id":"MERCHANT-0001","country":"FIN"},"transaction":{"transactionAmount":{"amount":1000,"currency":"EUR"}}}',
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('serializes the CREDIT application selection to the exact JSON body', async () => {
|
|
50
|
-
const { captured, instance } = capturingClient();
|
|
51
|
-
const api = new AuthorisationRequestAPIApi(undefined, 'http://localhost', instance);
|
|
52
|
-
|
|
53
|
-
await api.authPost({
|
|
54
|
-
card: {
|
|
55
|
-
id: '22222222-2222-2222-2222-222222222222',
|
|
56
|
-
applicationSelection: CardApplicationSelectionEnum.Credit,
|
|
57
|
-
},
|
|
58
|
-
merchant: {
|
|
59
|
-
id: 'MERCHANT-0002',
|
|
60
|
-
country: 'SWE',
|
|
61
|
-
},
|
|
62
|
-
transaction: {
|
|
63
|
-
transactionAmount: { amount: 2500, currency: 'EUR' },
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
expect(captured.config?.data).toBe(
|
|
68
|
-
'{"card":{"id":"22222222-2222-2222-2222-222222222222","applicationSelection":"CREDIT"},"merchant":{"id":"MERCHANT-0002","country":"SWE"},"transaction":{"transactionAmount":{"amount":2500,"currency":"EUR"}}}',
|
|
69
|
-
);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wire-level tests for the issuer-events API client, asserting the request against
|
|
3
|
-
* an exact JSON payload. A capturing axios adapter intercepts the request instead
|
|
4
|
-
* of hitting the network, so this exercises the real generated client (URL building,
|
|
5
|
-
* Content-Type, body serialization) without a live server or a mock library.
|
|
6
|
-
*/
|
|
7
|
-
import axios, { type InternalAxiosRequestConfig } from 'axios';
|
|
8
|
-
import { describe, expect, it } from 'vitest';
|
|
9
|
-
import { IssuerEventWebhooksApi, CardRole } from '../src/issuer-events';
|
|
10
|
-
|
|
11
|
-
function capturingClient() {
|
|
12
|
-
const captured: { config?: InternalAxiosRequestConfig } = {};
|
|
13
|
-
const instance = axios.create({
|
|
14
|
-
adapter: async (config) => {
|
|
15
|
-
captured.config = config;
|
|
16
|
-
return { data: undefined, status: 200, statusText: 'OK', headers: {}, config };
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
return { captured, instance };
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
describe('IssuerEventWebhooksApi.cardEvent', () => {
|
|
23
|
-
it('POSTs the exact card-event JSON to the card webhook endpoint', async () => {
|
|
24
|
-
const { captured, instance } = capturingClient();
|
|
25
|
-
const api = new IssuerEventWebhooksApi(undefined, 'http://localhost', instance);
|
|
26
|
-
|
|
27
|
-
await api.cardEvent({
|
|
28
|
-
id: '11111111-1111-1111-1111-111111111111',
|
|
29
|
-
programId: '22222222-2222-2222-2222-222222222222',
|
|
30
|
-
role: CardRole.MainCard,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
expect(captured.config?.method?.toUpperCase()).toBe('POST');
|
|
34
|
-
expect(captured.config?.url).toBe('http://localhost/card');
|
|
35
|
-
expect(captured.config?.headers?.['Content-Type']).toBe('application/json');
|
|
36
|
-
expect(captured.config?.data).toBe(
|
|
37
|
-
'{"id":"11111111-1111-1111-1111-111111111111","programId":"22222222-2222-2222-2222-222222222222","role":"MAIN_CARD"}',
|
|
38
|
-
);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('serializes the CARD_APPLICATION role to the exact JSON body', async () => {
|
|
42
|
-
const { captured, instance } = capturingClient();
|
|
43
|
-
const api = new IssuerEventWebhooksApi(undefined, 'http://localhost', instance);
|
|
44
|
-
|
|
45
|
-
await api.cardEvent({
|
|
46
|
-
id: '33333333-3333-3333-3333-333333333333',
|
|
47
|
-
programId: '44444444-4444-4444-4444-444444444444',
|
|
48
|
-
role: CardRole.CardApplication,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
expect(captured.config?.data).toBe(
|
|
52
|
-
'{"id":"33333333-3333-3333-3333-333333333333","programId":"44444444-4444-4444-4444-444444444444","role":"CARD_APPLICATION"}',
|
|
53
|
-
);
|
|
54
|
-
});
|
|
55
|
-
});
|
package/test/threeds-oob.test.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wire-level tests for the threeds-oob API client, asserting the request against an
|
|
3
|
-
* exact JSON payload. A capturing axios adapter intercepts the request instead of
|
|
4
|
-
* hitting the network, so this exercises the real generated client (URL building,
|
|
5
|
-
* Content-Type, body serialization) without a live server or a mock library.
|
|
6
|
-
*/
|
|
7
|
-
import axios, { type InternalAxiosRequestConfig } from 'axios';
|
|
8
|
-
import { describe, expect, it } from 'vitest';
|
|
9
|
-
import {
|
|
10
|
-
OOBAuthenticationChallengeWebhookNotificationApi,
|
|
11
|
-
ThreeDsTransactionCategoryEnum,
|
|
12
|
-
ThreeDsTransactionDeviceChannelEnum,
|
|
13
|
-
} from '../src/threeds-oob';
|
|
14
|
-
|
|
15
|
-
function capturingClient() {
|
|
16
|
-
const captured: { config?: InternalAxiosRequestConfig } = {};
|
|
17
|
-
const instance = axios.create({
|
|
18
|
-
adapter: async (config) => {
|
|
19
|
-
captured.config = config;
|
|
20
|
-
return { data: undefined, status: 200, statusText: 'OK', headers: {}, config };
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
return { captured, instance };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
describe('OOBAuthenticationChallengeWebhookNotificationApi.initiateAuthenticationChallenge', () => {
|
|
27
|
-
it('POSTs the exact challenge JSON to the OOB challenge initiate endpoint', async () => {
|
|
28
|
-
const { captured, instance } = capturingClient();
|
|
29
|
-
const api = new OOBAuthenticationChallengeWebhookNotificationApi(undefined, 'http://localhost', instance);
|
|
30
|
-
|
|
31
|
-
await api.initiateAuthenticationChallenge({
|
|
32
|
-
authenticationId: '11111111-1111-1111-1111-111111111111',
|
|
33
|
-
challengeId: '22222222-2222-2222-2222-222222222222',
|
|
34
|
-
cardholder: {
|
|
35
|
-
id: '33333333-3333-3333-3333-333333333333',
|
|
36
|
-
customerNumber: 'CUST-0001',
|
|
37
|
-
},
|
|
38
|
-
card: {
|
|
39
|
-
id: '44444444-4444-4444-4444-444444444444',
|
|
40
|
-
maskedPan: '512345******0000',
|
|
41
|
-
},
|
|
42
|
-
threeDsTransaction: {
|
|
43
|
-
transactionAmount: { amount: 1000, currency: 'EUR' },
|
|
44
|
-
category: ThreeDsTransactionCategoryEnum.Payment,
|
|
45
|
-
deviceChannel: ThreeDsTransactionDeviceChannelEnum.App,
|
|
46
|
-
processedDateTime: '2024-05-31T06:55:17Z',
|
|
47
|
-
},
|
|
48
|
-
merchant: {
|
|
49
|
-
name: 'Acme Shop',
|
|
50
|
-
country: 'FIN',
|
|
51
|
-
url: 'https://merchant.example',
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
expect(captured.config?.method?.toUpperCase()).toBe('POST');
|
|
56
|
-
expect(captured.config?.url).toBe('http://localhost/v1/3ds/oob/challenge/initiate');
|
|
57
|
-
expect(captured.config?.headers?.['Content-Type']).toBe('application/json');
|
|
58
|
-
expect(captured.config?.data).toBe(
|
|
59
|
-
'{"authenticationId":"11111111-1111-1111-1111-111111111111","challengeId":"22222222-2222-2222-2222-222222222222","cardholder":{"id":"33333333-3333-3333-3333-333333333333","customerNumber":"CUST-0001"},"card":{"id":"44444444-4444-4444-4444-444444444444","maskedPan":"512345******0000"},"threeDsTransaction":{"transactionAmount":{"amount":1000,"currency":"EUR"},"category":"PAYMENT","deviceChannel":"APP","processedDateTime":"2024-05-31T06:55:17Z"},"merchant":{"name":"Acme Shop","country":"FIN","url":"https://merchant.example"}}',
|
|
60
|
-
);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('serializes the NON_PAYMENT category to the exact JSON body', async () => {
|
|
64
|
-
const { captured, instance } = capturingClient();
|
|
65
|
-
const api = new OOBAuthenticationChallengeWebhookNotificationApi(undefined, 'http://localhost', instance);
|
|
66
|
-
|
|
67
|
-
await api.initiateAuthenticationChallenge({
|
|
68
|
-
authenticationId: '55555555-5555-5555-5555-555555555555',
|
|
69
|
-
challengeId: '66666666-6666-6666-6666-666666666666',
|
|
70
|
-
cardholder: {
|
|
71
|
-
id: '77777777-7777-7777-7777-777777777777',
|
|
72
|
-
customerNumber: 'CUST-0002',
|
|
73
|
-
},
|
|
74
|
-
card: {
|
|
75
|
-
id: '88888888-8888-8888-8888-888888888888',
|
|
76
|
-
maskedPan: '512345******1111',
|
|
77
|
-
},
|
|
78
|
-
threeDsTransaction: {
|
|
79
|
-
transactionAmount: { amount: 2500, currency: 'EUR' },
|
|
80
|
-
category: ThreeDsTransactionCategoryEnum.NonPayment,
|
|
81
|
-
deviceChannel: ThreeDsTransactionDeviceChannelEnum.Browser,
|
|
82
|
-
processedDateTime: '2024-06-01T10:00:00Z',
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
expect(captured.config?.data).toBe(
|
|
87
|
-
'{"authenticationId":"55555555-5555-5555-5555-555555555555","challengeId":"66666666-6666-6666-6666-666666666666","cardholder":{"id":"77777777-7777-7777-7777-777777777777","customerNumber":"CUST-0002"},"card":{"id":"88888888-8888-8888-8888-888888888888","maskedPan":"512345******1111"},"threeDsTransaction":{"transactionAmount":{"amount":2500,"currency":"EUR"},"category":"NON_PAYMENT","deviceChannel":"BROWSER","processedDateTime":"2024-06-01T10:00:00Z"}}',
|
|
88
|
-
);
|
|
89
|
-
});
|
|
90
|
-
});
|