/
Nspection
/
rules-manager-mcp
Обзор
Документация
Войти
/
Nspection
/
rules-manager-mcp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
node_modules/jose/dist/webapi/jwt/decrypt.js
23 строки
1 KB
Buglov Evgeny
Первый коммит
27 фев 2026, 21:12
27 фев 2026, 21:12
e51dee3
Код
Авторство
О чём код?
import { compactDecrypt } from '../jwe/compact/decrypt.js'; import { validateClaimsSet } from '../lib/jwt_claims_set.js'; import { JWTClaimValidationFailed } from '../util/errors.js'; export async function jwtDecrypt(jwt, key, options) { const decrypted = await compactDecrypt(jwt, key, options); const payload = validateClaimsSet(decrypted.protectedHeader, decrypted.plaintext, options); const { protectedHeader } = decrypted; if (protectedHeader.iss !== undefined && protectedHeader.iss !== payload.iss) { throw new JWTClaimValidationFailed('replicated "iss" claim header parameter mismatch', payload, 'iss', 'mismatch'); } if (protectedHeader.sub !== undefined && protectedHeader.sub !== payload.sub) { throw new JWTClaimValidationFailed('replicated "sub" claim header parameter mismatch', payload, 'sub', 'mismatch'); } if (protectedHeader.aud !== undefined && JSON.stringify(protectedHeader.aud) !== JSON.stringify(payload.aud)) { throw new JWTClaimValidationFailed('replicated "aud" claim header parameter mismatch', payload, 'aud', 'mismatch'); } const result = { payload, protectedHeader }; if (typeof key === 'function') { return { ...result, key: decrypted.key }; } return result; }