feat: Add validate identity helper to resolver (#23068)

This commit is contained in:
Stephen Wright
2025-12-11 10:48:12 +00:00
committed by GitHub
parent 8ecf6e0e2f
commit 9e7fafbc24
3 changed files with 21 additions and 0 deletions
@@ -81,6 +81,14 @@ export interface ICredentialResolver {
*/
validateOptions(options: CredentialResolverConfiguration): Promise<void>;
/**
* Validates if the userIdentity provided has access to the resolver capable credential
*
* @param identity - The identity of the entity to validate access for
* @throws {CredentialResolverAccessValidationError} When access is invalid
*/
validateIdentity?(identity: string, handle: CredentialResolverHandle): Promise<void>;
/**
* Runs initialization logic for the resolver. This might be called multiple times!
* Optional - not all resolvers require initialization.
@@ -78,4 +78,13 @@ describe('StubCredentialResolver', () => {
await expect(resolver2.getSecret(credentialId, context, handle)).rejects.toThrow();
});
});
describe('validateIdentity', () => {
it('should validate identity', async () => {
const resolver = new StubCredentialResolver(mockLogger);
const identity = 'test-identity';
const handle = testHelpers.createHandle({});
await expect(resolver.validateIdentity(identity, handle)).resolves.toBeUndefined();
});
});
});
@@ -108,4 +108,8 @@ export class StubCredentialResolver implements ICredentialResolver {
async validateOptions(options: CredentialResolverConfiguration): Promise<void> {
await this.parseOptions(options);
}
async validateIdentity(_identity: string, _handle: CredentialResolverHandle): Promise<void> {
return;
}
}