-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathtypes.ts
132 lines (113 loc) · 3.16 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import * as OctokitTypes from "@octokit/types";
import LRUCache from "lru-cache";
export type AnyResponse = OctokitTypes.OctokitResponse<any>;
export type EndpointDefaults = OctokitTypes.EndpointDefaults;
export type EndpointOptions = OctokitTypes.EndpointOptions;
export type RequestParameters = OctokitTypes.RequestParameters;
export type Route = OctokitTypes.Route;
export type RequestInterface = OctokitTypes.RequestInterface;
export type StrategyInterface = OctokitTypes.StrategyInterface<
[StrategyOptions],
[AuthOptions],
Authentication
>;
export type Cache =
| LRUCache<string, string>
| {
get: (key: string) => string;
set: (key: string, value: string) => any;
};
export interface AppAuthStrategy {
(options?: StrategyOptions): AppAuth;
}
export interface AppAuth {
(options: AuthOptions): Promise<Authentication>;
}
export type APP_TYPE = "app";
export type TOKEN_TYPE = "token";
export type INSTALLATION_TOKEN_TYPE = "installation";
export type OAUTH_TOKEN_TYPE = "oauth";
export type REPOSITORY_SELECTION = "all" | "selected";
export type JWT = string;
export type ACCESS_TOKEN = string;
export type UTC_TIMESTAMP = string;
export type AppAuthentication = {
type: APP_TYPE;
token: JWT;
appId: number;
expiresAt: string;
};
export type InstallationAccessTokenData = {
token: ACCESS_TOKEN;
createdAt: UTC_TIMESTAMP;
expiresAt: UTC_TIMESTAMP;
permissions: Permissions;
repositorySelection: REPOSITORY_SELECTION;
repositoryIds?: number[];
singleFileName?: string;
};
export type CacheData = InstallationAccessTokenData;
export type InstallationAccessTokenAuthentication = InstallationAccessTokenData & {
type: TOKEN_TYPE;
tokenType: INSTALLATION_TOKEN_TYPE;
};
export type OAuthAccesTokenAuthentication = {
type: TOKEN_TYPE;
tokenType: OAUTH_TOKEN_TYPE;
token: ACCESS_TOKEN;
scopes: string[];
};
export type Authentication =
| AppAuthentication
| InstallationAccessTokenAuthentication
| OAuthAccesTokenAuthentication;
export type StrategyOptions = {
id: number | string;
privateKey: string;
installationId?: number | string;
clientId?: string;
clientSecret?: string;
request?: OctokitTypes.RequestInterface;
cache?: Cache;
timeDifference?: number;
log?: {
warn: (message: string, additionalInfo?: object) => any;
[key: string]: any;
};
};
export type StrategyOptionsWithDefaults = StrategyOptions & {
id: number;
request: OctokitTypes.RequestInterface;
cache: Cache;
};
export type Permissions = {
[name: string]: string;
};
export type InstallationAuthOptions = {
installationId?: number | string;
repositoryIds?: number[];
permissions?: Permissions;
refresh?: boolean;
};
export type OAuthOptions = {
code?: string;
redirectUrl?: string;
state?: string;
};
export type AuthOptions = InstallationAuthOptions &
OAuthOptions & {
type: "app" | "installation" | "oauth";
};
export type WithInstallationId = {
installationId: number;
};
export type State = StrategyOptions & {
id: number;
installationId?: number;
request: OctokitTypes.RequestInterface;
cache: Cache;
log: {
warn: (message: string, additionalInfo?: object) => any;
[key: string]: any;
};
};