@basiq/connect-auth 0.1.88 → 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 +40 -140
- package/dist/App.d.ts +2 -1
- package/dist/actions/actions.d.ts +16 -2
- package/dist/components/BasiqConnect.d.ts +4 -1
- package/dist/components/pages/AuthScreen.d.ts +3 -2
- package/dist/components/pages/StartScreen.d.ts +2 -1
- package/dist/connect-auth.cjs.development.js +176 -105
- package/dist/connect-auth.cjs.development.js.map +1 -1
- package/dist/connect-auth.cjs.production.min.js +1 -1
- package/dist/connect-auth.cjs.production.min.js.map +1 -1
- package/dist/connect-auth.esm.js +177 -106
- package/dist/connect-auth.esm.js.map +1 -1
- package/dist/helpers/constants.d.ts +1 -0
- package/dist/helpers/utils.d.ts +1 -0
- package/dist/styledComponents/pages/auth.d.ts +4 -1
- package/package.json +2 -4
package/README.md
CHANGED
|
@@ -1,160 +1,60 @@
|
|
|
1
|
-
#
|
|
1
|
+
# BASIQ CONNECT COMPONENT
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Basiq Connect Auth is a ReactJS UI component exposed to partners who prefer to implement the auth flow as an external component with an SMS OTP built in. When rendered, it will take the user through an SMS OTP flow and then proceed to redirect them to the [Basiq Consent UI](https://api.basiq.io/docs/consent-ui) flow to connect their accounts.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Note: This has been offered as interim solution for partners who require access to v3 of the API before we have released the upgrades to `https://connect.basiq.io/`. If you have any questions regarding this please reach out to support@basiq.io.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Setup
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
1. Install `@basiq/connect-auth` and import the component
|
|
10
10
|
|
|
11
|
-
TSDX scaffolds your new library inside `/src`, and also sets up a [Parcel-based](https://parceljs.org) playground for it inside `/example`.
|
|
12
|
-
|
|
13
|
-
The recommended workflow is to run TSDX in one terminal:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
npm start # or yarn start
|
|
17
11
|
```
|
|
18
|
-
|
|
19
|
-
This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
|
|
20
|
-
|
|
21
|
-
Then run the example inside another:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
cd example
|
|
25
|
-
npm i # or yarn to install dependencies
|
|
26
|
-
npm start # or yarn start
|
|
12
|
+
$ npm install @basiq/basiq-connect-control
|
|
27
13
|
```
|
|
28
14
|
|
|
29
|
-
The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**, we use [Parcel's aliasing](https://parceljs.org/module_resolution.html#aliases).
|
|
30
|
-
|
|
31
|
-
To do a one-off build, use `npm run build` or `yarn build`.
|
|
32
|
-
|
|
33
|
-
To run tests, use `npm test` or `yarn test`.
|
|
34
|
-
|
|
35
|
-
## Configuration
|
|
36
|
-
|
|
37
|
-
Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
|
|
38
|
-
|
|
39
|
-
### Jest
|
|
40
|
-
|
|
41
|
-
Jest tests are set up to run with `npm test` or `yarn test`.
|
|
42
|
-
|
|
43
|
-
### Bundle analysis
|
|
44
|
-
|
|
45
|
-
Calculates the real cost of your library using [size-limit](https://github.com/ai/size-limit) with `npm run size` and visulize it with `npm run analyze`.
|
|
46
|
-
|
|
47
|
-
#### Setup Files
|
|
48
|
-
|
|
49
|
-
This is the folder structure we set up for you:
|
|
50
|
-
|
|
51
|
-
```txt
|
|
52
|
-
/example
|
|
53
|
-
index.html
|
|
54
|
-
index.tsx # test your component here in a demo app
|
|
55
|
-
package.json
|
|
56
|
-
tsconfig.json
|
|
57
|
-
/src
|
|
58
|
-
index.tsx # EDIT THIS
|
|
59
|
-
/test
|
|
60
|
-
blah.test.tsx # EDIT THIS
|
|
61
|
-
.gitignore
|
|
62
|
-
package.json
|
|
63
|
-
README.md # EDIT THIS
|
|
64
|
-
tsconfig.json
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
#### React Testing Library
|
|
68
|
-
|
|
69
|
-
We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.
|
|
70
|
-
|
|
71
|
-
### Rollup
|
|
72
|
-
|
|
73
|
-
TSDX uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
|
|
74
|
-
|
|
75
|
-
### TypeScript
|
|
76
|
-
|
|
77
|
-
`tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs.
|
|
78
|
-
|
|
79
|
-
## Continuous Integration
|
|
80
|
-
|
|
81
|
-
### GitHub Actions
|
|
82
|
-
|
|
83
|
-
Two actions are added by default:
|
|
84
|
-
|
|
85
|
-
- `main` which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
|
|
86
|
-
- `size` which comments cost comparison of your library on every pull request using [`size-limit`](https://github.com/ai/size-limit)
|
|
87
|
-
|
|
88
|
-
## Optimizations
|
|
89
|
-
|
|
90
|
-
Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:
|
|
91
|
-
|
|
92
15
|
```js
|
|
93
|
-
|
|
94
|
-
declare var __DEV__: boolean;
|
|
95
|
-
|
|
96
|
-
// inside your code...
|
|
97
|
-
if (__DEV__) {
|
|
98
|
-
console.log('foo');
|
|
99
|
-
}
|
|
16
|
+
import { BasiqConnect } from "@basiq/connect-auth";
|
|
100
17
|
```
|
|
101
18
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
## Module Formats
|
|
105
|
-
|
|
106
|
-
CJS, ESModules, and UMD module formats are supported.
|
|
107
|
-
|
|
108
|
-
The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
|
|
109
|
-
|
|
110
|
-
## Deploying the Example Playground
|
|
111
|
-
|
|
112
|
-
The Playground is just a simple [Parcel](https://parceljs.org) app, you can deploy it anywhere you would normally deploy that. Here are some guidelines for **manually** deploying with the Netlify CLI (`npm i -g netlify-cli`):
|
|
19
|
+
2. Generate a new Auth Link, and retrieve the auth link ID from the public URL that is returned.
|
|
113
20
|
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
21
|
+
```js
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const { data } = await axios.get(
|
|
25
|
+
`https://au-api.basiq.io/users/{userId}/auth_link`,
|
|
26
|
+
{
|
|
27
|
+
method: 'post',
|
|
28
|
+
headers: {
|
|
29
|
+
Authorization: `Bearer ${YOUR_SERVER_ACCESS_TOKEN}`,
|
|
30
|
+
Accept: 'application/json',
|
|
31
|
+
'Content-Type': 'application/json',
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
let auth_id = data.links.public.replace('https://connect.basiq.io/','');
|
|
37
|
+
|
|
38
|
+
return auth_id;
|
|
39
|
+
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.log(error)
|
|
42
|
+
}
|
|
121
43
|
|
|
122
|
-
```bash
|
|
123
|
-
netlify init
|
|
124
|
-
# build command: yarn build && cd example && yarn && yarn build
|
|
125
|
-
# directory to deploy: example/dist
|
|
126
|
-
# pick yes for netlify.toml
|
|
127
44
|
```
|
|
128
45
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.
|
|
132
|
-
|
|
133
|
-
## Including Styles
|
|
134
|
-
|
|
135
|
-
There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.
|
|
46
|
+
3. Drop the component in your code on the page you wish to call it. The component will retrieve the auth_id from the URL so failing to include it there will result in an error. **Note** that the component is full page and will eventually handle the redirect to the Basiq Consent UI, so it should be rendered on it's own page (or conditionally, after appending an auth_link ID)
|
|
136
47
|
|
|
137
|
-
For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.
|
|
138
48
|
|
|
139
|
-
|
|
49
|
+
```jsx
|
|
140
50
|
|
|
141
|
-
|
|
51
|
+
// Component rendered at /auth-link/:auth_id
|
|
142
52
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
```diff
|
|
152
|
-
"alias": {
|
|
153
|
-
- "react": "../node_modules/react",
|
|
154
|
-
- "react-dom": "../node_modules/react-dom"
|
|
155
|
-
+ "react": "../../../node_modules/react",
|
|
156
|
-
+ "react-dom": "../../../node_modules/react-dom"
|
|
157
|
-
},
|
|
53
|
+
export default function Auth() {
|
|
54
|
+
return (
|
|
55
|
+
<main>
|
|
56
|
+
<BasiqConnect />
|
|
57
|
+
</main>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
158
60
|
```
|
|
159
|
-
|
|
160
|
-
An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead. [However, that might cause other problems.](https://github.com/palmerhq/tsdx/issues/64)
|
package/dist/App.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export declare const verifySmsCode: (authRequestId
|
|
1
|
+
export declare const verifySmsCode: ({ authRequestId, smsCode, test }: {
|
|
2
|
+
authRequestId: string;
|
|
3
|
+
smsCode: string;
|
|
4
|
+
test?: boolean;
|
|
5
|
+
}) => Promise<{
|
|
2
6
|
data: any;
|
|
3
7
|
headers: Headers;
|
|
4
8
|
statusCode: number;
|
|
@@ -11,7 +15,11 @@ export declare const verifySmsCode: (authRequestId: string, smsCode: string) =>
|
|
|
11
15
|
ok: boolean;
|
|
12
16
|
data?: undefined;
|
|
13
17
|
}>;
|
|
14
|
-
export declare const authUser: (authRequestId
|
|
18
|
+
export declare const authUser: ({ authRequestId, method, test }: {
|
|
19
|
+
authRequestId: string;
|
|
20
|
+
method?: 'POST' | 'GET';
|
|
21
|
+
test?: boolean;
|
|
22
|
+
}) => Promise<{
|
|
15
23
|
data: any;
|
|
16
24
|
headers: Headers;
|
|
17
25
|
statusCode: number;
|
|
@@ -23,4 +31,10 @@ export declare const authUser: (authRequestId: string, method?: 'POST' | 'GET')
|
|
|
23
31
|
error: any;
|
|
24
32
|
ok: boolean;
|
|
25
33
|
data?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
statusCode: number;
|
|
36
|
+
error: string;
|
|
37
|
+
ok: boolean;
|
|
38
|
+
data?: undefined;
|
|
39
|
+
headers?: undefined;
|
|
26
40
|
}>;
|
|
@@ -3,7 +3,8 @@ interface IProps {
|
|
|
3
3
|
shadow: boolean;
|
|
4
4
|
onBack: () => void;
|
|
5
5
|
number: string;
|
|
6
|
-
|
|
6
|
+
authRequestId: string;
|
|
7
|
+
test?: boolean;
|
|
7
8
|
}
|
|
8
|
-
declare function AuthScreen({ onBack, number,
|
|
9
|
+
declare function AuthScreen({ onBack, number, authRequestId, shadow, test }: IProps): JSX.Element;
|
|
9
10
|
export default AuthScreen;
|