build: add jsr.io distribution

This commit is contained in:
Filip Skokan
2025-02-24 17:25:34 +01:00
parent ce63213be8
commit 1f57453f8f
6 changed files with 58 additions and 7 deletions
+13
View File
@@ -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
@@ -47,6 +59,7 @@ jobs:
github:
needs:
- npm
- jsr
runs-on: ubuntu-latest
steps:
- name: Checkout
+17 -1
View File
@@ -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 = [
[
@@ -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' })
+1 -1
View File
@@ -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)
+20
View File
@@ -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"
}
}
+1 -1
View File
@@ -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",
+6 -4
View File
@@ -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)
}
@@ -806,7 +808,7 @@ export function calculatePKCECodeChallenge(codeVerifier: string) {
*
* @group PKCE
*/
export function randomPKCECodeVerifier() {
export function randomPKCECodeVerifier(): string {
return oauth.generateRandomCodeVerifier()
}
@@ -815,7 +817,7 @@ export function randomPKCECodeVerifier() {
*
* @group Authorization Request
*/
export function randomNonce() {
export function randomNonce(): string {
return oauth.generateRandomNonce()
}
@@ -824,7 +826,7 @@ export function randomNonce() {
*
* @group Authorization Request
*/
export function randomState() {
export function randomState(): string {
return oauth.generateRandomState()
}