Skip to content

Instantly share code, notes, and snippets.

@kamescg
Last active June 26, 2018 18:15
Show Gist options
  • Save kamescg/5c2d2f4961628bb6deaa31ad290457f2 to your computer and use it in GitHub Desktop.
Save kamescg/5c2d2f4961628bb6deaa31ad290457f2 to your computer and use it in GitHub Desktop.
Attestation Generation Firebase Cloud Function
/**
* @desc Generates a uPort login request using the createRequest method
* @param {object} eventData The data saved in the Firebase realtime database.
* @param {string} eventKey The key referencing the new realtime database entry.
*/
const loginGenerate = (eventData, eventKey) => {
return uportCredentials.createRequest({
requested: eventData.input.requested,
notifications: eventData.input.notifications,
callbackUrl: `https://us-central1-${projectId}.cloudfunctions.net/identityCallback?uid=${eventKey}`
}).then(requestToken => {
database.databaseWrite({
writeType: 'update',
branch: ['request', 'login', eventKey],
payload: {
data: {
qr: `me.uport:me?requestToken=${requestToken}`
},
meta: {
status: 'requested',
type: 'login'
}
}
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment