Last active
June 26, 2018 18:15
-
-
Save kamescg/5c2d2f4961628bb6deaa31ad290457f2 to your computer and use it in GitHub Desktop.
Attestation Generation Firebase Cloud Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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