Skip to content

Commit

Permalink
Improve documentation, remove incorrect statement, only use options f…
Browse files Browse the repository at this point in the history
…or check
  • Loading branch information
ewanharris committed Aug 15, 2022
1 parent 6be3459 commit 9e62367
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions src/Auth0Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ export class Auth0Client {
private readonly isAuthenticatedCookieName: string;
private readonly nowProvider: () => number | Promise<number>;
private readonly httpTimeoutMs: number;
private readonly useRefreshTokensFallback: boolean;

cacheLocation: CacheLocation;
private worker: Worker;
Expand Down Expand Up @@ -307,9 +306,6 @@ export class Auth0Client {
}

this.customOptions = getCustomInitialOptions(options);

this.useRefreshTokensFallback =
this.options.useRefreshTokensFallback === true;
}

private _url(path: string) {
Expand Down Expand Up @@ -817,7 +813,7 @@ export class Auth0Client {
* remaining before expiration, return the token. Otherwise, attempt
* to obtain a new token.
*
* A new token will be obtained either by opening an iframe (if `useRefreshTokensFallback` is true) or a
* A new token will be obtained either by opening an iframe or a
* refresh token (if `useRefreshTokens` is `true`).
* If iframes are used, opens an iframe with the `/authorize` URL
Expand All @@ -829,7 +825,7 @@ export class Auth0Client {
* 'refresh_token' grant. If no refresh token is available to make this call,
* the SDK will only fall back to using an iframe to the '/authorize' URL if
* the `useRefreshTokensFallback` setting has been set to `true`. By default this
* setting is false.
* setting is `false`.
*
* This method may use a web worker to perform the token call if the in-memory
* cache is used.
Expand Down Expand Up @@ -1193,7 +1189,7 @@ export class Auth0Client {
// and useRefreshTokensFallback was explicitly enabled
// fallback to an iframe
if ((!cache || !cache.refresh_token) && !this.worker) {
if (this.useRefreshTokensFallback) {
if (this.options.useRefreshTokensFallback) {
return await this._getTokenFromIFrame(options);
}

Expand Down Expand Up @@ -1252,7 +1248,7 @@ export class Auth0Client {
// and useRefreshTokensFallback is explicitly enabled. Fallback to an iframe.
(e.message &&
e.message.indexOf(INVALID_REFRESH_TOKEN_ERROR_MESSAGE) > -1)) &&
this.useRefreshTokensFallback
this.options.useRefreshTokensFallback
) {
return await this._getTokenFromIFrame(options);
}
Expand Down
4 changes: 2 additions & 2 deletions src/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,11 @@ export interface Auth0ClientOptions extends BaseLoginOptions {

/**
* If true, fallback to the technique of using a hidden iframe and the `authorization_code` grant with `prompt=none` when unable to use refresh tokens. If false, the iframe fallback is not used and
* errors relating to a failed Refresh Grant should be handled appropriately by having the user to login. The default setting is `false`.
* errors relating to a failed `refresh_token` grant should be handled appropriately. The default setting is `false`.
*
* **Note**: There might be situations where doing silent auth with a Web Message response from an iframe is not possible,
* like when you're serving your application from the file system or a custom protocol (like in a Desktop or Native app).
* In situations like this you can disable the iframe fallback and handle the failed Refresh Grant and prompt the user to login interactively with `loginWithRedirect` or `loginWithPopup`."
* In situations like this you can disable the iframe fallback and handle the failed `refresh_token` grant and prompt the user to login interactively with `loginWithRedirect` or `loginWithPopup`."
*
* E.g. Using the `file:` protocol in an Electron application does not support that legacy technique.
*
Expand Down

0 comments on commit 9e62367

Please sign in to comment.