-
Notifications
You must be signed in to change notification settings - Fork 9
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
Set issuer resolver #762
Merged
Merged
Set issuer resolver #762
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Class: CachedIssuerResolver | ||
|
||
[modules/claims](../modules/modules_claims.md).CachedIssuerResolver | ||
|
||
## Implements | ||
|
||
- `IssuerResolver` | ||
|
||
## Table of contents | ||
|
||
### Constructors | ||
|
||
- [constructor](modules_claims.CachedIssuerResolver.md#constructor) | ||
|
||
### Methods | ||
|
||
- [getIssuerDefinition](modules_claims.CachedIssuerResolver.md#getissuerdefinition) | ||
|
||
## Constructors | ||
|
||
### constructor | ||
|
||
• **new CachedIssuerResolver**(`domainsService`) | ||
|
||
#### Parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `domainsService` | [`DomainsService`](modules_domains.DomainsService.md) | | ||
|
||
## Methods | ||
|
||
### getIssuerDefinition | ||
|
||
▸ **getIssuerDefinition**(`namespace`): `Promise`<`IIssuerDefinition`\> | ||
|
||
#### Parameters | ||
|
||
| Name | Type | | ||
| :------ | :------ | | ||
| `namespace` | `string` | | ||
|
||
#### Returns | ||
|
||
`Promise`<`IIssuerDefinition`\> | ||
|
||
#### Implementation of | ||
|
||
IssuerResolver.getIssuerDefinition |
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
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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { | ||
IIssuerDefinition, | ||
IRoleDefinitionV2, | ||
} from '@energyweb/credential-governance'; | ||
import { IssuerResolver } from '@energyweb/vc-verification'; | ||
import { DomainsService, NamespaceType } from '../domains'; | ||
|
||
export class CachedIssuerResolver implements IssuerResolver { | ||
constructor(private readonly domainsService: DomainsService) {} | ||
|
||
async getIssuerDefinition(namespace: string): Promise<IIssuerDefinition> { | ||
const role = (await this.domainsService.getDefinition({ | ||
type: NamespaceType.Role, | ||
namespace, | ||
})) as IRoleDefinitionV2; | ||
return role.issuer; | ||
} | ||
} |
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,2 +1,3 @@ | ||
export * from './claims.service'; | ||
export * from './claims.types'; | ||
export * from './cached-issuer-resolver'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JGiter why the addition of the
?
? Is there a code path wherein_issuerResolver
is undefined?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed meaning of this field. Now this is overriding resolver, which might not be set. I will add comment. May be also rename it somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you're saying this code wouldn't work? From my reading of the code it should be fine. I'm testing it out locally....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally typescript should error this when strictProperyInitialization is true. In our configuration it is false, but error is not thrown even if to change it to true. May be this rule overwritten somewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually typescript indeed reject not initialized _issuerResolver if enable
strictPropertyInitialization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah okay, I see. Good point about
strictPropertyInitialization
. However, as I think we currently havestrictPropertyInitialization = false
and as this would affect all of the other private properties in this class (and several other of the service classes), I'm not sure it makes sense to deviate from the pattern here. Not a big deal though. I think we can proceed either way 👍