tink icon indicating copy to clipboard operation
tink copied to clipboard

referenceerror: self is not defined when using in Nodejs

Open victorxx11 opened this issue 4 years ago • 2 comments

Can we use tink in nodejs?

Help us help you

We are using tink downloaded from npm: https://www.npmjs.com/package/tink-crypto. We are using it from Nodejs

Describe the bug

The whole lib can not initialize. We tried both static and dynamic import and both failed with above error message.

Here is a code sample:

const tinkLoader = () => import('tink-crypto');

tinkLoader().then((tink) => {
                    tink.hybrid.register();
                    const keyset = stringToUint8Array(atob(resource_response.data.encoded_key));
                    tink.binary
                      .deserializeNoSecretKeyset(keyset)
                      .getPrimitive(tink.hybrid.HybridEncrypt)
                      .then((hybridEncrypt) => {
                        //do some thing
                        });
                      });

To Reproduce

just copy above code to any nodejs env

Expected behavior

can use it in node.

Error messages, stack traces, etc.

ReferenceError: self is not defined at internal/proto.ts:85:23 at node_modules/tink-crypto/bundles/tink-crypto.umd.js:2:68 at Object. (node_modules/tink-crypto/bundles/tink-crypto.umd.js:5:2) Version information

  • Language: JS
  • Version: 0.1.0
  • Environment: node 12

victorxx11 avatar Aug 09 '21 19:08 victorxx11

Thanks for your help!

victorxx11 avatar Aug 09 '21 19:08 victorxx11

Tink currently doesn't work in Node.js. We're hoping to address this limitation in the future.

taymonbeal avatar Aug 10 '21 16:08 taymonbeal

We will not be able to address this.

tholenst avatar Apr 12 '23 15:04 tholenst