@soyio/soyio-rn-sdk 0.2.15 → 1.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/README.md +34 -14
- package/{src/main.ts → index.ts} +2 -2
- package/package/index.d.ts +2 -0
- package/package/index.js +6 -0
- package/{dist/src/lib → package/src}/constants.d.ts +0 -2
- package/package/src/constants.js +6 -0
- package/{dist/src/lib → package/src}/core.d.ts +1 -2
- package/package/src/core.jsx +115 -0
- package/{dist → package}/src/types.d.ts +3 -2
- package/package/src/types.js +3 -0
- package/package/src/utils.d.ts +6 -0
- package/package/src/utils.js +133 -0
- package/package.json +30 -46
- package/.eslintignore +0 -2
- package/.eslintrc.js +0 -46
- package/.github/actions/setup/action.yml +0 -27
- package/.node-version +0 -1
- package/app.json +0 -13
- package/dist/main.es.js +0 -261
- package/dist/main.es.js.map +0 -1
- package/dist/main.umd.js +0 -2
- package/dist/main.umd.js.map +0 -1
- package/dist/src/lib/constants.d.ts.map +0 -1
- package/dist/src/lib/core.d.ts.map +0 -1
- package/dist/src/lib/utils.d.ts +0 -4
- package/dist/src/lib/utils.d.ts.map +0 -1
- package/dist/src/main.d.ts +0 -3
- package/dist/src/main.d.ts.map +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/vite.config.d.ts +0 -3
- package/dist/vite.config.d.ts.map +0 -1
- package/scripts/bump.sh +0 -26
- package/src/lib/constants.ts +0 -3
- package/src/lib/core.tsx +0 -45
- package/src/lib/utils.ts +0 -25
- package/src/types.ts +0 -20
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -34
- package/tsconfig.node.json +0 -8
- package/vite.config.ts +0 -27
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
|
-
Install using npm! (or your favorite package manager)
|
|
17
|
+
- Install using npm! (or your favorite package manager)
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
20
|
# Using npm
|
|
@@ -24,13 +24,19 @@ npm install @soyio/soyio-rn-sdk
|
|
|
24
24
|
yarn add @soyio/soyio-rn-sdk
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
For developers working with a bare React Native application, it is essential to include Expo modules to ensure full compatibility and functionality of the Soyio SDK. To install Expo modules, run the following command in your project directory:
|
|
27
|
+
- Add custom uri scheme to your project:
|
|
29
28
|
|
|
30
29
|
```bash
|
|
31
|
-
npx
|
|
30
|
+
npx uri-scheme add custom-uri-scheme
|
|
32
31
|
```
|
|
33
32
|
|
|
33
|
+
Here, `custom-uri-scheme` is a unique scheme used for redirecting within Android applications, ensuring links open in the correct app without prompting the user to choose. It should be structured uniquely for your application. For example, for a company with name `Test`, a custom uri scheme could be `soyio-test` or simply `test`.
|
|
34
|
+
|
|
35
|
+
**IMPORTANT:**
|
|
36
|
+
For developers integrating with a **bare React Native** application, it's crucial to prepare your project for Expo modules:
|
|
37
|
+
|
|
38
|
+
`npx install-expo-modules`: This command installs Expo modules in your React Native project, allowing you to use Expo's powerful library of APIs and components without needing to eject from the Expo managed workflow.
|
|
39
|
+
|
|
34
40
|
## Usage
|
|
35
41
|
|
|
36
42
|
`Soyio React Native` exports a single hook called `useSoyioAuth`. This is a hook that opens a `WebBrowser` using the `openAuthSessionAsync` method by [expo](https://docs.expo.dev/versions/latest/sdk/webbrowser/#webbrowseropenauthsessionasyncurl-redirecturl-options).
|
|
@@ -46,8 +52,9 @@ After retrieving the `useSoyioAuth` hook, you are ready to instantiate the widge
|
|
|
46
52
|
```jsx
|
|
47
53
|
export default function App() {
|
|
48
54
|
const options = {
|
|
49
|
-
userReference: "<company identifier of user>", // OPTIONAL
|
|
50
55
|
companyId: "<company id>", // Starts with 'com_'
|
|
56
|
+
uriScheme: "<company custom uri scheme>"
|
|
57
|
+
userReference: "<company identifier of user>", // OPTIONAL
|
|
51
58
|
isSandbox: true, // Optional. Default is false
|
|
52
59
|
};
|
|
53
60
|
|
|
@@ -55,6 +62,7 @@ export default function App() {
|
|
|
55
62
|
const registerParams = {
|
|
56
63
|
flowTemplateId: "<flow template id>", // Starts with 'vft_'
|
|
57
64
|
userEmail: "<user email>", // OPTIONAL
|
|
65
|
+
forceError: 'no_error', // OPTIONAL
|
|
58
66
|
};
|
|
59
67
|
|
|
60
68
|
// For authenticate existing identity
|
|
@@ -93,27 +101,39 @@ The `onEventChange` function returns an object with the following properties:
|
|
|
93
101
|
|
|
94
102
|
- `"open register"`: Triggered when the user initiates the `register` method.
|
|
95
103
|
- `"open authenticate"`: Triggered when the user initiates the `authenticate` method.
|
|
96
|
-
- `"
|
|
104
|
+
- `"dismiss"`: Triggered when the user closes the `WebBrowser`.
|
|
97
105
|
- `"success"`: Triggered when the authentication flow is successfully completed.
|
|
98
106
|
|
|
99
107
|
- `url` (optional): URL associated only with the `success` event.
|
|
100
108
|
|
|
101
|
-
- For registration: `"
|
|
102
|
-
- For authentication: `"
|
|
109
|
+
- For registration: `"<uriScheme>://registered?userReference=<company user reference>&id=<identity_id>"`
|
|
110
|
+
- For authentication: `"<uriScheme>://authenticated?userReference=<company user reference>&id=<identity_id>"`
|
|
103
111
|
|
|
104
112
|
where `<identity_id>` is the unique identifier of the newly registered or authenticated user, respectively.
|
|
105
113
|
|
|
106
|
-
|
|
114
|
+
#### Attribute Descriptions
|
|
115
|
+
|
|
116
|
+
- **`companyId`**: The unique identifier for the company, must start with `'com_'`.
|
|
117
|
+
- **`userReference`**: (Optional) A reference identifier provided by the company for the user engaging with the widget. This identifier is used in events (`onEvent` and `webhooks`) to inform the company which user the events are associated with.
|
|
118
|
+
- **`userEmail`**: The user's email address. This field is optional when the flow is `'register'`, where if not provided, Soyio will prompt the user to enter their email. However, for the `'authenticate'` flow, this field should not be provided.
|
|
119
|
+
- **`flowTemplateId`**: Required only in the `'register'` flow, this identifier specifies the order and quantity of documents requested from the user. It must start with `'vft_'`.
|
|
120
|
+
- **`identityId`**: Necessary only in the `'authenticate'` flow, this identifier must start with `'id_'` and signifies the user's identity.
|
|
121
|
+
- **`isSandbox`**: (Optional) Indicates if the widget should operate in sandbox mode, defaulting to `false`.
|
|
122
|
+
- **`uriScheme`**: The unique redirect scheme you've set with `npx uri-scheme add ...`, critical for redirect handling in your app.
|
|
107
123
|
|
|
108
|
-
|
|
109
|
-
|
|
124
|
+
|
|
125
|
+
#### Simulating a failed registration
|
|
126
|
+
To simulate a failed validation flow (useful for handling failure case during integration), simply add
|
|
127
|
+
```js
|
|
128
|
+
forceError: 'validation_error'
|
|
110
129
|
```
|
|
130
|
+
to the `registerParams` object. This only works in the `sandbox` environment.
|
|
111
131
|
|
|
112
|
-
|
|
132
|
+
#### TypeScript support
|
|
113
133
|
|
|
114
|
-
This package includes TypeScript declarations
|
|
134
|
+
This package includes TypeScript declarations..
|
|
115
135
|
|
|
116
|
-
|
|
136
|
+
#### Developing
|
|
117
137
|
|
|
118
138
|
To develop the package, you need to use `npm`. Install the dependencies:
|
|
119
139
|
|
package/{src/main.ts → index.ts}
RENAMED
package/package/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSoyioAuth = void 0;
|
|
4
|
+
var core_1 = require("./src/core");
|
|
5
|
+
Object.defineProperty(exports, "useSoyioAuth", { enumerable: true, get: function () { return core_1.useSoyioAuth; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SANDBOX_URL = exports.PRODUCTION_URL = void 0;
|
|
4
|
+
exports.PRODUCTION_URL = 'https://app.soyio.id/widget';
|
|
5
|
+
exports.SANDBOX_URL = 'https://sandbox.soyio.id/widget';
|
|
6
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AuthenticateParams, RegisterParams, 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
5
|
};
|
|
6
|
-
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
+
function step(op) {
|
|
39
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
41
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
42
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
+
switch (op[0]) {
|
|
44
|
+
case 0: case 1: t = op; break;
|
|
45
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
+
default:
|
|
49
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
+
if (t[2]) _.ops.pop();
|
|
54
|
+
_.trys.pop(); continue;
|
|
55
|
+
}
|
|
56
|
+
op = body.call(thisArg, _);
|
|
57
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
62
|
+
exports.useSoyioAuth = void 0;
|
|
63
|
+
var WebBrowser = __importStar(require("expo-web-browser"));
|
|
64
|
+
var react_1 = require("react");
|
|
65
|
+
var utils_1 = require("./utils");
|
|
66
|
+
var useSoyioAuth = function (_a) {
|
|
67
|
+
var options = _a.options, onEventChange = _a.onEventChange;
|
|
68
|
+
var register = (0, react_1.useCallback)(function (registerParams) { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
+
var registerBaseUri, registerUri, redirectUrl, webBrowserOptions, registerResult;
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
switch (_a.label) {
|
|
72
|
+
case 0:
|
|
73
|
+
registerBaseUri = (0, utils_1.getFlowUrl)(options, 'register');
|
|
74
|
+
registerUri = "".concat(registerBaseUri, "?").concat((0, utils_1.buildUrlParams)(options, registerParams));
|
|
75
|
+
redirectUrl = (0, utils_1.getRedirectUrl)(options.uriScheme);
|
|
76
|
+
return [4 /*yield*/, (0, utils_1.getBrowserOptions)()];
|
|
77
|
+
case 1:
|
|
78
|
+
webBrowserOptions = _a.sent();
|
|
79
|
+
if (onEventChange)
|
|
80
|
+
onEventChange({ type: 'open register' });
|
|
81
|
+
return [4 /*yield*/, WebBrowser.openAuthSessionAsync(registerUri, redirectUrl, webBrowserOptions)];
|
|
82
|
+
case 2:
|
|
83
|
+
registerResult = _a.sent();
|
|
84
|
+
if (onEventChange)
|
|
85
|
+
onEventChange(registerResult);
|
|
86
|
+
return [2 /*return*/];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}); }, [options, onEventChange]);
|
|
90
|
+
var authenticate = (0, react_1.useCallback)(function (authenticateParams) { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
+
var authenticateBaseUri, authenticateUri, redirectUrl, webBrowserOptions, authenticateResult;
|
|
92
|
+
return __generator(this, function (_a) {
|
|
93
|
+
switch (_a.label) {
|
|
94
|
+
case 0:
|
|
95
|
+
authenticateBaseUri = (0, utils_1.getFlowUrl)(options, 'authenticate');
|
|
96
|
+
authenticateUri = "".concat(authenticateBaseUri, "?").concat((0, utils_1.buildUrlParams)(options, authenticateParams));
|
|
97
|
+
redirectUrl = (0, utils_1.getRedirectUrl)(options.uriScheme);
|
|
98
|
+
return [4 /*yield*/, (0, utils_1.getBrowserOptions)()];
|
|
99
|
+
case 1:
|
|
100
|
+
webBrowserOptions = _a.sent();
|
|
101
|
+
if (onEventChange)
|
|
102
|
+
onEventChange({ type: 'open authenticate' });
|
|
103
|
+
return [4 /*yield*/, WebBrowser.openAuthSessionAsync(authenticateUri, redirectUrl, webBrowserOptions)];
|
|
104
|
+
case 2:
|
|
105
|
+
authenticateResult = _a.sent();
|
|
106
|
+
if (onEventChange)
|
|
107
|
+
onEventChange(authenticateResult);
|
|
108
|
+
return [2 /*return*/];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}); }, [options, onEventChange]);
|
|
112
|
+
return { register: register, authenticate: authenticate };
|
|
113
|
+
};
|
|
114
|
+
exports.useSoyioAuth = useSoyioAuth;
|
|
115
|
+
//# sourceMappingURL=core.jsx.map
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export type SoyioWidgetParams = {
|
|
2
2
|
companyId: string;
|
|
3
3
|
userReference?: string;
|
|
4
|
-
|
|
4
|
+
uriScheme: string;
|
|
5
|
+
isSandbox?: boolean;
|
|
5
6
|
developmentUrl?: string;
|
|
6
7
|
};
|
|
7
8
|
export type RegisterParams = {
|
|
8
9
|
flowTemplateId: string;
|
|
9
10
|
userEmail?: string;
|
|
11
|
+
forceError?: 'no_error' | 'validation_error';
|
|
10
12
|
};
|
|
11
13
|
export type AuthenticateParams = {
|
|
12
14
|
identityId: string;
|
|
@@ -18,4 +20,3 @@ export type SoyioWidgetViewPropsType = {
|
|
|
18
20
|
url?: string;
|
|
19
21
|
}) => void;
|
|
20
22
|
};
|
|
21
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as WebBrowser from 'expo-web-browser';
|
|
2
|
+
import { AuthenticateParams, RegisterParams, SoyioWidgetParams } from './types';
|
|
3
|
+
export declare function getFlowUrl(options: SoyioWidgetParams, flow: 'authenticate' | 'register'): string;
|
|
4
|
+
export declare function buildUrlParams(widgetParams: SoyioWidgetParams, flowParams: RegisterParams | AuthenticateParams): string;
|
|
5
|
+
export declare function getBrowserOptions(): Promise<WebBrowser.AuthSessionOpenOptions>;
|
|
6
|
+
export declare function getRedirectUrl(scheme: string): string;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
+
exports.getRedirectUrl = exports.getBrowserOptions = exports.buildUrlParams = exports.getFlowUrl = void 0;
|
|
74
|
+
var WebBrowser = __importStar(require("expo-web-browser"));
|
|
75
|
+
var react_native_1 = require("react-native");
|
|
76
|
+
var constants_1 = require("./constants");
|
|
77
|
+
function getFlowUrl(options, flow) {
|
|
78
|
+
var baseUrl = options.developmentUrl || (options.isSandbox ? constants_1.SANDBOX_URL : constants_1.PRODUCTION_URL);
|
|
79
|
+
return "".concat(baseUrl, "/").concat(flow);
|
|
80
|
+
}
|
|
81
|
+
exports.getFlowUrl = getFlowUrl;
|
|
82
|
+
function buildUrlParams(widgetParams, flowParams) {
|
|
83
|
+
// eslint-disable-next-line no-nested-ternary
|
|
84
|
+
var platformSuffix = react_native_1.Platform.OS === 'android' ? '-android' : react_native_1.Platform.OS === 'ios' ? '-ios' : '';
|
|
85
|
+
var baseParams = {
|
|
86
|
+
platform: "rn".concat(platformSuffix),
|
|
87
|
+
uriScheme: widgetParams.uriScheme,
|
|
88
|
+
companyId: widgetParams.companyId,
|
|
89
|
+
userReference: widgetParams.userReference,
|
|
90
|
+
};
|
|
91
|
+
var allParams = __assign(__assign({}, baseParams), flowParams);
|
|
92
|
+
var queryParams = Object.entries(allParams)
|
|
93
|
+
.filter(function (_a) {
|
|
94
|
+
var value = _a[1];
|
|
95
|
+
return value;
|
|
96
|
+
})
|
|
97
|
+
.map(function (_a) {
|
|
98
|
+
var key = _a[0], value = _a[1];
|
|
99
|
+
return "".concat(key, "=").concat(encodeURIComponent(value));
|
|
100
|
+
})
|
|
101
|
+
.join('&');
|
|
102
|
+
return queryParams;
|
|
103
|
+
}
|
|
104
|
+
exports.buildUrlParams = buildUrlParams;
|
|
105
|
+
function getBrowserOptions() {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
+
var webBrowserOptions, preferredBrowserPackage;
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
switch (_a.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
webBrowserOptions = {
|
|
112
|
+
dismissButtonStyle: 'cancel',
|
|
113
|
+
createTask: false,
|
|
114
|
+
enableBarCollapsing: true,
|
|
115
|
+
showTitle: true,
|
|
116
|
+
};
|
|
117
|
+
if (!(react_native_1.Platform.OS === 'android')) return [3 /*break*/, 2];
|
|
118
|
+
return [4 /*yield*/, WebBrowser.getCustomTabsSupportingBrowsersAsync()];
|
|
119
|
+
case 1:
|
|
120
|
+
preferredBrowserPackage = (_a.sent()).preferredBrowserPackage;
|
|
121
|
+
webBrowserOptions.browserPackage = preferredBrowserPackage;
|
|
122
|
+
_a.label = 2;
|
|
123
|
+
case 2: return [2 /*return*/, webBrowserOptions];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
exports.getBrowserOptions = getBrowserOptions;
|
|
129
|
+
function getRedirectUrl(scheme) {
|
|
130
|
+
return "".concat(scheme, "://");
|
|
131
|
+
}
|
|
132
|
+
exports.getRedirectUrl = getRedirectUrl;
|
|
133
|
+
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,59 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soyio/soyio-rn-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"repository": {
|
|
5
|
-
"type": "git",
|
|
6
|
-
"url": "git+https://github.com/Soyio-id/soyio-webview-rn.git"
|
|
7
|
-
},
|
|
3
|
+
"version": "1.0.0",
|
|
8
4
|
"license": "MIT",
|
|
9
|
-
"author":
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
"main": "dist/main.umd.js",
|
|
14
|
-
"module": "dist/main.es.js",
|
|
15
|
-
"types": "dist/main.d.ts",
|
|
16
|
-
"exports": {
|
|
17
|
-
".": {
|
|
18
|
-
"require": "./dist/main.umd.js",
|
|
19
|
-
"import": "./dist/main.es.js"
|
|
20
|
-
}
|
|
21
|
-
},
|
|
5
|
+
"author": "Ignacio Méndez",
|
|
6
|
+
"main": "./package/index.js",
|
|
7
|
+
"types": "./package/index.d.ts",
|
|
22
8
|
"scripts": {
|
|
23
9
|
"bump!": "sh scripts/bump.sh",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
10
|
+
"start": "expo start",
|
|
11
|
+
"android": "expo start --android",
|
|
12
|
+
"ios": "expo start --ios",
|
|
13
|
+
"web": "expo start --web",
|
|
14
|
+
"build": "npm run build:esm && npm run build:cjs",
|
|
15
|
+
"build:esm": "tsc",
|
|
16
|
+
"build:cjs": "tsc --module commonjs",
|
|
17
|
+
"lint": "eslint . --ext .ts",
|
|
18
|
+
"version:get": "node -p \"require('./package.json').version\""
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"expo-status-bar": "~1.11.1",
|
|
22
|
+
"expo-web-browser": "~12.8.2"
|
|
31
23
|
},
|
|
32
24
|
"peerDependencies": {
|
|
33
25
|
"react": "*",
|
|
34
|
-
"react-native": "*"
|
|
26
|
+
"react-native": "*",
|
|
27
|
+
"expo": "*"
|
|
35
28
|
},
|
|
36
29
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@types/react": "
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"@
|
|
43
|
-
"eslint": "^
|
|
30
|
+
"@babel/core": "^7.20.0",
|
|
31
|
+
"@types/react": "~18.2.45",
|
|
32
|
+
"react": "^18.2.0",
|
|
33
|
+
"react-native": "^0.73.6",
|
|
34
|
+
"typescript": "^5.4.3",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
|
36
|
+
"@typescript-eslint/parser": "^7.4.0",
|
|
37
|
+
"eslint": "^8.57.0",
|
|
44
38
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
45
|
-
"eslint-
|
|
46
|
-
"eslint-plugin-import": "^2.
|
|
47
|
-
"eslint-plugin-
|
|
48
|
-
"npm-run-all": "^4.1.5",
|
|
49
|
-
"react": "^18.0.2",
|
|
50
|
-
"react-native": "^0.73.4",
|
|
51
|
-
"typescript": "^4.5.4",
|
|
52
|
-
"vite": "^2.8.0"
|
|
53
|
-
},
|
|
54
|
-
"dependencies": {
|
|
55
|
-
"expo-auth-session": "~5.4.0",
|
|
56
|
-
"expo-crypto": "~12.8.0",
|
|
57
|
-
"expo-web-browser": "~12.8.2"
|
|
39
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
40
|
+
"eslint-plugin-import": "^2.29.1",
|
|
41
|
+
"eslint-plugin-tsdoc": "^0.2.17"
|
|
58
42
|
}
|
|
59
43
|
}
|
package/.eslintignore
DELETED
package/.eslintrc.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
parser: '@typescript-eslint/parser',
|
|
4
|
-
env: {
|
|
5
|
-
browser: true,
|
|
6
|
-
es2021: true,
|
|
7
|
-
node: true,
|
|
8
|
-
},
|
|
9
|
-
extends: [
|
|
10
|
-
'airbnb-base',
|
|
11
|
-
'eslint:recommended',
|
|
12
|
-
'plugin:react/recommended',
|
|
13
|
-
'plugin:@typescript-eslint/recommended',
|
|
14
|
-
],
|
|
15
|
-
plugins: ['import', '@typescript-eslint'],
|
|
16
|
-
parserOptions: {
|
|
17
|
-
ecmaVersion: 2021,
|
|
18
|
-
},
|
|
19
|
-
settings: {
|
|
20
|
-
'import/resolver': {
|
|
21
|
-
node: {
|
|
22
|
-
paths: ['src'],
|
|
23
|
-
},
|
|
24
|
-
typescript: {
|
|
25
|
-
project: './',
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
react: {
|
|
29
|
-
version: 'detect',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
rules: {
|
|
33
|
-
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
|
|
34
|
-
'import/prefer-default-export': 'off',
|
|
35
|
-
'import/extensions': [
|
|
36
|
-
'error',
|
|
37
|
-
'ignorePackages',
|
|
38
|
-
{
|
|
39
|
-
js: 'never',
|
|
40
|
-
jsx: 'never',
|
|
41
|
-
ts: 'never',
|
|
42
|
-
tsx: 'never',
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
name: Setup
|
|
2
|
-
description: Setup Node.js and install dependencies
|
|
3
|
-
|
|
4
|
-
runs:
|
|
5
|
-
using: composite
|
|
6
|
-
steps:
|
|
7
|
-
- name: Setup Node.js
|
|
8
|
-
uses: actions/setup-node@v3
|
|
9
|
-
with:
|
|
10
|
-
node-version-file: .node-version
|
|
11
|
-
|
|
12
|
-
- name: Cache dependencies
|
|
13
|
-
id: npm-cache
|
|
14
|
-
uses: actions/cache@v3
|
|
15
|
-
with:
|
|
16
|
-
path: |
|
|
17
|
-
**/node_modules
|
|
18
|
-
.npm/install-state.gz
|
|
19
|
-
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
|
|
20
|
-
restore-keys: |
|
|
21
|
-
${{ runner.os }}-npm-${{ hashFiles('npm.lock') }}
|
|
22
|
-
${{ runner.os }}-npm-
|
|
23
|
-
|
|
24
|
-
- name: Install dependencies
|
|
25
|
-
if: steps.npm-cache.outputs.cache-hit != 'true'
|
|
26
|
-
run: npm install --immutable
|
|
27
|
-
shell: bash
|
package/.node-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
20
|