chore(deps): update ts-dpop to v0.3.0

This commit is contained in:
Ruben Verborgh
2020-12-27 19:54:41 +01:00
parent a5c372c37c
commit 97e7e42fdc
5 changed files with 18 additions and 18 deletions

10
package-lock.json generated
View File

@@ -9413,15 +9413,15 @@
"integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw=="
},
"ts-dpop": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/ts-dpop/-/ts-dpop-0.2.7.tgz",
"integrity": "sha512-vu7xLgEVHzmUYonI6hfHeGXeGZiLSlDInI26AZ0UrFNBVqGR6OG+gIOF8t/Wtr+xPgFb0jJmMRMM5XPEij2Q7A==",
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/ts-dpop/-/ts-dpop-0.3.0.tgz",
"integrity": "sha512-5UzXARerh1kh8iYusP0IWL5NanosuDG+ORJpYAGi2ZXwItHrLhJOiECB8RoPeW73jOhJQgV2wSgjeGRv4pCIyQ==",
"requires": {
"cross-fetch": "^3.0.6",
"jose": "^3.3.2",
"jose": "^3.5.0",
"lru-cache": "^6.0.0",
"n3": "^1.6.4",
"nmspc": "^0.2.2",
"nmspc": "^0.2.4",
"rdf-data-factory": "^1.0.4",
"rdf-dereference": "^1.6.0",
"rdf-parse": "^1.6.1",

View File

@@ -101,7 +101,7 @@
"sparqlalgebrajs": "^2.3.1",
"sparqljs": "^3.1.2",
"streamify-array": "^1.0.1",
"ts-dpop": "^0.2.7",
"ts-dpop": "^0.3.0",
"uuid": "^8.3.0",
"winston": "^3.3.3",
"winston-transport": "^4.4.0",

View File

@@ -1,5 +1,5 @@
import type { RequestMethod, VerifySolidIdentityFunction } from 'ts-dpop';
import { createSolidIdentityVerifier } from 'ts-dpop';
import type { RequestMethod, SolidTokenVerifierFunction } from 'ts-dpop';
import { createSolidTokenVerifier } from 'ts-dpop';
import type { TargetExtractor } from '../ldp/http/TargetExtractor';
import { getLoggerFor } from '../logging/LogUtil';
import type { HttpRequest } from '../server/HttpRequest';
@@ -14,12 +14,12 @@ import { CredentialsExtractor } from './CredentialsExtractor';
export class DPoPWebIdExtractor extends CredentialsExtractor {
protected readonly logger = getLoggerFor(this);
private readonly targetExtractor: TargetExtractor;
private readonly verify: VerifySolidIdentityFunction;
private readonly verify: SolidTokenVerifierFunction;
public constructor(targetExtractor: TargetExtractor) {
super();
this.targetExtractor = targetExtractor;
this.verify = createSolidIdentityVerifier();
this.verify = createSolidTokenVerifier();
}
public async canHandle({ headers }: HttpRequest): Promise<void> {

View File

@@ -1,4 +1,4 @@
import type { VerifySolidIdentityFunction } from 'ts-dpop';
import type { SolidTokenVerifierFunction } from 'ts-dpop';
const solidIdentityVerifier = jest.fn().mockResolvedValue({ aud: 'solid', exp: 1234, iat: 1234, iss: 'example.com/idp', webid: 'http://alice.example/card#me' });
export const createSolidIdentityVerifier = jest.fn((): VerifySolidIdentityFunction => solidIdentityVerifier);
const solidTokenVerifier = jest.fn().mockResolvedValue({ aud: 'solid', exp: 1234, iat: 1234, iss: 'example.com/idp', webid: 'http://alice.example/card#me' });
export const createSolidTokenVerifier = jest.fn((): SolidTokenVerifierFunction => solidTokenVerifier);

View File

@@ -1,11 +1,11 @@
import { createSolidIdentityVerifier } from 'ts-dpop';
import { createSolidTokenVerifier } from 'ts-dpop';
import { DPoPWebIdExtractor } from '../../../src/authentication/DPoPWebIdExtractor';
import type { HttpRequest } from '../../../src/server/HttpRequest';
import { BadRequestHttpError } from '../../../src/util/errors/BadRequestHttpError';
import { NotImplementedHttpError } from '../../../src/util/errors/NotImplementedHttpError';
import { StaticAsyncHandler } from '../../util/StaticAsyncHandler';
const solidIdentityVerifier = createSolidIdentityVerifier() as jest.MockedFunction<any>;
const solidTokenVerifier = createSolidTokenVerifier() as jest.MockedFunction<any>;
describe('A DPoPWebIdExtractor', (): void => {
const targetExtractor = new StaticAsyncHandler(true, { path: 'http://example.org/foo/bar' });
@@ -79,8 +79,8 @@ describe('A DPoPWebIdExtractor', (): void => {
it('calls the DPoP verifier with the correct parameters.', async(): Promise<void> => {
await webIdExtractor.handleSafe(request);
expect(solidIdentityVerifier).toHaveBeenCalledTimes(1);
expect(solidIdentityVerifier).toHaveBeenCalledWith('DPoP token-1234', 'token-5678', 'GET', 'http://example.org/foo/bar');
expect(solidTokenVerifier).toHaveBeenCalledTimes(1);
expect(solidTokenVerifier).toHaveBeenCalledWith('DPoP token-1234', 'token-5678', 'GET', 'http://example.org/foo/bar');
});
it('returns the extracted WebID.', async(): Promise<void> => {
@@ -99,7 +99,7 @@ describe('A DPoPWebIdExtractor', (): void => {
} as any as HttpRequest;
beforeEach((): void => {
solidIdentityVerifier.mockImplementationOnce((): void => {
solidTokenVerifier.mockImplementationOnce((): void => {
throw new Error('invalid');
});
});