microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/extension/appcenter/auth/tokenStore/tokenStore.ts
37lines · modeblame
0c0b4844max-mironov8 years ago | 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT license. See LICENSE file in the project root for details. | |
| 3 | | |
| 4 | import { Observable } from "rx-lite"; | |
| 5 | import * as Q from "q"; | |
| 6 | | |
| 7 | export interface TokenStore { | |
| 8 | // List all entries in the store for our project | |
| 9 | list(): Observable<TokenEntry>; | |
| 10 | | |
| 11 | // Get a specific token | |
| 12 | get(key: TokenKeyType): Q.Promise<TokenEntry | null>; | |
| 13 | | |
| 14 | // Add or update a token | |
| 15 | set(key: TokenKeyType, token: TokenValueType): Q.Promise<void>; | |
| 16 | | |
| 17 | // Remove a token | |
| 18 | remove(key: TokenKeyType): Q.Promise<void> ; | |
| 19 | } | |
| 20 | | |
| 21 | // Information stored about in each token | |
| 22 | export interface TokenEntry { | |
| 23 | key: TokenKeyType; | |
| 24 | accessToken: TokenValueType; | |
| 25 | } | |
| 26 | | |
| 27 | export interface TokenValueType { | |
| 28 | token: string; | |
| 29 | } | |
| 30 | | |
| 31 | // | |
| 32 | // Object used as token keys. | |
| 33 | // Right now just a string, prepping for when we hook up to | |
| 34 | // AAD and have to use ADAL tokens. | |
| 35 | // | |
| 36 | export type TokenKeyType = string; | |
| 37 | |