@nium/nium-sdk 0.1.3 → 0.1.5

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 CHANGED
@@ -6,12 +6,20 @@ type NiumElementType = 'payment' | 'tax' | 'identity' | 'full';
6
6
  interface NiumInitOptions {
7
7
  /** Target environment */
8
8
  env: NiumEnv;
9
- /** Session code returned by marketplace-service /init */
10
- sessionCode: string;
11
9
  /** Optional locale (defaults to 'en') */
12
10
  locale?: string;
13
11
  /** Override the hosted form base URL (useful for local dev) */
14
12
  hostedFormUrl?: string;
13
+ /** Authorization code from NIAM oauth/authcode */
14
+ authCode?: string;
15
+ /** PKCE code verifier corresponding to the code challenge sent to get authCode */
16
+ codeVerifier?: string;
17
+ /** Customer hash ID */
18
+ customerHashId?: string;
19
+ /** Client ID */
20
+ clientId?: string;
21
+ /** Pre-exchanged session token (temporary — bypasses auth code exchange) */
22
+ sessionToken?: string;
15
23
  }
16
24
  /** Theme options for embedded components */
17
25
  interface NiumTheme {
@@ -36,10 +44,14 @@ interface NiumPaymentPrefill {
36
44
  }
37
45
  /** Options passed to `createElement()` */
38
46
  interface NiumElementOptions {
47
+ /** Customer hash ID */
48
+ customerHashId?: string;
39
49
  /** Pre-fill form fields */
40
50
  prefill?: NiumPaymentPrefill;
41
51
  /** Custom theme overrides */
42
52
  theme?: NiumTheme;
53
+ /** If true, the form will call the create beneficiary API directly instead of returning the payload */
54
+ createBeneficiary?: boolean;
43
55
  /** Custom minimum height for the iframe (default: 400) */
44
56
  customizations?: {
45
57
  minHeight?: number;
@@ -57,11 +69,7 @@ interface NiumChangeEvent {
57
69
  type: 'change';
58
70
  data: Record<string, unknown>;
59
71
  }
60
- interface NiumSubmitResult {
61
- beneficiaryId?: string;
62
- filerHashId?: string;
63
- status: 'success';
64
- }
72
+ type NiumSubmitResult = Record<string, unknown>;
65
73
  interface NiumSubmitEvent {
66
74
  type: 'submit';
67
75
  result: NiumSubmitResult;
@@ -144,7 +152,7 @@ declare class NiumElement {
144
152
  *
145
153
  * await init({
146
154
  * env: 'sandbox',
147
- * sessionCode: '<code-from-server>',
155
+ * authCode: '<auth-code-from-niam>',
148
156
  * })
149
157
  *
150
158
  * const element = await createElement('payment')
package/dist/index.d.ts CHANGED
@@ -6,12 +6,20 @@ type NiumElementType = 'payment' | 'tax' | 'identity' | 'full';
6
6
  interface NiumInitOptions {
7
7
  /** Target environment */
8
8
  env: NiumEnv;
9
- /** Session code returned by marketplace-service /init */
10
- sessionCode: string;
11
9
  /** Optional locale (defaults to 'en') */
12
10
  locale?: string;
13
11
  /** Override the hosted form base URL (useful for local dev) */
14
12
  hostedFormUrl?: string;
13
+ /** Authorization code from NIAM oauth/authcode */
14
+ authCode?: string;
15
+ /** PKCE code verifier corresponding to the code challenge sent to get authCode */
16
+ codeVerifier?: string;
17
+ /** Customer hash ID */
18
+ customerHashId?: string;
19
+ /** Client ID */
20
+ clientId?: string;
21
+ /** Pre-exchanged session token (temporary — bypasses auth code exchange) */
22
+ sessionToken?: string;
15
23
  }
16
24
  /** Theme options for embedded components */
17
25
  interface NiumTheme {
@@ -36,10 +44,14 @@ interface NiumPaymentPrefill {
36
44
  }
37
45
  /** Options passed to `createElement()` */
38
46
  interface NiumElementOptions {
47
+ /** Customer hash ID */
48
+ customerHashId?: string;
39
49
  /** Pre-fill form fields */
40
50
  prefill?: NiumPaymentPrefill;
41
51
  /** Custom theme overrides */
42
52
  theme?: NiumTheme;
53
+ /** If true, the form will call the create beneficiary API directly instead of returning the payload */
54
+ createBeneficiary?: boolean;
43
55
  /** Custom minimum height for the iframe (default: 400) */
44
56
  customizations?: {
45
57
  minHeight?: number;
@@ -57,11 +69,7 @@ interface NiumChangeEvent {
57
69
  type: 'change';
58
70
  data: Record<string, unknown>;
59
71
  }
60
- interface NiumSubmitResult {
61
- beneficiaryId?: string;
62
- filerHashId?: string;
63
- status: 'success';
64
- }
72
+ type NiumSubmitResult = Record<string, unknown>;
65
73
  interface NiumSubmitEvent {
66
74
  type: 'submit';
67
75
  result: NiumSubmitResult;
@@ -144,7 +152,7 @@ declare class NiumElement {
144
152
  *
145
153
  * await init({
146
154
  * env: 'sandbox',
147
- * sessionCode: '<code-from-server>',
155
+ * authCode: '<auth-code-from-niam>',
148
156
  * })
149
157
  *
150
158
  * const element = await createElement('payment')
package/dist/index.js CHANGED
@@ -196,9 +196,9 @@ var NiumElement = class {
196
196
  var initConfig = null;
197
197
  var ENV_URLS = {
198
198
  local: "http://localhost:3000",
199
- sandbox: "https://onboard.sandbox.niumops.com",
200
199
  qa: "https://onboard-qa.nium.com",
201
- production: "https://onboard.niumops.com"
200
+ sandbox: "https://onboard-sandbox.nium.com/",
201
+ production: "https://onboard.nium.com"
202
202
  };
203
203
  var ELEMENT_ROUTES = {
204
204
  payment: "/sdk/beneficiary-form",
@@ -207,8 +207,8 @@ var ELEMENT_ROUTES = {
207
207
  full: "/sdk/full-form"
208
208
  };
209
209
  var init = async (options) => {
210
- if (!options.sessionCode) {
211
- throw new Error("@nium/nium-sdk: sessionCode is required");
210
+ if (!options.authCode && !options.sessionToken) {
211
+ throw new Error("@nium/nium-sdk: authCode or sessionToken is required");
212
212
  }
213
213
  if (!options.env) {
214
214
  throw new Error("@nium/nium-sdk: env is required");
@@ -226,7 +226,24 @@ var createElement = async (type, options = {}) => {
226
226
  const origin = new URL(baseUrl).origin;
227
227
  const route = ELEMENT_ROUTES[type];
228
228
  const url = new URL(`${baseUrl}${route}`);
229
- url.searchParams.set("code", initConfig.sessionCode);
229
+ if (initConfig.authCode) {
230
+ url.searchParams.set("authCode", initConfig.authCode);
231
+ }
232
+ if (initConfig.codeVerifier) {
233
+ url.searchParams.set("codeVerifier", initConfig.codeVerifier);
234
+ }
235
+ if (initConfig.clientId) {
236
+ url.searchParams.set("clientId", initConfig.clientId);
237
+ }
238
+ if (initConfig.sessionToken) {
239
+ url.searchParams.set("sessionToken", initConfig.sessionToken);
240
+ }
241
+ if (options.customerHashId) {
242
+ url.searchParams.set("customerHashId", options.customerHashId);
243
+ }
244
+ if (options.createBeneficiary) {
245
+ url.searchParams.set("createBeneficiary", "true");
246
+ }
230
247
  if (initConfig.locale) {
231
248
  url.searchParams.set("locale", initConfig.locale);
232
249
  }
package/dist/index.mjs CHANGED
@@ -168,9 +168,9 @@ var NiumElement = class {
168
168
  var initConfig = null;
169
169
  var ENV_URLS = {
170
170
  local: "http://localhost:3000",
171
- sandbox: "https://onboard.sandbox.niumops.com",
172
171
  qa: "https://onboard-qa.nium.com",
173
- production: "https://onboard.niumops.com"
172
+ sandbox: "https://onboard-sandbox.nium.com/",
173
+ production: "https://onboard.nium.com"
174
174
  };
175
175
  var ELEMENT_ROUTES = {
176
176
  payment: "/sdk/beneficiary-form",
@@ -179,8 +179,8 @@ var ELEMENT_ROUTES = {
179
179
  full: "/sdk/full-form"
180
180
  };
181
181
  var init = async (options) => {
182
- if (!options.sessionCode) {
183
- throw new Error("@nium/nium-sdk: sessionCode is required");
182
+ if (!options.authCode && !options.sessionToken) {
183
+ throw new Error("@nium/nium-sdk: authCode or sessionToken is required");
184
184
  }
185
185
  if (!options.env) {
186
186
  throw new Error("@nium/nium-sdk: env is required");
@@ -198,7 +198,24 @@ var createElement = async (type, options = {}) => {
198
198
  const origin = new URL(baseUrl).origin;
199
199
  const route = ELEMENT_ROUTES[type];
200
200
  const url = new URL(`${baseUrl}${route}`);
201
- url.searchParams.set("code", initConfig.sessionCode);
201
+ if (initConfig.authCode) {
202
+ url.searchParams.set("authCode", initConfig.authCode);
203
+ }
204
+ if (initConfig.codeVerifier) {
205
+ url.searchParams.set("codeVerifier", initConfig.codeVerifier);
206
+ }
207
+ if (initConfig.clientId) {
208
+ url.searchParams.set("clientId", initConfig.clientId);
209
+ }
210
+ if (initConfig.sessionToken) {
211
+ url.searchParams.set("sessionToken", initConfig.sessionToken);
212
+ }
213
+ if (options.customerHashId) {
214
+ url.searchParams.set("customerHashId", options.customerHashId);
215
+ }
216
+ if (options.createBeneficiary) {
217
+ url.searchParams.set("createBeneficiary", "true");
218
+ }
202
219
  if (initConfig.locale) {
203
220
  url.searchParams.set("locale", initConfig.locale);
204
221
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nium/nium-sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
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",