(subscription: WebPushInfos)
| 23 | } |
| 24 | |
| 25 | async function getSubKeyAsCryptoKey(subscription: WebPushInfos): Promise<CryptoKey> { |
| 26 | const key = urlsafeBase64Decode(subscription.key) |
| 27 | const publicKey = await crypto.subtle.importKey( |
| 28 | 'jwk', |
| 29 | { |
| 30 | kty: 'EC', |
| 31 | crv: 'P-256', |
| 32 | x: b64ToUrlEncoded(btoa(key.slice(1, 33))), |
| 33 | y: b64ToUrlEncoded(btoa(key.slice(33, 65))), |
| 34 | ext: true, |
| 35 | }, |
| 36 | { |
| 37 | name: 'ECDH', |
| 38 | namedCurve: 'P-256', |
| 39 | }, |
| 40 | true, |
| 41 | [] |
| 42 | ) |
| 43 | return publicKey |
| 44 | } |
| 45 | |
| 46 | async function getSharedSecret(subscription: WebPushInfos, serverKeys: mKeyPair): Promise<ArrayBuffer> { |
| 47 | const publicKey = await getSubKeyAsCryptoKey(subscription) |
no test coverage detected