Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
Fixing exported typings (#4)
Browse files Browse the repository at this point in the history
* Fixing typings by bumping up to the auth0 beta sdk
  • Loading branch information
jasonvasquez authored Mar 27, 2020
1 parent 8c61e1f commit d911ac7
Show file tree
Hide file tree
Showing 6 changed files with 5,997 additions and 5,993 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@developertown/auth0-react-spa-provider",
"version": "0.0.3",
"version": "0.0.4",
"license": "MIT",
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
Expand All @@ -19,7 +19,7 @@
"test:coverage": "yarn test --coverage"
},
"dependencies": {
"@auth0/auth0-spa-js": "^1.6.5",
"@auth0/auth0-spa-js": "^1.7.0-beta.5",
"typescript-fsa": "^3.0.0",
"typescript-fsa-reducers": "^1.2.1"
},
Expand Down
38 changes: 18 additions & 20 deletions src/__tests__/reducer.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Auth0 from "@auth0/auth0-spa-js";
import { auth0Loaded, handleRedirectCallbackAction, loginWithPopupAction } from "../actions";
import { auth0ProviderStateReducer } from "../reducer";
import {
Expand All @@ -10,16 +11,14 @@ import {
UnauthenticatedState,
} from "../types";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const createFakeAuth0Client = (): any => {
return {
loginWithRedirect: jest.fn(),
getTokenWithPopup: jest.fn(),
getTokenSilently: jest.fn(),
getIdTokenClaims: jest.fn(),
logout: jest.fn(),
};
};
jest.mock("@auth0/auth0-spa-js");

const createFakeAuth0Client = (): Auth0.Auth0Client =>
new Auth0.Auth0Client({
domain: "",
// eslint-disable-next-line @typescript-eslint/camelcase
client_id: "",
});

const createInitialState = (): LoadingState => ({
loading: true,
Expand All @@ -30,23 +29,22 @@ const createInitialState = (): LoadingState => ({
handlingRedirect: false,
});

const createFakeUnauthenticatedState = (): UnauthenticatedState => ({
const createFakeUnauthenticatedState = (
auth0Client: Auth0.Auth0Client = createFakeAuth0Client(),
): UnauthenticatedState => ({
isAuthenticated: false,
loading: false,
loginWithPopup: jest.fn(),
handleRedirectCallback: jest.fn(),
handlingRedirect: false,
user: undefined,
popupOpen: false,
// eslint-disable-next-line @typescript-eslint/camelcase,@typescript-eslint/ban-ts-ignore
// @ts-ignore
auth0Client: {
loginWithRedirect: jest.fn(),
getTokenWithPopup: jest.fn(),
getTokenSilently: jest.fn(),
getIdTokenClaims: jest.fn(),
logout: jest.fn(),
}, //new Auth0Client({ domain: "xyz", client_id: "pdq" }),
auth0Client,
loginWithRedirect: auth0Client.loginWithRedirect.bind(auth0Client),
getTokenWithPopup: auth0Client.getTokenWithPopup.bind(auth0Client),
getTokenSilently: auth0Client.getTokenSilently.bind(auth0Client),
getIdTokenClaims: auth0Client.getIdTokenClaims.bind(auth0Client),
logout: auth0Client.logout.bind(auth0Client),
});

const createHandlingRedirectState = (): HandlingRedirectState =>
Expand Down
2 changes: 1 addition & 1 deletion src/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import createAuth0Client from "@auth0/auth0-spa-js";
import createAuth0Client, { PopupConfigOptions, PopupLoginOptions, RedirectLoginResult } from "@auth0/auth0-spa-js";
import Auth0Client from "@auth0/auth0-spa-js/dist/typings/Auth0Client";
import React, { Dispatch, Reducer, useEffect, useReducer } from "react";
import { useAsync, useAsyncFn, useLocation } from "react-use";
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "@auth0/auth0-spa-js";
import { Auth0ClientOptions } from "@auth0/auth0-spa-js";
import Auth0Client from "@auth0/auth0-spa-js/dist/typings/Auth0Client";
import { History } from "history";
import { createContext, Dispatch, ReactElement } from "react";
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"isolatedModules": false,
"isolatedModules": true,
"resolveJsonModule": true
},
"exclude": ["node_modules", "dist"]
Expand Down
Loading

0 comments on commit d911ac7

Please sign in to comment.