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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@maroon1/wechat-signable-url

v0.2.0

Published

获取微信内当前 WebView 的 URL 用于签名

Downloads

3

Readme

WeChat Signable URL

获取微信内当前 WebView 的 URL 用于签名

动机

在调用微信 JS SDK 前需要调用 wx.config 方法往当前页面注入权限验证配置,wx.config 方法中的 signature 参数需要使用「当前 WebView 的 URL」(以下统称 WebView URL) 来生成。iOS 与 Android 两个平台的 WebView URL 获取结果不一致。在 Android 平台中,WebView URL 等于当前 window.location.href 的值,而在 iOS 平台中则为打开 WebView 时的 URL 的值。这就造成 iOS 平台下的 SPA ,在使用 History API 跳转页面后,因为 window.location.href 与 Native 获取的 WebView URL 不同,导致签名无效。所以在 iOS 平台中总是使用初始化时获取的 window.location.href 值来签名就能解决签名无效的问题。

安装

npm install @maroon1/wechat-signable-url

使用

import url from '@maroon1/wechat-signable-url';

// 尽可能早的(在页面发生跳转之前)初始化入口地址,否则获取的待签名URL地址可能不正确
url.init();

const signableUrl = url();

getSignatureFromRemote(signableUrl)
  .then(signature => {
    wx.config({
      signature,
      ...
    });
  });