Socket
Socket
Sign inDemoInstall

@auth0/auth0-spa-js

Package Overview
Dependencies
Maintainers
43
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.16.1 to 1.17.0

12

CHANGELOG.md
# Change Log
## [v1.17.0](https://github.com/auth0/auth0-spa-js/tree/v1.17.0) (2021-08-03)
[Full Changelog](https://github.com/auth0/auth0-spa-js/compare/v1.16.1...v1.17.0)
**Added**
- Add `useFormData` to enable `application/x-www-form-urlencoded` requests [\#768](https://github.com/auth0/auth0-spa-js/pull/768) ([stevehobbsdev](https://github.com/stevehobbsdev))
**Changed**
- Allow providing a `domain` that includes `http` or `https`. [\#768](https://github.com/auth0/auth0-spa-js/pull/768) ([stevehobbsdev](https://github.com/stevehobbsdev))
## [v1.16.1](https://github.com/auth0/auth0-spa-js/tree/v1.16.1) (2021-07-07)

@@ -4,0 +16,0 @@

2

dist/typings/api.d.ts

@@ -9,2 +9,2 @@ import { TokenEndpointOptions } from './global';

};
export declare function oauthToken({ baseUrl, timeout, audience, scope, auth0Client, ...options }: TokenEndpointOptions, worker?: Worker): Promise<TokenEndpointResponse>;
export declare function oauthToken({ baseUrl, timeout, audience, scope, auth0Client, useFormData, ...options }: TokenEndpointOptions, worker?: Worker): Promise<TokenEndpointResponse>;

@@ -184,2 +184,10 @@ import { ICache } from './cache';

sessionCheckExpiryDays?: number;
/**
* When true, data to the token endpoint is transmitted as x-www-form-urlencoded data instead of JSON. The default is false, but will default to true in a
* future major version.
*
* **Note:** Setting this to `true` may affect you if you use Auth0 Rules and are sending custom, non-primative data. If you enable this, please verify that your Auth0 Rules
* continue to work as intended.
*/
useFormData?: boolean;
}

@@ -391,2 +399,3 @@ /**

auth0Client: any;
useFormData?: boolean;
[key: string]: any;

@@ -393,0 +402,0 @@ }

import { FetchOptions } from './global';
export declare const createAbortController: () => AbortController;
export declare const switchFetch: (fetchUrl: string, audience: string, scope: string, fetchOptions: FetchOptions, worker?: Worker, timeout?: number) => Promise<any>;
export declare function getJSON<T>(url: string, timeout: number, audience: string, scope: string, options: FetchOptions, worker?: Worker): Promise<T>;
export declare const switchFetch: (fetchUrl: string, audience: string, scope: string, fetchOptions: FetchOptions, worker?: Worker, useFormData?: boolean, timeout?: number) => Promise<any>;
export declare function getJSON<T>(url: string, timeout: number, audience: string, scope: string, options: FetchOptions, worker?: Worker, useFormData?: boolean): Promise<T>;

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

declare const _default: "1.16.1";
declare const _default: "1.17.0";
export default _default;

@@ -9,2 +9,3 @@ import { FetchOptions } from '../global';

fetchOptions: FetchOptions;
useFormData?: boolean;
auth?: {

@@ -11,0 +12,0 @@ audience?: string;

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

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

@@ -26,3 +26,3 @@ "types": "dist/typings/index.d.ts",

"test:es-check:es2015:module": "es-check es2015 --module 'dist/auth0-spa-js.production.esm.js'",
"test:integration:server": "cp static/index.html dist/index.html && serve ./dist/ -p 3000 -n",
"test:integration:server": "npm run dev",
"test:integration:tests": "wait-on http://localhost:3000/ && cypress run",

@@ -42,29 +42,31 @@ "test:integration": "concurrently --raw --kill-others --success first npm:test:integration:server npm:test:integration:tests",

"@types/cypress": "^1.1.3",
"@types/jest": "^26.0.23",
"@typescript-eslint/eslint-plugin-tslint": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"@types/jest": "^26.0.24",
"@typescript-eslint/eslint-plugin-tslint": "^4.28.4",
"@typescript-eslint/parser": "^4.28.4",
"browserstack-cypress-cli": "^1.8.1",
"cli-table": "^0.3.6",
"codecov": "^3.8.1",
"codecov": "^3.8.3",
"concurrently": "^5.3.0",
"cypress": "^5.6.0",
"es-check": "^5.2.3",
"eslint": "^7.25.0",
"cypress": "7.2.0",
"es-check": "^5.2.4",
"eslint": "^7.31.0",
"gzip-size": "^5.1.1",
"husky": "^4.3.8",
"idtoken-verifier": "^2.1.0",
"idtoken-verifier": "^2.2.0",
"jest": "^26.6.3",
"jest-junit": "^12.0.0",
"jest-localstorage-mock": "^2.4.10",
"jest-junit": "^12.2.0",
"jest-localstorage-mock": "^2.4.14",
"jsonwebtoken": "^8.5.1",
"oidc-provider": "^7.5.4",
"pem": "^1.14.4",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0",
"prettier": "^2.3.2",
"pretty-quick": "^3.1.1",
"qss": "^2.0.3",
"rimraf": "^3.0.2",
"rollup": "^2.45.2",
"rollup": "^2.53.3",
"rollup-plugin-analyzer": "^3.3.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-livereload": "^2.0.0",
"rollup-plugin-dev": "^1.1.3",
"rollup-plugin-livereload": "^2.0.5",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-serve": "^1.1.0",
"rollup-plugin-sourcemaps": "^0.6.3",

@@ -76,14 +78,14 @@ "rollup-plugin-terser": "^7.0.2",

"serve": "^11.3.2",
"ts-jest": "^26.5.5",
"tslib": "^2.2.0",
"ts-jest": "^26.5.6",
"tslib": "^2.3.0",
"tslint": "^6.1.3",
"tslint-config-security": "^1.16.0",
"typedoc": "^0.18.0",
"typescript": "^4.2.4",
"typescript": "^4.3.5",
"wait-on": "^5.3.0"
},
"dependencies": {
"abortcontroller-polyfill": "^1.7.1",
"browser-tabs-lock": "^1.2.13",
"core-js": "^3.11.0",
"abortcontroller-polyfill": "^1.7.3",
"browser-tabs-lock": "^1.2.14",
"core-js": "^3.15.2",
"es-cookie": "^1.3.2",

@@ -90,0 +92,0 @@ "fast-text-encoding": "^1.0.3",

import { TokenEndpointOptions } from './global';
import { DEFAULT_AUTH0_CLIENT } from './constants';
import { getJSON } from './http';
import { createQueryParams } from './utils';

@@ -20,2 +21,3 @@ export type TokenEndpointResponse = {

auth0Client,
useFormData,
...options

@@ -25,2 +27,6 @@ }: TokenEndpointOptions,

) {
const body = useFormData
? createQueryParams(options)
: JSON.stringify(options);
return await getJSON<TokenEndpointResponse>(

@@ -33,5 +39,7 @@ `${baseUrl}/oauth/token`,

method: 'POST',
body: JSON.stringify(options),
body,
headers: {
'Content-type': 'application/json',
'Content-Type': useFormData
? 'application/x-www-form-urlencoded'
: 'application/json',
'Auth0-Client': btoa(

@@ -42,4 +50,5 @@ JSON.stringify(auth0Client || DEFAULT_AUTH0_CLIENT)

},
worker
worker,
useFormData
);
}

@@ -121,2 +121,13 @@ import Lock from 'browser-tabs-lock';

*/
const getDomain = (domainUrl: string) => {
if (!/^https?:\/\//.test(domainUrl)) {
return `https://${domainUrl}`;
}
return domainUrl;
};
/**
* @ignore
*/
const getCustomInitialOptions = (

@@ -139,2 +150,4 @@ options: Auth0ClientOptions

useRefreshTokens,
useCookiesForTransactions,
useFormData,
...customParams

@@ -200,3 +213,3 @@ } = options;

this.cacheManager = new CacheManager(cache, this.options.client_id);
this.domainUrl = `https://${this.options.domain}`;
this.domainUrl = getDomain(this.options.domain);
this.tokenIssuer = getTokenIssuer(this.options.issuer, this.domainUrl);

@@ -251,10 +264,11 @@

useCookiesForTransactions,
useFormData,
auth0Client,
cacheLocation,
advancedOptions,
...withoutDomain
...withoutClientOptions
} = this.options;
return {
...withoutDomain,
...withoutClientOptions,
...authorizeOptions,

@@ -426,3 +440,4 @@ scope: getUniqueScopes(

redirect_uri: params.redirect_uri,
auth0Client: this.options.auth0Client
auth0Client: this.options.auth0Client,
useFormData: this.options.useFormData
} as OAuthTokenOptions,

@@ -579,3 +594,4 @@ this.worker

code,
auth0Client: this.options.auth0Client
auth0Client: this.options.auth0Client,
useFormData: this.options.useFormData
} as OAuthTokenOptions;

@@ -938,3 +954,4 @@ // some old versions of the SDK might not have added redirect_uri to the

redirect_uri: params.redirect_uri,
auth0Client: this.options.auth0Client
auth0Client: this.options.auth0Client,
useFormData: this.options.useFormData
} as OAuthTokenOptions,

@@ -993,9 +1010,4 @@ this.worker

const {
scope,
audience,
ignoreCache,
timeoutInSeconds,
...customOptions
} = options;
const { scope, audience, ignoreCache, timeoutInSeconds, ...customOptions } =
options;

@@ -1020,3 +1032,4 @@ const timeout =

...(timeout && { timeout }),
auth0Client: this.options.auth0Client
auth0Client: this.options.auth0Client,
useFormData: this.options.useFormData
} as RefreshTokenOptions,

@@ -1023,0 +1036,0 @@ this.worker

@@ -206,2 +206,11 @@ import { ICache } from './cache';

sessionCheckExpiryDays?: number;
/**
* When true, data to the token endpoint is transmitted as x-www-form-urlencoded data instead of JSON. The default is false, but will default to true in a
* future major version.
*
* **Note:** Setting this to `true` may affect you if you use Auth0 Rules and are sending custom, non-primative data. If you enable this, please verify that your Auth0 Rules
* continue to work as intended.
*/
useFormData?: boolean;
}

@@ -440,2 +449,3 @@

auth0Client: any;
useFormData?: boolean;
[key: string]: any;

@@ -442,0 +452,0 @@ }

@@ -52,3 +52,4 @@ import fetch from 'unfetch';

timeout: number,
worker?: Worker
worker?: Worker,
useFormData?: boolean
) => {

@@ -63,3 +64,4 @@ return sendMessage(

fetchUrl,
fetchOptions
fetchOptions,
useFormData
},

@@ -76,2 +78,3 @@ worker

worker?: Worker,
useFormData?: boolean,
timeout = DEFAULT_FETCH_TIMEOUT_MS

@@ -86,3 +89,4 @@ ): Promise<any> => {

timeout,
worker
worker,
useFormData
);

@@ -100,3 +104,4 @@ } else {

options: FetchOptions,
worker?: Worker
worker?: Worker,
useFormData?: boolean
): Promise<T> {

@@ -114,2 +119,3 @@ let fetchError: null | Error = null;

worker,
useFormData,
timeout

@@ -116,0 +122,0 @@ );

@@ -15,3 +15,3 @@ import { AuthenticationResult, PopupConfigOptions } from './global';

export const parseQueryResult = (queryString: string) => {
export const parseQueryResult = (queryString: string): AuthenticationResult => {
if (queryString.indexOf('#') > -1) {

@@ -22,4 +22,4 @@ queryString = queryString.substr(0, queryString.indexOf('#'));

const queryParams = queryString.split('&');
const parsedQuery: Record<string, any> = {};
const parsedQuery: any = {};
queryParams.forEach(qp => {

@@ -30,6 +30,7 @@ const [key, val] = qp.split('=');

return {
...parsedQuery,
expires_in: parseInt(parsedQuery.expires_in)
} as AuthenticationResult;
if (parsedQuery.expires_in) {
parsedQuery.expires_in = parseInt(parsedQuery.expires_in);
}
return parsedQuery as AuthenticationResult;
};

@@ -36,0 +37,0 @@

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

export default '1.16.1';
export default '1.17.0';

@@ -23,4 +23,15 @@ import { MISSING_REFRESH_TOKEN_ERROR_MESSAGE } from '../constants';

const formDataToObject = (formData: string): Record<string, any> => {
const queryParams = new URLSearchParams(formData);
const parsedQuery: any = {};
queryParams.forEach((val, key) => {
parsedQuery[key] = val;
});
return parsedQuery;
};
const messageHandler = async ({
data: { timeout, auth, fetchUrl, fetchOptions },
data: { timeout, auth, fetchUrl, fetchOptions, useFormData },
ports: [port]

@@ -35,3 +46,5 @@ }: MessageEvent<WorkerRefreshTokenMessage>) => {

try {
const body = JSON.parse(fetchOptions.body);
const body = useFormData
? formDataToObject(fetchOptions.body)
: JSON.parse(fetchOptions.body);

@@ -45,6 +58,11 @@ if (!body.refresh_token && body.grant_type === 'refresh_token') {

fetchOptions.body = JSON.stringify({
...body,
refresh_token: refreshToken
});
fetchOptions.body = useFormData
? new URLSearchParams({
...body,
refresh_token: refreshToken
}).toString()
: JSON.stringify({
...body,
refresh_token: refreshToken
});
}

@@ -51,0 +69,0 @@

@@ -10,2 +10,3 @@ import { FetchOptions } from '../global';

fetchOptions: FetchOptions;
useFormData?: boolean;
auth?: {

@@ -12,0 +13,0 @@ audience?: string;

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