@@ -65,7 +65,7 @@ async function handle(r, env, ctx) {
6565 if ( ( await admit ( env , r ) ) === false ) {
6666 return r429 ( `wsf: ${ ray } rate limited` ) ;
6767 }
68- return forwardToWs ( env , r ) ;
68+ return await forwardToWs ( env , r ) ;
6969 }
7070
7171 if ( path == null || path . length === 0 ) return r302 ( home ) ;
@@ -97,14 +97,14 @@ async function handle(r, env, ctx) {
9797 // d; device registration
9898 // d/?did=hex&cid=hex[&test]
9999 // metadata as json in the body
100- return registerDevice ( env , r ) ;
100+ return await registerDevice ( env , r ) ;
101101 } else if ( p [ 1 ] === urlstripe ) {
102102 // s; stripe webhook
103103 const whsec = env . STRIPE_WEBHOOK_SECRET ;
104104 const apikey = env . STRIPE_API_KEY ;
105105 const db = env . DB ;
106106 // opt: p[2] === "checkout"
107- return stripeCheckout ( r , db , apikey , whsec ) ;
107+ return await stripeCheckout ( r , db , apikey , whsec ) ;
108108 } else if ( p [ 1 ] === urlgplay ) {
109109 // g; play store subs rtdn at g/rtdn
110110 const p2 = p [ 2 ] ? p [ 2 ] . toLowerCase ( ) : "" ;
@@ -113,7 +113,7 @@ async function handle(r, env, ctx) {
113113 }
114114
115115 if ( p2 === "rtdn" ) {
116- return googlePlayNotification ( env , r ) ;
116+ return await googlePlayNotification ( env , r ) ;
117117 }
118118
119119 const vcode = url . searchParams . get ( "vcode" ) ;
@@ -133,30 +133,30 @@ async function handle(r, env, ctx) {
133133 // g/ack/[vcode]?cid&purchaseToken&vcode[&force&sku&test]
134134 if ( r . method !== "POST" )
135135 return r405 ( `g/ack: ${ ray } method not allowed` ) ;
136- return googlePlayAcknowledgePurchase ( env , r ) ;
136+ return await googlePlayAcknowledgePurchase ( env , r ) ;
137137 } else if ( p2 === "con" ) {
138138 // g/con/[vcode]?cid&purchaseToken&vcode[&sku&test]
139139 if ( r . method !== "POST" )
140140 return r405 ( `g/con: ${ ray } method not allowed` ) ;
141- return googlePlayConsumePurchase ( env , r ) ;
141+ return await googlePlayConsumePurchase ( env , r ) ;
142142 } else if ( p2 === "ent" ) {
143143 // TODO: mere possession of cid is auth, right now
144144 // will get entitlement for onetime purchase too, if &sku=onetime.tier
145145 // g/entitlements/[vcode]?cid&vcode&test[&sku]
146146 if ( r . method !== "GET" ) return r405 ( `g/ent: ${ ray } method not allowed` ) ;
147- return googlePlayGetEntitlements ( env , r ) ;
147+ return await googlePlayGetEntitlements ( env , r ) ;
148148 } else if ( p2 === "stop" ) {
149149 // will refund and revoke onetime purchase, if &sku=onetime.tier
150150 // g/stop/[vcode]?cid&purchaseToken&vcode[&sku&test]
151151 if ( r . method !== "POST" )
152152 return r405 ( `g/stop: ${ ray } method not allowed` ) ;
153- return cancelSubscription ( env , r ) ;
153+ return await cancelSubscription ( env , r ) ;
154154 } else if ( p2 === "refund" ) {
155155 // will refund and revoke onetime purchase, if &sku=onetime.tier
156156 // g/refund/[vcode]?cid&purchaseToken&vcode[&sku&test]
157157 if ( r . method !== "POST" )
158158 return r405 ( `g/refund: ${ ray } method not allowed` ) ;
159- return revokeSubscription ( env , r ) ;
159+ return await revokeSubscription ( env , r ) ;
160160 }
161161 return r400 ( `g: ${ ray } unknown resource ${ p2 } ` ) ;
162162 } else if ( p [ 1 ] === urlmoney1 ) {
@@ -165,13 +165,13 @@ async function handle(r, env, ctx) {
165165 const db = env . DB ;
166166 const pubkeys = rsapubmodulus ( env ) ;
167167 // blindMsg
168- return finalizeOrder ( r , psk , pubkeys , db ) ;
168+ return await finalizeOrder ( r , psk , pubkeys , db ) ;
169169 } else if ( p [ 1 ] === urlmoney2 ) {
170170 // mt; token
171171 const psk = env . PRE_SHARED_KEY_SVC ;
172172 const db = env . DB ;
173173 // msg:rsaSig:sha256(rsaSig):hashedtoken(rand)
174- return generateToken ( r , psk , db ) ;
174+ return await generateToken ( r , psk , db ) ;
175175 } else if ( p [ 1 ] === urlsproxy ) {
176176 // p; proxy metadata
177177 const clientVCode = p [ 2 ] ;
@@ -202,6 +202,7 @@ async function handle(r, env, ctx) {
202202 }
203203 }
204204 const svcs = svcstatus ( env ) ;
205+ // TODO: move json to class
205206 return r200j ( {
206207 vcode : clientVCode ,
207208 minvcode : minVCodeNeeded ,
@@ -591,8 +592,8 @@ function mustWsFwd(url) {
591592}
592593
593594/**
594- * @param {any } env
595- * @param {Request } r
595+ * @param {any } env - Worker environment
596+ * @param {Request } r - The incoming request
596597 * @returns {Promise<boolean> } - True if the request is allowed, false otherwise
597598 */
598599async function admit2 ( env , r ) {
0 commit comments