File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,25 @@ export class Verifier<T extends BaseClaims> {
3333 this . disableCaching = disableCaching ;
3434 }
3535
36+ /**
37+ * Static method to instantiate a Verifier class
38+ * @param inputToken The input token you get from the request
39+ * @param keysUrlPath The URL path to the public keys
40+ * @param disableCaching Caches keys for 24 hours, defaults to false
41+ * @returns {Verifier } Returns an instance of Verifier class
42+ */
43+ public static fromToken < T extends BaseClaims > (
44+ inputToken : string ,
45+ keysUrlPath : string ,
46+ disableCaching = false
47+ ) : Verifier < T > {
48+ const parsedToken = jwtDecode < T > ( this . getCleanedJwt ( inputToken ) ) ;
49+ if ( ! keysUrlPath . startsWith ( "/" ) ) {
50+ keysUrlPath = "/" + keysUrlPath ;
51+ }
52+ return new Verifier ( `${ parsedToken . iss } ${ keysUrlPath } ` , disableCaching ) ;
53+ }
54+
3655 private async getPublicKeys ( ) : Promise < Array < PublicKey > > {
3756 if ( ! this . publicKeys ) {
3857 if ( ! this . disableCaching ) {
You can’t perform that action at this time.
0 commit comments