import { TypedMessage , makeTypedMessageText , isTypedMessageText , type , AESJsonWebKey } from '@masknet/shared-base' ; export * from './crypto-alpha-39' ; export const publicSharedAESKey = { alg : 'A256GCM' , ext : true , k : '3Bf8BJ3ZPSMUM2jg2ThODeLuRRD_-_iwQEaeLdcQXpg' , key_ops : [ 'encrypt' , 'decrypt' ] , kty : 'oct' , } ; /**
 * With plugin: {"payload": "data"}🧩My message
 * Without plugin: My message
 */ export function typedMessageStringify ( x ) { if ( ! isTypedMessageText ( x ) ) throw new Error ( 'Not supported typed message.' ) ; if ( ! x . meta || x . meta . size === 0 ) return x . content ; const obj = { } ; for ( const [ a , b ] of x . meta ) obj [ a ] = b ; return JSON . stringify ( obj ) + '\u{1F9E9}' + x . content ; } export function typedMessageParse ( x ) { const [ maybeMetadata , ... end ] = x . split ( '\u{1F9E9}' ) ; try { const json = JSON . parse ( maybeMetadata ) ; if ( typeof json !== 'object' || json === null || Object . keys ( json ) . length === 0 ) throw new Error ( 'Not a metadata' ) ; return makeTypedMessageText ( end . join ( '\u{1F9E9}' ) , new Map ( Object . entries ( json ) ) ) ; } catch { } return makeTypedMessageText ( x ) ; }