@melio-eng/web-sdk 1.0.10 → 1.0.11-pr.26.4013b14

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.js CHANGED
@@ -151,6 +151,38 @@ class Flow {
151
151
  this.eventListeners.clear();
152
152
  }
153
153
  }
154
+ /**
155
+ * OnboardingFlow subclass with custom URL construction
156
+ */
157
+ class OnboardingFlow extends Flow {
158
+ constructor(containerId, config, partnerName, environment, branchOverride) {
159
+ super(containerId, config, partnerName, environment, branchOverride);
160
+ const { userDetails, organizationDetails } = config;
161
+ this.preFilledParams = { userDetails, organizationDetails };
162
+ }
163
+ /**
164
+ * Construct the specific flow URL for onboarding
165
+ */
166
+ constructFlowUrl(baseUrl) {
167
+ const params = Object.fromEntries(Object.entries(this.preFilledParams).filter(([_, v]) => v !== undefined));
168
+ let preFilledBase64 = '';
169
+ if (Object.keys(params).length > 0) {
170
+ try {
171
+ const json = JSON.stringify(params);
172
+ preFilledBase64 = btoa(unescape(encodeURIComponent(json)));
173
+ }
174
+ catch (e) {
175
+ preFilledBase64 = '';
176
+ }
177
+ }
178
+ let url = `${baseUrl}/${this.partnerName}/auth/demo/new`;
179
+ if (preFilledBase64) {
180
+ url += `?preFilledParams=${encodeURIComponent(preFilledBase64)}`;
181
+ }
182
+ return url;
183
+ return `${baseUrl}/${this.partnerName}/auth/demo/new`;
184
+ }
185
+ }
154
186
  /**
155
187
  * SinglePayFlow subclass with custom URL construction
156
188
  */
@@ -260,7 +292,7 @@ export class MelioSDK {
260
292
  */
261
293
  createAuthInitUrl(authorizationCode) {
262
294
  const params = new URLSearchParams({
263
- code: authorizationCode,
295
+ token: authorizationCode,
264
296
  theme: this.partnerName,
265
297
  });
266
298
  const baseUrl = getBaseUrl(this.environment);
@@ -285,7 +317,7 @@ export class MelioSDK {
285
317
  * Launch the onboarding flow
286
318
  */
287
319
  openOnboarding(config) {
288
- const flow = new Flow(config.containerId, config, this.partnerName, this.environment, this.branchOverride);
320
+ const flow = new OnboardingFlow(config.containerId, config, this.partnerName, this.environment, this.branchOverride);
289
321
  flow.initialize();
290
322
  return flow;
291
323
  }
package/dist/types.d.ts CHANGED
@@ -24,10 +24,29 @@ export interface BaseFlowConfig {
24
24
  /** Optional authorization code for the flow */
25
25
  authCode?: string;
26
26
  }
27
+ export type BusinessType = 'partnership' | 'limitedLiabilityCompany' | 'corporation' | 'nonProfit';
28
+ export interface OrganizationDetails {
29
+ companyName: string;
30
+ businessType?: BusinessType;
31
+ companyLegalName?: string;
32
+ taxId?: string;
33
+ legalDateOfBirth?: string;
34
+ website?: string;
35
+ description?: string;
36
+ contactPhone?: string;
37
+ }
38
+ export interface UserDetails {
39
+ email: string;
40
+ firstName: string;
41
+ lastName: string;
42
+ dateOfBirth?: string;
43
+ }
27
44
  /**
28
45
  * Configuration for onboarding flow
29
46
  */
30
47
  export interface OnboardingConfig extends BaseFlowConfig {
48
+ userDetails?: UserDetails;
49
+ organizationDetails?: OrganizationDetails;
31
50
  }
32
51
  /**
33
52
  * Configuration for single pay flow
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@melio-eng/web-sdk",
3
- "version": "1.0.10",
3
+ "version": "1.0.11-pr.26.4013b14",
4
4
  "description": "Melio Web SDK - Embed core Melio workflows directly into partner UI with minimal effort",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",