* @param {string} encryptedDocumentKey * @return {?string}
(encryptedDocumentKey)
| 1566 | * @return {?string} |
| 1567 | */ |
| 1568 | function decryptDocumentKey(encryptedDocumentKey) { |
| 1569 | if (!encryptedDocumentKey) { |
| 1570 | return null; |
| 1571 | } |
| 1572 | const cryptoStart = 'ENCRYPT('; |
| 1573 | if (!encryptedDocumentKey.includes(cryptoStart, 0)) { |
| 1574 | return null; |
| 1575 | } |
| 1576 | let jsonString = encryptedDocumentKey.replace(cryptoStart, ''); |
| 1577 | jsonString = jsonString.substring(0, jsonString.length - 1); |
| 1578 | const parsedJson = JSON.parse(jsonString); |
| 1579 | if (!parsedJson) { |
| 1580 | return null; |
| 1581 | } |
| 1582 | return parsedJson.key; |
| 1583 | } |
| 1584 | |
| 1585 | // serve local vendor config JSON files |
| 1586 | app.use( |