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

@digigov/auth

Package Overview
Dependencies
Maintainers
3
Versions
269
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@digigov/auth - npm Package Compare versions

Comparing version 0.0.1-alpha.181 to 0.0.1-auth-flow.17

19

es/hooks.js
import { useEffect, useMemo } from 'react';
import useAuth from './index';
import { readSession } from './localSession';
export function useToken() {

@@ -46,2 +47,18 @@ return useAuth().token;

}
};
};
export function useLoginPortal(loginUrl) {
useEffect(function () {
if (loginUrl) {
var url = new URL(loginUrl, document.baseURI).href;
var urlParams = new URLSearchParams(window.location.search);
var nextURL = urlParams.get('next') || '';
var externalWindow = window.open(url, '', 'width=600,height=400,left=200,top=200');
externalWindow.document.title = 'Login';
externalWindow.addEventListener('beforeunload', function () {
if (readSession().authenticated) {
window.location.href = new URL(nextURL, document.baseURI).href;
}
});
}
}, [loginUrl]);
}

17

es/TokenLogin.js
import React, { useEffect } from 'react';
import qs from 'qs';
import useAuth from './index';

@@ -8,12 +7,5 @@ var isBrowser = typeof window !== 'undefined';

var auth = useAuth();
var location = isBrowser ? window.location : {
hash: '',
search: ''
};
var navigate = auth.navigate;
var params = qs.parse(location.search.slice(1));
var next = params.next || isBrowser && window.localStorage.getItem('login-next') || '/';
useEffect(function () {
if (!code) {
navigate('/');
isBrowser && window.close();
} else {

@@ -25,10 +17,7 @@ auth.resolveTokenFromCode(code);

if (auth.authenticated) {
isBrowser && window.localStorage.removeItem('login-next');
navigate(next || '/');
isBrowser && window.close();
}
if (auth.error) {
console.error(auth.error);
isBrowser && window.localStorage.removeItem('login-next');
navigate('/');
isBrowser && window.close();
}

@@ -35,0 +24,0 @@ }, [auth.authenticated, auth.error, auth.code]);

import { useEffect, useMemo } from 'react';
import useAuth from './index';
import { readSession } from './localSession';
export function useToken() {

@@ -46,2 +47,18 @@ return useAuth().token;

}
};
};
export function useLoginPortal(loginUrl) {
useEffect(function () {
if (loginUrl) {
var url = new URL(loginUrl, document.baseURI).href;
var urlParams = new URLSearchParams(window.location.search);
var nextURL = urlParams.get('next') || '';
var externalWindow = window.open(url, '', 'width=600,height=400,left=200,top=200');
externalWindow.document.title = 'Login';
externalWindow.addEventListener('beforeunload', function () {
if (readSession().authenticated) {
window.location.href = new URL(nextURL, document.baseURI).href;
}
});
}
}, [loginUrl]);
}

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

/** @license Digigov v0.0.1-alpha.181
/** @license Digigov v0.0.1-auth-flow.17+2cc0bf5
*

@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the

import React, { useEffect } from 'react';
import qs from 'qs';
import useAuth from './index';

@@ -8,12 +7,5 @@ var isBrowser = typeof window !== 'undefined';

var auth = useAuth();
var location = isBrowser ? window.location : {
hash: '',
search: ''
};
var navigate = auth.navigate;
var params = qs.parse(location.search.slice(1));
var next = params.next || isBrowser && window.localStorage.getItem('login-next') || '/';
useEffect(function () {
if (!code) {
navigate('/');
isBrowser && window.close();
} else {

@@ -25,10 +17,7 @@ auth.resolveTokenFromCode(code);

if (auth.authenticated) {
isBrowser && window.localStorage.removeItem('login-next');
navigate(next || '/');
isBrowser && window.close();
}
if (auth.error) {
console.error(auth.error);
isBrowser && window.localStorage.removeItem('login-next');
navigate('/');
isBrowser && window.close();
}

@@ -35,0 +24,0 @@ }, [auth.authenticated, auth.error, auth.code]);

@@ -7,1 +7,2 @@ import { TokenType, UserType } from './index';

export declare const useRequireAnonymous: () => void;
export declare function useLoginPortal(loginUrl: any): void;

@@ -11,2 +11,3 @@ "use strict";

exports.makeRequireUserTypeHook = makeRequireUserTypeHook;
exports.useLoginPortal = useLoginPortal;
exports.useRequireAnonymous = exports.useRequireUser = void 0;

@@ -18,2 +19,4 @@

var _localSession = require("./localSession");
function useToken() {

@@ -69,2 +72,19 @@ return (0, _index["default"])().token;

exports.useRequireAnonymous = useRequireAnonymous;
exports.useRequireAnonymous = useRequireAnonymous;
function useLoginPortal(loginUrl) {
(0, _react.useEffect)(function () {
if (loginUrl) {
var url = new URL(loginUrl, document.baseURI).href;
var urlParams = new URLSearchParams(window.location.search);
var nextURL = urlParams.get('next') || '';
var externalWindow = window.open(url, '', 'width=600,height=400,left=200,top=200');
externalWindow.document.title = 'Login';
externalWindow.addEventListener('beforeunload', function () {
if ((0, _localSession.readSession)().authenticated) {
window.location.href = new URL(nextURL, document.baseURI).href;
}
});
}
}, [loginUrl]);
}

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

/** @license Digigov v0.0.1-alpha.181
/** @license Digigov v0.0.1-auth-flow.17+2cc0bf5
*

@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the

{
"name": "@digigov/auth",
"version": "0.0.1-alpha.181",
"version": "0.0.1-auth-flow.17+2cc0bf5",
"description": "@digigov authentication client",

@@ -20,5 +20,5 @@ "author": "GRNET Developers <devs@lists.grnet.gr>",

},
"gitHead": "1b3ba0a4f011a23009dfe75c47906a23ace4f3b2",
"gitHead": "2cc0bf5a622def669851a8ec5ea98c3986af4383",
"private": false,
"typings": "./index.d.ts"
}

@@ -14,4 +14,2 @@ "use strict";

var _qs = _interopRequireDefault(require("qs"));
var _index = _interopRequireDefault(require("./index"));

@@ -24,14 +22,5 @@

var auth = (0, _index["default"])();
var location = isBrowser ? window.location : {
hash: '',
search: ''
};
var navigate = auth.navigate;
var params = _qs["default"].parse(location.search.slice(1));
var next = params.next || isBrowser && window.localStorage.getItem('login-next') || '/';
(0, _react.useEffect)(function () {
if (!code) {
navigate('/');
isBrowser && window.close();
} else {

@@ -43,10 +32,7 @@ auth.resolveTokenFromCode(code);

if (auth.authenticated) {
isBrowser && window.localStorage.removeItem('login-next');
navigate(next || '/');
isBrowser && window.close();
}
if (auth.error) {
console.error(auth.error);
isBrowser && window.localStorage.removeItem('login-next');
navigate('/');
isBrowser && window.close();
}

@@ -53,0 +39,0 @@ }, [auth.authenticated, auth.error, auth.code]);

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