MCPcopy Create free account
hub / github.com/ampproject/amphtml / decryptDocumentKey

Function decryptDocumentKey

build-system/server/app.js:1568–1583  ·  view source on GitHub ↗

* @param {string} encryptedDocumentKey * @return {?string}

(encryptedDocumentKey)

Source from the content-addressed store, hash-verified

1566 * @return {?string}
1567 */
1568function 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
1586app.use(

Callers 1

app.jsFile · 0.85

Calls 2

replaceMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected