@inrupt/solid-client-authn-core
Advanced tools
Comparing version 1.13.2 to 1.13.3-alpha.0
/// <reference types="node" /> | ||
import { fetch } from "cross-fetch"; | ||
import { fetch } from "@inrupt/universal-fetch"; | ||
import { EventEmitter } from "events"; | ||
@@ -4,0 +4,0 @@ import { ITokenRefresher } from "../login/oidc/refresh/ITokenRefresher"; |
'use strict'; | ||
var crossFetch = require('cross-fetch'); | ||
var universalFetch = require('@inrupt/universal-fetch'); | ||
var jose = require('jose'); | ||
@@ -60,3 +60,3 @@ var uuid = require('uuid'); | ||
async function fetchJwks(jwksIri, issuerIri) { | ||
const jwksResponse = await crossFetch.fetch(jwksIri); | ||
const jwksResponse = await universalFetch.fetch(jwksIri); | ||
if (jwksResponse.status !== 200) { | ||
@@ -365,3 +365,3 @@ throw new Error(`Could not fetch JWKS for [${issuerIri}] at [${jwksIri}]: ${jwksResponse.status} ${jwksResponse.statusText}`); | ||
var _a; | ||
const headers = new crossFetch.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers); | ||
const headers = new universalFetch.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers); | ||
headers.set("Authorization", `DPoP ${authToken}`); | ||
@@ -378,3 +378,3 @@ headers.set("DPoP", await createDpopHeader(targetUrl, (_a = defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.method) !== null && _a !== void 0 ? _a : "get", dpopKey)); | ||
} | ||
const headers = new crossFetch.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers); | ||
const headers = new universalFetch.Headers(defaultOptions === null || defaultOptions === void 0 ? void 0 : defaultOptions.headers); | ||
headers.set("Authorization", `Bearer ${authToken}`); | ||
@@ -381,0 +381,0 @@ return { |
/// <reference types="node" /> | ||
import { fetch } from "cross-fetch"; | ||
import { fetch } from "@inrupt/universal-fetch"; | ||
import { EventEmitter } from "events"; | ||
@@ -4,0 +4,0 @@ import IHandleable from "../../util/handlerPattern/IHandleable"; |
{ | ||
"name": "@inrupt/solid-client-authn-core", | ||
"version": "1.13.2", | ||
"version": "1.13.3-alpha.0", | ||
"license": "MIT", | ||
@@ -41,3 +41,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"cross-fetch": "^3.1.5", | ||
"@inrupt/universal-fetch": "../../../universal-fetch", | ||
"events": "^3.3.0", | ||
@@ -57,4 +57,3 @@ "jose": "^4.10.0", | ||
"@types/uuid": "^8.3.4" | ||
}, | ||
"gitHead": "76a536b31ba87632891d726b5179bfde9afed7be" | ||
} | ||
} |
@@ -28,4 +28,4 @@ // | ||
import { EventEmitter } from "events"; | ||
import { Response, Headers } from "cross-fetch"; | ||
import type * as CrossFetch from "cross-fetch"; | ||
import { Response, Headers } from "@inrupt/universal-fetch"; | ||
import type * as UniversalFetch from "@inrupt/universal-fetch"; | ||
import { | ||
@@ -45,8 +45,8 @@ buildAuthenticatedFetch, | ||
jest.mock("cross-fetch", () => { | ||
jest.mock("@inrupt/universal-fetch", () => { | ||
return { | ||
...(jest.requireActual("cross-fetch") as typeof CrossFetch), | ||
...(jest.requireActual("@inrupt/universal-fetch") as typeof UniversalFetch), | ||
default: jest.fn(), | ||
fetch: jest.fn(), | ||
} as typeof CrossFetch; | ||
} as typeof UniversalFetch; | ||
}); | ||
@@ -93,4 +93,4 @@ | ||
const mockFetch = (response: Response, url: string) => { | ||
const { fetch } = jest.requireMock("cross-fetch") as jest.Mocked< | ||
typeof CrossFetch | ||
const { fetch } = jest.requireMock("@inrupt/universal-fetch") as jest.Mocked< | ||
typeof UniversalFetch | ||
>; | ||
@@ -343,4 +343,4 @@ const mockedResponse = response; | ||
const { fetch: mockedFetch } = jest.requireMock( | ||
"cross-fetch" | ||
) as jest.Mocked<typeof CrossFetch>; | ||
"@inrupt/universal-fetch" | ||
) as jest.Mocked<typeof UniversalFetch>; | ||
const mockRefresher = mockDefaultTokenRefresher(); | ||
@@ -371,4 +371,4 @@ await buildAuthenticatedFetch(mockedFetch, "myToken", { | ||
const { fetch: mockedFetch } = jest.requireMock( | ||
"cross-fetch" | ||
) as jest.Mocked<typeof CrossFetch>; | ||
"@inrupt/universal-fetch" | ||
) as jest.Mocked<typeof UniversalFetch>; | ||
const mockRefresher = mockDefaultTokenRefresher(); | ||
@@ -392,4 +392,4 @@ await buildAuthenticatedFetch(mockedFetch, "myToken", { | ||
const { fetch: mockedFetch } = jest.requireMock( | ||
"cross-fetch" | ||
) as jest.Mocked<typeof CrossFetch>; | ||
"@inrupt/universal-fetch" | ||
) as jest.Mocked<typeof UniversalFetch>; | ||
const keylikePair = await mockJwk(); | ||
@@ -440,4 +440,4 @@ // Mocks a refresher which refreshes only once to prevent re-scheduling timeouts. | ||
const { fetch: mockedFetch } = jest.requireMock( | ||
"cross-fetch" | ||
) as jest.Mocked<typeof CrossFetch>; | ||
"@inrupt/universal-fetch" | ||
) as jest.Mocked<typeof UniversalFetch>; | ||
const mockRefresher = mockTokenRefresher({ | ||
@@ -479,4 +479,4 @@ ...mockDefaultTokenSet(), | ||
const { fetch: mockedFetch } = jest.requireMock( | ||
"cross-fetch" | ||
) as jest.Mocked<typeof CrossFetch>; | ||
"@inrupt/universal-fetch" | ||
) as jest.Mocked<typeof UniversalFetch>; | ||
const mockRefresher = mockTokenRefresher({ | ||
@@ -509,4 +509,4 @@ ...mockDefaultTokenSet(), | ||
const { fetch: mockedFetch } = jest.requireMock( | ||
"cross-fetch" | ||
) as jest.Mocked<typeof CrossFetch>; | ||
"@inrupt/universal-fetch" | ||
) as jest.Mocked<typeof UniversalFetch>; | ||
const tokenSet = mockDefaultTokenSet(); | ||
@@ -534,4 +534,4 @@ const mockedFreshener = mockTokenRefresher({ | ||
const { fetch: mockedFetch } = jest.requireMock( | ||
"cross-fetch" | ||
) as jest.Mocked<typeof CrossFetch>; | ||
"@inrupt/universal-fetch" | ||
) as jest.Mocked<typeof UniversalFetch>; | ||
const tokenSet = mockDefaultTokenSet(); | ||
@@ -560,4 +560,4 @@ tokenSet.refreshToken = "some rotated refresh token"; | ||
const { fetch: mockedFetch } = jest.requireMock( | ||
"cross-fetch" | ||
) as jest.Mocked<typeof CrossFetch>; | ||
"@inrupt/universal-fetch" | ||
) as jest.Mocked<typeof UniversalFetch>; | ||
// Mocks a refresher which refreshes only once to prevent re-scheduling timeouts. | ||
@@ -595,4 +595,4 @@ // This would not be necessary with mock timers. | ||
const { fetch: mockedFetch } = jest.requireMock( | ||
"cross-fetch" | ||
) as jest.Mocked<typeof CrossFetch>; | ||
"@inrupt/universal-fetch" | ||
) as jest.Mocked<typeof UniversalFetch>; | ||
const mockedFreshener = mockTokenRefresher(mockDefaultTokenSet()); | ||
@@ -642,4 +642,4 @@ mockedFreshener.refresh = jest | ||
const { fetch: mockedFetch } = jest.requireMock( | ||
"cross-fetch" | ||
) as jest.Mocked<typeof CrossFetch>; | ||
"@inrupt/universal-fetch" | ||
) as jest.Mocked<typeof UniversalFetch>; | ||
const mockedFreshener = mockTokenRefresher(mockDefaultTokenSet()); | ||
@@ -676,4 +676,4 @@ mockedFreshener.refresh = jest | ||
const { fetch: mockedFetch } = jest.requireMock( | ||
"cross-fetch" | ||
) as jest.Mocked<typeof CrossFetch>; | ||
"@inrupt/universal-fetch" | ||
) as jest.Mocked<typeof UniversalFetch>; | ||
const mockedFreshener = mockTokenRefresher(mockDefaultTokenSet()); | ||
@@ -706,4 +706,4 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const { fetch: mockedFetch } = jest.requireMock( | ||
"cross-fetch" | ||
) as jest.Mocked<typeof CrossFetch>; | ||
"@inrupt/universal-fetch" | ||
) as jest.Mocked<typeof UniversalFetch>; | ||
const spyTimeout = jest.spyOn(global, "setTimeout"); | ||
@@ -710,0 +710,0 @@ await buildAuthenticatedFetch(mockedFetch, "myToken"); |
@@ -23,3 +23,3 @@ // | ||
// eslint-disable-next-line no-shadow | ||
import { fetch, Headers } from "cross-fetch"; | ||
import { fetch, Headers } from "@inrupt/universal-fetch"; | ||
import { EventEmitter } from "events"; | ||
@@ -26,0 +26,0 @@ import { REFRESH_BEFORE_EXPIRATION_SECONDS, EVENTS } from "../constant"; |
@@ -28,3 +28,3 @@ // | ||
// eslint-disable-next-line no-shadow | ||
import { fetch } from "cross-fetch"; | ||
import { fetch } from "@inrupt/universal-fetch"; | ||
import { EventEmitter } from "events"; | ||
@@ -31,0 +31,0 @@ import IHandleable from "../../util/handlerPattern/IHandleable"; |
@@ -24,12 +24,12 @@ // | ||
import { JWTPayload, KeyLike, SignJWT, generateKeyPair, exportJWK } from "jose"; | ||
import { Response as NodeResponse } from "cross-fetch"; | ||
import type * as CrossFetch from "cross-fetch"; | ||
import { Response as NodeResponse } from "@inrupt/universal-fetch"; | ||
import type * as UniversalFetch from "@inrupt/universal-fetch"; | ||
import { getWebidFromTokenPayload } from "./token"; | ||
jest.mock("cross-fetch", () => { | ||
jest.mock("@inrupt/universal-fetch", () => { | ||
return { | ||
...(jest.requireActual("cross-fetch") as typeof CrossFetch), | ||
default: jest.fn(), | ||
fetch: jest.fn(), | ||
} as typeof CrossFetch; | ||
...(jest.requireActual("@inrupt/universal-fetch") as typeof UniversalFetch), | ||
default: jest.fn<typeof fetch>(), | ||
fetch: jest.fn<typeof fetch>(), | ||
}; | ||
}); | ||
@@ -80,8 +80,12 @@ | ||
const mockFetch = (payload: string, statusCode: number): void => { | ||
const mockFetch = ( | ||
payload: string, | ||
statusCode: number, | ||
statusText?: string | ||
): void => { | ||
const { fetch: mockedFetch } = jest.requireMock( | ||
"cross-fetch" | ||
) as jest.Mocked<typeof CrossFetch>; | ||
"@inrupt/universal-fetch" | ||
) as jest.Mocked<typeof UniversalFetch>; | ||
mockedFetch.mockResolvedValueOnce( | ||
new NodeResponse(payload, { status: statusCode }) | ||
new NodeResponse(payload, { status: statusCode, statusText }) | ||
); | ||
@@ -91,3 +95,3 @@ }; | ||
it("throws if the JWKS cannot be fetched", async () => { | ||
mockFetch("", 404); | ||
mockFetch("", 404, "Not Found"); | ||
const jwt = await mockJwt( | ||
@@ -94,0 +98,0 @@ { someClaim: true }, |
@@ -23,3 +23,3 @@ // | ||
// eslint-disable-next-line no-shadow | ||
import { fetch } from "cross-fetch"; | ||
import { fetch } from "@inrupt/universal-fetch"; | ||
import { JWK, JWTPayload, jwtVerify, importJWK } from "jose"; | ||
@@ -26,0 +26,0 @@ |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
331321
166
7049
2
2
- Removedcross-fetch@^3.1.5
- Removedcross-fetch@3.2.0(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)