mirror of
https://github.com/desktop/desktop
synced 2024-10-31 11:07:25 +00:00
Split guid out into its own file.
This commit is contained in:
parent
fdc157f774
commit
c3d170b4f5
2 changed files with 10 additions and 10 deletions
12
src/auth.ts
12
src/auth.ts
|
@ -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
8
src/lib/guid.ts
Normal 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()
|
||||
}
|
Loading…
Reference in a new issue