magiclabs / magic-admin-js

Magic admin Node.js SDK makes it easy to leverage Decentralized ID tokens to protect routes and restricted resources for your application.
https://docs.magic.link/admin-sdk/node-js
MIT License
75 stars 33 forks source link

Fails to build for web worker environment #89

Closed vasco-santos closed 1 year ago

vasco-santos commented 2 years ago

✅ Prerequisites

🐛 Description

Since version 1.4.1 as a result of https://github.com/magiclabs/magic-admin-js/pull/88 fails to build in web workers due to https://git.coolaj86.com/coolaj86/atob.js/issues/5 .

Fails with:

ReferenceError: window is not defined
    at ../../node_modules/.pnpm/atob@2.1.2/node_modules/atob/browser-atob.js (/Users/vsantos/work/pl/gh/nftstorage/nftstorage.link/packages/api/dist/worker.mjs:2363:8)
    at __require (/Users/vsantos/work/pl/gh/nftstorage/nftstorage.link/packages/api/dist/worker.mjs:8:50)
    at /Users/vsantos/work/pl/gh/nftstorage/nftstorage.link/packages/api/dist/worker.mjs:5122:27

🧩 Steps to Reproduce

  1. Install in a web worker project
  2. Build using ESM (or any other)

🤔 Expected behavior

ESM Build works

😮 Actual behavior

ESM build fails

💻 Code Sample

[If possible, please provide a code repository, gist, code snippet or sample files to reproduce the issue.]

🌎 Environment

Software Version(s)
@magic-sdk/admin 1.4.1
Node 16.3.0
yarn
Operating System
justinnout commented 1 year ago

This seems to be addressed according to this thread: https://git.coolaj86.com/coolaj86/atob.js/issues/5. Closing for now unless issue needs to be reopened!