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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@uni/authorize

v1.0.1

Published

[![npm](https://img.shields.io/npm/v/@uni/authorize.svg)](https://www.npmjs.com/package/@uni/authorize)

Downloads

11

Readme

authorize

npm

Some of the APIs need users’ authorization before they can be called. We have divided these APIs into multiple scope according to the scope of usage. The users can select scope to authorize. After a scope is authorized, all of its APIs can be used directly.

When such an API is called:

  • If the user has not accepted or rejected this authorization, a pop-up window will appear to ask the user if he/she wants to accept. The API can be called only after the user clicks to accept;
  • If the user has accepted authorization, the API can be called directly;
  • If the user has rejected authorization, no pop-up appears. Instead, API fail callback will be accessed directly. Developers should make the scenario compatible where the user has rejected to authorization.

Supported

Install

$ npm install @uni/authorize --save

or

$ npm install @uni/apis --save

Usage

import authorize from '@uni/authorize';

authorize({
  scope: 'scope.userLocation',
  success: () => {
    console.log('success');
  },
  fail: (res) => {
    console.log('fail', res);
  },
  complete: (res) => {
    console.log('complete', res);
  }
});

authorize({
  scope: 'scope.userLocation',
}).then((res?) => {
  console.log('success');
});

你也可以从大包引入:

import { authorize } from '@uni/apis';

Parameters

| Property | Type | Description | Required | Default | | --- | --- | --- | --- | --- | | options | object  | | 是 | - | | options.scope | string  | The scope to be authorized. For details, see scope list | Yes | - | | options.success | Function  | The callback function for a successful API call | No | - | | options.fail | Function  | The callback function for a failed API call | No | - | | options.complete | Function  | The callback function used when the API call completed (always executed whether the call succeeds or fails) | No | - |

Scope List

| scope | Description | Corresponding APIs | Supported | | ------ | -------- | ------ | ---- | | scope.userInfo | User information | getUserInfo, getOpenUserInfo | | | scope.userLocation | Geographic location | getLocation, chooseLocation | | | scope.userLocationBackground | Background positioning | startLocationUpdateBackground | | | scope.werun | WeRun step counts | getWeRunData | | | scope.record | Recording feature | startRecord | | | scope.writePhotosAlbum | Saves to album | saveImage, saveVideo | | | scope.camera | Camera | scanCode,chooseImage,chooseVideo | | | scope.calendar | calendar | addEventOnCalendar,deleteEventOnCalendar | | | auth_base | Silent authorization will not initiate authorization floating window. Get auth_ from Alipay client Code, the incoming server invokes the alipay.system.oauth.token interface to get Alipay membership identifier (user_). id)| addEventOnCalendar,deleteEventOnCalendar | | | auth_zhima | User sesame information | zhima.credit.score.brief.get | |

Response<Response>(Not general)

Note: only Alipay applet returns.

| Property | Type | Description | | --- | --- | --- | | response | object | - | | response.authCode | string  | Authorization code | | response.authErrorScopes | object  | Failed authorization type. Key is the scope of failed authorization, and value is the corresponding error code | | response.authSuccessScopes | Array  | Successful authorization scope |