chore: Update dependencies

This commit is contained in:
Joachim Van Herwegen
2021-06-29 11:29:38 +02:00
parent d01382d36e
commit 5edbbc1958
37 changed files with 2904 additions and 3617 deletions

View File

@@ -30,7 +30,7 @@ export class BearerWebIdExtractor extends CredentialsExtractor {
const { headers: { authorization }} = request;
try {
const { webid: webId } = await this.verify(authorization as string);
const { webid: webId } = await this.verify(authorization!);
this.logger.info(`Verified WebID via Bearer access token: ${webId}`);
return { webId };
} catch (error: unknown) {

View File

@@ -45,7 +45,7 @@ export class DPoPWebIdExtractor extends CredentialsExtractor {
// and extract the WebID provided by the client
try {
const { webid: webId } = await this.verify(
authorization as string,
authorization!,
{
header: dpop as string,
method: method as RequestMethod,

View File

@@ -18,7 +18,7 @@ export class UnsecureWebIdExtractor extends CredentialsExtractor {
}
public async handle({ headers }: HttpRequest): Promise<Credentials> {
const webId = /^WebID\s+(.*)/u.exec(headers.authorization as string)![1];
const webId = /^WebID\s+(.*)/u.exec(headers.authorization!)![1];
this.logger.info(`Agent unsecurely claims to be ${webId}`);
return { webId };
}

View File

@@ -46,6 +46,8 @@ export class KeyConfigurationFactory implements ConfigurationFactory {
// If they are not, generate and save them
const { privateKey } = await generateKeyPair('RS256');
const jwk = await fromKeyLike(privateKey);
// Required for Solid authn client
jwk.alg = 'RS256';
// In node v15.12.0 the JWKS does not get accepted because the JWK is not a plain object,
// which is why we convert it into a plain object here.
// Potentially this can be changed at a later point in time to `{ keys: [ jwk ]}`.

View File

@@ -19,6 +19,6 @@ export class SessionHttpHandler extends InteractionHttpHandler {
if (!details.session || !details.session.accountId) {
throw new NotImplementedHttpError('Only confirm actions with a session and accountId are supported');
}
await this.interactionCompleter.handleSafe({ ...input, webId: details.session.accountId });
await this.interactionCompleter.handleSafe({ ...input, webId: details.session.accountId as any });
}
}

View File

@@ -188,16 +188,16 @@ export class RegistrationHandler extends HttpHandler {
* Verifies that all the data combinations make sense.
*/
private validateInput(parsed: NodeJS.Dict<string>): ParseResult {
const { email, password, confirmPassword, podName, webId } = parsed;
const { email, password, confirmPassword, podName, webId, createWebId, register, createPod } = parsed;
assert(typeof email === 'string' && email.length > 0 && emailRegex.test(email),
'A valid e-mail address is required');
const result: ParseResult = {
email,
createWebId: Boolean(parsed.createWebId),
register: Boolean(parsed.register),
createPod: Boolean(parsed.createPod),
createWebId: Boolean(createWebId),
register: Boolean(register),
createPod: Boolean(createPod),
data: parsed,
};

View File

@@ -54,7 +54,7 @@ export class ExpiringAdapter implements Adapter {
if (payload.grantId) {
storagePromises.push(
(async(): Promise<void> => {
const grantKey = this.grantKeyFor(payload.grantId as string);
const grantKey = this.grantKeyFor(payload.grantId!);
const grants = (await this.storage.get(grantKey) || []) as string[];
grants.push(key);
await this.storage.set(grantKey, grants, expires);

View File

@@ -200,6 +200,7 @@ export * from './server/BaseHttpServerFactory';
export * from './server/HttpHandler';
export * from './server/HttpRequest';
export * from './server/HttpResponse';
export * from './server/HttpServerFactory';
export * from './server/WebSocketServerFactory';
export * from './server/WebSocketHandler';

View File

@@ -7,6 +7,7 @@ import yargs from 'yargs';
import { getLoggerFor } from '../logging/LogUtil';
import { absoluteFilePath, ensureTrailingSlash, joinFilePath } from '../util/PathUtil';
import type { App } from './App';
export class AppRunner {
private readonly logger = getLoggerFor(this);
@@ -56,7 +57,8 @@ export class AppRunner {
stderr?: WriteStream;
} = {}): void {
// Parse the command-line arguments
const { argv: params } = yargs(argv.slice(2))
// eslint-disable-next-line no-sync
const params = yargs(argv.slice(2))
.strict()
.usage('node ./bin/server.js [args]')
.check((args): boolean => {
@@ -84,7 +86,7 @@ export class AppRunner {
sparqlEndpoint: { type: 'string', alias: 's', requiresArg: true },
podConfigJson: { type: 'string', default: './pod-config.json', requiresArg: true },
})
.help();
.parseSync();
// Gather settings for instantiating the server
const loaderProperties: IComponentsManagerBuilderOptions<App> = {

View File

@@ -207,11 +207,9 @@ export class DataAccessorBasedStore implements ResourceStore {
// if it contains no resources. If the container contains resources,
// the server MUST respond with the 409 status code and response body describing the error."
// https://solid.github.io/specification/protocol#deleting-resources
if (isContainerIdentifier(identifier)) {
// Auxiliary resources are not counted when deleting a container since they will also be deleted
if (await this.hasProperChildren(identifier)) {
throw new ConflictHttpError('Can only delete empty containers.');
}
// Auxiliary resources are not counted when deleting a container since they will also be deleted.
if (isContainerIdentifier(identifier) && await this.hasProperChildren(identifier)) {
throw new ConflictHttpError('Can only delete empty containers.');
}
// Solid, §5.4: "When a contained resource is deleted, the server MUST also delete the associated auxiliary
// resources"
@@ -291,9 +289,8 @@ export class DataAccessorBasedStore implements ResourceStore {
createContainers?: boolean): Promise<ResourceIdentifier[]> {
// Make sure the metadata has the correct identifier and correct type quads
// Need to do this before handling container data to have the correct identifier
const { metadata } = representation;
metadata.identifier = DataFactory.namedNode(identifier.path);
addResourceMetadata(metadata, isContainer);
representation.metadata.identifier = DataFactory.namedNode(identifier.path);
addResourceMetadata(representation.metadata, isContainer);
// Validate container data
if (isContainer) {

View File

@@ -142,8 +142,8 @@ export class ChainedConverter extends RepresentationConverter {
return input.representation;
}
const { path } = match;
this.logger.debug(`Converting ${match.inType} -> ${[ ...path.intermediateTypes, match.outType ].join(' -> ')}.`);
const { path, inType, outType } = match;
this.logger.debug(`Converting ${inType} -> ${[ ...path.intermediateTypes, outType ].join(' -> ')}.`);
const args = { ...input };
for (let i = 0; i < path.converters.length - 1; ++i) {
@@ -152,7 +152,7 @@ export class ChainedConverter extends RepresentationConverter {
args.representation = await path.converters[i].handle(args);
}
// For the last converter we set the preferences to the best output type
args.preferences = { type: { [match.outType]: 1 }};
args.preferences = { type: { [outType]: 1 }};
return path.converters.slice(-1)[0].handle(args);
}

View File

@@ -44,7 +44,7 @@ export class IfNeededConverter extends RepresentationConverter {
const noMatchingMediaType = !matchesMediaPreferences(contentType, preferences.type);
if (noMatchingMediaType) {
this.logger.debug(`Conversion needed for ${identifier
.path} from ${representation.metadata.contentType} to satisfy ${!preferences.type ?
.path} from ${contentType} to satisfy ${!preferences.type ?
'""' :
Object.entries(preferences.type).map(([ value, weight ]): string => `${value};q=${weight}`).join(', ')}`);
}

View File

@@ -142,6 +142,6 @@ export class SparqlUpdatePatchHandler extends ConvertingPatchHandler {
this.logger.debug(`${result.size} quads will be stored to ${identifier.path}.`);
return new BasicRepresentation(result.match() as Readable, metadata);
return new BasicRepresentation(result.match() as unknown as Readable, metadata);
}
}

View File

@@ -39,7 +39,7 @@ export class ConvertingRouterRule extends RouterRule {
entry.supportChecker.supports({ identifier, representation }));
} else {
// No content-type given so we can only check if one of the stores has data for the identifier
store = await this.findStore(async(entry): Promise<boolean> => entry.store.resourceExists(input.identifier));
store = await this.findStore(async(entry): Promise<boolean> => entry.store.resourceExists(identifier));
}
return store;
}

View File

@@ -144,7 +144,7 @@ export function isContainerIdentifier(identifier: ResourceIdentifier): boolean {
* E.g., `http://test.com/` results in `{ scheme: 'http://', rest: 'test.com/' }`.
* @param url - String to parse.
*/
export function extractScheme(url: string): { scheme: string; rest: string} {
export function extractScheme(url: string): { scheme: string; rest: string } {
const match = /^([^:]+:\/\/)(.*)$/u.exec(url)!;
return { scheme: match[1], rest: match[2] };
}

View File

@@ -1,4 +1,4 @@
/* eslint-disable @typescript-eslint/naming-convention, function-paren-newline */
/* eslint-disable function-paren-newline */
import { namedNode } from '@rdfjs/data-model';
import type { NamedNode } from 'rdf-js';