diff --git a/src/EventAPI.res b/src/EventAPI.res index b076328..ad7fba8 100644 --- a/src/EventAPI.res +++ b/src/EventAPI.res @@ -226,5 +226,5 @@ The ExtendableEvent interface extends the lifetime of the install and activate e */ @editor.completeFrom(ExtendableEvent) type extendableEvent = { - ...event -} \ No newline at end of file + ...event, +} diff --git a/src/NotificationAPI.res b/src/NotificationAPI.res index 78e446d..b780f59 100644 --- a/src/NotificationAPI.res +++ b/src/NotificationAPI.res @@ -73,7 +73,7 @@ type notification = { type notificationAction = { action: string, title: string, - icon?: string + icon?: string, } type notificationOptions = { @@ -86,7 +86,7 @@ type notificationOptions = { mutable silent?: Null.t, mutable requireInteraction?: bool, mutable data?: JSON.t, - mutable actions?: array + mutable actions?: array, } type getNotificationOptions = {mutable tag?: string} diff --git a/src/PushAPI.res b/src/PushAPI.res index 76b1140..a79edbe 100644 --- a/src/PushAPI.res +++ b/src/PushAPI.res @@ -65,10 +65,17 @@ type pushSubscriptionOptionsInit = { mutable applicationServerKey?: applicationServerKey, } +type pushSubscriptionJSONKeys = { + /** Base64URL-encoded ArrayBuffer value */ + p256dh: string, + /** Base64URL-encoded ArrayBuffer value */ + auth: string, +} + type pushSubscriptionJSON = { mutable endpoint?: string, mutable expirationTime?: Null.t, - mutable keys?: any, + mutable keys?: pushSubscriptionJSONKeys, } @editor.completeFrom(PushMessageData) @@ -81,4 +88,4 @@ type pushEvent = { [Read more on MDN](https://developer.mozilla.org/docs/Web/API/PushEvent/data) */ data?: pushMessageData, -} \ No newline at end of file +} diff --git a/src/PushAPI/PushEvent.res b/src/PushAPI/PushEvent.res index f87f648..df6cd76 100644 --- a/src/PushAPI/PushEvent.res +++ b/src/PushAPI/PushEvent.res @@ -1,5 +1,5 @@ open PushAPI include ExtendableEvent.Impl({ - type t = pushEvent; -}); \ No newline at end of file + type t = pushEvent +}) diff --git a/src/PushAPI/PushMessageData.res b/src/PushAPI/PushMessageData.res index acb6ec1..230f92b 100644 --- a/src/PushAPI/PushMessageData.res +++ b/src/PushAPI/PushMessageData.res @@ -12,4 +12,4 @@ The text() method of the PushMessageData interface extracts push message data as [Read more on MDN](https://developer.mozilla.org/docs/Web/API/PushMessageData/text) */ @send -external text: pushMessageData => string = "text" \ No newline at end of file +external text: pushMessageData => string = "text" diff --git a/src/ServiceWorkerAPI.res b/src/ServiceWorkerAPI.res index 3826412..af1e5a8 100644 --- a/src/ServiceWorkerAPI.res +++ b/src/ServiceWorkerAPI.res @@ -155,4 +155,4 @@ The WindowClient interface of the ServiceWorker API represents the scope of a se */ type windowClient = { ...client, -} \ No newline at end of file +} diff --git a/src/ServiceWorkerAPI/ServiceWorkerGlobalScope.res b/src/ServiceWorkerAPI/ServiceWorkerGlobalScope.res index 07e7695..cb454a5 100644 --- a/src/ServiceWorkerAPI/ServiceWorkerGlobalScope.res +++ b/src/ServiceWorkerAPI/ServiceWorkerGlobalScope.res @@ -2,4 +2,4 @@ open ServiceWorkerAPI include WorkerGlobalScope.Impl({ type t = serviceWorkerGlobalScope -}) \ No newline at end of file +}) diff --git a/src/WebWorkersAPI/WorkerGlobalScope.res b/src/WebWorkersAPI/WorkerGlobalScope.res index dcf170d..fc76c75 100644 --- a/src/WebWorkersAPI/WorkerGlobalScope.res +++ b/src/WebWorkersAPI/WorkerGlobalScope.res @@ -22,7 +22,7 @@ let response = await self->WorkerGlobalScope.fetch("https://rescript-lang.org") [Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/fetch) */ -@send + @send external fetch: (T.t, string, ~init: requestInit=?) => promise = "fetch" /** diff --git a/tests/Global__test.js b/tests/Global__test.js index 35e6a4e..810a85f 100644 --- a/tests/Global__test.js +++ b/tests/Global__test.js @@ -32,11 +32,32 @@ let subscription = await registrationResult.pushManager.subscribe({ applicationServerKey: "MyPublicKey" }); +let pushSubscriptionJSON = subscription.toJSON(); + +let keys = pushSubscriptionJSON.keys; + +let match = keys !== undefined ? [ + keys.auth, + keys.p256dh + ] : [ + "?", + "?" + ]; + +let p256dh = match[1]; + +let auth = match[0]; + +console.log("For subscription " + subscription.endpoint + ", auth is " + auth + " and p256dh is " + p256dh); + export { response, response2, response3, registrationResult, subscription, + pushSubscriptionJSON, + auth, + p256dh, } /* response Not a pure module */ diff --git a/tests/Global__test.res b/tests/Global__test.res index eac151f..2f76d0e 100644 --- a/tests/Global__test.res +++ b/tests/Global__test.res @@ -37,3 +37,10 @@ let subscription = await registrationResult.pushManager->PushManager.subscribe( applicationServerKey: ApplicationServerKey.fromString("MyPublicKey"), }, ) + +let pushSubscriptionJSON = subscription->PushSubscription.toJSON +let (auth, p256dh) = switch pushSubscriptionJSON.keys { +| None => ("?", "?") +| Some(keys) => (keys.auth, keys.p256dh) +} +Console.log(`For subscription ${subscription.endpoint}, auth is ${auth} and p256dh is ${p256dh}`)