"use strict";Object.defineProperty(exports,"__esModule",{value:!0});function e(s,i,r="string"){if(!s[i]||typeof s[i]!==r)throw new Error(`Missing or invalid "${i}" param`)}function l(s,i){let r=!0;return i.forEach(u=>{u in s||(r=!1)}),r}function R(s,i){return Array.isArray(s)?s.length===i:Object.keys(s).length===i}function P(s,i){return Array.isArray(s)?s.length>=i:Object.keys(s).length>=i}function t(s,i,r){return(r.length?P(s,i.length):R(s,i.length))?l(s,i):!1}function b(s,i,r="_"){const u=s.split(r);return u[u.length-1].trim().toLowerCase()===i.trim().toLowerCase()}function f(s){return n(s.method)&&a(s.params)}function n(s){return b(s,"subscribe")}function a(s){return t(s,["topic"],[])}function S(s){return c(s.method)&&h(s.params)}function c(s){return b(s,"publish")}function h(s){return t(s,["message","topic","ttl"],["prompt","tag"])}function w(s){return o(s.method)&&p(s.params)}function o(s){return b(s,"unsubscribe")}function p(s){return t(s,["id","topic"],[])}function _(s){return m(s.method)&&d(s.params)}function m(s){return b(s,"subscription")}function d(s){return t(s,["id","data"],[])}function q(s){if(!n(s.method))throw new Error("JSON-RPC Request has invalid subscribe method");if(!a(s.params))throw new Error("JSON-RPC Request has invalid subscribe params");const i=s.params;return e(i,"topic"),i}function g(s){if(!c(s.method))throw new Error("JSON-RPC Request has invalid publish method");if(!h(s.params))throw new Error("JSON-RPC Request has invalid publish params");const i=s.params;return e(i,"topic"),e(i,"message"),e(i,"ttl","number"),i}function M(s){if(!o(s.method))throw new Error("JSON-RPC Request has invalid unsubscribe method");if(!p(s.params))throw new Error("JSON-RPC Request has invalid unsubscribe params");const i=s.params;return e(i,"id"),i}function E(s){if(!m(s.method))throw new Error("JSON-RPC Request has invalid subscription method");if(!d(s.params))throw new Error("JSON-RPC Request has invalid subscription params");const i=s.params;return e(i,"id"),e(i,"data"),i}const U={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};exports.RELAY_JSONRPC=U,exports.isPublishMethod=c,exports.isPublishParams=h,exports.isPublishRequest=S,exports.isSubscribeMethod=n,exports.isSubscribeParams=a,exports.isSubscribeRequest=f,exports.isSubscriptionMethod=m,exports.isSubscriptionParams=d,exports.isSubscriptionRequest=_,exports.isUnsubscribeMethod=o,exports.isUnsubscribeParams=p,exports.isUnsubscribeRequest=w,exports.parsePublishRequest=g,exports.parseSubscribeRequest=q,exports.parseSubscriptionRequest=E,exports.parseUnsubscribeRequest=M;
//# sourceMappingURL=index.cjs.js.map
