|
1 | 1 | # Moneytree Link JavaScript SDK |
2 | 2 |
|
3 | | -This is a library for browser client to help you integrate Moneytree tools such as My Account and the Vault without having to do it yourself. |
| 3 | +This is a library for browser client to help you integrate Moneytree tools such as My Account and the Vault without having to do worry about the complex configurations. |
4 | 4 |
|
5 | | -## Installation |
6 | | - |
7 | | -### Browser based |
8 | | - |
9 | | -Include the script tag |
10 | | - |
11 | | -```html |
12 | | -<script |
13 | | - type="text/javascript" |
14 | | - src="https://cdn.jsdelivr.net/npm/@moneytree/mt-link-javascript-sdk@<version>/dist/index.js" |
15 | | -></script> |
16 | | -``` |
17 | | - |
18 | | -Change the `<version>` by the one you need (most likely the latest available). |
19 | | -You can also replace `<version>` by `latest` to always get the latest published, at your own risk. |
20 | | - |
21 | | -You will find the library under `window.mtLinkSdk`. |
22 | | - |
23 | | -### CommonJS |
24 | | - |
25 | | -Using NPM simply install the library |
26 | | - |
27 | | -```shell |
28 | | -npm install @moneytree/mt-link-javascript-sdk |
29 | | -``` |
30 | | - |
31 | | -Then you can use it directly in your code: |
32 | | - |
33 | | -```js |
34 | | -var mtLinkSdk = require('@moneytree/mt-link-javascript-sdk'); // es5 |
35 | | -// or |
36 | | -import mtLinkSdk from '@moneytree/mt-link-javascript-sdk'; // es-next |
37 | | -``` |
38 | | - |
39 | | -The source also include a Typescript definition. |
40 | | - |
41 | | -## API |
42 | | - |
43 | | -### Inititalising the API |
44 | | - |
45 | | -Call the following method with your desired configuration. |
46 | | -`init(<config>)` |
47 | | - |
48 | | -Config properties: |
49 | | - |
50 | | -```js |
51 | | -{ |
52 | | - clientId, // string; // The id of the application that asks for authorization. |
53 | | - responseType, // string; // Tells the authorization server which grant to execute (e.g.: code). |
54 | | - scope, // string[]; // A list of permissions that the application requires. |
55 | | - redirectUri, // string; // URI to return the user to after authorization is complete. |
56 | | - continueTo, // string; // [optional] Parameter appended as `continue` to the `redirectUri`. |
57 | | - locale, // string; // [optional] To force the display to a specific language (e.g.: en-AU). |
58 | | - state, // string; // [optional] An opaque value, used for security purposes. If this request parameter is set in the request, then it is returned to the application as part of the redirect_uri. |
59 | | - isTestEnvironment // boolean; // [optional] If you wanna use the staging or production environment |
60 | | -} |
61 | | -``` |
62 | | - |
63 | | -### Open the page for the user to authorize your application |
64 | | - |
65 | | -`mtLinkSdk.authorize(options);` |
66 | | -You can pass the following options: |
67 | | - |
68 | | -- `newTab`: Open in a new browser tab |
69 | | - - Values: `true` or `false` |
70 | | - - Default: `false` |
71 | | -- `authPage`: Page to display during unauthenticated redirection |
72 | | - - Values: `'login'` or `'signup'`. |
73 | | - - Default: `'login'` |
74 | | -- `email`: To prefill the email field for signup and login |
75 | | - - Values: A string |
76 | | - - Default: `undefined` |
77 | | -- `backTo`: Redirect URL for some actions (back, revoke, logout, delete) |
78 | | - - Values: A string representing a URL |
79 | | - - Default: Current URL |
80 | | -- `showAuthToggle`: Option to hide the button to toggle between login and signup pages |
81 | | - - Values: `false` |
82 | | - - Default: `undefined` |
83 | | - |
84 | | -### Logout from current session |
85 | | - |
86 | | -`mtLinkSdk.logout(options);` |
87 | | -You can pass the following options: |
88 | | - |
89 | | -- `newTab`: Open in a new browser tab |
90 | | - - Values: `true` or `false` |
91 | | - - Default: `false` |
92 | | - |
93 | | -- `backTo`: Redirect back to this url after logout, url must be whitelisted (contact support) |
94 | | - - Values: A string representing a URL |
95 | | - - Default: `undefined` |
96 | | - |
97 | | -### Open the setting page of the user account |
98 | | - |
99 | | -`mtLinkSdk.openSettings(options);` |
100 | | -You can pass the following options: |
101 | | - |
102 | | -- `newTab`: Open in a new browser tab |
103 | | - - Values: `true` or `false` |
104 | | - - Default: `false` |
105 | | -- `backTo`: Redirect URL for some actions (back, revoke, logout, delete) |
106 | | - - Values: A string representing a URL |
107 | | - - Default: Current URL |
108 | | - |
109 | | -### Open the vault to let the user add credentials |
110 | | - |
111 | | -`mtLinkSdk.openVault(options);` |
112 | | -You can pass the following options: |
113 | | - |
114 | | -- `newTab`: Open in a new browser tab |
115 | | - - Values: `true` or `false` |
116 | | - - Default: `false` |
117 | | -- `backTo`: Redirect URL for some actions (back, revoke, logout, delete) |
118 | | - - Values: A string representing a URL |
119 | | - - Default: Current URL |
| 5 | +Read the [documentation](docs/README.md) for more information. |
0 commit comments