New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ordergroove/auth

Package Overview
Dependencies
Maintainers
30
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ordergroove/auth - npm Package Compare versions

Comparing version

to
2.1.7

CHANGELOG.md

4

package.json
{
"name": "@ordergroove/auth",
"version": "2.1.6",
"version": "2.1.7",
"description": "",

@@ -29,3 +29,3 @@ "main": "dist/auth.js",

"license": "ISC",
"gitHead": "2f0f8d313cffc82009e61bed4ec23e150cf219a2"
"gitHead": "5aae9ade448bbedb1e616790cbb50b77187379fd"
}

@@ -19,4 +19,4 @@

const authUrl = 'http://some-merchant.com/ordergroove-auth.json'
auth.reoslveAuth(authUrl).then(auth => {
const auth_url = 'http://some-merchant.com/ordergroove-auth.json'
auth.reoslveAuth(auth_url).then(auth => {
const { sig_field, ts, sig } = auth;

@@ -34,4 +34,4 @@ console.log(auth);

OG.auth.resolveAuth()
const authUrl = 'http://some-merchant.com/ordergroove-auth.json'
OG.auth.reoslveAuth(authUrl).then(auth =>
const auth_url = 'http://some-merchant.com/ordergroove-auth.json'
OG.auth.reoslveAuth(auth_url).then(auth =>
const { sig_field, ts, sig } = auth;

@@ -45,5 +45,5 @@ console.log(auth);

#### reoslveAuth(authUrl)
#### reoslveAuth(auth_url)
Returns a promise with auth information
##### authUrl
##### auth_url
Authentication endpoint in merchant site. See below how to integrate this endpoint.

@@ -50,0 +50,0 @@

@@ -29,5 +29,5 @@ export const ogAuthRegExp = /^og_auth=/;

* Loads the auth url into and iframe and useful to detect cookies set by javascript
* @param {*} authUrl
* @param {*} auth_url
*/
export const iframeLoad = authUrl => {
export const iframeLoad = auth_url => {
return new Promise((resolve, reject) => {

@@ -40,3 +40,3 @@ const iframe = document.createElement('iframe');

iframe.onerror = reject;
iframe.src = authUrl;
iframe.src = auth_url;
});

@@ -58,11 +58,11 @@ };

*
* @param {*} authUrl Merchant auth url endpoint
* @param {*} auth_url Merchant auth url endpoint
* @param {*} _readAuthCookie method to read cookie (for test purpose)
* @param {*} _iframeLoad method to load an iframe (for test purpose)
*/ export const resolveAuth = (authUrl, _readAuthCookie = readAuthCookie, _iframeLoad = iframeLoad) => {
*/ export const resolveAuth = (auth_url, _readAuthCookie = readAuthCookie, _iframeLoad = iframeLoad) => {
return Promise.resolve(
_readAuthCookie() ||
(authUrl &&
typeof authUrl === 'string' &&
fetch(authUrl).then(response => {
(auth_url &&
typeof auth_url === 'string' &&
fetch(auth_url).then(response => {
// https://github.com/github/fetch/issues/386#issuecomment-243145797

@@ -73,3 +73,5 @@ // detect if cookie was written by latest request

_readAuthCookie() ||
(isJsonResponse(response) ? response.json() : Promise.resolve(_iframeLoad(authUrl)).then(_readAuthCookie))
(isJsonResponse(response)
? response.json()
: Promise.resolve(_iframeLoad(auth_url)).then(_readAuthCookie))
);

@@ -76,0 +78,0 @@ return null;

@@ -70,3 +70,3 @@ // import fetchMock from 'fetch-mock';

it('should call fetch given no cookie and authUrl is non-empty string', async () => {
it('should call fetch given no cookie and auth_url is non-empty string', async () => {
const readOgAuthCookie = jasmine.createSpy('readOgAuthCookie');

@@ -78,3 +78,3 @@ resolveAuth('/auth', readOgAuthCookie);

it('should not call fetch given no cookie and authUrl is a non-string', async () => {
it('should not call fetch given no cookie and auth_url is a non-string', async () => {
const readOgAuthCookie = jasmine.createSpy('readOgAuthCookie');

@@ -86,3 +86,3 @@ resolveAuth(undefined, readOgAuthCookie);

it('should not call fetch given no cookie and authUrl is an empty string', async () => {
it('should not call fetch given no cookie and auth_url is an empty string', async () => {
const readOgAuthCookie = jasmine.createSpy('readOgAuthCookie');

@@ -89,0 +89,0 @@ resolveAuth('', readOgAuthCookie);

Sorry, the diff of this file is not supported yet