1 | import { AsyncCreatable } from '@salesforce/kit';
|
2 | import { Nullable, Optional } from '@salesforce/ts-types';
|
3 | import { OAuth2Options } from 'jsforce';
|
4 | import { Connection } from './connection';
|
5 |
|
6 |
|
7 |
|
8 | export interface AuthFields {
|
9 | accessToken?: string;
|
10 | alias?: string;
|
11 | authCode?: string;
|
12 | clientId?: string;
|
13 | clientSecret?: string;
|
14 | created?: string;
|
15 | createdOrgInstance?: string;
|
16 | devHubUsername?: string;
|
17 | instanceUrl?: string;
|
18 | isDevHub?: boolean;
|
19 | loginUrl?: string;
|
20 | orgId?: string;
|
21 | password?: string;
|
22 | privateKey?: string;
|
23 | refreshToken?: string;
|
24 | scratchAdminUsername?: string;
|
25 | snapshot?: string;
|
26 | userId?: string;
|
27 | username?: string;
|
28 | usernames?: string[];
|
29 | userProfileName?: string;
|
30 | }
|
31 |
|
32 |
|
33 |
|
34 | export interface AccessTokenOptions {
|
35 | accessToken?: string;
|
36 | loginUrl?: string;
|
37 | instanceUrl?: string;
|
38 | }
|
39 |
|
40 |
|
41 |
|
42 | export declare type RefreshFn = (conn: Connection, callback: (err: Nullable<Error>, accessToken?: string, res?: object) => Promise<void>) => Promise<void>;
|
43 |
|
44 |
|
45 |
|
46 | export declare type ConnectionOptions = AuthFields & {
|
47 | |
48 |
|
49 |
|
50 | oauth2?: Partial<OAuth2Options>;
|
51 | |
52 |
|
53 |
|
54 | refreshFn?: RefreshFn;
|
55 | };
|
56 |
|
57 |
|
58 |
|
59 | export declare enum SfdcUrl {
|
60 | SANDBOX = "https://test.salesforce.com",
|
61 | PRODUCTION = "https://login.salesforce.com"
|
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 | export declare class AuthInfo extends AsyncCreatable<AuthInfo.Options> {
|
98 | |
99 |
|
100 |
|
101 |
|
102 | static listAllAuthFiles(): Promise<string[]>;
|
103 | |
104 |
|
105 |
|
106 | static hasAuthentications(): Promise<boolean>;
|
107 | |
108 |
|
109 |
|
110 |
|
111 | static getAuthorizationUrl(options: OAuth2Options): string;
|
112 | |
113 |
|
114 |
|
115 |
|
116 | static clearCache(username: string): boolean;
|
117 | private static authFilenameFilterRegEx;
|
118 | private static cache;
|
119 | private fields;
|
120 | private usingAccessToken;
|
121 | private logger;
|
122 | private authInfoCrypto;
|
123 | private options;
|
124 | |
125 |
|
126 |
|
127 |
|
128 |
|
129 | constructor(options: AuthInfo.Options);
|
130 | /**
|
131 | * Get the username.
|
132 | */
|
133 | getUsername(): Optional<string>;
|
134 | /**
|
135 | * Returns true if `this` is using the JWT flow.
|
136 | */
|
137 | isJwt(): boolean;
|
138 | /**
|
139 | * Returns true if `this` is using an access token flow.
|
140 | */
|
141 | isAccessTokenFlow(): boolean;
|
142 | /**
|
143 | * Returns true if `this` is using the oauth flow.
|
144 | */
|
145 | isOauth(): boolean;
|
146 | /**
|
147 | * Returns true if `this` is using the refresh token flow.
|
148 | */
|
149 | isRefreshTokenFlow(): boolean;
|
150 | /**
|
151 | * Updates the cache and persists the authentication fields (encrypted).
|
152 | * @param authData New data to save.
|
153 | */
|
154 | save(authData?: AuthFields): Promise<AuthInfo>;
|
155 | /**
|
156 | * Update the authorization fields, encrypting sensitive fields, but do not persist.
|
157 | * For convenience `this` object is returned.
|
158 | *
|
159 | * @param authData Authorization fields to update.
|
160 | * @param encrypt Encrypt the fields.
|
161 | */
|
162 | update(authData?: AuthFields, encrypt?: boolean): AuthInfo;
|
163 | /**
|
164 | * Get the auth fields (decrypted) needed to make a connection.
|
165 | */
|
166 | getConnectionOptions(): ConnectionOptions;
|
167 | /**
|
168 | * Get the authorization fields.
|
169 | */
|
170 | getFields(): AuthFields;
|
171 | /**
|
172 | * Returns true if this org is using access token auth.
|
173 | */
|
174 | isUsingAccessToken(): boolean;
|
175 | /**
|
176 | * Get the SFDX Auth URL.
|
177 | *
|
178 | * **See** [SFDX Authorization](https:
|
179 | */
|
180 | getSfdxAuthUrl(): string;
|
181 | |
182 |
|
183 |
|
184 | init(): Promise<void>;
|
185 | |
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 | private initAuthOptions;
|
194 | private isTokenOptions;
|
195 | private refreshFn;
|
196 | private buildJwtConfig;
|
197 | private buildRefreshTokenConfig;
|
198 | private buildWebAuthConfig;
|
199 | private lookup;
|
200 | }
|
201 | export declare namespace AuthInfo {
|
202 | |
203 |
|
204 |
|
205 | interface Options {
|
206 | |
207 |
|
208 |
|
209 | username?: string;
|
210 | |
211 |
|
212 |
|
213 | oauth2Options?: OAuth2Options;
|
214 | |
215 |
|
216 |
|
217 | accessTokenOptions?: AccessTokenOptions;
|
218 | }
|
219 | }
|
220 |
|
\ | No newline at end of file |