New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

atlassian-connect-auth

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atlassian-connect-auth

Helper for handling webhooks from Atlassian products

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-96.67%
Maintainers
2
Weekly downloads
 
Created
Source

atlassian-connect-auth

Known Vulnerabilities

Helper for handling webhooks from Atlassian products

const { Addon, AuthError } = require('atlassian-connect-auth')

const addon = new Addon({
  baseUrl: 'https://your-addon-url.com',
  product: 'jira', // or 'bitbucket'
})

const handleInstall = (req, res) => {
  try {
    await addon.install(req, {
      loadCredentials: clientKey => model.Credentials.findOne({ where: { clientKey } }),
      saveCredentials: (clientKey, newCredentials, storedCredentials) => {
        if (storedCredentials) {
          return storedCredentials.update(newCredentials)
        }

        return model.Credentials.create(newCredentials)
      }
    })

    res.sendStatus(201)
  } catch (error) {
    if (error instanceof AuthError) {
      console.warn(error)
      res.sendStatus(401)
    } else {
      console.error(error)
      res.sendStatus(500)
    }
  }
}

const handleAuth = (req, res, next) => {
  try {
    await addon.auth(req, {
      loadCredentials: clientKey => model.Credentials.findOne({ where: { clientKey } })
    })

    next()
  } catch (error) {
    if (error instanceof AuthError) {
      console.warn(error)
      res.sendStatus(401)
    } else {
      console.error(error)
      res.sendStatus(500)
    }
  }
}

const app = express()
  .post('/api/hooks/jira/installed', handleInstall)
  .post('/api/hooks/jira/uninstalled', handleAuth, handleUninstall)
  .post('/api/hooks/jira/project/created', handleAuth, handleProjectCreated)

Keywords

FAQs

Package last updated on 16 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc