idpay-b2b-sdk 0.0.26 → 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.
package/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./src/index";
1
+ export * from "./index";
package/index.esm.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./index";
package/index.esm.js ADDED
@@ -0,0 +1 @@
1
+ var e="2.0.0";let t,s,o,n,i=!1,c=!1;const r="IFRAME",a="REDIRECT",l="SILENT",d="dev",u="uat",p="prod",k={[d]:"https://idpay-dev.unico.io",[u]:"https://idpay-uat.unico.io",[p]:"https://idpay.unico.io"},A=n=>{let{transactionId:r,token:d,onFinish:u}=n;const p={transactionId:r,token:d,onFinish:u,host:s,sdkVersion:e,collectionId:o};if(console.log("open",p),i)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,p),t){case l:UnicoSDKAssets.clientBoxControl.verify(p);break;case a:UnicoSDKAssets.clientBoxControl.redirect(r,d,s,e);break;default:UnicoSDKAssets.clientBoxControl.open(p)}else c=p},E={init:async d=>{let{token:u,useCurrentOrigin:E,env:S=p,type:h=r}=d;switch(t=h,s=E?window.location.origin:k[S],await(()=>{if(n)return Promise.resolve();n=document.createElement("script"),n.src=`${s}/sdk-assets/index.js`;const e=new Promise((e=>{n.onload=e}));return document.body.appendChild(n),Promise.all([e])})(),UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),t){case l:o=await UnicoSDKAssets.clientBoxControl.initSilent();break;case a:break;default:await(()=>{const e=document.createElement("link");e.setAttribute("href",`${s}/sdk-assets/assets/styles.css`),e.setAttribute("rel","stylesheet");const t=new Promise((t=>{e.onload=t}));return document.head.appendChild(e),Promise.all([t])})(),UnicoSDKAssets.clientBoxControl.create({_currentHost:s,token:u,_sdkVersion:e})}if(i=!0,c&&A(c),o)return o},close:()=>{UnicoSDKAssets.clientBoxControl.close()},open:A};export{E as UnicoSDK};
package/index.js CHANGED
@@ -1,112 +1 @@
1
- /* eslint-disable no-undef */
2
-
3
- let _type;
4
- let _initialized = false;
5
- let _openWhileInitializing = false;
6
- let _collectionId;
7
- const TYPE__IFRAME = 'IFRAME';
8
- const TYPE_SILENT = 'SILENT';
9
- const ENV_DEV = 'dev';
10
- const ENV_UAT = 'uat';
11
- const ENV_PROD = 'prod';
12
- const _HOSTS = {
13
- [ENV_DEV]: 'https://idpay-dev.unico.io',
14
- [ENV_UAT]: 'https://idpay-uat.unico.io',
15
- [ENV_PROD]: 'https://idpay.unico.io'
16
- };
17
- const _createScript = ({
18
- host
19
- }) => {
20
- const script = document.createElement('script');
21
- script.src = `${host}/sdk-assets/index.js`;
22
- const prmScript = new Promise(resolve => {
23
- script.onload = resolve;
24
- });
25
- document.body.appendChild(script);
26
- return Promise.all([prmScript]);
27
- };
28
- const _createStyles = ({
29
- host
30
- }) => {
31
- const style = document.createElement('link');
32
- style.setAttribute('href', `${host}/sdk-assets/assets/styles.css`);
33
- style.setAttribute('rel', 'stylesheet');
34
- const prmStyle = new Promise(resolve => {
35
- style.onload = resolve;
36
- });
37
- document.head.appendChild(style);
38
- return Promise.all([prmStyle]);
39
- };
40
- const _getEnvHost = (env = ENV_PROD) => _HOSTS[env];
41
- const init = async options => {
42
- const token = options?.token;
43
- const host = options?.useCurrentOrigin ? window.location.origin : _getEnvHost(options?.env);
44
- await _createScript({
45
- host
46
- });
47
- IDPaySDKAssets.trackEvent(IDPaySDKAssets.EVENT_TYPES.INITIALIZE);
48
- _type = options?.type;
49
- if (_type === TYPE_SILENT) {
50
- _collectionId = await IDPaySDKAssets.clientBoxControl.initSilent();
51
- } else if (_type === TYPE__IFRAME) {
52
- await _createStyles({
53
- host
54
- });
55
- IDPaySDKAssets.clientBoxControl.create({
56
- host,
57
- token
58
- });
59
- }
60
- _initialized = true;
61
- if (_openWhileInitializing) {
62
- startPayFlow(_openWhileInitializing);
63
- }
64
- if (_collectionId) {
65
- return _collectionId;
66
- }
67
- };
68
- const startPayFlow = ({
69
- transactionId,
70
- token,
71
- onFinish
72
- }) => {
73
- console.log('startPayFlow', {
74
- transactionId,
75
- token,
76
- onFinish
77
- });
78
- if (!_initialized) {
79
- _openWhileInitializing = {
80
- transactionId,
81
- token,
82
- onFinish
83
- };
84
- return;
85
- }
86
- IDPaySDKAssets.trackEvent(IDPaySDKAssets.EVENT_TYPES.START_FLOW, {
87
- transactionId,
88
- token
89
- });
90
- if (_type === TYPE_SILENT) {
91
- IDPaySDKAssets.clientBoxControl.verify({
92
- transactionId,
93
- token,
94
- collectionId: _collectionId,
95
- onFinish
96
- });
97
- } else if (_type === TYPE__IFRAME) {
98
- IDPaySDKAssets.clientBoxControl.open({
99
- transactionId,
100
- token,
101
- onFinish
102
- });
103
- } else {
104
- IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
105
- }
106
- };
107
- const IDPaySDK = {
108
- init,
109
- open: startPayFlow
110
- };
111
-
112
- export { IDPaySDK };
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).UnicoSDK={})}(this,(function(e){"use strict";var t="2.0.0";let o,s,n,i,c=!1,r=!1;const l="IFRAME",a="REDIRECT",d="SILENT",u="dev",p="uat",f="prod",S={[u]:"https://idpay-dev.unico.io",[p]:"https://idpay-uat.unico.io",[f]:"https://idpay.unico.io"},h=e=>{let{transactionId:i,token:l,onFinish:u}=e;const p={transactionId:i,token:l,onFinish:u,host:s,sdkVersion:t,collectionId:n};if(console.log("open",p),c)switch(UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.START_FLOW,p),o){case d:UnicoSDKAssets.clientBoxControl.verify(p);break;case a:UnicoSDKAssets.clientBoxControl.redirect(i,l,s,t);break;default:UnicoSDKAssets.clientBoxControl.open(p)}else r=p},k={init:async e=>{let{token:u,useCurrentOrigin:p,env:k=f,type:A=l}=e;switch(o=A,s=p?window.location.origin:S[k],await(()=>{if(i)return Promise.resolve();i=document.createElement("script"),i.src=`${s}/sdk-assets/index.js`;const e=new Promise((e=>{i.onload=e}));return document.body.appendChild(i),Promise.all([e])})(),UnicoSDKAssets.trackEvent(UnicoSDKAssets.EVENT_TYPES.INITIALIZE),o){case d:n=await UnicoSDKAssets.clientBoxControl.initSilent();break;case a:break;default:await(()=>{const e=document.createElement("link");e.setAttribute("href",`${s}/sdk-assets/assets/styles.css`),e.setAttribute("rel","stylesheet");const t=new Promise((t=>{e.onload=t}));return document.head.appendChild(e),Promise.all([t])})(),UnicoSDKAssets.clientBoxControl.create({_currentHost:s,token:u,_sdkVersion:t})}if(c=!0,r&&h(r),n)return n},close:()=>{UnicoSDKAssets.clientBoxControl.close()},open:h};e.UnicoSDK=k}));
package/package.json CHANGED
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "idpay-b2b-sdk",
3
- "version": "0.0.26",
3
+ "version": "2.0.0",
4
+ "main": "./index.js",
5
+ "module": "./index.esm.js",
6
+ "types": "./index.d.ts",
4
7
  "repository": {
5
8
  "type": "git",
6
9
  "url": "https://github.com/acesso-io/frontend.git",
7
10
  "directory": "libs/pay/sdk/idpay-b2b-sdk"
8
11
  },
9
12
  "publishConfig": {
10
- "registry": "https://registry.npmjs.org",
11
- "tag": "internal"
13
+ "registry": "https://registry.npmjs.org"
12
14
  },
13
- "module": "./index.esm.js",
14
- "type": "module",
15
- "main": "./index.esm.js",
16
- "types": "./index.esm.d.ts"
15
+ "scripts": {
16
+ "correct-dts": "node correct-dts.js",
17
+ "build-with-postbuild": "nx run idpay-b2b-sdk:build-with-postbuild"
18
+ },
19
+ "type": "module"
17
20
  }
package/index.cjs DELETED
@@ -1,120 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.IDPaySDK = {}));
5
- })(this, (function (exports) { 'use strict';
6
-
7
- /* eslint-disable no-undef */
8
-
9
- let _type;
10
- let _initialized = false;
11
- let _openWhileInitializing = false;
12
- let _collectionId;
13
- const TYPE__IFRAME = 'IFRAME';
14
- const TYPE_SILENT = 'SILENT';
15
- const ENV_DEV = 'dev';
16
- const ENV_UAT = 'uat';
17
- const ENV_PROD = 'prod';
18
- const _HOSTS = {
19
- [ENV_DEV]: 'https://idpay-dev.unico.io',
20
- [ENV_UAT]: 'https://idpay-uat.unico.io',
21
- [ENV_PROD]: 'https://idpay.unico.io'
22
- };
23
- const _createScript = ({
24
- host
25
- }) => {
26
- const script = document.createElement('script');
27
- script.src = `${host}/sdk-assets/index.js`;
28
- const prmScript = new Promise(resolve => {
29
- script.onload = resolve;
30
- });
31
- document.body.appendChild(script);
32
- return Promise.all([prmScript]);
33
- };
34
- const _createStyles = ({
35
- host
36
- }) => {
37
- const style = document.createElement('link');
38
- style.setAttribute('href', `${host}/sdk-assets/assets/styles.css`);
39
- style.setAttribute('rel', 'stylesheet');
40
- const prmStyle = new Promise(resolve => {
41
- style.onload = resolve;
42
- });
43
- document.head.appendChild(style);
44
- return Promise.all([prmStyle]);
45
- };
46
- const _getEnvHost = (env = ENV_PROD) => _HOSTS[env];
47
- const init = async options => {
48
- const token = options?.token;
49
- const host = options?.useCurrentOrigin ? window.location.origin : _getEnvHost(options?.env);
50
- await _createScript({
51
- host
52
- });
53
- IDPaySDKAssets.trackEvent(IDPaySDKAssets.EVENT_TYPES.INITIALIZE);
54
- _type = options?.type;
55
- if (_type === TYPE_SILENT) {
56
- _collectionId = await IDPaySDKAssets.clientBoxControl.initSilent();
57
- } else if (_type === TYPE__IFRAME) {
58
- await _createStyles({
59
- host
60
- });
61
- IDPaySDKAssets.clientBoxControl.create({
62
- host,
63
- token
64
- });
65
- }
66
- _initialized = true;
67
- if (_openWhileInitializing) {
68
- startPayFlow(_openWhileInitializing);
69
- }
70
- if (_collectionId) {
71
- return _collectionId;
72
- }
73
- };
74
- const startPayFlow = ({
75
- transactionId,
76
- token,
77
- onFinish
78
- }) => {
79
- console.log('startPayFlow', {
80
- transactionId,
81
- token,
82
- onFinish
83
- });
84
- if (!_initialized) {
85
- _openWhileInitializing = {
86
- transactionId,
87
- token,
88
- onFinish
89
- };
90
- return;
91
- }
92
- IDPaySDKAssets.trackEvent(IDPaySDKAssets.EVENT_TYPES.START_FLOW, {
93
- transactionId,
94
- token
95
- });
96
- if (_type === TYPE_SILENT) {
97
- IDPaySDKAssets.clientBoxControl.verify({
98
- transactionId,
99
- token,
100
- collectionId: _collectionId,
101
- onFinish
102
- });
103
- } else if (_type === TYPE__IFRAME) {
104
- IDPaySDKAssets.clientBoxControl.open({
105
- transactionId,
106
- token,
107
- onFinish
108
- });
109
- } else {
110
- IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
111
- }
112
- };
113
- const IDPaySDK = {
114
- init,
115
- open: startPayFlow
116
- };
117
-
118
- exports.IDPaySDK = IDPaySDK;
119
-
120
- }));
package/index.umd.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/index";
package/index.umd.js DELETED
@@ -1,120 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.IDPaySDK = {}));
5
- })(this, (function (exports) { 'use strict';
6
-
7
- /* eslint-disable no-undef */
8
-
9
- let _type;
10
- let _initialized = false;
11
- let _openWhileInitializing = false;
12
- let _collectionId;
13
- const TYPE__IFRAME = 'IFRAME';
14
- const TYPE_SILENT = 'SILENT';
15
- const ENV_DEV = 'dev';
16
- const ENV_UAT = 'uat';
17
- const ENV_PROD = 'prod';
18
- const _HOSTS = {
19
- [ENV_DEV]: 'https://idpay-dev.unico.io',
20
- [ENV_UAT]: 'https://idpay-uat.unico.io',
21
- [ENV_PROD]: 'https://idpay.unico.io'
22
- };
23
- const _createScript = ({
24
- host
25
- }) => {
26
- const script = document.createElement('script');
27
- script.src = `${host}/sdk-assets/index.js`;
28
- const prmScript = new Promise(resolve => {
29
- script.onload = resolve;
30
- });
31
- document.body.appendChild(script);
32
- return Promise.all([prmScript]);
33
- };
34
- const _createStyles = ({
35
- host
36
- }) => {
37
- const style = document.createElement('link');
38
- style.setAttribute('href', `${host}/sdk-assets/assets/styles.css`);
39
- style.setAttribute('rel', 'stylesheet');
40
- const prmStyle = new Promise(resolve => {
41
- style.onload = resolve;
42
- });
43
- document.head.appendChild(style);
44
- return Promise.all([prmStyle]);
45
- };
46
- const _getEnvHost = (env = ENV_PROD) => _HOSTS[env];
47
- const init = async options => {
48
- const token = options?.token;
49
- const host = options?.useCurrentOrigin ? window.location.origin : _getEnvHost(options?.env);
50
- await _createScript({
51
- host
52
- });
53
- IDPaySDKAssets.trackEvent(IDPaySDKAssets.EVENT_TYPES.INITIALIZE);
54
- _type = options?.type;
55
- if (_type === TYPE_SILENT) {
56
- _collectionId = await IDPaySDKAssets.clientBoxControl.initSilent();
57
- } else if (_type === TYPE__IFRAME) {
58
- await _createStyles({
59
- host
60
- });
61
- IDPaySDKAssets.clientBoxControl.create({
62
- host,
63
- token
64
- });
65
- }
66
- _initialized = true;
67
- if (_openWhileInitializing) {
68
- startPayFlow(_openWhileInitializing);
69
- }
70
- if (_collectionId) {
71
- return _collectionId;
72
- }
73
- };
74
- const startPayFlow = ({
75
- transactionId,
76
- token,
77
- onFinish
78
- }) => {
79
- console.log('startPayFlow', {
80
- transactionId,
81
- token,
82
- onFinish
83
- });
84
- if (!_initialized) {
85
- _openWhileInitializing = {
86
- transactionId,
87
- token,
88
- onFinish
89
- };
90
- return;
91
- }
92
- IDPaySDKAssets.trackEvent(IDPaySDKAssets.EVENT_TYPES.START_FLOW, {
93
- transactionId,
94
- token
95
- });
96
- if (_type === TYPE_SILENT) {
97
- IDPaySDKAssets.clientBoxControl.verify({
98
- transactionId,
99
- token,
100
- collectionId: _collectionId,
101
- onFinish
102
- });
103
- } else if (_type === TYPE__IFRAME) {
104
- IDPaySDKAssets.clientBoxControl.open({
105
- transactionId,
106
- token,
107
- onFinish
108
- });
109
- } else {
110
- IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
111
- }
112
- };
113
- const IDPaySDK = {
114
- init,
115
- open: startPayFlow
116
- };
117
-
118
- exports.IDPaySDK = IDPaySDK;
119
-
120
- }));