@soyio/soyio-rn-sdk 2.1.0 → 2.2.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/README.md CHANGED
@@ -108,7 +108,7 @@ export default function App() {
108
108
  const options = {
109
109
  uriScheme: "<company custom uri scheme>"
110
110
  customColor: "<custom color>", // Optional
111
- isSandbox: true, // Optional
111
+ isSandbox: false, // Optional
112
112
  };
113
113
 
114
114
  // For initialize a disclosure request
@@ -138,41 +138,37 @@ export default function App() {
138
138
 
139
139
  Note that user and template properties are not specified here because they must be specified when creating the disclosure request beforehand.
140
140
 
141
- ### 2. Signature attempt (coming soon...)
141
+ ### 2. Auth Request
142
142
 
143
- The **`signature_attempt`** is a process where, using a previously created `signature_attempt_id`, a request is initiated in which a user can digitally sign a document. To sign the document, the user must be authenticated. This authentication can occur either through an access key or facial video. It's important to note that for this request, the user must have been previously verified with Soyio.
143
+ The **`auth_request`** is a process where, using a previously created `auth_request_id`, a request is initiated in which a user can authenticate with Soyio. This authentication can occur either through an access key or facial video.
144
144
 
145
145
  ```jsx
146
146
  import { useSoyioAuth } from "@soyio/soyio-rn-sdk";
147
147
 
148
148
  export default function App() {
149
149
  const options = {
150
- companyId: "<company id>", // Starts with 'com_'
151
150
  uriScheme: "<company custom uri scheme>"
152
- userReference: "<company identifier of user>", // Optional
153
151
  customColor: "<custom color>", // Optional
154
- isSandbox: true, // Optional
152
+ isSandbox: false, // Optional
155
153
  };
156
154
 
157
- // For signing documents
158
- const signatureParams = {
159
- signatureTemplateId: "<signature template id>" // Starts with 'st_'
160
- identityId: "<identity id>", // Starts with 'id_'
155
+ const authRequestParams = {
156
+ authRequestId: "<auth request id>" // Starts with 'authreq_'
161
157
  }
162
158
 
163
159
  const onEventChange = (event) => {
164
160
  console.log("Event:", event);
165
161
  };
166
162
 
167
- const { signature } = useSoyioAuth({ options, onEventChange });
163
+ const { authentication } = useSoyioAuth({ options, onEventChange });
168
164
 
169
- const initSignatureAttempt = () => {
170
- signature(signatureParams);
165
+ const initAuthRequest = () => {
166
+ authentication(authRequestParams);
171
167
  };
172
168
 
173
169
  return (
174
170
  <View>
175
- <Button title="Signature Request" onPress={initSignatureAttempt} />
171
+ <Button title="Auth Request" onPress={initAuthRequest} />
176
172
  </View>
177
173
  );
178
174
  }
@@ -180,12 +176,12 @@ export default function App() {
180
176
 
181
177
  The `onEventChange` function can return the following objects:
182
178
 
183
- 1. When disclosure request is successful:
179
+ 1. When a request is successful:
184
180
 
185
181
  ```js
186
182
  {
187
183
  type: "success",
188
- request: "disclosure",
184
+ request: "disclosure" | "authRequest",
189
185
  verificationKind: "validation" | "authentication",
190
186
  userReference: "<company-user-reference>",
191
187
  identityId: "<soyio-identity-id-of-user>",
@@ -196,7 +192,7 @@ The `onEventChange` function can return the following objects:
196
192
 
197
193
  ```js
198
194
  {
199
- type: "open_disclosure";
195
+ type: "open";
200
196
  }
201
197
  ```
202
198
 
@@ -213,8 +209,8 @@ The `onEventChange` function can return the following objects:
213
209
  ```js
214
210
  {
215
211
  type: "error",
216
- request: "disclosure",
217
- error: "DENIED_CAMERA_PERMISSIONS" | "UNEXPECTED_ERROR"
212
+ request: "disclosure" | "authRequest",
213
+ error: "UNEXPECTED_ERROR"
218
214
  }
219
215
  ```
220
216
 
@@ -228,7 +224,7 @@ The `onEventChange` function can return the following objects:
228
224
  - **`customColor`**: (Optional) A hex code string that specifies the base color of the interface
229
225
  - **`isSandbox`**: (Optional) Indicates if the widget should operate in sandbox mode, defaulting to `false`.
230
226
  - **`uriScheme`**: The unique redirect scheme you've set with `npx uri-scheme add ...`, critical for redirect handling in your app.
231
- - **`signatureTemplateId`**: Identifier of template. Specifies the order and quantity of documents to sign. It must start with `'st_'`.
227
+ - **`authRequestId`**: Identifier of auth request obtained when creating the `AuthRequest`. It must start with `'authreq_'`.
232
228
 
233
229
  #### Error types
234
230
 
@@ -1,4 +1,5 @@
1
- import type { DisclosureParams, SoyioWidgetViewPropsType } from './types';
1
+ import type { AuthRequestParams, DisclosureParams, SoyioWidgetViewPropsType } from './types';
2
2
  export declare const useSoyioAuth: ({ options, onEventChange }: SoyioWidgetViewPropsType) => {
3
3
  disclosure: (registerParams: DisclosureParams) => Promise<void>;
4
+ authentication: (authRequestParams: AuthRequestParams) => Promise<void>;
4
5
  };
@@ -76,29 +76,28 @@ var react_1 = require("react");
76
76
  var utils_1 = require("./utils");
77
77
  var useSoyioAuth = function (_a) {
78
78
  var options = _a.options, onEventChange = _a.onEventChange;
79
- var disclosure = (0, react_1.useCallback)(function (registerParams) { return __awaiter(void 0, void 0, void 0, function () {
80
- var disclosureBaseUri, disclosureUri, redirectUrl, webBrowserOptions, disclosureResult, urlParams;
79
+ var handleProcess = (0, react_1.useCallback)(function (baseUri, params) { return __awaiter(void 0, void 0, void 0, function () {
80
+ var uri, redirectUrl, webBrowserOptions, result, urlParams;
81
81
  var _a;
82
82
  return __generator(this, function (_b) {
83
83
  switch (_b.label) {
84
84
  case 0:
85
- disclosureBaseUri = (0, utils_1.getRequestUrl)(options, __assign({ request: 'disclosure' }, registerParams));
86
- disclosureUri = "".concat(disclosureBaseUri, "?").concat((0, utils_1.buildUrlParams)(options, registerParams));
85
+ uri = "".concat(baseUri, "?").concat((0, utils_1.buildUrlParams)(options, params));
87
86
  redirectUrl = (0, utils_1.getRedirectUrl)(options.uriScheme);
88
87
  return [4 /*yield*/, (0, utils_1.getBrowserOptions)()];
89
88
  case 1:
90
89
  webBrowserOptions = _b.sent();
91
90
  if (onEventChange)
92
- onEventChange({ type: 'open_disclosure' });
93
- return [4 /*yield*/, WebBrowser.openAuthSessionAsync(disclosureUri, redirectUrl, webBrowserOptions)];
91
+ onEventChange({ type: 'open' });
92
+ return [4 /*yield*/, WebBrowser.openAuthSessionAsync(uri, redirectUrl, webBrowserOptions)];
94
93
  case 2:
95
- disclosureResult = _b.sent();
94
+ result = _b.sent();
96
95
  if (onEventChange) {
97
96
  // 'success' type means that a redirection was triggered by Soyio,
98
97
  // but doesn't mean that the process was successful
99
- if (disclosureResult.type === 'success') {
100
- urlParams = (0, utils_1.parseUrlResponseParams)(disclosureResult.url);
101
- if ((_a = disclosureResult.url) === null || _a === void 0 ? void 0 : _a.includes('error')) {
98
+ if (result.type === 'success') {
99
+ urlParams = (0, utils_1.parseUrlResponseParams)(result.url);
100
+ if ((_a = result.url) === null || _a === void 0 ? void 0 : _a.includes('error')) {
102
101
  onEventChange(__assign({ type: 'error' }, urlParams));
103
102
  }
104
103
  else {
@@ -106,14 +105,30 @@ var useSoyioAuth = function (_a) {
106
105
  }
107
106
  }
108
107
  else {
109
- onEventChange(disclosureResult);
108
+ onEventChange(result);
110
109
  }
111
110
  }
112
111
  return [2 /*return*/];
113
112
  }
114
113
  });
115
114
  }); }, [options, onEventChange]);
116
- return { disclosure: disclosure };
115
+ var disclosure = (0, react_1.useCallback)(function (registerParams) { return __awaiter(void 0, void 0, void 0, function () {
116
+ var disclosureBaseUri;
117
+ return __generator(this, function (_a) {
118
+ disclosureBaseUri = (0, utils_1.getRequestUrl)(options, __assign({ request: 'disclosure' }, registerParams));
119
+ handleProcess(disclosureBaseUri, registerParams);
120
+ return [2 /*return*/];
121
+ });
122
+ }); }, [options, handleProcess]);
123
+ var authentication = (0, react_1.useCallback)(function (authRequestParams) { return __awaiter(void 0, void 0, void 0, function () {
124
+ var authBaseUri;
125
+ return __generator(this, function (_a) {
126
+ authBaseUri = (0, utils_1.getRequestUrl)(options, __assign({ request: 'authentication' }, authRequestParams));
127
+ handleProcess(authBaseUri, authRequestParams);
128
+ return [2 /*return*/];
129
+ });
130
+ }); }, [options, handleProcess]);
131
+ return { disclosure: disclosure, authentication: authentication };
117
132
  };
118
133
  exports.useSoyioAuth = useSoyioAuth;
119
134
  //# sourceMappingURL=core.jsx.map
@@ -11,6 +11,9 @@ type ExistingDisclosureParams = {
11
11
  userEmail?: never;
12
12
  forceError?: SoyioErrors;
13
13
  };
14
+ export type AuthRequestParams = {
15
+ authRequestId: `authreq_${string}`;
16
+ };
14
17
  export type SoyioWidgetParams = {
15
18
  companyId?: string;
16
19
  userReference?: string;
@@ -20,10 +23,6 @@ export type SoyioWidgetParams = {
20
23
  developmentUrl?: string;
21
24
  };
22
25
  export type DisclosureParams = NewDisclosureParams | ExistingDisclosureParams;
23
- export type SignatureParams = {
24
- signatureTemplateId: string;
25
- identityId: string;
26
- };
27
26
  export type SoyioWidgetViewPropsType = {
28
27
  options: SoyioWidgetParams;
29
28
  onEventChange?: (event: {
@@ -1,16 +1,16 @@
1
1
  import * as WebBrowser from 'expo-web-browser';
2
- import { DisclosureParams, SignatureParams, SoyioWidgetParams } from './types';
2
+ import { AuthRequestParams, DisclosureParams, SoyioWidgetParams } from './types';
3
3
  type RequestUrlParams = {
4
4
  request: 'disclosure';
5
5
  } & DisclosureParams | {
6
- request: 'signature';
7
- } & SignatureParams;
6
+ request: 'authentication';
7
+ } & AuthRequestParams;
8
8
  export declare function getRequestUrl(options: SoyioWidgetParams, params: RequestUrlParams): string;
9
- export declare function buildUrlParams(widgetParams: SoyioWidgetParams, requestParams: DisclosureParams): string;
9
+ export declare function buildUrlParams(widgetParams: SoyioWidgetParams, requestParams: DisclosureParams | AuthRequestParams): string;
10
10
  export declare function getBrowserOptions(): Promise<WebBrowser.AuthSessionOpenOptions>;
11
11
  export declare function getRedirectUrl(scheme: string): string;
12
12
  type ParsedUrlParameters = {
13
- request: 'data_access' | 'signature';
13
+ request: 'disclosure' | 'authentication';
14
14
  [key: string]: string;
15
15
  };
16
16
  export declare function parseUrlResponseParams(url: string): ParsedUrlParameters;
@@ -91,9 +91,9 @@ function buildUrlParams(widgetParams, requestParams) {
91
91
  var baseParams = {
92
92
  sdk: "rn".concat(sdkSuffix),
93
93
  uriScheme: widgetParams.uriScheme,
94
+ customColor: widgetParams.customColor,
94
95
  companyId: widgetParams.companyId,
95
96
  userReference: widgetParams.userReference,
96
- customColor: widgetParams.customColor,
97
97
  };
98
98
  var allParams = __assign(__assign({}, baseParams), requestParams);
99
99
  var queryParams = Object.entries(allParams)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soyio/soyio-rn-sdk",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "license": "MIT",
5
5
  "author": "Ignacio Méndez",
6
6
  "main": "./package/index.js",