-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Timo Glastra <[email protected]>
- Loading branch information
1 parent
3f044c5
commit 318f5cf
Showing
27 changed files
with
998 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,10 +122,12 @@ jobs: | |
uses: appleboy/[email protected] | ||
env: | ||
AGENT_WALLET_KEY: ${{ secrets.AGENT_WALLET_KEY }} | ||
CHEQD_TESTNET_COSMOS_PAYER_SEED: ${{ secrets.CHEQD_TESTNET_COSMOS_PAYER_SEED }} | ||
DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED: ${{ secrets.DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED }} | ||
with: | ||
host: dashboard.dev.animo.id | ||
username: root | ||
key: ${{ secrets.DOCKER_SSH_PRIVATE_KEY }} | ||
envs: AGENT_WALLET_KEY | ||
envs: AGENT_WALLET_KEY,DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED,CHEQD_TESTNET_COSMOS_PAYER_SEED | ||
script: | | ||
AGENT_WALLET_KEY=${AGENT_WALLET_KEY} docker stack deploy --compose-file openid4vc-playground/docker-compose.yml openid4vc-playground --with-registry-auth | ||
AGENT_WALLET_KEY=${AGENT_WALLET_KEY} CHEQD_TESTNET_COSMOS_PAYER_SEED=${CHEQD_TESTNET_COSMOS_PAYER_SEED} DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED=${DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED} docker stack deploy --compose-file openid4vc-playground/docker-compose.yml openid4vc-playground --with-registry-auth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
AGENT_HOST=http://localhost:3001 | ||
AGENT_WALLET_KEY=secret-wallet-key | ||
AGENT_WALLET_KEY=secret-wallet-key | ||
DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED=2543786a945a27258087ccfe95ff62df | ||
CHEQD_TESTNET_COSMOS_PAYER_SEED=robust across amount corn curve panther opera wish toe ring bleak empower wreck party abstract glad average muffin picnic jar squeeze annual long aunt |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
export const AGENT_HOST = process.env.AGENT_HOST ?? "http://localhost:3001"; | ||
export const AGENT_WALLET_KEY = | ||
process.env.AGENT_WALLET_KEY ?? "openid4vc-playground"; | ||
|
||
export const DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED = | ||
process.env.DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED; | ||
|
||
export const CHEQD_TESTNET_COSMOS_PAYER_SEED = | ||
process.env.CHEQD_TESTNET_COSMOS_PAYER_SEED; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { agent } from "../agent"; | ||
import { CheqdDidCreateOptions } from "@aries-framework/cheqd"; | ||
|
||
export async function createDidCheqd() { | ||
const didResult = await agent.dids.create<CheqdDidCreateOptions>({ | ||
method: "cheqd", | ||
options: { | ||
network: "testnet", | ||
methodSpecificIdAlgo: "base58btc", | ||
}, | ||
secret: { | ||
// FIXME: verificationMethod should be optional in AFJ for cheqd | ||
verificationMethod: { | ||
id: "key-1", | ||
type: "Ed25519VerificationKey2020", | ||
}, | ||
}, | ||
}); | ||
|
||
if (didResult.didState.state === "failed") { | ||
throw new Error("cheqd DID creation failed. " + didResult.didState.reason); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from "./util"; | ||
export * from "./web"; | ||
export * from "./jwk"; | ||
export * from "./key"; | ||
export * from "./cheqd"; | ||
export * from "./indy"; | ||
export * from "./setup"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { KeyType, TypedArrayEncoder } from "@aries-framework/core"; | ||
import { indyDidFromPublicKeyBase58 } from "@aries-framework/core/build/utils"; | ||
import { agent } from "../agent"; | ||
|
||
export async function importIndyDid( | ||
namespaceIdentifier: string, | ||
privateKey: string | ||
) { | ||
const key = await agent.wallet.createKey({ | ||
keyType: KeyType.Ed25519, | ||
privateKey: TypedArrayEncoder.fromString(privateKey), | ||
}); | ||
|
||
const indyDid = `did:indy:${namespaceIdentifier}:${indyDidFromPublicKeyBase58( | ||
key.publicKeyBase58 | ||
)}`; | ||
|
||
console.log({ | ||
indyDid, | ||
publicKeyBase58: key.publicKeyBase58, | ||
}); | ||
await agent.dids.import({ | ||
did: indyDid, | ||
overwrite: true, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { KeyType, JwkDidCreateOptions } from "@aries-framework/core"; | ||
import { agent } from "../agent"; | ||
|
||
export async function createDidJwk() { | ||
await agent.dids.create<JwkDidCreateOptions>({ | ||
method: "jwk", | ||
options: { | ||
keyType: KeyType.Ed25519, | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { KeyType, KeyDidCreateOptions } from "@aries-framework/core"; | ||
import { agent } from "../agent"; | ||
|
||
export async function createDidKey() { | ||
await agent.dids.create<KeyDidCreateOptions>({ | ||
method: "key", | ||
options: { | ||
keyType: KeyType.Ed25519, | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { | ||
CHEQD_TESTNET_COSMOS_PAYER_SEED, | ||
DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED, | ||
} from "../constants"; | ||
import { createDidCheqd } from "./cheqd"; | ||
import { importIndyDid } from "./indy"; | ||
import { createDidJwk } from "./jwk"; | ||
import { createDidKey } from "./key"; | ||
import { getDidForMethod, hasDidForMethod } from "./util"; | ||
import { createDidWeb } from "./web"; | ||
|
||
const availableDids: string[] = []; | ||
|
||
export async function setupAllDids() { | ||
if (!(await hasDidForMethod("key"))) { | ||
await createDidKey(); | ||
} | ||
availableDids.push(await getDidForMethod("key")); | ||
|
||
if (!(await hasDidForMethod("jwk"))) { | ||
await createDidJwk(); | ||
} | ||
availableDids.push(await getDidForMethod("jwk")); | ||
|
||
if (!(await hasDidForMethod("web"))) { | ||
await createDidWeb(); | ||
} | ||
availableDids.push(await getDidForMethod("web")); | ||
|
||
if (CHEQD_TESTNET_COSMOS_PAYER_SEED) { | ||
if (!(await hasDidForMethod("cheqd"))) { | ||
await createDidCheqd(); | ||
} | ||
availableDids.push(await getDidForMethod("cheqd")); | ||
} | ||
|
||
if (DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED) { | ||
if (!(await hasDidForMethod("indy"))) { | ||
await importIndyDid( | ||
"indicio:testnet", | ||
DID_INDY_INDICIO_TESTNET_PUBLIC_DID_SEED | ||
); | ||
} | ||
availableDids.push(await getDidForMethod("indy")); | ||
} | ||
} | ||
|
||
export function getAvailableDids() { | ||
return availableDids; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { agent } from "../agent"; | ||
|
||
export async function hasDidForMethod(method: string) { | ||
const [createdDid] = await agent.dids.getCreatedDids({ method }); | ||
|
||
return createdDid !== undefined; | ||
} | ||
|
||
export async function getDidForMethod(method: string) { | ||
const [createdDid] = await agent.dids.getCreatedDids({ method }); | ||
|
||
if (!createdDid) { | ||
throw new Error(`did for method ${method} does not exist`); | ||
} | ||
|
||
return createdDid.did; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.