UNPKG

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