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.

MIT License

Downloads
41.5K
Stars
74

Magic Authentication Admin Javascript SDK

The Magic Admin SDK lets developers secure endpoints, manage users, and create middlewares via easy-to-use utilities.

πŸ“– Documentation

See the developer documentation to learn how you can master the Magic Admin SDK in a matter of minutes.

πŸ”— Installation

Integrating your Node.js application with Magic will require our server-side NPM package:

# Via NPM:
npm install --save @magic-sdk/admin

# Via Yarn:
yarn add @magic-sdk/admin

⚑️ Quick Start

Sign up or log in to the developer dashboard to receive API keys that will allow your application to interact with Magic's administration APIs.

const { Magic } = require('@magic-sdk/admin');

// In async function:
const magic = await Magic.init('YOUR_SECRET_API_KEY');
// OR
Magic.init('YOUR_SECRET_API_KEY').then((magic) => {
  magic
});
// Validate a token
try {
  magic.token.validate("DIDToken");
} catch (e) {
  console.log(e);
}
// Magic Auth - Get User Email
try {
  await magic.users.getMetadataByToken("DIDToken");
} catch (e) {
  console.log(e);
}
Package Rankings
Top 2.74% on Npmjs.org
Badges
Extracted from project README
Publish
Related Projects