Skip to content

Commit

Permalink
build: add jsr.io distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Feb 24, 2025
1 parent 3c9f0d9 commit 6734619
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 7 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,21 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

jsr:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: npx jsr publish

cleanup:
needs:
- npm
- jsr
runs-on: ubuntu-latest
permissions:
contents: write
Expand All @@ -47,6 +59,7 @@ jobs:
github:
needs:
- npm
- jsr
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
18 changes: 17 additions & 1 deletion .postbump.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { execSync } = require('child_process')
const { readFileSync, writeFileSync } = require('fs')
const { version } = require('./package.json')
const { version, dependencies } = require('./package.json')

const updates = [
[
Expand All @@ -24,4 +24,20 @@ for (const [path, regex, replace, gitAdd = true] of updates) {
if (gitAdd) execSync(`git add ${path}`, { stdio: 'inherit' })
}

const jsr = require('./jsr.json')
jsr.imports = {}
jsr.version = version

for (const [dependency, semver] of Object.entries(dependencies)) {
switch (dependency) {
case 'jose':
case 'oauth4webapi':
jsr.imports[dependency] = `jsr:@panva/${dependency}@${semver}`
break
default:
throw new Error('unhandled jsr dependency')
}
}
writeFileSync('./jsr.json', JSON.stringify(jsr, null, 4) + '\n')

execSync('git add build/* -f', { stdio: 'inherit' })
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Support from the community to continue maintaining and improving this module is

## [API Reference Documentation](docs/README.md)

`openid-client` is distributed via [npmjs.com](https://www.npmjs.com/package/openid-client) and [github.com](https://github.com/panva/openid-client).
`openid-client` is distributed via [npmjs.com](https://www.npmjs.com/package/openid-client), [jsr.io](https://jsr.io/@panva/openid-client), and [github.com](https://github.com/panva/openid-client).

## [Examples](examples/README.md)

Expand Down
20 changes: 20 additions & 0 deletions jsr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://jsr.io/schema/config-file.v1.json",
"name": "@panva/openid-client",
"version": "6.3.1",
"exports": {
".": "./src/index.ts",
"./passport": "./src/passport.ts"
},
"publish": {
"include": [
"LICENSE.md",
"README.md",
"src/*.ts"
]
},
"imports": {
"jose": "jsr:@panva/jose@^6.0.1",
"oauth4webapi": "jsr:@panva/oauth4webapi@^3.3.0"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
],
"scripts": {
"_format": "find src test examples tap conformance -type f -name '*.ts' -o -name '*.mjs' -o -name '*.cjs' | xargs prettier --check",
"build": "rm -rf build && tsc && tsc --removeComments false --declaration --emitDeclarationOnly && tsc -p tsconfig.passport.json && tsc -p tsconfig.passport.json --removeComments false --declaration --emitDeclarationOnly && tsc -p test && npm run --silent check-build",
"build": "rm -rf build && tsc && tsc --removeComments false --declaration --emitDeclarationOnly && tsc -p tsconfig.passport.json && tsc -p tsconfig.passport.json --removeComments false --declaration --emitDeclarationOnly && tsc -p test && npm run --silent check-build && npx --yes jsr publish --dry-run --allow-dirty",
"check-build": "tsc --noEmit --types node --lib ES2022.Error && tsc -p conformance && tsc -p tap && tsc -p examples",
"conformance": "bash -c 'source .node_flags.sh && ava --config conformance/ava.config.ts'",
"docs": "patch-package && typedoc",
Expand Down
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,9 @@ function CodedTypeError(message: string, code: codes, cause?: unknown) {
* @group PKCE
* @group Authorization Request
*/
export function calculatePKCECodeChallenge(codeVerifier: string) {
export function calculatePKCECodeChallenge(
codeVerifier: string,
): Promise<string> {
return oauth.calculatePKCECodeChallenge(codeVerifier)
}

Expand All @@ -806,7 +808,7 @@ export function calculatePKCECodeChallenge(codeVerifier: string) {
*
* @group PKCE
*/
export function randomPKCECodeVerifier() {
export function randomPKCECodeVerifier(): string {
return oauth.generateRandomCodeVerifier()
}

Expand All @@ -815,7 +817,7 @@ export function randomPKCECodeVerifier() {
*
* @group Authorization Request
*/
export function randomNonce() {
export function randomNonce(): string {
return oauth.generateRandomNonce()
}

Expand All @@ -824,7 +826,7 @@ export function randomNonce() {
*
* @group Authorization Request
*/
export function randomState() {
export function randomState(): string {
return oauth.generateRandomState()
}

Expand Down

0 comments on commit 6734619

Please sign in to comment.