@parafin/core 0.0.1 → 1.0.1
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 +3 -0
- package/index.ts +51 -41
- package/out/index.d.ts +1 -1
- package/out/index.js +49 -40
- package/package.json +1 -8
- package/tsconfig.json +14 -0
package/README.md
ADDED
package/index.ts
CHANGED
|
@@ -1,54 +1,64 @@
|
|
|
1
1
|
export const openParafinDashboard = (props: {
|
|
2
2
|
token: string
|
|
3
|
+
product: 'capital' | 'banking'
|
|
3
4
|
route?: string
|
|
4
|
-
product?: string
|
|
5
5
|
externalBusinessId?: string
|
|
6
6
|
onExit?: () => void
|
|
7
7
|
environment?: string
|
|
8
8
|
}) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
try {
|
|
10
|
+
const existingParafinDashboard =
|
|
11
|
+
document.getElementById('parafin-dashboard')
|
|
12
|
+
if (existingParafinDashboard) {
|
|
13
|
+
document.removeChild(existingParafinDashboard)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const iframe = document.createElement('iframe')
|
|
17
|
+
iframe.id = 'parafin-dashboard'
|
|
18
|
+
iframe.style.position = 'fixed'
|
|
19
|
+
iframe.style.top = '0'
|
|
20
|
+
iframe.style.left = '0'
|
|
21
|
+
iframe.style.width = '100%'
|
|
22
|
+
iframe.style.height = '100%'
|
|
23
|
+
iframe.style.border = 'none'
|
|
24
|
+
iframe.style.zIndex = '2147483647'
|
|
25
|
+
iframe.style.backgroundColor = '#fff'
|
|
26
|
+
iframe.style.opacity = '0'
|
|
27
|
+
iframe.style.transition = 'opacity 0.2s'
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
const getBaseUrl = () => {
|
|
30
|
+
switch (props.environment) {
|
|
31
|
+
case 'local':
|
|
32
|
+
return 'http://localhost:9000'
|
|
33
|
+
case 'development':
|
|
34
|
+
return 'https://app.dev.parafin.com'
|
|
35
|
+
default:
|
|
36
|
+
return 'https://app.parafin.com'
|
|
37
|
+
}
|
|
30
38
|
}
|
|
31
|
-
}
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
const baseUrl = getBaseUrl()
|
|
41
|
+
const route = props.route ?? '/'
|
|
42
|
+
const token = `?token=${props.token}`
|
|
43
|
+
const product = `&product=${props.product}`
|
|
44
|
+
const externalBusinessId = props.externalBusinessId
|
|
45
|
+
? `&external_business_id=${props.externalBusinessId}`
|
|
46
|
+
: ''
|
|
40
47
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
const closeParafinDashboard = ({ data, origin }: MessageEvent) => {
|
|
49
|
+
if (origin === baseUrl && data?.message === 'close-dashboard') {
|
|
50
|
+
props.onExit?.()
|
|
51
|
+
window.removeEventListener('message', closeParafinDashboard)
|
|
52
|
+
iframe.style.opacity = '0'
|
|
53
|
+
setTimeout(() => document.body.removeChild(iframe), 200)
|
|
54
|
+
}
|
|
47
55
|
}
|
|
48
|
-
}
|
|
49
56
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
57
|
+
iframe.src = `${baseUrl}${route}${token}${product}${externalBusinessId}`
|
|
58
|
+
window.addEventListener('message', closeParafinDashboard)
|
|
59
|
+
document.body.appendChild(iframe)
|
|
60
|
+
setTimeout(() => (iframe.style.opacity = '1'), 1)
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('Error loading Parafin dashboard', error)
|
|
63
|
+
}
|
|
64
|
+
}
|
package/out/index.d.ts
CHANGED
package/out/index.js
CHANGED
|
@@ -1,43 +1,52 @@
|
|
|
1
1
|
export const openParafinDashboard = (props) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
iframe.style.left = '0';
|
|
7
|
-
iframe.style.width = '100%';
|
|
8
|
-
iframe.style.height = '100%';
|
|
9
|
-
iframe.style.border = 'none';
|
|
10
|
-
iframe.style.zIndex = '2147483647';
|
|
11
|
-
iframe.style.backgroundColor = '#fff';
|
|
12
|
-
iframe.style.opacity = '0';
|
|
13
|
-
iframe.style.transition = 'opacity 0.2s';
|
|
14
|
-
const getBaseUrl = () => {
|
|
15
|
-
switch (props.environment) {
|
|
16
|
-
case 'local':
|
|
17
|
-
return 'http://localhost:9000';
|
|
18
|
-
case 'development':
|
|
19
|
-
return 'https://app.dev.parafin.com';
|
|
20
|
-
default:
|
|
21
|
-
return 'https://app.parafin.com';
|
|
2
|
+
try {
|
|
3
|
+
const existingParafinDashboard = document.getElementById('parafin-dashboard');
|
|
4
|
+
if (existingParafinDashboard) {
|
|
5
|
+
document.removeChild(existingParafinDashboard);
|
|
22
6
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
7
|
+
const iframe = document.createElement('iframe');
|
|
8
|
+
iframe.id = 'parafin-dashboard';
|
|
9
|
+
iframe.style.position = 'fixed';
|
|
10
|
+
iframe.style.top = '0';
|
|
11
|
+
iframe.style.left = '0';
|
|
12
|
+
iframe.style.width = '100%';
|
|
13
|
+
iframe.style.height = '100%';
|
|
14
|
+
iframe.style.border = 'none';
|
|
15
|
+
iframe.style.zIndex = '2147483647';
|
|
16
|
+
iframe.style.backgroundColor = '#fff';
|
|
17
|
+
iframe.style.opacity = '0';
|
|
18
|
+
iframe.style.transition = 'opacity 0.2s';
|
|
19
|
+
const getBaseUrl = () => {
|
|
20
|
+
switch (props.environment) {
|
|
21
|
+
case 'local':
|
|
22
|
+
return 'http://localhost:9000';
|
|
23
|
+
case 'development':
|
|
24
|
+
return 'https://app.dev.parafin.com';
|
|
25
|
+
default:
|
|
26
|
+
return 'https://app.parafin.com';
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const baseUrl = getBaseUrl();
|
|
30
|
+
const route = props.route ?? '/';
|
|
31
|
+
const token = `?token=${props.token}`;
|
|
32
|
+
const product = `&product=${props.product}`;
|
|
33
|
+
const externalBusinessId = props.externalBusinessId
|
|
34
|
+
? `&external_business_id=${props.externalBusinessId}`
|
|
35
|
+
: '';
|
|
36
|
+
const closeParafinDashboard = ({ data, origin }) => {
|
|
37
|
+
if (origin === baseUrl && data?.message === 'close-dashboard') {
|
|
38
|
+
props.onExit?.();
|
|
39
|
+
window.removeEventListener('message', closeParafinDashboard);
|
|
40
|
+
iframe.style.opacity = '0';
|
|
41
|
+
setTimeout(() => document.body.removeChild(iframe), 200);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
iframe.src = `${baseUrl}${route}${token}${product}${externalBusinessId}`;
|
|
45
|
+
window.addEventListener('message', closeParafinDashboard);
|
|
46
|
+
document.body.appendChild(iframe);
|
|
47
|
+
setTimeout(() => (iframe.style.opacity = '1'), 1);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error('Error loading Parafin dashboard', error);
|
|
51
|
+
}
|
|
43
52
|
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parafin/core",
|
|
3
|
-
"version": "
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "1.0.1",
|
|
5
4
|
"description": "Parafin embedded core",
|
|
6
5
|
"author": "Parafin (https://www.parafin.com)",
|
|
7
|
-
"registry": "https://registry.npmjs.org",
|
|
8
|
-
"files": [
|
|
9
|
-
"index.ts",
|
|
10
|
-
"out"
|
|
11
|
-
],
|
|
12
|
-
"main": "out/index.js",
|
|
13
6
|
"module": "out/index.js",
|
|
14
7
|
"types": "out/index.d.ts",
|
|
15
8
|
"license": "MIT",
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "esnext",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"outDir": "./out",
|
|
11
|
+
"declarationDir": "./out"
|
|
12
|
+
},
|
|
13
|
+
"include": ["./index.ts"]
|
|
14
|
+
}
|