Best JavaScript code snippet using wpt
utils.js
Source:utils.js
...88 key.x = new Uint8Array(cbor[-2]);89 key.y = new Uint8Array(cbor[-3]);90 return key;91}92function parseAttestedCredentialData(attestedCredentialData) {93 // Parse the attested credential data according to94 // https://w3c.github.io/webauthn/#attested-credential-data95 let aaguid = attestedCredentialData.slice(0, 16);96 let credentialIdLength = (attestedCredentialData[16] << 8)97 + attestedCredentialData[17];98 let credentialId =99 attestedCredentialData.slice(18, 18 + credentialIdLength);100 let credentialPublicKey = parseCosePublicKey(101 attestedCredentialData.slice(18 + credentialIdLength,102 attestedCredentialData.length));103 return { aaguid, credentialIdLength, credentialId, credentialPublicKey };104}105function parseAuthenticatorData(authenticatorData) {106 // Parse the authenticator data according to107 // https://w3c.github.io/webauthn/#sctn-authenticator-data108 assert_greater_than_equal(authenticatorData.length, 37);109 let flags = authenticatorData[32];110 let counter = authenticatorData.slice(33, 37);111 let attestedCredentialData = authenticatorData.length > 37 ?112 parseAttestedCredentialData(authenticatorData.slice(37)) : null;113 let extensions = null;114 if (attestedCredentialData &&115 authenticatorData.length > 37 + attestedCredentialData.length) {116 extensions = authenticatorData.slice(37 + attestedCredentialData.length);117 }118 return {119 rpIdHash: authenticatorData.slice(0, 32),120 flags: {121 up: !!(flags & 0x01),122 uv: !!(flags & 0x04),123 at: !!(flags & 0x40),124 ed: !!(flags & 0x80),125 },126 counter: (counter[0] << 24)...
attestation.ts
Source:attestation.ts
...51 // @ts-ignore52 const validateSig = await jscu.pkc.verify(new Uint8Array(verificationData), signature, jscuKeyObj, 'SHA-256', {format: 'der'});53 if (!validateSig) return {valid: false};54 // Get Public Key From AuthData55 const parsed = await parseAttestedCredentialData(new Uint8Array(authData));56 return {valid: true, credentialPublicKey: parsed.publicKeyPem, attestationCertificate: pemCert};57 } else return {valid: false};...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!