npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@node-api-toolkit/dropbox

v1.1.0

Published

A set of Dropbox API utilities

Downloads

20

Readme

Dropbox

A set of Dropbox API utilities

Installation

yarn add @node-api-toolkit/dropbox

Utilities

  • @node-api-toolkit/dropbox/auth - Authenticates the user using oauth.

Usage

To Prototype

Run

yarn run create-dropbox-token-file --tokenIdentifier YOUR-TOKEN-IDENTIFIER

Then you can manually use the token by using save-token/getToken. Read those docs for more info

@node-api-toolkit/dropbox/auth

import express = require("express");

import auth from "@node-api-toolkit/dropbox/auth";

const app = express();
const server = app.listen(8888);

// if it succeeds we will be redirected here
// this should be the home page of your app
app.get("/success", (req, res) => {
  res.json({
    success: true
  });
});

// if it fails we will be redirected here
app.get("/failure", (req, res) => {
  res.json({
    success: false
  });
});

// this function gets called when an oauth is successful
// it needs to return back the user that it was given
// with possible metadata attached
// {
//   accessToken: "I_AM_THE_TOKEN",
//   refreshToken: "REFRESH_TOKEN",
//   user: {
//     userId: "123",
//     email: "[email protected]",
//     name: {
//       givenName: "Franz",
//       familyName: "Ferdinand",
//       displayName: "Franz Ferdinand (Personal)"
//     },
//     profile: expect.anything()
//   }
// }
const onOauthSuccess = ({ accessToken, refreshToken, profile }) => {
  return new Promise(resolve => {
    const modifiedUser = {
      ...profile,
      // attaching metadata
      metadata: {
        jwtToken: "123"
      }
    };

    // we do something to link the access token to the user
    // (User refers to a user model you use to create a user in your database)
    // example:
    User.findOrCreate({ providerId: profile.userId }, (err, user) => {
      if (err) {
        throw new Error(err);
      }
      return resolve(user);
    });
  });
};

// adds auth endpoints to the expressApp
auth({
  appKey: "KEY",
  appSecret: "SECRET",
  onOauthSuccess,

  expressApp: app,
  callbackURL: "http://localhost:8888/auth/dropbox/callback",

  successRedirect: "/success",
  failureRedirect: "/failure"
});

// User now visits the `oauthStartUrl` (default /auth/dropbox)
// http://localhost:8888/auth/dropbox

// The endpoint redirects us to dropbox's oauth server (below).
// usually it would have a login page where the user clicks "Login"
// but here we just mock some text so that we can verify that the
// redirect was successful

// once the user logs in the oauth server will redirect back to
// /auth/dropbox/callback (callbackUrl). We simulate that happening
// http://localhost:8888/auth/dropbox/callback?code=123

// Once the user reaches the callback url, the server will use the
// authorization code (code) to get an oauth token. We mock the
// response from dropbox's api with the access token and refresh
// token

// the callback endpoint then uses the token to reach out and get
// the account details which have the account_id and some other
// metadata

// once the server fetches the user info, it will redirect the user back
// to the /success endpoint we created on top. We are verifying the
// redirect was successful

Tests

This package is thoroughly tested. All tests located in __tests__

You should run tests from the monorepo root. But you can also run them individually.

Both accept the following yarn run commands:

  • yarn run test: Runs tests with mocks (mocks API)
  • test:watch: Watches tests (use for development)
  • test:debug: Prints debug information
  • yarn run test:watch:debug: Prints debug info in watch mode
  • yarn run test:integration: Uses the real APIs to test. Note you need to set up the token using yarn run create-jest-dropbox-token-file
  • yarn run test:integration:watch: Uses the real APIs to test in watch mode. Note you need to set up the token using yarn run create-jest-dropbox-token-file

To run tests with the real API, you must first generate a JEST token.

yarn run create-jest-dropbox-token-file