New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mirrorworld/server.utils

Package Overview
Dependencies
Maintainers
5
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mirrorworld/server.utils

Mirror World Server Utilities

  • 1.3.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

Approval Middleware

This middleware is used to authorize actions executed by users. This prevents external entities from performing actions on behalf of users. The way it works is that the user approves an action, which creates a token that is valid for 60 seconds on the Mirror World SSO.

This token should then be used to authenticate the user's action on the target service.

Installation

yarn add @mirrorworld/approval.middleware

Usage

import myRedisClient from "../path/to/redis"
import { ActionApprovalClient } from "@mirrorworld/approval.middleware"

const secret = process.env.MY_JWT_SECRET
const algorithm = process.env.MY_JWT_ALGORITHM

// 1. Create Action approval client
const approvalClient = new ActionApprovalClient({
  redisClient: myRedisClient,
  jwt: {
    secret: secret,
    algorithm: algorithm
  }
})

// 2. Create middleware instance
const approvalMiddleware = approvalClient.createValidateActionMiddleware("x-authorization-token")

// 3. Add middleware to request
router.post("/v1/transfer", approvalMiddleware, async (req, res, next) => {
  // Execute authorized action transfer
})

Keywords

FAQs

Package last updated on 14 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc