@ordergroove/auth
Advanced tools
Comparing version 2.3.0 to 2.3.1
@@ -6,2 +6,10 @@ # Change Log | ||
## [2.3.1](https://github.com/evasilchenko/demo/tree/master/packages/auth/compare/@ordergroove/auth@2.3.0...@ordergroove/auth@2.3.1) (2023-11-28) | ||
**Note:** Version bump only for package @ordergroove/auth | ||
# [2.3.0](https://github.com/evasilchenko/demo/tree/master/packages/auth/compare/@ordergroove/auth@2.2.0...@ordergroove/auth@2.3.0) (2022-02-10) | ||
@@ -8,0 +16,0 @@ |
@@ -1,2 +0,2 @@ | ||
var i=/^og_auth=/,c=(t=i)=>(document.cookie.split(/;\s*/).find(n=>n.match(t))||"").replace(i,""),r=t=>{if(typeof t=="object")return t;let n=String(t||"").split("|");return n.length===3?{sig_field:n[0],ts:parseInt(n[1],10),sig:n[2]}:null},p=t=>new Promise((n,s)=>{let e=document.createElement("iframe");e.style.setProperty("display","none","important"),document.body.appendChild(e),e.onload=n,e.onerror=s,e.src=t}),d=t=>(t.headers.get("content-type")||"").indexOf("application/json")!==-1;function a(){return typeof window.og_auth!="undefined"?r(window.og_auth):null}async function f(t=100){return new Promise(n=>{setTimeout(()=>n(a()),t)})}async function u(t,n=c,s=p){let e;if(e=r(a())||r(n()),e)return e;if(t&&typeof t=="string"){let o=await fetch(t);o.status>=200&&o.status<300&&(e=n()||await(d(o)?o.json():Promise.resolve(s(t)).then(n)))}else e||(e=await f());if(e=r(e),e)return e;throw new Error("Unauthorized")}var l=u;export{l as default,p as iframeLoad,d as isJsonResponse,i as ogAuthRegExp,r as parseAuth,c as readAuthCookie,u as resolveAuth}; | ||
var i=/^og_auth=/,c=(t=i)=>(document.cookie.split(/;\s*/).find(n=>n.match(t))||"").replace(i,""),r=t=>{if(typeof t=="object")return t;let n=String(t||"").split("|");return n.length===3?{sig_field:n[0],ts:parseInt(n[1],10),sig:n[2]}:null},p=t=>new Promise((n,s)=>{let e=document.createElement("iframe");e.style.setProperty("display","none","important"),document.body.appendChild(e),e.onload=n,e.onerror=s,e.src=t}),d=t=>(t.headers.get("content-type")||"").indexOf("application/json")!==-1;function a(){return typeof window.og_auth<"u"?r(window.og_auth):null}async function f(t=100){return new Promise(n=>{setTimeout(()=>n(a()),t)})}async function u(t,n=c,s=p){let e;if(e=r(a())||r(n()),e)return e;if(t&&typeof t=="string"){let o=await fetch(t);o.status>=200&&o.status<300&&(e=n()||await(d(o)?o.json():Promise.resolve(s(t)).then(n)))}else e||(e=await f());if(e=r(e),e)return e;throw new Error("Unauthorized")}var l=u;export{l as default,p as iframeLoad,d as isJsonResponse,i as ogAuthRegExp,r as parseAuth,c as readAuthCookie,u as resolveAuth}; | ||
//# sourceMappingURL=auth.js.map |
{ | ||
"name": "@ordergroove/auth", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "", | ||
@@ -28,3 +28,3 @@ "main": "dist/auth.js", | ||
"license": "ISC", | ||
"gitHead": "e5a962194ba3b17d2851ed75fd1af4d5234c8fd2" | ||
"gitHead": "1b08ceb2cca573488a040e8645304a446d72cd31" | ||
} |
import fetchMock from 'fetch-mock'; | ||
import { resolveAuth } from './index'; | ||
const { resolveAuth } = require('./index'); | ||
describe('AuthIframe', function() { | ||
@@ -71,3 +70,3 @@ beforeEach(() => { | ||
const readOgAuthCookie = jasmine.createSpy('readOgAuthCookie'); | ||
await resolveAuth('/auth', readOgAuthCookie).catch(err => null); | ||
await resolveAuth('/auth', readOgAuthCookie).catch(() => null); | ||
expect(readOgAuthCookie).toHaveBeenCalled(); | ||
@@ -79,3 +78,3 @@ expect(fetchMock.calls().length).toEqual(1); | ||
const readOgAuthCookie = jasmine.createSpy('readOgAuthCookie'); | ||
await resolveAuth(undefined, readOgAuthCookie).catch(err => null); | ||
await resolveAuth(undefined, readOgAuthCookie).catch(() => null); | ||
expect(readOgAuthCookie).toHaveBeenCalled(); | ||
@@ -87,3 +86,3 @@ expect(fetchMock.calls().length).toEqual(0); | ||
const readOgAuthCookie = jasmine.createSpy('readOgAuthCookie'); | ||
await resolveAuth('', readOgAuthCookie).catch(err => null); | ||
await resolveAuth('', readOgAuthCookie).catch(() => null); | ||
expect(readOgAuthCookie).toHaveBeenCalled(); | ||
@@ -90,0 +89,0 @@ expect(fetchMock.calls().length).toEqual(0); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23950