test(service-worker): allow SwPush
tests to run on Node.js (#24162)
PR Close #24162
This commit is contained in:

committed by
Miško Hevery

parent
86bf5f3912
commit
4d55dfd9d9
@ -13,7 +13,6 @@ import {map, switchMap, take} from 'rxjs/operators';
|
||||
import {ERR_SW_NOT_SUPPORTED, NgswCommChannel} from './low_level';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Subscribe and listen to push notifications from the Service Worker.
|
||||
*
|
||||
@ -55,7 +54,7 @@ export class SwPush {
|
||||
return Promise.reject(new Error(ERR_SW_NOT_SUPPORTED));
|
||||
}
|
||||
const pushOptions: PushSubscriptionOptionsInit = {userVisibleOnly: true};
|
||||
let key = atob(options.serverPublicKey.replace(/_/g, '/').replace(/-/g, '+'));
|
||||
let key = this.decodeBase64(options.serverPublicKey.replace(/_/g, '/').replace(/-/g, '+'));
|
||||
let applicationServerKey = new Uint8Array(new ArrayBuffer(key.length));
|
||||
for (let i = 0; i < key.length; i++) {
|
||||
applicationServerKey[i] = key.charCodeAt(i);
|
||||
@ -90,4 +89,6 @@ export class SwPush {
|
||||
}));
|
||||
return unsubscribe.pipe(take(1)).toPromise();
|
||||
}
|
||||
|
||||
private decodeBase64(input: string): string { return atob(input); }
|
||||
}
|
||||
|
Reference in New Issue
Block a user