Skip to content

Commit 23ac20e

Browse files
committed
refactor: Minor cleanups
1 parent d118a99 commit 23ac20e

3 files changed

Lines changed: 11 additions & 12 deletions

File tree

packages/css/src/authorization/UmaAuthorizer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ export const WWW_AUTH = namedNode('urn:css:http:headers:www-authenticate');
1212

1313
/**
1414
* Authorizer that bases its decision on that of another Authorizer.
15-
* It discovers the relevant UMA Authorization Server for the requeste resource(s),
15+
* It discovers the relevant UMA Authorization Server for the requested resource(s),
1616
* and checks whether that server protects the resource or whether it is public.
1717
* If the resource is not public and access is not granted by the other Authorizer,
18-
* the UmaAuthorizer includes a UMA Permission Ticket in the resulting error.
18+
* the UmaAuthorizer includes an UMA Permission Ticket in the resulting error.
1919
*/
2020
export class UmaAuthorizer extends Authorizer {
2121
protected readonly logger = getLoggerFor(this);
2222

2323
/**
2424
* The UmaAuthorizer bases its decisions on those of another {@link Authorizer}.
2525
* It uses an {@link OwnerUtil} to retrieve the relevant UMA issuer,
26-
* and an {@link UmaCLient} to communicate with that issuer.
26+
* and an {@link UmaClient} to communicate with that issuer.
2727
* @param authorizer - {@link Authorizer} that makes the main decision.
2828
* @param ownerUtil - {@link OwnerUtil} that links resources to owners and issuers.
2929
* @param umaClient - {@link UmaClient} that communicates with UMA issuers.

packages/css/src/authorization/UmaPermissionReader.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getLoggerFor, PermissionReader, PermissionReaderInput,
1+
import { getLoggerFor, PermissionReader, PermissionReaderInput,
22
PermissionMap, PermissionSet, IdentifierMap } from '@solid/community-server';
33
import { UmaClaims } from '../uma/UmaClient';
44

@@ -20,25 +20,25 @@ export class UmaPermissionReader extends PermissionReader {
2020
const { permissions, iat: t_iat, exp: t_exp, nbf: t_nbf } = rpt;
2121

2222
this.logger.info(`Reading UMA permissions at ${now}`);
23-
23+
2424
try {
2525
if (t_iat && t_iat >= now) throw new Error(`Token seems to be issued in the future at ${t_iat}.`);
2626
if (t_exp && t_exp <= now) throw new Error(`Token is expired since ${t_exp}.`);
2727
if (t_nbf && t_nbf > now) throw new Error(`Token is not valid before ${t_nbf}.`);
28-
} catch (error) {
28+
} catch (error) {
2929
this.logger.warn(`Invalid UMA token: ${error instanceof Error ? error.message : ''}`);
3030
return result;
3131
}
32-
32+
3333
for (const { resource_id, resource_scopes, iat: p_iat, exp: p_exp, nbf: p_nbf } of permissions ?? []) {
3434
const permissionSet = Object.fromEntries(resource_scopes.map(scope => {
3535
try {
3636
if (p_iat && p_iat >= now) throw new Error(`UMA permission seems to be issued in the future at ${p_iat}.`);
3737
if (p_exp && p_exp <= now) throw new Error(`UMA permission is expired since ${p_exp}.`);
3838
if (p_nbf && p_nbf > now) throw new Error(`UMA permission is not valid before ${p_nbf}.`);
39-
} catch (error) {
39+
} catch (error) {
4040
this.logger.warn(`Invalid UMA permission: ${error instanceof Error ? error.message : ''}`);
41-
return [scope, false];
41+
return [scope.replace('urn:example:css:modes:', ''), false];
4242
}
4343
return [scope.replace('urn:example:css:modes:', ''), true];
4444
}));

packages/css/src/util/fetch/SignedFetcher.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ export class SignedFetcher implements Fetcher {
5252
...init ?? {},
5353
url,
5454
method: init?.method ?? 'GET',
55-
headers: {} as Record<string, string>
56-
}
57-
;
55+
headers: {} as Record<string, string>,
56+
};
5857
new Headers(init?.headers).forEach((value, key) => request.headers[key] = value);
5958
request.headers['Authorization'] = `HttpSig cred="${this.baseUrl}"`;
6059

0 commit comments

Comments
 (0)