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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@knpkv/atlassian-common

v1.9.4

Published

Shared utilities for Atlassian tools (AST, serializers, auth, config)

Readme

@knpkv/atlassian-common

Shared utilities for Atlassian tools: OAuth2 + PKCE auth, shared auth profiles, token storage, config paths, AST types, and markdown serialization.

Installation

pnpm add @knpkv/atlassian-common

Subpath Exports

| Export | Contents | | ------------------------------------- | -------------------------------------------- | | @knpkv/atlassian-common | Everything (AST, auth, config, serializers) | | @knpkv/atlassian-common/ast | Inline, block, macro, and document AST nodes | | @knpkv/atlassian-common/auth | OAuth2 endpoints, PKCE, token exchange | | @knpkv/atlassian-common/cli-auth | Browser login and token refresh for a CLI | | @knpkv/atlassian-common/config | Config paths, schemas, token/profile storage | | @knpkv/atlassian-common/serializers | Markdown serializer for AST nodes |

OAuth2 + PKCE

Uses Effect's platform Crypto service. PKCE code verifier/challenge use effect/encoding/Base64Url for base64url.

import * as NodeCrypto from "@effect/platform-node/NodeCrypto"
import { Effect } from "effect"
import {
  generateCodeVerifier,
  computeCodeChallenge,
  buildAuthUrl,
  exchangeCodeForTokens,
  JIRA_SCOPES
} from "@knpkv/atlassian-common/auth"

const program = Effect.gen(function* () {
  // 1. Generate PKCE pair
  const codeVerifier = yield* generateCodeVerifier()
  const codeChallenge = yield* computeCodeChallenge(codeVerifier)

  // 2. Build authorization URL
  const url = buildAuthUrl({
    clientId: "your-client-id",
    state: "random-csrf-token",
    port: 8585,
    scopes: JIRA_SCOPES,
    codeChallenge
  })
  // → redirect user to `url`

  // 3. Exchange code for tokens (after callback)
  const tokens = yield* exchangeCodeForTokens({
    clientId: "your-client-id",
    clientSecret: "your-client-secret",
    code: "auth-code-from-callback",
    redirectUri: "http://localhost:8585/callback",
    codeVerifier
  })
  // tokens.access_token, tokens.refresh_token, tokens.expires_in
}).pipe(Effect.provide(NodeCrypto.layer))

JIRA_SCOPES is the broad legacy CLI set and includes Jira issue-mutation scopes. Control Center defines its own least-privilege release-publication set: it adds manage:jira-project to the read/identity scopes required for create-only project-version publication, but excludes write:jira-work and manage:jira-configuration. Jira issue edits remain proposal-only in Control Center and must not be presented as atomic Jira writes.

CLI Login And Token Refresh

@knpkv/atlassian-common/cli-auth is the whole OAuth flow an Atlassian command-line tool needs: browser login through a local callback server, the rotating refresh token (one refresh at a time, grant and save atomic, stored token deleted only on an invalid_grant 400/403), and profile switching. A CLI binds it to its own storage namespace, scopes and names, and keeps its own service tag:

import { makeAtlassianCliAuth, NodeCliAuthLive } from "@knpkv/atlassian-common/cli-auth"
import { Layer } from "effect"

export const layer = Layer.effect(
  JiraAuth,
  makeAtlassianCliAuth({
    toolName: "jira-cli", // storage namespace
    commandName: "jira", // used in "Run 'jira auth login'"
    productName: "Jira", // used in "No Jira sites found"
    scopes: JIRA_CLI_SCOPES,
    authMissing: () => new AuthMissingError()
  })
).pipe(Layer.provide(NodeCliAuthLive))

NodeCliAuthLive supplies the callback server and token storage on Node; the layer still needs HttpClient, ChildProcessSpawner and Crypto. Login prints the authorization URL, then tries open, xdg-open and rundll32.exe; if none succeeds it says so on stderr and keeps waiting for the callback. It is a separate subpath from ./auth because it carries a Node HTTP server and a browser launcher.

Token And Profile Storage

Stores OAuth config, auth profiles, and the active token mirror in ~/.config/atlassian/<tool>/ with 0600 permissions.

import { Effect } from "effect"
import {
  saveProfileToken,
  loadActiveProfileToken,
  loadProfiles,
  setActiveProfileBySelector,
  isTokenExpired,
  saveOAuthConfig,
  loadOAuthConfig,
  HomeDirectoryLive
} from "@knpkv/atlassian-common/config"

const program = Effect.gen(function* () {
  yield* saveOAuthConfig("jira", { clientId: "...", clientSecret: "..." })
  const config = yield* loadOAuthConfig("jira")

  yield* saveProfileToken("jira", {
    access_token: "...",
    refresh_token: "...",
    expires_at: Date.now() + 3600_000,
    scope: "read:jira-work offline_access",
    cloud_id: "...",
    site_url: "https://example.atlassian.net"
  })

  const profiles = yield* loadProfiles("jira")
  yield* setActiveProfileBySelector("jira", "https://example.atlassian.net")

  const token = yield* loadActiveProfileToken("jira")
  const expired = token ? isTokenExpired(token) : true
}).pipe(Effect.provide(HomeDirectoryLive))

profiles.json is the multi-account/site source of truth. auth.json is still mirrored to the active profile so older single-profile consumers keep working.

AST Types

Typed Atlassian Document Format nodes — used by @knpkv/jira-cli and @knpkv/confluence-to-markdown.

import { Document, Paragraph, Text, Heading, CodeBlock } from "@knpkv/atlassian-common/ast"

Markdown Serializer

Converts AST nodes to markdown strings.

import { serializeToMarkdown } from "@knpkv/atlassian-common/serializers"

const markdown = serializeToMarkdown(document)

License

MIT