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

feat: enveloping proof #207

Merged
merged 28 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e37e2b7
feat: issue an enveloping proof vc with custom Veramo
ldhyen99 Jul 23, 2024
58b8c28
feat: verify an enveloping proof vc
ldhyen99 Jul 23, 2024
981676e
feat: enveloping proof issue verify and revoked active status
ldhyen99 Jul 30, 2024
e65efa1
refactor: delete unused code
ldhyen99 Jul 30, 2024
8fc13a9
refactor: change payload when issue with EnvelopingProof
ldhyen99 Jul 30, 2024
55ad20a
feat: update agent file in cli default
ldhyen99 Jul 30, 2024
c37d301
test: add test for credetial router
ldhyen99 Jul 30, 2024
33f2e72
Merge branch 'next' into feat/enveloping_proof
ldhyen99 Jul 30, 2024
5fce2d2
refactor: change name of proofFormat
ldhyen99 Jul 30, 2024
431fa95
Merge branch 'feat/enveloping_proof' of https://github.com/uncefact/p…
ldhyen99 Jul 30, 2024
43f9d15
docs: update readme
ldhyen99 Jul 31, 2024
e245b10
Merge branch 'next' into feat/enveloping_proof
ldhyen99 Sep 6, 2024
bf2cc01
Merge branch 'next' into feat/enveloping_proof
ldhyen99 Sep 9, 2024
f6cc75e
chore: update pnpm lock
ldhyen99 Sep 9, 2024
b741ac7
Merge branch 'feat/enveloping_proof' of github.com:uncefact/project-v…
ldhyen99 Sep 9, 2024
7567911
feat: get all type in well-known
ldhyen99 Sep 10, 2024
fb83f81
refactor: change yml file
ldhyen99 Sep 10, 2024
b68ad9c
test: add test case to action handler of credential router
ldhyen99 Sep 10, 2024
f0b535b
refactor: delete useless code in credential router
ldhyen99 Sep 12, 2024
d48d9c1
Merge branch 'next' into feat/enveloping_proof
namhoang1604 Sep 12, 2024
fba0f6a
refactor: remove comment code in yml file
ldhyen99 Sep 12, 2024
10da348
Merge branch 'feat/enveloping_proof' of github.com:uncefact/project-v…
ldhyen99 Sep 12, 2024
320d180
test: remove useless test in credential router
ldhyen99 Sep 13, 2024
9eec9ff
test: remove useless test in credential router
ldhyen99 Sep 13, 2024
fc3bc8f
feat: return jwt credential without store encrypted data
ldhyen99 Sep 13, 2024
39aa6c9
test: delete useless code
ldhyen99 Sep 13, 2024
837924d
ci: update pnpm lock
ldhyen99 Sep 13, 2024
59d1768
ci: install package to pass pipeline
ldhyen99 Sep 13, 2024
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
7 changes: 4 additions & 3 deletions packages/cli/default/agent.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ constants:
- keyManagerSharedSecret
- keyManagerSignJWT
- keyManagerSignEthTX
- keyManagerSignJOSE
- didManagerGetProviders
- didManagerFind
- didManagerGet
Expand Down Expand Up @@ -175,9 +176,9 @@ server:

# DID Documents
- - $require: '@vckit/remote-server?t=function#WebDidDocRouter'
$args:
- keyMapping:
Ed25519: JsonWebKey2020 # Ed25519VerificationKey2020 | JsonWebKey2020
# $args:
# - keyMapping:
# Ed25519: # Ed25519VerificationKey2020 # JsonWebKey2020 # JsonWebKey

# VC API v1
- - /v1
Expand Down
1 change: 1 addition & 0 deletions packages/cli/default/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ agent:
- keyManagerSharedSecret
- keyManagerSignJWT
- keyManagerSignEthTX
- keyManagerSignJOSE
- didManagerGetProviders
- didManagerFind
- didManagerGet
Expand Down
7 changes: 4 additions & 3 deletions packages/cli/default/default-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ constants:
- keyManagerSharedSecret
- keyManagerSignJWT
- keyManagerSignEthTX
- keyManagerSignJOSE
- didManagerGetProviders
- didManagerFind
- didManagerGet
Expand Down Expand Up @@ -149,9 +150,9 @@ server:

# DID Documents
- - $require: '@vckit/remote-server?t=function#WebDidDocRouter'
$args:
- keyMapping:
Ed25519: JsonWebKey2020 # Ed25519VerificationKey2020 | JsonWebKey2020
# $args:
# - keyMapping:
# Ed25519: JsonWebKey # Ed25519VerificationKey2020 # JsonWebKey2020 # JsonWebKey

# VC API v1
- - /v1
Expand Down
8 changes: 5 additions & 3 deletions packages/cli/default/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ constants:
- keyManagerSharedSecret
- keyManagerSignJWT
- keyManagerSignEthTX
- keyManagerSignJOSE
- didManagerGetProviders
- didManagerFind
- didManagerGet
Expand Down Expand Up @@ -149,9 +150,9 @@ server:

# DID Documents
- - $require: '@vckit/remote-server?t=function#WebDidDocRouter'
$args:
- keyMapping:
Ed25519: JsonWebKey2020 # Ed25519VerificationKey2020 | JsonWebKey2020
# $args:
# - keyMapping:
# Ed25519: #JsonWebKey2020 # Ed25519VerificationKey2020 # JsonWebKey

# VC API v1
- - /v1
Expand Down Expand Up @@ -365,6 +366,7 @@ credentialIssuerLD:
# - $require: '@veramo/credential-ld#VeramoEd25519Signature2020'
- $require: '@veramo/credential-ld#VeramoJsonWebSignature2020'
# - $require: '@veramo/credential-ld#VeramoEcdsaSecp256k1RecoverySignature2020'

contextMaps:
# The LdDefaultContext is a "catch-all" for now.
- $require: '@veramo/credential-ld?t=object#LdDefaultContexts'
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
"@vckit/remote-server": "workspace:1.0.0-beta.7",
"@vckit/renderer": "workspace:1.0.0-beta.7",
"@vckit/revocationlist": "workspace:^",
"@vckit/tools": "workspace:^",
"@vckit/utils": "workspace:^",
"@vckit/vc-api": "workspace:1.0.0-beta.7",
"@vckit/tools": "workspace:^",
"@veramo/core": "5.5.3",
"@veramo/core": "link:../../.tmp_npm/veramo/packages/core",
ldhyen99 marked this conversation as resolved.
Show resolved Hide resolved
"@veramo/credential-eip712": "5.5.3",
"@veramo/credential-ld": "link:../../.tmp_npm/veramo/packages/credential-ld",
"@veramo/credential-status": "link:../../.tmp_npm/veramo/packages/credential-status",
Expand All @@ -67,10 +67,10 @@
"@veramo/did-provider-pkh": "5.5.3",
"@veramo/did-provider-web": "5.5.3",
"@veramo/did-resolver": "5.5.3",
"@veramo/key-manager": "5.5.3",
"@veramo/kms-local": "5.5.3",
"@veramo/key-manager": "link:../../.tmp_npm/veramo/packages/key-manager",
"@veramo/kms-local": "link:../../.tmp_npm/veramo/packages/kms-local",
"@veramo/message-handler": "5.5.3",
"@veramo/remote-client": "5.5.3",
"@veramo/remote-client": "link:../../.tmp_npm/veramo/packages/remote-client",
ldhyen99 marked this conversation as resolved.
Show resolved Hide resolved
"@veramo/selective-disclosure": "5.5.3",
"@veramo/url-handler": "5.5.3",
"@veramo/utils": "5.5.3",
Expand Down
36 changes: 33 additions & 3 deletions packages/core-types/src/plugin.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,24 @@
],
"description": "Input arguments for {@link IKeyManager.keyManagerSignEthTX | keyManagerSignEthTX }"
},
"IKeyManagerSignJOSE": {
"type": "object",
"properties": {
"kid": {
"type": "string",
"description": "Key ID"
},
"data": {
"type": "string",
"description": "Data to sign"
}
},
"required": [
"kid",
"data"
],
"description": "Input arguments for {@link IKeyManager.IKeyManagerSignJOSE | IKeyManagerSignJOSE }"
},
"IKeyManagerSignJWTArgs": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1021,6 +1039,15 @@
"type": "string"
}
},
"keyManagerSignJOSE": {
"description": "Signs JOSE object",
"arguments": {
"$ref": "#/components/schemas/IKeyManagerSignJOSE"
},
"returnType": {
"type": "string"
}
},
"keyManagerSignJWT": {
"description": "Signs JWT",
"arguments": {
Expand Down Expand Up @@ -4338,7 +4365,8 @@
"lds",
"EthereumEip712Signature2021",
"OpenAttestationMerkleProofSignature2018",
"MerkleDisclosureProof2021"
"MerkleDisclosureProof2021",
"EnvelopingProofJose"
],
"description": "The type of encoding to be used for the Verifiable Credential or Presentation to be generated.\n\nOnly `jwt` , `lds` and `OpenAttestationMerkleProofSignature2018` are supported at the moment."
},
Expand Down Expand Up @@ -5095,7 +5123,8 @@
"lds",
"EthereumEip712Signature2021",
"OpenAttestationMerkleProofSignature2018",
"MerkleDisclosureProof2021"
"MerkleDisclosureProof2021",
"EnvelopingProofJose"
],
"description": "The type of encoding to be used for the Verifiable Credential or Presentation to be generated.\n\nOnly `jwt` , `lds` and `OpenAttestationMerkleProofSignature2018` are supported at the moment."
},
Expand Down Expand Up @@ -6596,7 +6625,8 @@
"lds",
"EthereumEip712Signature2021",
"OpenAttestationMerkleProofSignature2018",
"MerkleDisclosureProof2021"
"MerkleDisclosureProof2021",
"EnvelopingProofJose"
],
"description": "The type of encoding to be used for the Verifiable Credential or Presentation to be generated.\n\nOnly `jwt` , `lds` and `OpenAttestationMerkleProofSignature2018` are supported at the moment."
},
Expand Down
3 changes: 2 additions & 1 deletion packages/core-types/src/types/ICredentialIssuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export type ProofFormat =
| 'lds'
| 'EthereumEip712Signature2021'
| 'OpenAttestationMerkleProofSignature2018'
| 'MerkleDisclosureProof2021';
| 'MerkleDisclosureProof2021'
| 'EnvelopingProofJose';

/**
* Encapsulates the parameters required to create a
Expand Down
19 changes: 19 additions & 0 deletions packages/core-types/src/types/IKeyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ export interface IKeyManagerSignEthTXArgs {
transaction: object;
}

/**
* Input arguments for {@link IKeyManager.IKeyManagerSignJOSE | IKeyManagerSignJOSE}
* @public
*/
export interface IKeyManagerSignJOSE {
/**
* Key ID
*/
kid: string;

/**
* Data to sign
*/
data: string;
}

/**
* Key manager interface.
*
Expand Down Expand Up @@ -267,4 +283,7 @@ export interface IKeyManager extends IPluginMethodMap {

/** Signs Ethereum transaction */
keyManagerSignEthTX(args: IKeyManagerSignEthTXArgs): Promise<string>;

/** Signs JOSE object */
keyManagerSignJOSE(args: IKeyManagerSignJOSE): Promise<string>;
}
72 changes: 72 additions & 0 deletions packages/credential-router/__tests__/action-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {

import { CredentialRouter } from '../src/action-handler';
import {
ENVELOPING_PROOF_JOSE,
RAW_CREDENTIAL,
SIGNED_WRAPPED_DOCUMENT_JWT,
SIGNED_WRAPPED_DOCUMENT_MERKLE_DISCLOSURE,
Expand Down Expand Up @@ -91,6 +92,54 @@ describe('CredentialRouter', () => {
expect(result).toEqual(SIGNED_WRAPPED_DOCUMENT_JWT);
});

it('should call createVerifiableCredential function when proofFormat is EnvelopingProofJose', async () => {
const mockIssuerAgentContext = {
agent: {
createVerifiableCredential: jest
.fn()
.mockReturnValue(ENVELOPING_PROOF_JOSE),
},
} as unknown as IssuerAgentContext;

const credentialPlugin = new CredentialRouter();
const args: ICreateVerifiableCredentialArgs = {
credential: RAW_CREDENTIAL,
proofFormat: 'EnvelopingProofJose',
};

const result = await credentialPlugin.routeCreationVerifiableCredential(
args,
mockIssuerAgentContext,
);

expect(result).not.toBeNull();
expect(result).toEqual(ENVELOPING_PROOF_JOSE);
});

it('should throw error when create a credential router with proofFormat is EnvelopingProofJose', async () => {
const mockIssuerAgentContext = {
agent: {
createVerifiableCredential: jest
.fn()
.mockReturnValue(ENVELOPING_PROOF_JOSE),
},
} as unknown as IssuerAgentContext;

const credentialPlugin = new CredentialRouter();
const args: ICreateVerifiableCredentialArgs = {
credential: RAW_CREDENTIAL,
proofFormat: 'EnvelopingProofJose',
};

const result = await credentialPlugin.routeCreationVerifiableCredential(
args,
mockIssuerAgentContext,
);

expect(result).not.toBeNull();
expect(result).toEqual(ENVELOPING_PROOF_JOSE);
});
ldhyen99 marked this conversation as resolved.
Show resolved Hide resolved

it(`should throw error when create a credential router with proofFormat is OpenAttestationMerkleProofSignature2018`, async () => {
const mockIssuerAgentContext = {
agent: {
Expand Down Expand Up @@ -159,6 +208,29 @@ describe('CredentialRouter', () => {
'invalid_setup: your agent does not seem to have CredentialW3c plugin installed',
);
});

it(`should throw error when create a credential router with proofFormat is EnvelopingProofJose`, async () => {
const mockIssuerAgentContext = {
agent: {
createVerifiableCredential: undefined,
},
} as unknown as IssuerAgentContext;

const credentialPlugin = new CredentialRouter();
const args: ICreateVerifiableCredentialArgs = {
credential: RAW_CREDENTIAL,
proofFormat: 'EnvelopingProofJose',
};

await expect(
credentialPlugin.routeCreationVerifiableCredential(
args,
mockIssuerAgentContext,
),
).rejects.toThrow(
'invalid_setup: your agent does not seem to have CredentialW3c plugin installed',
);
});
ldhyen99 marked this conversation as resolved.
Show resolved Hide resolved
});

describe('routeVerifyCredential', () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/credential-router/__tests__/mocks/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,6 @@ export const SIGNED_WRAPPED_DOCUMENT_JWT = {
...RAW_CREDENTIAL,
...JWT_PROOF,
};

export const ENVELOPING_PROOF_JOSE =
'eyJhbGciOiJFZERTQSIsImlzcyI6ImRpZDp3ZWI6N2Y1Mi0yNDAyLTgwMC02MzE1LWZlYjQtZDVlOC0xMzg3LTc2ODUtZThhNi5uZ3Jvay1mcmVlLmFwcCIsInR5cCI6InZjLWxkK2p3dCJ9.eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvbnMvY3JlZGVudGlhbHMvdjIiLCJodHRwczovL3d3dy53My5vcmcvbnMvY3JlZGVudGlhbHMvZXhhbXBsZXMvdjIiXSwiaWQiOiJodHRwOi8vdW5pdmVyc2l0eS5leGFtcGxlL2NyZWRlbnRpYWxzLzE4NzIiLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIiwiRXhhbXBsZUFsdW1uaUNyZWRlbnRpYWwiXSwiaXNzdWVyIjoiZGlkOndlYjo3ZjUyLTI0MDItODAwLTYzMTUtZmViNC1kNWU4LT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