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

feature: make package environment agnostic #81

Merged
merged 3 commits into from
Mar 29, 2022

Conversation

f5io
Copy link
Contributor

@f5io f5io commented Feb 17, 2022

📦 Pull Request

This PR makes the @magic-sdk/admin package environment agnostic by

  • removing the usage of eth-sig-util and ethereumjs-util that rely heavily on node internals.
  • using ethereum-cryptography and some inlined functionality.
  • removing usage of node's Buffer in favour of typed arrays.
  • shimming node-fetch only where no global fetch implementation is available.
  • building both commonjs and esm outputs of the package.

✅ Fixed Issues

🚨 Test instructions

All tests pass and coverage is maintained.

I have also created an example of this new @magic-sdk/admin running in a sveltekit application: https://github.com/f5io/magic-link-cloudflare-demo
Here it is actually deployed on cloudflare workers 🎉 : https://magic-link-demo.trustshare.workers.dev/

⚠️ Don't forget to add a semver label!

  • minor: New Feature

@smithki
Copy link
Contributor

smithki commented Feb 17, 2022

Your contribution is very appreciated @f5io! Some unfortunate timing that we are currently in the process of moving this SDK source code to the Magic JS monorepo. We expect to have completed the transition next week. At that time we would love to help you translate this PR to the new repo!

@@ -1,5 +1,6 @@
import fetch, { RequestInit } from 'node-fetch';
import { RequestInit } from 'node-fetch';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be updated to import type {... now that an async shim is being used instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i did attempt to change type imports with the following in the tsconfig.json...

...
    "importsNotUsedAsValues": "error",
...

however, it seems like your current linting set up does not support this syntax :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can look at this as a follow-up on our side, in that case!

@f5io
Copy link
Contributor Author

f5io commented Feb 17, 2022

Your contribution is very appreciated @f5io! Some unfortunate timing that we are currently in the process of moving this SDK source code to the Magic JS monorepo. We expect to have completed the transition next week. At that time we would love to help you translate this PR to the new repo!

absolutely happy to transition these changes into the new monorepo, just let me know when you are ready 👍

@smithki
Copy link
Contributor

smithki commented Mar 3, 2022

Priorities shifted a bit and we'll be delaying the merging of this package into our JS monorepo for now. Just a heads up that I'll be reviewing your change shortly and hopefully we can cut a release by end-of-week!

@smithki
Copy link
Contributor

smithki commented Mar 3, 2022

@f5io We have updated our test framework to use Jest in order to align this repository with the code standards in our monorepo. This change does create a few minor conflicts in your PR. Once we can get those sorted, I'm happy to ship this one!

@f5io
Copy link
Contributor Author

f5io commented Mar 4, 2022

@smithki on it... will sort asap

@f5io f5io force-pushed the feature/#62/environment-agnostic branch from a88c7c1 to c79b704 Compare March 4, 2022 11:22
@f5io
Copy link
Contributor Author

f5io commented Mar 4, 2022

@smithki rebased my branch from your master, everything seems to be passing as intended 👍

@f5io
Copy link
Contributor Author

f5io commented Mar 29, 2022

hey @smithki, just bumping this...

we're planning on going into production with this approach in a couple of weeks. obviously, i'm more than happy to roll with pointing at my fork for now.

@liam0215
Copy link

I'd like to bump this as well, I think this'll get me unblocked from using Magic with Convex

@3x071c
Copy link

3x071c commented Mar 29, 2022

@smithki Don't want to annoy anybody, but I've been encountering similar issues with Remix on Cloudflare Pages (running on dynamic workers functions, which don't run full-blown Node.js for efficiency). Would greatly appreciate having this integrated!

@smithki smithki merged commit 60aa124 into magiclabs:master Mar 29, 2022
@smithki smithki added the minor Increment the minor version when merged label Mar 29, 2022
@smithki
Copy link
Contributor

smithki commented Mar 29, 2022

🚀 PR was released in v1.4.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor Increment the minor version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ideas to unblock usage in deno?
4 participants