Split guid out into its own file.

This commit is contained in:
joshaber 2016-05-31 13:11:54 -04:00
parent fdc157f774
commit c3d170b4f5
2 changed files with 10 additions and 10 deletions

View file

@ -1,7 +1,8 @@
import {shell} from 'electron'
import * as keytar from 'keytar'
import guid from './lib/guid'
const ServiceName = 'GitHubClient'
const ClientID = 'de0e3c7e9973e1c4dd77'
@ -39,15 +40,6 @@ function getOAuthURL(endpoint: string, state: string): string {
return `${endpoint}/login/oauth/authorize?client_id=${ClientID}&scope=repo&state=${state}`
}
function guid(): string {
function s4(): string {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1)
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4()
}
export function getDotComEndpoint(): string {
return 'https://github.com'
}

8
src/lib/guid.ts Normal file
View file

@ -0,0 +1,8 @@
export default function guid(): string {
function s4(): string {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1)
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4()
}