Socket
Socket
Sign inDemoInstall

@auth0/auth0-spa-js

Package Overview
Dependencies
Maintainers
41
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@auth0/auth0-spa-js - npm Package Compare versions

Comparing version 1.13.6 to 1.14.0

18

CHANGELOG.md
# Change Log
## [v1.14.0](https://github.com/auth0/auth0-spa-js/tree/v1.14.0) (2021-03-22)
[Full Changelog](https://github.com/auth0/auth0-spa-js/compare/v1.13.6...v1.14.0)
**Added**
- feat(loginWithRedirect): add redirectMethod option [\#717](https://github.com/auth0/auth0-spa-js/pull/717) ([slaywell](https://github.com/slaywell))
- Export errors for type checking [\#716](https://github.com/auth0/auth0-spa-js/pull/716) ([adamjmcgrath](https://github.com/adamjmcgrath))
**Changed**
- Add screen_hint parameter to BaseLoginOptions [\#721](https://github.com/auth0/auth0-spa-js/pull/721) ([damieng](https://github.com/damieng))
**Fixed**
- Updated minor syntax, to allow for TypeScript compiler to be happier [\#714](https://github.com/auth0/auth0-spa-js/pull/714) ([kachihro](https://github.com/kachihro))
- Revert [SDK-2183] Add warning when requested scopes differ from retrieved scopes [\#712](https://github.com/auth0/auth0-spa-js/pull/712) ([frederikprijck](https://github.com/frederikprijck))
## [v1.13.6](https://github.com/auth0/auth0-spa-js/tree/v1.13.6) (2021-01-07)

@@ -4,0 +22,0 @@

8

dist/typings/Auth0Client.d.ts

@@ -1,2 +0,2 @@

import { Auth0ClientOptions, RedirectLoginOptions, PopupLoginOptions, PopupConfigOptions, GetUserOptions, GetIdTokenClaimsOptions, RedirectLoginResult, GetTokenSilentlyOptions, GetTokenWithPopupOptions, LogoutOptions, CacheLocation, LogoutUrlOptions, User } from './global';
import { Auth0ClientOptions, RedirectLoginOptions, PopupLoginOptions, PopupConfigOptions, GetUserOptions, GetIdTokenClaimsOptions, RedirectLoginResult, GetTokenSilentlyOptions, GetTokenWithPopupOptions, LogoutOptions, CacheLocation, LogoutUrlOptions, User, IdToken } from './global';
/**

@@ -66,6 +66,6 @@ * Auth0 SDK for Single Page Applications using [Authorization Code Grant Flow with PKCE](https://auth0.com/docs/api-auth/tutorials/authorization-code-grant-pkce).

*
* @typeparam TUser The type to return, has to extend {@link User}. Defaults to {@link User} when omitted.
* @typeparam TUser The type to return, has to extend {@link User}.
* @param options
*/
getUser<TUser extends User = User>(options?: GetUserOptions): Promise<TUser | undefined>;
getUser<TUser extends User>(options?: GetUserOptions): Promise<TUser | undefined>;
/**

@@ -84,3 +84,3 @@ * ```js

*/
getIdTokenClaims(options?: GetIdTokenClaimsOptions): Promise<import("./global").IdToken>;
getIdTokenClaims(options?: GetIdTokenClaimsOptions): Promise<IdToken>;
/**

@@ -87,0 +87,0 @@ * ```js

@@ -0,1 +1,4 @@

/**
* Thrown when network requests to the Auth server fail.
*/
export declare class GenericError extends Error {

@@ -10,2 +13,6 @@ error: string;

}
/**
* Thrown when handling the redirect callback fails, will be one of Auth0's
* Authentication API's Standard Error Responses: https://auth0.com/docs/api/authentication?javascript#standard-error-responses
*/
export declare class AuthenticationError extends GenericError {

@@ -16,5 +23,12 @@ state: string;

}
/**
* Thrown when silent auth times out (usually due to a configuration issue) or
* when network requests to the Auth server timeout.
*/
export declare class TimeoutError extends GenericError {
constructor();
}
/**
* Error thrown when the login popup times out (if the user does not complete auth)
*/
export declare class PopupTimeoutError extends TimeoutError {

@@ -21,0 +35,0 @@ popup: Window;

@@ -35,2 +35,10 @@ /**

/**
* Provides a hint to Auth0 as to what flow should be displayed.
* The default behavior is to show a login page but you can override
* this by passing 'signup' to show the signup page instead.
*
* This only affects the New Universal Login Experience.
*/
screen_hint?: string;
/**
* The user's email address or other identifier. When your app knows

@@ -61,2 +69,13 @@ * which user is trying to authenticate, you can provide this parameter

/**
* The Id of an organization to log in to (Organizations is currently a Closed Beta).
*
* This will specify an `organization` parameter in your user's login request and will add a step to validate
* the `org_id` claim in your user's ID Token.
*/
organization?: string;
/**
* The Id of an invitation to accept. This is available from the user invitation URL that is given when participating in a user invitation flow.
*/
invitation?: string;
/**
* If you need to send custom parameters to the Authorization Server,

@@ -108,2 +127,4 @@ * make sure to use the original parameter name.

* The default setting is `memory`.
*
* Read more about [changing storage options in the Auth0 docs](https://auth0.com/docs/libraries/auth0-single-page-app-sdk#change-storage-options)
*/

@@ -195,2 +216,6 @@ cacheLocation?: CacheLocation;

fragment?: string;
/**
* Used to select the window.location method used to redirect
*/
redirectMethod?: 'replace' | 'assign';
}

@@ -197,0 +222,0 @@ export interface RedirectLoginResult {

@@ -17,1 +17,2 @@ import 'core-js/es/string/starts-with';

export { Auth0Client };
export { GenericError, AuthenticationError, TimeoutError, PopupTimeoutError } from './errors';

@@ -5,5 +5,1 @@ /**

export declare const getUniqueScopes: (...scopes: string[]) => string;
/**
* @ignore
*/
export declare const getMissingScope: (originalScope?: string, comparingScope?: string) => string;

@@ -1,2 +0,2 @@

declare const _default: "1.13.6";
declare const _default: "1.14.0";
export default _default;

@@ -6,3 +6,3 @@ {

"license": "MIT",
"version": "1.13.6",
"version": "1.14.0",
"main": "dist/lib/auth0-spa-js.cjs.js",

@@ -9,0 +9,0 @@ "types": "dist/typings/index.d.ts",

@@ -188,2 +188,10 @@ # @auth0/auth0-spa-js

You can redirect users back to your app after logging out. This URL must appear in the **Allowed Logout URLs** setting for the app in your [Auth0 Dashboard](https://manage.auth0.com):
```js
auth0.logout({
returnTo: 'https://your.custom.url.example.com/'
});
```
### Data caching options

@@ -233,2 +241,65 @@

### Organizations (Closed Beta)
Organizations is a set of features that provide better support for developers who build and maintain SaaS and Business-to-Business (B2B) applications.
Using Organizations, you can:
- Represent teams, business customers, partner companies, or any logical grouping of users that should have different ways of accessing your applications, as organizations.
- Manage their membership in a variety of ways, including user invitation.
- Configure branded, federated login flows for each organization.
- Implement role-based access control, such that users can have different roles when authenticating in the context of different organizations.
- Build administration capabilities into your products, using Organizations APIs, so that those businesses can manage their own organizations.
Note that Organizations is currently only available to customers on our Enterprise and Startup subscription plans.
#### Log in to an organization
Log in to an organization by specifying the `organization` parameter when setting up the client:
```js
createAuth0Client({
domain: '<AUTH0_DOMAIN>',
client_id: '<AUTH0_CLIENT_ID>',
redirect_uri: '<MY_CALLBACK_URL>',
organization: '<MY_ORG_ID>'
});
```
You can also specify the organization when logging in:
```js
// Using a redirect
client.loginWithRedirect({
organization: '<MY_ORG_ID>'
});
// Using a popup window
client.loginWithPopup({
organization: '<MY_ORG_ID>'
});
```
#### Accept user invitations
Accept a user invitation through the SDK by creating a route within your application that can handle the user invitation URL, and log the user in by passing the `organization` and `invitation` parameters from this URL. You can either use `loginWithRedirect` or `loginWithPopup` as needed.
```js
const url = new URL(invitationUrl);
const params = new URLSearchParams(url.search);
const organization = params.get('organization');
const invitation = params.get('invitation');
if (organization && invitation) {
client.loginWithRedirect({
organization,
invitation
});
}
```
### Advanced options

@@ -235,0 +306,0 @@

import { TokenEndpointOptions } from './global';
import { DEFAULT_AUTH0_CLIENT } from './constants';
import { getJSON } from './http';
import { getMissingScope } from './scope';

@@ -25,3 +24,3 @@ export type TokenEndpointResponse = {

) {
const result = await getJSON<TokenEndpointResponse>(
return await getJSON<TokenEndpointResponse>(
`${baseUrl}/oauth/token`,

@@ -43,14 +42,2 @@ timeout,

);
const missingScope = getMissingScope(scope, result.scope);
if (missingScope.length) {
console.warn(
`The requested scopes (${scope}) are different from the scopes of the retrieved token (${result.scope}). This could mean that your access token may not include all the scopes that you expect. It is advised to resolve this by either:
- Removing \`${missingScope}\` from the scope when requesting a new token.
- Ensuring \`${missingScope}\` is returned as part of the requested token's scopes.`
);
}
return result;
}

@@ -59,3 +59,4 @@ import Lock from 'browser-tabs-lock';

LogoutUrlOptions,
User
User,
IdToken
} from './global';

@@ -423,6 +424,6 @@

*
* @typeparam TUser The type to return, has to extend {@link User}. Defaults to {@link User} when omitted.
* @typeparam TUser The type to return, has to extend {@link User}.
* @param options
*/
public async getUser<TUser extends User = User>(
public async getUser<TUser extends User>(
options: GetUserOptions = {}

@@ -457,3 +458,3 @@ ): Promise<TUser | undefined> {

*/
public async getIdTokenClaims(options: GetIdTokenClaimsOptions = {}) {
public async getIdTokenClaims(options: GetIdTokenClaimsOptions = {}): Promise<IdToken> {
const audience = options.audience || this.options.audience || 'default';

@@ -485,4 +486,5 @@ const scope = getUniqueScopes(this.defaultScope, this.scope, options.scope);

public async loginWithRedirect(options: RedirectLoginOptions = {}) {
const url = await this.buildAuthorizeUrl(options);
window.location.assign(url);
const { redirectMethod, ...urlOptions } = options;
const url = await this.buildAuthorizeUrl(urlOptions);
window.location[redirectMethod || 'assign'](url);
}

@@ -834,4 +836,4 @@

options.redirect_uri ||
this.options.redirect_uri ||
window.location.origin
this.options.redirect_uri ||
window.location.origin
);

@@ -838,0 +840,0 @@

@@ -0,1 +1,4 @@

/**
* Thrown when network requests to the Auth server fail.
*/
export class GenericError extends Error {

@@ -19,2 +22,6 @@ constructor(public error: string, public error_description: string) {

/**
* Thrown when handling the redirect callback fails, will be one of Auth0's
* Authentication API's Standard Error Responses: https://auth0.com/docs/api/authentication?javascript#standard-error-responses
*/
export class AuthenticationError extends GenericError {

@@ -33,2 +40,6 @@ constructor(

/**
* Thrown when silent auth times out (usually due to a configuration issue) or
* when network requests to the Auth server timeout.
*/
export class TimeoutError extends GenericError {

@@ -42,2 +53,5 @@ constructor() {

/**
* Error thrown when the login popup times out (if the user does not complete auth)
*/
export class PopupTimeoutError extends TimeoutError {

@@ -44,0 +58,0 @@ constructor(public popup: Window) {

@@ -12,2 +12,3 @@ /**

display?: 'page' | 'popup' | 'touch' | 'wap';
/**

@@ -20,2 +21,3 @@ * - `'none'`: do not prompt user for login or consent on reauthentication

prompt?: 'none' | 'login' | 'consent' | 'select_account';
/**

@@ -27,2 +29,3 @@ * Maximum allowable elasped time (in seconds) since authentication.

max_age?: string | number;
/**

@@ -33,2 +36,3 @@ * The space-separated list of language tags, ordered by preference.

ui_locales?: string;
/**

@@ -38,3 +42,13 @@ * Previously issued ID Token.

id_token_hint?: string;
/**
* Provides a hint to Auth0 as to what flow should be displayed.
* The default behavior is to show a login page but you can override
* this by passing 'signup' to show the signup page instead.
*
* This only affects the New Universal Login Experience.
*/
screen_hint?: string;
/**
* The user's email address or other identifier. When your app knows

@@ -47,3 +61,5 @@ * which user is trying to authenticate, you can provide this parameter

login_hint?: string;
acr_values?: string;
/**

@@ -55,2 +71,3 @@ * The default scope to be used on authentication requests.

scope?: string;
/**

@@ -60,2 +77,3 @@ * The default audience to be used for requesting API access.

audience?: string;
/**

@@ -67,4 +85,17 @@ * The name of the connection configured for your application.

connection?: string;
/**
* The Id of an organization to log in to (Organizations is currently a Closed Beta).
*
* This will specify an `organization` parameter in your user's login request and will add a step to validate
* the `org_id` claim in your user's ID Token.
*/
organization?: string;
/**
* The Id of an invitation to accept. This is available from the user invitation URL that is given when participating in a user invitation flow.
*/
invitation?: string;
/**
* If you need to send custom parameters to the Authorization Server,

@@ -119,2 +150,4 @@ * make sure to use the original parameter name.

* The default setting is `memory`.
*
* Read more about [changing storage options in the Auth0 docs](https://auth0.com/docs/libraries/auth0-single-page-app-sdk#change-storage-options)
*/

@@ -213,2 +246,6 @@ cacheLocation?: CacheLocation;

fragment?: string;
/**
* Used to select the window.location method used to redirect
*/
redirectMethod?: 'replace' | 'assign';
}

@@ -215,0 +252,0 @@

@@ -1,2 +0,8 @@

import createAuth0Client, { Auth0Client } from './index';
import createAuth0Client, {
Auth0Client,
GenericError,
AuthenticationError,
TimeoutError,
PopupTimeoutError
} from './index';

@@ -10,3 +16,7 @@ /**

wrapper.createAuth0Client = createAuth0Client;
wrapper.GenericError = GenericError;
wrapper.AuthenticationError = AuthenticationError;
wrapper.TimeoutError = TimeoutError;
wrapper.PopupTimeoutError = PopupTimeoutError;
export default wrapper;

@@ -26,1 +26,7 @@ import 'core-js/es/string/starts-with';

export { Auth0Client };
export {
GenericError,
AuthenticationError,
TimeoutError,
PopupTimeoutError
} from './errors';

@@ -12,16 +12,1 @@ /**

};
/**
* @ignore
*/
export const getMissingScope = (
originalScope: string = '',
comparingScope: string = ''
) => {
const originalScopes = originalScope.split(/\s+/);
const comparingScopes = comparingScope.split(/\s+/);
return originalScopes
.filter(scope => !comparingScopes.includes(scope))
.join(' ');
};

@@ -1,1 +0,1 @@

export default '1.13.6';
export default '1.14.0';

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc