Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: credentials updates #55

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/api-credentials/src/app/verify/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ verifyDiscordApp.get(
handle: user.username,
verifiedAt: new Date().toISOString(),
platformProfileUrl: `https://discordapp.com/users/${user.id}`,
platformProfileImageUrl: `https://cdn.discordapp.com/avatars/${user.id}/${user.avatar}`,
},
});
const issuer =
Expand Down
4 changes: 2 additions & 2 deletions apps/api-credentials/src/app/verify/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ verifyGithubApp.get(
}

let credential: VerifiableCredential;

try {
credential = await createCredential({
credentialSubject: {
id: did,
platform: 'github',
platformUserId: user.id,
platformUserId: user.id.toString(),
handle: `@${user.login}`,
verifiedAt: new Date().toISOString(),
platformProfileUrl: `https://github.com/${user.login}`,
platformProfileImageUrl: user.avatar_url,
},
});
const issuer =
Expand Down
1 change: 1 addition & 0 deletions apps/api-credentials/src/app/verify/x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ verifyXApp.get(
handle: `@${user.username}`,
verifiedAt: new Date().toISOString(),
platformProfileUrl: `https://x.com/${user.username}`,
platformProfileImageUrl: user.profile_image_url,
},
});

Expand Down
14 changes: 11 additions & 3 deletions apps/api-credentials/src/lib/veramo/actions/create-credential.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { alias, veramoAgent } from '../agent.js';

type Platform = 'x' | 'github' | 'discord';

type CreateCredentialParams = {
// TODO: Process credential correctly
// biome-ignore lint/suspicious/noExplicitAny: any
credentialSubject: any;
credentialSubject: {
id: string;
platform: Platform;
platformUserId: string;
handle: string;
verifiedAt: string;
platformProfileUrl: string;
platformProfileImageUrl: string | undefined;
};
};
export async function createCredential({
credentialSubject,
Expand Down
11 changes: 11 additions & 0 deletions apps/api-credentials/src/scripts/create-identifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createIdentifier } from '../lib/veramo/actions/create-identifier.js';

async function main() {
const identifier = await createIdentifier();
console.log('New identifier created');
console.log(JSON.stringify(identifier, null, 2));
}

(async () => {
await main();
})();
Loading