@ -12,9 +12,6 @@ import { deriveAddress, generateSeed, newIdentifier } from "@/libs/crypto";
import { GenericServerRecord , containsHiddenDid } from "@/libs/endorserServer" ;
import { GenericServerRecord , containsHiddenDid } from "@/libs/endorserServer" ;
import * as serverUtil from "@/libs/endorserServer" ;
import * as serverUtil from "@/libs/endorserServer" ;
// eslint-disable-next-line @typescript-eslint/no-var-requires
//const Buffer = require("buffer/").Buffer;
export const PRIVACY_MESSAGE =
export const PRIVACY_MESSAGE =
"The data you send be visible to the world -- except: your IDs and the IDs of anyone you tag will stay private, only visible to those you allow." ;
"The data you send be visible to the world -- except: your IDs and the IDs of anyone you tag will stay private, only visible to those you allow." ;
@ -241,7 +238,7 @@ export const generateSaveAndActivateIdentity = async (): Promise<string> => {
} ;
} ;
export const sendTestThroughPushServer = async (
export const sendTestThroughPushServer = async (
subscription : PushSubscriptionJSON ,
subscriptionJSON : PushSubscriptionJSON ,
skipFilter : boolean ,
skipFilter : boolean ,
) : Promise < AxiosResponse > = > {
) : Promise < AxiosResponse > = > {
await db . open ( ) ;
await db . open ( ) ;
@ -256,38 +253,11 @@ 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
// 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 DIRECT_PUSH_TITLE = "DIRECT_NOTIFICATION" ;
/ * * r e m o v e i f t h e P u s h S u b s c r i p t i o n J S O N a p p r o a c h w o r k s
*
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 newPayload = {
endpoint : subscription.endpoint ,
keys : {
auth : authB64 ,
p256dh : p256dhB64 ,
} ,
message : ` Test, where you will see this message ${
skipFilter ? "un" : ""
} filtered . ` ,
title : skipFilter ? DIRECT_PUSH_TITLE : "Your Web Push" ,
} ;
*
* * /
const newPayload = {
const newPayload = {
// eslint-disable-next-line prettier/prettier
// eslint-disable-next-line prettier/prettier
message : ` Test, where you will see this message ${ skipFilter ? "un" : "" } filtered. ` ,
message : ` Test, where you will see this message ${ skipFilter ? "un" : "" } filtered. ` ,
title : skipFilter ? DIRECT_PUSH_TITLE : "Your Web Push" ,
title : skipFilter ? DIRECT_PUSH_TITLE : "Your Web Push" ,
. . . subscription ,
. . . subscriptionJSON ,
} ;
} ;
console . log ( "Sending a test web push message:" , newPayload ) ;
console . log ( "Sending a test web push message:" , newPayload ) ;
const payloadStr = JSON . stringify ( newPayload ) ;
const payloadStr = JSON . stringify ( newPayload ) ;