Last active
August 29, 2015 14:05
-
-
Save hongkongkiwi/2b736e4045f2123c3051 to your computer and use it in GitHub Desktop.
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
var moment = require('moment'), | |
crypto = require('crypto'); | |
function getICEServerJSON(username) { | |
var ttl = 86400; | |
var expiry = moment().add(ttl, 'seconds').unix(); | |
var usernameToken = expiry + ":" + username; | |
var secret = "mysupersecret"; | |
var nonce = crypto.createHmac("sha1", secret).update(usernameToken).digest("base64"); | |
return { | |
"username" : usernameToken, | |
"password" : nonce, | |
"ttl" : ttl, | |
"uris" : [ | |
"stun:127.0.0.1", | |
"turn:127.0.0.1" | |
] | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment