(input: {
recipients: Record<string, { publicKeyring: Uint8Array }>;
patientId?: string;
notifications: {
agent?: object;
target?: object;
observers?: object;
};
})
| 81 | } |
| 82 | |
| 83 | export async function createNotifications(input: { |
| 84 | recipients: Record<string, { publicKeyring: Uint8Array }>; |
| 85 | |
| 86 | patientId?: string; |
| 87 | |
| 88 | notifications: { |
| 89 | agent?: object; |
| 90 | target?: object; |
| 91 | observers?: object; |
| 92 | }; |
| 93 | }): Promise< |
| 94 | { |
| 95 | recipients: Record<string, { encryptedSymmetricKey: Uint8Array }>; |
| 96 | encryptedContent: Uint8Array; |
| 97 | }[] |
| 98 | > { |
| 99 | const agentId = authStore().userId; |
| 100 | |
| 101 | const agentSymmetricKey = wrapSymmetricKey(); |
| 102 | const targetSymmetricKey = wrapSymmetricKey(); |
| 103 | const observersSymmetricKey = wrapSymmetricKey(); |
| 104 | |
| 105 | return [ |
| 106 | // Agent |
| 107 | |
| 108 | ...(input.notifications.agent != null |
| 109 | ? [ |
| 110 | { |
| 111 | recipients: { |
| 112 | [agentId]: { |
| 113 | encryptedSymmetricKey: internals.keyPair.encrypt( |
| 114 | agentSymmetricKey.value, |
| 115 | internals.keyPair.publicKey, |
| 116 | ), |
| 117 | }, |
| 118 | }, |
| 119 | |
| 120 | encryptedContent: agentSymmetricKey.encrypt( |
| 121 | pack({ |
| 122 | ...input.notifications.agent, |
| 123 | |
| 124 | recipientType: 'agent', |
| 125 | }), |
| 126 | { |
| 127 | padding: true, |
| 128 | associatedData: { context: 'UserNotificationContent' }, |
| 129 | }, |
| 130 | ), |
| 131 | }, |
| 132 | ] |
| 133 | : []), |
| 134 | |
| 135 | // Target |
| 136 | |
| 137 | ...(input.notifications.target != null && |
| 138 | input.patientId != null && |
| 139 | input.recipients[input.patientId] != null |
| 140 | ? [ |
no test coverage detected