Skip to content

Commit

Permalink
Chore: credentials updates (#55)
Browse files Browse the repository at this point in the history
* chore: add create identifier script

* feat: add profile image url to credential
  • Loading branch information
marthendalnunes authored Dec 5, 2024
1 parent 780ecf5 commit 1ca33fa
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
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();
})();

0 comments on commit 1ca33fa

Please sign in to comment.