1 const uisrv='ui.alpha-mail.jp'; 2 (async function() { 3 if (!window.PublicKeyCredential || !window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable) { 4 return; 5 } 6 7 async function initiatePasskeyLogin() { 8 try { 9 let getArgs = await fetch(`https://${uisrv}/webauthn-remote.php?fn=getGetArgs`, { 10 method: 'POST', 11 credentials: 'include' 12 }).then(res => res.json()); 13 recursiveBase64StrToArrayBuffer(getArgs); 14 15 const cred = await navigator.credentials.get(getArgs); 16 const assertionResponse = { 17 id: arrayBufferToBase64(cred.rawId), 18 clientDataJSON: arrayBufferToBase64(cred.response.clientDataJSON), 19 authenticatorData: arrayBufferToBase64(cred.response.authenticatorData), 20 signature: arrayBufferToBase64(cred.response.signature), 21 userHandle: cred.response.userHandle ? arrayBufferToBase64(cred.response.userHandle) : null 22 }; 23 24 let loginResult = await fetch(`https://${uisrv}/webauthn-remote.php?fn=processGet`, { 25 method: 'POST', 26 body: JSON.stringify(assertionResponse), 27 headers: { 'Content-Type': 'application/json' }, 28 credentials: 'include' 29 }).then(res => res.json()); 30 31 if (loginResult.success) { 32 window.location.href = `https://${uisrv}/index.php?lang=jp`; 33 } else { 34 throw new Error(loginResult.msg || 'ãã¹ãã¼èªè¨¼ã«å¤±æãã¾ããã'); 35 } 36 } catch (err) { 37 const dispmsg = document.getElementById('passkeyError'); 38 if(err.message == 'WEBAUTHN_ERROR_PASSKEY_NOT_FOUND') 39 dispmsg.textContent='ãã¹ãã¼ãè¦ã¤ããã¾ããã'; 40 else if(err.message == 'WEBAUTHN_ERROR_USER_NOT_FOUND') 41 dispmsg.textContent='ã¦ã¼ã¶ã¼ãè¦ã¤ããã¾ããã'; 42 else 43 console.log(err.message); 44 } 45 } 46 47 document.getElementById('loginWithPasskeyButton').addEventListener('click', async function() { 48 await initiatePasskeyLogin(); 49 }); 50 })(); 51 52 function arrayBufferToBase64(buffer) { 53 let binary = ''; 54 let bytes = new Uint8Array(buffer); 55 let len = bytes.byteLength; 56 for (let i = 0; i < len; i++) { 57 binary += String.fromCharCode( bytes[ i ] ); 58 } 59 return window.btoa(binary); 60 } 61 62 function recursiveBase64StrToArrayBuffer(obj) { 63 let prefix = '=?BINARY?B?'; 64 let suffix = '?='; 65 if (typeof obj === 'object') { 66 for (let key in obj) { 67 if (typeof obj[key] === 'string') { 68 let str = obj[key]; 69 if (str.substring(0, prefix.length) === prefix && str.substring(str.length - suffix.length) === suffix) { 70 str = str.substring(prefix.length, str.length - suffix.length); 71 72 let binary_string = window.atob(str); 73 let len = binary_string.length; 74 let bytes = new Uint8Array(len); 75 for (let i = 0; i < len; i++) { 76 bytes[i] = binary_string.charCodeAt(i); 77 } 78 obj[key] = bytes.buffer; 79 } 80 } else { 81 recursiveBase64StrToArrayBuffer(obj[key]); 82 } 83 } 84 } 85 }
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.