Skip to content

Commit 6171925

Browse files
committed
Patch identity core security flow
1 parent 1816258 commit 6171925

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

identity-core/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.

identity-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@interdead/identity-core",
3-
"version": "0.1.8",
3+
"version": "0.1.9",
44
"description": "Headless identity kernel that wires Discord OAuth with portable storage adapters using a hexagonal/ports-and-adapters layout.",
55
"type": "module",
66
"main": "dist/esm/index.js",

identity-core/src/adapters/CloudflareProfileRepositoryAdapter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface CloudflareBindings {
1111
readonly kv?: {
1212
get: (key: string) => Promise<string | null>;
1313
put: (key: string, value: string) => Promise<void>;
14+
delete: (key: string) => Promise<void>;
1415
};
1516
}
1617

@@ -51,7 +52,7 @@ export class CloudflareProfileRepositoryAdapter implements IIdentityRepository {
5152
"DELETE FROM profiles WHERE profile_id = ?",
5253
[profileId],
5354
);
54-
await this.bindings.kv?.put(`identity:${profileId}`, "");
55+
await this.bindings.kv?.delete(`identity:${profileId}`);
5556
this.logger.warn("Deleted profile from Cloudflare", { profileId });
5657
}
5758
}

identity-core/src/application/IdentityLinkService.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ILogger,
99
ISessionStore,
1010
} from "../ports/index.js";
11+
import { IdentityCoreError } from "../utils/errorMapper.js";
1112

1213
export interface IdentityLinkOptions {
1314
readonly allowUsernameOverride?: boolean;
@@ -42,6 +43,12 @@ export class IdentityLinkService {
4243
throw new Error("Discord OAuth is disabled for this runtime");
4344
}
4445

46+
if (metadata.profileId !== profileId) {
47+
throw new IdentityCoreError(
48+
"Profile metadata does not match requested profile id",
49+
);
50+
}
51+
4552
const linkPayload: DiscordProfileLink =
4653
options.discordLink ?? (await this.discordPort.exchangeCode(code));
4754
const policy = options.policy ?? new DiscordLinkPolicy();

0 commit comments

Comments
 (0)