@soyio/soyio-rn-sdk 1.0.4 → 1.0.5

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
@@ -71,11 +71,17 @@ export default function App() {
71
71
  identityId: "<identity id>", // Starts with 'id_'
72
72
  };
73
73
 
74
+ // For signing documents (coming soon...)
75
+ const signatureParams = {
76
+ signatureTemplateId: "<signature template id>" // Starts with 'st_'
77
+ identityId: "<identity id>", // Starts with 'id_'
78
+ }
79
+
74
80
  const onEventChange = (event) => {
75
81
  console.log("Event:", event);
76
82
  };
77
83
 
78
- const { register, authenticate } = useSoyioAuth({ options, onEventChange });
84
+ const { register, authenticate, signature } = useSoyioAuth({ options, onEventChange });
79
85
 
80
86
  const registerNewIdentity = () => {
81
87
  register(registerParams);
@@ -85,10 +91,15 @@ export default function App() {
85
91
  authenticate(authenticateParams);
86
92
  };
87
93
 
94
+ const signDocuments = () => {
95
+ signature(authenticateParams);
96
+ };
97
+
88
98
  return (
89
99
  <View>
90
100
  <Button title="Register new user" onPress={registerNewIdentity} />
91
101
  <Button title="Authenticate identity" onPress={authenticateIdentity} />
102
+ <Button title="Sign Documents" onPress={signDocuments} />
92
103
  </View>
93
104
  );
94
105
  }
@@ -128,6 +139,7 @@ The `onEventChange` function returns an object with the following properties:
128
139
  - **`customColor`**: (Optional) A hex code string that specifies the base color of the interface during either the authentication or registration flow.
129
140
  - **`isSandbox`**: (Optional) Indicates if the widget should operate in sandbox mode, defaulting to `false`.
130
141
  - **`uriScheme`**: The unique redirect scheme you've set with `npx uri-scheme add ...`, critical for redirect handling in your app.
142
+ - **`signatureTemplateId`**: Identifier of template. Specifies the order and quantity of documents to sign. It must start with `'st_'`.
131
143
 
132
144
  #### Error types
133
145
 
@@ -1,5 +1,6 @@
1
- import type { AuthenticateParams, RegisterParams, SoyioWidgetViewPropsType } from './types';
1
+ import type { AuthenticateParams, RegisterParams, SignatureParams, SoyioWidgetViewPropsType } from './types';
2
2
  export declare const useSoyioAuth: ({ options, onEventChange }: SoyioWidgetViewPropsType) => {
3
3
  register: (registerParams: RegisterParams) => Promise<void>;
4
4
  authenticate: (authenticateParams: AuthenticateParams) => Promise<void>;
5
+ signature: (signatureParams: SignatureParams) => Promise<void>;
5
6
  };
@@ -115,7 +115,35 @@ var useSoyioAuth = function (_a) {
115
115
  }
116
116
  });
117
117
  }); }, [options, onEventChange]);
118
- return { register: register, authenticate: authenticate };
118
+ var signature = (0, react_1.useCallback)(function (signatureParams) { return __awaiter(void 0, void 0, void 0, function () {
119
+ var signatureBaseUri, signatureUri, redirectUrl, webBrowserOptions, signatureResult, errorMessage;
120
+ var _a;
121
+ return __generator(this, function (_b) {
122
+ switch (_b.label) {
123
+ case 0:
124
+ signatureBaseUri = (0, utils_1.getFlowUrl)(options, 'signature');
125
+ signatureUri = "".concat(signatureBaseUri, "?").concat((0, utils_1.buildUrlParams)(options, signatureParams));
126
+ redirectUrl = (0, utils_1.getRedirectUrl)(options.uriScheme);
127
+ return [4 /*yield*/, (0, utils_1.getBrowserOptions)()];
128
+ case 1:
129
+ webBrowserOptions = _b.sent();
130
+ if (onEventChange)
131
+ onEventChange({ type: 'open signature' });
132
+ return [4 /*yield*/, WebBrowser.openAuthSessionAsync(signatureUri, redirectUrl, webBrowserOptions)];
133
+ case 2:
134
+ signatureResult = _b.sent();
135
+ if ((signatureResult.type === 'success') && ((_a = signatureResult.url) === null || _a === void 0 ? void 0 : _a.includes('error'))) {
136
+ errorMessage = signatureResult.url.match(utils_1.ERROR_URL_REGEX)[1];
137
+ if (onEventChange)
138
+ onEventChange({ type: 'error', message: errorMessage });
139
+ }
140
+ else if (onEventChange)
141
+ onEventChange(signatureResult);
142
+ return [2 /*return*/];
143
+ }
144
+ });
145
+ }); }, [options, onEventChange]);
146
+ return { register: register, authenticate: authenticate, signature: signature };
119
147
  };
120
148
  exports.useSoyioAuth = useSoyioAuth;
121
149
  //# sourceMappingURL=core.jsx.map
@@ -15,6 +15,10 @@ export type RegisterParams = {
15
15
  export type AuthenticateParams = {
16
16
  identityId: string;
17
17
  };
18
+ export type SignatureParams = {
19
+ signatureTemplateId: string;
20
+ identityId: string;
21
+ };
18
22
  export type SoyioWidgetViewPropsType = {
19
23
  options: SoyioWidgetParams;
20
24
  onEventChange?: (event: {
@@ -1,6 +1,6 @@
1
1
  import * as WebBrowser from 'expo-web-browser';
2
2
  import { AuthenticateParams, RegisterParams, SoyioWidgetParams } from './types';
3
- export declare function getFlowUrl(options: SoyioWidgetParams, flow: 'authenticate' | 'register'): string;
3
+ export declare function getFlowUrl(options: SoyioWidgetParams, flow: 'authenticate' | 'register' | 'signature'): string;
4
4
  export declare function buildUrlParams(widgetParams: SoyioWidgetParams, flowParams: RegisterParams | AuthenticateParams): string;
5
5
  export declare function getBrowserOptions(): Promise<WebBrowser.AuthSessionOpenOptions>;
6
6
  export declare function getRedirectUrl(scheme: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soyio/soyio-rn-sdk",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "license": "MIT",
5
5
  "author": "Ignacio Méndez",
6
6
  "main": "./package/index.js",