Skip to content

Commit

Permalink
feat: set issuer resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
JGiter committed Jul 16, 2024
1 parent 880ae80 commit f94963c
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 39 deletions.
17 changes: 17 additions & 0 deletions docs/api/classes/modules_claims.ClaimsService.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)\>
Expand Down
8 changes: 4 additions & 4 deletions docs/api/classes/modules_signer.SignerService.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions docs/api/classes/modules_staking.StakingFactoryService.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions docs/api/classes/modules_staking.StakingPoolService.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ ___

**partialWithdraw**(`value`): `Promise`<`ContractReceipt`\>

**`Description`**

#### Parameters

| Name | Type |
Expand All @@ -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 |
Expand All @@ -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`\>
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions docs/api/modules/modules_signer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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
Expand Down
20 changes: 16 additions & 4 deletions src/modules/claims/claims.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -1632,4 +1640,8 @@ export class ClaimsService {
return JSON.stringify({ errors: [] });
});
}

private _getDefaultIssuerResolver(): IssuerResolver {
return new EthersProviderIssuerResolver(this._domainsService.domainReader);
}
}

0 comments on commit f94963c

Please sign in to comment.