web-push-browser
Advanced tools
Comparing version
@@ -8,3 +8,3 @@ type BaseOptions = { | ||
salt: ArrayBuffer; | ||
localPublicKey: CryptoKey; | ||
appServerPubKey: CryptoKey; | ||
}; | ||
@@ -11,0 +11,0 @@ type AES128GCMOptions = BaseOptions & { |
@@ -21,3 +21,3 @@ import { toBase64Url } from "../utils/base64url.js"; | ||
if (options.algorithm === "aesgcm") { | ||
const exportedLocalPubKey = await crypto.subtle.exportKey("raw", options.localPublicKey); | ||
const exportedLocalPubKey = await crypto.subtle.exportKey("raw", options.appServerPubKey); | ||
const encodedLocalPubKey = toBase64Url(exportedLocalPubKey); | ||
@@ -24,0 +24,0 @@ headers.append("Authorization", `Bearer ${jwt}`); |
@@ -6,2 +6,3 @@ import type { PushNotificationSubscription } from "../types.js"; | ||
ttl?: number; | ||
salt?: ArrayBuffer; | ||
}; | ||
@@ -8,0 +9,0 @@ /** |
import { createJWT } from "../crypto/jwt.js"; | ||
import { encryptPayload } from "../crypto/payload.js"; | ||
import { encryptPayload } from "../crypto/encrypt.js"; | ||
import { generateHeaders } from "./generate.js"; | ||
@@ -16,6 +16,6 @@ /** | ||
const jwt = await createJWT(vapidKeys.privateKey, new URL(subscription.endpoint), email); | ||
const { encrypted, salt, localPublicKey } = await encryptPayload(payload, subscription.keys); | ||
const { encrypted, salt, appServerPublicKey } = await encryptPayload(payload, subscription.keys, options); | ||
const headers = await generateHeaders(vapidKeys.publicKey, jwt, encrypted, { | ||
...options, | ||
localPublicKey, | ||
appServerPubKey: appServerPublicKey, | ||
salt, | ||
@@ -22,0 +22,0 @@ }); |
{ | ||
"name": "web-push-browser", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"description": "Minimal library for sending notifications via the browser Push API", | ||
"main": "build/index.js", | ||
"devDependencies": { | ||
"@types/jest": "^29.5.13", | ||
"jest": "^29.7.0", | ||
"ts-jest": "^29.2.5", | ||
"ts-jest-resolver": "^2.0.1", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.5.4" | ||
}, | ||
"scripts": { | ||
"build": "tsc" | ||
"build": "tsc", | ||
"test": "jest ./test" | ||
}, | ||
@@ -12,0 +18,0 @@ "author": "Cole Crouter", |
@@ -84,2 +84,5 @@ # web-push-browser | ||
This package only supports the basic functionality. If you need more advanced features, such as proxies, custom headers, etc. you can access the internal functions to create your own requests. | ||
This package only supports the basic functionality. If you need more advanced features, such as proxies, custom headers, etc. you can access the internal functions to create your own requests. | ||
> [!NOTE] | ||
> `aesgcm` is not completely implemented in this package. Please use `aes128gcm` instead. |
23384
26.07%21
16.67%489
32.52%87
3.57%6
500%