From b18603d8c08f4e49ce0a08d4786f88b3021388fd Mon Sep 17 00:00:00 2001 From: Nemo | DFR Date: Thu, 5 Oct 2023 17:16:56 +0900 Subject: [PATCH] doc(sdk) replace markdown API doc with links typedoc --- docs/README.md | 414 +++++++++++-------------------------------------- 1 file changed, 94 insertions(+), 320 deletions(-) diff --git a/docs/README.md b/docs/README.md index 35f5568..14eb759 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,16 +4,12 @@ Install the SDK using `npm` or `yarn`. ```bash npm install @moneytree/mt-link-javascript-sdk - # or - yarn add @moneytree/mt-link-javascript-sdk ``` Then you can use it directly in your code: -
Usage:
- ```javascript // using import import mtLinkSdk, { MtLinkSdk } from '@moneytree/mt-link-javascript-sdk'; @@ -38,365 +34,143 @@ The source also includes Typescript definitions out of the box. 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. -## API +## [API](/types/classes/MtLinkSdk.html) The Moneytree LINK Javascript SDK exposes APIs to get guest consent to access financial data, and exchange an authorization grant for an access token. -### init - -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`.

-Calls related to OAuth require a client id which can only be set via the `init` function. These APIs include: - -- authorize -- onboard -- exchangeToken -- tokenInfo - -
Usage:
- -```javascript -mtLinkSdk.init(clientId, options); -``` - -| Parameter | Type | Required | Default Value | Description | -| ------------------------------------------ | ------------------------------------------- | -------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| clientId | string | true | |

OAuth `clientId` of the app (please request this from your Moneytree representative if you need one).

NOTE: This function will throw an error if this parameter isn't provided.

| -| options | object | false | |

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.

Available options are documented under [authorize options](#api-authorize_options) and [common options](#common-api-options); refer to each individual link for more details.

| -| options.mode | `production`, `staging`, `develop`, `local` | false | `production` |

Environment for the SDK to connect to, the SDK will connect to the Moneytree production server by default.

| -| 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.

Currently supported values are:
`en`, `en-AU`, `ja`. | -| options.cobrandClientId (private) | string | false | | NOTE: This is an internal attribute. Please do not use it unless instructed by your integration representative.

Brand Moneytree apps with client's branding. E.g: logo or theme. | -| options.samlSubjectId | string | false | | Sets subject Id for saml session version. | - -### setSamlSubjectId - -The `setSamlSubjectId` method is used to set the value of the `saml_subject_id` parameter. This parameter can be set during `init` or changed by this method. It can not be overriden. -The `setSamlSubjectId` parameter allows the client to pass a guest identifier to Moneytree so that Moneytree can forward it to the Identity Provider (IdP) via the SAMLRequest. -The `saml_subject_id` parameter will be forwarded to the `authorize`, `logout` and `open-service` methods when defined. - -
Usage:
- -```javascript -mtLinkSdk.setSamlSubjectId(samlSubjectId); -``` - -| Parameter | Type | Required | Default Value | Description | -| ------------- | ------ | -------- | ------------- | ---------------------------------------- | -| sublSubjectId | string | true | |

Set the saml_subject_id parameter

| - -### authorize - -OAuth authorization method to request guest consent to access data via the [Link API](https://getmoneytree.com/jp/link/about).

-For [security reasons](https://developer.okta.com/blog/2019/08/22/okta-authjs-pkce#why-you-should-never-use-the-implicit-flow-again) we removed support for implicit flow. We have opted for the [PKCE](https://auth0.com/docs/flows/concepts/auth-code-pkce)/[code grant](https://www.oauth.com/oauth2-servers/access-tokens/authorization-code-request/) flow.

-Guest login is required for this SDK to work, by default we will show the login screen and redirect the guest to the consent screen after they log in (Redirection happens immediately if they are currently logged in; you may pass the [forceLogout option](#authorize_option_force_logout) to force the guest to log in, even if they have an active session.)

-You may also choose to display the sign up form by default by passing the [authAction option](#authorize_option_auth_action). - -NOTE: You must initialize the SDK (via the `init` method) before calling this API. - -
Usage:
- -```javascript -mtLinkSdk.authorize(options); -``` - -| Parameter | Type | Required | Default Value | Description | -| ------------------------------------------------------------------- | ------------------------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| options | object | false | Value set during `init`. | Optional parameters as described in [common options](#common-api-options). | -| options.scopes | string

OR

string[] | false | Value set during `init`.

OR

`guest_read` | Access scopes you're requesting. This can be a single scope, or an array of scopes.

Currently supported scopes are:
`guest_read`, `accounts_read`, `points_read`, `point_transactions_read`, `transactions_read`, `transactions_write`, `expense_claims_read`, `categories_read`, `investment_accounts_read`, `investment_transactions_read`, `notifications_read`, `request_refresh`, `life_insurance_read`. | -| options.redirectUri | string | false | Value set during `init`. | OAuth redirection URI, refer [here](https://www.oauth.com/oauth2-servers/redirect-uris/) for more details.

NOTE: This function will throw an error if this value is undefined and no default value was provided in the [init options](?id=api-init_options). | -| options.state | string | false | Value set during `init`.

OR

Randomly generated [uuid](). | Refer [here](https://auth0.com/docs/protocols/oauth2/oauth-state) for more details.

NOTE: Make sure to set this value explicitly if your server generates an identifier for the OAuth authorization request so that you can use to acquire the access token after the OAuth redirect occurs. | -| 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.

NOTE: Set this value only if your server wish to use PKCE flow. | -| 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). | -| options.forceLogout | boolean | false | `false` | Force existing guest session to logout and call authorize with a clean state. | - -### authorizeUrl - -This method generates an URL for OAuth authorization that requires guest consent to access data via [Link API](https://getmoneytree.com/jp/link/about). See `authorize` API for authorization details. - -
Usage:
- -```javascript -mtLinkSdk.authorizeUrl(options); -``` - -This API has exactly the same parameters as `authorize`, the only difference being that it returns an URL instead of opening immediately with `window.open`. - -### onboard - -The onboard API allows a new guest to get onboard faster without having to go through the registration process. All you have to do is provide an emai address and pass the same options parameter as the [authorize](#authorize) function. We will display a consent screen explaining the access requests and applicable scopes. Once the guest consents, a new Moneytree account will be created on their behalf and authorization is completed. Resulting behavior will be the same as the [authorize](#authorize) redirection flow. - -Onboard will force any current guest session to logout, hence you do not have to call [logout](#logout) manually to ensure a clean state. - -If an account with this email address already exists we will redirect the guest to the login screen. - -NOTE: - -
  • You must call `init` before using this API.
  • -
  • For legal reasons, you will have to set up your app's terms and conditions link to use the onboard API. Please ask your Moneytree representative for more details.
  • - -
    Usage:
    - -```javascript -mtLinkSdk.onboard(options); -``` - -| Parameter | Type | Required | Default Value | Description | -| ------------- | ------ | -------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| options | object | false | Value set during `init`. | Optional parameters.

    Most options are the same as the [authorize method](#authorize) options and [common options](#common-api-options) with a few exceptions.

    Unsupported options from [authorize](#authorize) and [common options](#common-api-options) are:
  • forceLogout
  • authAction
  • showAuthToggle
  • showRememberMe
  • | -| 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.

    NOTE: SDK will throw an error if both values here and from the [init options](?id=api-init_options) are undefined. | - -### onboardUrl - -This method generates a URL for guest onboarding. See the `onboard` API for more information on onboarding. - -
    Usage:
    - -```javascript -mtLinkSdk.onboardUrl(options); -``` - -This API has exactly the same parameters as `onboard`, the only difference being that it returns an URL instead of opening immediately with `window.open`. - -### exchangeToken - -Use this function to exchange an authorization `code` for a token. You can optionally pass `code` via options parameter, otherwise it will automatically extract the `code` URL parameter of the current URL. - -The `code` can be used only once. The SDK does not store it internally, you have to store it in your application. +The complete list of SDK functions is: -Refer [here](https://www.oauth.com/oauth2-servers/pkce/authorization-code-exchange/) for more details. +* [`init`](/types/classes/MtLinkSdk.html#init ':ignore') +* [`setSamlSubjectId`](/types/classes/MtLinkSdk.html#setSamlSubjectId ':ignore') +* [`authorize`](/types/classes/MtLinkSdk.html#authorize ':ignore') +* [`authorizeUrl`](/types/classes/MtLinkSdk.html#authorizeUrl ':ignore') +* [`onboard`](/types/classes/MtLinkSdk.html#onboard ':ignore') +* [`onboardUrl`](/types/classes/MtLinkSdk.html#onboardUrl ':ignore') +* [`exchangeToken`](/types/classes/MtLinkSdk.html#exchangeToken ':ignore') +* [`tokenInfo`](/types/classes/MtLinkSdk.html#tokenInfo ':ignore') +* [`logout`](/types/classes/MtLinkSdk.html#logout ':ignore') +* [`logoutUrl`](/types/classes/MtLinkSdk.html#logoutUrl ':ignore') +* [`openService`](/types/classes/MtLinkSdk.html#openService ':ignore') +* [`openServiceUrl`](/types/classes/MtLinkSdk.html#openServiceUrl ':ignore') +* [`requestLoginLink`](/types/classes/MtLinkSdk.html#requestLoginLink ':ignore') | -
    Usage:
    +Below are examples of common use cases. -One way to use this API is by calling it on your redirection page. For example, if `authorize` redirects to `https://yourapp.com/callback?code=somecode`, you can call this function in the script loaded on that redirection page and the client library will automatically extract the code to exchange for a token. - -Alternatively, you can extract the `code` manually from the redirect URL and pass it to this function via the options object yourself. +### Authorize user & get access token ```javascript -const token = await mtLinkSdk.exchangeToken(options); -token.access_token; // access token -token.refresh_token; // refresh token -token.token_type; // token type -token.created_at: // created at in seconds -token.expires_in; // expiry in seconds -token.scope; // scope of the token -``` - -| Parameter | Type | Required | Default Value | Description | -| -------------------- | ------ | -------- | ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| options | object | false | Value set during `init`. | Optional parameters. | -| options.code | string | false | Value from browser URL | Code from OAuth redirection used to exchange for a token, SDK will try to extract it from the browser URL if none is provided.

    NOTE: SDK will throw an error if no value is provided here and the client library failed to extract it from browser URL. | -| options.codeVerifier | string | false | | If you pass a `codeChallenge` option during the `authorize` or `onboard` call and wish to exchange the token on the client side application, make sure to set the code verifier used to generate the said `codeChallenge` here. | -| options.redirectUri | string | false | Value set during `init`. | Make sure the value of `redirectUri` here is the same redirectUri value used during the `authorize` or `onboard` call.

    NOTE: The SDK will throw an error if both this parameter and the default value from the [init options](?id=api-init_options) are undefined. | - -### tokenInfo - -You can validate a token or get guest or resource server information related to the token by calling this API. - -NOTE: This function will throw an error if the token has expired. - -
    Usage:
    +import mtLinkSdk from '@moneytree/mt-link-javascript-sdk'; -```javascript -const tokenInfo = await mtLinkSdk.tokenInfo(token); -tokenInfo.iat; // token creation timestamp, -tokenInfo.exp; // token expiration timestamp, -tokenInfo.sub; // guest uid or null, -tokenInfo.scope; // string with space separated scopes -tokenInfo.client_id; // application client id or null -tokenInfo.app; // application related information or null -tokenInfo.app.name; // application name -tokenInfo.app.is_mt; // is moneytree client (internal usage) -tokenInfo.guest; // guest related information or null -tokenInfo.guest.email; // guest email if available -tokenInfo.guest.country; // guest country -tokenInfo.guest.currency; // guest currency, -tokenInfo.guest.lang; // guest language +// initialize SDK with application information +mtLinkSdk.init('my-client-id', { + redirectUri: 'https://localhost:9000', + scopes: ['guest_read', 'accounts_read', 'transactions_read'] +}); +// start authorization flow +// If the user is not logged in yet this will prompt them to login +// If the user has not granted consent yet this will prompt them to grant consent +// if the user is logged in and has already granted consent this redirects immediately with an authorization code +mtLinkSdk.authorize(); +// after redirect from moneytree back to your app's redirectUri +const token = mtLinkSdk.exchangeToken(); +const tokenInfo = mtLinkSdk.tokenInfo(token.access_token) ``` -| Parameter | Type | Required | Default Value | Description | -| --------- | ------ | -------- | ------------- | ------------------------------- | -| token | string | true | | Token you wish to get info for. | - -### logout +You can also use the [authorizeUrl](/types/classes/MtLinkSdk.html#authorizeUrl ':ignore') method to generate the authorization url without opening it immetiately. -Logout current guest from Moneytree. - -
    Usage:
    +### Passwordless Onboarding ```javascript -mtLinkSdk.logout(options); -``` - -| Parameter | Type | Required | Default Value | Description | -| --------- | ------ | -------- | ------------------------ | ----------------------------------------------------------------------------------- | -| options | object | false | Value set during `init`. | Optional parameters. Includes all options in [common options](#common-api-options). | - -### openService - -This is a method to open various services provided by Moneytree such as Moneytree account settings, Vault etc. +import mtLinkSdk from '@moneytree/mt-link-javascript-sdk'; -NOTE: calling this API before calling `init` will open the services view without branding (company logo etc.) - -
    Usage:
    - -```javascript -mtLinkSdk.openService(serviceId, options); +// initialize SDK with application information +mtLinkSdk.init('my-client-id', { + redirectUri: 'https://localhost:9000', + scopes: ['guest_read', 'accounts_read', 'transactions_read'] +}); +// Start onboarding flow for a new user +// After the user completes onboarding this redirects with an authorization code +// If a Monetyree user with this email already exists this prompts the user to login & grant consent (similar to authorize) +mtLinkSdk.onboard({ email: 'user@test.com'}); +// after redirect from moneytree back to your app's redirectUri +const token = mtLinkSdk.exchangeToken(); ``` -| Parameter | Type | Required | Default Value | Description | -| -------------------------- | ---------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| serviceId | `vault`, `myaccount`, `link-kit` | true | | Open a service by Id, current supported services are:
  • `vault` - Manage your financial institution credentials.
  • `myaccount` - Manage your Moneytree account settings.
  • `link-kit` - View all your financial data.

    NOTE: This function will throw an error if you do not specify a valid service ID. | -| options | object | false | Value set during `init`. | Optional parameters. Includes all options in [common options](#common-api-options). | -| 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:
  • [Open Vault Services Page](#open-vault-services-page)
  • [Open Vault Service Connection Page](#open-vault-service-connection-page)
  • [Open Vault Service Setting Page](#open-vault-service-setting-page)
  • [Open Vault Customer Support Page](#open-vault-customer-support-page)


  • NOTE: The serviceId must be `vault` to enable this option. | -| 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:
  • [Open MyAccount Page](#open-myaccount-page)


  • NOTE: The serviceId must be `myaccount` to enable this option. | - -### logoutUrl +You can also use the [onboardUrl](/types/classes/MtLinkSdk.html#onboardUrl ':ignore') method to generate the onboard url without opening it immetiately. -This method generates a URL to log out the guest. See the `logout` API for details on logout. - -
    Usage:
    +### Logout ```javascript -mtLinkSdk.logoutUrl(options); -``` - -This API has exactly the same parameters as `logout`, the only difference being that it returns an URL instead of opening immediately with `window.open`. +import mtLinkSdk from '@moneytree/mt-link-javascript-sdk'; -#### Open Vault Services Page +// initialize SDK with application information +mtLinkSdk.init('my-client-id', { + redirectUri: 'https://localhost:9000', + scopes: ['guest_read', 'accounts_read', 'transactions_read'] +}); -It has to include these properties of `options` below when calling [openService](#openservice) API. - -NOTE: This scenario only works when serviceId is `vault`. - -
    Usage:
    - -```javascript -mtLinkSdk.openService('vault', { view: 'services-list', type: 'bank', group: 'grouping_bank', search: 'japan' }); +// logout the user +mtLinkSdk.logout(); ``` -| Parameter | Type | Required | Default Value | Description | -| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------- | --------------------------------------- | -| serviceId | `vault` | true | | Open a Vault service. | -| options.view | `services-list` | true | | Assign to open services page. | -| options.type | `bank` (personal bank),
    `credit_card` (personal credit card),
    `stored_value` (electronic money), `point` (loyalty point),
    `corporate` (corporate bank or card) | false | | Filter the services by type. | -| options.group | `grouping_bank`, `grouping_bank_credit_card`, `grouping_bank_dc_card`, `grouping_corporate_credit_card`, `grouping_credit_card`, `grouping_credit_coop`, `grouping_credit_union`, `grouping_dc_pension_plan`, `grouping_debit_card`, `grouping_digital_money`, `grouping_ja_bank`, `grouping_life_insurance`, `grouping_point`, `grouping_regional_bank`, `grouping_stock`, `grouping_testing` | false | | Filter the services by group. | -| options.search | string | false | | Filter the services by the search term. | - -#### Open Vault Service Connection Page +You can also use the [logoutUrl](/types/classes/MtLinkSdk.html#logoutUrl ':ignore') method to generate the logout url without redirecting the user. -It has to include these properties of `options` below when calling [openService](#openservice) API. +### Open Services -NOTE: This scenario only works when serviceId is `vault`. +With the [openService](/types/classes/MtLinkSdk.html#openService ':ignore') function you can open Moneytree services directly from your app. +Alternatively, you can also use [openServiceUrl](/types/classes/MtLinkSdk.html#openServiceUrl ':ignore') to generate the url without opening it immetiately. -
    Usage:
    +#### Open Vault ```javascript -mtLinkSdk.openService('vault', { view: 'service-connection', entityKey: 'yucho_bank' }); -``` +import mtLinkSdk from '@moneytree/mt-link-javascript-sdk'; -| Parameter | Type | Required | Default Value | Description | -| ----------------- | -------------------- | -------- | ------------- | --------------------------------------------------------------------------------------------------------------------- | -| serviceId | `vault` | true | | Open a Vault service | -| options.view | `service-connection` | true | | Assign to open service connection page | -| options.entityKey | string | true | | Service entity key

    NOTE: Top page of the Vault would be shown if `entityKey` is invalid. | - -#### Open Vault Service Setting Page - -It has to include these properties of `options` below when calling [openService](#openservice) API. - -NOTE: This scenario only works when serviceId is `vault`. - -
    Usage:
    - -```javascript -mtLinkSdk.openService('vault', { view: 'connection-setting', credentialId: '123456' }); -``` - -| Parameter | Type | Required | Default Value | Description | -| -------------------- | -------------------- | -------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------- | -| serviceId | `vault` | true | | Open a Vault service | -| options.view | `connection-setting` | true | | Assign to open connection setting page | -| options.credentialId | string | true | | Service credential Id

    NOTE: Top page of the Vault would be shown if the `credentialId` is invalid. | - -#### Open Vault Customer Support Page - -It has to include these properties of `options` below when calling [openService](#openservice) API. - -NOTE: This scenario only works when serviceId is `vault`. - -
    Usage:
    - -```javascript -mtLinkSdk.openService('vault', { view: 'customer-support' }); +// initialize SDK with application information +mtLinkSdk.init('my-client-id', { + redirectUri: 'https://localhost:9000', + scopes: ['guest_read', 'accounts_read', 'transactions_read'] +}); +// Open Vault on the services list page +// If the user is not logged in yet this will prompt them to login +// If the user has not granted consent yet this will prompt them to grant consent +mtLinkSdk.openService('vault', {view: 'services-list'}); ``` -| Parameter | Type | Required | Default Value | Description | -| ------------ | ------------------ | -------- | ------------- | ------------------------------------ | -| serviceId | `vault` | true | | Open a Vault service | -| options.view | `customer-support` | true | | Assign to open customer support page | - -#### Open MyAccount Page - -It has to include these properties of `options` below when calling [openService](#openservice) API. - -NOTE: This scenario only works when serviceId is `myaccount`. +Vault has serveral different views with different options for each, view the full documentation [here](/types/classes/MtLinkSdk.html#openService.openService-3 ':ignore'). -
    Usage:
    +#### Open MyAccount ```javascript -mtLinkSdk.openService('myaccount', { view: 'settings/update-email' }); -``` - -| Parameter | Type | Required | Default Value | Description | -| ------------ | ----------- | -------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| serviceId | `myaccount` | true | | Open MyAccount | -| options.view | string | false | `settings` (for mobile view)

    OR

    `settings/update-email` (for desktop view) | Directly go to the chosen page. Currently supported locations include:
  • `settings` - Main Moneytree account settings screen.
  • `settings/authorized-applications` - List of apps currently connected to Moneytree.
  • `settings/change-language` - Change Moneytree account language screen.
  • `settings/email-preferences` - Change Moneytree email preferences screen
  • `settings/delete-account` - Delete Moneytree account screen.
  • `settings/update-email` - Change Moneytree account email screen.
  • `settings/update-password` - Change Moneytree account password screen.

  • If no value is provided, it goes to the top page of MyAccount. | - -### openServiceUrl +import mtLinkSdk from '@moneytree/mt-link-javascript-sdk'; -This method can generate URLs for various services provided by Moneytree, such as Moneytree Account Settings and Vault. See the `openService` API for details on combining the various options. - -
    Usage:
    - -```javascript -mtLinkSdk.openServiceUrl(serviceId, options); +// initialize SDK with application information +mtLinkSdk.init('my-client-id', { + redirectUri: 'https://localhost:9000', + scopes: ['guest_read', 'accounts_read', 'transactions_read'] +}); +// Open MyAccount on the settings page +// If the user is not logged in yet this will prompt them to login +mtLinkSdk.openService('myaccount', {view: 'settings'}); ``` -This API has exactly the same parameters as `openService`, the only difference being that it returns an URL instead of opening immediately with `window.open`. +MyAccount has serveral different views with different options for each, view the full documentation [here](/types/classes/MtLinkSdk.html#openService.openService-2 ':ignore'). -### requestLoginLink - -Request for a 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 `loginLinkTo` parameter. - -
    Usage:
    +### Set identifier for SSO login flow ```javascript -mtLinkSdk.requestLoginLink(options); +// initialize SDK with application information +mtLinkSdk.init('my-client-id', { + redirectUri: 'https://localhost:9000', + scopes: ['guest_read', 'accounts_read', 'transactions_read'], + authMethod: 'sso' // configure SDK to use SSO for login +}); +// set application specific identifier for SSO login flow +// this identifier will be passed back to your SAML Identity Provider in the SAML AuthnRequest +mtLinkSdk.setSamlSubjectId('my-saml-subject-id'); +// Opens Vault, if the user is not logged in it will trigger the SAML SSO login flow and pass the SAML subject ID to the IdP +mtLinkSdk.openService('vault', {view: 'services-list'}); ``` -| Parameter | Type | Required | Default Value | Description | -| ------------------- | ------ | -------- | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| options | object | false | Value set during `init`. | Optional parameters. Includes all options in [common options](#common-api-options). | -| options.loginLinkTo | string | true | `settings` (for mobile view)

    OR

    `settings/update-email` (for desktop view) | Redirection to location after login, currently supported locations include:
  • `settings` - Main Moneytree account settings screen.
  • `settings/authorized-applications` - List of apps currently connected to Moneytree.
  • `settings/change-language` - Change Moneytree account language screen.
  • `settings/email-preferences` - Change Moneytree email preferences screen
  • `settings/delete-account` - Delete Moneytree account screen.
  • `settings/update-email` - Change Moneytree account email screen.
  • `settings/update-password` - Change Moneytree account password screen.
  • | -| options.email | string | true | Value set during `init`. | Login Link will be sent to this email.

    NOTE: This function will throw an error if both values here and from the [init options](?id=api-init_options) are undefined. | - -## Common API options - -These common options are used in multiple APIs. Instead of repeating the same options in every definition, they are documented here. - -NOTE: Since `options` are optional for each function call in the SDK, they will be read from the [init options](?id=api-init_options) by default if none are provided. - -| Parameter | Type | Required | Default Value | Description | -| ----------------------------------------------------------------- | ----------------- | -------- | --------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| options.email | string | false | Value set during `init`. | Email used to pre-fill the email field in login or sign up or form. | -| options.backTo | string | false | Value set during `init`. | A redirection URL for redirecting a guest back to in the following condition:
  • Guest clicks on `Back to [App Name]` button in any Moneytree screen.
  • Guest refuses to give consent to access permission in the consent screen.
  • Guest logs out from Moneytree via an app with this client id
  • Revoke an app's consent from settings screen opened via an app with this client id


  • NOTE: 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. | -| options.authAction | `login`, `signup` | false | Value set during `init`.

    OR

    `login` | Show login or sign up screen when a session does not exist during an `authorize` call. | -| options.showAuthToggle | boolean | false | Value set during `init`.

    OR

    `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`. | -| options.showRememberMe | boolean | false | Value set during `init`.

    OR

    `true` | If you wish to disable the `Stay logged in for 30 days` checkbox in the login screen, set this to `false`. | -| options.isNewTab | boolean | false | Value set during `init`.

    OR

    `false` | Call method and open/render in a new browser tab, by default all views open in the same tab. | -| options.authnMethod | string | | Value set during `init`. | Use different authentication methods. This can be a string with the following values:

    `sso`, `passwordless`, `credentials`. | -| options.sdkPlatform (private) | string | false | Generated by the SDK. | NOTE: this is for Moneytree internal use, please do not use it to avoid unintended behavior!

    Indicating sdk platform. | -| options.sdkVersion (private) | semver | false | Generated by the SDK. | NOTE: this is for Moneytree internal use, please do not use it to avoid unintended behavior!

    Indicating sdk version. | - ## Theming We support gray labelling some of the services offered by Moneytree, please contact your Moneytree representative for more information.