pwdless
<div style="display: flex; justify-content: right; ">
<input type="text" value="" id="sub" readonly size="50"><button onclick="copy_text()">Copy</button>
</div>
<div style="display: flex; align-items: right; " id="in_out">
</div>
<script type="module">
import passwordless from './src/index.js'
const scope = {scope:'openid'}
async function init() {
window.login_status = await passwordless.id(scope)
if(window.login_status.signedIn){
document.getElementById('sub').value = window.login_status.profile.sub
//??? console.log("curl -X GET https://api.passwordless.id/openid/validate?token="+ window.login_status.id_token +"&origin="+encodeURIComponent(window.location.href))
//curl -X GET "https://api.passwordless.id/openid/validate?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJodHRwczovL2FwaS5wYXNzd29yZGxlc3MuaWQiLCJzdWIiOiJSWUVHVkVseVM4QTBhbGEwX3hxRTA1THV5aXh5MV9HbmlpbHQzbk5uRnRnPSIsImF1ZCI6Imh0dHBzOi8vZWM0ZS00OS0yMDYtNjEtMTM0LmluLm5ncm9rLmlvIiwiaWF0IjoxNjc2OTE1NTE1LCJleHAiOjE2NzcwMDE5MTV9.c6ycqQHZwFeiBUCjW_9d_VtqZHcCCcFK9l-lQSEk0b3nHaOEXMTewz500msU5Lp2qcjusvPe6yAr2E9tIAW_84Tjh837-iMaOYYmYNgEfumBKDwdBKHeQWhSdfkt8WnmAFIchI4Fk7_Lvgu5u6gTgq0-o4YFXDcSrVAdh_8HslfRt9aM7gqiijwVr4U611kHJ9nxQfbasTvw-ZgY8bgJ1Kj0DAfbqmUBbqFYl1CAG0svzCix8_UAyE9CUCr2THVm2gXnmXQwPhnLA8cjzwl1yq7f7E4Q5ykTmJJMw-TzYLpUtcz0j0mIu4xmjz7JDI_wHeqqXtwU_IncduRoRA4uaDs9YU5RAJ3_FRG_cl46JClp-MIF6ZbqounEei4uXybQLqFTXdSq4eW2-8xyYQA0fsEcInRm64weDdsmFb3jRXf5GPaRj7ceiQ-ibihaurOLyDVzswIgOMxfPgZAjWxMx4zjlm6KRrp57WIg9ZuM2TgeFZ-aWwToxiNo98M2i3g6nYBAmEVnjOQJeRyWshnfo7oPF4HFTnCf7jeYbv09qK-K4cHiqjgHNBzooB6kJGmhgeU4rtC8Hg2USaEdO_gD1F6ESKEE0hrCZcGCuWPVDzHLVYpI47Nkgb86oDuL0daBb6FN-kIjzyaZ4Up2tKkfl4GhMGeiX9slQRFXQNRTpHc&origin=https%3A%2F%2Fec4e-49-206-61-134.in.ngrok.io" \
}else{
document.getElementById('in_out').innerHTML = '<button onclick="onClickSignIn()">Sign In</button>'
}
}
init()
window.onClickSignIn = () => {
passwordless.auth(scope)
}
window.onClickSignOut = async () => {
const user = await passwordless.logout()
}
</script>
<script>
function copy_text() {
var copyText = document.getElementById("sub");
copyText.select();
copyText.setSelectionRange(0, 99999); // For mobile devices
navigator.clipboard.writeText(copyText.value);
console.log(copyText.value)
}
</script>
Comments