JS library for verifying JWTs signed by Amazon Cognito, and any OIDC-compatible IDP that signs JWTs with RS256, RS384, RS512, ES256, ES384, and ES512
633
stars
45
forks
source link
Can you not just return the instance without knowing what "Generic" properties are defined???? #137
Closed
markbenedict closed 1 year ago
Question The create function should just return the instance of the object, who cares about shape used to define it.
Instead of:
container .bind<CognitoJwtVerifierSingleUserPool<{ userPoolId: string; tokenUse: 'id' | 'access' }>>(IocSymbols.Authorizer) .toConstantValue(CognitoJwtVerifier.create({ userPoolId: APP_ENV.userPoolId, tokenUse: 'id' }));
Use: @inject(IocSymbols.Authorizer) private readonly _authorizer: CognitoJwtVerifierSingleUserPool<{ userPoolId: string; tokenUse: 'id' | 'access' }>,
public handler(....) { this._authorizer.verify(authToken); <----- this throws an error because it can't interpret the values }
Intended:
container .bind(IocSymbols.Authorizer)
.toConstantValue(CognitoJwtVerifier.create({ userPoolId: APP_ENV.userPoolId, tokenUse: 'id' }));
Use: @inject(IocSymbols.Authorizer) private readonly _authorizer: CognitoJwtVerifier>,
public handler(....) { this._authorizer.verify(authToken); <---- inject the instance and properties are set }