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

https://peculiarventures.github.io/webcrypto-local/webcrypto-socket.js returns 404 #229

Closed
tokyoweb3 opened this issue Jan 20, 2020 · 19 comments

Comments

@tokyoweb3
Copy link

tokyoweb3 commented Jan 20, 2020

I have a code importing 'https://peculiarventures.github.io/webcrypto-local/webcrypto-socket.js', but since one week ago, I get 404 not found.
Any way to work around this?

@microshine
Copy link
Contributor

See https://unpkg.com/@webcrypto-local/client@latest

<script src="https://unpkg.com/@webcrypto-local/[email protected]/build/webcrypto-socket.js"></script>

or minified version

<script src="https://unpkg.com/@webcrypto-local/[email protected]/build/webcrypto-socket.min.js"></script>

@microshine
Copy link
Contributor

<!-- Babel Polyfill -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/7.7.0/polyfill.min.js"></script>
<!-- Crypto -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/asmCrypto/2.3.2/asmcrypto.all.es5.min.js"></script>
<script src="https://cdn.rawgit.com/indutny/elliptic/master/dist/elliptic.min.js"></script>
<script src="https://unpkg.com/[email protected]/build/webcrypto-liner.shim.min.js"></script>
<!-- WebCrypto Socket -->
<script src="https://cdn.rawgit.com/dcodeIO/protobuf.js/6.8.0/dist/protobuf.js"></script>
<script src="https://unpkg.com/@webcrypto-local/[email protected]/build/webcrypto-socket.min.js"></script>

@tokyoweb3
Copy link
Author

tokyoweb3 commented Jan 20, 2020

@microshine
Thank you for your help.
With the url you provided, I get error.

    at new t (webcrypto-socket.min.js:15)
    at init (Certificate.tsx:59)
    at Certificate.tsx:54
    at commitHookEffectList (react-dom.development.js:22030)
    at commitPassiveHookEffects (react-dom.development.js:22064)
    at HTMLUnknownElement.callCallback (react-dom.development.js:336)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:385)
    at invokeGuardedCallback (react-dom.development.js:440)
    at flushPassiveEffectsImpl (react-dom.development.js:25392)
    at unstable_runWithPriority (scheduler.development.js:697)
    at runWithPriority$2 (react-dom.development.js:12149)
    at flushPassiveEffects (react-dom.development.js:25361)
    at react-dom.development.js:25240
    at workLoop (scheduler.development.js:641)
    at flushWork (scheduler.development.js:596)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:203)```

@microshine
Copy link
Contributor

Please try the full version. It would be easier to find a problem

@tokyoweb3
Copy link
Author

webcrypto-socket.js:10196 Uncaught TypeError: Cannot read property 'storage' of undefined
    at new SocketProvider (webcrypto-socket.js:10196)
    at init (Certificate.tsx:59)
    at Certificate.tsx:54
    at commitHookEffectList (react-dom.development.js:22030)
    at commitPassiveHookEffects (react-dom.development.js:22064)
    at HTMLUnknownElement.callCallback (react-dom.development.js:336)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:385)
    at invokeGuardedCallback (react-dom.development.js:440)
    at flushPassiveEffectsImpl (react-dom.development.js:25392)
    at unstable_runWithPriority (scheduler.development.js:697)
    at runWithPriority$2 (react-dom.development.js:12149)
    at flushPassiveEffects (react-dom.development.js:25361)
    at react-dom.development.js:25240
    at workLoop (scheduler.development.js:641)
    at flushWork (scheduler.development.js:596)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:203)

@tokyoweb3
Copy link
Author

tokyoweb3 commented Jan 20, 2020

Im using React and importing all the external js urls with this.
I'm quite new to coding in general, so descriptive reply would be very helpful.

for (const id in urls) {
    let tag = document.createElement('script');
    tag.async = false;
    tag.src = urls[id];
    let body = document.getElementsByTagName('body')[0];
    body.appendChild(tag);
  }

@tokyoweb3
Copy link
Author

tokyoweb3 commented Jan 20, 2020

Certificate.tsx: 54

  // get webcryptosocket
  useEffect(() => {
    window.WebcryptoSocket && init();
  }, [window.WebcryptoSocket])

  const init = () => {
    const WebcryptoSocket = window.WebcryptoSocket;
    const ws = new WebcryptoSocket.SocketProvider();
    setWs(ws);
    setWsReady(true);
  }

@microshine
Copy link
Contributor

const ws = new WebcryptoSocket.SocketProvider({
  storage: await WebcryptoSocket.BrowserStorage.create(),
});

@microshine
Copy link
Contributor

I'll update README file. I created a new ticket for that #230

@tokyoweb3
Copy link
Author

tokyoweb3 commented Jan 20, 2020

I updated the code to this:

  const init = async () => {
    const WebcryptoSocket = window.WebcryptoSocket;
    const ws = new WebcryptoSocket.SocketProvider({
      storage: await WebcryptoSocket.BrowserStorage.create(),
    });
    setWs(ws);
    setWsReady(true);
  }

@tokyoweb3
Copy link
Author

@microshine I'm using react. Is there a template to load js resources to use WebSocket?

@tokyoweb3
Copy link
Author

tokyoweb3 commented Jan 20, 2020

It seemed to detect provider, but cannot decode certificate storage. Public key is read w/o problems but x.509 certificate.
Any solution?

Cannot get x509-xxxxx-xxxxx from CertificateStorage

index.js:1 Error: Error: Cannot decode message for t.
$ProtobufError: index out of range: 305 + 58 > 315

@tokyoweb3
Copy link
Author

Screen Shot 2020-01-20 at 17 19 11

@tokyoweb3
Copy link
Author

https://peculiarventures.github.io/fortify-examples/example4.html

By the way, this example also gives the same error.

@tokyoweb3
Copy link
Author

tokyoweb3 commented Jan 20, 2020

https://peculiarventures.github.io/fortify-examples/example4.html

By the way, this example also gives the same error.

This error was solved by downgrading webcrypto-local to 1.0.12

But ws.connect produces DOMException error. How do I solve this?

    ws.connect("127.0.0.1:31337")
    .on("error", function (e: any) {
      console.error(e);
    })

produces error :

DOMException
console.<computed> @ index.js:1
(anonymous) @ Certificate.tsx:88
emitOne @ webcrypto-socket.js:625
emit @ webcrypto-socket.js:700
(anonymous) @ webcrypto-socket.js:4311
emitOne @ webcrypto-socket.js:629
emit @ webcrypto-socket.js:700
(anonymous) @ webcrypto-socket.js:3429
Promise.catch (async)
socket.onmessage @ webcrypto-socket.js:3428

@microshine
Copy link
Contributor

Are you using Fortify or @webcrypto-local/server?
What version do you use?

@microshine
Copy link
Contributor

The latest version of Fortify is v1.0.21?
@webcrypto-local/server - v1.0.16

@tokyoweb3
Copy link
Author

Currently using v1.0.20
I will update and get back to you

@tokyoweb3
Copy link
Author

Updating and a bit of tweaking solved the problem! Thanks!

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

2 participants