How to use the atlassian-jwt.createQueryStringHash function in atlassian-jwt

To help you get started, we’ve selected a few atlassian-jwt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github integrations / jira / lib / jira / client / axios.js View on Github external
return (config) => {
    const { query, pathname } = url.parse(config.url, true)

    const jwtToken = jwt.encode({
      ...getExpirationInSeconds(),
      iss,
      qsh: jwt.createQueryStringHash({
        method: config.method,
        originalUrl: pathname,
        query
      })
    }, secret)

    return {
      ...config,
      headers: {
        ...config.headers,
        Authorization: `JWT ${jwtToken}`
      }
    }
  }
}
github floralvikings / jira-connector / index.js View on Github external
if (!options.headers) {
                    options.headers = {}
                }
                options.headers['Authorization'] = 'Basic ' + this.basic_auth.base64
            } else {
                options.auth = this.basic_auth;
            }
        } else if (this.jwt) {
            const pathname = new URL(options.uri).pathname;
            const nowInSeconds = Math.floor(Date.now() / 1000);
            const queryParam = queryString.parse(queryString.stringify(options.qs));
            const jwtToken = jwt.encode({
              iss: this.jwt.iss,
              iat: nowInSeconds,
              exp: nowInSeconds + this.jwt.expiry_time_seconds,
              qsh: jwt.createQueryStringHash({
                method: options.method,
                pathname,
                query: queryParam || {}
              })
            }, this.jwt.secret);

            if (!options.headers) {
              options.headers = {};
            }
            options.headers['Authorization'] = `JWT ${jwtToken}`;
        }

        if (this.cookie_jar) {
            options.jar = this.cookie_jar;
        }
github mtmendonca / ace-boilerplate / api / src / services / JiraClient.js View on Github external
getToken = (method: string = 'get', path: string, iss: string, sharedSecret: string): Promise => {
    const iat = Math.floor(Date.now() / 1000);
    const exp = iat + 180;
    const req: Request = fromMethodAndUrl(method, path);
    const tokenData = {
      iss,
      iat,
      exp,
      qsh: createQueryStringHash(req),
    };

    const token = encode(tokenData, sharedSecret);
    return token;
  };

atlassian-jwt

JWT (JSON Web Token) implementation with custom Atlassian QSH claim verification

MIT
Latest version published 12 months ago

Package Health Score

61 / 100
Full package analysis