Skip to content

Commit 72c1e71

Browse files
committed
feat(myaccount): able to open each page
1 parent da9b8e1 commit 72c1e71

File tree

9 files changed

+688
-707
lines changed

9 files changed

+688
-707
lines changed

docs/README.md

+26-6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const newInstance = new window.MtLinkSdk();
3535
The source also includes Typescript definitions out of the box.
3636

3737
### Polyfills
38+
3839
We use [fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) and [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) internally, if you wish to support old browsers (e.g: IE11), make sure to add the necessary polyfills.
3940

4041
## API
@@ -45,6 +46,7 @@ The Moneytree LINK Javascript SDK exposes APIs to get guest consent to access fi
4546

4647
The `init` call is used to initialize the SDK and set default options for API calls. Some LINK APIs can be used without calling `init`.<br /><br />
4748
Calls related to OAuth require a client id which can only be set via the `init` function. These APIs include:
49+
4850
- authorize
4951
- onboard
5052
- exchangeToken
@@ -60,7 +62,7 @@ mtLinkSdk.init(clientId, options);
6062
| - | - | - | - | - |
6163
| clientId | string | true | | <p>OAuth `clientId` of the app (please request this from your Moneytree representative if you need one).<p><p><strong>NOTE:</strong> This function will throw an error if this parameter isn't provided.</p> |
6264
| <span id="api-init_options">options</span> | object | false | | <p>These options include all of the values below and also all `options` parameters of the other APIs. Options values passed here during initialization will be used by default if no options are passed when calling a specific API.</p><p>Available options are documented under [authorize options](#api-authorize_options) and [common options](#common-api-options); refer to each individual link for more details.</p> |
63-
| options.mode | `production`, ` staging`, ` develop`, ` local` | false | `production` | <p>Environment for the SDK to connect to, the SDK will connect to the Moneytree production server by default.<ul><li>Moneytree clients should use `staging` for development as `develop` may contain unstable features.</li><li>`local` should only be used for SDK development as it has local dependencies.</li></ul></p> |
65+
| options.mode | `production`, `staging`, `develop`, `local` | false | `production` | <p>Environment for the SDK to connect to, the SDK will connect to the Moneytree production server by default.<ul><li>Moneytree clients should use `staging` for development as `develop` may contain unstable features.</li><li>`local` should only be used for SDK development as it has local dependencies.</li></ul></p> |
6466
| options.locale | string | false | Auto detect. | Force Moneytree to load content in this specific locale. A default value will be auto detected based on guest langauges configurations and location if available. Check this [spec](https://www.w3.org/TR/html401/struct/dirlang.html#h-8.1.1) for more information.<br /><br />Currently supported values are:<br />`en`, `en-AU`, `ja`. |
6567
| options.cobrandClientId (private) | string | false | | <strong>NOTE: This is an internal attribute. Please do not use it unless instructed by your integration representative.</strong><br /><br />Brand Moneytree apps with client's branding. E.g: logo or theme.
6668

@@ -88,7 +90,7 @@ mtLinkSdk.authorize(options);
8890
| options.codeChallenge | string | false | | We only support SHA256 as code challenge method, therefore please ensure the `code_challenge` was generated using the SHA256 hash algorithm. [Click here](https://auth0.com/docs/api-auth/tutorials/authorization-code-grant-pkce) for more details.</p><strong>NOTE:</strong> Set this value only if your server wish to use PKCE flow. |
8991
| options.pkce | boolean | false | false | Set to `true` if you wish to use PKCE flow on the client side, SDK will automatically generate the code challenge from a locally generated code verifier and use the code verifier in [exchangeToken](#exchangetoken). |
9092
| <span id="authorize_option_force_logout">options.forceLogout</span> | boolean | false | `false` | Force existing guest session to logout and call authorize with a clean state. |
91-
| options.country | `AU`, ` JP` | false | Value set during `init`. | Server location for the guest to login or sign up. If you wish to restrict your guest to only one country, make sure to set this value.<br /><br /><strong>NOTE:</strong> For apps created after 2020-07-08, the sign up form will display a country selection dropdown for the guest to select a country when this value is undefined or invalid. |
93+
| options.country | `AU`, `JP` | false | Value set during `init`. | Server location for the guest to login or sign up. If you wish to restrict your guest to only one country, make sure to set this value.<br /><br /><strong>NOTE:</strong> For apps created after 2020-07-08, the sign up form will display a country selection dropdown for the guest to select a country when this value is undefined or invalid. |
9294

9395
### onboard
9496

@@ -111,7 +113,7 @@ mtLinkSdk.onboard(options)
111113
| Parameter | Type | Required | Default Value | Description |
112114
| - | - | - | - | - |
113115
| options | object | false | Value set during `init`. | Optional parameters.<br /><br />Most options are the same as the [authorize method](#authorize) options and [common options](#common-api-options) with a few exceptions.<br /><br />Unsupported options from [authorize](#authorize) and [common options](#common-api-options) are:<li>forceLogout</li><li>authAction</li><li>showAuthToggle</li><li>showRememberMe</li> |
114-
| options.country | `AU`, ` JP` | true | Value set during `init`. | Server location for the guest to login or sign up.<br /><br /><strong>NOTE:</strong> SDK will throw an error if both values here and from the [init options](?id=api-init_options) are undefined. |
116+
| options.country | `AU`, `JP` | true | Value set during `init`. | Server location for the guest to login or sign up.<br /><br /><strong>NOTE:</strong> SDK will throw an error if both values here and from the [init options](?id=api-init_options) are undefined. |
115117
| options.email | string | true | Value set during `init`. | A new Moneytree account will be created with this email address. If an existing account with this email exists, the guest will be redirected to the login screen.<br /><br /><strong>NOTE:</strong> SDK will throw an error if both values here and from the [init options](?id=api-init_options) are undefined. |
116118

117119
### exchangeToken
@@ -128,7 +130,6 @@ One way to use this API is by calling it in the script on your redirection page.
128130

129131
Alternatively, you can extract the `code` manually from the redirect URL and pass it to this function via the options object yourself.
130132

131-
132133
```javascript
133134
const token = await mtLinkSdk.exchangeToken(options);
134135
```
@@ -199,7 +200,8 @@ mtLinkSdk.openService(serviceId, options);
199200
| - | - | - | - | - |
200201
| serviceId | `vault`, `myaccount-settings`, `link-kit` | true | | Open a service by Id, current supported services are:<br /><li>`vault` - Manage your financial institution credentials.</li><li>`myaccount-settings` - Manage your Moneytree account settings.</li><li>`link-kit` - View all your financial data.<br /><br /><strong>NOTE:</strong> This function will throw an error if you do not specify a valid service ID. |
201202
| options | object | false | Value set during `init`. | Optional parameters. Includes all options in [common options](#common-api-options). |
202-
| options.view | `services-list`, `service-connection`, `connection-setting`, `customer-support` | false | | We provide the way to open the Vault's specific pages. Please check the following sessions:<br /> <li>[Open Vault Services Page](#open-vault-services-page)</li><li>[Open Vault Service Connection Page](#open-vault-service-connection-page)</li><li>[Open Vault Service Setting Page](#open-vault-service-setting-page)</li><li>[Open Vault Customer Support Page](#open-vault-customer-support-page)</li> <br /><br /><strong>NOTE:</strong> The serviceId must be `vault` to enable this option.|
203+
| options.view for Vault | `services-list`, `service-connection`, `connection-setting`, `customer-support` | false | | We provide options for opening a specific page on Vault and MyAccount. Please check the following sessions:<br /> <li>[Open Vault Services Page](#open-vault-services-page)</li><li>[Open Vault Service Connection Page](#open-vault-service-connection-page)</li><li>[Open Vault Service Setting Page](#open-vault-service-setting-page)</li><li>[Open Vault Customer Support Page](#open-vault-customer-support-page)</li><br /><br /><strong>NOTE:</strong> The serviceId must be `vault` to enable this option.|
204+
| options.view for MyAccount | `authorized-applications`, `change-language`, `email-preferences`, `delete-account`, `update-email`, `update-password` | false | | We provide options for opening a specific page on MyAccount. Please check the following sessions:<br /> <li>[Open MyAccount Page](#open-myaccount-page)</li> <br /><br /><strong>NOTE:</strong> The serviceId must be `myaccount-settings` to enable this option.|
203205

204206
#### Open Vault Services Page
205207

@@ -274,6 +276,23 @@ mtLinkSdk.openService('vault', { view: 'customer-support' });
274276
| serviceId | `vault` | true | | Open a Vault service|
275277
| options.view | `customer-support` | true | | Assign to open customer support page|
276278

279+
#### Open MyAccount Page
280+
281+
It has to include these properties of `options` below when calling [openService](#openservice) API.
282+
283+
<strong>NOTE:</strong> This scenario only works when serviceId is `myaccount-settings`.
284+
285+
<h6>Usage:</h6>
286+
287+
```javascript
288+
mtLinkSdk.openService('myaccount-settings', { view: 'update-email' });
289+
```
290+
291+
| Parameter | Type | Required | Default Value | Description |
292+
| - | - | - | - | - |
293+
| serviceId | `myaccount-settings` | true | | Open MyAccount |
294+
| options.view | `authorized-applications`, `change-language`, `email-preferences`, `delete-account`, `update-email`, `update-password` | false | | Directly go to the chosen page. If no view is provided, it goes to the top page of MyAccount. |
295+
277296
### requestMagicLink
278297

279298
Request for a magic link (password-less login link) to be sent to the guest's email address. Clicking on the link in the email will log a guest in directly to the screen specified by the `magicLinkTo` parameter.
@@ -300,7 +319,7 @@ These common options are used in multiple APIs. Instead of repeating the same op
300319
| - | - | - | - | - |
301320
| options.email | string | false | Value set during `init`. | Email used to pre-fill the email field in login or sign up or form. |
302321
| options.backTo | string | false | Value set during `init`. | A redirection URL for redirecting a guest back to in the following condition: <li>Guest clicks on `Back to [App Name]` button in any Moneytree screen.</li><li>Guest refuses to give consent to access permission in the consent screen.</li><li>Guest logs out from Moneytree via an app with this client id</li><li>Revoke an app's consent from settings screen opened via an app with this client id</li><br /><br /><strong>NOTE:</strong> No `Back to [App Name]` button will be shown if this value is not set, and any of the actions mentioned above will redirect the guest back to login screen by default. |
303-
| <span id="authorize_option_auth_action">options.authAction</span> | `login`, ` signup` | false | Value set during `init`.<p><strong>OR</strong></p>`login` | Show login or sign up screen when a session does not exist during an `authorize` call. |
322+
| <span id="authorize_option_auth_action">options.authAction</span> | `login`, `signup` | false | Value set during `init`.<p><strong>OR</strong></p>`login` | Show login or sign up screen when a session does not exist during an `authorize` call. |
304323
| options.showAuthToggle | boolean | false | Value set during `init`.<p><strong>OR</strong></p>`true` | If you wish to disable the login to sign up form toggle button and vice-versa in the auth screen, set this to `false`.
305324
| options.showRememberMe | boolean | false | Value set during `init`.<p><strong>OR</strong></p>`true` | If you wish to disable the `Stay logged in for 30 days` checkbox in the login screen, set this to `false`.
306325
| options.isNewTab | boolean | false | Value set during `init`.<p><strong>OR</strong></p>`false` | Call method and open/render in a new browser tab, by default all views open in the same tab.
@@ -312,6 +331,7 @@ These common options are used in multiple APIs. Instead of repeating the same op
312331
We support gray labelling some of the services offered by Moneytree, please contact your Moneytree representative for more information.
313332

314333
Currently supported services:
334+
315335
- onboard API
316336
- Vault service
317337
- Link-Kit service

sample/src/index.html

+6
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ <h3>Open Service</h3>
223223
<option value="service-connection">service-connection</option>
224224
<option value="connection-setting">connection-setting</option>
225225
<option value="customer-support">customer-support</option>
226+
<option value="authorized-applications">authorized-applications</option>
227+
<option value="change-language">change-language</option>
228+
<option value="email-preferences">email-preferences</option>
229+
<option value="delete-account">delete-account</option>
230+
<option value="update-email">update-email</option>
231+
<option value="update-password">update-password</option>
226232
</select>
227233
</div>
228234

sample/src/index.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,19 @@ elements.openServiceBtn.onclick = () => {
165165
}
166166
}
167167

168+
if (serviceId === 'myaccount-settings') {
169+
const view = openServiceOptionsElms.view.options[openServiceOptionsElms.view.selectedIndex]
170+
.value as
171+
| 'authorized-applications'
172+
| 'change-language'
173+
| 'email-preferences'
174+
| 'delete-account'
175+
| 'update-email'
176+
| 'update-password';
177+
178+
OpenServicesConfigsOptions = { view };
179+
}
180+
168181
mtLinkSdk.openService(serviceId, OpenServicesConfigsOptions);
169182
};
170183

@@ -193,7 +206,7 @@ elements.openServiceOptionsElms.serviceId.onchange = () => {
193206
const selectedValue =
194207
openServiceOptionsElms.serviceId.options[openServiceOptionsElms.serviceId.selectedIndex].value;
195208

196-
if (selectedValue === 'vault') {
209+
if (selectedValue === 'vault' || selectedValue === 'myaccount-settings') {
197210
vaultOptions.style.display = 'block';
198211
return;
199212
}
@@ -203,7 +216,7 @@ elements.openServiceOptionsElms.serviceId.onchange = () => {
203216

204217
// Helper, To switch the options, depends on openService's view value for vault
205218
elements.openServiceOptionsElms.view.onchange = () => {
206-
const { openServiceOptionsElms, vaultOptions } = elements;
219+
const { openServiceOptionsElms } = elements;
207220
const selectedValue =
208221
openServiceOptionsElms.view.options[openServiceOptionsElms.view.selectedIndex].value;
209222

0 commit comments

Comments
 (0)