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.1

32

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

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

}
};
};
export function useLoginPortal(_ref) {
var loginUrl = _ref.loginUrl,
_ref$size = _ref.size,
size = _ref$size === void 0 ? {
width: 600,
height: 400
} : _ref$size,
_ref$position = _ref.position,
position = _ref$position === void 0 ? {
left: 200,
top: 200
} : _ref$position,
title = _ref.title;
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=".concat(size.width, ",height=").concat(size.height, ",left=").concat(position.left, ",top=").concat(position.top));
window.localStorage.setItem('popup-login', '1');
externalWindow.document.title = title || 'Login';
externalWindow.addEventListener('beforeunload', function () {
if (readSession().authenticated) {
window.location.href = new URL(nextURL, document.baseURI).href;
}
});
}
}, [loginUrl]);
}

30

es/TokenLogin.js

@@ -15,5 +15,15 @@ import React, { useEffect } from 'react';

var next = params.next || isBrowser && window.localStorage.getItem('login-next') || '/';
var isPopup = window.localStorage.getItem('popup-login') === '1';
if (isPopup) {
window.localStorage.removeItem('popup-login');
}
useEffect(function () {
if (!code) {
navigate('/');
if (!isPopup) {
navigate('/');
} else {
isBrowser && window.close();
}
} else {

@@ -25,10 +35,18 @@ auth.resolveTokenFromCode(code);

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

@@ -35,0 +53,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,31 @@ return useAuth().token;

}
};
};
export function useLoginPortal(_ref) {
var loginUrl = _ref.loginUrl,
_ref$size = _ref.size,
size = _ref$size === void 0 ? {
width: 600,
height: 400
} : _ref$size,
_ref$position = _ref.position,
position = _ref$position === void 0 ? {
left: 200,
top: 200
} : _ref$position,
title = _ref.title;
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=".concat(size.width, ",height=").concat(size.height, ",left=").concat(position.left, ",top=").concat(position.top));
window.localStorage.setItem('popup-login', '1');
externalWindow.document.title = 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.1+48578ec
*

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

@@ -15,5 +15,15 @@ import React, { useEffect } from 'react';

var next = params.next || isBrowser && window.localStorage.getItem('login-next') || '/';
var isPopup = window.localStorage.getItem('popup-login') === '1';
if (isPopup) {
window.localStorage.removeItem('popup-login');
}
useEffect(function () {
if (!code) {
navigate('/');
if (!isPopup) {
navigate('/');
} else {
isBrowser && window.close();
}
} else {

@@ -25,10 +35,18 @@ auth.resolveTokenFromCode(code);

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

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

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

export declare const useRequireAnonymous: () => void;
export declare function useLoginPortal({ loginUrl, size, position, title, }: {
loginUrl: any;
size?: {
width: number;
height: number;
} | undefined;
position?: {
left: number;
top: number;
} | undefined;
title: 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,32 @@ return (0, _index["default"])().token;

exports.useRequireAnonymous = useRequireAnonymous;
exports.useRequireAnonymous = useRequireAnonymous;
function useLoginPortal(_ref) {
var loginUrl = _ref.loginUrl,
_ref$size = _ref.size,
size = _ref$size === void 0 ? {
width: 600,
height: 400
} : _ref$size,
_ref$position = _ref.position,
position = _ref$position === void 0 ? {
left: 200,
top: 200
} : _ref$position,
title = _ref.title;
(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=".concat(size.width, ",height=").concat(size.height, ",left=").concat(position.left, ",top=").concat(position.top));
window.localStorage.setItem('popup-login', '1');
externalWindow.document.title = 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.1+48578ec
*

@@ -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.1+48578ec",
"description": "@digigov authentication client",

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

},
"gitHead": "1b3ba0a4f011a23009dfe75c47906a23ace4f3b2",
"gitHead": "48578ecbac73a63dfcb24fc2da64225628973944",
"private": false,
"typings": "./index.d.ts"
}

@@ -32,5 +32,15 @@ "use strict";

var next = params.next || isBrowser && window.localStorage.getItem('login-next') || '/';
var isPopup = window.localStorage.getItem('popup-login') === '1';
if (isPopup) {
window.localStorage.removeItem('popup-login');
}
(0, _react.useEffect)(function () {
if (!code) {
navigate('/');
if (!isPopup) {
navigate('/');
} else {
isBrowser && window.close();
}
} else {

@@ -42,10 +52,18 @@ auth.resolveTokenFromCode(code);

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

@@ -52,0 +70,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