File tree Expand file tree Collapse file tree 3 files changed +12
-8
lines changed
Expand file tree Collapse file tree 3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 11import doRequest from './do-request' ;
2+ import { version as sdkVersion } from '../package.json' ;
23
34const INTERESTS_REGEX = new RegExp ( '^(_|\\-|=|@|,|\\.|;|[A-Z]|[a-z]|[0-9])*$' ) ;
45const MAX_INTEREST_LENGTH = 164 ;
@@ -14,7 +15,7 @@ export const RegistrationState = Object.freeze({
1415} ) ;
1516
1617export default class BaseClient {
17- constructor ( config ) { }
18+ constructor ( _ ) { }
1819
1920 async getDeviceId ( ) {
2021 await this . _resolveSDKState ( ) ;
@@ -195,7 +196,6 @@ export default class BaseClient {
195196 const response = await doRequest ( options ) ;
196197 return response . id ;
197198 }
198-
199199}
200200
201201function validateInterestName ( interest ) {
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ export class SafariClient extends BaseClient {
7979 }
8080
8181 _requestPermission ( ) {
82- return new Promise ( ( resolve ) => {
82+ return new Promise ( resolve => {
8383 window . safari . pushNotification . requestPermission (
8484 __url ,
8585 __pushId ,
@@ -94,7 +94,7 @@ export class SafariClient extends BaseClient {
9494 return this ;
9595 }
9696
97- let { deviceToken , permission } = getPermission ( __pushId ) ;
97+ let { permission } = getPermission ( __pushId ) ;
9898
9999 if ( permission === 'default' ) {
100100 console . debug ( 'permission is default, requesting permission' ) ;
@@ -209,6 +209,10 @@ export class SafariClient extends BaseClient {
209209 }
210210}
211211
212+ function isSupportedBrowser ( ) {
213+ return isSupportedVersion ( ) ;
214+ }
215+
212216function isSupportedVersion ( ) {
213217 return 'safari' in window && 'pushNotification' in window . safari ;
214218}
Original file line number Diff line number Diff line change @@ -261,8 +261,8 @@ export class WebPushClient extends BaseClient {
261261
262262 async _clearPushToken ( ) {
263263 return navigator . serviceWorker . ready
264- . then ( ( reg ) => reg . pushManager . getSubscription ( ) )
265- . then ( ( sub ) => {
264+ . then ( reg => reg . pushManager . getSubscription ( ) )
265+ . then ( sub => {
266266 if ( sub ) sub . unsubscribe ( ) ;
267267 } ) ;
268268 }
@@ -289,7 +289,7 @@ async function getServiceWorkerRegistration() {
289289function getWebPushToken ( swReg ) {
290290 return swReg . pushManager
291291 . getSubscription ( )
292- . then ( ( sub ) => ( ! sub ? null : encodeSubscription ( sub ) ) ) ;
292+ . then ( sub => ( ! sub ? null : encodeSubscription ( sub ) ) ) ;
293293}
294294
295295function encodeSubscription ( sub ) {
@@ -300,7 +300,7 @@ function urlBase64ToUInt8Array(base64String) {
300300 const padding = '=' . repeat ( ( 4 - ( base64String . length % 4 ) ) % 4 ) ;
301301 const base64 = ( base64String + padding ) . replace ( / - / g, '+' ) . replace ( / _ / g, '/' ) ;
302302 const rawData = window . atob ( base64 ) ;
303- return Uint8Array . from ( [ ...rawData ] . map ( ( char ) => char . charCodeAt ( 0 ) ) ) ;
303+ return Uint8Array . from ( [ ...rawData ] . map ( char => char . charCodeAt ( 0 ) ) ) ;
304304}
305305
306306/**
You can’t perform that action at this time.
0 commit comments