Skip to content

Commit e53a792

Browse files
committed
Got security tests and examples working.
1 parent b0871d3 commit e53a792

File tree

11 files changed

+70
-819
lines changed

11 files changed

+70
-819
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,6 @@ cucumber-report.html
2828
nyc-coverage-report/
2929
.history/
3030
.rollup.cache
31-
tsconfig.tsbuildinfo
31+
tsconfig.tsbuildinfo
32+
**/html-report/
33+
packages/fdc3-security/junit.xml

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/fdc3-agent-proxy/src/channels/DefaultChannel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export class DefaultChannel implements Channel {
4545
payload: {
4646
channelId: this.id,
4747
context,
48+
metadata: {},
4849
},
4950
type: 'broadcastRequest',
5051
};

packages/fdc3-agent-proxy/src/listeners/DefaultContextListener.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ export class DefaultContextListener
5858

5959
action(m: BroadcastEvent): void {
6060
const metadata: DesktopAgentProvidableContextMetadata = {
61-
source: m.payload.originatingApp,
61+
source: m.payload.metadata?.source,
6262
timestamp: m.meta.timestamp,
63-
traceId: m.metadata?.traceId,
6463
};
6564
this.handler(m.payload.context, metadata);
6665
}

packages/fdc3-schema/generated/api/BrowserTypes.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,8 @@ export interface MessageAuthenticity {
13151315
*/
13161316
kid?: string;
13171317
/**
1318-
* Indicates whether the message was signed.
1318+
* Indicates whether the context includes a signature, but check other fields to see if the
1319+
* signature is valid.
13191320
*/
13201321
signed: boolean;
13211322
/**

packages/fdc3-schema/schemas/api/api.schema copy.json-bk

Lines changed: 0 additions & 740 deletions
This file was deleted.

packages/fdc3-schema/schemas/api/api.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"properties": {
5858
"signed": {
5959
"type": "boolean",
60-
"description": "Indicates whether the message was signed."
60+
"description": "Indicates whether the context includes a signature, but check other fields to see if the signature is valid."
6161
},
6262
"valid": {
6363
"type": "boolean",

packages/fdc3-security/junit.xml

Lines changed: 0 additions & 29 deletions
This file was deleted.

packages/fdc3-security/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
},
3535
"devDependencies": {
3636
"@cucumber/cucumber": "10.3.1",
37-
"@types/jest": "^29.5.12",
3837
"@cucumber/html-formatter": "11.0.4",
3938
"@cucumber/pretty-formatter": "1.0.1",
4039
"@eslint/js": "^9.19.0",
4140
"@finos/testing": "2.2.0",
4241
"@types/expect": "24.3.0",
42+
"@types/jest": "^29.5.12",
4343
"@types/lodash": "4.14.167",
4444
"@types/node": "^20.16.11",
4545
"@types/uuid": "^10.0.0",
@@ -67,4 +67,4 @@
6767
"typescript-eslint": "^8.17.0",
6868
"uuid": "^9.0.1"
6969
}
70-
}
70+
}

packages/fdc3-security/src/impl/JosePublicFDC3Security.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -157,39 +157,40 @@ export class JosePublicFDC3Security implements PublicFDC3Security {
157157

158158
const result = await jose.compactVerify(reconstitutedJws, jwksEndpoint, {});
159159

160+
const errors: string[] = [];
161+
160162
// Check signature freshness (based on iat in header)
161163
if (iat && now - iat > this.timeLimits.signatureFreshnessSeconds) {
162-
return {
163-
signed: true,
164-
valid: false,
165-
trusted: false,
166-
antiReplayClaims: antiReplay,
167-
168-
errors: [
169-
`Signature is too old (iat: ${iat}, now: ${now}, max age: ${this.timeLimits.signatureFreshnessSeconds}s)`,
170-
],
171-
};
164+
errors.push(
165+
`Signature is too old (iat: ${iat}, now: ${now}, max age: ${this.timeLimits.signatureFreshnessSeconds}s)`
166+
);
172167
}
173168

174169
// Check context expiry (based on exp in antiReplay)
175170
if (antiReplay.exp && now > antiReplay.exp) {
176-
return {
177-
signed: false,
178-
errors: [`Context has expired (exp: ${antiReplay.exp}, now: ${now})`],
179-
};
171+
errors.push(`Context has expired (exp: ${antiReplay.exp}, now: ${now})`);
180172
}
181173

182174
// Check pluggable anti-replay claims (like jti)
183175
if (this.antiReplayChecker) {
184176
const replayValid = await this.antiReplayChecker.check(antiReplay);
185177
if (!replayValid) {
186-
return {
187-
signed: false,
188-
errors: [`Anti-replay check failed for jti: ${antiReplay.jti}`],
189-
};
178+
errors.push(`Anti-replay check failed for jti: ${antiReplay.jti}`);
190179
}
191180
}
192181

182+
if (errors.length > 0) {
183+
return {
184+
signed: true,
185+
valid: false,
186+
alg,
187+
kid,
188+
jku,
189+
antiReplayClaims: antiReplay,
190+
errors,
191+
};
192+
}
193+
193194
return {
194195
signed: true,
195196
valid: result.payload != null,

0 commit comments

Comments
 (0)