@nium/nium-sdk 0.1.6 → 0.1.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.
- package/dist/index.d.mts +32 -4
- package/dist/index.d.ts +32 -4
- package/dist/index.js +20 -2
- package/dist/index.mjs +20 -2
- package/package.json +9 -8
package/dist/index.d.mts
CHANGED
|
@@ -23,10 +23,34 @@ interface NiumInitOptions {
|
|
|
23
23
|
}
|
|
24
24
|
/** Theme options for embedded components */
|
|
25
25
|
interface NiumTheme {
|
|
26
|
-
primaryColor?: string;
|
|
27
26
|
borderRadius?: string;
|
|
28
27
|
fontFamily?: string;
|
|
28
|
+
formBackgroundColor?: string;
|
|
29
|
+
inputFieldBackgroundColor?: string;
|
|
30
|
+
inputFieldBorderColor?: string;
|
|
31
|
+
inputFieldPlaceholderColor?: string;
|
|
32
|
+
inputFieldTextColor?: string;
|
|
33
|
+
inputFieldBorderRadius?: string;
|
|
34
|
+
formHeadingColor?: string;
|
|
35
|
+
labelBackgroundColor?: string;
|
|
36
|
+
radioColor?: string;
|
|
29
37
|
}
|
|
38
|
+
/** Per-field UI customization options for SDK beneficiary form fields. */
|
|
39
|
+
interface NiumFieldCustomization {
|
|
40
|
+
hidden?: boolean;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Per-section UI customization options for SDK beneficiary form sections. */
|
|
44
|
+
interface NiumSectionCustomization {
|
|
45
|
+
hidden?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** Supported beneficiary form field paths for `customizations.fields`. */
|
|
48
|
+
type NiumBeneficiaryFieldPath = 'name' | 'entityType' | 'line1' | 'line2' | 'city' | 'state' | 'postalCode' | 'countryCode' | 'communicationPreference' | 'contactNumber' | 'email' | 'termsCheckbox' | 'helperText';
|
|
49
|
+
type NiumBeneficiarySectionPath = 'demographicInfo' | 'communicationPreferences' | 'accountType' | 'bankAccountDetails';
|
|
50
|
+
type NiumBeneficiaryFieldCustomizations = Partial<Record<NiumBeneficiaryFieldPath | string, NiumFieldCustomization>>;
|
|
51
|
+
type NiumBeneficiarySectionCustomizations = Partial<Record<NiumBeneficiarySectionPath | string, NiumSectionCustomization>>;
|
|
52
|
+
/** Intent for the payment (beneficiary) form */
|
|
53
|
+
type NiumPaymentIntent = 'create_beneficiary' | 'return_payload' | 'update_beneficiary';
|
|
30
54
|
/** Prefill data for the payment (beneficiary) form */
|
|
31
55
|
interface NiumPaymentPrefill {
|
|
32
56
|
name?: string;
|
|
@@ -50,12 +74,16 @@ interface NiumElementOptions {
|
|
|
50
74
|
prefill?: NiumPaymentPrefill;
|
|
51
75
|
/** Custom theme overrides */
|
|
52
76
|
theme?: NiumTheme;
|
|
53
|
-
/**
|
|
54
|
-
|
|
77
|
+
/** Form intent: 'create_beneficiary' creates and returns beneficiaryId + payload; 'return_payload' returns payload only; 'update_beneficiary' updates an existing beneficiary */
|
|
78
|
+
intent?: NiumPaymentIntent;
|
|
79
|
+
/** Beneficiary hash ID (required for 'update_beneficiary' intent) */
|
|
80
|
+
beneficiaryHashId?: string;
|
|
55
81
|
/** Custom minimum height for the iframe (default: 400) */
|
|
56
82
|
customizations?: {
|
|
57
83
|
minHeight?: number;
|
|
58
84
|
maxHeight?: number;
|
|
85
|
+
fields?: NiumBeneficiaryFieldCustomizations;
|
|
86
|
+
sections?: NiumBeneficiarySectionCustomizations;
|
|
59
87
|
};
|
|
60
88
|
}
|
|
61
89
|
interface NiumReadyEvent {
|
|
@@ -175,4 +203,4 @@ declare const init: (options: NiumInitOptions) => Promise<void>;
|
|
|
175
203
|
*/
|
|
176
204
|
declare const createElement: (type: NiumElementType, options?: NiumElementOptions) => Promise<NiumElement>;
|
|
177
205
|
|
|
178
|
-
export { type NiumCancelEvent, type NiumChangeEvent, NiumElement, type NiumElementOptions, type NiumElementType, type NiumEnv, type NiumErrorEvent, type NiumEvent, type NiumEventCallback, type NiumEventMap, type NiumInitOptions, type NiumPaymentPrefill, type NiumReadyEvent, type NiumResizeEvent, type NiumSubmitEvent, type NiumSubmitResult, type NiumTheme, createElement, init };
|
|
206
|
+
export { type NiumBeneficiaryFieldCustomizations, type NiumBeneficiaryFieldPath, type NiumCancelEvent, type NiumChangeEvent, NiumElement, type NiumElementOptions, type NiumElementType, type NiumEnv, type NiumErrorEvent, type NiumEvent, type NiumEventCallback, type NiumEventMap, type NiumFieldCustomization, type NiumInitOptions, type NiumPaymentIntent, type NiumPaymentPrefill, type NiumReadyEvent, type NiumResizeEvent, type NiumSubmitEvent, type NiumSubmitResult, type NiumTheme, createElement, init };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,10 +23,34 @@ interface NiumInitOptions {
|
|
|
23
23
|
}
|
|
24
24
|
/** Theme options for embedded components */
|
|
25
25
|
interface NiumTheme {
|
|
26
|
-
primaryColor?: string;
|
|
27
26
|
borderRadius?: string;
|
|
28
27
|
fontFamily?: string;
|
|
28
|
+
formBackgroundColor?: string;
|
|
29
|
+
inputFieldBackgroundColor?: string;
|
|
30
|
+
inputFieldBorderColor?: string;
|
|
31
|
+
inputFieldPlaceholderColor?: string;
|
|
32
|
+
inputFieldTextColor?: string;
|
|
33
|
+
inputFieldBorderRadius?: string;
|
|
34
|
+
formHeadingColor?: string;
|
|
35
|
+
labelBackgroundColor?: string;
|
|
36
|
+
radioColor?: string;
|
|
29
37
|
}
|
|
38
|
+
/** Per-field UI customization options for SDK beneficiary form fields. */
|
|
39
|
+
interface NiumFieldCustomization {
|
|
40
|
+
hidden?: boolean;
|
|
41
|
+
disabled?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/** Per-section UI customization options for SDK beneficiary form sections. */
|
|
44
|
+
interface NiumSectionCustomization {
|
|
45
|
+
hidden?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** Supported beneficiary form field paths for `customizations.fields`. */
|
|
48
|
+
type NiumBeneficiaryFieldPath = 'name' | 'entityType' | 'line1' | 'line2' | 'city' | 'state' | 'postalCode' | 'countryCode' | 'communicationPreference' | 'contactNumber' | 'email' | 'termsCheckbox' | 'helperText';
|
|
49
|
+
type NiumBeneficiarySectionPath = 'demographicInfo' | 'communicationPreferences' | 'accountType' | 'bankAccountDetails';
|
|
50
|
+
type NiumBeneficiaryFieldCustomizations = Partial<Record<NiumBeneficiaryFieldPath | string, NiumFieldCustomization>>;
|
|
51
|
+
type NiumBeneficiarySectionCustomizations = Partial<Record<NiumBeneficiarySectionPath | string, NiumSectionCustomization>>;
|
|
52
|
+
/** Intent for the payment (beneficiary) form */
|
|
53
|
+
type NiumPaymentIntent = 'create_beneficiary' | 'return_payload' | 'update_beneficiary';
|
|
30
54
|
/** Prefill data for the payment (beneficiary) form */
|
|
31
55
|
interface NiumPaymentPrefill {
|
|
32
56
|
name?: string;
|
|
@@ -50,12 +74,16 @@ interface NiumElementOptions {
|
|
|
50
74
|
prefill?: NiumPaymentPrefill;
|
|
51
75
|
/** Custom theme overrides */
|
|
52
76
|
theme?: NiumTheme;
|
|
53
|
-
/**
|
|
54
|
-
|
|
77
|
+
/** Form intent: 'create_beneficiary' creates and returns beneficiaryId + payload; 'return_payload' returns payload only; 'update_beneficiary' updates an existing beneficiary */
|
|
78
|
+
intent?: NiumPaymentIntent;
|
|
79
|
+
/** Beneficiary hash ID (required for 'update_beneficiary' intent) */
|
|
80
|
+
beneficiaryHashId?: string;
|
|
55
81
|
/** Custom minimum height for the iframe (default: 400) */
|
|
56
82
|
customizations?: {
|
|
57
83
|
minHeight?: number;
|
|
58
84
|
maxHeight?: number;
|
|
85
|
+
fields?: NiumBeneficiaryFieldCustomizations;
|
|
86
|
+
sections?: NiumBeneficiarySectionCustomizations;
|
|
59
87
|
};
|
|
60
88
|
}
|
|
61
89
|
interface NiumReadyEvent {
|
|
@@ -175,4 +203,4 @@ declare const init: (options: NiumInitOptions) => Promise<void>;
|
|
|
175
203
|
*/
|
|
176
204
|
declare const createElement: (type: NiumElementType, options?: NiumElementOptions) => Promise<NiumElement>;
|
|
177
205
|
|
|
178
|
-
export { type NiumCancelEvent, type NiumChangeEvent, NiumElement, type NiumElementOptions, type NiumElementType, type NiumEnv, type NiumErrorEvent, type NiumEvent, type NiumEventCallback, type NiumEventMap, type NiumInitOptions, type NiumPaymentPrefill, type NiumReadyEvent, type NiumResizeEvent, type NiumSubmitEvent, type NiumSubmitResult, type NiumTheme, createElement, init };
|
|
206
|
+
export { type NiumBeneficiaryFieldCustomizations, type NiumBeneficiaryFieldPath, type NiumCancelEvent, type NiumChangeEvent, NiumElement, type NiumElementOptions, type NiumElementType, type NiumEnv, type NiumErrorEvent, type NiumEvent, type NiumEventCallback, type NiumEventMap, type NiumFieldCustomization, type NiumInitOptions, type NiumPaymentIntent, type NiumPaymentPrefill, type NiumReadyEvent, type NiumResizeEvent, type NiumSubmitEvent, type NiumSubmitResult, type NiumTheme, createElement, init };
|
package/dist/index.js
CHANGED
|
@@ -241,8 +241,14 @@ var createElement = async (type, options = {}) => {
|
|
|
241
241
|
if (options.customerHashId) {
|
|
242
242
|
url.searchParams.set("customerHashId", options.customerHashId);
|
|
243
243
|
}
|
|
244
|
-
if (options.
|
|
245
|
-
|
|
244
|
+
if (options.intent) {
|
|
245
|
+
if (options.intent === "update_beneficiary" && !options.beneficiaryHashId) {
|
|
246
|
+
throw new Error("@nium/nium-sdk: beneficiaryHashId is required for update_beneficiary intent");
|
|
247
|
+
}
|
|
248
|
+
url.searchParams.set("intent", options.intent);
|
|
249
|
+
}
|
|
250
|
+
if (options.beneficiaryHashId) {
|
|
251
|
+
url.searchParams.set("beneficiaryHashId", options.beneficiaryHashId);
|
|
246
252
|
}
|
|
247
253
|
if (initConfig.locale) {
|
|
248
254
|
url.searchParams.set("locale", initConfig.locale);
|
|
@@ -259,6 +265,18 @@ var createElement = async (type, options = {}) => {
|
|
|
259
265
|
btoa(JSON.stringify(options.theme))
|
|
260
266
|
);
|
|
261
267
|
}
|
|
268
|
+
const iframeCustomizations = {
|
|
269
|
+
...options.customizations?.fields ? { fields: options.customizations.fields } : {},
|
|
270
|
+
...options.customizations?.sections ? { sections: options.customizations.sections } : {}
|
|
271
|
+
};
|
|
272
|
+
if (Object.keys(iframeCustomizations).length > 0) {
|
|
273
|
+
url.searchParams.set(
|
|
274
|
+
"customizations",
|
|
275
|
+
btoa(
|
|
276
|
+
JSON.stringify(iframeCustomizations)
|
|
277
|
+
)
|
|
278
|
+
);
|
|
279
|
+
}
|
|
262
280
|
return new NiumElement(url.toString(), type, options, origin);
|
|
263
281
|
};
|
|
264
282
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -213,8 +213,14 @@ var createElement = async (type, options = {}) => {
|
|
|
213
213
|
if (options.customerHashId) {
|
|
214
214
|
url.searchParams.set("customerHashId", options.customerHashId);
|
|
215
215
|
}
|
|
216
|
-
if (options.
|
|
217
|
-
|
|
216
|
+
if (options.intent) {
|
|
217
|
+
if (options.intent === "update_beneficiary" && !options.beneficiaryHashId) {
|
|
218
|
+
throw new Error("@nium/nium-sdk: beneficiaryHashId is required for update_beneficiary intent");
|
|
219
|
+
}
|
|
220
|
+
url.searchParams.set("intent", options.intent);
|
|
221
|
+
}
|
|
222
|
+
if (options.beneficiaryHashId) {
|
|
223
|
+
url.searchParams.set("beneficiaryHashId", options.beneficiaryHashId);
|
|
218
224
|
}
|
|
219
225
|
if (initConfig.locale) {
|
|
220
226
|
url.searchParams.set("locale", initConfig.locale);
|
|
@@ -231,6 +237,18 @@ var createElement = async (type, options = {}) => {
|
|
|
231
237
|
btoa(JSON.stringify(options.theme))
|
|
232
238
|
);
|
|
233
239
|
}
|
|
240
|
+
const iframeCustomizations = {
|
|
241
|
+
...options.customizations?.fields ? { fields: options.customizations.fields } : {},
|
|
242
|
+
...options.customizations?.sections ? { sections: options.customizations.sections } : {}
|
|
243
|
+
};
|
|
244
|
+
if (Object.keys(iframeCustomizations).length > 0) {
|
|
245
|
+
url.searchParams.set(
|
|
246
|
+
"customizations",
|
|
247
|
+
btoa(
|
|
248
|
+
JSON.stringify(iframeCustomizations)
|
|
249
|
+
)
|
|
250
|
+
);
|
|
251
|
+
}
|
|
234
252
|
return new NiumElement(url.toString(), type, options, origin);
|
|
235
253
|
};
|
|
236
254
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nium/nium-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "NIUM Onboarding SDK - Embed hosted onboarding forms with a clean JavaScript API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -8,18 +8,19 @@
|
|
|
8
8
|
"files": [
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
13
|
-
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
14
|
-
"type": "tsc --noEmit",
|
|
15
|
-
"lint": "eslint src/"
|
|
16
|
-
},
|
|
17
11
|
"devDependencies": {
|
|
12
|
+
"@rollup/rollup-darwin-arm64": "^4.60.1",
|
|
18
13
|
"tsup": "^8.0.0",
|
|
19
14
|
"typescript": "^5.0.0"
|
|
20
15
|
},
|
|
21
16
|
"license": "UNLICENSED",
|
|
22
17
|
"publishConfig": {
|
|
23
18
|
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
22
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
23
|
+
"type": "tsc --noEmit",
|
|
24
|
+
"lint": "eslint src/"
|
|
24
25
|
}
|
|
25
|
-
}
|
|
26
|
+
}
|