@wf-financing/headless-sdk 3.0.7 → 4.0.0
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 +7 -7
- package/dist/config/url.d.ts +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +1 -1
- package/dist/sdk/index.d.ts +2 -2
- package/dist/sdk-mode/loadHeadlessMode.d.ts +2 -2
- package/dist/utils/initializeHeadlessSdk.d.ts +2 -2
- package/dist/utils/loadScriptAndInitializeSdk.d.ts +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,16 +7,16 @@ Install the package directly from NPM with `npm install @wf-financing/headless-s
|
|
|
7
7
|
To minimize bundle size and reduce the impact on partners' page load times, the SDK uses dynamic imports to load the main functionality.
|
|
8
8
|
|
|
9
9
|
## Instantiation
|
|
10
|
-
Initialize the Wayflyer headless SDK by passing the `companyToken` and an optional `options` object with a type of `
|
|
10
|
+
Initialize the Wayflyer headless SDK by passing the `companyToken` and an optional `options` object with a type of `HeadlessSdkOptions` that specifies additional functionality of SDK instance - e.g. consuming sandbox API instead of the production.
|
|
11
11
|
|
|
12
12
|
```jsx
|
|
13
|
-
import { WayflyerHeadlessSdk,
|
|
13
|
+
import { WayflyerHeadlessSdk, HeadlessSdkOptions } from '@wf-financing/headless-sdk';
|
|
14
14
|
|
|
15
15
|
// instantiation in production mode
|
|
16
16
|
const wayflyerHeadlessSdk = await WayflyerHeadlessSdk.loadSdk(companyToken);
|
|
17
17
|
|
|
18
|
-
// instantiation in sandbox mode, `options` type of
|
|
19
|
-
const options:
|
|
18
|
+
// instantiation in sandbox mode, `options` type of HeadlessSdkOptions
|
|
19
|
+
const options: HeadlessSdkOptions = { isSandbox: true };
|
|
20
20
|
const wayflyerHeadlessSdk = await WayflyerHeadlessSdk.loadSdk(companyToken, options);
|
|
21
21
|
```
|
|
22
22
|
Note: The companyToken should be minted using the Company Token endpoint on the partner's backend. See the Authentication section [here](https://docs.wayflyer.com/embedded-finance/authentication) for more details.
|
|
@@ -64,12 +64,12 @@ await wayflyerSdk.dismissCta();
|
|
|
64
64
|
|
|
65
65
|
## Sandbox
|
|
66
66
|
|
|
67
|
-
To simplify the testing process, the SDK can be initialized in sandbox mode. To do so, pass the second argument of type `
|
|
67
|
+
To simplify the testing process, the SDK can be initialized in sandbox mode. To do so, pass the second argument of type `HeadlessSdkOptions` with `isSandbox` flag set to `true`. In sandbox mode, the partner can simulate responses for SDK methods with the help of additional package `@wf-financing/sandbox-ui`.
|
|
68
68
|
|
|
69
69
|
```jsx
|
|
70
|
-
import { WayflyerHeadlessSdk,
|
|
70
|
+
import { WayflyerHeadlessSdk, HeadlessSdkOptions } from '@wf-financing/headless-sdk';
|
|
71
71
|
|
|
72
|
-
const options:
|
|
72
|
+
const options: HeadlessSdkOptions = { isSandbox: true };
|
|
73
73
|
const wayflyerSdk = await WayflyerHeadlessSdk.loadSdk(companyToken, options);
|
|
74
74
|
```
|
|
75
75
|
|
package/dist/config/url.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HEADLESS_PACKAGE_URL = "https://embedded-finance-frontend.vercel.app/npm/@wf-financing/headless@
|
|
1
|
+
export declare const HEADLESS_PACKAGE_URL = "https://embedded-finance-frontend.vercel.app/npm/@wf-financing/headless@3";
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var l=(e=>(e.GENERIC_OFFER="generic_offer",e.INDICATIVE_OFFER="indicative_offer",e.CONTINUE_APPLICATION="continue_application",e))(l||{});const s="wayflyer-headless-sdk",c="https://embedded-finance-frontend.vercel.app/npm/@wf-financing/headless@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var l=(e=>(e.GENERIC_OFFER="generic_offer",e.INDICATIVE_OFFER="indicative_offer",e.CONTINUE_APPLICATION="continue_application",e))(l||{});const s="wayflyer-headless-sdk",c="https://embedded-finance-frontend.vercel.app/npm/@wf-financing/headless@3",n=(e,d)=>{if(!window.WayflyerHeadlessSdk)throw new Error("Failed to load WayflyerHeadlessSdk from the script.");const r=window.WayflyerHeadlessSdk;return window.waylflyerHeadlessSdk||(window.waylflyerHeadlessSdk=new r(e,d)),window.waylflyerHeadlessSdk},t=(e,d,r)=>new Promise((a,i)=>{e.onload=()=>{try{a(n(d,r))}catch(o){i(o)}}}),y=async(e,d)=>{try{const r=document.getElementById(s);if(window.WayflyerHeadlessSdk)return n(e,d);if(r)return t(r,e,d);const a=document.createElement("script");return a.src=c,a.type="module",a.id=s,a.async=!0,document.head.appendChild(a),t(a,e,d)}catch(r){throw console.error("Error in loading headless SDK:",r),new Error("Failed to load script")}};class f{static async loadSdk(d,r){return await y(d,r)}}exports.CtaStateType=l;exports.WayflyerHeadlessSdk=f;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { CtaStateType } from '@wf-financing/embedded-types';
|
|
2
|
-
export type { CanadianProvinceCode, CompanyDataType, ContinueHostedApplicationResponseType, CountryCode, CtaContinueFundingType, CtaGenericOfferType, CtaIndicativeOfferType, CtaResponseType, IWayflyerHeadlessSdk, SdkOptionsType, StartHostedApplicationRequestType, StartHostedApplicationResponseType, UserDataType, USStateCode, } from '@wf-financing/embedded-types';
|
|
2
|
+
export type { CanadianProvinceCode, CompanyDataType, ContinueHostedApplicationResponseType, CountryCode, CtaContinueFundingType, CtaGenericOfferType, CtaIndicativeOfferType, CtaResponseType, IWayflyerHeadlessSdk, SdkOptionsType, HeadlessSdkOptions, StartHostedApplicationRequestType, StartHostedApplicationResponseType, UserDataType, USStateCode, } from '@wf-financing/embedded-types';
|
|
3
3
|
export { WayflyerHeadlessSdk } from './sdk';
|
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var o = /* @__PURE__ */ ((e) => (e.GENERIC_OFFER = "generic_offer", e.INDICATIVE_OFFER = "indicative_offer", e.CONTINUE_APPLICATION = "continue_application", e))(o || {});
|
|
2
|
-
const s = "wayflyer-headless-sdk", c = "https://embedded-finance-frontend.vercel.app/npm/@wf-financing/headless@
|
|
2
|
+
const s = "wayflyer-headless-sdk", c = "https://embedded-finance-frontend.vercel.app/npm/@wf-financing/headless@3", l = (e, d) => {
|
|
3
3
|
if (!window.WayflyerHeadlessSdk)
|
|
4
4
|
throw new Error("Failed to load WayflyerHeadlessSdk from the script.");
|
|
5
5
|
const r = window.WayflyerHeadlessSdk;
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HeadlessSdkOptions, IWayflyerHeadlessSdk } from '@wf-financing/embedded-types';
|
|
2
2
|
|
|
3
3
|
export declare class WayflyerHeadlessSdk {
|
|
4
|
-
static loadSdk(companyToken: string, options?:
|
|
4
|
+
static loadSdk(companyToken: string, options?: HeadlessSdkOptions): Promise<IWayflyerHeadlessSdk>;
|
|
5
5
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IWayflyerHeadlessSdk,
|
|
1
|
+
import { IWayflyerHeadlessSdk, HeadlessSdkOptions } from '@wf-financing/embedded-types';
|
|
2
2
|
|
|
3
|
-
type LoadHeadlessSdkModeType = (companyToken: string, options?:
|
|
3
|
+
type LoadHeadlessSdkModeType = (companyToken: string, options?: HeadlessSdkOptions) => Promise<IWayflyerHeadlessSdk | void>;
|
|
4
4
|
export declare const loadHeadlessSdkMode: LoadHeadlessSdkModeType;
|
|
5
5
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IWayflyerHeadlessSdk,
|
|
1
|
+
import { IWayflyerHeadlessSdk, HeadlessSdkOptions } from '@wf-financing/embedded-types';
|
|
2
2
|
|
|
3
|
-
export declare const initializeHeadlessSdk: (companyToken: string, options?:
|
|
3
|
+
export declare const initializeHeadlessSdk: (companyToken: string, options?: HeadlessSdkOptions) => IWayflyerHeadlessSdk;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IWayflyerHeadlessSdk,
|
|
1
|
+
import { IWayflyerHeadlessSdk, HeadlessSdkOptions } from '@wf-financing/embedded-types';
|
|
2
2
|
|
|
3
|
-
export declare const loadScriptAndInitializeSdk: (script: HTMLScriptElement, companyToken: string, options?:
|
|
3
|
+
export declare const loadScriptAndInitializeSdk: (script: HTMLScriptElement, companyToken: string, options?: HeadlessSdkOptions) => Promise<IWayflyerHeadlessSdk>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wf-financing/headless-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"module": "dist/index.es.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@wf-financing/embedded-types": "0.
|
|
18
|
+
"@wf-financing/embedded-types": "1.0.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"vite": "^6.3.5",
|