Skip to content

Commit 48566f4

Browse files
committed
WIP
1 parent ee9caf9 commit 48566f4

36 files changed

Lines changed: 1436 additions & 265 deletions

packages/css/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@
4646
"types": "./dist/index.d.ts",
4747
"exports": {
4848
"./package.json": "./package.json",
49-
".": {
50-
"require": "./dist/index.js"
51-
}
49+
".": "./dist/index.js"
5250
},
5351
"files": [
5452
".componentsignore",

packages/css/test/unit/util/fetch/SignedFetcher.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('SignedFetcher', (): void => {
2929
alg: 'ES256',
3030
getPrivateKey: vi.fn().mockResolvedValue(jwk),
3131
getPublicKey: vi.fn(),
32-
}
32+
};
3333

3434
source = {
3535
fetch: vi.fn().mockResolvedValue('result'),

packages/ucp/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@
4141
"types": "./dist/index.d.ts",
4242
"exports": {
4343
"./package.json": "./package.json",
44-
".": {
45-
"require": "./dist/index.js"
46-
}
44+
".": "./dist/index.js"
4745
},
4846
"files": [
4947
".componentsignore",

packages/uma/config/routes/introspection.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"methods": [ "POST" ],
1010
"handler": {
1111
"@type": "IntrospectionHandler",
12-
"tokenStore": { "@id": "urn:uma:default:TokenStore" },
13-
"jwtTokenFactory": { "@id": "urn:uma:default:TokenFactory" }
12+
"tokenStore": { "@id": "urn:uma:default:TokenStore" }
1413
},
1514
"path": "/uma/introspect"
1615
}

packages/uma/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@
4242
"types": "./dist/index.d.ts",
4343
"exports": {
4444
"./package.json": "./package.json",
45-
".": {
46-
"require": "./dist/index.js"
47-
}
45+
".": "./dist/index.js"
4846
},
4947
"files": [
5048
".componentsignore",

packages/uma/src/credentials/verify/JwtVerifier.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,14 @@ export class JwtVerifier implements Verifier {
5353
await jwtVerify(credential.token, Object.assign(jwk, { type: 'JWK' }));
5454
}
5555

56-
for (const claim of Object.keys(claims)) if (!this.allowedClaims.includes(claim)) {
57-
if (this.errorOnExtraClaims) throw new Error(`Claim '${claim}' not allowed.`);
56+
for (const claim of Object.keys(claims)) {
57+
if (!this.allowedClaims.includes(claim)) {
58+
if (this.errorOnExtraClaims) {
59+
throw new Error(`Claim '${claim}' not allowed.`);
60+
}
5861

59-
delete claims[claim];
62+
delete claims[claim];
63+
}
6064
}
6165

6266
this.logger.debug(`Returning discovered claims: ${JSON.stringify(claims)}`)

packages/uma/src/credentials/verify/SolidOidcVerifier.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getLoggerFor } from '@solid/community-server';
1+
import { BadRequestHttpError, getLoggerFor } from '@solid/community-server';
22
import { Verifier } from './Verifier';
33
import { ClaimSet } from '../ClaimSet';
44
import { Credential } from "../Credential";
@@ -18,7 +18,7 @@ export class SolidOidcVerifier implements Verifier {
1818
public async verify(credential: Credential): Promise<ClaimSet> {
1919
this.logger.debug(`Verifying credential ${JSON.stringify(credential)}`);
2020
if (credential.format !== OIDC) {
21-
throw new Error(`Token format ${credential.format} does not match this processor's format.`);
21+
throw new BadRequestHttpError(`Token format ${credential.format} does not match this processor's format.`);
2222
}
2323

2424
try {
@@ -35,7 +35,7 @@ export class SolidOidcVerifier implements Verifier {
3535
const message = `Error verifying OIDC ID Token: ${(error as Error).message}`;
3636

3737
this.logger.debug(message);
38-
throw new Error(message);
38+
throw new BadRequestHttpError(message);
3939
}
4040
}
4141
}

packages/uma/src/dialog/BaseNegotiator.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ import { serializePolicyInstantiation } from '../logging/OperationSerializer';
2323
*/
2424
export class BaseNegotiator implements Negotiator {
2525
protected readonly logger = getLoggerFor(this);
26-
operationLogger = getOperationLogger();
26+
protected readonly operationLogger = getOperationLogger();
2727

2828
/**
2929
* Construct a new Negotiator
3030
* @param verifier - The Verifier used to verify Claims of incoming Credentials.
3131
* @param ticketStore - A KeyValueStorage to track Tickets.
32-
* @param ticketManager - The strategy describing the life cycle of a Ticket.
32+
* @param ticketingStrategy - The strategy describing the life cycle of a Ticket.
3333
* @param tokenFactory - A factory for minting Access Tokens.
3434
*/
3535
public constructor(
@@ -41,10 +41,6 @@ export class BaseNegotiator implements Negotiator {
4141

4242
/**
4343
* Performs UMA grant negotiation.
44-
*
45-
* @param {TokenRequest} body - request body
46-
* @param {HttpHandlerContext} context - request context
47-
* @return {Promise<TokenResponse>} tokens - yielded tokens
4844
*/
4945
public async negotiate(input: DialogInput): Promise<DialogOutput> {
5046
reType(input, DialogInput);

packages/uma/src/dialog/ContractNegotiator.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ import { DialogOutput } from './Output';
2121
export class ContractNegotiator extends BaseNegotiator {
2222
protected readonly logger = getLoggerFor(this);
2323

24-
// protected readonly operationLogger = getOperationLogger();
2524
protected readonly contractManager = new ContractManager();
2625

2726
/**
2827
* Construct a new Negotiator
2928
* @param verifier - The Verifier used to verify Claims of incoming Credentials.
3029
* @param ticketStore - A KeyValueStore to track Tickets.
31-
* @param ticketManager - The strategy describing the life cycle of a Ticket.
30+
* @param ticketingStrategy - The strategy describing the life cycle of a Ticket.
3231
* @param tokenFactory - A factory for minting Access Tokens.
3332
*/
3433
public constructor(
@@ -43,15 +42,15 @@ export class ContractNegotiator extends BaseNegotiator {
4342

4443
/**
4544
* Performs UMA grant negotiation.
46-
*
47-
* @param {TokenRequest} body - request body
48-
* @param {HttpHandlerContext} context - request context
49-
* @return {Promise<TokenResponse>} tokens - yielded tokens
5045
*/
5146
public async negotiate(input: DialogInput): Promise<DialogOutput> {
5247
reType(input, DialogInput);
53-
if (!input.permissions && input.permission?.length)
54-
input.permissions = input.permission.map(p => processRequestPermission(p))
48+
if (!input.permissions && input.permission?.length) {
49+
input = {
50+
...input,
51+
permissions: input.permission.map(p => processRequestPermission(p)),
52+
};
53+
}
5554
this.logger.debug(`Input. ${JSON.stringify(input)}`);
5655
// Create or retrieve ticket
5756
const ticket = await this.getTicket(input);
@@ -170,7 +169,7 @@ export class ContractNegotiator extends BaseNegotiator {
170169
const policyCreationResponse = await fetch(instantiatedPolicyContainer, {
171170
method: 'POST',
172171
headers: { 'content-type': 'application/ld+json' },
173-
body: JSON.stringify(contract, null, 2)
172+
body: JSON.stringify(contract),
174173
});
175174

176175
if (policyCreationResponse.status !== 201) {

packages/uma/src/policies/authorizers/NamespacedAuthorizer.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import { getLoggerFor, KeyValueStorage } from '@solid/community-server';
22
import { ResourceDescription } from '../../views/ResourceDescription';
33
import { Authorizer } from './Authorizer';
44
import { Permission } from '../../views/Permission';
5-
import { Requirements, type ClaimVerifier } from '../../credentials/Requirements';
5+
import { Requirements } from '../../credentials/Requirements';
66
import { ClaimSet } from '../../credentials/ClaimSet';
77

8-
const NO_RESOURCE = Symbol();
98
const namespace = (resource: string) => new URL(resource).pathname.split('/')?.[2] ?? '';
109

1110
/**
@@ -39,8 +38,8 @@ export class NamespacedAuthorizer implements Authorizer {
3938
const ns = query[0].resource_id ? await this.findNamespace(query[0].resource_id) : undefined;
4039

4140
// Check namespaces of other resources
42-
for (const permission of query) {
43-
if ((permission.resource_id ? namespace(permission.resource_id) : undefined) !== ns) {
41+
for (let i = 1; i < query.length; ++i) {
42+
if ((query[i].resource_id ? await this.findNamespace(query[i].resource_id) : undefined) !== ns) {
4443
this.logger.warn(`Cannot calculate permissions over multiple namespaces at once.`);
4544
return [];
4645
}
@@ -64,8 +63,8 @@ export class NamespacedAuthorizer implements Authorizer {
6463
const ns = await this.findNamespace(permissions[0].resource_id);
6564

6665
// Check namespaces of other resources
67-
for (const permission of permissions) {
68-
if (namespace(permission.resource_id) !== ns) {
66+
for (let i = 1; i < permissions.length; ++i) {
67+
if (await this.findNamespace(permissions[i].resource_id) !== ns) {
6968
this.logger.warn(`Cannot calculate credentials over multiple namespaces at once.`);
7069
return [];
7170
}

0 commit comments

Comments
 (0)