UNPKG

2.38 kBTypeScriptView Raw
1import * as stream from 'stream';
2import { JWTInput } from './credentials';
3import { Headers } from './oauth2client';
4export interface Claims {
5 [index: string]: string;
6}
7export declare class JWTAccess {
8 email?: string | null;
9 key?: string | null;
10 keyId?: string | null;
11 projectId?: string;
12 eagerRefreshThresholdMillis: number;
13 private cache;
14 /**
15 * JWTAccess service account credentials.
16 *
17 * Create a new access token by using the credential to create a new JWT token
18 * that's recognized as the access token.
19 *
20 * @param email the service account email address.
21 * @param key the private key that will be used to sign the token.
22 * @param keyId the ID of the private key used to sign the token.
23 */
24 constructor(email?: string | null, key?: string | null, keyId?: string | null, eagerRefreshThresholdMillis?: number);
25 /**
26 * Ensures that we're caching a key appropriately, giving precedence to scopes vs. url
27 *
28 * @param url The URI being authorized.
29 * @param scopes The scope or scopes being authorized
30 * @returns A string that returns the cached key.
31 */
32 getCachedKey(url?: string, scopes?: string | string[]): string;
33 /**
34 * Get a non-expired access token, after refreshing if necessary.
35 *
36 * @param url The URI being authorized.
37 * @param additionalClaims An object with a set of additional claims to
38 * include in the payload.
39 * @returns An object that includes the authorization header.
40 */
41 getRequestHeaders(url?: string, additionalClaims?: Claims, scopes?: string | string[]): Headers;
42 /**
43 * Returns an expiration time for the JWT token.
44 *
45 * @param iat The issued at time for the JWT.
46 * @returns An expiration time for the JWT.
47 */
48 private static getExpirationTime;
49 /**
50 * Create a JWTAccess credentials instance using the given input options.
51 * @param json The input object.
52 */
53 fromJSON(json: JWTInput): void;
54 /**
55 * Create a JWTAccess credentials instance using the given input stream.
56 * @param inputStream The input stream.
57 * @param callback Optional callback.
58 */
59 fromStream(inputStream: stream.Readable): Promise<void>;
60 fromStream(inputStream: stream.Readable, callback: (err?: Error) => void): void;
61 private fromStreamAsync;
62}