Closed planktoon1 closed 2 years ago
HI @planktoon1,
Makes sense, think we should add some export
statements to make that easier.
In the meantime here is a workaround:
import { CognitoJwtVerifier } from "aws-jwt-verify";
class Test {
verifier: CognitoJwtVerifier<
{
// add only properties here, that you're not passing in the actual `create` call, e.g.
// clientId: string
// properties that you add here, will become mandatory on individual `verify` calls (i.e. make the 2nd paramater mandatory)
},
{
issuer: string;
audience: null;
userPoolId: string;
}, // just satisfy the type, for assignment below you don't have to spell out everything
false // false for single user pool, true for multi user pool
>;
constructor() {
this.verifier = CognitoJwtVerifier.create({
userPoolId: "<user_pool_id>",
tokenUse: "access",
clientId: "<client_id>",
});
}
public async test() {
await this.verifier.verify("ey......");
}
}
Solved by #42
The module is built with typescript but is not exporting any types which makes it hard to work within a typescript project.
Specifically, I want to use the verifier inside a class where I initialize it in the constructor of the class and assign it to a private member. But I'm missing the
CognitoJwtVerifierSingleUserPool
type to be able to do it.