MCPcopy Index your code
hub / github.com/nodejs/node / parseJwk

Function parseJwk

lib/internal/crypto/webcrypto.js:802–826  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

800
801// Parse wrapped JWK bytes according to WebCrypto's "parse a JWK" procedure.
802function parseJwk(data) {
803 let key;
804 try {
805 // WebCrypto parses JWKs in a fresh global. Detach parsed JSON values
806 // from user-mutated prototypes before WebIDL dictionary conversion.
807 // Wrapped JWKs may be produced outside WebCrypto, so parse using the
808 // spec-required UTF-8.
809 const json = decodeUTF8(data, false, true);
810 const result = JSONParse(json);
811 detachFromUserPrototypes(result);
812 key = webidl.converters.JsonWebKey(result);
813 } catch (err) {
814 throw lazyDOMException(
815 'Invalid wrapped JWK key',
816 { name: 'DataError', cause: err });
817 }
818
819 if (key.kty === undefined) {
820 throw lazyDOMException(
821 'Invalid wrapped JWK key',
822 'DataError');
823 }
824
825 return key;
826}
827
828function aliasKeyFormat(format, alias) {
829 return format === alias ? 'raw' : format;

Callers 1

unwrapKeyImplFunction · 0.85

Calls 2

detachFromUserPrototypesFunction · 0.85
lazyDOMExceptionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…