Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

oidc-jwt-client

Package Overview
Dependencies
Maintainers
4
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oidc-jwt-client - npm Package Compare versions

Comparing version 4.0.9 to 4.0.10-develop.1

33

dist/cjs/hooks.js

@@ -8,18 +8,15 @@ 'use strict';

var reactUse = require('react-use');
var OidcJwtProvider = require('./OidcJwtProvider.js');
var store = require('./store.js');
function useAuthControls() {
var useStore = OidcJwtProvider.useOidcJwtContext().useStore;
var authorize = useStore(function (state) { return state.methods.authorize; });
var logout = useStore(function (state) { return state.methods.logout; });
var authorize = store.useStore(function (state) { return state.methods.authorize; });
var logout = store.useStore(function (state) { return state.methods.logout; });
return { authorize: authorize, logout: logout };
}
function useAuthInitialized() {
var useStore = OidcJwtProvider.useOidcJwtContext().useStore;
return useStore(function (state) { return state.isInitialized; });
return store.useStore(function (state) { return state.isInitialized; });
}
function useAuthUserInfo() {
var _this = this;
var useStore = OidcJwtProvider.useOidcJwtContext().useStore;
var getUserInfo = useStore(function (state) { return state.methods.getUserInfo; });
var getUserInfo = store.useStore(function (state) { return state.methods.getUserInfo; });
var isLoggedIn = useAuthIsLoggedIn();

@@ -37,4 +34,3 @@ return reactUse.useAsync(function () { return tslib_es6.__awaiter(_this, void 0, void 0, function () {

var _this = this;
var useStore = OidcJwtProvider.useOidcJwtContext().useStore;
var getAccessToken = useStore(function (state) { return state.methods.getAccessToken; });
var getAccessToken = store.useStore(function (state) { return state.methods.getAccessToken; });
var isLoggedIn = useAuthIsLoggedIn();

@@ -51,12 +47,10 @@ return reactUse.useAsync(function () { return tslib_es6.__awaiter(_this, void 0, void 0, function () {

function useAuthIsLoggedIn() {
var useStore = OidcJwtProvider.useOidcJwtContext().useStore;
return useStore(function (state) { return state.isLoggedIn; });
return store.useStore(function (state) { return state.isLoggedIn; });
}
function useAuthSessionExpired() {
var useStore = OidcJwtProvider.useOidcJwtContext().useStore;
var resetStorage = useStore(function (state) { return state.methods.resetStorage; });
var authorize = useStore(function (state) { return state.methods.authorize; });
var unsetRetryLogin = useStore(function (state) { return state.methods.unsetRetryLogin; });
var isLoggedIn = useStore(function (state) { return state.isLoggedIn; });
var didRetryLogin = useStore(function (state) { return state.didRetryLogin; });
var resetStorage = store.useStore(function (state) { return state.methods.resetStorage; });
var authorize = store.useStore(function (state) { return state.methods.authorize; });
var unsetRetryLogin = store.useStore(function (state) { return state.methods.unsetRetryLogin; });
var isLoggedIn = store.useStore(function (state) { return state.isLoggedIn; });
var didRetryLogin = store.useStore(function (state) { return state.didRetryLogin; });
var isPrevLoggedIn = reactUse.usePrevious(isLoggedIn);

@@ -98,4 +92,3 @@ var _a = React.useState(false), isSessionExpired = _a[0], setSessionExpired = _a[1];

function useAuthAccessToken() {
var useStore = OidcJwtProvider.useOidcJwtContext().useStore;
var getAccessToken = useStore(function (state) { return state.methods.getAccessToken; });
var getAccessToken = store.useStore(function (state) { return state.methods.getAccessToken; });
return React.useCallback(function () {

@@ -102,0 +95,0 @@ return getAccessToken().then(function (result) { var _a; return (_a = result === null || result === void 0 ? void 0 : result.token) !== null && _a !== void 0 ? _a : null; });

@@ -21,3 +21,2 @@ 'use strict';

exports.OidcJwtProvider = OidcJwtProvider.OidcJwtProvider;
exports.useOidcJwtContext = OidcJwtProvider.useOidcJwtContext;
Object.defineProperty(exports, 'CsrfTokenMethod', {

@@ -24,0 +23,0 @@ enumerable: true,

@@ -5,2 +5,3 @@ 'use strict';

var tslib_es6 = require('./node_modules/tslib/tslib.es6.js');
var React = require('react');

@@ -15,21 +16,6 @@ var store = require('./store.js');

var OidcJwtContext = React__default["default"].createContext(null);
function useOidcJwtContext() {
var context = React.useContext(OidcJwtContext);
if (!context) {
throw new Error('Can only use useAuth...() inside OidcJwtProvider');
}
return context;
}
var OidcJwtProvider = function (props) {
var options = props.client, _a = props.shouldAttemptLogin, shouldAttemptLogin = _a === void 0 ? false : _a, _b = props.shouldMonitorAccessTokens, shouldMonitorAccessTokens = _b === void 0 ? true : _b, _c = props.removeTokenFromUrlFunction, removeTokenFromUrlFunction = _c === void 0 ? stripTokenFromUrl.removeTokenFromUrl : _c, children = props.children;
var contextRef = React.useRef();
if (!contextRef.current) {
contextRef.current = {
useStore: store.createOidcJwtClientStore(options, removeTokenFromUrlFunction),
};
}
var useStore = contextRef.current.useStore;
var _d = useStore(function (state) { return state.methods; }), getCsrfToken = _d.getCsrfToken, authorize = _d.authorize, loadInitialData = _d.loadInitialData, monitorAccessToken = _d.monitorAccessToken, stopMonitoringAccessToken = _d.stopMonitoringAccessToken;
var isLoggedIn = useStore(function (state) { return state.isLoggedIn; });
var OidcJwtInitializer = function (_a) {
var _b = _a.shouldAttemptLogin, shouldAttemptLogin = _b === void 0 ? false : _b, _c = _a.shouldMonitorAccessTokens, shouldMonitorAccessTokens = _c === void 0 ? true : _c, children = _a.children;
var _d = store.useStore(function (state) { return state.methods; }), getCsrfToken = _d.getCsrfToken, authorize = _d.authorize, loadInitialData = _d.loadInitialData, monitorAccessToken = _d.monitorAccessToken, stopMonitoringAccessToken = _d.stopMonitoringAccessToken;
var isLoggedIn = store.useStore(function (state) { return state.isLoggedIn; });
React.useEffect(function () {

@@ -53,7 +39,14 @@ loadInitialData();

}
return React__default["default"].createElement(OidcJwtContext.Provider, { value: contextRef.current }, children);
return React__default["default"].createElement(React__default["default"].Fragment, null, children);
};
var OidcJwtProvider = function (props) {
var options = props.client, _a = props.removeTokenFromUrlFunction, removeTokenFromUrlFunction = _a === void 0 ? stripTokenFromUrl.removeTokenFromUrl : _a, children = props.children;
var createStore = React.useCallback(function () {
return store.createOidcJwtClientStore(options, removeTokenFromUrlFunction);
}, [options, removeTokenFromUrlFunction]);
return (React__default["default"].createElement(store.Provider, { createStore: createStore },
React__default["default"].createElement(OidcJwtInitializer, tslib_es6.__assign({}, props), children)));
};
exports.OidcJwtProvider = OidcJwtProvider;
exports.useOidcJwtContext = useOidcJwtContext;
//# sourceMappingURL=OidcJwtProvider.js.map

@@ -8,2 +8,3 @@ 'use strict';

var create = require('zustand');
var createContext = require('zustand/context');
var storage = require('./storage.js');

@@ -17,2 +18,3 @@ var errors = require('./utils/errors.js');

var create__default = /*#__PURE__*/_interopDefaultLegacy(create);
var createContext__default = /*#__PURE__*/_interopDefaultLegacy(createContext);

@@ -288,5 +290,8 @@ exports.CsrfTokenMethod = void 0;

}
var _a = createContext__default["default"](), Provider = _a.Provider, useStore = _a.useStore;
exports.CSRF_TOKEN_STORAGE_KEY = CSRF_TOKEN_STORAGE_KEY;
exports.Provider = Provider;
exports.createOidcJwtClientStore = createOidcJwtClientStore;
exports.useStore = useStore;
//# sourceMappingURL=store.js.map
import { __awaiter, __generator } from './node_modules/tslib/tslib.es6.js';
import { useState, useCallback, useEffect } from 'react';
import { useAsync, usePrevious } from 'react-use';
import { useOidcJwtContext } from './OidcJwtProvider.js';
import { useStore } from './store.js';
function useAuthControls() {
var useStore = useOidcJwtContext().useStore;
var authorize = useStore(function (state) { return state.methods.authorize; });

@@ -13,3 +12,2 @@ var logout = useStore(function (state) { return state.methods.logout; });

function useAuthInitialized() {
var useStore = useOidcJwtContext().useStore;
return useStore(function (state) { return state.isInitialized; });

@@ -19,3 +17,2 @@ }

var _this = this;
var useStore = useOidcJwtContext().useStore;
var getUserInfo = useStore(function (state) { return state.methods.getUserInfo; });

@@ -34,3 +31,2 @@ var isLoggedIn = useAuthIsLoggedIn();

var _this = this;
var useStore = useOidcJwtContext().useStore;
var getAccessToken = useStore(function (state) { return state.methods.getAccessToken; });

@@ -48,7 +44,5 @@ var isLoggedIn = useAuthIsLoggedIn();

function useAuthIsLoggedIn() {
var useStore = useOidcJwtContext().useStore;
return useStore(function (state) { return state.isLoggedIn; });
}
function useAuthSessionExpired() {
var useStore = useOidcJwtContext().useStore;
var resetStorage = useStore(function (state) { return state.methods.resetStorage; });

@@ -95,3 +89,2 @@ var authorize = useStore(function (state) { return state.methods.authorize; });

function useAuthAccessToken() {
var useStore = useOidcJwtContext().useStore;
var getAccessToken = useStore(function (state) { return state.methods.getAccessToken; });

@@ -98,0 +91,0 @@ return useCallback(function () {

export { useAuthAccessClaims, useAuthAccessToken, useAuthControls, useAuthInitialized, useAuthIsLoggedIn, useAuthSessionExpired, useAuthUserInfo } from './hooks.js';
export { OidcJwtProvider, useOidcJwtContext } from './OidcJwtProvider.js';
export { OidcJwtProvider } from './OidcJwtProvider.js';
export { CsrfTokenMethod } from './store.js';

@@ -4,0 +4,0 @@ import './utils/errors.js';

@@ -1,23 +0,9 @@

import React, { useContext, useRef, useEffect } from 'react';
import { createOidcJwtClientStore } from './store.js';
import { __assign } from './node_modules/tslib/tslib.es6.js';
import React, { useCallback, useEffect } from 'react';
import { createOidcJwtClientStore, Provider, useStore } from './store.js';
import './utils/errors.js';
import { removeTokenFromUrl } from './utils/stripTokenFromUrl.js';
var OidcJwtContext = React.createContext(null);
function useOidcJwtContext() {
var context = useContext(OidcJwtContext);
if (!context) {
throw new Error('Can only use useAuth...() inside OidcJwtProvider');
}
return context;
}
var OidcJwtProvider = function (props) {
var options = props.client, _a = props.shouldAttemptLogin, shouldAttemptLogin = _a === void 0 ? false : _a, _b = props.shouldMonitorAccessTokens, shouldMonitorAccessTokens = _b === void 0 ? true : _b, _c = props.removeTokenFromUrlFunction, removeTokenFromUrlFunction = _c === void 0 ? removeTokenFromUrl : _c, children = props.children;
var contextRef = useRef();
if (!contextRef.current) {
contextRef.current = {
useStore: createOidcJwtClientStore(options, removeTokenFromUrlFunction),
};
}
var useStore = contextRef.current.useStore;
var OidcJwtInitializer = function (_a) {
var _b = _a.shouldAttemptLogin, shouldAttemptLogin = _b === void 0 ? false : _b, _c = _a.shouldMonitorAccessTokens, shouldMonitorAccessTokens = _c === void 0 ? true : _c, children = _a.children;
var _d = useStore(function (state) { return state.methods; }), getCsrfToken = _d.getCsrfToken, authorize = _d.authorize, loadInitialData = _d.loadInitialData, monitorAccessToken = _d.monitorAccessToken, stopMonitoringAccessToken = _d.stopMonitoringAccessToken;

@@ -43,6 +29,14 @@ var isLoggedIn = useStore(function (state) { return state.isLoggedIn; });

}
return React.createElement(OidcJwtContext.Provider, { value: contextRef.current }, children);
return React.createElement(React.Fragment, null, children);
};
var OidcJwtProvider = function (props) {
var options = props.client, _a = props.removeTokenFromUrlFunction, removeTokenFromUrlFunction = _a === void 0 ? removeTokenFromUrl : _a, children = props.children;
var createStore = useCallback(function () {
return createOidcJwtClientStore(options, removeTokenFromUrlFunction);
}, [options, removeTokenFromUrlFunction]);
return (React.createElement(Provider, { createStore: createStore },
React.createElement(OidcJwtInitializer, __assign({}, props), children)));
};
export { OidcJwtProvider, useOidcJwtContext };
export { OidcJwtProvider };
//# sourceMappingURL=OidcJwtProvider.js.map
import { __assign } from './node_modules/tslib/tslib.es6.js';
import queryString from 'query-string';
import create from 'zustand';
import createContext from 'zustand/context';
import { Storage } from './storage.js';

@@ -277,4 +278,5 @@ import { HttpError } from './utils/errors.js';

}
var _a = createContext(), Provider = _a.Provider, useStore = _a.useStore;
export { CSRF_TOKEN_STORAGE_KEY, CsrfTokenMethod, createOidcJwtClientStore };
export { CSRF_TOKEN_STORAGE_KEY, CsrfTokenMethod, Provider, createOidcJwtClientStore, useStore };
//# sourceMappingURL=store.js.map
import React from 'react';
import { UseBoundStore } from 'zustand';
import { OidcJwtClientOptions, UseOidcJwtClientStore } from './store';
import { OidcJwtClientOptions } from './store';
export interface OidcJwtProviderProps {

@@ -10,7 +9,3 @@ client: OidcJwtClientOptions;

}
interface OidcJwtContextData {
useStore: UseBoundStore<UseOidcJwtClientStore>;
}
declare function useOidcJwtContext(): OidcJwtContextData;
declare const OidcJwtProvider: React.FC<OidcJwtProviderProps>;
export { OidcJwtProvider, useOidcJwtContext };
export { OidcJwtProvider };

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

import { UseBoundStore } from 'zustand';
/// <reference types="react" />
import { HttpError } from './utils';

@@ -147,3 +147,8 @@ export interface Params {

export declare const CSRF_TOKEN_STORAGE_KEY = "oidc_jwt_provider_token";
declare function createOidcJwtClientStore(options: OidcJwtClientOptions, removeTokenFromUrlFunction: (url: string) => void): UseBoundStore<UseOidcJwtClientStore>;
export { createOidcJwtClientStore };
declare function createOidcJwtClientStore(options: OidcJwtClientOptions, removeTokenFromUrlFunction: (url: string) => void): import("zustand").UseBoundStore<UseOidcJwtClientStore, import("zustand").StoreApi<UseOidcJwtClientStore>>;
declare const Provider: ({ initialStore, createStore, children, }: {
initialStore?: import("zustand").UseBoundStore<UseOidcJwtClientStore, import("zustand").StoreApi<UseOidcJwtClientStore>> | undefined;
createStore: () => import("zustand").UseBoundStore<UseOidcJwtClientStore, import("zustand").StoreApi<UseOidcJwtClientStore>>;
children: import("react").ReactNode;
}) => import("react").FunctionComponentElement<import("react").ProviderProps<import("zustand").UseBoundStore<UseOidcJwtClientStore, import("zustand").StoreApi<UseOidcJwtClientStore>> | undefined>>, useStore: import("zustand/context").UseContextStore<UseOidcJwtClientStore>;
export { createOidcJwtClientStore, Provider, useStore };
{
"name": "oidc-jwt-client",
"version": "4.0.9",
"version": "4.0.10-develop.1",
"description": "Fetch JWTs for API access from oidc-jwt-provider",

@@ -35,5 +35,5 @@ "sideEffects": false,

"@elseu/sdu-react-scripts-rollup": "^1.0.1",
"@storybook/addon-essentials": "^6.5.9",
"@storybook/addon-links": "^6.5.9",
"@storybook/react": "^6.5.9",
"@storybook/addon-essentials": "^6.5.10",
"@storybook/addon-links": "^6.5.10",
"@storybook/react": "^6.5.10",
"@types/query-string": "^6.3.0",

@@ -43,2 +43,3 @@ "@types/react": "^17.0.38",

"eslint": "^8.19.0",
"eslint-plugin-storybook": "^0.6.4",
"husky": "^7.0.4",

@@ -45,0 +46,0 @@ "prettier": "^2.5.1",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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