@ -12,8 +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" ;
import { Buffer } from "buffer/" ;
// If you edit this, check that the numbers still line up on the side in the alert (on mobile, too),
// 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.
// and make sure they can take all actions while the notification shows.
export const ONBOARD_MESSAGE =
export const ONBOARD_MESSAGE =
@ -237,6 +235,19 @@ export const generateSaveAndActivateIdentity = async (): Promise<string> => {
return newId . did ;
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 (
export const sendTestThroughPushServer = async (
subscription : PushSubscription ,
subscription : PushSubscription ,
skipFilter : boolean ,
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
// 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" ;
const auth = Buffer . from ( subscription . getKey ( "auth" ) ) ;
const authB64 = getBase64 ( subscription , "auth" ) ;
const authB64 = auth
const p256dhB64 = getBase64 ( subscription , "p256dh" ) ;
. 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 = {
const newPayload = {
endpoint : subscription.endpoint ,
endpoint : subscription.endpoint ,
keys : {
keys : {