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

The npm package does not have compiled .js files #22

Closed
irori opened this issue Feb 3, 2020 · 5 comments · Fixed by #31
Closed

The npm package does not have compiled .js files #22

irori opened this issue Feb 3, 2020 · 5 comments · Fixed by #31
Labels
bug Something isn't working

Comments

@irori
Copy link

irori commented Feb 3, 2020

The example in README.md does not work:

$ npm install structured-headers

+ structured-headers@0.3.0
added 1 package from 1 contributor and audited 1 package in 1.869s
found 0 vulnerabilities

$ node
> const sh = require('structured-headers');
Thrown:
{ Error: Cannot find module 'structured-headers'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18) code: 'MODULE_NOT_FOUND' }

It looks the npm package does not have dist/ and browser/ directories, probably because these are listed in .gitignore and there's no .npmignore file.

Also, "main": "index.js" in package.json should be "main": "dist/index.js".

@evert evert added the bug Something isn't working label Feb 3, 2020
@aljones15
Copy link

aljones15 commented May 12, 2021

related:

> const sh = require('structured-headers');
Uncaught:
Error: Cannot find module '/home/liminal18/Programs/nodeJS/digital_bazaar/http-signature-header/node_modules/structured-headers/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (internal/modules/cjs/loader.js:303:19)
    at Function.Module._findPath (internal/modules/cjs/loader.js:516:18)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18) {
  code: 'MODULE_NOT_FOUND',
  path: '/home/liminal18/Programs/nodeJS/digital_bazaar/http-signature-header/node_modules/structured-headers/package.json',                                                                                          
  requestPath: 'structured-headers'
}
> .exit

[liminal18@nixos:~/Programs/nodeJS/digital_bazaar/http-signature-header]$ ls node_modules/structured-headers/
changelog.md  Makefile  package.json  readme.md  src  test  tsconfig.json  tslint.json  webpack.config.js

node -v
v14.15.1

@evert
Copy link
Collaborator

evert commented May 13, 2021

Given that it's a typescript package, I believe this import style should work in javascript:

const sh = require('structured-headers').default;

If that fails, i'll dig a bit deeper. This package needs some work to be back up to date with the current standard though, it's been a bit hard to find time =(

@evert
Copy link
Collaborator

evert commented May 13, 2021

If there is interest in adopting this, I can spend some time fully bringing this up to par with the latest standards. Something I planned to do anyway, but I can potentially prioritize this

@aljones15
Copy link

As the Signing HTTP Headers specification now uses structured fields it might be a good idea. The spec that brought me here. I tried your import method:

const sh = require('structured-headers').default;
Uncaught:
Error: Cannot find module '/home/liminal18/Programs/nodeJS/digital_bazaar/http-signature-header/node_modules/structured-headers/index.js'. Please verify that the package.json has a valid "main" entry
    at tryPackage (internal/modules/cjs/loader.js:303:19)
    at Function.Module._findPath (internal/modules/cjs/loader.js:516:18)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18) {
  code: 'MODULE_NOT_FOUND',
  path: '/home/liminal18/Programs/nodeJS/digital_bazaar/http-signature-header/node_modules/structured-headers/package.json',                                                                                          
  requestPath: 'structured-headers'
}

still doesn't work. The issue I'm running into is that HTTP signatures are both front end and back end and the other structured fields library uses the node only Buffer class which requires a 200kb polyfill. So there doesn't seem to be a good cross environment structured fields library surprisingly.

@evert
Copy link
Collaborator

evert commented May 14, 2021

This library was several drafts behind, and instead of trying to get it up to date with the current RFC, I rewrote it yesterday.

The new parser passes all official tests, but the serializer is not done yet.

I've kept the 'No buffer' requirement in mind, so the eventual release will use ArrayBuffer instead, which is available in browsers.

If this can wait a few more days, I can have a fully functioning npm package ready to go.

evert added a commit that referenced this issue May 16, 2021
@evert evert closed this as completed in #31 May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants