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

@superwall/protocol

v2.7.2

Published

The Superwall SDK ↔ paywall message protocol: message schemas, transports, initialization params.

Readme

Install

npm install @superwall/protocol

You will not usually install this directly: @superwall/runtime, @superwall/host and the superwall framework depend on it. Reach for it alone to validate or replay SDK messages, or to build a transport of your own.

What's here

| File | Owns | | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | | messages/incoming.ts | IncomingMessageSchema, host → paywall, and one TIncomingMessage… type per message | | messages/outgoing.ts | OutgoingMessageSchema, paywall → host | | messages/permissions.ts | The permission types a paywall can request and the statuses a host answers with | | transport/ | ITransport, the envelope (wrap/unwrap, MessageDirection), and the three transports buildTransport(kind) selects | | transport/kind.ts | TransportKind and detectTransportKind: which host a paywall was loaded by (?transport=) | | test/fixtures/host/ | Literal message sequences copied from the production hosts, the contract every host and runtime in this repo is tested against |

The schemas are a copy of paywall.js's paywall-js/messages, kept in step with it. Three differences are deliberate: freeTrial_start.trial_end_date also accepts the epoch in milliseconds iOS actually sends; back_button_input carries no payload, which is what Android sends; and the editor's substitution and page-style payloads (ping.substitutions, page_styles, template_substitutions) are opaque arrays, because a framework paywall sends none and ignores what an editor sends.

Host → paywall

Every native message also carries paywall_id and paywall_identifier; the schemas strip what they do not declare.

| event_name | Fields | Sent by | | ----------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | ------------------------------------------- | | template_variables | variables (device, user, params, products + v3 slots) | every host, in reply to ping | | products | products[] of { product, productId } | every host, in reply to ping | | experiment | experimentId, variantId, campaignId | every host, in reply to ping | | template_substitutions_prefix | prefix: "freeTrial" or null | every host, in reply to ping | | paywall_open | paywall_id, paywall_identifier | every host, last in the reply to ping | | paywall_close | optional ids | iOS, Android | | transaction_start, transaction_complete, transaction_abandon | optional product_identifier, product | iOS, Android, web host | | transaction_fail, transaction_timeout, transaction_restore | optional product_identifier, product | iOS | | freeTrial_start | optional product_identifier, trial_end_date (ms or ISO) | iOS, Android | | restore_start, restore_complete | none | iOS | | restore_fail | none | iOS, Android | | permission_result | permission_type, request_id, status | iOS, Android | | callback_result | request_id, name, status, optional data | iOS, Android | | event_tracking_behavior | behavior: all, superwallOnly, none | iOS, Android | | back_button_input | none | Android | | game_controller_input | controller_element, directional + x/y or value | iOS | | redeem_discount | code | hosts embedding web checkout | | template_substitutions, page_styles, template_json, focus_*, unfocus_*, substitution_editor_*, application_settings, paywall_settings | editor state | the visual editor; the runtime ignores them |

Paywall → host

| event_name | Fields | | ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | | ping | substitutions, page_styles, optional version, products, coordinates, fonts | | close, restore | none | | purchase | product (reference), optional product_identifier, should_dismiss | | open_url | url, optional browser_type: "payment_sheet" | | open_url_external, open_payment_sheet | url | | open_deep_link | link | | custom | data | | custom_placement | name, params | | user_attribute_updated | attributes[] of { key, value } | | request_store_review | review_type: in-app, external | | haptic_feedback | haptic_type | | request_permission | permission_type, request_id | | request_callback | request_id, name, behavior, optional variables | | schedule_notification | id, type: "TRIAL_STARTED", title, optional subtitle, body, delay (ms) | | page_view | type, page_node_id, page_name, navigation_node_id, flow_position, previous page | | initiate_web_checkout, stripe_checkout_*, post_checkout_complete | web checkout lifecycle, keyed by checkout_context_id and product_identifier | | discount_redemption_result | code, valid, optional reason, appliedProductCount | | var_click, page_styles, has_set_dom | editor state |

Transports

buildTransport(kind) picks how messages reach the host: WebKit message handlers on iOS (window.webkit.messageHandlers.paywallMessageHandler, queueing into window.app.messages until the host installs one), the Android SWAndroid interface, or postMessage to the parent window for the editor and the studio. Every host delivers messages to the paywall through window.paywall.accept64(base64) or accept(messages); the transport's accept fans them out to listeners once startListening has been called.

The editor transport posts to window.parent with origin * and accepts any origin, the same as paywall.js; a paywall only ever runs in a page its host loaded, so the host is trusted by construction.

Set localStorage.SW_DEBUG_TRANSPORT = "true" to log every message.

Compatibility rules

Old app binaries with old native SDKs load new paywall bundles indefinitely. Therefore:

  • Additive changes only — new message types, new optional fields.
  • Never rename or remove an event_name, a field, or an enum value.
  • Never make an optional field required.
  • Every new message type ships with accept and reject test cases.

Develop

This package lives in the superwall/superwall monorepo. Read AGENTS.md first - the conventions in it are decided, not suggested.

bun install
bun run test          # every message has accept and reject cases; the host fixtures replay real sequences
bun run typecheck

There is no compile step in day-to-day development — exports point straight at src/, so tests and consumers resolve the sources directly.

License

Functional Source License (FSL-1.1-ALv2): use it, modify it, embed it, ship it — anything except building a competing product with it — and every release becomes Apache 2.0 two years after publication.