Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please publish ts native version to jsr.io #85

Closed
inverted-capital opened this issue Apr 9, 2024 · 3 comments
Closed

Please publish ts native version to jsr.io #85

inverted-capital opened this issue Apr 9, 2024 · 3 comments

Comments

@inverted-capital
Copy link

Pretty please could we have a typescript native version on jsr.io ?

For those of us in modern js environments, this would be grand.

jsr.io has supply chain provenance from github actions as well, but you might be able to skip the build step perhaps, and webhook straight from github, putting even less stuff in the way of purity.

Thank you for the @noble libraries 🙏

@paulmillr
Copy link
Owner

Pull requests are welcome.

Before the pull request perhaps you can test this in your fork of noble hashes first. Like under name “inverted-noble-hashes” or something, to ensure everything works correctly. I have some concerns with regards to webcrypto imports.

@quentinadam
Copy link
Contributor

quentinadam commented Dec 30, 2024

I played around I managed to get it working quite easily. I published it as a test to this location on JSR: https://jsr.io/@solardancer/test.

The trick was to add an import map to remap the @noble/hashes/crypto specifier to ./src/crypto.ts.
Here is a working jsr.json file:

{
  "name": "@noble/hashes",
  "version": "1.6.1",
  "exports": {
    ".": "./src/index.ts",
    "./crypto": "./src/crypto.ts",
    "./_assert": "./src/_assert.ts",
    "./_md": "./src/_md.ts",
    "./argon2": "./src/argon2.ts",
    "./blake2b": "./src/blake2b.ts",
    "./blake2s": "./src/blake2s.ts",
    "./blake3": "./src/blake3.ts",
    "./eskdf": "./src/eskdf.ts",
    "./hkdf": "./src/hkdf.ts",
    "./hmac": "./src/hmac.ts",
    "./pbkdf2": "./src/pbkdf2.ts",
    "./ripemd160": "./src/ripemd160.ts",
    "./scrypt": "./src/scrypt.ts",
    "./sha1": "./src/sha1.ts",
    "./sha2": "./src/sha2.ts",
    "./sha3-addons": "./src/sha3-addons.ts",
    "./sha3": "./src/sha3.ts",
    "./sha256": "./src/sha256.ts",
    "./sha512": "./src/sha512.ts",
    "./utils": "./src/utils.ts"
  },
  "imports": {
    "@noble/hashes/crypto": "./src/crypto.ts"
  },
  "publish": {
    "include": [
      "src",
      "jsr.json",
      "LICENSE",
      "README.md"
    ],
    "exclude": [
      "src/cryptoNode.ts"
    ]
  }
}

Publishing can be done with the following command:

jsr publish --allow-slow-types

The publishing command requires the --allow-slow-types flag. This is because by default JSR requires that all exported symbols must explicitly specify types. For instance return types should be explicitly specified on the exported functions. Updating this should not be too complex and I can create a follow-up pull request if you want.

I have also added the same publish-jsr.yml file from your other packages (@noble/secp256k1 and @noble/ed25519):

name: Publish packge to jsr
on:
  release:
    types: [created]
jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4
      - run: npm install -g jsr
      - run: jsr publish --allow-slow-types

I have gone ahead and created a pull request with just the jsr.json file and the publish-jsr.yml file to automate the publishing of new releases:

#103

Please let me know if you would like me to look into updating some of the other items I mentioned above.

@paulmillr
Copy link
Owner

Published

Also i've went forward and ensured there are no slow types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants