Skip to content

DENO 2 related issue. Update helper.ts#48

Open
shaunie2fly wants to merge 1 commit intoinvisal:masterfrom
shaunie2fly:shaunie2fly-patch-1-deno2_support
Open

DENO 2 related issue. Update helper.ts#48
shaunie2fly wants to merge 1 commit intoinvisal:masterfrom
shaunie2fly:shaunie2fly-patch-1-deno2_support

Conversation

@shaunie2fly
Copy link

update base64_to_binary function .

In browser JavaScript, atob() is used to decode a base64-encoded string. It's part of the Web APIs, which aren't natively available in Deno's runtime environment.

After enabling DENO_FUTURE=1 we now get thsi error :

error: Uncaught (in promise) ReferenceError: window is not defined
let binaryString = window.atob(b);
^
at base64_to_binary (https://deno.land/x/god_crypto@v1.4.11/src/helper.ts:60:22)
at rsa_import_pem_public (https://deno.land/x/god_crypto@v1.4.11/src/rsa/import_key.ts:132:16)
at rsa_import_pem (https://deno.land/x/god_crypto@v1.4.11/src/rsa/import_key.ts:160:50)
at rsa_import_key (https://deno.land/x/god_crypto@v1.4.11/src/rsa/import_key.ts:179:37)
at Function.importKey (https://deno.land/x/god_crypto@v1.4.11/src/rsa/mod.ts:102:23)
at Function.parseKey (https://deno.land/x/god_crypto@v1.4.11/src/rsa/mod.ts:89:17)

atob() is a global function in browser environments, typically accessed via window.atob(). In Deno, especially with DENO_FUTURE=1, this global function isn't available by default.

update base64_to_binary function .

In browser JavaScript, atob() is used to decode a base64-encoded string. It's part of the Web APIs, which aren't natively available in Deno's runtime environment.

After enabling DENO_FUTURE=1 we now get thsi error :

error: Uncaught (in promise) ReferenceError: window is not defined
  let binaryString = window.atob(b);
                     ^
    at base64_to_binary (https://deno.land/x/god_crypto@v1.4.11/src/helper.ts:60:22)
    at rsa_import_pem_public (https://deno.land/x/god_crypto@v1.4.11/src/rsa/import_key.ts:132:16)
    at rsa_import_pem (https://deno.land/x/god_crypto@v1.4.11/src/rsa/import_key.ts:160:50)
    at rsa_import_key (https://deno.land/x/god_crypto@v1.4.11/src/rsa/import_key.ts:179:37)
    at Function.importKey (https://deno.land/x/god_crypto@v1.4.11/src/rsa/mod.ts:102:23)
    at Function.parseKey (https://deno.land/x/god_crypto@v1.4.11/src/rsa/mod.ts:89:17)

atob() is a global function in browser environments, typically accessed via window.atob().
In Deno, especially with DENO_FUTURE=1, this global function isn't available by default.
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

Successfully merging this pull request may close these issues.

1 participant