UNPKG

ribbit-wallet-connect

Version:

Next-generation multi-chain wallet and payments app that makes crypto simple, secure, and usable in daily life.

36 lines (35 loc) 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AppTransport = void 0; class AppTransport { listen() { // No-op; the host app may internally manage events } async sendMessage(type, payload) { if (typeof window === 'undefined') throw new Error('SSR mode'); if (!window.ribbit || window.ribbit.type !== 'app') { throw new Error('AppTransport: ribbit app not detected'); } return window.ribbit.postMessage(type, payload); } registerHandler(event, handler) { var _a, _b; if (typeof window === 'undefined') return; (_b = (_a = window.ribbit) === null || _a === void 0 ? void 0 : _a.on) === null || _b === void 0 ? void 0 : _b.call(_a, event, handler); } on(event, handler) { var _a, _b; if (typeof window === 'undefined') return; (_b = (_a = window.ribbit) === null || _a === void 0 ? void 0 : _a.on) === null || _b === void 0 ? void 0 : _b.call(_a, event, handler); } off(event, handler) { var _a, _b; if (typeof window === 'undefined') return; (_b = (_a = window.ribbit) === null || _a === void 0 ? void 0 : _a.off) === null || _b === void 0 ? void 0 : _b.call(_a, event, handler); } } exports.AppTransport = AppTransport;