idpay-b2b-sdk 0.0.27 → 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,124 +1 @@
1
- /* eslint-disable no-undef */
2
-
3
- let _type;
4
- let _initialized = false;
5
- let _openWhileInitializing = false;
6
- let _collectionId;
7
- let _script;
8
-
9
- // const TYPE__IFRAME = 'IFRAME';
10
- const TYPE__REDIRECT = 'REDIRECT';
11
- const TYPE_SILENT = 'SILENT';
12
- const ENV_DEV = 'dev';
13
- const ENV_UAT = 'uat';
14
- const ENV_PROD = 'prod';
15
- const _HOSTS = {
16
- [ENV_DEV]: 'https://idpay-dev.unico.io',
17
- [ENV_UAT]: 'https://idpay-uat.unico.io',
18
- [ENV_PROD]: 'https://idpay.unico.io'
19
- };
20
- const _createScript = ({
21
- host
22
- }) => {
23
- if (_script) {
24
- return Promise.resolve();
25
- }
26
- _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__REDIRECT) {
58
- // iframe
59
- await _createStyles({
60
- host
61
- });
62
- IDPaySDKAssets.clientBoxControl.create({
63
- host,
64
- token
65
- });
66
- }
67
- _initialized = true;
68
- if (_openWhileInitializing) {
69
- startPayFlow(_openWhileInitializing);
70
- }
71
- if (_collectionId) {
72
- return _collectionId;
73
- }
74
- };
75
- const startPayFlow = ({
76
- transactionId,
77
- token,
78
- onFinish
79
- }) => {
80
- console.log('startPayFlow', {
81
- transactionId,
82
- token,
83
- onFinish
84
- });
85
- if (!_initialized) {
86
- _openWhileInitializing = {
87
- transactionId,
88
- token,
89
- onFinish
90
- };
91
- return;
92
- }
93
- IDPaySDKAssets.trackEvent(IDPaySDKAssets.EVENT_TYPES.START_FLOW, {
94
- transactionId,
95
- token
96
- });
97
- if (_type === TYPE_SILENT) {
98
- IDPaySDKAssets.clientBoxControl.verify({
99
- transactionId,
100
- token,
101
- collectionId: _collectionId,
102
- onFinish
103
- });
104
- } else if (_type === TYPE__REDIRECT) {
105
- IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
106
- } else {
107
- // iframe
108
- IDPaySDKAssets.clientBoxControl.open({
109
- transactionId,
110
- token,
111
- onFinish
112
- });
113
- }
114
- };
115
- const close = () => {
116
- IDPaySDKAssets.clientBoxControl.close();
117
- };
118
- const IDPaySDK = {
119
- init,
120
- close,
121
- open: startPayFlow
122
- };
123
-
124
- 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.27",
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": "beta"
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,132 +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
- let _script;
14
-
15
- // const TYPE__IFRAME = 'IFRAME';
16
- const TYPE__REDIRECT = 'REDIRECT';
17
- const TYPE_SILENT = 'SILENT';
18
- const ENV_DEV = 'dev';
19
- const ENV_UAT = 'uat';
20
- const ENV_PROD = 'prod';
21
- const _HOSTS = {
22
- [ENV_DEV]: 'https://idpay-dev.unico.io',
23
- [ENV_UAT]: 'https://idpay-uat.unico.io',
24
- [ENV_PROD]: 'https://idpay.unico.io'
25
- };
26
- const _createScript = ({
27
- host
28
- }) => {
29
- if (_script) {
30
- return Promise.resolve();
31
- }
32
- _script = document.createElement('script');
33
- _script.src = `${host}/sdk-assets/index.js`;
34
- const prmScript = new Promise(resolve => {
35
- _script.onload = resolve;
36
- });
37
- document.body.appendChild(_script);
38
- return Promise.all([prmScript]);
39
- };
40
- const _createStyles = ({
41
- host
42
- }) => {
43
- const style = document.createElement('link');
44
- style.setAttribute('href', `${host}/sdk-assets/assets/styles.css`);
45
- style.setAttribute('rel', 'stylesheet');
46
- const prmStyle = new Promise(resolve => {
47
- style.onload = resolve;
48
- });
49
- document.head.appendChild(style);
50
- return Promise.all([prmStyle]);
51
- };
52
- const _getEnvHost = (env = ENV_PROD) => _HOSTS[env];
53
- const init = async options => {
54
- const token = options?.token;
55
- const host = options?.useCurrentOrigin ? window.location.origin : _getEnvHost(options?.env);
56
- await _createScript({
57
- host
58
- });
59
- IDPaySDKAssets.trackEvent(IDPaySDKAssets.EVENT_TYPES.INITIALIZE);
60
- _type = options?.type;
61
- if (_type === TYPE_SILENT) {
62
- _collectionId = await IDPaySDKAssets.clientBoxControl.initSilent();
63
- } else if (_type !== TYPE__REDIRECT) {
64
- // iframe
65
- await _createStyles({
66
- host
67
- });
68
- IDPaySDKAssets.clientBoxControl.create({
69
- host,
70
- token
71
- });
72
- }
73
- _initialized = true;
74
- if (_openWhileInitializing) {
75
- startPayFlow(_openWhileInitializing);
76
- }
77
- if (_collectionId) {
78
- return _collectionId;
79
- }
80
- };
81
- const startPayFlow = ({
82
- transactionId,
83
- token,
84
- onFinish
85
- }) => {
86
- console.log('startPayFlow', {
87
- transactionId,
88
- token,
89
- onFinish
90
- });
91
- if (!_initialized) {
92
- _openWhileInitializing = {
93
- transactionId,
94
- token,
95
- onFinish
96
- };
97
- return;
98
- }
99
- IDPaySDKAssets.trackEvent(IDPaySDKAssets.EVENT_TYPES.START_FLOW, {
100
- transactionId,
101
- token
102
- });
103
- if (_type === TYPE_SILENT) {
104
- IDPaySDKAssets.clientBoxControl.verify({
105
- transactionId,
106
- token,
107
- collectionId: _collectionId,
108
- onFinish
109
- });
110
- } else if (_type === TYPE__REDIRECT) {
111
- IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
112
- } else {
113
- // iframe
114
- IDPaySDKAssets.clientBoxControl.open({
115
- transactionId,
116
- token,
117
- onFinish
118
- });
119
- }
120
- };
121
- const close = () => {
122
- IDPaySDKAssets.clientBoxControl.close();
123
- };
124
- const IDPaySDK = {
125
- init,
126
- close,
127
- open: startPayFlow
128
- };
129
-
130
- exports.IDPaySDK = IDPaySDK;
131
-
132
- }));
package/index.umd.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/index";
package/index.umd.js DELETED
@@ -1,132 +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
- let _script;
14
-
15
- // const TYPE__IFRAME = 'IFRAME';
16
- const TYPE__REDIRECT = 'REDIRECT';
17
- const TYPE_SILENT = 'SILENT';
18
- const ENV_DEV = 'dev';
19
- const ENV_UAT = 'uat';
20
- const ENV_PROD = 'prod';
21
- const _HOSTS = {
22
- [ENV_DEV]: 'https://idpay-dev.unico.io',
23
- [ENV_UAT]: 'https://idpay-uat.unico.io',
24
- [ENV_PROD]: 'https://idpay.unico.io'
25
- };
26
- const _createScript = ({
27
- host
28
- }) => {
29
- if (_script) {
30
- return Promise.resolve();
31
- }
32
- _script = document.createElement('script');
33
- _script.src = `${host}/sdk-assets/index.js`;
34
- const prmScript = new Promise(resolve => {
35
- _script.onload = resolve;
36
- });
37
- document.body.appendChild(_script);
38
- return Promise.all([prmScript]);
39
- };
40
- const _createStyles = ({
41
- host
42
- }) => {
43
- const style = document.createElement('link');
44
- style.setAttribute('href', `${host}/sdk-assets/assets/styles.css`);
45
- style.setAttribute('rel', 'stylesheet');
46
- const prmStyle = new Promise(resolve => {
47
- style.onload = resolve;
48
- });
49
- document.head.appendChild(style);
50
- return Promise.all([prmStyle]);
51
- };
52
- const _getEnvHost = (env = ENV_PROD) => _HOSTS[env];
53
- const init = async options => {
54
- const token = options?.token;
55
- const host = options?.useCurrentOrigin ? window.location.origin : _getEnvHost(options?.env);
56
- await _createScript({
57
- host
58
- });
59
- IDPaySDKAssets.trackEvent(IDPaySDKAssets.EVENT_TYPES.INITIALIZE);
60
- _type = options?.type;
61
- if (_type === TYPE_SILENT) {
62
- _collectionId = await IDPaySDKAssets.clientBoxControl.initSilent();
63
- } else if (_type !== TYPE__REDIRECT) {
64
- // iframe
65
- await _createStyles({
66
- host
67
- });
68
- IDPaySDKAssets.clientBoxControl.create({
69
- host,
70
- token
71
- });
72
- }
73
- _initialized = true;
74
- if (_openWhileInitializing) {
75
- startPayFlow(_openWhileInitializing);
76
- }
77
- if (_collectionId) {
78
- return _collectionId;
79
- }
80
- };
81
- const startPayFlow = ({
82
- transactionId,
83
- token,
84
- onFinish
85
- }) => {
86
- console.log('startPayFlow', {
87
- transactionId,
88
- token,
89
- onFinish
90
- });
91
- if (!_initialized) {
92
- _openWhileInitializing = {
93
- transactionId,
94
- token,
95
- onFinish
96
- };
97
- return;
98
- }
99
- IDPaySDKAssets.trackEvent(IDPaySDKAssets.EVENT_TYPES.START_FLOW, {
100
- transactionId,
101
- token
102
- });
103
- if (_type === TYPE_SILENT) {
104
- IDPaySDKAssets.clientBoxControl.verify({
105
- transactionId,
106
- token,
107
- collectionId: _collectionId,
108
- onFinish
109
- });
110
- } else if (_type === TYPE__REDIRECT) {
111
- IDPaySDKAssets.clientBoxControl.redirect(transactionId, token);
112
- } else {
113
- // iframe
114
- IDPaySDKAssets.clientBoxControl.open({
115
- transactionId,
116
- token,
117
- onFinish
118
- });
119
- }
120
- };
121
- const close = () => {
122
- IDPaySDKAssets.clientBoxControl.close();
123
- };
124
- const IDPaySDK = {
125
- init,
126
- close,
127
- open: startPayFlow
128
- };
129
-
130
- exports.IDPaySDK = IDPaySDK;
131
-
132
- }));