npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@3fv/atlassian-oauth-connect

v1.0.10

Published

Atlassian Connect OAuth2 library

Downloads

35

Readme

Atlassian OAuth 2 (3LO) Browser/Server Client

Install

It's a properly configured hybrid module, so both commonjs & module/esm runtimes are supported, which means that both browser & node environments can you the entire library excluding the decode functionality, which I'll eventually convert for browser support using cryptojs, but it's transparently functional in any evironment now

yarn add @3fv/atlassian-oauth-connect

Example Implementation (not for prod use)

Prequistes

First, make sure you've got direnv installed via your package manager of choice brew, apt, pacman, etc...

Setup

Copy .envrc.templace to .envrc and fill in all the missing fields. Also, the scope list is robust, but the purpose is to show near every currently available scope, so, go ahead and pair it down to what you need.

Populate your redirect URI, client id, and client secret with the values you entered/received Atlassian Developer Console when your configured your app

WARNING: As mentioned, this is just an example; in a real world scenario the configuration would come from another system like AWS AppConfig with appropriate secret management, etc.

First, copy the file: cp .envrc.template .envrc

Next, populate your app's values from the aforementioned Atlassian Developer Console App Registration.

# IN CASE YOUR SHELL DOESN'T DO THIS FOR YOU
PATH_add $PWD/node_modules/.bin

# SCOPES FOR AUTHORIZATION.
# THEY MUST BE SPACE DELIMITED
export ATLASSIAN_SCOPE="\
  read:me \
  offline_access \
  read:jira-user \
  read:jira-work \
  write:jira-work \
  manage:jira-project \
  manage:jira-configuration \
  manage:jira-webhook \
  read:confluence-content.all \
  read:confluence-content.summary \
  write:confluence-content \
  write:confluence-space \
  write:confluence-file \
  read:confluence-props \
  write:confluence-props \
  manage:confluence-project \
  manage:confluence-configuration \
  search:confluence"

# APP REGISTRATION DETAILS
export ATLASSIAN_REDIRECT_URI=<YOUR_ATLASSIAN_REDIRECT_URI>
export ATLASSIAN_CLIENT_ID=<YOUR_ATLASSIAN_CLIENT_ID>
export ATLASSIAN_CLIENT_SECRET=<YOUR_ATLASSIAN_CLIENT_SECRET>

Run the example

The example server is a very basic html page and express web server that together function as a fairly complete tooling for testing & verifyingthe atlassian connect integration.

The source is here ./src/example/server.ts & ./src/example/index.html

# Install Deps
yarn

# Build & Run Example Server
yarn example:server:start

Now you can open a browser to http://localhost:4000 and play around

Hackup to play with Atlassian Connect

I figured you'd probably get annoyed if this wasn't easy, so it's all scripted

To start up the typescript compiler in watch mode and server via nodemon, just run the following

yarn run example:server:dev

Features

  • getAccessibleResources() queries for all resources (projects & spaces) for which a user accepted grants. Here's an example response.
[
  {
    "id": "00000000-0000-0000-0000-000000000000",
    "url": "https://3fv.atlassian.net",
    "name": "3fv",
    "scopes": [
      "manage:confluence-configuration",
      "search:confluence",
      "write:confluence-props",
      "read:confluence-props",
      "write:confluence-file",
      "write:confluence-space",
      "write:confluence-content",
      "read:confluence-content.summary",
      "read:confluence-content.all"
    ],
    "avatarUrl": "https://site-admin-avatar-cdn.prod.public.atl-paas.net/avatars/240/triangle.png"
  },
  {
    "id": "00000000-0000-0000-0000-000000000000",
    "url": "https://3fv.atlassian.net",
    "name": "3fv",
    "scopes": [
      "manage:jira-configuration",
      "manage:jira-project",
      "manage:jira-webhook",
      "write:jira-work",
      "read:jira-work",
      "read:jira-user"
    ],
    "avatarUrl": "https://site-admin-avatar-cdn.prod.public.atl-paas.net/avatars/240/triangle.png"
  }
]
  • retrieveAccessToken() for code to token exchange

  • getUserProfile() to retrieve the current user profile.

{
  "account_id": "0000000000000",
  "email": "[email protected]",
  "name": "Jonathan Glanz",
  "picture": "https://secure.gravatar.com/avatar/...",
  "account_status": "active",
  "last_updated": "2021-11-15T14:49:38.747Z",
  "nickname": "Jonathan Glanz",
  "locale": "en-US",
  "extended_profile": {
    "job_title": "Software Engineer",
    "team_type": "Software Development"
  },
  "account_type": "atlassian",
  "email_verified": true
}
  • Token refresh rolling functionality; all the requirements to implement refresh token rolling, including the actual refresh token (if you specified the offline_access scope) & the expiration data, so you can implement your own refresh token rolling or wait for me to find a reason :grin:

Todo

  • [ ] Signature Verification (OOB the atlassian-jwt package chucks errors when verifying the returned tokens)
  • [ ] Caching, right now, if you call getUserProfile, retrieveAccessToken, etc., every call no matter identical params or not, query the endpoints; so this is kind of important
  • [ ] Unit tests would be a good idea (started & configured, just not implemented :smile:)
  • [ ] Plus a few e2e cypress tests (started)

Credit

Written with love in #NYC by @jglanz 3FV. Enjoy