( groupId: string, password: string, )
| 208 | } |
| 209 | |
| 210 | export async function unlockGroupContentKeyring( |
| 211 | groupId: string, |
| 212 | password: string, |
| 213 | ) { |
| 214 | const groupPasswordValues = await computeGroupPasswordValues( |
| 215 | groupId, |
| 216 | password, |
| 217 | ); |
| 218 | |
| 219 | let groupContentKeyring = await groupContentKeyrings()(groupId).getAsync(); |
| 220 | |
| 221 | if (groupContentKeyring == null) { |
| 222 | throw new Error('Group content keyring was not found.'); |
| 223 | } |
| 224 | |
| 225 | if (groupContentKeyring.topLayer === DataLayer.Symmetric) { |
| 226 | try { |
| 227 | groupContentKeyring = groupContentKeyring.unwrapSymmetric( |
| 228 | groupPasswordValues.passwordKey, |
| 229 | { |
| 230 | associatedData: { |
| 231 | context: 'GroupContentKeyringPasswordProtection', |
| 232 | groupId, |
| 233 | }, |
| 234 | }, |
| 235 | ); |
| 236 | } catch (error) { |
| 237 | throw new Error('Password is incorrect.'); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | pagesStore().dict[`${GROUP_CONTENT_KEYRING}:${groupId}`] = |
| 242 | groupContentKeyring; |
| 243 | |
| 244 | return groupContentKeyring; |
| 245 | } |
no test coverage detected