fix: buffer typescript error in util.ts when parsing ArrayBuffer
This commit is contained in:
@@ -12,8 +12,6 @@ import { deriveAddress, generateSeed, newIdentifier } from "@/libs/crypto";
|
||||
import { GenericServerRecord, containsHiddenDid } from "@/libs/endorserServer";
|
||||
import * as serverUtil from "@/libs/endorserServer";
|
||||
|
||||
import { Buffer } from "buffer/";
|
||||
|
||||
// If you edit this, check that the numbers still line up on the side in the alert (on mobile, too),
|
||||
// and make sure they can take all actions while the notification shows.
|
||||
export const ONBOARD_MESSAGE =
|
||||
@@ -237,6 +235,19 @@ export const generateSaveAndActivateIdentity = async (): Promise<string> => {
|
||||
return newId.did;
|
||||
};
|
||||
|
||||
function getBase64(subscription: PushSubscription, key: PushEncryptionKeyName) {
|
||||
const buffer = subscription.getKey(key);
|
||||
if (!buffer) {
|
||||
return null;
|
||||
}
|
||||
const value = Buffer.from(buffer);
|
||||
return value
|
||||
.toString("base64")
|
||||
.replace(/\+/g, "-")
|
||||
.replace(/\//g, "_")
|
||||
.replace(/=+$/, "");
|
||||
}
|
||||
|
||||
export const sendTestThroughPushServer = async (
|
||||
subscription: PushSubscription,
|
||||
skipFilter: boolean,
|
||||
@@ -253,18 +264,8 @@ export const sendTestThroughPushServer = async (
|
||||
// Use something other than "Daily Update" https://gitea.anomalistdesign.com/trent_larson/py-push-server/src/commit/3c0e196c11bc98060ec5934e99e7dbd591b5da4d/app.py#L213
|
||||
const DIRECT_PUSH_TITLE = "DIRECT_NOTIFICATION";
|
||||
|
||||
const auth = Buffer.from(subscription.getKey("auth"));
|
||||
const authB64 = auth
|
||||
.toString("base64")
|
||||
.replace(/\+/g, "-")
|
||||
.replace(/\//g, "_")
|
||||
.replace(/=+$/, "");
|
||||
const p256dh = Buffer.from(subscription.getKey("p256dh"));
|
||||
const p256dhB64 = p256dh
|
||||
.toString("base64")
|
||||
.replace(/\+/g, "-")
|
||||
.replace(/\//g, "_")
|
||||
.replace(/=+$/, "");
|
||||
const authB64 = getBase64(subscription, "auth");
|
||||
const p256dhB64 = getBase64(subscription, "p256dh");
|
||||
const newPayload = {
|
||||
endpoint: subscription.endpoint,
|
||||
keys: {
|
||||
|
||||
Reference in New Issue
Block a user