From f94963c52d0beee0c726b7e0cf07de4247484675 Mon Sep 17 00:00:00 2001 From: JGiter Date: Tue, 16 Jul 2024 13:55:32 +0300 Subject: [PATCH] feat: set issuer resolver --- .../classes/modules_claims.ClaimsService.md | 17 +++++++++++ .../classes/modules_signer.SignerService.md | 8 +++--- .../modules_staking.StakingFactoryService.md | 16 +++++------ .../modules_staking.StakingPoolService.md | 28 +++++++++---------- ...ntials.VerifiableCredentialsServiceBase.md | 8 +++--- docs/api/modules/modules_signer.md | 10 +++---- src/modules/claims/claims.service.ts | 20 ++++++++++--- 7 files changed, 68 insertions(+), 39 deletions(-) diff --git a/docs/api/classes/modules_claims.ClaimsService.md b/docs/api/classes/modules_claims.ClaimsService.md index bbd7e606..03c970e3 100644 --- a/docs/api/classes/modules_claims.ClaimsService.md +++ b/docs/api/classes/modules_claims.ClaimsService.md @@ -47,6 +47,7 @@ claimsService.getClaimById(claim.id); - [resolveCredentialAndVerify](modules_claims.ClaimsService.md#resolvecredentialandverify) - [revokeClaim](modules_claims.ClaimsService.md#revokeclaim) - [revokeMultipleClaim](modules_claims.ClaimsService.md#revokemultipleclaim) +- [setIssuerResolver](modules_claims.ClaimsService.md#setissuerresolver) - [verifyRoleEIP191JWT](modules_claims.ClaimsService.md#verifyroleeip191jwt) - [verifyVc](modules_claims.ClaimsService.md#verifyvc) - [create](modules_claims.ClaimsService.md#create) @@ -820,6 +821,22 @@ claimsService.revokeMultipleClaim({ ___ +### setIssuerResolver + +▸ **setIssuerResolver**(`issuerResolver`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `issuerResolver` | `IssuerResolver` | + +#### Returns + +`void` + +___ + ### verifyRoleEIP191JWT ▸ **verifyRoleEIP191JWT**(`roleEIP191JWT`): `Promise`<[`CredentialVerificationResult`](../interfaces/modules_claims.CredentialVerificationResult.md)\> diff --git a/docs/api/classes/modules_signer.SignerService.md b/docs/api/classes/modules_signer.SignerService.md index 24a17182..f5897ed5 100644 --- a/docs/api/classes/modules_signer.SignerService.md +++ b/docs/api/classes/modules_signer.SignerService.md @@ -353,14 +353,14 @@ ___ Add event handler for certain events -#### Returns - -`void` - **`Requires`** to be called after the connection to wallet was initialized +#### Returns + +`void` + ___ ### on diff --git a/docs/api/classes/modules_staking.StakingFactoryService.md b/docs/api/classes/modules_staking.StakingFactoryService.md index 0bfd489f..c99d9dc1 100644 --- a/docs/api/classes/modules_staking.StakingFactoryService.md +++ b/docs/api/classes/modules_staking.StakingFactoryService.md @@ -35,28 +35,28 @@ Intended for staking pool ▸ **allServices**(): `Promise`<[`Service`](../modules/modules_staking.md#service)[]\> -#### Returns - -`Promise`<[`Service`](../modules/modules_staking.md#service)[]\> - **`Description`** Returns all services for which pools are launched +#### Returns + +`Promise`<[`Service`](../modules/modules_staking.md#service)[]\> + ___ ### getPool ▸ **getPool**(): `Promise`<[`StakingPoolService`](modules_staking.StakingPoolService.md)\> -#### Returns - -`Promise`<[`StakingPoolService`](modules_staking.StakingPoolService.md)\> - **`Description`** Returns pool launched for energyweb org +#### Returns + +`Promise`<[`StakingPoolService`](modules_staking.StakingPoolService.md)\> + ___ ### create diff --git a/docs/api/classes/modules_staking.StakingPoolService.md b/docs/api/classes/modules_staking.StakingPoolService.md index 7b3b1271..008ba397 100644 --- a/docs/api/classes/modules_staking.StakingPoolService.md +++ b/docs/api/classes/modules_staking.StakingPoolService.md @@ -127,6 +127,8 @@ ___ ▸ **partialWithdraw**(`value`): `Promise`<`ContractReceipt`\> +**`Description`** + #### Parameters | Name | Type | @@ -137,14 +139,20 @@ ___ `Promise`<`ContractReceipt`\> -**`Description`** - ___ ### putStake ▸ **putStake**(`stake`): `Promise`<`void`\> +**`Description`** + +Locks stake and starts accumulating reward + +**`Emits`** + +StakingPool.StakePut + #### Parameters | Name | Type | @@ -155,24 +163,16 @@ ___ `Promise`<`void`\> -**`Description`** - -Locks stake and starts accumulating reward - -**`Emits`** - -StakingPool.StakePut - ___ ### withdraw ▸ **withdraw**(): `Promise`<`void`\> -#### Returns - -`Promise`<`void`\> - **`Description`** pays back stake with accumulated reward. + +#### Returns + +`Promise`<`void`\> diff --git a/docs/api/classes/modules_verifiable_credentials.VerifiableCredentialsServiceBase.md b/docs/api/classes/modules_verifiable_credentials.VerifiableCredentialsServiceBase.md index 767b7845..debd6e02 100644 --- a/docs/api/classes/modules_verifiable_credentials.VerifiableCredentialsServiceBase.md +++ b/docs/api/classes/modules_verifiable_credentials.VerifiableCredentialsServiceBase.md @@ -50,6 +50,10 @@ verifiableCredentialsService.createRoleVC(...); ▸ **continueExchange**(`«destructured»`): `Promise`<`undefined` \| `VerifiablePresentation` \| `VpRequest`\> +**`Description`** + +Sends credentials requested by issuer and returns either issued credentials or next credentials request + #### Parameters | Name | Type | @@ -62,10 +66,6 @@ verifiableCredentialsService.createRoleVC(...); issued credentials or request of additional credentials -**`Description`** - -Sends credentials requested by issuer and returns either issued credentials or next credentials request - ___ ### createCredential diff --git a/docs/api/modules/modules_signer.md b/docs/api/modules/modules_signer.md index b2616804..43d75f97 100644 --- a/docs/api/modules/modules_signer.md +++ b/docs/api/modules/modules_signer.md @@ -106,6 +106,11 @@ ___ ▸ **fromGnosis**(`safeAppSdk`): `Promise`<[`SignerService`](../classes/modules_signer.SignerService.md)\> +**`Description`** + +Intended for use in Volta Gnosis web interface(https://volta.gnosis-safe.io/). +Dapp should provide SafeAppSdk injected by Gnosis interface + #### Parameters | Name | Type | @@ -116,11 +121,6 @@ ___ `Promise`<[`SignerService`](../classes/modules_signer.SignerService.md)\> -**`Description`** - -Intended for use in Volta Gnosis web interface(https://volta.gnosis-safe.io/). -Dapp should provide SafeAppSdk injected by Gnosis interface - ___ ### fromKms diff --git a/src/modules/claims/claims.service.ts b/src/modules/claims/claims.service.ts index 1d68a4c3..6307716a 100644 --- a/src/modules/claims/claims.service.ts +++ b/src/modules/claims/claims.service.ts @@ -75,6 +75,7 @@ import { RevocationVerification, RoleEIP191JWT, isEIP191Jwt, + IssuerResolver, } from '@energyweb/vc-verification'; import { DidRegistry } from '../did-registry/did-registry.service'; import { ClaimData, isClaimService } from '../did-registry/did.types'; @@ -109,7 +110,7 @@ export class ClaimsService { private _claimManagerInterface = ClaimManager__factory.createInterface(); private _claimRevocation: ClaimRevocation; private _issuerVerification: IssuerVerification; - private _issuerResolver: EthersProviderIssuerResolver; + private _issuerResolver?: IssuerResolver; private _credentialResolver: CredentialResolver; private _statusVerifier: StatusListEntryVerification; @@ -172,6 +173,12 @@ export class ClaimsService { ); } + public setIssuerResolver(issuerResolver: IssuerResolver): void { + this._issuerResolver = issuerResolver; + + this._setIssuerVerifier(); + } + /** * A utility function to check the blockchain directly if a DID has a role. * @@ -1599,7 +1606,8 @@ export class ClaimsService { this._didRegistry.ipfsStore ); const domainReader = this._domainsService.domainReader; - this._issuerResolver = new EthersProviderIssuerResolver(domainReader); + const issuerResolver = + this._issuerResolver || this._getDefaultIssuerResolver(); const revokerResolver = new EthersProviderRevokerResolver(domainReader); const verifyProof = (vc: string, proofOptions: string) => this._verifiableCredentialService.verify( @@ -1608,12 +1616,12 @@ export class ClaimsService { ); const revocationVerification = new RevocationVerification( revokerResolver, - this._issuerResolver, + issuerResolver, this._credentialResolver, verifyProof ); this._issuerVerification = new IssuerVerification( - this._issuerResolver, + issuerResolver, this._credentialResolver, this._signerService.provider, this._didRegistry.registrySettings, @@ -1632,4 +1640,8 @@ export class ClaimsService { return JSON.stringify({ errors: [] }); }); } + + private _getDefaultIssuerResolver(): IssuerResolver { + return new EthersProviderIssuerResolver(this._domainsService.domainReader); + } }