@frankieone/one-sdk 1.7.14-rc.1 → 1.7.14-rc.3

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.
Files changed (42) hide show
  1. package/dist/cli/cli.js +25 -3
  2. package/dist/cli/darwin-amd64/onesdk-cli +0 -0
  3. package/dist/cli/darwin-arm64/onesdk-cli +0 -0
  4. package/dist/cli/linux-amd64/onesdk-cli +0 -0
  5. package/dist/cli/linux-arm64/onesdk-cli +0 -0
  6. package/dist/cli/templateGenerator.js +25 -0
  7. package/dist/cli/windows-amd64/onesdk-cli.exe +0 -0
  8. package/dist/commit.txt +1 -1
  9. package/dist/esm/modules/cli/template/templateIdv.d.ts.map +1 -1
  10. package/dist/esm/modules/cli/template/templateIdv.js +94 -53
  11. package/dist/esm/modules/cli/template/templateIdv.js.map +1 -1
  12. package/dist/esm/modules/cli/template/templateIdvReview.d.ts.map +1 -1
  13. package/dist/esm/modules/cli/template/templateIdvReview.js +127 -85
  14. package/dist/esm/modules/cli/template/templateIdvReview.js.map +1 -1
  15. package/dist/esm/modules/cli/template/templateManualKyc.d.ts.map +1 -1
  16. package/dist/esm/modules/cli/template/templateManualKyc.js +211 -169
  17. package/dist/esm/modules/cli/template/templateManualKyc.js.map +1 -1
  18. package/dist/esm/modules/frankie-client/clients/DocumentClient.d.ts +5 -0
  19. package/dist/esm/modules/frankie-client/clients/DocumentClient.d.ts.map +1 -0
  20. package/dist/esm/modules/frankie-client/clients/DocumentClient.js +18 -0
  21. package/dist/esm/modules/frankie-client/clients/DocumentClient.js.map +1 -0
  22. package/dist/esm/modules/frankie-client/clients/F2/DocumentClientF2.d.ts +5 -0
  23. package/dist/esm/modules/frankie-client/clients/F2/DocumentClientF2.d.ts.map +1 -0
  24. package/dist/esm/modules/frankie-client/clients/F2/DocumentClientF2.js +18 -0
  25. package/dist/esm/modules/frankie-client/clients/F2/DocumentClientF2.js.map +1 -0
  26. package/dist/esm/modules/idv/vendors/Sumsub/index.d.ts.map +1 -1
  27. package/dist/esm/modules/idv/vendors/Sumsub/index.js +24 -11
  28. package/dist/esm/modules/idv/vendors/Sumsub/index.js.map +1 -1
  29. package/dist/esm/modules/individual/F2/index.d.ts.map +1 -1
  30. package/dist/esm/modules/individual/F2/index.js +11 -4
  31. package/dist/esm/modules/individual/F2/index.js.map +1 -1
  32. package/dist/esm/modules/individual/actions/documents.d.ts +5 -0
  33. package/dist/esm/modules/individual/actions/documents.d.ts.map +1 -1
  34. package/dist/esm/modules/individual/actions/documents.js +15 -0
  35. package/dist/esm/modules/individual/actions/documents.js.map +1 -1
  36. package/dist/esm/modules/individual/definition.d.ts +2 -0
  37. package/dist/esm/modules/individual/definition.d.ts.map +1 -1
  38. package/dist/esm/modules/individual/index.d.ts.map +1 -1
  39. package/dist/esm/modules/individual/index.js +11 -4
  40. package/dist/esm/modules/individual/index.js.map +1 -1
  41. package/dist/esm/modules/meta.json +1 -1
  42. package/package.json +1 -1
package/dist/cli/cli.js CHANGED
@@ -3,6 +3,8 @@
3
3
  /* eslint-disable no-undef */
4
4
  /* eslint-disable no-console */
5
5
  import { spawnSync, spawn } from 'node:child_process';
6
+ import fs from 'node:fs';
7
+ import path from 'node:path';
6
8
  import os from 'os';
7
9
 
8
10
  const executableName = 'onesdk-cli';
@@ -10,16 +12,19 @@ const executableName = 'onesdk-cli';
10
12
  const installationPath = () => {
11
13
  const errorMsg = 'Failed to find executable path.';
12
14
 
13
- const whichCmd = spawnSync('which', [executableName]);
15
+ // First, check the 'npm' executable path. with this we can resolve whether
16
+ // user using some kind of nvm or fnm or any other node version manager.
17
+ const whichCmd = spawnSync('which', ['npm']);
14
18
  if (whichCmd.error) {
15
19
  console.error(errorMsg, whichCmd.error);
16
20
  process.exit(1);
17
21
  }
18
22
  const whichOutput = whichCmd.stdout.toString().trim();
19
23
 
24
+ // Replace the 'npm' executable path with the 'onesdk-cli' executable path.
20
25
  const sedCmd = spawnSync(
21
26
  'sed',
22
- ['-e', 's|bin/onesdk-cli|lib/node_modules/@frankieone/one-sdk/dist/cli|'],
27
+ ['-e', 's|bin/npm|lib/node_modules/@frankieone/one-sdk/dist/cli|'],
23
28
  { input: whichOutput },
24
29
  );
25
30
 
@@ -28,7 +33,24 @@ const installationPath = () => {
28
33
  process.exit(1);
29
34
  }
30
35
 
31
- return sedCmd.stdout.toString().trim();
36
+ // Check if the resolved path exists.
37
+ const resolvedPath = sedCmd.stdout.toString().trim();
38
+ if (resolvedPath && fs.existsSync(resolvedPath)) {
39
+ return resolvedPath;
40
+ }
41
+
42
+ // Fallback for npx and local installations
43
+ const npxPath = path.resolve(
44
+ process.cwd(),
45
+ 'node_modules/@frankieone/one-sdk/dist/cli',
46
+ );
47
+
48
+ if (fs.existsSync(npxPath)) {
49
+ return npxPath;
50
+ }
51
+
52
+ console.error(errorMsg, 'Executable not found');
53
+ process.exit(1);
32
54
  };
33
55
 
34
56
  const darwinExecutable = (basePath) => {
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+
3
+ /* eslint-disable no-undef */
4
+ /* eslint-disable no-console */
5
+
6
+ (async () => {
7
+ try {
8
+ const isDev = process.env.CLI_MODE === 'dev';
9
+ const modulePath = isDev
10
+ ? '../modules/cli/index.js'
11
+ : '../esm/modules/cli/index.js';
12
+
13
+ const templateModule = await import(modulePath);
14
+ const generateOneSdkFlow = templateModule.default;
15
+
16
+ if (typeof generateOneSdkFlow !== 'function') {
17
+ throw new Error('generateOneSdkFlow is not a function');
18
+ }
19
+
20
+ const flowId = process.argv[2];
21
+ process.stdout.write(generateOneSdkFlow(flowId));
22
+ } catch (error) {
23
+ console.error('Error loading module:', error);
24
+ }
25
+ })();
package/dist/commit.txt CHANGED
@@ -1 +1 @@
1
- 573196d577117cb682e1a718a342076ff63cbadc
1
+ ef2b97b9e8b4480c0f4133b451d81c7ffad22a65
@@ -1 +1 @@
1
- {"version":3,"file":"templateIdv.d.ts","sourceRoot":"","sources":["../../../../../modules/cli/template/templateIdv.js"],"names":[],"mappings":"AAEA,iCA8DS"}
1
+ {"version":3,"file":"templateIdv.d.ts","sourceRoot":"","sources":["../../../../../modules/cli/template/templateIdv.js"],"names":[],"mappings":"AAEA,iCAuGW"}
@@ -1,65 +1,106 @@
1
1
  const html = String.raw;
2
- export const templateIdv = html `<html lang="en">
3
- <head>
4
- <!-- UTF-8 encoding you page is important as some text in the smart UI might not come out as you expect -->
5
- <meta charset="utf-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>oneSdk onboarding</title>
8
- <script src="https://assets.frankiefinancial.io/one-sdk/v1/oneSdk.umd.js"></script>
2
+ export const templateIdv = html `<!-- Generated by OneSDK CLI -->
3
+ <!-- More information: https://docs.frankieone.com/v1.14.1/docs/about-onesdk -->
9
4
 
10
- <script>
11
- async function startOneSdk() {
12
- const oneSdk = await OneSdk({
13
- session: {
14
- token: GENERATED_TOKEN,
15
- },
16
- mode: 'production',
17
- recipe: {
18
- form: {
19
- provider: {
20
- name: 'react',
5
+ <!doctype html>
6
+ <html lang="en">
7
+ <head>
8
+ <!-- UTF-8 encoding you page is important as some text in the smart UI might not come out as you expect -->
9
+ <meta charset="utf-8" />
10
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
11
+ <title>OneSDK - IDV</title>
12
+
13
+ <!-- NOTE: You can change the version of OneSDK to the desired version here -->
14
+ <script src="https://assets.frankiefinancial.io/one-sdk/v1/oneSdk.umd.js"></script>
15
+
16
+ <script>
17
+ async function getToken() {
18
+ // WARNING: This is for testing purposes only
19
+ // use server-side code to request the token in production for security reasons
20
+
21
+ const customerId = '<CUSTOMER_ID_HERE>';
22
+ const customerChildId = '<CUSTOMER_CHILD_ID_HERE>';
23
+ const apiKey = '<API_KEY_HERE>';
24
+ const authKey = btoa(
25
+ customerId + ':' + customerChildId + ':' + apiKey,
26
+ );
27
+
28
+ const tokenResponse = await fetch(
29
+ BACKEND_URL[env] + '/auth/v2/machine-session',
30
+ {
31
+ method: 'POST',
32
+ headers: {
33
+ authorization: 'machine ' + authKey,
34
+ 'Content-Type': 'application/json',
35
+ },
36
+ body: JSON.stringify({
37
+ permissions: {
38
+ preset: 'one-sdk',
39
+ reference: '<CUSTOMER_REFERENCE_HERE>',
40
+ },
41
+ }),
42
+ },
43
+ );
44
+
45
+ return await tokenResponse.json();
46
+ }
47
+
48
+ async function startOneSdk() {
49
+ const sessionToken = await getToken();
50
+
51
+ const oneSdk = await OneSdk({
52
+ session: {
53
+ token: sessionToken,
54
+ },
55
+ mode: 'production',
56
+ recipe: {
57
+ form: {
58
+ provider: {
59
+ name: 'react',
60
+ // NOTE: This is for the autocomplete feature in the form
61
+ // googleApiKey: "<GOOGLE_API_KEY>",
62
+ },
21
63
  },
22
64
  },
23
- },
24
- });
65
+ });
25
66
 
26
- const idv = oneSdk.flow('idv');
67
+ const idv = oneSdk.flow('idv');
27
68
 
28
- idv.mount('#idv-el');
29
- idv.on('loading', () => {
30
- console.log('loading');
31
- });
69
+ idv.mount('#idv-el');
70
+ idv.on('loading', () => {
71
+ console.log('loading');
72
+ });
32
73
 
33
- idv.on('results', async ({ checkStatus, document, entityId }) => {
34
- if (checkStatus) {
35
- console.log('results succesful');
36
- } else {
37
- console.log('no data returned');
38
- }
39
- });
74
+ idv.on('results', async ({ checkStatus, document, entityId }) => {
75
+ if (checkStatus) {
76
+ console.log('results succesful');
77
+ } else {
78
+ console.log('no data returned');
79
+ }
80
+ });
40
81
 
41
- idv.on('error', ({ message, payload }) => {
42
- console.log('received error');
43
- console.log(message, payload);
44
- });
82
+ idv.on('error', ({ message, payload }) => {
83
+ console.log('received error');
84
+ console.log(message, payload);
85
+ });
45
86
 
46
- idv.on('detection_complete', (message) => {
47
- console.log('capture finished');
48
- console.log(message);
49
- });
87
+ idv.on('detection_complete', (message) => {
88
+ console.log('capture finished');
89
+ console.log(message);
90
+ });
50
91
 
51
- idv.on('*', (message) => {
52
- console.log(message);
53
- });
54
- }
55
- </script>
56
- </head>
92
+ idv.on('*', (message) => {
93
+ console.log(message);
94
+ });
95
+ }
96
+ </script>
97
+ </head>
57
98
 
58
- <body style="background-color: white" onload="startOneSdk()">
59
- <div
60
- id="idv-el"
61
- style="top: 0; left: 0; width: 100%; height: 100%; display: block"
62
- ></div>
63
- </body>
64
- </html>`;
99
+ <body style="background-color: white" onload="startOneSdk()">
100
+ <div
101
+ id="idv-el"
102
+ style="top: 0; left: 0; width: 100%; height: 100%; display: block"
103
+ ></div>
104
+ </body>
105
+ </html>`;
65
106
  //# sourceMappingURL=templateIdv.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templateIdv.js","sourceRoot":"","sources":["../../../../../modules/cli/template/templateIdv.js"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8DvB,CAAC"}
1
+ {"version":3,"file":"templateIdv.js","sourceRoot":"","sources":["../../../../../modules/cli/template/templateIdv.js"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC;AAExB,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAuGrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"templateIdvReview.d.ts","sourceRoot":"","sources":["../../../../../modules/cli/template/templateIdvReview.js"],"names":[],"mappings":"AAEA,uCAgGS"}
1
+ {"version":3,"file":"templateIdvReview.d.ts","sourceRoot":"","sources":["../../../../../modules/cli/template/templateIdvReview.js"],"names":[],"mappings":"AAEA,uCA0IW"}
@@ -1,99 +1,141 @@
1
1
  const html = String.raw;
2
- export const templateIdvReview = html `<html lang="en">
3
- <head>
4
- <!-- UTF-8 encoding you page is important as some text in the smart UI might not come out as you expect -->
5
- <meta charset="utf-8" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
- <title>oneSdk onboarding</title>
8
- <script src="https://assets.frankiefinancial.io/one-sdk/v1/oneSdk.umd.js"></script>
2
+ export const templateIdvReview = html `<!-- Generated by OneSDK CLI -->
3
+ <!-- More information: https://docs.frankieone.com/v1.14.1/docs/about-onesdk -->
9
4
 
10
- <script>
11
- async function startOneSdk() {
12
- const oneSdk = await OneSdk({
13
- session: {
14
- token: GENERATED_TOKEN,
15
- },
16
- mode: 'production',
17
- recipe: {
18
- form: {
19
- provider: {
20
- name: 'react',
5
+ <!doctype html>
6
+ <html lang="en">
7
+ <head>
8
+ <!-- UTF-8 encoding you page is important as some text in the smart UI might not come out as you expect -->
9
+ <meta charset="utf-8" />
10
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
11
+ <title>OneSDK - IDV+Review</title>
12
+
13
+ <!-- NOTE: You can change the version of OneSDK to the desired version here -->
14
+ <script src="https://assets.frankiefinancial.io/one-sdk/v1/oneSdk.umd.js"></script>
15
+
16
+ <script>
17
+ async function getToken() {
18
+ // WARNING: This is for testing purposes only
19
+ // use server-side code to request the token in production for security reasons
20
+
21
+ const customerId = '<CUSTOMER_ID_HERE>';
22
+ const customerChildId = '<CUSTOMER_CHILD_ID_HERE>';
23
+ const apiKey = '<API_KEY_HERE>';
24
+ const authKey = btoa(
25
+ customerId + ':' + customerChildId + ':' + apiKey,
26
+ );
27
+
28
+ const tokenResponse = await fetch(
29
+ BACKEND_URL[env] + '/auth/v2/machine-session',
30
+ {
31
+ method: 'POST',
32
+ headers: {
33
+ authorization: 'machine ' + authKey,
34
+ 'Content-Type': 'application/json',
21
35
  },
36
+ body: JSON.stringify({
37
+ permissions: {
38
+ preset: 'one-sdk',
39
+ // NOTE: Replace this with your customer reference
40
+ reference: '<CUSTOMER_REFERENCE_HERE>',
41
+ },
42
+ }),
22
43
  },
23
- },
24
- });
44
+ );
25
45
 
26
- const idv = oneSdk.flow('idv');
27
- const loading1 = oneSdk.component('form', {
28
- name: 'LOADING',
29
- title: { label: 'Loading...' },
30
- descriptions: [{ label: '' }],
31
- });
32
- const loading2 = oneSdk.component('form', {
33
- name: 'LOADING',
34
- title: { label: 'Processing results...' },
35
- descriptions: [
36
- {
37
- label:
38
- "Hold tight, this can take up to 30 seconds. Please do not refresh this page or click the 'back' button on your browser.",
46
+ return await tokenResponse.json();
47
+ }
48
+
49
+ async function startOneSdk() {
50
+ const sessionToken = await getToken();
51
+
52
+ const oneSdk = await OneSdk({
53
+ session: {
54
+ token: sessionToken,
55
+ },
56
+ mode: 'production',
57
+ recipe: {
58
+ form: {
59
+ provider: {
60
+ name: 'react',
61
+ // NOTE: This is for the autocomplete feature in the form
62
+ // googleApiKey: "<GOOGLE_API_KEY>",
63
+ },
64
+ },
39
65
  },
40
- ],
41
- });
42
- const review = oneSdk.component('form', {
43
- name: 'REVIEW',
44
- type: 'ocr',
45
- });
66
+ });
46
67
 
47
- idv.mount('#idv-el');
48
- let before = true;
49
- idv.on('loading', (display) => {
50
- if (display) {
51
- if (before) {
52
- loading1.mount('#loading1');
53
- }
54
- } else {
55
- if (before) {
56
- loading1.unmount();
68
+ const idv = oneSdk.flow('idv');
69
+ const loading1 = oneSdk.component('form', {
70
+ name: 'LOADING',
71
+ title: { label: 'Loading...' },
72
+ descriptions: [{ label: '' }],
73
+ });
74
+ const loading2 = oneSdk.component('form', {
75
+ name: 'LOADING',
76
+ title: { label: 'Processing results...' },
77
+ descriptions: [
78
+ {
79
+ label:
80
+ "Hold tight, this can take up to 30 seconds. Please do not refresh this page or click the 'back' button on your browser.",
81
+ },
82
+ ],
83
+ });
84
+ const review = oneSdk.component('form', {
85
+ name: 'REVIEW',
86
+ type: 'ocr',
87
+ });
88
+
89
+ idv.mount('#idv-el');
90
+ let before = true;
91
+ idv.on('loading', (display) => {
92
+ if (display) {
93
+ if (before) {
94
+ loading1.mount('#loading1');
95
+ }
96
+ } else {
97
+ if (before) {
98
+ loading1.unmount();
99
+ }
100
+ before = false;
57
101
  }
58
- before = false;
59
- }
60
- console.log(before);
61
- console.log(display);
62
- });
102
+ console.log(before);
103
+ console.log(display);
104
+ });
63
105
 
64
- idv.on('results', async ({ checkStatus, document, entityId }) => {
65
- if (checkStatus) {
66
- console.log('results succesful');
67
- loading2.unmount();
68
- review.mount('#idv-el');
69
- } else {
70
- console.log('no data returned');
71
- }
72
- });
106
+ idv.on('results', async ({ checkStatus, document, entityId }) => {
107
+ if (checkStatus) {
108
+ console.log('results succesful');
109
+ loading2.unmount();
110
+ review.mount('#idv-el');
111
+ } else {
112
+ console.log('no data returned');
113
+ }
114
+ });
73
115
 
74
- idv.on('error', ({ message, payload }) => {
75
- console.log('received error');
76
- console.log(message, payload);
77
- });
116
+ idv.on('error', ({ message, payload }) => {
117
+ console.log('received error');
118
+ console.log(message, payload);
119
+ });
78
120
 
79
- idv.on('detection_complete', (message) => {
80
- console.log('capture finished');
81
- console.log(message);
82
- loading2.mount('#loading2');
83
- });
121
+ idv.on('detection_complete', (message) => {
122
+ console.log('capture finished');
123
+ console.log(message);
124
+ loading2.mount('#loading2');
125
+ });
84
126
 
85
- idv.on('*', (message) => {
86
- console.log(message);
87
- });
88
- }
89
- </script>
90
- </head>
127
+ idv.on('*', (message) => {
128
+ console.log(message);
129
+ });
130
+ }
131
+ </script>
132
+ </head>
91
133
 
92
- <body style="background-color: white" onload="startOneSdk()">
93
- <div
94
- id="idv-el"
95
- style="top: 0; left: 0; width: 100%; height: 100%; display: block"
96
- ></div>
97
- </body>
98
- </html>`;
134
+ <body style="background-color: white" onload="startOneSdk()">
135
+ <div
136
+ id="idv-el"
137
+ style="top: 0; left: 0; width: 100%; height: 100%; display: block"
138
+ ></div>
139
+ </body>
140
+ </html>`;
99
141
  //# sourceMappingURL=templateIdvReview.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templateIdvReview.js","sourceRoot":"","sources":["../../../../../modules/cli/template/templateIdvReview.js"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAgG7B,CAAC"}
1
+ {"version":3,"file":"templateIdvReview.js","sourceRoot":"","sources":["../../../../../modules/cli/template/templateIdvReview.js"],"names":[],"mappings":"AAAA,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA0I3B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"templateManualKyc.d.ts","sourceRoot":"","sources":["../../../../../modules/cli/template/templateManualKyc.js"],"names":[],"mappings":"AAEA,uCA2KS"}
1
+ {"version":3,"file":"templateManualKyc.d.ts","sourceRoot":"","sources":["../../../../../modules/cli/template/templateManualKyc.js"],"names":[],"mappings":"AAEA,uCAqNW"}