Skip to content

Commit c82346c

Browse files
authored
Merge pull request #42 from mt-kenny/test/remove-default-code-verifier
[AK-414] Make PKCE as optional
2 parents b4912d1 + b7de0ab commit c82346c

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

dist/index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ mtLinkSdk.init(clientId, options);
6767
### authorize
6868

6969
OAuth authorization method to request guest consent to access data via the [Link API](https://getmoneytree.com/au/link/about).<br /><br />
70+
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.<br /><br />
7071
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.)<br /><br />
7172
You may also choose to display the sign up form by default by passing the [authAction option](#authorize_option_auth_action).
7273

@@ -84,7 +85,7 @@ mtLinkSdk.authorize(options);
8485
| options.scopes | string <p><strong>OR</strong></p> string[] | false | Value set during `init`.<p><strong>OR</strong></p>`guest_read` | Access scopes you're requesting. This can be a single scope, or an array of scopes.<br /><br />Currently supported scopes are:<br />`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`. |
8586
| options.redirectUri | string | false | Value set during `init`. | OAuth redirection URI, refer [here](https://www.oauth.com/oauth2-servers/redirect-uris/) for more details.<br /><br /><strong>NOTE:</strong> This function will throw an error if this value is undefined <strong>and</strong> no default value was provided in the [init options](?id=api-init_options). |
8687
| options.state | string | false | Value set during `init`.<p><strong>OR</strong></p>Randomly generated [uuid](<https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)>). | Refer [here](https://auth0.com/docs/protocols/oauth2/oauth-state) for more details.<br /><br /><strong>NOTE:</strong> 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. |
87-
| options.codeVerifier | string | false | Value set during `init`.<p><strong>OR</strong></p>Randomly generated [uuid](<https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_4_(random)>). | 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.<p>We only support SHA256, therefore this `codeVerifier` will be used to generate the `code_challenge` 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> 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. |
88+
| options.codeVerifier | string | false | Value set during `init`. | We only support SHA256, therefore this `codeVerifier` will be used to generate the `code_challenge` 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> 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. |
8889
| <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. |
8990
| 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. |
9091

src/api/authorize.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ export default function authorize(
6767
response_type: 'code',
6868
scope: constructScopes(scopes),
6969
redirect_uri: redirectUri,
70-
code_challenge: codeChallenge,
71-
code_challenge_method: codeVerifier && 'S256',
70+
code_challenge: codeChallenge || undefined,
71+
code_challenge_method: codeVerifier ? 'S256' : undefined,
7272
state,
7373
country,
7474
locale,

src/api/onboard.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ export default function onboard(storedOptions: StoredOptions, options: OnboardOp
8484
response_type: 'code',
8585
scope: constructScopes(scopes),
8686
redirect_uri: redirectUri,
87-
code_challenge: codeChallenge,
88-
code_challenge_method: codeVerifier && 'S256',
87+
code_challenge: codeChallenge || undefined,
88+
code_challenge_method: codeVerifier ? 'S256' : undefined,
8989
state,
9090
country,
9191
locale,

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class MtLinkSdk {
3030
public storedOptions: StoredOptions = {
3131
mode: 'production',
3232
state: storage.get('state') || uuid(),
33-
codeVerifier: storage.get('codeVerifier') || uuid(),
33+
codeVerifier: storage.get('codeVerifier') || '',
3434
};
3535

3636
public init(clientId: string, options: InitOptions = {}): void {

0 commit comments

Comments
 (0)