@wf-financing/headless-sdk 1.0.1 → 2.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.
@@ -1 +1 @@
1
- export declare const HEADLESS_PACKAGE_URL = "https://cdn.jsdelivr.net/npm/@wf-financing/headless@1/dist/index.es.js";
1
+ export declare const HEADLESS_PACKAGE_URL = "https://embedded-finance-frontend.vercel.app/npm/@wf-financing/headless@2";
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var s=(e=>(e.GENERIC_OFFER="generic_offer",e.INDICATIVE_OFFER="indicative_offer",e.CONTINUE_HOSTED_APPLICATION="continue_hosted_application",e.NO_CTA="no_cta",e.INVALID_TOKEN="invalid_token",e))(s||{}),d=(e=>(e.REDIRECT_URL="redirect_url",e.BAD_REQUEST="bad_request",e.INVALID_TOKEN="invalid_token",e))(d||{}),o=(e=>(e.REDIRECT_URL="redirect_url",e.BAD_REQUEST="bad_request",e.INVALID_TOKEN="invalid_token",e))(o||{}),l=(e=>(e.NO_CTA="no_cta",e.CONTINUE_APPLICATION="continue_application",e.GENERIC_NEW_APPLICATION="generic_new_application",e.INDICATIVE_NEW_APPLICATION="indicative_new_application",e))(l||{}),c=(e=>(e.GENERIC_OFFER="generic_offer",e.INDICATIVE_OFFER="indicative_offer",e.CONTINUE_APPLICATION="continue_application",e))(c||{});const a="wayflyer-headless-sdk",y="https://cdn.jsdelivr.net/npm/@wf-financing/headless@1/dist/index.es.js",E=(e,n)=>{if(!window.WayflyerHeadlessSdk)throw new Error("Failed to load WayflyerHeadlessSdk from the script.");const t=window.WayflyerHeadlessSdk;return new t(e,n)},i=(e,n,t)=>new Promise((r,I)=>{e.onload=()=>{try{r(E(n,t))}catch(p){I(p)}}}),S=async(e,n)=>{try{const t=document.getElementById(a);if(window.WayflyerHeadlessSdk)return E(e,n);if(t)return i(t,e,n);const r=document.createElement("script");return r.src=y,r.type="module",r.id=a,r.async=!0,document.head.appendChild(r),i(r,e,n)}catch(t){throw console.error("Error in loading headless SDK:",t),new Error("Failed to load script")}};class _{static async loadSdk(n,t){return await S(n,t)}}exports.ContinueHostedApplicationResponseTypes=o;exports.CtaResponseTypes=s;exports.CtaStateType=c;exports.SdkScenarios=l;exports.StartHostedApplicationResponseTypes=d;exports.WayflyerHeadlessSdk=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var s=(e=>(e.GENERIC_OFFER="generic_offer",e.INDICATIVE_OFFER="indicative_offer",e.CONTINUE_HOSTED_APPLICATION="continue_hosted_application",e.NO_CTA="no_cta",e.INVALID_TOKEN="invalid_token",e))(s||{}),i=(e=>(e.REDIRECT_URL="redirect_url",e.BAD_REQUEST="bad_request",e.INVALID_TOKEN="invalid_token",e))(i||{}),o=(e=>(e.REDIRECT_URL="redirect_url",e.BAD_REQUEST="bad_request",e.INVALID_TOKEN="invalid_token",e))(o||{}),l=(e=>(e.GENERIC_OFFER="generic_offer",e.INDICATIVE_OFFER="indicative_offer",e.CONTINUE_APPLICATION="continue_application",e))(l||{});const d="wayflyer-headless-sdk",S="https://embedded-finance-frontend.vercel.app/npm/@wf-financing/headless@2",c=(e,r)=>{if(!window.WayflyerHeadlessSdk)throw new Error("Failed to load WayflyerHeadlessSdk from the script.");const t=window.WayflyerHeadlessSdk;return new t(e,r)},n=(e,r,t)=>new Promise((a,E)=>{e.onload=()=>{try{a(c(r,t))}catch(y){E(y)}}}),f=async(e,r)=>{try{const t=document.getElementById(d);if(window.WayflyerHeadlessSdk)return c(e,r);if(t)return n(t,e,r);const a=document.createElement("script");return a.src=S,a.type="module",a.id=d,a.async=!0,document.head.appendChild(a),n(a,e,r)}catch(t){throw console.error("Error in loading headless SDK:",t),new Error("Failed to load script")}};class I{static async loadSdk(r,t){return await f(r,t)}}exports.ContinueHostedApplicationResponseTypes=o;exports.CtaResponseTypes=s;exports.CtaStateType=l;exports.StartHostedApplicationResponseTypes=i;exports.WayflyerHeadlessSdk=I;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { ContinueHostedApplicationResponseTypes, CtaResponseTypes, CtaStateType, StartHostedApplicationResponseTypes, SdkScenarios, } from '@wf-financing/embedded-types';
2
- export type { CanadianProvinceCode, CompanyDataType, ContinueHostedApplicationResponseType, CountryCode, CtaContinueFundingType, CtaGenericOfferType, CtaIndicativeOfferType, CtaResponseType, IHeadlessWayflyerSdk, StartHostedApplicationRequestType, StartHostedApplicationResponseType, UserDataType, USStateCode, } from '@wf-financing/embedded-types';
1
+ export { ContinueHostedApplicationResponseTypes, CtaResponseTypes, CtaStateType, StartHostedApplicationResponseTypes, } from '@wf-financing/embedded-types';
2
+ export type { CanadianProvinceCode, CompanyDataType, ContinueHostedApplicationResponseType, CountryCode, CtaContinueFundingType, CtaGenericOfferType, CtaIndicativeOfferType, CtaResponseType, IHeadlessWayflyerSdk, StartHostedApplicationRequestType, StartHostedApplicationResponseType, UserDataType, USStateCode, SdkOptionsType, } from '@wf-financing/embedded-types';
3
3
  export { WayflyerHeadlessSdk } from './sdk';
package/dist/index.es.js CHANGED
@@ -1,40 +1,39 @@
1
- var l = /* @__PURE__ */ ((e) => (e.GENERIC_OFFER = "generic_offer", e.INDICATIVE_OFFER = "indicative_offer", e.CONTINUE_HOSTED_APPLICATION = "continue_hosted_application", e.NO_CTA = "no_cta", e.INVALID_TOKEN = "invalid_token", e))(l || {}), c = /* @__PURE__ */ ((e) => (e.REDIRECT_URL = "redirect_url", e.BAD_REQUEST = "bad_request", e.INVALID_TOKEN = "invalid_token", e))(c || {}), E = /* @__PURE__ */ ((e) => (e.REDIRECT_URL = "redirect_url", e.BAD_REQUEST = "bad_request", e.INVALID_TOKEN = "invalid_token", e))(E || {}), I = /* @__PURE__ */ ((e) => (e.NO_CTA = "no_cta", e.CONTINUE_APPLICATION = "continue_application", e.GENERIC_NEW_APPLICATION = "generic_new_application", e.INDICATIVE_NEW_APPLICATION = "indicative_new_application", e))(I || {}), p = /* @__PURE__ */ ((e) => (e.GENERIC_OFFER = "generic_offer", e.INDICATIVE_OFFER = "indicative_offer", e.CONTINUE_APPLICATION = "continue_application", e))(p || {});
2
- const r = "wayflyer-headless-sdk", _ = "https://cdn.jsdelivr.net/npm/@wf-financing/headless@1/dist/index.es.js", s = (e, a) => {
1
+ var l = /* @__PURE__ */ ((e) => (e.GENERIC_OFFER = "generic_offer", e.INDICATIVE_OFFER = "indicative_offer", e.CONTINUE_HOSTED_APPLICATION = "continue_hosted_application", e.NO_CTA = "no_cta", e.INVALID_TOKEN = "invalid_token", e))(l || {}), c = /* @__PURE__ */ ((e) => (e.REDIRECT_URL = "redirect_url", e.BAD_REQUEST = "bad_request", e.INVALID_TOKEN = "invalid_token", e))(c || {}), E = /* @__PURE__ */ ((e) => (e.REDIRECT_URL = "redirect_url", e.BAD_REQUEST = "bad_request", e.INVALID_TOKEN = "invalid_token", e))(E || {}), y = /* @__PURE__ */ ((e) => (e.GENERIC_OFFER = "generic_offer", e.INDICATIVE_OFFER = "indicative_offer", e.CONTINUE_APPLICATION = "continue_application", e))(y || {});
2
+ const s = "wayflyer-headless-sdk", I = "https://embedded-finance-frontend.vercel.app/npm/@wf-financing/headless@2", n = (e, t) => {
3
3
  if (!window.WayflyerHeadlessSdk)
4
4
  throw new Error("Failed to load WayflyerHeadlessSdk from the script.");
5
- const t = window.WayflyerHeadlessSdk;
6
- return new t(e, a);
7
- }, i = (e, a, t) => new Promise((n, d) => {
5
+ const r = window.WayflyerHeadlessSdk;
6
+ return new r(e, t);
7
+ }, d = (e, t, r) => new Promise((a, i) => {
8
8
  e.onload = () => {
9
9
  try {
10
- n(s(a, t));
10
+ a(n(t, r));
11
11
  } catch (o) {
12
- d(o);
12
+ i(o);
13
13
  }
14
14
  };
15
- }), A = async (e, a) => {
15
+ }), f = async (e, t) => {
16
16
  try {
17
- const t = document.getElementById(r);
17
+ const r = document.getElementById(s);
18
18
  if (window.WayflyerHeadlessSdk)
19
- return s(e, a);
20
- if (t)
21
- return i(t, e, a);
22
- const n = document.createElement("script");
23
- return n.src = _, n.type = "module", n.id = r, n.async = !0, document.head.appendChild(n), i(n, e, a);
24
- } catch (t) {
25
- throw console.error("Error in loading headless SDK:", t), new Error("Failed to load script");
19
+ return n(e, t);
20
+ if (r)
21
+ return d(r, e, t);
22
+ const a = document.createElement("script");
23
+ return a.src = I, a.type = "module", a.id = s, a.async = !0, document.head.appendChild(a), d(a, e, t);
24
+ } catch (r) {
25
+ throw console.error("Error in loading headless SDK:", r), new Error("Failed to load script");
26
26
  }
27
27
  };
28
- class N {
29
- static async loadSdk(a, t) {
30
- return await A(a, t);
28
+ class p {
29
+ static async loadSdk(t, r) {
30
+ return await f(t, r);
31
31
  }
32
32
  }
33
33
  export {
34
34
  E as ContinueHostedApplicationResponseTypes,
35
35
  l as CtaResponseTypes,
36
- p as CtaStateType,
37
- I as SdkScenarios,
36
+ y as CtaStateType,
38
37
  c as StartHostedApplicationResponseTypes,
39
- N as WayflyerHeadlessSdk
38
+ p as WayflyerHeadlessSdk
40
39
  };
@@ -1,3 +1,5 @@
1
+ import { SdkOptionsType } from '@wf-financing/embedded-types';
2
+
1
3
  export declare class WayflyerHeadlessSdk {
2
- static loadSdk(companyToken: string, isMockedMode?: boolean): Promise<void | import('@wf-financing/embedded-types').IHeadlessWayflyerSdk>;
4
+ static loadSdk(companyToken: string, options?: SdkOptionsType): Promise<void | import('@wf-financing/embedded-types').IHeadlessWayflyerSdk>;
3
5
  }
@@ -1,5 +1,5 @@
1
- import { IHeadlessWayflyerSdk } from '@wf-financing/embedded-types';
1
+ import { IHeadlessWayflyerSdk, SdkOptionsType } from '@wf-financing/embedded-types';
2
2
 
3
- type LoadHeadlessSdkModeType = (companyToken: string, isMockedMode?: boolean) => Promise<IHeadlessWayflyerSdk | void>;
3
+ type LoadHeadlessSdkModeType = (companyToken: string, options?: SdkOptionsType) => Promise<IHeadlessWayflyerSdk | void>;
4
4
  export declare const loadHeadlessSdkMode: LoadHeadlessSdkModeType;
5
5
  export {};
@@ -1,3 +1,3 @@
1
- import { IHeadlessWayflyerSdk } from '@wf-financing/embedded-types';
1
+ import { IHeadlessWayflyerSdk, SdkOptionsType } from '@wf-financing/embedded-types';
2
2
 
3
- export declare const initializeHeadlessSdk: (companyToken: string, isMockedMode?: boolean) => IHeadlessWayflyerSdk;
3
+ export declare const initializeHeadlessSdk: (companyToken: string, options?: SdkOptionsType) => IHeadlessWayflyerSdk;
@@ -1,3 +1,3 @@
1
- import { IHeadlessWayflyerSdk } from '@wf-financing/embedded-types';
1
+ import { IHeadlessWayflyerSdk, SdkOptionsType } from '@wf-financing/embedded-types';
2
2
 
3
- export declare const loadScriptAndInitializeSdk: (script: HTMLScriptElement, companyToken: string, isMockedMode?: boolean) => Promise<IHeadlessWayflyerSdk>;
3
+ export declare const loadScriptAndInitializeSdk: (script: HTMLScriptElement, companyToken: string, options?: SdkOptionsType) => Promise<IHeadlessWayflyerSdk>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wf-financing/headless-sdk",
3
- "version": "1.0.1",
3
+ "version": "2.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.3.0"
18
+ "@wf-financing/embedded-types": "0.4.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "vite": "^6.3.5",