Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / legacy-libs / google-auth-library / build / src / auth / jwtclient.d.ts
1 /**
2  * Copyright 2013 Google Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 /// <reference types="node" />
17 import { GoogleToken } from 'gtoken';
18 import * as stream from 'stream';
19 import { CredentialBody, Credentials, JWTInput } from './credentials';
20 import { GetTokenResponse, OAuth2Client, RefreshOptions, RequestMetadataResponse } from './oauth2client';
21 export interface JWTOptions extends RefreshOptions {
22     email?: string;
23     keyFile?: string;
24     key?: string;
25     keyId?: string;
26     scopes?: string | string[];
27     subject?: string;
28     additionalClaims?: {};
29 }
30 export declare class JWT extends OAuth2Client {
31     email?: string;
32     keyFile?: string;
33     key?: string;
34     keyId?: string;
35     scopes?: string | string[];
36     scope?: string;
37     subject?: string;
38     gtoken?: GoogleToken;
39     additionalClaims?: {};
40     private access?;
41     /**
42      * JWT service account credentials.
43      *
44      * Retrieve access token using gtoken.
45      *
46      * @param email service account email address.
47      * @param keyFile path to private key file.
48      * @param key value of key
49      * @param scopes list of requested scopes or a single scope.
50      * @param subject impersonated account's email address.
51      * @param key_id the ID of the key
52      */
53     constructor(options: JWTOptions);
54     constructor(email?: string, keyFile?: string, key?: string, scopes?: string | string[], subject?: string, keyId?: string);
55     /**
56      * Creates a copy of the credential with the specified scopes.
57      * @param scopes List of requested scopes or a single scope.
58      * @return The cloned instance.
59      */
60     createScoped(scopes?: string | string[]): JWT;
61     /**
62      * Obtains the metadata to be sent with the request.
63      *
64      * @param url the URI being authorized.
65      */
66     protected getRequestMetadataAsync(url?: string | null): Promise<RequestMetadataResponse>;
67     /**
68      * Indicates whether the credential requires scopes to be created by calling
69      * createScoped before use.
70      * @deprecated
71      * @return false if createScoped does not need to be called.
72      */
73     createScopedRequired(): boolean;
74     /**
75      * Determine if there are currently scopes available.
76      */
77     private hasScopes;
78     /**
79      * Get the initial access token using gToken.
80      * @param callback Optional callback.
81      * @returns Promise that resolves with credentials
82      */
83     authorize(): Promise<Credentials>;
84     authorize(callback: (err: Error | null, result?: Credentials) => void): void;
85     private authorizeAsync;
86     /**
87      * Refreshes the access token.
88      * @param refreshToken ignored
89      * @private
90      */
91     protected refreshTokenNoCache(refreshToken?: string | null): Promise<GetTokenResponse>;
92     /**
93      * Create a gToken if it doesn't already exist.
94      */
95     private createGToken;
96     /**
97      * Create a JWT credentials instance using the given input options.
98      * @param json The input object.
99      */
100     fromJSON(json: JWTInput): void;
101     /**
102      * Create a JWT credentials instance using the given input stream.
103      * @param inputStream The input stream.
104      * @param callback Optional callback.
105      */
106     fromStream(inputStream: stream.Readable): Promise<void>;
107     fromStream(inputStream: stream.Readable, callback: (err?: Error | null) => void): void;
108     private fromStreamAsync;
109     /**
110      * Creates a JWT credentials instance using an API Key for authentication.
111      * @param apiKey The API Key in string form.
112      */
113     fromAPIKey(apiKey: string): void;
114     /**
115      * Using the key or keyFile on the JWT client, obtain an object that contains
116      * the key and the client email.
117      */
118     getCredentials(): Promise<CredentialBody>;
119 }