@visulima/storage 1.0.0-alpha.26 → 1.0.0-alpha.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/LICENSE.md +0 -1104
- package/README.md +79 -466
- package/dist/adapter/nuxt/module.d.ts +4 -4
- package/dist/adapter/nuxt/node_modules/.bin/nuxi +22 -0
- package/dist/adapter/nuxt/node_modules/.bin/nuxt +22 -0
- package/dist/ai/ai-sdk/index.d.ts +113 -0
- package/dist/ai/ai-sdk/index.js +1 -0
- package/dist/ai/claude/index.d.ts +177 -0
- package/dist/ai/claude/index.js +1 -0
- package/dist/ai/openai/index.d.ts +205 -0
- package/dist/ai/openai/index.js +1 -0
- package/dist/ai/tanstack/index.d.ts +115 -0
- package/dist/ai/tanstack/index.js +1 -0
- package/dist/handler/http/fetch/index.d.ts +13 -7
- package/dist/handler/http/fetch/index.js +1 -1
- package/dist/handler/http/hono/index.d.ts +5 -1412
- package/dist/handler/http/hono/index.js +1 -1
- package/dist/handler/http/nextjs/index.d.ts +4 -4
- package/dist/handler/http/nextjs/index.js +1 -1
- package/dist/handler/http/node/index.d.ts +7 -7
- package/dist/handler/http/node/index.js +1 -1
- package/dist/handler/http/solid-start/index.d.ts +4 -4
- package/dist/handler/http/solid-start/index.js +1 -1
- package/dist/index.d.ts +6 -324
- package/dist/index.js +1 -1
- package/dist/packem_shared/{AwsLightFile-BTLiRxXj.js → AwsLightFile-BSqjc_rD.js} +1 -1
- package/dist/packem_shared/{AwsLightStorage-CA9cdfJ6.js → AwsLightStorage-SH7j-myh.js} +1 -1
- package/dist/packem_shared/{AzureFile-BKHru1zB.js → AzureFile-Dgj2Tef4.js} +1 -1
- package/dist/packem_shared/{AzureSMetaStorage-BqA4jUDJ.js → AzureSMetaStorage-DV2tNjKh.js} +1 -1
- package/dist/packem_shared/AzureStorage-BVYMFEBP.js +1 -0
- package/dist/packem_shared/BaseTransformer-Fpcuz4kj.js +1 -0
- package/dist/packem_shared/BoxFile-Be0S4N1L.js +1 -0
- package/dist/packem_shared/BoxMetaStorage-BUe5Qmqe.js +1 -0
- package/dist/packem_shared/BoxStorage-CgC81_So.js +1 -0
- package/dist/packem_shared/BunnyFile-Dotl-lO9.js +1 -0
- package/dist/packem_shared/BunnyMetaStorage-D0mT6veJ.js +1 -0
- package/dist/packem_shared/BunnyStorage-Bl4usdVT.js +1 -0
- package/dist/packem_shared/DiskStorage-B5uIDVXr.js +1 -0
- package/dist/packem_shared/DiskStorageWithChecksum-CbXWpSOr.js +1 -0
- package/dist/packem_shared/DropboxFile-BGVG2kXM.js +1 -0
- package/dist/packem_shared/DropboxMetaStorage-CICuUZ1n.js +1 -0
- package/dist/packem_shared/DropboxStorage-CPjhDN5B.js +1 -0
- package/dist/packem_shared/ERRORS-CyOuSMLY.js +1 -0
- package/dist/packem_shared/File-BhfUgJjs.js +1 -0
- package/dist/packem_shared/Files-B7hlJcB4.js +1 -0
- package/dist/packem_shared/{GCSFile-CHjX_fJk.js → GCSFile-CDQ6IWAz.js} +1 -1
- package/dist/packem_shared/{GCSMetaStorage-DV0MBO3W.js → GCSMetaStorage-CqP9ifYB.js} +1 -1
- package/dist/packem_shared/GCStorage-XSBKVx90.js +1 -0
- package/dist/packem_shared/GoogleDriveFile-D0aGfGbL.js +1 -0
- package/dist/packem_shared/GoogleDriveMetaStorage-rghGy3Fa.js +1 -0
- package/dist/packem_shared/GoogleDriveStorage-DuB6glUk.js +1 -0
- package/dist/packem_shared/LocalMetaStorage-B5uh1snG.js +1 -0
- package/dist/packem_shared/MediaTransformer-D-1c9Q_k.js +1 -0
- package/dist/packem_shared/Multipart-7FSSy2n1.js +1 -0
- package/dist/packem_shared/Multipart-DACQFsrn.js +1 -0
- package/dist/packem_shared/{NetlifyBlobFile-CpzkMKng.js → NetlifyBlobFile-PMZLJ8AC.js} +1 -1
- package/dist/packem_shared/NetlifyBlobMetaStorage-BcRFPky8.js +1 -0
- package/dist/packem_shared/NetlifyBlobStorage-C4qkJv1R.js +1 -0
- package/dist/packem_shared/OneDriveFile-XbVVKIJh.js +1 -0
- package/dist/packem_shared/OneDriveMetaStorage-B_BkGLzW.js +1 -0
- package/dist/packem_shared/OneDriveStorage-Cu0cGcrh.js +1 -0
- package/dist/packem_shared/Rest-5NwM1xYj.js +1 -0
- package/dist/packem_shared/{Rest-CYEBbtCD.js → Rest-y8Vz2Rt0.js} +1 -1
- package/dist/packem_shared/{S3File-Du6wP0Sz.js → S3File-BfmCOET4.js} +1 -1
- package/dist/packem_shared/S3Storage-D8dopWoO.js +1 -0
- package/dist/packem_shared/SupabaseFile-DZ1iv9gM.js +1 -0
- package/dist/packem_shared/SupabaseMetaStorage-BR1UGqnj.js +1 -0
- package/dist/packem_shared/SupabaseStorage-CCtMTiN5.js +1 -0
- package/dist/packem_shared/{Tus-CUBCkuPE.js → Tus-BCVAbJIi.js} +1 -1
- package/dist/packem_shared/Tus-CJMcygk7.js +1 -0
- package/dist/packem_shared/UploadThingFile-BpG9mE8K.js +1 -0
- package/dist/packem_shared/UploadThingMetaStorage-DyGNyaAq.js +1 -0
- package/dist/packem_shared/UploadThingStorage-B_fNzNFO.js +1 -0
- package/dist/packem_shared/{VercelBlobFile-CL9MjKcY.js → VercelBlobFile-Cni_1qwD.js} +1 -1
- package/dist/packem_shared/{VercelBlobMetaStorage-BsOTx-Su.js → VercelBlobMetaStorage-Do9ZoKrl.js} +1 -1
- package/dist/packem_shared/VercelBlobStorage-D5zy4PPQ.js +1 -0
- package/dist/packem_shared/agentsListFiles-R-CnGKc4.js +1 -0
- package/dist/packem_shared/akamai-BYS9pP8S.js +1 -0
- package/dist/packem_shared/approval-BBeX3o4E.js +1 -0
- package/dist/packem_shared/approval.d-CMAYH9GF.d.ts +75 -0
- package/dist/packem_shared/backblaze-CvdtCvJL.js +1 -0
- package/dist/packem_shared/base-handler-core-BfwZ1RS1.js +1 -0
- package/dist/packem_shared/base-handler-fetch-CLxqXTQf.js +1 -0
- package/dist/packem_shared/base-handler-node-DBZjcqsp.js +1 -0
- package/dist/packem_shared/claudeListFiles-DAezbKEi.js +1 -0
- package/dist/packem_shared/cloudflare-Bm_Pg6yx.js +1 -0
- package/dist/packem_shared/createResponsesFileTools-BCep-qdO.js +1 -0
- package/dist/packem_shared/defaultCloudStorageFileNameValidation-6URTv-Mp.js +1 -0
- package/dist/packem_shared/detect-file-type-5JhzC9RU.js +1 -0
- package/dist/packem_shared/digitalOcean-Lj1NfDzc.js +1 -0
- package/dist/packem_shared/disk-storage-CbSSPnOf.js +5 -0
- package/dist/packem_shared/{disk-storage-with-checksum.d-hEoe2ugb.d.ts → disk-storage-with-checksum.d-BQMXA4Wl.d.ts} +6 -4
- package/dist/packem_shared/executors-DG6hGtvm.js +1 -0
- package/dist/packem_shared/executors.d-UtkeCbk1.d.ts +65 -0
- package/dist/packem_shared/{gcs-meta-storage-BfJB-ejI.js → gcs-meta-storage-XB-UPJn6.js} +1 -1
- package/dist/packem_shared/hetzner-DDxE7Gy7.js +1 -0
- package/dist/packem_shared/index.d-DotjipuX.d.ts +89 -0
- package/dist/packem_shared/isRetryableError-B6ZS_-5I.js +1 -0
- package/dist/packem_shared/listFiles-B6VF05d-.js +1 -0
- package/dist/packem_shared/listFiles-BtP6VnUp.js +1 -0
- package/dist/packem_shared/{local-meta-storage-Bkwqi_gi.js → local-meta-storage-CT1audnK.js} +1 -1
- package/dist/packem_shared/{local-meta-storage.d-Dop9RP9k.d.ts → local-meta-storage.d-B5R1nswK.d.ts} +2 -1
- package/dist/packem_shared/{media-transformer.d-CY9CsEOe.d.ts → media-transformer.d-DK7NJncf.d.ts} +2 -2
- package/dist/packem_shared/minio-T_Z3iEy7.js +1 -0
- package/dist/packem_shared/multipart-base-BxckfvQf.js +1 -0
- package/dist/packem_shared/oauth-refresh-Dg2ybc6_.js +1 -0
- package/dist/packem_shared/part-match-B5fLLmFw.js +1 -0
- package/dist/packem_shared/rest-base-CCv78k7h.js +1 -0
- package/dist/packem_shared/s3-base-storage-f_EyFAAt.js +1 -0
- package/dist/packem_shared/{s3-base-storage.d-CczjSe98.d.ts → s3-base-storage.d-BROGYJ4F.d.ts} +1 -1
- package/dist/packem_shared/storage-CoyB2O-Y.js +1 -0
- package/dist/packem_shared/{storage.d-BOMUJD96.d.ts → storage.d-Cr6f2lac.d.ts} +179 -78
- package/dist/packem_shared/storj-CVA9mM-7.js +1 -0
- package/dist/packem_shared/tigris-wmhjfsH2.js +1 -0
- package/dist/packem_shared/{tus-base.d-DNZRXR9X.d.ts → tus-base.d-4-ZfDQwl.d.ts} +3 -3
- package/dist/packem_shared/{types.d-D4caL2Fp.d.ts → types.d-BgCmSE94.d.ts} +2 -2
- package/dist/packem_shared/{types.d-BCN94sB_.d.ts → types.d-C8eSxqX9.d.ts} +13 -1
- package/dist/packem_shared/wasabi-JQzxdrFy.js +1 -0
- package/dist/storage/aws/clients/index.d.ts +90 -15
- package/dist/storage/aws/clients/index.js +1 -1
- package/dist/storage/aws/index.d.ts +16 -15
- package/dist/storage/aws/index.js +1 -1
- package/dist/storage/aws-light/index.d.ts +5 -3
- package/dist/storage/aws-light/index.js +1 -1
- package/dist/storage/azure/index.d.ts +4 -10277
- package/dist/storage/azure/index.js +1 -1
- package/dist/storage/box/index.d.ts +186 -0
- package/dist/storage/box/index.js +1 -0
- package/dist/storage/bunny/index.d.ts +116 -0
- package/dist/storage/bunny/index.js +1 -0
- package/dist/storage/dropbox/index.d.ts +129 -0
- package/dist/storage/dropbox/index.js +1 -0
- package/dist/storage/gcs/index.d.ts +6 -3941
- package/dist/storage/gcs/index.js +1 -1
- package/dist/storage/google-drive/index.d.ts +145 -0
- package/dist/storage/google-drive/index.js +1 -0
- package/dist/storage/local/index.d.ts +3 -3
- package/dist/storage/local/index.js +1 -1
- package/dist/storage/netlify-blob/index.d.ts +4 -2
- package/dist/storage/netlify-blob/index.js +1 -1
- package/dist/storage/onedrive/index.d.ts +192 -0
- package/dist/storage/onedrive/index.js +1 -0
- package/dist/storage/supabase/index.d.ts +111 -0
- package/dist/storage/supabase/index.js +1 -0
- package/dist/storage/uploadthing/index.d.ts +91 -0
- package/dist/storage/uploadthing/index.js +1 -0
- package/dist/storage/vercel-blob/index.d.ts +17 -2
- package/dist/storage/vercel-blob/index.js +1 -1
- package/dist/transformer/audio-transformer.d.ts +2 -2
- package/dist/transformer/audio-transformer.js +1 -1
- package/dist/transformer/image-transformer.d.ts +6 -2
- package/dist/transformer/image-transformer.js +1 -1
- package/dist/transformer/index.d.ts +3 -3
- package/dist/transformer/index.js +1 -1
- package/dist/transformer/video-transformer.d.ts +2 -2
- package/dist/transformer/video-transformer.js +1 -1
- package/package.json +99 -3
- package/dist/packem_shared/AzureStorage-BKUjCymW.js +0 -1
- package/dist/packem_shared/BaseTransformer-D68eLyz1.js +0 -1
- package/dist/packem_shared/DiskStorage-DNjpDMX9.js +0 -1
- package/dist/packem_shared/DiskStorageWithChecksum-Bb6JX_tC.js +0 -1
- package/dist/packem_shared/ERRORS-B9jkvKwx.js +0 -1
- package/dist/packem_shared/File-alcSNpLq.js +0 -1
- package/dist/packem_shared/GCStorage-B8dl6TGK.js +0 -1
- package/dist/packem_shared/LocalMetaStorage-BWuFvWn4.js +0 -1
- package/dist/packem_shared/MediaTransformer-2C8MJeAg.js +0 -1
- package/dist/packem_shared/Multipart-Bd9YFFn0.js +0 -1
- package/dist/packem_shared/Multipart-D5bcEvga.js +0 -1
- package/dist/packem_shared/NetlifyBlobMetaStorage-dD0oBLom.js +0 -1
- package/dist/packem_shared/NetlifyBlobStorage-ByTwCN-h.js +0 -1
- package/dist/packem_shared/Rest-DoonVU7B.js +0 -1
- package/dist/packem_shared/S3Client.d-CZ62Jztg.d.ts +0 -20357
- package/dist/packem_shared/S3Storage-Fx6-OSc-.js +0 -1
- package/dist/packem_shared/Tus-Bd_2Ki2G.js +0 -1
- package/dist/packem_shared/VercelBlobStorage-kNkk5Cn4.js +0 -1
- package/dist/packem_shared/backblaze-DEflv87m.js +0 -1
- package/dist/packem_shared/base-handler-core-DaggCVsq.js +0 -1
- package/dist/packem_shared/base-handler-fetch-DnarP64X.js +0 -1
- package/dist/packem_shared/base-handler-node-BTes6sql.js +0 -1
- package/dist/packem_shared/cloudflare-DLAeQvgD.js +0 -1
- package/dist/packem_shared/defaultCloudStorageFileNameValidation-yiM9GxHr.js +0 -1
- package/dist/packem_shared/digitalOcean-nhZUds87.js +0 -1
- package/dist/packem_shared/disk-storage-BvdK4bqF.js +0 -5
- package/dist/packem_shared/isRetryableError-DQNSZiBc.js +0 -1
- package/dist/packem_shared/minio-BWwgGXeE.js +0 -1
- package/dist/packem_shared/multipart-base-C6OjBwMS.js +0 -1
- package/dist/packem_shared/part-match-DqD5U7An.js +0 -1
- package/dist/packem_shared/rest-base-B2Dv7esY.js +0 -1
- package/dist/packem_shared/s3-base-storage-xHZNtsGe.js +0 -1
- package/dist/packem_shared/storage-m_Cxgiih.js +0 -1
- package/dist/packem_shared/tigris-DZoyrMNd.js +0 -1
- package/dist/packem_shared/validator-DK41xp8N.js +0 -1
- package/dist/packem_shared/wasabi-Dmce4x9s.js +0 -1
|
@@ -1,3951 +1,15 @@
|
|
|
1
|
-
import { F as File
|
|
1
|
+
import { F as File, t as MetaStorageOptions, L as LocalMetaStorageOptions, l as BaseStorageOptions, M as MetaStorage, H as HttpError, e as FileInit, f as FilePart, g as FileQuery, a as FileReturn, B as BaseStorage } from "../../packem_shared/storage.d-Cr6f2lac.js";
|
|
2
2
|
import 'node:stream';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import * as stream from 'stream';
|
|
6
|
-
import { Readable } from 'stream';
|
|
7
|
-
import * as querystring from 'querystring';
|
|
8
|
-
import * as _$google_logging_utils0 from 'google-logging-utils';
|
|
9
|
-
import { EventEmitter } from 'events';
|
|
10
|
-
import * as gcpMetadata from 'gcp-metadata';
|
|
3
|
+
import { RetryConfig } from 'gaxios';
|
|
4
|
+
import { GoogleAuthOptions, GoogleAuth } from 'google-auth-library';
|
|
11
5
|
import 'node:crypto';
|
|
12
6
|
import 'node:http';
|
|
13
7
|
import 'lru-cache';
|
|
14
8
|
declare const GCSConfig: Record<string, string | string[]>;
|
|
15
|
-
declare class GCSFile extends File
|
|
9
|
+
declare class GCSFile extends File {
|
|
16
10
|
GCSUploadURI?: string;
|
|
17
11
|
uri?: string;
|
|
18
12
|
}
|
|
19
|
-
/**
|
|
20
|
-
* TypeScript does not have this type available globally - however `@types/node` includes `undici-types`, which has it:
|
|
21
|
-
* - https://www.npmjs.com/package/@types/node/v/18.19.59?activeTab=dependencies
|
|
22
|
-
*
|
|
23
|
-
* Additionally, this is the TypeScript pattern for type sniffing and `import("undici-types")` is pretty common:
|
|
24
|
-
* - https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/globals.d.ts
|
|
25
|
-
*/
|
|
26
|
-
type _BodyInit = typeof globalThis extends {
|
|
27
|
-
BodyInit: infer T;
|
|
28
|
-
} ? T : _$undici_types0.BodyInit;
|
|
29
|
-
/**
|
|
30
|
-
* An AIP-193 conforming error interface.
|
|
31
|
-
*
|
|
32
|
-
* @see {@link https://google.aip.dev/193#http11json-representation AIP-193}
|
|
33
|
-
*
|
|
34
|
-
* @param res the response object
|
|
35
|
-
* @returns the extracted error information
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Support `instanceof` operator for `GaxiosError`s in different versions of this library.
|
|
40
|
-
*
|
|
41
|
-
* @see {@link GaxiosError[Symbol.hasInstance]}
|
|
42
|
-
*/
|
|
43
|
-
declare const GAXIOS_ERROR_SYMBOL: unique symbol;
|
|
44
|
-
declare class GaxiosError<T = ReturnType<JSON['parse']>> extends Error {
|
|
45
|
-
config: GaxiosOptionsPrepared;
|
|
46
|
-
response?: GaxiosResponse<T> | undefined;
|
|
47
|
-
/**
|
|
48
|
-
* An error code.
|
|
49
|
-
* Can be a system error code, DOMException error name, or any error's 'code' property where it is a `string`.
|
|
50
|
-
*
|
|
51
|
-
* It is only a `number` when the cause is sourced from an API-level error (AIP-193).
|
|
52
|
-
*
|
|
53
|
-
* @see {@link https://nodejs.org/api/errors.html#errorcode error.code}
|
|
54
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/DOMException#error_names DOMException#error_names}
|
|
55
|
-
* @see {@link https://google.aip.dev/193#http11json-representation AIP-193}
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* 'ECONNRESET'
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* 'TimeoutError'
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* 500
|
|
65
|
-
*/
|
|
66
|
-
code?: string | number;
|
|
67
|
-
/**
|
|
68
|
-
* An HTTP Status code.
|
|
69
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Response/status Response#status}
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* 500
|
|
73
|
-
*/
|
|
74
|
-
status?: number;
|
|
75
|
-
/**
|
|
76
|
-
* @deprecated use {@link GaxiosError.cause} instead.
|
|
77
|
-
*
|
|
78
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause Error#cause}
|
|
79
|
-
*
|
|
80
|
-
* @privateRemarks
|
|
81
|
-
*
|
|
82
|
-
* We will want to remove this property later as the modern `cause` property is better suited
|
|
83
|
-
* for displaying and relaying nested errors. Keeping this here makes the resulting
|
|
84
|
-
* error log larger than it needs to be.
|
|
85
|
-
*
|
|
86
|
-
*/
|
|
87
|
-
error?: Error | NodeJS.ErrnoException;
|
|
88
|
-
/**
|
|
89
|
-
* Support `instanceof` operator for `GaxiosError` across builds/duplicated files.
|
|
90
|
-
*
|
|
91
|
-
* @see {@link GAXIOS_ERROR_SYMBOL}
|
|
92
|
-
* @see {@link GaxiosError[Symbol.hasInstance]}
|
|
93
|
-
* @see {@link https://github.com/microsoft/TypeScript/issues/13965#issuecomment-278570200}
|
|
94
|
-
* @see {@link https://stackoverflow.com/questions/46618852/require-and-instanceof}
|
|
95
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/@@hasInstance#reverting_to_default_instanceof_behavior}
|
|
96
|
-
*/
|
|
97
|
-
[GAXIOS_ERROR_SYMBOL]: string;
|
|
98
|
-
/**
|
|
99
|
-
* Support `instanceof` operator for `GaxiosError` across builds/duplicated files.
|
|
100
|
-
*
|
|
101
|
-
* @see {@link GAXIOS_ERROR_SYMBOL}
|
|
102
|
-
* @see {@link GaxiosError[GAXIOS_ERROR_SYMBOL]}
|
|
103
|
-
*/
|
|
104
|
-
static [Symbol.hasInstance](instance: unknown): boolean;
|
|
105
|
-
constructor(message: string, config: GaxiosOptionsPrepared, response?: GaxiosResponse<T> | undefined, cause?: unknown);
|
|
106
|
-
}
|
|
107
|
-
type GaxiosResponseData = ReturnType<JSON['parse']> | GaxiosOptionsPrepared['data'];
|
|
108
|
-
type GaxiosPromise<T = GaxiosResponseData> = Promise<GaxiosResponse<T>>;
|
|
109
|
-
interface GaxiosResponse<T = GaxiosResponseData> extends Response {
|
|
110
|
-
config: GaxiosOptionsPrepared;
|
|
111
|
-
data: T;
|
|
112
|
-
}
|
|
113
|
-
interface GaxiosMultipartOptions {
|
|
114
|
-
headers: Headers;
|
|
115
|
-
content: string | Readable;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Request options that are used to form the request.
|
|
119
|
-
*/
|
|
120
|
-
interface GaxiosOptions extends RequestInit {
|
|
121
|
-
/**
|
|
122
|
-
* Optional method to override making the actual HTTP request. Useful
|
|
123
|
-
* for writing tests.
|
|
124
|
-
*/
|
|
125
|
-
adapter?: <T = GaxiosResponseData>(options: GaxiosOptionsPrepared, defaultAdapter: (options: GaxiosOptionsPrepared) => GaxiosPromise<T>) => GaxiosPromise<T>;
|
|
126
|
-
url?: string | URL;
|
|
127
|
-
baseURL?: string | URL;
|
|
128
|
-
/**
|
|
129
|
-
* The data to send in the {@link RequestInit.body} of the request. Objects will be
|
|
130
|
-
* serialized as JSON, except for:
|
|
131
|
-
* - `ArrayBuffer`
|
|
132
|
-
* - `Blob`
|
|
133
|
-
* - `Buffer` (Node.js)
|
|
134
|
-
* - `DataView`
|
|
135
|
-
* - `File`
|
|
136
|
-
* - `FormData`
|
|
137
|
-
* - `ReadableStream`
|
|
138
|
-
* - `stream.Readable` (Node.js)
|
|
139
|
-
* - strings
|
|
140
|
-
* - `TypedArray` (e.g. `Uint8Array`, `BigInt64Array`)
|
|
141
|
-
* - `URLSearchParams`
|
|
142
|
-
* - all other objects where:
|
|
143
|
-
* - headers['Content-Type'] === 'application/x-www-form-urlencoded' (serialized as `URLSearchParams`)
|
|
144
|
-
*
|
|
145
|
-
* In all other cases, if you would like to prevent `application/json` as the
|
|
146
|
-
* default `Content-Type` header you must provide a string or readable stream
|
|
147
|
-
* rather than an object, e.g.:
|
|
148
|
-
*
|
|
149
|
-
* ```ts
|
|
150
|
-
* {data: JSON.stringify({some: 'data'})}
|
|
151
|
-
* {data: fs.readFile('./some-data.jpeg')}
|
|
152
|
-
* ```
|
|
153
|
-
*/
|
|
154
|
-
data?: _BodyInit | ArrayBuffer | Blob | Buffer | DataView | File | FormData | ReadableStream | Readable | string | ArrayBufferView | URLSearchParams | {};
|
|
155
|
-
/**
|
|
156
|
-
* The maximum size of the http response `Content-Length` in bytes allowed.
|
|
157
|
-
*/
|
|
158
|
-
maxContentLength?: number;
|
|
159
|
-
/**
|
|
160
|
-
* The maximum number of redirects to follow. Defaults to 20.
|
|
161
|
-
*
|
|
162
|
-
* @deprecated non-spec. Should use `20` if enabled per-spec: https://fetch.spec.whatwg.org/#http-redirect-fetch
|
|
163
|
-
*/
|
|
164
|
-
maxRedirects?: number;
|
|
165
|
-
/**
|
|
166
|
-
* @deprecated non-spec. Should use `20` if enabled per-spec: https://fetch.spec.whatwg.org/#http-redirect-fetch
|
|
167
|
-
*/
|
|
168
|
-
follow?: number;
|
|
169
|
-
/**
|
|
170
|
-
* A collection of parts to send as a `Content-Type: multipart/related` request.
|
|
171
|
-
*
|
|
172
|
-
* This is passed to {@link RequestInit.body}.
|
|
173
|
-
*/
|
|
174
|
-
multipart?: GaxiosMultipartOptions[];
|
|
175
|
-
params?: GaxiosResponseData;
|
|
176
|
-
/**
|
|
177
|
-
* @deprecated Use {@link URLSearchParams} instead and pass this directly to {@link GaxiosOptions.data `data`}.
|
|
178
|
-
*/
|
|
179
|
-
paramsSerializer?: (params: {
|
|
180
|
-
[index: string]: string | number;
|
|
181
|
-
}) => string;
|
|
182
|
-
/**
|
|
183
|
-
* A timeout for the request, in milliseconds. No timeout by default.
|
|
184
|
-
*/
|
|
185
|
-
timeout?: number;
|
|
186
|
-
/**
|
|
187
|
-
* @deprecated ignored
|
|
188
|
-
*/
|
|
189
|
-
onUploadProgress?: (progressEvent: GaxiosResponseData) => void;
|
|
190
|
-
/**
|
|
191
|
-
* If the `fetchImplementation` is native `fetch`, the
|
|
192
|
-
* stream is a `ReadableStream`, otherwise `readable.Stream`
|
|
193
|
-
*/
|
|
194
|
-
responseType?: 'arraybuffer' | 'blob' | 'json' | 'text' | 'stream' | 'unknown';
|
|
195
|
-
agent?: Agent | ((parsedUrl: URL) => Agent);
|
|
196
|
-
validateStatus?: (status: number) => boolean;
|
|
197
|
-
retryConfig?: RetryConfig;
|
|
198
|
-
retry?: boolean;
|
|
199
|
-
/**
|
|
200
|
-
* @deprecated non-spec. https://github.com/node-fetch/node-fetch/issues/1438
|
|
201
|
-
*/
|
|
202
|
-
size?: number;
|
|
203
|
-
/**
|
|
204
|
-
* Implementation of `fetch` to use when making the API call. Will use `fetch` by default.
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
*
|
|
208
|
-
* let customFetchCalled = false;
|
|
209
|
-
* const myFetch = (...args: Parameters<typeof fetch>) => {
|
|
210
|
-
* customFetchCalled = true;
|
|
211
|
-
* return fetch(...args);
|
|
212
|
-
* };
|
|
213
|
-
*
|
|
214
|
-
* {fetchImplementation: myFetch};
|
|
215
|
-
*/
|
|
216
|
-
fetchImplementation?: typeof fetch;
|
|
217
|
-
cert?: string;
|
|
218
|
-
key?: string;
|
|
219
|
-
/**
|
|
220
|
-
* An optional proxy to use for requests.
|
|
221
|
-
* Available via `process.env.HTTP_PROXY` and `process.env.HTTPS_PROXY` as well - with a preference for the this config option when multiple are available.
|
|
222
|
-
* The {@link GaxiosOptions.agent `agent`} option overrides this.
|
|
223
|
-
*
|
|
224
|
-
* @see {@link GaxiosOptions.noProxy}
|
|
225
|
-
* @see {@link GaxiosOptions.agent}
|
|
226
|
-
*/
|
|
227
|
-
proxy?: string | URL;
|
|
228
|
-
/**
|
|
229
|
-
* A list for excluding traffic for proxies.
|
|
230
|
-
* Available via `process.env.NO_PROXY` as well as a common-separated list of strings - merged with any local `noProxy` rules.
|
|
231
|
-
*
|
|
232
|
-
* - When provided a string, it is matched by
|
|
233
|
-
* - Wildcard `*.` and `.` matching are available. (e.g. `.example.com` or `*.example.com`)
|
|
234
|
-
* - When provided a URL, it is matched by the `.origin` property.
|
|
235
|
-
* - For example, requesting `https://example.com` with the following `noProxy`s would result in a no proxy use:
|
|
236
|
-
* - new URL('https://example.com')
|
|
237
|
-
* - new URL('https://example.com:443')
|
|
238
|
-
* - The following would be used with a proxy:
|
|
239
|
-
* - new URL('http://example.com:80')
|
|
240
|
-
* - new URL('https://example.com:8443')
|
|
241
|
-
* - When provided a regular expression it is used to match the stringified URL
|
|
242
|
-
*
|
|
243
|
-
* @see {@link GaxiosOptions.proxy}
|
|
244
|
-
*/
|
|
245
|
-
noProxy?: (string | URL | RegExp)[];
|
|
246
|
-
/**
|
|
247
|
-
* An experimental error redactor.
|
|
248
|
-
*
|
|
249
|
-
* @remarks
|
|
250
|
-
*
|
|
251
|
-
* This does not replace the requirement for an active Data Loss Prevention (DLP) provider. For DLP suggestions, see:
|
|
252
|
-
* - https://cloud.google.com/sensitive-data-protection/docs/redacting-sensitive-data#dlp_deidentify_replace_infotype-nodejs
|
|
253
|
-
* - https://cloud.google.com/sensitive-data-protection/docs/infotypes-reference#credentials_and_secrets
|
|
254
|
-
*
|
|
255
|
-
* @experimental
|
|
256
|
-
*/
|
|
257
|
-
errorRedactor?: typeof defaultErrorRedactor | false;
|
|
258
|
-
}
|
|
259
|
-
interface GaxiosOptionsPrepared extends GaxiosOptions {
|
|
260
|
-
headers: Headers;
|
|
261
|
-
url: URL;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Gaxios retry configuration.
|
|
265
|
-
*/
|
|
266
|
-
interface RetryConfig {
|
|
267
|
-
/**
|
|
268
|
-
* The number of times to retry the request. Defaults to 3.
|
|
269
|
-
*/
|
|
270
|
-
retry?: number;
|
|
271
|
-
/**
|
|
272
|
-
* The number of retries already attempted.
|
|
273
|
-
*/
|
|
274
|
-
currentRetryAttempt?: number;
|
|
275
|
-
/**
|
|
276
|
-
* The amount of time to initially delay the retry, in ms. Defaults to 100ms.
|
|
277
|
-
*/
|
|
278
|
-
retryDelay?: number;
|
|
279
|
-
/**
|
|
280
|
-
* The HTTP Methods that will be automatically retried.
|
|
281
|
-
* Defaults to ['GET','PUT','HEAD','OPTIONS','DELETE']
|
|
282
|
-
*/
|
|
283
|
-
httpMethodsToRetry?: string[];
|
|
284
|
-
/**
|
|
285
|
-
* The HTTP response status codes that will automatically be retried.
|
|
286
|
-
* Defaults to: [[100, 199], [408, 408], [429, 429], [500, 599]]
|
|
287
|
-
*/
|
|
288
|
-
statusCodesToRetry?: number[][];
|
|
289
|
-
/**
|
|
290
|
-
* Function to invoke when a retry attempt is made.
|
|
291
|
-
*/
|
|
292
|
-
onRetryAttempt?: (err: GaxiosError) => Promise<void> | void;
|
|
293
|
-
/**
|
|
294
|
-
* Function to invoke which determines if you should retry
|
|
295
|
-
*/
|
|
296
|
-
shouldRetry?: (err: GaxiosError) => Promise<boolean> | boolean;
|
|
297
|
-
/**
|
|
298
|
-
* When there is no response, the number of retries to attempt. Defaults to 2.
|
|
299
|
-
*/
|
|
300
|
-
noResponseRetries?: number;
|
|
301
|
-
/**
|
|
302
|
-
* Function to invoke which returns a promise. After the promise resolves,
|
|
303
|
-
* the retry will be triggered. If provided, this will be used in-place of
|
|
304
|
-
* the `retryDelay`
|
|
305
|
-
*/
|
|
306
|
-
retryBackoff?: (err: GaxiosError, defaultBackoffMs: number) => Promise<void>;
|
|
307
|
-
/**
|
|
308
|
-
* Time that the initial request was made. Users should not set this directly.
|
|
309
|
-
*/
|
|
310
|
-
timeOfFirstRequest?: number;
|
|
311
|
-
/**
|
|
312
|
-
* The length of time to keep retrying in ms. The last sleep period will
|
|
313
|
-
* be shortened as necessary, so that the last retry runs at deadline (and not
|
|
314
|
-
* considerably beyond it). The total time starting from when the initial
|
|
315
|
-
* request is sent, after which an error will be returned, regardless of the
|
|
316
|
-
* retrying attempts made meanwhile. Defaults to Number.MAX_SAFE_INTEGER indicating to effectively
|
|
317
|
-
* ignore totalTimeout.
|
|
318
|
-
*/
|
|
319
|
-
totalTimeout?: number;
|
|
320
|
-
maxRetryDelay?: number;
|
|
321
|
-
retryDelayMultiplier?: number;
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* An experimental error redactor.
|
|
325
|
-
*
|
|
326
|
-
* @param config Config to potentially redact properties of
|
|
327
|
-
* @param response Config to potentially redact properties of
|
|
328
|
-
*
|
|
329
|
-
* @experimental
|
|
330
|
-
*/
|
|
331
|
-
declare function defaultErrorRedactor<O extends GaxiosOptionsPrepared, R extends GaxiosResponse<GaxiosResponseData>>(data: {
|
|
332
|
-
config?: O;
|
|
333
|
-
response?: R;
|
|
334
|
-
}): {
|
|
335
|
-
config?: O;
|
|
336
|
-
response?: R;
|
|
337
|
-
};
|
|
338
|
-
/**
|
|
339
|
-
* Interceptors that can be run for requests or responses. These interceptors run asynchronously.
|
|
340
|
-
*/
|
|
341
|
-
interface GaxiosInterceptor<T extends GaxiosOptionsPrepared | GaxiosResponse> {
|
|
342
|
-
/**
|
|
343
|
-
* Function to be run when applying an interceptor.
|
|
344
|
-
*
|
|
345
|
-
* @param {T} configOrResponse The current configuration or response.
|
|
346
|
-
* @returns {Promise<T>} Promise that resolves to the modified set of options or response.
|
|
347
|
-
*/
|
|
348
|
-
resolved?: (configOrResponse: T) => Promise<T>;
|
|
349
|
-
/**
|
|
350
|
-
* Function to be run if the previous call to resolved throws / rejects or the request results in an invalid status
|
|
351
|
-
* as determined by the call to validateStatus.
|
|
352
|
-
*
|
|
353
|
-
* @param {GaxiosError} err The error thrown from the previously called resolved function.
|
|
354
|
-
*/
|
|
355
|
-
rejected?: (err: GaxiosError) => void;
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Class to manage collections of GaxiosInterceptors for both requests and responses.
|
|
359
|
-
*/
|
|
360
|
-
declare class GaxiosInterceptorManager<T extends GaxiosOptionsPrepared | GaxiosResponse> extends Set<GaxiosInterceptor<T> | null> {}
|
|
361
|
-
/**
|
|
362
|
-
* An interface for enforcing `fetch`-type compliance.
|
|
363
|
-
*
|
|
364
|
-
* @remarks
|
|
365
|
-
*
|
|
366
|
-
* This provides type guarantees during build-time, ensuring the `fetch` method is 1:1
|
|
367
|
-
* compatible with the `fetch` API.
|
|
368
|
-
*/
|
|
369
|
-
interface FetchCompliance {
|
|
370
|
-
fetch: typeof fetch;
|
|
371
|
-
}
|
|
372
|
-
declare class Gaxios implements FetchCompliance {
|
|
373
|
-
#private;
|
|
374
|
-
protected agentCache: Map<string | URL, Agent | ((parsedUrl: URL) => Agent)>;
|
|
375
|
-
/**
|
|
376
|
-
* Default HTTP options that will be used for every HTTP request.
|
|
377
|
-
*/
|
|
378
|
-
defaults: GaxiosOptions;
|
|
379
|
-
/**
|
|
380
|
-
* Interceptors
|
|
381
|
-
*/
|
|
382
|
-
interceptors: {
|
|
383
|
-
request: GaxiosInterceptorManager<GaxiosOptionsPrepared>;
|
|
384
|
-
response: GaxiosInterceptorManager<GaxiosResponse>;
|
|
385
|
-
};
|
|
386
|
-
/**
|
|
387
|
-
* The Gaxios class is responsible for making HTTP requests.
|
|
388
|
-
* @param defaults The default set of options to be used for this instance.
|
|
389
|
-
*/
|
|
390
|
-
constructor(defaults?: GaxiosOptions);
|
|
391
|
-
/**
|
|
392
|
-
* A {@link fetch `fetch`} compliant API for {@link Gaxios}.
|
|
393
|
-
*
|
|
394
|
-
* @remarks
|
|
395
|
-
*
|
|
396
|
-
* This is useful as a drop-in replacement for `fetch` API usage.
|
|
397
|
-
*
|
|
398
|
-
* @example
|
|
399
|
-
*
|
|
400
|
-
* ```ts
|
|
401
|
-
* const gaxios = new Gaxios();
|
|
402
|
-
* const myFetch: typeof fetch = (...args) => gaxios.fetch(...args);
|
|
403
|
-
* await myFetch('https://example.com');
|
|
404
|
-
* ```
|
|
405
|
-
*
|
|
406
|
-
* @param args `fetch` API or `Gaxios#request` parameters
|
|
407
|
-
* @returns the {@link Response} with Gaxios-added properties
|
|
408
|
-
*/
|
|
409
|
-
fetch<T = unknown>(...args: Parameters<typeof fetch> | Parameters<Gaxios['request']>): GaxiosPromise<T>;
|
|
410
|
-
/**
|
|
411
|
-
* Perform an HTTP request with the given options.
|
|
412
|
-
* @param opts Set of HTTP options that will be used for this HTTP request.
|
|
413
|
-
*/
|
|
414
|
-
request<T = ReturnType<JSON['parse']>>(opts?: GaxiosOptions): GaxiosPromise<T>;
|
|
415
|
-
private _defaultAdapter;
|
|
416
|
-
/**
|
|
417
|
-
* Internal, retryable version of the `request` method.
|
|
418
|
-
* @param opts Set of HTTP options that will be used for this HTTP request.
|
|
419
|
-
*/
|
|
420
|
-
protected _request<T = ReturnType<JSON['parse']>>(opts: GaxiosOptionsPrepared): GaxiosPromise<T>;
|
|
421
|
-
private getResponseData;
|
|
422
|
-
/**
|
|
423
|
-
* By default, throw for any non-2xx status code
|
|
424
|
-
* @param status status code from the HTTP response
|
|
425
|
-
*/
|
|
426
|
-
private validateStatus;
|
|
427
|
-
/**
|
|
428
|
-
* Attempts to parse a response by looking at the Content-Type header.
|
|
429
|
-
* @param {Response} response the HTTP response.
|
|
430
|
-
* @returns a promise that resolves to the response data.
|
|
431
|
-
*/
|
|
432
|
-
private getResponseDataFromContentType;
|
|
433
|
-
/**
|
|
434
|
-
* Creates an async generator that yields the pieces of a multipart/related request body.
|
|
435
|
-
* This implementation follows the spec: https://www.ietf.org/rfc/rfc2387.txt. However, recursive
|
|
436
|
-
* multipart/related requests are not currently supported.
|
|
437
|
-
*
|
|
438
|
-
* @param {GaxiosMultipartOptions[]} multipartOptions the pieces to turn into a multipart/related body.
|
|
439
|
-
* @param {string} boundary the boundary string to be placed between each part.
|
|
440
|
-
*/
|
|
441
|
-
private getMultipartRequest;
|
|
442
|
-
/**
|
|
443
|
-
* Merges headers.
|
|
444
|
-
* If the base headers do not exist a new `Headers` object will be returned.
|
|
445
|
-
*
|
|
446
|
-
* @remarks
|
|
447
|
-
*
|
|
448
|
-
* Using this utility can be helpful when the headers are not known to exist:
|
|
449
|
-
* - if they exist as `Headers`, that instance will be used
|
|
450
|
-
* - it improves performance and allows users to use their existing references to their `Headers`
|
|
451
|
-
* - if they exist in another form (`HeadersInit`), they will be used to create a new `Headers` object
|
|
452
|
-
* - if the base headers do not exist a new `Headers` object will be created
|
|
453
|
-
*
|
|
454
|
-
* @param base headers to append/overwrite to
|
|
455
|
-
* @param append headers to append/overwrite with
|
|
456
|
-
* @returns the base headers instance with merged `Headers`
|
|
457
|
-
*/
|
|
458
|
-
static mergeHeaders(base?: HeadersInit$1, ...append: HeadersInit$1[]): Headers;
|
|
459
|
-
}
|
|
460
|
-
type HeadersInit$1 = ConstructorParameters<typeof Headers>[0];
|
|
461
|
-
/**
|
|
462
|
-
* The default instance used when the `request` method is directly
|
|
463
|
-
* invoked.
|
|
464
|
-
*/
|
|
465
|
-
declare const instance: Gaxios;
|
|
466
|
-
/**
|
|
467
|
-
* Make an HTTP request using the given options.
|
|
468
|
-
* @param opts Options for the request
|
|
469
|
-
*/
|
|
470
|
-
declare function request<T>(opts: GaxiosOptions): Promise<GaxiosResponse<T>>;
|
|
471
|
-
interface Credentials {
|
|
472
|
-
/**
|
|
473
|
-
* This field is only present if the access_type parameter was set to offline in the authentication request. For details, see Refresh tokens.
|
|
474
|
-
*/
|
|
475
|
-
refresh_token?: string | null;
|
|
476
|
-
/**
|
|
477
|
-
* The time in ms at which this token is thought to expire.
|
|
478
|
-
*/
|
|
479
|
-
expiry_date?: number | null;
|
|
480
|
-
/**
|
|
481
|
-
* A token that can be sent to a Google API.
|
|
482
|
-
*/
|
|
483
|
-
access_token?: string | null;
|
|
484
|
-
/**
|
|
485
|
-
* Identifies the type of token returned. At this time, this field always has the value Bearer.
|
|
486
|
-
*/
|
|
487
|
-
token_type?: string | null;
|
|
488
|
-
/**
|
|
489
|
-
* A JWT that contains identity information about the user that is digitally signed by Google.
|
|
490
|
-
*/
|
|
491
|
-
id_token?: string | null;
|
|
492
|
-
/**
|
|
493
|
-
* The scopes of access granted by the access_token expressed as a list of space-delimited, case-sensitive strings.
|
|
494
|
-
*/
|
|
495
|
-
scope?: string;
|
|
496
|
-
}
|
|
497
|
-
interface CredentialRequest {
|
|
498
|
-
/**
|
|
499
|
-
* This field is only present if the access_type parameter was set to offline in the authentication request. For details, see Refresh tokens.
|
|
500
|
-
*/
|
|
501
|
-
refresh_token?: string;
|
|
502
|
-
/**
|
|
503
|
-
* A token that can be sent to a Google API.
|
|
504
|
-
*/
|
|
505
|
-
access_token?: string;
|
|
506
|
-
/**
|
|
507
|
-
* Identifies the type of token returned. At this time, this field always has the value Bearer.
|
|
508
|
-
*/
|
|
509
|
-
token_type?: string;
|
|
510
|
-
/**
|
|
511
|
-
* The remaining lifetime of the access token in seconds.
|
|
512
|
-
*/
|
|
513
|
-
expires_in?: number;
|
|
514
|
-
/**
|
|
515
|
-
* A JWT that contains identity information about the user that is digitally signed by Google.
|
|
516
|
-
*/
|
|
517
|
-
id_token?: string;
|
|
518
|
-
/**
|
|
519
|
-
* The scopes of access granted by the access_token expressed as a list of space-delimited, case-sensitive strings.
|
|
520
|
-
*/
|
|
521
|
-
scope?: string;
|
|
522
|
-
}
|
|
523
|
-
interface JWTInput {
|
|
524
|
-
type?: string;
|
|
525
|
-
client_email?: string;
|
|
526
|
-
private_key?: string;
|
|
527
|
-
private_key_id?: string;
|
|
528
|
-
project_id?: string;
|
|
529
|
-
client_id?: string;
|
|
530
|
-
client_secret?: string;
|
|
531
|
-
refresh_token?: string;
|
|
532
|
-
quota_project_id?: string;
|
|
533
|
-
universe_domain?: string;
|
|
534
|
-
}
|
|
535
|
-
interface ImpersonatedJWTInput {
|
|
536
|
-
type?: string;
|
|
537
|
-
source_credentials?: JWTInput;
|
|
538
|
-
service_account_impersonation_url?: string;
|
|
539
|
-
delegates?: string[];
|
|
540
|
-
scopes?: string[];
|
|
541
|
-
}
|
|
542
|
-
interface CredentialBody {
|
|
543
|
-
client_email?: string;
|
|
544
|
-
private_key?: string;
|
|
545
|
-
universe_domain?: string;
|
|
546
|
-
}
|
|
547
|
-
interface JwkCertificate {
|
|
548
|
-
kty: string;
|
|
549
|
-
alg: string;
|
|
550
|
-
use?: string;
|
|
551
|
-
kid: string;
|
|
552
|
-
n: string;
|
|
553
|
-
e: string;
|
|
554
|
-
}
|
|
555
|
-
/**
|
|
556
|
-
* A utility for converting snake_case to camelCase.
|
|
557
|
-
*
|
|
558
|
-
* For, for example `my_snake_string` becomes `mySnakeString`.
|
|
559
|
-
*/
|
|
560
|
-
type SnakeToCamel<S> = S extends `${infer FirstWord}_${infer Remainder}` ? `${FirstWord}${Capitalize<SnakeToCamel<Remainder>>}` : S;
|
|
561
|
-
/**
|
|
562
|
-
* A utility for converting an type's keys from snake_case
|
|
563
|
-
* to camelCase, if the keys are strings.
|
|
564
|
-
*
|
|
565
|
-
* For example:
|
|
566
|
-
*
|
|
567
|
-
* ```ts
|
|
568
|
-
* {
|
|
569
|
-
* my_snake_string: boolean;
|
|
570
|
-
* myCamelString: string;
|
|
571
|
-
* my_snake_obj: {
|
|
572
|
-
* my_snake_obj_string: string;
|
|
573
|
-
* };
|
|
574
|
-
* }
|
|
575
|
-
* ```
|
|
576
|
-
*
|
|
577
|
-
* becomes:
|
|
578
|
-
*
|
|
579
|
-
* ```ts
|
|
580
|
-
* {
|
|
581
|
-
* mySnakeString: boolean;
|
|
582
|
-
* myCamelString: string;
|
|
583
|
-
* mySnakeObj: {
|
|
584
|
-
* mySnakeObjString: string;
|
|
585
|
-
* }
|
|
586
|
-
* }
|
|
587
|
-
* ```
|
|
588
|
-
*
|
|
589
|
-
* @remarks
|
|
590
|
-
*
|
|
591
|
-
* The generated documentation for the camelCase'd properties won't be available
|
|
592
|
-
* until {@link https://github.com/microsoft/TypeScript/issues/50715} has been
|
|
593
|
-
* resolved.
|
|
594
|
-
*/
|
|
595
|
-
type SnakeToCamelObject<T> = { [K in keyof T as SnakeToCamel<K>]: T[K] extends {} ? SnakeToCamelObject<T[K]> : T[K] };
|
|
596
|
-
/**
|
|
597
|
-
* A utility for adding camelCase versions of a type's snake_case keys, if the
|
|
598
|
-
* keys are strings, preserving any existing keys.
|
|
599
|
-
*
|
|
600
|
-
* For example:
|
|
601
|
-
*
|
|
602
|
-
* ```ts
|
|
603
|
-
* {
|
|
604
|
-
* my_snake_boolean: boolean;
|
|
605
|
-
* myCamelString: string;
|
|
606
|
-
* my_snake_obj: {
|
|
607
|
-
* my_snake_obj_string: string;
|
|
608
|
-
* };
|
|
609
|
-
* }
|
|
610
|
-
* ```
|
|
611
|
-
*
|
|
612
|
-
* becomes:
|
|
613
|
-
*
|
|
614
|
-
* ```ts
|
|
615
|
-
* {
|
|
616
|
-
* my_snake_boolean: boolean;
|
|
617
|
-
* mySnakeBoolean: boolean;
|
|
618
|
-
* myCamelString: string;
|
|
619
|
-
* my_snake_obj: {
|
|
620
|
-
* my_snake_obj_string: string;
|
|
621
|
-
* };
|
|
622
|
-
* mySnakeObj: {
|
|
623
|
-
* mySnakeObjString: string;
|
|
624
|
-
* }
|
|
625
|
-
* }
|
|
626
|
-
* ```
|
|
627
|
-
* @remarks
|
|
628
|
-
*
|
|
629
|
-
* The generated documentation for the camelCase'd properties won't be available
|
|
630
|
-
* until {@link https://github.com/microsoft/TypeScript/issues/50715} has been
|
|
631
|
-
* resolved.
|
|
632
|
-
*
|
|
633
|
-
* Tracking: {@link https://github.com/googleapis/google-auth-library-nodejs/issues/1686}
|
|
634
|
-
*/
|
|
635
|
-
type OriginalAndCamel<T> = { [K in keyof T as K | SnakeToCamel<K>]: T[K] extends {} ? OriginalAndCamel<T[K]> : T[K] };
|
|
636
|
-
/**
|
|
637
|
-
* An interface for enforcing `fetch`-type compliance.
|
|
638
|
-
*
|
|
639
|
-
* @remarks
|
|
640
|
-
*
|
|
641
|
-
* This provides type guarantees during build-time, ensuring the `fetch` method is 1:1
|
|
642
|
-
* compatible with the `Gaxios#fetch` API.
|
|
643
|
-
*/
|
|
644
|
-
interface GaxiosFetchCompliance {
|
|
645
|
-
fetch: typeof fetch | Gaxios['fetch'];
|
|
646
|
-
}
|
|
647
|
-
/**
|
|
648
|
-
* Easy access to symbol-indexed strings on config objects.
|
|
649
|
-
*/
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
* Base auth configurations (e.g. from JWT or `.json` files) with conventional
|
|
653
|
-
* camelCased options.
|
|
654
|
-
*
|
|
655
|
-
* @privateRemarks
|
|
656
|
-
*
|
|
657
|
-
* This interface is purposely not exported so that it can be removed once
|
|
658
|
-
* {@link https://github.com/microsoft/TypeScript/issues/50715} has been
|
|
659
|
-
* resolved. Then, we can use {@link OriginalAndCamel} to shrink this interface.
|
|
660
|
-
*
|
|
661
|
-
* Tracking: {@link https://github.com/googleapis/google-auth-library-nodejs/issues/1686}
|
|
662
|
-
*/
|
|
663
|
-
interface AuthJSONOptions {
|
|
664
|
-
/**
|
|
665
|
-
* The project ID corresponding to the current credentials if available.
|
|
666
|
-
*/
|
|
667
|
-
project_id: string | null;
|
|
668
|
-
/**
|
|
669
|
-
* An alias for {@link AuthJSONOptions.project_id `project_id`}.
|
|
670
|
-
*/
|
|
671
|
-
projectId: AuthJSONOptions['project_id'];
|
|
672
|
-
/**
|
|
673
|
-
* The quota project ID. The quota project can be used by client libraries for the billing purpose.
|
|
674
|
-
* See {@link https://cloud.google.com/docs/quota Working with quotas}
|
|
675
|
-
*/
|
|
676
|
-
quota_project_id: string;
|
|
677
|
-
/**
|
|
678
|
-
* An alias for {@link AuthJSONOptions.quota_project_id `quota_project_id`}.
|
|
679
|
-
*/
|
|
680
|
-
quotaProjectId: AuthJSONOptions['quota_project_id'];
|
|
681
|
-
/**
|
|
682
|
-
* The default service domain for a given Cloud universe.
|
|
683
|
-
*
|
|
684
|
-
* @example
|
|
685
|
-
* 'googleapis.com'
|
|
686
|
-
*/
|
|
687
|
-
universe_domain: string;
|
|
688
|
-
/**
|
|
689
|
-
* An alias for {@link AuthJSONOptions.universe_domain `universe_domain`}.
|
|
690
|
-
*/
|
|
691
|
-
universeDomain: AuthJSONOptions['universe_domain'];
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* Base `AuthClient` configuration.
|
|
695
|
-
*
|
|
696
|
-
* The camelCased options are aliases of the snake_cased options, supporting both
|
|
697
|
-
* JSON API and JS conventions.
|
|
698
|
-
*/
|
|
699
|
-
interface AuthClientOptions extends Partial<OriginalAndCamel<AuthJSONOptions>> {
|
|
700
|
-
/**
|
|
701
|
-
* An API key to use, optional.
|
|
702
|
-
*/
|
|
703
|
-
apiKey?: string;
|
|
704
|
-
credentials?: Credentials;
|
|
705
|
-
/**
|
|
706
|
-
* The {@link Gaxios `Gaxios`} instance used for making requests.
|
|
707
|
-
*
|
|
708
|
-
* @see {@link AuthClientOptions.useAuthRequestParameters}
|
|
709
|
-
*/
|
|
710
|
-
transporter?: Gaxios;
|
|
711
|
-
/**
|
|
712
|
-
* Provides default options to the transporter, such as {@link GaxiosOptions.agent `agent`} or
|
|
713
|
-
* {@link GaxiosOptions.retryConfig `retryConfig`}.
|
|
714
|
-
*
|
|
715
|
-
* This option is ignored if {@link AuthClientOptions.transporter `gaxios`} has been provided
|
|
716
|
-
*/
|
|
717
|
-
transporterOptions?: GaxiosOptions;
|
|
718
|
-
/**
|
|
719
|
-
* The expiration threshold in milliseconds before forcing token refresh of
|
|
720
|
-
* unexpired tokens.
|
|
721
|
-
*/
|
|
722
|
-
eagerRefreshThresholdMillis?: number;
|
|
723
|
-
/**
|
|
724
|
-
* Whether to attempt to refresh tokens on status 401/403 responses
|
|
725
|
-
* even if an attempt is made to refresh the token preemptively based
|
|
726
|
-
* on the expiry_date.
|
|
727
|
-
*/
|
|
728
|
-
forceRefreshOnFailure?: boolean;
|
|
729
|
-
/**
|
|
730
|
-
* Enables/disables the adding of the AuthClient's default interceptor.
|
|
731
|
-
*
|
|
732
|
-
* @see {@link AuthClientOptions.transporter}
|
|
733
|
-
*
|
|
734
|
-
* @remarks
|
|
735
|
-
*
|
|
736
|
-
* Disabling is useful for debugging and experimentation.
|
|
737
|
-
*
|
|
738
|
-
* @default true
|
|
739
|
-
*/
|
|
740
|
-
useAuthRequestParameters?: boolean;
|
|
741
|
-
}
|
|
742
|
-
/**
|
|
743
|
-
* The default cloud universe
|
|
744
|
-
*
|
|
745
|
-
* @see {@link AuthJSONOptions.universe_domain}
|
|
746
|
-
*/
|
|
747
|
-
declare const DEFAULT_UNIVERSE = "googleapis.com";
|
|
748
|
-
/**
|
|
749
|
-
* Defines the root interface for all clients that generate credentials
|
|
750
|
-
* for calling Google APIs. All clients should implement this interface.
|
|
751
|
-
*/
|
|
752
|
-
interface CredentialsClient {
|
|
753
|
-
projectId?: AuthClientOptions['projectId'];
|
|
754
|
-
eagerRefreshThresholdMillis: NonNullable<AuthClientOptions['eagerRefreshThresholdMillis']>;
|
|
755
|
-
forceRefreshOnFailure: NonNullable<AuthClientOptions['forceRefreshOnFailure']>;
|
|
756
|
-
/**
|
|
757
|
-
* @return A promise that resolves with the current GCP access token
|
|
758
|
-
* response. If the current credential is expired, a new one is retrieved.
|
|
759
|
-
*/
|
|
760
|
-
getAccessToken(): Promise<GetAccessTokenResponse>;
|
|
761
|
-
/**
|
|
762
|
-
* The main authentication interface. It takes an optional url which when
|
|
763
|
-
* present is the endpoint being accessed, and returns a Promise which
|
|
764
|
-
* resolves with authorization header fields.
|
|
765
|
-
*
|
|
766
|
-
* The result has the form:
|
|
767
|
-
* { authorization: 'Bearer <access_token_value>' }
|
|
768
|
-
* @param url The URI being authorized.
|
|
769
|
-
*/
|
|
770
|
-
getRequestHeaders(url?: string | URL): Promise<Headers>;
|
|
771
|
-
/**
|
|
772
|
-
* Provides an alternative Gaxios request implementation with auth credentials
|
|
773
|
-
*/
|
|
774
|
-
request<T>(opts: GaxiosOptions): GaxiosPromise<T>;
|
|
775
|
-
/**
|
|
776
|
-
* Sets the auth credentials.
|
|
777
|
-
*/
|
|
778
|
-
setCredentials(credentials: Credentials): void;
|
|
779
|
-
/**
|
|
780
|
-
* Subscribes a listener to the tokens event triggered when a token is
|
|
781
|
-
* generated.
|
|
782
|
-
*
|
|
783
|
-
* @param event The tokens event to subscribe to.
|
|
784
|
-
* @param listener The listener that triggers on event trigger.
|
|
785
|
-
* @return The current client instance.
|
|
786
|
-
*/
|
|
787
|
-
on(event: 'tokens', listener: (tokens: Credentials) => void): this;
|
|
788
|
-
}
|
|
789
|
-
declare interface AuthClient {
|
|
790
|
-
on(event: 'tokens', listener: (tokens: Credentials) => void): this;
|
|
791
|
-
}
|
|
792
|
-
/**
|
|
793
|
-
* The base of all Auth Clients.
|
|
794
|
-
*/
|
|
795
|
-
declare abstract class AuthClient extends EventEmitter implements CredentialsClient, GaxiosFetchCompliance {
|
|
796
|
-
apiKey?: string;
|
|
797
|
-
projectId?: string | null;
|
|
798
|
-
/**
|
|
799
|
-
* The quota project ID. The quota project can be used by client libraries for the billing purpose.
|
|
800
|
-
* See {@link https://cloud.google.com/docs/quota Working with quotas}
|
|
801
|
-
*/
|
|
802
|
-
quotaProjectId?: string;
|
|
803
|
-
/**
|
|
804
|
-
* The {@link Gaxios `Gaxios`} instance used for making requests.
|
|
805
|
-
*/
|
|
806
|
-
transporter: Gaxios;
|
|
807
|
-
credentials: Credentials;
|
|
808
|
-
eagerRefreshThresholdMillis: number;
|
|
809
|
-
forceRefreshOnFailure: boolean;
|
|
810
|
-
universeDomain: string;
|
|
811
|
-
/**
|
|
812
|
-
* Symbols that can be added to GaxiosOptions to specify the method name that is
|
|
813
|
-
* making an RPC call, for logging purposes, as well as a string ID that can be
|
|
814
|
-
* used to correlate calls and responses.
|
|
815
|
-
*/
|
|
816
|
-
static readonly RequestMethodNameSymbol: unique symbol;
|
|
817
|
-
static readonly RequestLogIdSymbol: unique symbol;
|
|
818
|
-
constructor(opts?: AuthClientOptions);
|
|
819
|
-
/**
|
|
820
|
-
* A {@link fetch `fetch`} compliant API for {@link AuthClient}.
|
|
821
|
-
*
|
|
822
|
-
* @see {@link AuthClient.request} for the classic method.
|
|
823
|
-
*
|
|
824
|
-
* @remarks
|
|
825
|
-
*
|
|
826
|
-
* This is useful as a drop-in replacement for `fetch` API usage.
|
|
827
|
-
*
|
|
828
|
-
* @example
|
|
829
|
-
*
|
|
830
|
-
* ```ts
|
|
831
|
-
* const authClient = new AuthClient();
|
|
832
|
-
* const fetchWithAuthClient: typeof fetch = (...args) => authClient.fetch(...args);
|
|
833
|
-
* await fetchWithAuthClient('https://example.com');
|
|
834
|
-
* ```
|
|
835
|
-
*
|
|
836
|
-
* @param args `fetch` API or {@link Gaxios.fetch `Gaxios#fetch`} parameters
|
|
837
|
-
* @returns the {@link GaxiosResponse} with Gaxios-added properties
|
|
838
|
-
*/
|
|
839
|
-
fetch<T>(...args: Parameters<Gaxios['fetch']>): GaxiosPromise<T>;
|
|
840
|
-
/**
|
|
841
|
-
* The public request API in which credentials may be added to the request.
|
|
842
|
-
*
|
|
843
|
-
* @see {@link AuthClient.fetch} for the modern method.
|
|
844
|
-
*
|
|
845
|
-
* @param options options for `gaxios`
|
|
846
|
-
*/
|
|
847
|
-
abstract request<T>(options: GaxiosOptions): GaxiosPromise<T>;
|
|
848
|
-
/**
|
|
849
|
-
* The main authentication interface. It takes an optional url which when
|
|
850
|
-
* present is the endpoint being accessed, and returns a Promise which
|
|
851
|
-
* resolves with authorization header fields.
|
|
852
|
-
*
|
|
853
|
-
* The result has the form:
|
|
854
|
-
* ```ts
|
|
855
|
-
* new Headers({'authorization': 'Bearer <access_token_value>'});
|
|
856
|
-
* ```
|
|
857
|
-
*
|
|
858
|
-
* @param url The URI being authorized.
|
|
859
|
-
*/
|
|
860
|
-
abstract getRequestHeaders(url?: string | URL): Promise<Headers>;
|
|
861
|
-
/**
|
|
862
|
-
* @return A promise that resolves with the current GCP access token
|
|
863
|
-
* response. If the current credential is expired, a new one is retrieved.
|
|
864
|
-
*/
|
|
865
|
-
abstract getAccessToken(): Promise<{
|
|
866
|
-
token?: string | null;
|
|
867
|
-
res?: GaxiosResponse | null;
|
|
868
|
-
}>;
|
|
869
|
-
/**
|
|
870
|
-
* Sets the auth credentials.
|
|
871
|
-
*/
|
|
872
|
-
setCredentials(credentials: Credentials): void;
|
|
873
|
-
/**
|
|
874
|
-
* Append additional headers, e.g., x-goog-user-project, shared across the
|
|
875
|
-
* classes inheriting AuthClient. This method should be used by any method
|
|
876
|
-
* that overrides getRequestMetadataAsync(), which is a shared helper for
|
|
877
|
-
* setting request information in both gRPC and HTTP API calls.
|
|
878
|
-
*
|
|
879
|
-
* @param headers object to append additional headers to.
|
|
880
|
-
*/
|
|
881
|
-
protected addSharedMetadataHeaders(headers: Headers): Headers;
|
|
882
|
-
/**
|
|
883
|
-
* Adds the `x-goog-user-project` and `authorization` headers to the target Headers
|
|
884
|
-
* object, if they exist on the source.
|
|
885
|
-
*
|
|
886
|
-
* @param target the headers to target
|
|
887
|
-
* @param source the headers to source from
|
|
888
|
-
* @returns the target headers
|
|
889
|
-
*/
|
|
890
|
-
protected addUserProjectAndAuthHeaders<T extends Headers>(target: T, source: Headers): T;
|
|
891
|
-
static log: _$google_logging_utils0.AdhocDebugLogFunction;
|
|
892
|
-
static readonly DEFAULT_REQUEST_INTERCEPTOR: Parameters<Gaxios['interceptors']['request']['add']>[0];
|
|
893
|
-
static readonly DEFAULT_RESPONSE_INTERCEPTOR: Parameters<Gaxios['interceptors']['response']['add']>[0];
|
|
894
|
-
/**
|
|
895
|
-
* Sets the method name that is making a Gaxios request, so that logging may tag
|
|
896
|
-
* log lines with the operation.
|
|
897
|
-
* @param config A Gaxios request config
|
|
898
|
-
* @param methodName The method name making the call
|
|
899
|
-
*/
|
|
900
|
-
static setMethodName(config: GaxiosOptions, methodName: string): void;
|
|
901
|
-
/**
|
|
902
|
-
* Retry config for Auth-related requests.
|
|
903
|
-
*
|
|
904
|
-
* @remarks
|
|
905
|
-
*
|
|
906
|
-
* This is not a part of the default {@link AuthClient.transporter transporter/gaxios}
|
|
907
|
-
* config as some downstream APIs would prefer if customers explicitly enable retries,
|
|
908
|
-
* such as GCS.
|
|
909
|
-
*/
|
|
910
|
-
protected static get RETRY_CONFIG(): GaxiosOptions;
|
|
911
|
-
}
|
|
912
|
-
type HeadersInit = ConstructorParameters<typeof Headers>[0];
|
|
913
|
-
interface GetAccessTokenResponse {
|
|
914
|
-
token?: string | null;
|
|
915
|
-
res?: GaxiosResponse | null;
|
|
916
|
-
}
|
|
917
|
-
/**
|
|
918
|
-
* @deprecated - use the Promise API instead
|
|
919
|
-
*/
|
|
920
|
-
interface BodyResponseCallback<T> {
|
|
921
|
-
(err: Error | null, res?: GaxiosResponse<T> | null): void;
|
|
922
|
-
}
|
|
923
|
-
declare class LoginTicket {
|
|
924
|
-
private envelope?;
|
|
925
|
-
private payload?;
|
|
926
|
-
/**
|
|
927
|
-
* Create a simple class to extract user ID from an ID Token
|
|
928
|
-
*
|
|
929
|
-
* @param {string} env Envelope of the jwt
|
|
930
|
-
* @param {TokenPayload} pay Payload of the jwt
|
|
931
|
-
* @constructor
|
|
932
|
-
*/
|
|
933
|
-
constructor(env?: string, pay?: TokenPayload);
|
|
934
|
-
getEnvelope(): string | undefined;
|
|
935
|
-
getPayload(): TokenPayload | undefined;
|
|
936
|
-
/**
|
|
937
|
-
* Create a simple class to extract user ID from an ID Token
|
|
938
|
-
*
|
|
939
|
-
* @return The user ID
|
|
940
|
-
*/
|
|
941
|
-
getUserId(): string | null;
|
|
942
|
-
/**
|
|
943
|
-
* Returns attributes from the login ticket. This can contain
|
|
944
|
-
* various information about the user session.
|
|
945
|
-
*
|
|
946
|
-
* @return The envelope and payload
|
|
947
|
-
*/
|
|
948
|
-
getAttributes(): {
|
|
949
|
-
envelope: string | undefined;
|
|
950
|
-
payload: TokenPayload | undefined;
|
|
951
|
-
};
|
|
952
|
-
}
|
|
953
|
-
interface TokenPayload {
|
|
954
|
-
/**
|
|
955
|
-
* The Issuer Identifier for the Issuer of the response. Always
|
|
956
|
-
* https://accounts.google.com or accounts.google.com for Google ID tokens.
|
|
957
|
-
*/
|
|
958
|
-
iss: string;
|
|
959
|
-
/**
|
|
960
|
-
* Access token hash. Provides validation that the access token is tied to the
|
|
961
|
-
* identity token. If the ID token is issued with an access token in the
|
|
962
|
-
* server flow, this is always included. This can be used as an alternate
|
|
963
|
-
* mechanism to protect against cross-site request forgery attacks, but if you
|
|
964
|
-
* follow Step 1 and Step 3 it is not necessary to verify the access token.
|
|
965
|
-
*/
|
|
966
|
-
at_hash?: string;
|
|
967
|
-
/**
|
|
968
|
-
* True if the user's e-mail address has been verified; otherwise false.
|
|
969
|
-
*/
|
|
970
|
-
email_verified?: boolean;
|
|
971
|
-
/**
|
|
972
|
-
* An identifier for the user, unique among all Google accounts and never
|
|
973
|
-
* reused. A Google account can have multiple emails at different points in
|
|
974
|
-
* time, but the sub value is never changed. Use sub within your application
|
|
975
|
-
* as the unique-identifier key for the user.
|
|
976
|
-
*/
|
|
977
|
-
sub: string;
|
|
978
|
-
/**
|
|
979
|
-
* The client_id of the authorized presenter. This claim is only needed when
|
|
980
|
-
* the party requesting the ID token is not the same as the audience of the ID
|
|
981
|
-
* token. This may be the case at Google for hybrid apps where a web
|
|
982
|
-
* application and Android app have a different client_id but share the same
|
|
983
|
-
* project.
|
|
984
|
-
*/
|
|
985
|
-
azp?: string;
|
|
986
|
-
/**
|
|
987
|
-
* The user's email address. This may not be unique and is not suitable for
|
|
988
|
-
* use as a primary key. Provided only if your scope included the string
|
|
989
|
-
* "email".
|
|
990
|
-
*/
|
|
991
|
-
email?: string;
|
|
992
|
-
/**
|
|
993
|
-
* The URL of the user's profile page. Might be provided when:
|
|
994
|
-
* - The request scope included the string "profile"
|
|
995
|
-
* - The ID token is returned from a token refresh
|
|
996
|
-
* - When profile claims are present, you can use them to update your app's
|
|
997
|
-
* user records. Note that this claim is never guaranteed to be present.
|
|
998
|
-
*/
|
|
999
|
-
profile?: string;
|
|
1000
|
-
/**
|
|
1001
|
-
* The URL of the user's profile picture. Might be provided when:
|
|
1002
|
-
* - The request scope included the string "profile"
|
|
1003
|
-
* - The ID token is returned from a token refresh
|
|
1004
|
-
* - When picture claims are present, you can use them to update your app's
|
|
1005
|
-
* user records. Note that this claim is never guaranteed to be present.
|
|
1006
|
-
*/
|
|
1007
|
-
picture?: string;
|
|
1008
|
-
/**
|
|
1009
|
-
* The user's full name, in a displayable form. Might be provided when:
|
|
1010
|
-
* - The request scope included the string "profile"
|
|
1011
|
-
* - The ID token is returned from a token refresh
|
|
1012
|
-
* - When name claims are present, you can use them to update your app's user
|
|
1013
|
-
* records. Note that this claim is never guaranteed to be present.
|
|
1014
|
-
*/
|
|
1015
|
-
name?: string;
|
|
1016
|
-
/**
|
|
1017
|
-
* The user's given name, in a displayable form. Might be provided when:
|
|
1018
|
-
* - The request scope included the string "profile"
|
|
1019
|
-
* - The ID token is returned from a token refresh
|
|
1020
|
-
* - When name claims are present, you can use them to update your app's user
|
|
1021
|
-
* records. Note that this claim is never guaranteed to be present.
|
|
1022
|
-
*/
|
|
1023
|
-
given_name?: string;
|
|
1024
|
-
/**
|
|
1025
|
-
* The user's family name, in a displayable form. Might be provided when:
|
|
1026
|
-
* - The request scope included the string "profile"
|
|
1027
|
-
* - The ID token is returned from a token refresh
|
|
1028
|
-
* - When name claims are present, you can use them to update your app's user
|
|
1029
|
-
* records. Note that this claim is never guaranteed to be present.
|
|
1030
|
-
*/
|
|
1031
|
-
family_name?: string;
|
|
1032
|
-
/**
|
|
1033
|
-
* Identifies the audience that this ID token is intended for. It must be one
|
|
1034
|
-
* of the OAuth 2.0 client IDs of your application.
|
|
1035
|
-
*/
|
|
1036
|
-
aud: string;
|
|
1037
|
-
/**
|
|
1038
|
-
* The time the ID token was issued, represented in Unix time (integer
|
|
1039
|
-
* seconds).
|
|
1040
|
-
*/
|
|
1041
|
-
iat: number;
|
|
1042
|
-
/**
|
|
1043
|
-
* The time the ID token expires, represented in Unix time (integer seconds).
|
|
1044
|
-
*/
|
|
1045
|
-
exp: number;
|
|
1046
|
-
/**
|
|
1047
|
-
* The value of the nonce supplied by your app in the authentication request.
|
|
1048
|
-
* You should enforce protection against replay attacks by ensuring it is
|
|
1049
|
-
* presented only once.
|
|
1050
|
-
*/
|
|
1051
|
-
nonce?: string;
|
|
1052
|
-
/**
|
|
1053
|
-
* The hosted G Suite domain of the user. Provided only if the user belongs to
|
|
1054
|
-
* a hosted domain.
|
|
1055
|
-
*/
|
|
1056
|
-
hd?: string;
|
|
1057
|
-
/**
|
|
1058
|
-
* The user's locale, represented by a BCP 47 language tag.
|
|
1059
|
-
* Might be provided when a name claim is present.
|
|
1060
|
-
*/
|
|
1061
|
-
locale?: string;
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* The results from the `generateCodeVerifierAsync` method. To learn more,
|
|
1065
|
-
* See the sample:
|
|
1066
|
-
* https://github.com/googleapis/google-auth-library-nodejs/blob/main/samples/oauth2-codeVerifier.js
|
|
1067
|
-
*/
|
|
1068
|
-
interface CodeVerifierResults {
|
|
1069
|
-
/**
|
|
1070
|
-
* The code verifier that will be used when calling `getToken` to obtain a new
|
|
1071
|
-
* access token.
|
|
1072
|
-
*/
|
|
1073
|
-
codeVerifier: string;
|
|
1074
|
-
/**
|
|
1075
|
-
* The code_challenge that should be sent with the `generateAuthUrl` call
|
|
1076
|
-
* to obtain a verifiable authentication url.
|
|
1077
|
-
*/
|
|
1078
|
-
codeChallenge?: string;
|
|
1079
|
-
}
|
|
1080
|
-
interface Certificates {
|
|
1081
|
-
[index: string]: string | JwkCertificate;
|
|
1082
|
-
}
|
|
1083
|
-
interface PublicKeys {
|
|
1084
|
-
[index: string]: string;
|
|
1085
|
-
}
|
|
1086
|
-
declare enum CodeChallengeMethod {
|
|
1087
|
-
Plain = "plain",
|
|
1088
|
-
S256 = "S256",
|
|
1089
|
-
}
|
|
1090
|
-
declare enum CertificateFormat {
|
|
1091
|
-
PEM = "PEM",
|
|
1092
|
-
JWK = "JWK",
|
|
1093
|
-
}
|
|
1094
|
-
/**
|
|
1095
|
-
* The client authentication type. Supported values are basic, post, and none.
|
|
1096
|
-
* https://datatracker.ietf.org/doc/html/rfc7591#section-2
|
|
1097
|
-
*/
|
|
1098
|
-
declare enum ClientAuthentication$1 {
|
|
1099
|
-
ClientSecretPost = "ClientSecretPost",
|
|
1100
|
-
ClientSecretBasic = "ClientSecretBasic",
|
|
1101
|
-
None = "None",
|
|
1102
|
-
}
|
|
1103
|
-
interface GetTokenOptions$1 {
|
|
1104
|
-
code: string;
|
|
1105
|
-
codeVerifier?: string;
|
|
1106
|
-
/**
|
|
1107
|
-
* The client ID for your application. The value passed into the constructor
|
|
1108
|
-
* will be used if not provided. Must match any client_id option passed to
|
|
1109
|
-
* a corresponding call to generateAuthUrl.
|
|
1110
|
-
*/
|
|
1111
|
-
client_id?: string;
|
|
1112
|
-
/**
|
|
1113
|
-
* Determines where the API server redirects the user after the user
|
|
1114
|
-
* completes the authorization flow. The value passed into the constructor
|
|
1115
|
-
* will be used if not provided. Must match any redirect_uri option passed to
|
|
1116
|
-
* a corresponding call to generateAuthUrl.
|
|
1117
|
-
*/
|
|
1118
|
-
redirect_uri?: string;
|
|
1119
|
-
}
|
|
1120
|
-
interface TokenInfo {
|
|
1121
|
-
/**
|
|
1122
|
-
* The application that is the intended user of the access token.
|
|
1123
|
-
*/
|
|
1124
|
-
aud: string;
|
|
1125
|
-
/**
|
|
1126
|
-
* This value lets you correlate profile information from multiple Google
|
|
1127
|
-
* APIs. It is only present in the response if you included the profile scope
|
|
1128
|
-
* in your request in step 1. The field value is an immutable identifier for
|
|
1129
|
-
* the logged-in user that can be used to create and manage user sessions in
|
|
1130
|
-
* your application. The identifier is the same regardless of which client ID
|
|
1131
|
-
* is used to retrieve it. This enables multiple applications in the same
|
|
1132
|
-
* organization to correlate profile information.
|
|
1133
|
-
*/
|
|
1134
|
-
user_id?: string;
|
|
1135
|
-
/**
|
|
1136
|
-
* An array of scopes that the user granted access to.
|
|
1137
|
-
*/
|
|
1138
|
-
scopes: string[];
|
|
1139
|
-
/**
|
|
1140
|
-
* The datetime when the token becomes invalid.
|
|
1141
|
-
*/
|
|
1142
|
-
expiry_date: number;
|
|
1143
|
-
/**
|
|
1144
|
-
* An identifier for the user, unique among all Google accounts and never
|
|
1145
|
-
* reused. A Google account can have multiple emails at different points in
|
|
1146
|
-
* time, but the sub value is never changed. Use sub within your application
|
|
1147
|
-
* as the unique-identifier key for the user.
|
|
1148
|
-
*/
|
|
1149
|
-
sub?: string;
|
|
1150
|
-
/**
|
|
1151
|
-
* The client_id of the authorized presenter. This claim is only needed when
|
|
1152
|
-
* the party requesting the ID token is not the same as the audience of the ID
|
|
1153
|
-
* token. This may be the case at Google for hybrid apps where a web
|
|
1154
|
-
* application and Android app have a different client_id but share the same
|
|
1155
|
-
* project.
|
|
1156
|
-
*/
|
|
1157
|
-
azp?: string;
|
|
1158
|
-
/**
|
|
1159
|
-
* Indicates whether your application can refresh access tokens
|
|
1160
|
-
* when the user is not present at the browser. Valid parameter values are
|
|
1161
|
-
* 'online', which is the default value, and 'offline'. Set the value to
|
|
1162
|
-
* 'offline' if your application needs to refresh access tokens when the user
|
|
1163
|
-
* is not present at the browser. This value instructs the Google
|
|
1164
|
-
* authorization server to return a refresh token and an access token the
|
|
1165
|
-
* first time that your application exchanges an authorization code for
|
|
1166
|
-
* tokens.
|
|
1167
|
-
*/
|
|
1168
|
-
access_type?: string;
|
|
1169
|
-
/**
|
|
1170
|
-
* The user's email address. This value may not be unique to this user and
|
|
1171
|
-
* is not suitable for use as a primary key. Provided only if your scope
|
|
1172
|
-
* included the email scope value.
|
|
1173
|
-
*/
|
|
1174
|
-
email?: string;
|
|
1175
|
-
/**
|
|
1176
|
-
* True if the user's e-mail address has been verified; otherwise false.
|
|
1177
|
-
*/
|
|
1178
|
-
email_verified?: boolean;
|
|
1179
|
-
}
|
|
1180
|
-
interface GenerateAuthUrlOpts {
|
|
1181
|
-
/**
|
|
1182
|
-
* Recommended. Indicates whether your application can refresh access tokens
|
|
1183
|
-
* when the user is not present at the browser. Valid parameter values are
|
|
1184
|
-
* 'online', which is the default value, and 'offline'. Set the value to
|
|
1185
|
-
* 'offline' if your application needs to refresh access tokens when the user
|
|
1186
|
-
* is not present at the browser. This value instructs the Google
|
|
1187
|
-
* authorization server to return a refresh token and an access token the
|
|
1188
|
-
* first time that your application exchanges an authorization code for
|
|
1189
|
-
* tokens.
|
|
1190
|
-
*/
|
|
1191
|
-
access_type?: string;
|
|
1192
|
-
/**
|
|
1193
|
-
* The hd (hosted domain) parameter streamlines the login process for G Suite
|
|
1194
|
-
* hosted accounts. By including the domain of the G Suite user (for example,
|
|
1195
|
-
* mycollege.edu), you can indicate that the account selection UI should be
|
|
1196
|
-
* optimized for accounts at that domain. To optimize for G Suite accounts
|
|
1197
|
-
* generally instead of just one domain, use an asterisk: hd=*.
|
|
1198
|
-
* Don't rely on this UI optimization to control who can access your app,
|
|
1199
|
-
* as client-side requests can be modified. Be sure to validate that the
|
|
1200
|
-
* returned ID token has an hd claim value that matches what you expect
|
|
1201
|
-
* (e.g. mycolledge.edu). Unlike the request parameter, the ID token claim is
|
|
1202
|
-
* contained within a security token from Google, so the value can be trusted.
|
|
1203
|
-
*/
|
|
1204
|
-
hd?: string;
|
|
1205
|
-
/**
|
|
1206
|
-
* The 'response_type' will always be set to 'CODE'.
|
|
1207
|
-
*/
|
|
1208
|
-
response_type?: string;
|
|
1209
|
-
/**
|
|
1210
|
-
* The client ID for your application. The value passed into the constructor
|
|
1211
|
-
* will be used if not provided. You can find this value in the API Console.
|
|
1212
|
-
*/
|
|
1213
|
-
client_id?: string;
|
|
1214
|
-
/**
|
|
1215
|
-
* Determines where the API server redirects the user after the user
|
|
1216
|
-
* completes the authorization flow. The value must exactly match one of the
|
|
1217
|
-
* 'redirect_uri' values listed for your project in the API Console. Note that
|
|
1218
|
-
* the http or https scheme, case, and trailing slash ('/') must all match.
|
|
1219
|
-
* The value passed into the constructor will be used if not provided.
|
|
1220
|
-
*/
|
|
1221
|
-
redirect_uri?: string;
|
|
1222
|
-
/**
|
|
1223
|
-
* Required. A space-delimited list of scopes that identify the resources that
|
|
1224
|
-
* your application could access on the user's behalf. These values inform the
|
|
1225
|
-
* consent screen that Google displays to the user. Scopes enable your
|
|
1226
|
-
* application to only request access to the resources that it needs while
|
|
1227
|
-
* also enabling users to control the amount of access that they grant to your
|
|
1228
|
-
* application. Thus, there is an inverse relationship between the number of
|
|
1229
|
-
* scopes requested and the likelihood of obtaining user consent. The
|
|
1230
|
-
* OAuth 2.0 API Scopes document provides a full list of scopes that you might
|
|
1231
|
-
* use to access Google APIs. We recommend that your application request
|
|
1232
|
-
* access to authorization scopes in context whenever possible. By requesting
|
|
1233
|
-
* access to user data in context, via incremental authorization, you help
|
|
1234
|
-
* users to more easily understand why your application needs the access it is
|
|
1235
|
-
* requesting.
|
|
1236
|
-
*/
|
|
1237
|
-
scope?: string[] | string;
|
|
1238
|
-
/**
|
|
1239
|
-
* Recommended. Specifies any string value that your application uses to
|
|
1240
|
-
* maintain state between your authorization request and the authorization
|
|
1241
|
-
* server's response. The server returns the exact value that you send as a
|
|
1242
|
-
* name=value pair in the hash (#) fragment of the 'redirect_uri' after the
|
|
1243
|
-
* user consents to or denies your application's access request. You can use
|
|
1244
|
-
* this parameter for several purposes, such as directing the user to the
|
|
1245
|
-
* correct resource in your application, sending nonces, and mitigating
|
|
1246
|
-
* cross-site request forgery. Since your redirect_uri can be guessed, using a
|
|
1247
|
-
* state value can increase your assurance that an incoming connection is the
|
|
1248
|
-
* result of an authentication request. If you generate a random string or
|
|
1249
|
-
* encode the hash of a cookie or another value that captures the client's
|
|
1250
|
-
* state, you can validate the response to additionally ensure that the
|
|
1251
|
-
* request and response originated in the same browser, providing protection
|
|
1252
|
-
* against attacks such as cross-site request forgery. See the OpenID Connect
|
|
1253
|
-
* documentation for an example of how to create and confirm a state token.
|
|
1254
|
-
*/
|
|
1255
|
-
state?: string;
|
|
1256
|
-
/**
|
|
1257
|
-
* Optional. Enables applications to use incremental authorization to request
|
|
1258
|
-
* access to additional scopes in context. If you set this parameter's value
|
|
1259
|
-
* to true and the authorization request is granted, then the new access token
|
|
1260
|
-
* will also cover any scopes to which the user previously granted the
|
|
1261
|
-
* application access. See the incremental authorization section for examples.
|
|
1262
|
-
*/
|
|
1263
|
-
include_granted_scopes?: boolean;
|
|
1264
|
-
/**
|
|
1265
|
-
* Optional. If your application knows which user is trying to authenticate,
|
|
1266
|
-
* it can use this parameter to provide a hint to the Google Authentication
|
|
1267
|
-
* Server. The server uses the hint to simplify the login flow either by
|
|
1268
|
-
* prefilling the email field in the sign-in form or by selecting the
|
|
1269
|
-
* appropriate multi-login session. Set the parameter value to an email
|
|
1270
|
-
* address or sub identifier, which is equivalent to the user's Google ID.
|
|
1271
|
-
*/
|
|
1272
|
-
login_hint?: string;
|
|
1273
|
-
/**
|
|
1274
|
-
* Optional. A space-delimited, case-sensitive list of prompts to present the
|
|
1275
|
-
* user. If you don't specify this parameter, the user will be prompted only
|
|
1276
|
-
* the first time your app requests access. Possible values are:
|
|
1277
|
-
*
|
|
1278
|
-
* 'none' - Donot display any authentication or consent screens. Must not be
|
|
1279
|
-
* specified with other values.
|
|
1280
|
-
* 'consent' - Prompt the user for consent.
|
|
1281
|
-
* 'select_account' - Prompt the user to select an account.
|
|
1282
|
-
*/
|
|
1283
|
-
prompt?: string;
|
|
1284
|
-
/**
|
|
1285
|
-
* Recommended. Specifies what method was used to encode a 'code_verifier'
|
|
1286
|
-
* that will be used during authorization code exchange. This parameter must
|
|
1287
|
-
* be used with the 'code_challenge' parameter. The value of the
|
|
1288
|
-
* 'code_challenge_method' defaults to "plain" if not present in the request
|
|
1289
|
-
* that includes a 'code_challenge'. The only supported values for this
|
|
1290
|
-
* parameter are "S256" or "plain".
|
|
1291
|
-
*/
|
|
1292
|
-
code_challenge_method?: CodeChallengeMethod;
|
|
1293
|
-
/**
|
|
1294
|
-
* Recommended. Specifies an encoded 'code_verifier' that will be used as a
|
|
1295
|
-
* server-side challenge during authorization code exchange. This parameter
|
|
1296
|
-
* must be used with the 'code_challenge' parameter described above.
|
|
1297
|
-
*/
|
|
1298
|
-
code_challenge?: string;
|
|
1299
|
-
/**
|
|
1300
|
-
* A way for developers and/or the auth team to provide a set of key value
|
|
1301
|
-
* pairs to be added as query parameters to the authorization url.
|
|
1302
|
-
*/
|
|
1303
|
-
[key: string]: querystring.ParsedUrlQueryInput[keyof querystring.ParsedUrlQueryInput];
|
|
1304
|
-
}
|
|
1305
|
-
interface AccessTokenResponse {
|
|
1306
|
-
access_token: string;
|
|
1307
|
-
expiry_date: number;
|
|
1308
|
-
}
|
|
1309
|
-
interface GetRefreshHandlerCallback {
|
|
1310
|
-
(): Promise<AccessTokenResponse>;
|
|
1311
|
-
}
|
|
1312
|
-
interface GetTokenCallback$1 {
|
|
1313
|
-
(err: GaxiosError | null, token?: Credentials | null, res?: GaxiosResponse | null): void;
|
|
1314
|
-
}
|
|
1315
|
-
interface GetTokenResponse {
|
|
1316
|
-
tokens: Credentials;
|
|
1317
|
-
res: GaxiosResponse | null;
|
|
1318
|
-
}
|
|
1319
|
-
interface GetAccessTokenCallback {
|
|
1320
|
-
(err: GaxiosError | null, token?: string | null, res?: GaxiosResponse | null): void;
|
|
1321
|
-
}
|
|
1322
|
-
interface RefreshAccessTokenCallback {
|
|
1323
|
-
(err: GaxiosError | null, credentials?: Credentials | null, res?: GaxiosResponse | null): void;
|
|
1324
|
-
}
|
|
1325
|
-
interface RefreshAccessTokenResponse {
|
|
1326
|
-
credentials: Credentials;
|
|
1327
|
-
res: GaxiosResponse | null;
|
|
1328
|
-
}
|
|
1329
|
-
interface RequestMetadataResponse {
|
|
1330
|
-
headers: Headers;
|
|
1331
|
-
res?: GaxiosResponse<void> | null;
|
|
1332
|
-
}
|
|
1333
|
-
interface GetFederatedSignonCertsCallback {
|
|
1334
|
-
(err: GaxiosError | null, certs?: Certificates, response?: GaxiosResponse<void> | null): void;
|
|
1335
|
-
}
|
|
1336
|
-
interface FederatedSignonCertsResponse {
|
|
1337
|
-
certs: Certificates;
|
|
1338
|
-
format: CertificateFormat;
|
|
1339
|
-
res?: GaxiosResponse<void> | null;
|
|
1340
|
-
}
|
|
1341
|
-
interface GetIapPublicKeysCallback {
|
|
1342
|
-
(err: GaxiosError | null, pubkeys?: PublicKeys, response?: GaxiosResponse<void> | null): void;
|
|
1343
|
-
}
|
|
1344
|
-
interface IapPublicKeysResponse {
|
|
1345
|
-
pubkeys: PublicKeys;
|
|
1346
|
-
res?: GaxiosResponse<void> | null;
|
|
1347
|
-
}
|
|
1348
|
-
interface RevokeCredentialsResult {
|
|
1349
|
-
success: boolean;
|
|
1350
|
-
}
|
|
1351
|
-
interface VerifyIdTokenOptions {
|
|
1352
|
-
idToken: string;
|
|
1353
|
-
audience?: string | string[];
|
|
1354
|
-
maxExpiry?: number;
|
|
1355
|
-
}
|
|
1356
|
-
interface OAuth2ClientEndpoints {
|
|
1357
|
-
/**
|
|
1358
|
-
* The endpoint for viewing access token information
|
|
1359
|
-
*
|
|
1360
|
-
* @example
|
|
1361
|
-
* 'https://oauth2.googleapis.com/tokeninfo'
|
|
1362
|
-
*/
|
|
1363
|
-
tokenInfoUrl: string | URL;
|
|
1364
|
-
/**
|
|
1365
|
-
* The base URL for auth endpoints.
|
|
1366
|
-
*
|
|
1367
|
-
* @example
|
|
1368
|
-
* 'https://accounts.google.com/o/oauth2/v2/auth'
|
|
1369
|
-
*/
|
|
1370
|
-
oauth2AuthBaseUrl: string | URL;
|
|
1371
|
-
/**
|
|
1372
|
-
* The base endpoint for token retrieval
|
|
1373
|
-
* .
|
|
1374
|
-
* @example
|
|
1375
|
-
* 'https://oauth2.googleapis.com/token'
|
|
1376
|
-
*/
|
|
1377
|
-
oauth2TokenUrl: string | URL;
|
|
1378
|
-
/**
|
|
1379
|
-
* The base endpoint to revoke tokens.
|
|
1380
|
-
*
|
|
1381
|
-
* @example
|
|
1382
|
-
* 'https://oauth2.googleapis.com/revoke'
|
|
1383
|
-
*/
|
|
1384
|
-
oauth2RevokeUrl: string | URL;
|
|
1385
|
-
/**
|
|
1386
|
-
* Sign on certificates in PEM format.
|
|
1387
|
-
*
|
|
1388
|
-
* @example
|
|
1389
|
-
* 'https://www.googleapis.com/oauth2/v1/certs'
|
|
1390
|
-
*/
|
|
1391
|
-
oauth2FederatedSignonPemCertsUrl: string | URL;
|
|
1392
|
-
/**
|
|
1393
|
-
* Sign on certificates in JWK format.
|
|
1394
|
-
*
|
|
1395
|
-
* @example
|
|
1396
|
-
* 'https://www.googleapis.com/oauth2/v3/certs'
|
|
1397
|
-
*/
|
|
1398
|
-
oauth2FederatedSignonJwkCertsUrl: string | URL;
|
|
1399
|
-
/**
|
|
1400
|
-
* IAP Public Key URL.
|
|
1401
|
-
* This URL contains a JSON dictionary that maps the `kid` claims to the public key values.
|
|
1402
|
-
*
|
|
1403
|
-
* @example
|
|
1404
|
-
* 'https://www.gstatic.com/iap/verify/public_key'
|
|
1405
|
-
*/
|
|
1406
|
-
oauth2IapPublicKeyUrl: string | URL;
|
|
1407
|
-
}
|
|
1408
|
-
/**
|
|
1409
|
-
* A convenient interface for those looking to pass the OAuth2 Client config via a parsed
|
|
1410
|
-
* JSON file.
|
|
1411
|
-
*/
|
|
1412
|
-
interface OAuth2JSONOptions {
|
|
1413
|
-
/**
|
|
1414
|
-
* The authentication client ID.
|
|
1415
|
-
*
|
|
1416
|
-
* @alias {@link OAuth2ClientOptions.clientId}
|
|
1417
|
-
*/
|
|
1418
|
-
client_id?: string;
|
|
1419
|
-
/**
|
|
1420
|
-
* The authentication client secret.
|
|
1421
|
-
*
|
|
1422
|
-
* @alias {@link OAuth2ClientOptions.clientSecret}
|
|
1423
|
-
*/
|
|
1424
|
-
client_secret?: string;
|
|
1425
|
-
/**
|
|
1426
|
-
* The URIs to redirect to after completing the auth request.
|
|
1427
|
-
*
|
|
1428
|
-
* @alias {@link OAuth2ClientOptions.redirectUri}
|
|
1429
|
-
*/
|
|
1430
|
-
redirect_uris?: string[];
|
|
1431
|
-
}
|
|
1432
|
-
interface OAuth2ClientOptions extends AuthClientOptions, OAuth2JSONOptions {
|
|
1433
|
-
/**
|
|
1434
|
-
* The authentication client ID.
|
|
1435
|
-
*
|
|
1436
|
-
* @alias {@link OAuth2JSONOptions.client_id}
|
|
1437
|
-
*/
|
|
1438
|
-
clientId?: string;
|
|
1439
|
-
/**
|
|
1440
|
-
* The authentication client secret.
|
|
1441
|
-
*
|
|
1442
|
-
* @alias {@link OAuth2JSONOptions.client_secret}
|
|
1443
|
-
*/
|
|
1444
|
-
clientSecret?: string;
|
|
1445
|
-
/**
|
|
1446
|
-
* The URI to redirect to after completing the auth request.
|
|
1447
|
-
*
|
|
1448
|
-
* @alias {@link OAuth2JSONOptions.redirect_uris}
|
|
1449
|
-
*/
|
|
1450
|
-
redirectUri?: string;
|
|
1451
|
-
/**
|
|
1452
|
-
* Customizable endpoints.
|
|
1453
|
-
*/
|
|
1454
|
-
endpoints?: Partial<OAuth2ClientEndpoints>;
|
|
1455
|
-
/**
|
|
1456
|
-
* The allowed OAuth2 token issuers.
|
|
1457
|
-
*/
|
|
1458
|
-
issuers?: string[];
|
|
1459
|
-
/**
|
|
1460
|
-
* The client authentication type. Supported values are basic, post, and none.
|
|
1461
|
-
* Defaults to post if not provided.
|
|
1462
|
-
* https://datatracker.ietf.org/doc/html/rfc7591#section-2
|
|
1463
|
-
*/
|
|
1464
|
-
clientAuthentication?: ClientAuthentication$1;
|
|
1465
|
-
}
|
|
1466
|
-
type RefreshOptions = Pick<AuthClientOptions, 'eagerRefreshThresholdMillis' | 'forceRefreshOnFailure'>;
|
|
1467
|
-
declare class OAuth2Client extends AuthClient {
|
|
1468
|
-
private redirectUri?;
|
|
1469
|
-
private certificateCache;
|
|
1470
|
-
private certificateExpiry;
|
|
1471
|
-
private certificateCacheFormat;
|
|
1472
|
-
protected refreshTokenPromises: Map<string, Promise<GetTokenResponse>>;
|
|
1473
|
-
readonly endpoints: Readonly<OAuth2ClientEndpoints>;
|
|
1474
|
-
readonly issuers: string[];
|
|
1475
|
-
readonly clientAuthentication: ClientAuthentication$1;
|
|
1476
|
-
_clientId?: string;
|
|
1477
|
-
_clientSecret?: string;
|
|
1478
|
-
refreshHandler?: GetRefreshHandlerCallback;
|
|
1479
|
-
/**
|
|
1480
|
-
* An OAuth2 Client for Google APIs.
|
|
1481
|
-
*
|
|
1482
|
-
* @param options The OAuth2 Client Options. Passing an `clientId` directly is **@DEPRECATED**.
|
|
1483
|
-
* @param clientSecret **@DEPRECATED**. Provide a {@link OAuth2ClientOptions `OAuth2ClientOptions`} object in the first parameter instead.
|
|
1484
|
-
* @param redirectUri **@DEPRECATED**. Provide a {@link OAuth2ClientOptions `OAuth2ClientOptions`} object in the first parameter instead.
|
|
1485
|
-
*/
|
|
1486
|
-
constructor(options?: OAuth2ClientOptions | OAuth2ClientOptions['clientId'],
|
|
1487
|
-
/**
|
|
1488
|
-
* @deprecated - provide a {@link OAuth2ClientOptions `OAuth2ClientOptions`} object in the first parameter instead
|
|
1489
|
-
*/
|
|
1490
|
-
clientSecret?: OAuth2ClientOptions['clientSecret'],
|
|
1491
|
-
/**
|
|
1492
|
-
* @deprecated - provide a {@link OAuth2ClientOptions `OAuth2ClientOptions`} object in the first parameter instead
|
|
1493
|
-
*/
|
|
1494
|
-
redirectUri?: OAuth2ClientOptions['redirectUri']);
|
|
1495
|
-
/**
|
|
1496
|
-
* @deprecated use instance's {@link OAuth2Client.endpoints}
|
|
1497
|
-
*/
|
|
1498
|
-
protected static readonly GOOGLE_TOKEN_INFO_URL = "https://oauth2.googleapis.com/tokeninfo";
|
|
1499
|
-
/**
|
|
1500
|
-
* Clock skew - five minutes in seconds
|
|
1501
|
-
*/
|
|
1502
|
-
private static readonly CLOCK_SKEW_SECS_;
|
|
1503
|
-
/**
|
|
1504
|
-
* The default max Token Lifetime is one day in seconds
|
|
1505
|
-
*/
|
|
1506
|
-
private static readonly DEFAULT_MAX_TOKEN_LIFETIME_SECS_;
|
|
1507
|
-
/**
|
|
1508
|
-
* Generates URL for consent page landing.
|
|
1509
|
-
* @param opts Options.
|
|
1510
|
-
* @return URL to consent page.
|
|
1511
|
-
*/
|
|
1512
|
-
generateAuthUrl(opts?: GenerateAuthUrlOpts): string;
|
|
1513
|
-
generateCodeVerifier(): void;
|
|
1514
|
-
/**
|
|
1515
|
-
* Convenience method to automatically generate a code_verifier, and its
|
|
1516
|
-
* resulting SHA256. If used, this must be paired with a S256
|
|
1517
|
-
* code_challenge_method.
|
|
1518
|
-
*
|
|
1519
|
-
* For a full example see:
|
|
1520
|
-
* https://github.com/googleapis/google-auth-library-nodejs/blob/main/samples/oauth2-codeVerifier.js
|
|
1521
|
-
*/
|
|
1522
|
-
generateCodeVerifierAsync(): Promise<CodeVerifierResults>;
|
|
1523
|
-
/**
|
|
1524
|
-
* Gets the access token for the given code.
|
|
1525
|
-
* @param code The authorization code.
|
|
1526
|
-
* @param callback Optional callback fn.
|
|
1527
|
-
*/
|
|
1528
|
-
getToken(code: string): Promise<GetTokenResponse>;
|
|
1529
|
-
getToken(options: GetTokenOptions$1): Promise<GetTokenResponse>;
|
|
1530
|
-
getToken(code: string, callback: GetTokenCallback$1): void;
|
|
1531
|
-
getToken(options: GetTokenOptions$1, callback: GetTokenCallback$1): void;
|
|
1532
|
-
private getTokenAsync;
|
|
1533
|
-
/**
|
|
1534
|
-
* Refreshes the access token.
|
|
1535
|
-
* @param refresh_token Existing refresh token.
|
|
1536
|
-
* @private
|
|
1537
|
-
*/
|
|
1538
|
-
protected refreshToken(refreshToken?: string | null): Promise<GetTokenResponse>;
|
|
1539
|
-
protected refreshTokenNoCache(refreshToken?: string | null): Promise<GetTokenResponse>;
|
|
1540
|
-
/**
|
|
1541
|
-
* Retrieves the access token using refresh token
|
|
1542
|
-
*
|
|
1543
|
-
* @param callback callback
|
|
1544
|
-
*/
|
|
1545
|
-
refreshAccessToken(): Promise<RefreshAccessTokenResponse>;
|
|
1546
|
-
refreshAccessToken(callback: RefreshAccessTokenCallback): void;
|
|
1547
|
-
private refreshAccessTokenAsync;
|
|
1548
|
-
/**
|
|
1549
|
-
* Get a non-expired access token, after refreshing if necessary
|
|
1550
|
-
*
|
|
1551
|
-
* @param callback Callback to call with the access token
|
|
1552
|
-
*/
|
|
1553
|
-
getAccessToken(): Promise<GetAccessTokenResponse>;
|
|
1554
|
-
getAccessToken(callback: GetAccessTokenCallback): void;
|
|
1555
|
-
private getAccessTokenAsync;
|
|
1556
|
-
/**
|
|
1557
|
-
* The main authentication interface. It takes an optional url which when
|
|
1558
|
-
* present is the endpoint being accessed, and returns a Promise which
|
|
1559
|
-
* resolves with authorization header fields.
|
|
1560
|
-
*
|
|
1561
|
-
* In OAuth2Client, the result has the form:
|
|
1562
|
-
* { authorization: 'Bearer <access_token_value>' }
|
|
1563
|
-
*/
|
|
1564
|
-
getRequestHeaders(url?: string | URL): Promise<Headers>;
|
|
1565
|
-
protected getRequestMetadataAsync(url?: string | URL | null): Promise<RequestMetadataResponse>;
|
|
1566
|
-
/**
|
|
1567
|
-
* Generates an URL to revoke the given token.
|
|
1568
|
-
* @param token The existing token to be revoked.
|
|
1569
|
-
*
|
|
1570
|
-
* @deprecated use instance method {@link OAuth2Client.getRevokeTokenURL}
|
|
1571
|
-
*/
|
|
1572
|
-
static getRevokeTokenUrl(token: string): string;
|
|
1573
|
-
/**
|
|
1574
|
-
* Generates a URL to revoke the given token.
|
|
1575
|
-
*
|
|
1576
|
-
* @param token The existing token to be revoked.
|
|
1577
|
-
*/
|
|
1578
|
-
getRevokeTokenURL(token: string): URL;
|
|
1579
|
-
/**
|
|
1580
|
-
* Revokes the access given to token.
|
|
1581
|
-
* @param token The existing token to be revoked.
|
|
1582
|
-
* @param callback Optional callback fn.
|
|
1583
|
-
*/
|
|
1584
|
-
revokeToken(token: string): GaxiosPromise<RevokeCredentialsResult>;
|
|
1585
|
-
revokeToken(token: string, callback: BodyResponseCallback<RevokeCredentialsResult>): void;
|
|
1586
|
-
/**
|
|
1587
|
-
* Revokes access token and clears the credentials object
|
|
1588
|
-
* @param callback callback
|
|
1589
|
-
*/
|
|
1590
|
-
revokeCredentials(): GaxiosPromise<RevokeCredentialsResult>;
|
|
1591
|
-
revokeCredentials(callback: BodyResponseCallback<RevokeCredentialsResult>): void;
|
|
1592
|
-
private revokeCredentialsAsync;
|
|
1593
|
-
/**
|
|
1594
|
-
* Provides a request implementation with OAuth 2.0 flow. If credentials have
|
|
1595
|
-
* a refresh_token, in cases of HTTP 401 and 403 responses, it automatically
|
|
1596
|
-
* asks for a new access token and replays the unsuccessful request.
|
|
1597
|
-
* @param opts Request options.
|
|
1598
|
-
* @param callback callback.
|
|
1599
|
-
* @return Request object
|
|
1600
|
-
*/
|
|
1601
|
-
request<T>(opts: GaxiosOptions): GaxiosPromise<T>;
|
|
1602
|
-
request<T>(opts: GaxiosOptions, callback: BodyResponseCallback<T>): void;
|
|
1603
|
-
protected requestAsync<T>(opts: GaxiosOptions, reAuthRetried?: boolean): Promise<GaxiosResponse<T>>;
|
|
1604
|
-
/**
|
|
1605
|
-
* Verify id token is token by checking the certs and audience
|
|
1606
|
-
* @param options that contains all options.
|
|
1607
|
-
* @param callback Callback supplying GoogleLogin if successful
|
|
1608
|
-
*/
|
|
1609
|
-
verifyIdToken(options: VerifyIdTokenOptions): Promise<LoginTicket>;
|
|
1610
|
-
verifyIdToken(options: VerifyIdTokenOptions, callback: (err: Error | null, login?: LoginTicket) => void): void;
|
|
1611
|
-
private verifyIdTokenAsync;
|
|
1612
|
-
/**
|
|
1613
|
-
* Obtains information about the provisioned access token. Especially useful
|
|
1614
|
-
* if you want to check the scopes that were provisioned to a given token.
|
|
1615
|
-
*
|
|
1616
|
-
* @param accessToken Required. The Access Token for which you want to get
|
|
1617
|
-
* user info.
|
|
1618
|
-
*/
|
|
1619
|
-
getTokenInfo(accessToken: string): Promise<TokenInfo>;
|
|
1620
|
-
/**
|
|
1621
|
-
* Gets federated sign-on certificates to use for verifying identity tokens.
|
|
1622
|
-
* Returns certs as array structure, where keys are key ids, and values
|
|
1623
|
-
* are certificates in either PEM or JWK format.
|
|
1624
|
-
* @param callback Callback supplying the certificates
|
|
1625
|
-
*/
|
|
1626
|
-
getFederatedSignonCerts(): Promise<FederatedSignonCertsResponse>;
|
|
1627
|
-
getFederatedSignonCerts(callback: GetFederatedSignonCertsCallback): void;
|
|
1628
|
-
getFederatedSignonCertsAsync(): Promise<FederatedSignonCertsResponse>;
|
|
1629
|
-
/**
|
|
1630
|
-
* Gets federated sign-on certificates to use for verifying identity tokens.
|
|
1631
|
-
* Returns certs as array structure, where keys are key ids, and values
|
|
1632
|
-
* are certificates in either PEM or JWK format.
|
|
1633
|
-
* @param callback Callback supplying the certificates
|
|
1634
|
-
*/
|
|
1635
|
-
getIapPublicKeys(): Promise<IapPublicKeysResponse>;
|
|
1636
|
-
getIapPublicKeys(callback: GetIapPublicKeysCallback): void;
|
|
1637
|
-
getIapPublicKeysAsync(): Promise<IapPublicKeysResponse>;
|
|
1638
|
-
verifySignedJwtWithCerts(): void;
|
|
1639
|
-
/**
|
|
1640
|
-
* Verify the id token is signed with the correct certificate
|
|
1641
|
-
* and is from the correct audience.
|
|
1642
|
-
* @param jwt The jwt to verify (The ID Token in this case).
|
|
1643
|
-
* @param certs The array of certs to test the jwt against.
|
|
1644
|
-
* @param requiredAudience The audience to test the jwt against.
|
|
1645
|
-
* @param issuers The allowed issuers of the jwt (Optional).
|
|
1646
|
-
* @param maxExpiry The max expiry the certificate can be (Optional).
|
|
1647
|
-
* @return Returns a promise resolving to LoginTicket on verification.
|
|
1648
|
-
*/
|
|
1649
|
-
verifySignedJwtWithCertsAsync(jwt: string, certs: Certificates | PublicKeys, requiredAudience?: string | string[], issuers?: string[], maxExpiry?: number): Promise<LoginTicket>;
|
|
1650
|
-
/**
|
|
1651
|
-
* Returns a promise that resolves with AccessTokenResponse type if
|
|
1652
|
-
* refreshHandler is defined.
|
|
1653
|
-
* If not, nothing is returned.
|
|
1654
|
-
*/
|
|
1655
|
-
private processAndValidateRefreshHandler;
|
|
1656
|
-
/**
|
|
1657
|
-
* Returns true if a token is expired or will expire within
|
|
1658
|
-
* eagerRefreshThresholdMillismilliseconds.
|
|
1659
|
-
* If there is no expiry time, assumes the token is not expired or expiring.
|
|
1660
|
-
*/
|
|
1661
|
-
protected isTokenExpiring(): boolean;
|
|
1662
|
-
}
|
|
1663
|
-
interface IdTokenOptions extends OAuth2ClientOptions {
|
|
1664
|
-
/**
|
|
1665
|
-
* The client to make the request to fetch an ID token.
|
|
1666
|
-
*/
|
|
1667
|
-
idTokenProvider: IdTokenProvider;
|
|
1668
|
-
/**
|
|
1669
|
-
* The audience to use when requesting an ID token.
|
|
1670
|
-
*/
|
|
1671
|
-
targetAudience: string;
|
|
1672
|
-
}
|
|
1673
|
-
interface IdTokenProvider {
|
|
1674
|
-
fetchIdToken: (targetAudience: string) => Promise<string>;
|
|
1675
|
-
}
|
|
1676
|
-
declare class IdTokenClient extends OAuth2Client {
|
|
1677
|
-
targetAudience: string;
|
|
1678
|
-
idTokenProvider: IdTokenProvider;
|
|
1679
|
-
/**
|
|
1680
|
-
* Google ID Token client
|
|
1681
|
-
*
|
|
1682
|
-
* Retrieve ID token from the metadata server.
|
|
1683
|
-
* See: https://cloud.google.com/docs/authentication/get-id-token#metadata-server
|
|
1684
|
-
*/
|
|
1685
|
-
constructor(options: IdTokenOptions);
|
|
1686
|
-
protected getRequestMetadataAsync(): Promise<RequestMetadataResponse>;
|
|
1687
|
-
private getIdTokenExpiryDate;
|
|
1688
|
-
}
|
|
1689
|
-
declare enum GCPEnv {
|
|
1690
|
-
APP_ENGINE = "APP_ENGINE",
|
|
1691
|
-
KUBERNETES_ENGINE = "KUBERNETES_ENGINE",
|
|
1692
|
-
CLOUD_FUNCTIONS = "CLOUD_FUNCTIONS",
|
|
1693
|
-
COMPUTE_ENGINE = "COMPUTE_ENGINE",
|
|
1694
|
-
CLOUD_RUN = "CLOUD_RUN",
|
|
1695
|
-
CLOUD_RUN_JOBS = "CLOUD_RUN_JOBS",
|
|
1696
|
-
NONE = "NONE",
|
|
1697
|
-
}
|
|
1698
|
-
interface Transporter {
|
|
1699
|
-
request<T>(opts: GaxiosOptions): GaxiosPromise<T>;
|
|
1700
|
-
}
|
|
1701
|
-
interface TokenOptions {
|
|
1702
|
-
/**
|
|
1703
|
-
* Path to a .json, .pem, or .p12 key file.
|
|
1704
|
-
*/
|
|
1705
|
-
keyFile?: string;
|
|
1706
|
-
/**
|
|
1707
|
-
* The raw private key value.
|
|
1708
|
-
*/
|
|
1709
|
-
key?: string;
|
|
1710
|
-
/**
|
|
1711
|
-
* The service account email address.
|
|
1712
|
-
*/
|
|
1713
|
-
email?: string;
|
|
1714
|
-
/**
|
|
1715
|
-
* The issuer claim for the JWT.
|
|
1716
|
-
*/
|
|
1717
|
-
iss?: string;
|
|
1718
|
-
/**
|
|
1719
|
-
* The subject claim for the JWT. This is used for impersonation.
|
|
1720
|
-
*/
|
|
1721
|
-
sub?: string;
|
|
1722
|
-
/**
|
|
1723
|
-
* The space-delimited list of scopes for the requested token.
|
|
1724
|
-
*/
|
|
1725
|
-
scope?: string | string[];
|
|
1726
|
-
/**
|
|
1727
|
-
* Additional claims to include in the JWT payload.
|
|
1728
|
-
*/
|
|
1729
|
-
additionalClaims?: {
|
|
1730
|
-
[key: string]: any;
|
|
1731
|
-
};
|
|
1732
|
-
/**
|
|
1733
|
-
* Eagerly refresh unexpired tokens when they are within this many
|
|
1734
|
-
* milliseconds from expiring.
|
|
1735
|
-
* Defaults to 0.
|
|
1736
|
-
*/
|
|
1737
|
-
eagerRefreshThresholdMillis?: number;
|
|
1738
|
-
transporter?: Transporter;
|
|
1739
|
-
}
|
|
1740
|
-
/**
|
|
1741
|
-
* Interface for the data returned from the token endpoint.
|
|
1742
|
-
*/
|
|
1743
|
-
interface TokenData {
|
|
1744
|
-
/** An optional refresh token. */
|
|
1745
|
-
refresh_token?: string;
|
|
1746
|
-
/** The duration of the token in seconds. */
|
|
1747
|
-
expires_in?: number;
|
|
1748
|
-
/** The access token. */
|
|
1749
|
-
access_token?: string;
|
|
1750
|
-
/** The type of token, e.g., "Bearer". */
|
|
1751
|
-
token_type?: string;
|
|
1752
|
-
/** An optional ID token. */
|
|
1753
|
-
id_token?: string;
|
|
1754
|
-
}
|
|
1755
|
-
/**
|
|
1756
|
-
* Fetches an access token.
|
|
1757
|
-
* @param tokenOptions The options for the token.
|
|
1758
|
-
* @returns A promise that resolves with the token data.
|
|
1759
|
-
*/
|
|
1760
|
-
/**
|
|
1761
|
-
* Options for fetching an access token.
|
|
1762
|
-
*/
|
|
1763
|
-
interface GetTokenOptions {
|
|
1764
|
-
/**
|
|
1765
|
-
* If true, a new token will be fetched, ignoring any cached token.
|
|
1766
|
-
*/
|
|
1767
|
-
forceRefresh?: boolean;
|
|
1768
|
-
}
|
|
1769
|
-
/**
|
|
1770
|
-
* Callback type for the `getToken` method.
|
|
1771
|
-
*/
|
|
1772
|
-
type GetTokenCallback = (err: Error | null, token?: TokenData) => void;
|
|
1773
|
-
/**
|
|
1774
|
-
* The GoogleToken class is used to manage authentication with Google's OAuth 2.0 authorization server.
|
|
1775
|
-
* It handles fetching, caching, and refreshing of access tokens.
|
|
1776
|
-
*/
|
|
1777
|
-
declare class GoogleToken {
|
|
1778
|
-
/** The configuration options for this token instance. */
|
|
1779
|
-
private tokenOptions;
|
|
1780
|
-
/** The handler for token fetching and caching logic. */
|
|
1781
|
-
private tokenHandler;
|
|
1782
|
-
/**
|
|
1783
|
-
* Create a GoogleToken.
|
|
1784
|
-
*
|
|
1785
|
-
* @param options Configuration object.
|
|
1786
|
-
*/
|
|
1787
|
-
constructor(options?: TokenOptions);
|
|
1788
|
-
get expiresAt(): number | undefined;
|
|
1789
|
-
/**
|
|
1790
|
-
* The most recent access token obtained by this client.
|
|
1791
|
-
*/
|
|
1792
|
-
get accessToken(): string | undefined;
|
|
1793
|
-
/**
|
|
1794
|
-
* The most recent ID token obtained by this client.
|
|
1795
|
-
*/
|
|
1796
|
-
get idToken(): string | undefined;
|
|
1797
|
-
/**
|
|
1798
|
-
* The token type of the most recent access token.
|
|
1799
|
-
*/
|
|
1800
|
-
get tokenType(): string | undefined;
|
|
1801
|
-
/**
|
|
1802
|
-
* The refresh token for the current credentials.
|
|
1803
|
-
*/
|
|
1804
|
-
get refreshToken(): string | undefined;
|
|
1805
|
-
/**
|
|
1806
|
-
* A boolean indicating if the current token has expired.
|
|
1807
|
-
*/
|
|
1808
|
-
hasExpired(): boolean;
|
|
1809
|
-
/**
|
|
1810
|
-
* A boolean indicating if the current token is expiring soon,
|
|
1811
|
-
* based on the `eagerRefreshThresholdMillis` option.
|
|
1812
|
-
*/
|
|
1813
|
-
isTokenExpiring(): boolean;
|
|
1814
|
-
/**
|
|
1815
|
-
* Fetches a new access token and returns it.
|
|
1816
|
-
* @param opts Options for fetching the token.
|
|
1817
|
-
*/
|
|
1818
|
-
getToken(opts?: GetTokenOptions): Promise<TokenData>;
|
|
1819
|
-
getToken(callback: GetTokenCallback, opts?: GetTokenOptions): void;
|
|
1820
|
-
/**
|
|
1821
|
-
* Revokes the current access token and resets the token handler.
|
|
1822
|
-
*/
|
|
1823
|
-
revokeToken(): Promise<void>;
|
|
1824
|
-
revokeToken(callback: (err?: Error) => void): void;
|
|
1825
|
-
/**
|
|
1826
|
-
* Returns the configuration options for this token instance.
|
|
1827
|
-
*/
|
|
1828
|
-
get googleTokenOptions(): TokenOptions;
|
|
1829
|
-
}
|
|
1830
|
-
interface JWTOptions extends OAuth2ClientOptions {
|
|
1831
|
-
/**
|
|
1832
|
-
* The service account email address.
|
|
1833
|
-
*/
|
|
1834
|
-
email?: string;
|
|
1835
|
-
/**
|
|
1836
|
-
* The path to private key file. Not necessary if {@link JWTOptions.key} has been provided.
|
|
1837
|
-
*/
|
|
1838
|
-
keyFile?: string;
|
|
1839
|
-
/**
|
|
1840
|
-
* The value of key. Not necessary if {@link JWTOptions.keyFile} has been provided.
|
|
1841
|
-
*/
|
|
1842
|
-
key?: string;
|
|
1843
|
-
/**
|
|
1844
|
-
* The list of requested scopes or a single scope.
|
|
1845
|
-
*/
|
|
1846
|
-
keyId?: string;
|
|
1847
|
-
/**
|
|
1848
|
-
* The impersonated account's email address.
|
|
1849
|
-
*/
|
|
1850
|
-
scopes?: string | string[];
|
|
1851
|
-
/**
|
|
1852
|
-
* The ID of the key.
|
|
1853
|
-
*/
|
|
1854
|
-
subject?: string;
|
|
1855
|
-
/**
|
|
1856
|
-
* Additional claims, such as target audience.
|
|
1857
|
-
*
|
|
1858
|
-
* @example
|
|
1859
|
-
* ```
|
|
1860
|
-
* {target_audience: 'targetAudience'}
|
|
1861
|
-
* ```
|
|
1862
|
-
*/
|
|
1863
|
-
additionalClaims?: {};
|
|
1864
|
-
}
|
|
1865
|
-
declare class JWT extends OAuth2Client implements IdTokenProvider {
|
|
1866
|
-
email?: string;
|
|
1867
|
-
keyFile?: string;
|
|
1868
|
-
key?: string;
|
|
1869
|
-
keyId?: string;
|
|
1870
|
-
defaultScopes?: string | string[];
|
|
1871
|
-
scopes?: string | string[];
|
|
1872
|
-
scope?: string;
|
|
1873
|
-
subject?: string;
|
|
1874
|
-
gtoken?: GoogleToken;
|
|
1875
|
-
additionalClaims?: {};
|
|
1876
|
-
useJWTAccessWithScope?: boolean;
|
|
1877
|
-
defaultServicePath?: string;
|
|
1878
|
-
private access?;
|
|
1879
|
-
/**
|
|
1880
|
-
* JWT service account credentials.
|
|
1881
|
-
*
|
|
1882
|
-
* Retrieve access token using gtoken.
|
|
1883
|
-
*
|
|
1884
|
-
* @param options the
|
|
1885
|
-
*/
|
|
1886
|
-
constructor(options?: JWTOptions);
|
|
1887
|
-
/**
|
|
1888
|
-
* Creates a copy of the credential with the specified scopes.
|
|
1889
|
-
* @param scopes List of requested scopes or a single scope.
|
|
1890
|
-
* @return The cloned instance.
|
|
1891
|
-
*/
|
|
1892
|
-
createScoped(scopes?: string | string[]): JWT;
|
|
1893
|
-
/**
|
|
1894
|
-
* Obtains the metadata to be sent with the request.
|
|
1895
|
-
*
|
|
1896
|
-
* @param url the URI being authorized.
|
|
1897
|
-
*/
|
|
1898
|
-
protected getRequestMetadataAsync(url?: string | null): Promise<RequestMetadataResponse>;
|
|
1899
|
-
/**
|
|
1900
|
-
* Fetches an ID token.
|
|
1901
|
-
* @param targetAudience the audience for the fetched ID token.
|
|
1902
|
-
*/
|
|
1903
|
-
fetchIdToken(targetAudience: string): Promise<string>;
|
|
1904
|
-
/**
|
|
1905
|
-
* Determine if there are currently scopes available.
|
|
1906
|
-
*/
|
|
1907
|
-
private hasUserScopes;
|
|
1908
|
-
/**
|
|
1909
|
-
* Are there any default or user scopes defined.
|
|
1910
|
-
*/
|
|
1911
|
-
private hasAnyScopes;
|
|
1912
|
-
/**
|
|
1913
|
-
* Get the initial access token using gToken.
|
|
1914
|
-
* @param callback Optional callback.
|
|
1915
|
-
* @returns Promise that resolves with credentials
|
|
1916
|
-
*/
|
|
1917
|
-
authorize(): Promise<Credentials>;
|
|
1918
|
-
authorize(callback: (err: Error | null, result?: Credentials) => void): void;
|
|
1919
|
-
private authorizeAsync;
|
|
1920
|
-
/**
|
|
1921
|
-
* Refreshes the access token.
|
|
1922
|
-
* @param refreshToken ignored
|
|
1923
|
-
* @private
|
|
1924
|
-
*/
|
|
1925
|
-
protected refreshTokenNoCache(): Promise<GetTokenResponse>;
|
|
1926
|
-
/**
|
|
1927
|
-
* Create a gToken if it doesn't already exist.
|
|
1928
|
-
*/
|
|
1929
|
-
private createGToken;
|
|
1930
|
-
/**
|
|
1931
|
-
* Create a JWT credentials instance using the given input options.
|
|
1932
|
-
* @param json The input object.
|
|
1933
|
-
*
|
|
1934
|
-
* @remarks
|
|
1935
|
-
*
|
|
1936
|
-
* **Important**: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information, refer to {@link https://cloud.google.com/docs/authentication/external/externally-sourced-credentials Validate credential configurations from external sources}.
|
|
1937
|
-
*/
|
|
1938
|
-
fromJSON(json: JWTInput): void;
|
|
1939
|
-
/**
|
|
1940
|
-
* Create a JWT credentials instance using the given input stream.
|
|
1941
|
-
* @param inputStream The input stream.
|
|
1942
|
-
* @param callback Optional callback.
|
|
1943
|
-
*
|
|
1944
|
-
* @remarks
|
|
1945
|
-
*
|
|
1946
|
-
* **Important**: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information, refer to {@link https://cloud.google.com/docs/authentication/external/externally-sourced-credentials Validate credential configurations from external sources}.
|
|
1947
|
-
*/
|
|
1948
|
-
fromStream(inputStream: stream.Readable): Promise<void>;
|
|
1949
|
-
fromStream(inputStream: stream.Readable, callback: (err?: Error | null) => void): void;
|
|
1950
|
-
private fromStreamAsync;
|
|
1951
|
-
/**
|
|
1952
|
-
* Creates a JWT credentials instance using an API Key for authentication.
|
|
1953
|
-
* @param apiKey The API Key in string form.
|
|
1954
|
-
*/
|
|
1955
|
-
fromAPIKey(apiKey: string): void;
|
|
1956
|
-
/**
|
|
1957
|
-
* Using the key or keyFile on the JWT client, obtain an object that contains
|
|
1958
|
-
* the key and the client email.
|
|
1959
|
-
*/
|
|
1960
|
-
getCredentials(): Promise<CredentialBody>;
|
|
1961
|
-
}
|
|
1962
|
-
interface UserRefreshClientOptions extends OAuth2ClientOptions {
|
|
1963
|
-
/**
|
|
1964
|
-
* The authentication client ID.
|
|
1965
|
-
*/
|
|
1966
|
-
clientId?: string;
|
|
1967
|
-
/**
|
|
1968
|
-
* The authentication client secret.
|
|
1969
|
-
*/
|
|
1970
|
-
clientSecret?: string;
|
|
1971
|
-
/**
|
|
1972
|
-
* The authentication refresh token.
|
|
1973
|
-
*/
|
|
1974
|
-
refreshToken?: string;
|
|
1975
|
-
}
|
|
1976
|
-
declare class UserRefreshClient extends OAuth2Client {
|
|
1977
|
-
_refreshToken?: string | null;
|
|
1978
|
-
/**
|
|
1979
|
-
* The User Refresh Token client.
|
|
1980
|
-
*
|
|
1981
|
-
* @param optionsOrClientId The User Refresh Token client options. Passing an `clientId` directly is **@DEPRECATED**.
|
|
1982
|
-
* @param clientSecret **@DEPRECATED**. Provide a {@link UserRefreshClientOptions `UserRefreshClientOptions`} object in the first parameter instead.
|
|
1983
|
-
* @param refreshToken **@DEPRECATED**. Provide a {@link UserRefreshClientOptions `UserRefreshClientOptions`} object in the first parameter instead.
|
|
1984
|
-
* @param eagerRefreshThresholdMillis **@DEPRECATED**. Provide a {@link UserRefreshClientOptions `UserRefreshClientOptions`} object in the first parameter instead.
|
|
1985
|
-
* @param forceRefreshOnFailure **@DEPRECATED**. Provide a {@link UserRefreshClientOptions `UserRefreshClientOptions`} object in the first parameter instead.
|
|
1986
|
-
*/
|
|
1987
|
-
constructor(optionsOrClientId?: string | UserRefreshClientOptions,
|
|
1988
|
-
/**
|
|
1989
|
-
* @deprecated - provide a {@link UserRefreshClientOptions `UserRefreshClientOptions`} object in the first parameter instead
|
|
1990
|
-
*/
|
|
1991
|
-
|
|
1992
|
-
clientSecret?: UserRefreshClientOptions['clientSecret'],
|
|
1993
|
-
/**
|
|
1994
|
-
* @deprecated - provide a {@link UserRefreshClientOptions `UserRefreshClientOptions`} object in the first parameter instead
|
|
1995
|
-
*/
|
|
1996
|
-
|
|
1997
|
-
refreshToken?: UserRefreshClientOptions['refreshToken'],
|
|
1998
|
-
/**
|
|
1999
|
-
* @deprecated - provide a {@link UserRefreshClientOptions `UserRefreshClientOptions`} object in the first parameter instead
|
|
2000
|
-
*/
|
|
2001
|
-
|
|
2002
|
-
eagerRefreshThresholdMillis?: UserRefreshClientOptions['eagerRefreshThresholdMillis'],
|
|
2003
|
-
/**
|
|
2004
|
-
* @deprecated - provide a {@link UserRefreshClientOptions `UserRefreshClientOptions`} object in the first parameter instead
|
|
2005
|
-
*/
|
|
2006
|
-
|
|
2007
|
-
forceRefreshOnFailure?: UserRefreshClientOptions['forceRefreshOnFailure']);
|
|
2008
|
-
/**
|
|
2009
|
-
* Refreshes the access token.
|
|
2010
|
-
* @param refreshToken An ignored refreshToken..
|
|
2011
|
-
* @param callback Optional callback.
|
|
2012
|
-
*/
|
|
2013
|
-
protected refreshTokenNoCache(): Promise<GetTokenResponse>;
|
|
2014
|
-
fetchIdToken(targetAudience: string): Promise<string>;
|
|
2015
|
-
/**
|
|
2016
|
-
* Create a UserRefreshClient credentials instance using the given input
|
|
2017
|
-
* options.
|
|
2018
|
-
* @param json The input object.
|
|
2019
|
-
*/
|
|
2020
|
-
fromJSON(json: JWTInput): void;
|
|
2021
|
-
/**
|
|
2022
|
-
* Create a UserRefreshClient credentials instance using the given input
|
|
2023
|
-
* stream.
|
|
2024
|
-
* @param inputStream The input stream.
|
|
2025
|
-
* @param callback Optional callback.
|
|
2026
|
-
*/
|
|
2027
|
-
fromStream(inputStream: stream.Readable): Promise<void>;
|
|
2028
|
-
fromStream(inputStream: stream.Readable, callback: (err?: Error) => void): void;
|
|
2029
|
-
private fromStreamAsync;
|
|
2030
|
-
/**
|
|
2031
|
-
* Create a UserRefreshClient credentials instance using the given input
|
|
2032
|
-
* options.
|
|
2033
|
-
* @param json The input object.
|
|
2034
|
-
*/
|
|
2035
|
-
static fromJSON(json: JWTInput): UserRefreshClient;
|
|
2036
|
-
}
|
|
2037
|
-
interface ImpersonatedOptions extends OAuth2ClientOptions {
|
|
2038
|
-
/**
|
|
2039
|
-
* Client used to perform exchange for impersonated client.
|
|
2040
|
-
*/
|
|
2041
|
-
sourceClient?: AuthClient;
|
|
2042
|
-
/**
|
|
2043
|
-
* The service account to impersonate.
|
|
2044
|
-
*/
|
|
2045
|
-
targetPrincipal?: string;
|
|
2046
|
-
/**
|
|
2047
|
-
* Scopes to request during the authorization grant.
|
|
2048
|
-
*/
|
|
2049
|
-
targetScopes?: string[];
|
|
2050
|
-
/**
|
|
2051
|
-
* The chained list of delegates required to grant the final access_token.
|
|
2052
|
-
*/
|
|
2053
|
-
delegates?: string[];
|
|
2054
|
-
/**
|
|
2055
|
-
* Number of seconds the delegated credential should be valid.
|
|
2056
|
-
*/
|
|
2057
|
-
lifetime?: number | 3600;
|
|
2058
|
-
/**
|
|
2059
|
-
* API endpoint to fetch token from.
|
|
2060
|
-
*/
|
|
2061
|
-
endpoint?: string;
|
|
2062
|
-
}
|
|
2063
|
-
interface FetchIdTokenOptions {
|
|
2064
|
-
/**
|
|
2065
|
-
* Include the service account email in the token.
|
|
2066
|
-
* If set to `true`, the token will contain `email` and `email_verified` claims.
|
|
2067
|
-
*/
|
|
2068
|
-
includeEmail: boolean;
|
|
2069
|
-
}
|
|
2070
|
-
declare class Impersonated extends OAuth2Client implements IdTokenProvider {
|
|
2071
|
-
private sourceClient;
|
|
2072
|
-
private targetPrincipal;
|
|
2073
|
-
private targetScopes;
|
|
2074
|
-
private delegates;
|
|
2075
|
-
private lifetime;
|
|
2076
|
-
private endpoint;
|
|
2077
|
-
/**
|
|
2078
|
-
* Impersonated service account credentials.
|
|
2079
|
-
*
|
|
2080
|
-
* Create a new access token by impersonating another service account.
|
|
2081
|
-
*
|
|
2082
|
-
* Impersonated Credentials allowing credentials issued to a user or
|
|
2083
|
-
* service account to impersonate another. The source project using
|
|
2084
|
-
* Impersonated Credentials must enable the "IAMCredentials" API.
|
|
2085
|
-
* Also, the target service account must grant the orginating principal
|
|
2086
|
-
* the "Service Account Token Creator" IAM role.
|
|
2087
|
-
*
|
|
2088
|
-
* **IMPORTANT**: This method does not validate the credential configuration.
|
|
2089
|
-
* A security risk occurs when a credential configuration configured with
|
|
2090
|
-
* malicious URLs is used. When the credential configuration is accepted from
|
|
2091
|
-
* an untrusted source, you should validate it before using it with this
|
|
2092
|
-
* method. For more details, see
|
|
2093
|
-
* https://cloud.google.com/docs/authentication/external/externally-sourced-credentials.
|
|
2094
|
-
*
|
|
2095
|
-
* @param {object} options - The configuration object.
|
|
2096
|
-
* @param {object} [options.sourceClient] the source credential used as to
|
|
2097
|
-
* acquire the impersonated credentials.
|
|
2098
|
-
* @param {string} [options.targetPrincipal] the service account to
|
|
2099
|
-
* impersonate.
|
|
2100
|
-
* @param {string[]} [options.delegates] the chained list of delegates
|
|
2101
|
-
* required to grant the final access_token. If set, the sequence of
|
|
2102
|
-
* identities must have "Service Account Token Creator" capability granted to
|
|
2103
|
-
* the preceding identity. For example, if set to [serviceAccountB,
|
|
2104
|
-
* serviceAccountC], the sourceCredential must have the Token Creator role on
|
|
2105
|
-
* serviceAccountB. serviceAccountB must have the Token Creator on
|
|
2106
|
-
* serviceAccountC. Finally, C must have Token Creator on target_principal.
|
|
2107
|
-
* If left unset, sourceCredential must have that role on targetPrincipal.
|
|
2108
|
-
* @param {string[]} [options.targetScopes] scopes to request during the
|
|
2109
|
-
* authorization grant.
|
|
2110
|
-
* @param {number} [options.lifetime] number of seconds the delegated
|
|
2111
|
-
* credential should be valid for up to 3600 seconds by default, or 43,200
|
|
2112
|
-
* seconds by extending the token's lifetime, see:
|
|
2113
|
-
* https://cloud.google.com/iam/docs/creating-short-lived-service-account-credentials#sa-credentials-oauth
|
|
2114
|
-
* @param {string} [options.endpoint] api endpoint override.
|
|
2115
|
-
*/
|
|
2116
|
-
constructor(options?: ImpersonatedOptions);
|
|
2117
|
-
/**
|
|
2118
|
-
* Signs some bytes.
|
|
2119
|
-
*
|
|
2120
|
-
* {@link https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signBlob Reference Documentation}
|
|
2121
|
-
* @param blobToSign String to sign.
|
|
2122
|
-
*
|
|
2123
|
-
* @returns A {@link SignBlobResponse} denoting the keyID and signedBlob in base64 string
|
|
2124
|
-
*/
|
|
2125
|
-
sign(blobToSign: string): Promise<SignBlobResponse>;
|
|
2126
|
-
/** The service account email to be impersonated. */
|
|
2127
|
-
getTargetPrincipal(): string;
|
|
2128
|
-
/**
|
|
2129
|
-
* Refreshes the access token.
|
|
2130
|
-
*/
|
|
2131
|
-
protected refreshToken(): Promise<GetTokenResponse>;
|
|
2132
|
-
/**
|
|
2133
|
-
* Generates an OpenID Connect ID token for a service account.
|
|
2134
|
-
*
|
|
2135
|
-
* {@link https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/generateIdToken Reference Documentation}
|
|
2136
|
-
*
|
|
2137
|
-
* @param targetAudience the audience for the fetched ID token.
|
|
2138
|
-
* @param options the for the request
|
|
2139
|
-
* @return an OpenID Connect ID token
|
|
2140
|
-
*/
|
|
2141
|
-
fetchIdToken(targetAudience: string, options?: FetchIdTokenOptions): Promise<string>;
|
|
2142
|
-
}
|
|
2143
|
-
/**
|
|
2144
|
-
* OAuth client authentication types.
|
|
2145
|
-
* https://tools.ietf.org/html/rfc6749#section-2.3
|
|
2146
|
-
*/
|
|
2147
|
-
type ConfidentialClientType = 'basic' | 'request-body';
|
|
2148
|
-
/**
|
|
2149
|
-
* Defines the client authentication credentials for basic and request-body
|
|
2150
|
-
* credentials.
|
|
2151
|
-
* https://tools.ietf.org/html/rfc6749#section-2.3.1
|
|
2152
|
-
*/
|
|
2153
|
-
interface ClientAuthentication {
|
|
2154
|
-
confidentialClientType: ConfidentialClientType;
|
|
2155
|
-
clientId: string;
|
|
2156
|
-
clientSecret?: string;
|
|
2157
|
-
}
|
|
2158
|
-
interface OAuthClientAuthHandlerOptions {
|
|
2159
|
-
/**
|
|
2160
|
-
* Defines the client authentication credentials for basic and request-body
|
|
2161
|
-
* credentials.
|
|
2162
|
-
*/
|
|
2163
|
-
clientAuthentication?: ClientAuthentication;
|
|
2164
|
-
/**
|
|
2165
|
-
* An optional transporter to use.
|
|
2166
|
-
*/
|
|
2167
|
-
transporter?: Gaxios;
|
|
2168
|
-
}
|
|
2169
|
-
/**
|
|
2170
|
-
* Abstract class for handling client authentication in OAuth-based
|
|
2171
|
-
* operations.
|
|
2172
|
-
* When request-body client authentication is used, only application/json and
|
|
2173
|
-
* application/x-www-form-urlencoded content types for HTTP methods that support
|
|
2174
|
-
* request bodies are supported.
|
|
2175
|
-
*/
|
|
2176
|
-
declare abstract class OAuthClientAuthHandler {
|
|
2177
|
-
#private;
|
|
2178
|
-
protected transporter: Gaxios;
|
|
2179
|
-
/**
|
|
2180
|
-
* Instantiates an OAuth client authentication handler.
|
|
2181
|
-
* @param options The OAuth Client Auth Handler instance options. Passing an `ClientAuthentication` directly is **@DEPRECATED**.
|
|
2182
|
-
*/
|
|
2183
|
-
constructor(options?: ClientAuthentication | OAuthClientAuthHandlerOptions);
|
|
2184
|
-
/**
|
|
2185
|
-
* Applies client authentication on the OAuth request's headers or POST
|
|
2186
|
-
* body but does not process the request.
|
|
2187
|
-
* @param opts The GaxiosOptions whose headers or data are to be modified
|
|
2188
|
-
* depending on the client authentication mechanism to be used.
|
|
2189
|
-
* @param bearerToken The optional bearer token to use for authentication.
|
|
2190
|
-
* When this is used, no client authentication credentials are needed.
|
|
2191
|
-
*/
|
|
2192
|
-
protected applyClientAuthenticationOptions(opts: GaxiosOptions, bearerToken?: string): void;
|
|
2193
|
-
/**
|
|
2194
|
-
* Applies client authentication on the request's header if either
|
|
2195
|
-
* basic authentication or bearer token authentication is selected.
|
|
2196
|
-
*
|
|
2197
|
-
* @param opts The GaxiosOptions whose headers or data are to be modified
|
|
2198
|
-
* depending on the client authentication mechanism to be used.
|
|
2199
|
-
* @param bearerToken The optional bearer token to use for authentication.
|
|
2200
|
-
* When this is used, no client authentication credentials are needed.
|
|
2201
|
-
*/
|
|
2202
|
-
private injectAuthenticatedHeaders;
|
|
2203
|
-
/**
|
|
2204
|
-
* Applies client authentication on the request's body if request-body
|
|
2205
|
-
* client authentication is selected.
|
|
2206
|
-
*
|
|
2207
|
-
* @param opts The GaxiosOptions whose headers or data are to be modified
|
|
2208
|
-
* depending on the client authentication mechanism to be used.
|
|
2209
|
-
*/
|
|
2210
|
-
private injectAuthenticatedRequestBody;
|
|
2211
|
-
/**
|
|
2212
|
-
* Retry config for Auth-related requests.
|
|
2213
|
-
*
|
|
2214
|
-
* @remarks
|
|
2215
|
-
*
|
|
2216
|
-
* This is not a part of the default {@link AuthClient.transporter transporter/gaxios}
|
|
2217
|
-
* config as some downstream APIs would prefer if customers explicitly enable retries,
|
|
2218
|
-
* such as GCS.
|
|
2219
|
-
*/
|
|
2220
|
-
protected static get RETRY_CONFIG(): GaxiosOptions;
|
|
2221
|
-
}
|
|
2222
|
-
/**
|
|
2223
|
-
* Defines the interface needed to initialize an StsCredentials instance.
|
|
2224
|
-
* The interface does not directly map to the spec and instead is converted
|
|
2225
|
-
* to be compliant with the JavaScript style guide. This is because this is
|
|
2226
|
-
* instantiated internally.
|
|
2227
|
-
* StsCredentials implement the OAuth 2.0 token exchange based on
|
|
2228
|
-
* https://tools.ietf.org/html/rfc8693.
|
|
2229
|
-
* Request options are defined in
|
|
2230
|
-
* https://tools.ietf.org/html/rfc8693#section-2.1
|
|
2231
|
-
*/
|
|
2232
|
-
interface StsCredentialsOptions {
|
|
2233
|
-
/**
|
|
2234
|
-
* REQUIRED. The value "urn:ietf:params:oauth:grant-type:token-exchange"
|
|
2235
|
-
* indicates that a token exchange is being performed.
|
|
2236
|
-
*/
|
|
2237
|
-
grantType: string;
|
|
2238
|
-
/**
|
|
2239
|
-
* OPTIONAL. A URI that indicates the target service or resource where the
|
|
2240
|
-
* client intends to use the requested security token.
|
|
2241
|
-
*/
|
|
2242
|
-
resource?: string;
|
|
2243
|
-
/**
|
|
2244
|
-
* OPTIONAL. The logical name of the target service where the client
|
|
2245
|
-
* intends to use the requested security token. This serves a purpose
|
|
2246
|
-
* similar to the "resource" parameter but with the client providing a
|
|
2247
|
-
* logical name for the target service.
|
|
2248
|
-
*/
|
|
2249
|
-
audience?: string;
|
|
2250
|
-
/**
|
|
2251
|
-
* OPTIONAL. A list of space-delimited, case-sensitive strings, as defined
|
|
2252
|
-
* in Section 3.3 of [RFC6749], that allow the client to specify the desired
|
|
2253
|
-
* scope of the requested security token in the context of the service or
|
|
2254
|
-
* resource where the token will be used.
|
|
2255
|
-
*/
|
|
2256
|
-
scope?: string[];
|
|
2257
|
-
/**
|
|
2258
|
-
* OPTIONAL. An identifier, as described in Section 3 of [RFC8693], eg.
|
|
2259
|
-
* "urn:ietf:params:oauth:token-type:access_token" for the type of the
|
|
2260
|
-
* requested security token.
|
|
2261
|
-
*/
|
|
2262
|
-
requestedTokenType?: string;
|
|
2263
|
-
/**
|
|
2264
|
-
* REQUIRED. A security token that represents the identity of the party on
|
|
2265
|
-
* behalf of whom the request is being made.
|
|
2266
|
-
*/
|
|
2267
|
-
subjectToken: string;
|
|
2268
|
-
/**
|
|
2269
|
-
* REQUIRED. An identifier, as described in Section 3 of [RFC8693], that
|
|
2270
|
-
* indicates the type of the security token in the "subject_token" parameter.
|
|
2271
|
-
*/
|
|
2272
|
-
subjectTokenType: string;
|
|
2273
|
-
actingParty?: {
|
|
2274
|
-
/**
|
|
2275
|
-
* OPTIONAL. A security token that represents the identity of the acting
|
|
2276
|
-
* party. Typically, this will be the party that is authorized to use the
|
|
2277
|
-
* requested security token and act on behalf of the subject.
|
|
2278
|
-
*/
|
|
2279
|
-
actorToken: string;
|
|
2280
|
-
/**
|
|
2281
|
-
* An identifier, as described in Section 3, that indicates the type of the
|
|
2282
|
-
* security token in the "actor_token" parameter. This is REQUIRED when the
|
|
2283
|
-
* "actor_token" parameter is present in the request but MUST NOT be
|
|
2284
|
-
* included otherwise.
|
|
2285
|
-
*/
|
|
2286
|
-
actorTokenType: string;
|
|
2287
|
-
};
|
|
2288
|
-
}
|
|
2289
|
-
/**
|
|
2290
|
-
* Defines the OAuth 2.0 token exchange successful response based on
|
|
2291
|
-
* https://tools.ietf.org/html/rfc8693#section-2.2.1
|
|
2292
|
-
*/
|
|
2293
|
-
interface StsSuccessfulResponse {
|
|
2294
|
-
access_token: string;
|
|
2295
|
-
issued_token_type: string;
|
|
2296
|
-
token_type: string;
|
|
2297
|
-
expires_in?: number;
|
|
2298
|
-
refresh_token?: string;
|
|
2299
|
-
scope?: string;
|
|
2300
|
-
res?: GaxiosResponse | null;
|
|
2301
|
-
}
|
|
2302
|
-
interface StsCredentialsConstructionOptions extends OAuthClientAuthHandlerOptions {
|
|
2303
|
-
/**
|
|
2304
|
-
* The client authentication credentials if available.
|
|
2305
|
-
*/
|
|
2306
|
-
clientAuthentication?: ClientAuthentication;
|
|
2307
|
-
/**
|
|
2308
|
-
* The token exchange endpoint.
|
|
2309
|
-
*/
|
|
2310
|
-
tokenExchangeEndpoint: string | URL;
|
|
2311
|
-
}
|
|
2312
|
-
/**
|
|
2313
|
-
* Implements the OAuth 2.0 token exchange based on
|
|
2314
|
-
* https://tools.ietf.org/html/rfc8693
|
|
2315
|
-
*/
|
|
2316
|
-
declare class StsCredentials extends OAuthClientAuthHandler {
|
|
2317
|
-
#private;
|
|
2318
|
-
/**
|
|
2319
|
-
* Initializes an STS credentials instance.
|
|
2320
|
-
*
|
|
2321
|
-
* @param options The STS credentials instance options. Passing an `tokenExchangeEndpoint` directly is **@DEPRECATED**.
|
|
2322
|
-
* @param clientAuthentication **@DEPRECATED**. Provide a {@link StsCredentialsConstructionOptions `StsCredentialsConstructionOptions`} object in the first parameter instead.
|
|
2323
|
-
*/
|
|
2324
|
-
constructor(options?: StsCredentialsConstructionOptions | string | URL,
|
|
2325
|
-
/**
|
|
2326
|
-
* @deprecated - provide a {@link StsCredentialsConstructionOptions `StsCredentialsConstructionOptions`} object in the first parameter instead
|
|
2327
|
-
*/
|
|
2328
|
-
|
|
2329
|
-
clientAuthentication?: ClientAuthentication);
|
|
2330
|
-
/**
|
|
2331
|
-
* Exchanges the provided token for another type of token based on the
|
|
2332
|
-
* rfc8693 spec.
|
|
2333
|
-
* @param stsCredentialsOptions The token exchange options used to populate
|
|
2334
|
-
* the token exchange request.
|
|
2335
|
-
* @param additionalHeaders Optional additional headers to pass along the
|
|
2336
|
-
* request.
|
|
2337
|
-
* @param options Optional additional GCP-specific non-spec defined options
|
|
2338
|
-
* to send with the request.
|
|
2339
|
-
* Example: `&options=${encodeUriComponent(JSON.stringified(options))}`
|
|
2340
|
-
* @return A promise that resolves with the token exchange response containing
|
|
2341
|
-
* the requested token and its expiration time.
|
|
2342
|
-
*/
|
|
2343
|
-
exchangeToken(stsCredentialsOptions: StsCredentialsOptions, headers?: HeadersInit, options?: Parameters<JSON['stringify']>[0]): Promise<StsSuccessfulResponse>;
|
|
2344
|
-
}
|
|
2345
|
-
/**
|
|
2346
|
-
* Shared options used to build {@link ExternalAccountClient} and
|
|
2347
|
-
* {@link ExternalAccountAuthorizedUserClient}.
|
|
2348
|
-
*/
|
|
2349
|
-
interface SharedExternalAccountClientOptions extends AuthClientOptions {
|
|
2350
|
-
/**
|
|
2351
|
-
* The Security Token Service audience, which is usually the fully specified
|
|
2352
|
-
* resource name of the workload or workforce pool provider.
|
|
2353
|
-
*/
|
|
2354
|
-
audience: string;
|
|
2355
|
-
/**
|
|
2356
|
-
* The Security Token Service token URL used to exchange the third party token
|
|
2357
|
-
* for a GCP access token. If not provided, will default to
|
|
2358
|
-
* 'https://sts.googleapis.com/v1/token'
|
|
2359
|
-
*/
|
|
2360
|
-
token_url?: string;
|
|
2361
|
-
}
|
|
2362
|
-
/**
|
|
2363
|
-
* Interface containing context about the requested external identity. This is
|
|
2364
|
-
* passed on all requests from external account clients to external identity suppliers.
|
|
2365
|
-
*/
|
|
2366
|
-
interface ExternalAccountSupplierContext {
|
|
2367
|
-
/**
|
|
2368
|
-
* The requested external account audience. For example:
|
|
2369
|
-
* * "//iam.googleapis.com/locations/global/workforcePools/$WORKFORCE_POOL_ID/providers/$PROVIDER_ID"
|
|
2370
|
-
* * "//iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL_ID/providers/PROVIDER_ID"
|
|
2371
|
-
*/
|
|
2372
|
-
audience: string;
|
|
2373
|
-
/**
|
|
2374
|
-
* The requested subject token type. Expected values include:
|
|
2375
|
-
* * "urn:ietf:params:oauth:token-type:jwt"
|
|
2376
|
-
* * "urn:ietf:params:aws:token-type:aws4_request"
|
|
2377
|
-
* * "urn:ietf:params:oauth:token-type:saml2"
|
|
2378
|
-
* * "urn:ietf:params:oauth:token-type:id_token"
|
|
2379
|
-
*/
|
|
2380
|
-
subjectTokenType: string;
|
|
2381
|
-
/**
|
|
2382
|
-
* The {@link Gaxios} instance for calling external account
|
|
2383
|
-
* to use for requests.
|
|
2384
|
-
*/
|
|
2385
|
-
transporter: Gaxios;
|
|
2386
|
-
}
|
|
2387
|
-
/**
|
|
2388
|
-
* Base external account credentials json interface.
|
|
2389
|
-
*/
|
|
2390
|
-
interface BaseExternalAccountClientOptions extends SharedExternalAccountClientOptions {
|
|
2391
|
-
/**
|
|
2392
|
-
* Credential type, should always be 'external_account'.
|
|
2393
|
-
*/
|
|
2394
|
-
type?: string;
|
|
2395
|
-
/**
|
|
2396
|
-
* The Security Token Service subject token type based on the OAuth 2.0
|
|
2397
|
-
* token exchange spec. Expected values include:
|
|
2398
|
-
* * 'urn:ietf:params:oauth:token-type:jwt'
|
|
2399
|
-
* * 'urn:ietf:params:aws:token-type:aws4_request'
|
|
2400
|
-
* * 'urn:ietf:params:oauth:token-type:saml2'
|
|
2401
|
-
* * 'urn:ietf:params:oauth:token-type:id_token'
|
|
2402
|
-
*/
|
|
2403
|
-
subject_token_type: string;
|
|
2404
|
-
/**
|
|
2405
|
-
* The URL for the service account impersonation request. This URL is required
|
|
2406
|
-
* for some APIs. If this URL is not available, the access token from the
|
|
2407
|
-
* Security Token Service is used directly.
|
|
2408
|
-
*/
|
|
2409
|
-
service_account_impersonation_url?: string;
|
|
2410
|
-
/**
|
|
2411
|
-
* Object containing additional options for service account impersonation.
|
|
2412
|
-
*/
|
|
2413
|
-
service_account_impersonation?: {
|
|
2414
|
-
/**
|
|
2415
|
-
* The desired lifetime of the impersonated service account access token.
|
|
2416
|
-
* If not provided, the default lifetime will be 3600 seconds.
|
|
2417
|
-
*/
|
|
2418
|
-
token_lifetime_seconds?: number;
|
|
2419
|
-
};
|
|
2420
|
-
/**
|
|
2421
|
-
* The endpoint used to retrieve account related information.
|
|
2422
|
-
*/
|
|
2423
|
-
token_info_url?: string;
|
|
2424
|
-
/**
|
|
2425
|
-
* Client ID of the service account from the console.
|
|
2426
|
-
*/
|
|
2427
|
-
client_id?: string;
|
|
2428
|
-
/**
|
|
2429
|
-
* Client secret of the service account from the console.
|
|
2430
|
-
*/
|
|
2431
|
-
client_secret?: string;
|
|
2432
|
-
/**
|
|
2433
|
-
* The workforce pool user project. Required when using a workforce identity
|
|
2434
|
-
* pool.
|
|
2435
|
-
*/
|
|
2436
|
-
workforce_pool_user_project?: string;
|
|
2437
|
-
/**
|
|
2438
|
-
* The scopes to request during the authorization grant.
|
|
2439
|
-
*/
|
|
2440
|
-
scopes?: string[];
|
|
2441
|
-
/**
|
|
2442
|
-
* @example
|
|
2443
|
-
* https://cloudresourcemanager.googleapis.com/v1/projects/
|
|
2444
|
-
**/
|
|
2445
|
-
cloud_resource_manager_url?: string | URL;
|
|
2446
|
-
}
|
|
2447
|
-
/**
|
|
2448
|
-
* Interface defining the successful response for iamcredentials
|
|
2449
|
-
* generateAccessToken API.
|
|
2450
|
-
* https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/generateAccessToken
|
|
2451
|
-
*/
|
|
2452
|
-
interface IamGenerateAccessTokenResponse {
|
|
2453
|
-
accessToken: string;
|
|
2454
|
-
/**
|
|
2455
|
-
* ISO format used for expiration time.
|
|
2456
|
-
*
|
|
2457
|
-
* @example
|
|
2458
|
-
* '2014-10-02T15:01:23.045123456Z'
|
|
2459
|
-
*/
|
|
2460
|
-
expireTime: string;
|
|
2461
|
-
}
|
|
2462
|
-
/**
|
|
2463
|
-
* Internal interface for tracking the access token expiration time.
|
|
2464
|
-
*/
|
|
2465
|
-
interface CredentialsWithResponse$2 extends Credentials {
|
|
2466
|
-
res?: GaxiosResponse | null;
|
|
2467
|
-
}
|
|
2468
|
-
/**
|
|
2469
|
-
* Base external account client. This is used to instantiate AuthClients for
|
|
2470
|
-
* exchanging external account credentials for GCP access token and authorizing
|
|
2471
|
-
* requests to GCP APIs.
|
|
2472
|
-
* The base class implements common logic for exchanging various type of
|
|
2473
|
-
* external credentials for GCP access token. The logic of determining and
|
|
2474
|
-
* retrieving the external credential based on the environment and
|
|
2475
|
-
* credential_source will be left for the subclasses.
|
|
2476
|
-
*/
|
|
2477
|
-
declare abstract class BaseExternalAccountClient extends AuthClient {
|
|
2478
|
-
#private;
|
|
2479
|
-
/**
|
|
2480
|
-
* OAuth scopes for the GCP access token to use. When not provided,
|
|
2481
|
-
* the default https://www.googleapis.com/auth/cloud-platform is
|
|
2482
|
-
* used.
|
|
2483
|
-
*/
|
|
2484
|
-
scopes?: string | string[];
|
|
2485
|
-
projectNumber: string | null;
|
|
2486
|
-
protected readonly audience: string;
|
|
2487
|
-
protected readonly subjectTokenType: string;
|
|
2488
|
-
protected stsCredential: StsCredentials;
|
|
2489
|
-
protected readonly clientAuth?: ClientAuthentication;
|
|
2490
|
-
protected credentialSourceType?: string;
|
|
2491
|
-
private cachedAccessToken;
|
|
2492
|
-
private readonly serviceAccountImpersonationUrl?;
|
|
2493
|
-
private readonly serviceAccountImpersonationLifetime?;
|
|
2494
|
-
private readonly workforcePoolUserProject?;
|
|
2495
|
-
private readonly configLifetimeRequested;
|
|
2496
|
-
private readonly tokenUrl;
|
|
2497
|
-
/**
|
|
2498
|
-
* @example
|
|
2499
|
-
* ```ts
|
|
2500
|
-
* new URL('https://cloudresourcemanager.googleapis.com/v1/projects/');
|
|
2501
|
-
* ```
|
|
2502
|
-
*/
|
|
2503
|
-
protected cloudResourceManagerURL: URL | string;
|
|
2504
|
-
protected supplierContext: ExternalAccountSupplierContext;
|
|
2505
|
-
/**
|
|
2506
|
-
* Instantiate a BaseExternalAccountClient instance using the provided JSON
|
|
2507
|
-
* object loaded from an external account credentials file.
|
|
2508
|
-
* @param options The external account options object typically loaded
|
|
2509
|
-
* from the external account JSON credential file. The camelCased options
|
|
2510
|
-
* are aliases for the snake_cased options.
|
|
2511
|
-
*/
|
|
2512
|
-
constructor(options: BaseExternalAccountClientOptions | SnakeToCamelObject<BaseExternalAccountClientOptions>);
|
|
2513
|
-
/** The service account email to be impersonated, if available. */
|
|
2514
|
-
getServiceAccountEmail(): string | null;
|
|
2515
|
-
/**
|
|
2516
|
-
* Provides a mechanism to inject GCP access tokens directly.
|
|
2517
|
-
* When the provided credential expires, a new credential, using the
|
|
2518
|
-
* external account options, is retrieved.
|
|
2519
|
-
* @param credentials The Credentials object to set on the current client.
|
|
2520
|
-
*/
|
|
2521
|
-
setCredentials(credentials: Credentials): void;
|
|
2522
|
-
/**
|
|
2523
|
-
* Triggered when a external subject token is needed to be exchanged for a GCP
|
|
2524
|
-
* access token via GCP STS endpoint.
|
|
2525
|
-
* This abstract method needs to be implemented by subclasses depending on
|
|
2526
|
-
* the type of external credential used.
|
|
2527
|
-
* @return A promise that resolves with the external subject token.
|
|
2528
|
-
*/
|
|
2529
|
-
abstract retrieveSubjectToken(): Promise<string>;
|
|
2530
|
-
/**
|
|
2531
|
-
* @return A promise that resolves with the current GCP access token
|
|
2532
|
-
* response. If the current credential is expired, a new one is retrieved.
|
|
2533
|
-
*/
|
|
2534
|
-
getAccessToken(): Promise<GetAccessTokenResponse>;
|
|
2535
|
-
/**
|
|
2536
|
-
* The main authentication interface. It takes an optional url which when
|
|
2537
|
-
* present is the endpoint being accessed, and returns a Promise which
|
|
2538
|
-
* resolves with authorization header fields.
|
|
2539
|
-
*
|
|
2540
|
-
* The result has the form:
|
|
2541
|
-
* { authorization: 'Bearer <access_token_value>' }
|
|
2542
|
-
*/
|
|
2543
|
-
getRequestHeaders(): Promise<Headers>;
|
|
2544
|
-
/**
|
|
2545
|
-
* Provides a request implementation with OAuth 2.0 flow. In cases of
|
|
2546
|
-
* HTTP 401 and 403 responses, it automatically asks for a new access token
|
|
2547
|
-
* and replays the unsuccessful request.
|
|
2548
|
-
* @param opts Request options.
|
|
2549
|
-
* @param callback callback.
|
|
2550
|
-
* @return A promise that resolves with the HTTP response when no callback is
|
|
2551
|
-
* provided.
|
|
2552
|
-
*/
|
|
2553
|
-
request<T>(opts: GaxiosOptions): GaxiosPromise<T>;
|
|
2554
|
-
request<T>(opts: GaxiosOptions, callback: BodyResponseCallback<T>): void;
|
|
2555
|
-
/**
|
|
2556
|
-
* @return A promise that resolves with the project ID corresponding to the
|
|
2557
|
-
* current workload identity pool or current workforce pool if
|
|
2558
|
-
* determinable. For workforce pool credential, it returns the project ID
|
|
2559
|
-
* corresponding to the workforcePoolUserProject.
|
|
2560
|
-
* This is introduced to match the current pattern of using the Auth
|
|
2561
|
-
* library:
|
|
2562
|
-
* const projectId = await auth.getProjectId();
|
|
2563
|
-
* const url = `https://dns.googleapis.com/dns/v1/projects/${projectId}`;
|
|
2564
|
-
* const res = await client.request({ url });
|
|
2565
|
-
* The resource may not have permission
|
|
2566
|
-
* (resourcemanager.projects.get) to call this API or the required
|
|
2567
|
-
* scopes may not be selected:
|
|
2568
|
-
* https://cloud.google.com/resource-manager/reference/rest/v1/projects/get#authorization-scopes
|
|
2569
|
-
*/
|
|
2570
|
-
getProjectId(): Promise<string | null>;
|
|
2571
|
-
/**
|
|
2572
|
-
* Authenticates the provided HTTP request, processes it and resolves with the
|
|
2573
|
-
* returned response.
|
|
2574
|
-
* @param opts The HTTP request options.
|
|
2575
|
-
* @param reAuthRetried Whether the current attempt is a retry after a failed attempt due to an auth failure.
|
|
2576
|
-
* @return A promise that resolves with the successful response.
|
|
2577
|
-
*/
|
|
2578
|
-
protected requestAsync<T>(opts: GaxiosOptions, reAuthRetried?: boolean): Promise<GaxiosResponse<T>>;
|
|
2579
|
-
/**
|
|
2580
|
-
* Forces token refresh, even if unexpired tokens are currently cached.
|
|
2581
|
-
* External credentials are exchanged for GCP access tokens via the token
|
|
2582
|
-
* exchange endpoint and other settings provided in the client options
|
|
2583
|
-
* object.
|
|
2584
|
-
* If the service_account_impersonation_url is provided, an additional
|
|
2585
|
-
* step to exchange the external account GCP access token for a service
|
|
2586
|
-
* account impersonated token is performed.
|
|
2587
|
-
* @return A promise that resolves with the fresh GCP access tokens.
|
|
2588
|
-
*/
|
|
2589
|
-
protected refreshAccessTokenAsync(): Promise<CredentialsWithResponse$2>;
|
|
2590
|
-
/**
|
|
2591
|
-
* Returns the workload identity pool project number if it is determinable
|
|
2592
|
-
* from the audience resource name.
|
|
2593
|
-
* @param audience The STS audience used to determine the project number.
|
|
2594
|
-
* @return The project number associated with the workload identity pool, if
|
|
2595
|
-
* this can be determined from the STS audience field. Otherwise, null is
|
|
2596
|
-
* returned.
|
|
2597
|
-
*/
|
|
2598
|
-
private getProjectNumber;
|
|
2599
|
-
/**
|
|
2600
|
-
* Exchanges an external account GCP access token for a service
|
|
2601
|
-
* account impersonated access token using iamcredentials
|
|
2602
|
-
* GenerateAccessToken API.
|
|
2603
|
-
* @param token The access token to exchange for a service account access
|
|
2604
|
-
* token.
|
|
2605
|
-
* @return A promise that resolves with the service account impersonated
|
|
2606
|
-
* credentials response.
|
|
2607
|
-
*/
|
|
2608
|
-
private getImpersonatedAccessToken;
|
|
2609
|
-
/**
|
|
2610
|
-
* Returns whether the provided credentials are expired or not.
|
|
2611
|
-
* If there is no expiry time, assumes the token is not expired or expiring.
|
|
2612
|
-
* @param accessToken The credentials to check for expiration.
|
|
2613
|
-
* @return Whether the credentials are expired or not.
|
|
2614
|
-
*/
|
|
2615
|
-
private isExpired;
|
|
2616
|
-
/**
|
|
2617
|
-
* @return The list of scopes for the requested GCP access token.
|
|
2618
|
-
*/
|
|
2619
|
-
private getScopesArray;
|
|
2620
|
-
private getMetricsHeaderValue;
|
|
2621
|
-
protected getTokenUrl(): string;
|
|
2622
|
-
}
|
|
2623
|
-
type SubjectTokenFormatType = 'json' | 'text';
|
|
2624
|
-
/**
|
|
2625
|
-
* Supplier interface for subject tokens. This can be implemented to
|
|
2626
|
-
* return a subject token which can then be exchanged for a GCP token by an
|
|
2627
|
-
* {@link IdentityPoolClient}.
|
|
2628
|
-
*/
|
|
2629
|
-
interface SubjectTokenSupplier {
|
|
2630
|
-
/**
|
|
2631
|
-
* Gets a valid subject token for the requested external account identity.
|
|
2632
|
-
* Note that these are not cached by the calling {@link IdentityPoolClient},
|
|
2633
|
-
* so caching should be including in the implementation.
|
|
2634
|
-
* @param context {@link ExternalAccountSupplierContext} from the calling
|
|
2635
|
-
* {@link IdentityPoolClient}, contains the requested audience and subject token type
|
|
2636
|
-
* for the external account identity as well as the transport from the
|
|
2637
|
-
* calling client to use for requests.
|
|
2638
|
-
* @return A promise that resolves with the requested subject token string.
|
|
2639
|
-
*/
|
|
2640
|
-
getSubjectToken: (context: ExternalAccountSupplierContext) => Promise<string>;
|
|
2641
|
-
}
|
|
2642
|
-
/**
|
|
2643
|
-
* Url-sourced/file-sourced credentials json interface.
|
|
2644
|
-
* This is used for K8s and Azure workloads.
|
|
2645
|
-
*/
|
|
2646
|
-
interface IdentityPoolClientOptions extends BaseExternalAccountClientOptions {
|
|
2647
|
-
/**
|
|
2648
|
-
* Object containing options to retrieve identity pool credentials. A valid credential
|
|
2649
|
-
* source or a subject token supplier must be specified.
|
|
2650
|
-
*/
|
|
2651
|
-
credential_source?: {
|
|
2652
|
-
/**
|
|
2653
|
-
* The file location to read the subject token from. Either this, a URL
|
|
2654
|
-
* or a certificate location should be specified.
|
|
2655
|
-
*/
|
|
2656
|
-
file?: string;
|
|
2657
|
-
/**
|
|
2658
|
-
* The URL to call to retrieve the subject token. Either this, a file
|
|
2659
|
-
* location or a certificate location should be specified.
|
|
2660
|
-
*/
|
|
2661
|
-
url?: string;
|
|
2662
|
-
/**
|
|
2663
|
-
* Optional headers to send on the request to the specified URL.
|
|
2664
|
-
*/
|
|
2665
|
-
headers?: {
|
|
2666
|
-
[key: string]: string;
|
|
2667
|
-
};
|
|
2668
|
-
/**
|
|
2669
|
-
* The format that the subject token is in the file or the URL response.
|
|
2670
|
-
* If not provided, will default to reading the text string directly.
|
|
2671
|
-
*/
|
|
2672
|
-
format?: {
|
|
2673
|
-
/**
|
|
2674
|
-
* The format type. Can either be 'text' or 'json'.
|
|
2675
|
-
*/
|
|
2676
|
-
type: SubjectTokenFormatType;
|
|
2677
|
-
/**
|
|
2678
|
-
* The field name containing the subject token value if the type is 'json'.
|
|
2679
|
-
*/
|
|
2680
|
-
subject_token_field_name?: string;
|
|
2681
|
-
};
|
|
2682
|
-
/**
|
|
2683
|
-
* The certificate location to call to retrieve the subject token. Either this, a file
|
|
2684
|
-
* location, or an url should be specified.
|
|
2685
|
-
* @example
|
|
2686
|
-
* File Format:
|
|
2687
|
-
* ```json
|
|
2688
|
-
* {
|
|
2689
|
-
* "cert_configs": {
|
|
2690
|
-
* "workload": {
|
|
2691
|
-
* "key_path": "$PATH_TO_LEAF_KEY",
|
|
2692
|
-
* "cert_path": "$PATH_TO_LEAF_CERT"
|
|
2693
|
-
* }
|
|
2694
|
-
* }
|
|
2695
|
-
* }
|
|
2696
|
-
* ```
|
|
2697
|
-
*/
|
|
2698
|
-
certificate?: {
|
|
2699
|
-
/**
|
|
2700
|
-
* Specify whether the certificate config should be used from the default location.
|
|
2701
|
-
* Either this or the certificate_config_location must be provided.
|
|
2702
|
-
* The certificate config file must be in the following JSON format:
|
|
2703
|
-
*/
|
|
2704
|
-
use_default_certificate_config?: boolean;
|
|
2705
|
-
/**
|
|
2706
|
-
* Location to fetch certificate config from in case default config is not to be used.
|
|
2707
|
-
* Either this or use_default_certificate_config=true should be provided.
|
|
2708
|
-
*/
|
|
2709
|
-
certificate_config_location?: string;
|
|
2710
|
-
/**
|
|
2711
|
-
* TrustChainPath specifies the path to a PEM-formatted file containing the X.509 certificate trust chain.
|
|
2712
|
-
* The file should contain any intermediate certificates needed to connect
|
|
2713
|
-
* the mTLS leaf certificate to a root certificate in the trust store.
|
|
2714
|
-
*/
|
|
2715
|
-
trust_chain_path?: string;
|
|
2716
|
-
};
|
|
2717
|
-
};
|
|
2718
|
-
/**
|
|
2719
|
-
* The subject token supplier to call to retrieve the subject token to exchange
|
|
2720
|
-
* for a GCP access token. Either this or a valid credential source should
|
|
2721
|
-
* be specified.
|
|
2722
|
-
*/
|
|
2723
|
-
subject_token_supplier?: SubjectTokenSupplier;
|
|
2724
|
-
}
|
|
2725
|
-
/**
|
|
2726
|
-
* Defines the Url-sourced and file-sourced external account clients mainly
|
|
2727
|
-
* used for K8s and Azure workloads.
|
|
2728
|
-
*/
|
|
2729
|
-
declare class IdentityPoolClient extends BaseExternalAccountClient {
|
|
2730
|
-
private readonly subjectTokenSupplier;
|
|
2731
|
-
/**
|
|
2732
|
-
* Instantiate an IdentityPoolClient instance using the provided JSON
|
|
2733
|
-
* object loaded from an external account credentials file.
|
|
2734
|
-
* An error is thrown if the credential is not a valid file-sourced or
|
|
2735
|
-
* url-sourced credential or a workforce pool user project is provided
|
|
2736
|
-
* with a non workforce audience.
|
|
2737
|
-
* @param options The external account options object typically loaded
|
|
2738
|
-
* from the external account JSON credential file. The camelCased options
|
|
2739
|
-
* are aliases for the snake_cased options.
|
|
2740
|
-
*/
|
|
2741
|
-
constructor(options: IdentityPoolClientOptions | SnakeToCamelObject<IdentityPoolClientOptions>);
|
|
2742
|
-
/**
|
|
2743
|
-
* Triggered when a external subject token is needed to be exchanged for a GCP
|
|
2744
|
-
* access token via GCP STS endpoint. Gets a subject token by calling
|
|
2745
|
-
* the configured {@link SubjectTokenSupplier}
|
|
2746
|
-
* @return A promise that resolves with the external subject token.
|
|
2747
|
-
*/
|
|
2748
|
-
retrieveSubjectToken(): Promise<string>;
|
|
2749
|
-
}
|
|
2750
|
-
/**
|
|
2751
|
-
* Interface defining AWS security credentials.
|
|
2752
|
-
* These are either determined from AWS security_credentials endpoint or
|
|
2753
|
-
* AWS environment variables.
|
|
2754
|
-
*/
|
|
2755
|
-
interface AwsSecurityCredentials {
|
|
2756
|
-
accessKeyId: string;
|
|
2757
|
-
secretAccessKey: string;
|
|
2758
|
-
token?: string;
|
|
2759
|
-
}
|
|
2760
|
-
/**
|
|
2761
|
-
* Implements an AWS API request signer based on the AWS Signature Version 4
|
|
2762
|
-
* signing process.
|
|
2763
|
-
* https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
|
|
2764
|
-
*/
|
|
2765
|
-
declare class AwsRequestSigner {
|
|
2766
|
-
private readonly getCredentials;
|
|
2767
|
-
private readonly region;
|
|
2768
|
-
private readonly crypto;
|
|
2769
|
-
/**
|
|
2770
|
-
* Instantiates an AWS API request signer used to send authenticated signed
|
|
2771
|
-
* requests to AWS APIs based on the AWS Signature Version 4 signing process.
|
|
2772
|
-
* This also provides a mechanism to generate the signed request without
|
|
2773
|
-
* sending it.
|
|
2774
|
-
* @param getCredentials A mechanism to retrieve AWS security credentials
|
|
2775
|
-
* when needed.
|
|
2776
|
-
* @param region The AWS region to use.
|
|
2777
|
-
*/
|
|
2778
|
-
constructor(getCredentials: () => Promise<AwsSecurityCredentials>, region: string);
|
|
2779
|
-
/**
|
|
2780
|
-
* Generates the signed request for the provided HTTP request for calling
|
|
2781
|
-
* an AWS API. This follows the steps described at:
|
|
2782
|
-
* https://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html
|
|
2783
|
-
* @param amzOptions The AWS request options that need to be signed.
|
|
2784
|
-
* @return A promise that resolves with the GaxiosOptions containing the
|
|
2785
|
-
* signed HTTP request parameters.
|
|
2786
|
-
*/
|
|
2787
|
-
getRequestOptions(amzOptions: GaxiosOptions): Promise<GaxiosOptions>;
|
|
2788
|
-
}
|
|
2789
|
-
/**
|
|
2790
|
-
* AWS credentials JSON interface. This is used for AWS workloads.
|
|
2791
|
-
*/
|
|
2792
|
-
interface AwsClientOptions extends BaseExternalAccountClientOptions {
|
|
2793
|
-
/**
|
|
2794
|
-
* Object containing options to retrieve AWS security credentials. A valid credential
|
|
2795
|
-
* source or a aws security credentials supplier should be specified.
|
|
2796
|
-
*/
|
|
2797
|
-
credential_source?: {
|
|
2798
|
-
/**
|
|
2799
|
-
* AWS environment ID. Currently only 'AWS1' is supported.
|
|
2800
|
-
*/
|
|
2801
|
-
environment_id: string;
|
|
2802
|
-
/**
|
|
2803
|
-
* The EC2 metadata URL to retrieve the current AWS region from. If this is
|
|
2804
|
-
* not provided, the region should be present in the AWS_REGION or AWS_DEFAULT_REGION
|
|
2805
|
-
* environment variables.
|
|
2806
|
-
*/
|
|
2807
|
-
region_url?: string;
|
|
2808
|
-
/**
|
|
2809
|
-
* The EC2 metadata URL to retrieve AWS security credentials. If this is not provided,
|
|
2810
|
-
* the credentials should be present in the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,
|
|
2811
|
-
* and AWS_SESSION_TOKEN environment variables.
|
|
2812
|
-
*/
|
|
2813
|
-
url?: string;
|
|
2814
|
-
/**
|
|
2815
|
-
* The regional GetCallerIdentity action URL, used to determine the account
|
|
2816
|
-
* ID and its roles.
|
|
2817
|
-
*/
|
|
2818
|
-
regional_cred_verification_url: string;
|
|
2819
|
-
/**
|
|
2820
|
-
* The imdsv2 session token url is used to fetch session token from AWS
|
|
2821
|
-
* which is later sent through headers for metadata requests. If the
|
|
2822
|
-
* field is missing, then session token won't be fetched and sent with
|
|
2823
|
-
* the metadata requests.
|
|
2824
|
-
* The session token is required for IMDSv2 but optional for IMDSv1
|
|
2825
|
-
*/
|
|
2826
|
-
imdsv2_session_token_url?: string;
|
|
2827
|
-
};
|
|
2828
|
-
/**
|
|
2829
|
-
* The AWS security credentials supplier to call to retrieve the AWS region
|
|
2830
|
-
* and AWS security credentials. Either this or a valid credential source
|
|
2831
|
-
* must be specified.
|
|
2832
|
-
*/
|
|
2833
|
-
aws_security_credentials_supplier?: AwsSecurityCredentialsSupplier;
|
|
2834
|
-
}
|
|
2835
|
-
/**
|
|
2836
|
-
* Supplier interface for AWS security credentials. This can be implemented to
|
|
2837
|
-
* return an AWS region and AWS security credentials. These credentials can
|
|
2838
|
-
* then be exchanged for a GCP token by an {@link AwsClient}.
|
|
2839
|
-
*/
|
|
2840
|
-
interface AwsSecurityCredentialsSupplier {
|
|
2841
|
-
/**
|
|
2842
|
-
* Gets the active AWS region.
|
|
2843
|
-
* @param context {@link ExternalAccountSupplierContext} from the calling
|
|
2844
|
-
* {@link AwsClient}, contains the requested audience and subject token type
|
|
2845
|
-
* for the external account identity as well as the transport from the
|
|
2846
|
-
* calling client to use for requests.
|
|
2847
|
-
* @return A promise that resolves with the AWS region string.
|
|
2848
|
-
*/
|
|
2849
|
-
getAwsRegion: (context: ExternalAccountSupplierContext) => Promise<string>;
|
|
2850
|
-
/**
|
|
2851
|
-
* Gets valid AWS security credentials for the requested external account
|
|
2852
|
-
* identity. Note that these are not cached by the calling {@link AwsClient},
|
|
2853
|
-
* so caching should be including in the implementation.
|
|
2854
|
-
* @param context {@link ExternalAccountSupplierContext} from the calling
|
|
2855
|
-
* {@link AwsClient}, contains the requested audience and subject token type
|
|
2856
|
-
* for the external account identity as well as the transport from the
|
|
2857
|
-
* calling client to use for requests.
|
|
2858
|
-
* @return A promise that resolves with the requested {@link AwsSecurityCredentials}.
|
|
2859
|
-
*/
|
|
2860
|
-
getAwsSecurityCredentials: (context: ExternalAccountSupplierContext) => Promise<AwsSecurityCredentials>;
|
|
2861
|
-
}
|
|
2862
|
-
/**
|
|
2863
|
-
* AWS external account client. This is used for AWS workloads, where
|
|
2864
|
-
* AWS STS GetCallerIdentity serialized signed requests are exchanged for
|
|
2865
|
-
* GCP access token.
|
|
2866
|
-
*/
|
|
2867
|
-
declare class AwsClient extends BaseExternalAccountClient {
|
|
2868
|
-
#private;
|
|
2869
|
-
private readonly environmentId?;
|
|
2870
|
-
private readonly awsSecurityCredentialsSupplier;
|
|
2871
|
-
private readonly regionalCredVerificationUrl;
|
|
2872
|
-
private awsRequestSigner;
|
|
2873
|
-
private region;
|
|
2874
|
-
/**
|
|
2875
|
-
* @deprecated AWS client no validates the EC2 metadata address.
|
|
2876
|
-
**/
|
|
2877
|
-
static AWS_EC2_METADATA_IPV4_ADDRESS: string;
|
|
2878
|
-
/**
|
|
2879
|
-
* @deprecated AWS client no validates the EC2 metadata address.
|
|
2880
|
-
**/
|
|
2881
|
-
static AWS_EC2_METADATA_IPV6_ADDRESS: string;
|
|
2882
|
-
/**
|
|
2883
|
-
* Instantiates an AwsClient instance using the provided JSON
|
|
2884
|
-
* object loaded from an external account credentials file.
|
|
2885
|
-
* An error is thrown if the credential is not a valid AWS credential.
|
|
2886
|
-
* @param options The external account options object typically loaded
|
|
2887
|
-
* from the external account JSON credential file.
|
|
2888
|
-
*/
|
|
2889
|
-
constructor(options: AwsClientOptions | SnakeToCamelObject<AwsClientOptions>);
|
|
2890
|
-
private validateEnvironmentId;
|
|
2891
|
-
/**
|
|
2892
|
-
* Triggered when an external subject token is needed to be exchanged for a
|
|
2893
|
-
* GCP access token via GCP STS endpoint. This will call the
|
|
2894
|
-
* {@link AwsSecurityCredentialsSupplier} to retrieve an AWS region and AWS
|
|
2895
|
-
* Security Credentials, then use them to create a signed AWS STS request that
|
|
2896
|
-
* can be exchanged for a GCP access token.
|
|
2897
|
-
* @return A promise that resolves with the external subject token.
|
|
2898
|
-
*/
|
|
2899
|
-
retrieveSubjectToken(): Promise<string>;
|
|
2900
|
-
}
|
|
2901
|
-
/**
|
|
2902
|
-
* Error thrown from the executable run by PluggableAuthClient.
|
|
2903
|
-
*/
|
|
2904
|
-
declare class ExecutableError extends Error {
|
|
2905
|
-
/**
|
|
2906
|
-
* The exit code returned by the executable.
|
|
2907
|
-
*/
|
|
2908
|
-
readonly code: string;
|
|
2909
|
-
constructor(message: string, code: string);
|
|
2910
|
-
}
|
|
2911
|
-
/**
|
|
2912
|
-
* Defines the credential source portion of the configuration for PluggableAuthClient.
|
|
2913
|
-
*
|
|
2914
|
-
* <p>Command is the only required field. If timeout_millis is not specified, the library will
|
|
2915
|
-
* default to a 30-second timeout.
|
|
2916
|
-
*
|
|
2917
|
-
* <pre>
|
|
2918
|
-
* Sample credential source for Pluggable Auth Client:
|
|
2919
|
-
* {
|
|
2920
|
-
* ...
|
|
2921
|
-
* "credential_source": {
|
|
2922
|
-
* "executable": {
|
|
2923
|
-
* "command": "/path/to/get/credentials.sh --arg1=value1 --arg2=value2",
|
|
2924
|
-
* "timeout_millis": 5000,
|
|
2925
|
-
* "output_file": "/path/to/generated/cached/credentials"
|
|
2926
|
-
* }
|
|
2927
|
-
* }
|
|
2928
|
-
* }
|
|
2929
|
-
* </pre>
|
|
2930
|
-
*/
|
|
2931
|
-
interface PluggableAuthClientOptions extends BaseExternalAccountClientOptions {
|
|
2932
|
-
credential_source: {
|
|
2933
|
-
executable: {
|
|
2934
|
-
/**
|
|
2935
|
-
* The command used to retrieve the 3rd party token.
|
|
2936
|
-
*/
|
|
2937
|
-
command: string;
|
|
2938
|
-
/**
|
|
2939
|
-
* The timeout for executable to run in milliseconds. If none is provided it
|
|
2940
|
-
* will be set to the default timeout of 30 seconds.
|
|
2941
|
-
*/
|
|
2942
|
-
timeout_millis?: number;
|
|
2943
|
-
/**
|
|
2944
|
-
* An optional output file location that will be checked for a cached response
|
|
2945
|
-
* from a previous run of the executable.
|
|
2946
|
-
*/
|
|
2947
|
-
output_file?: string;
|
|
2948
|
-
};
|
|
2949
|
-
};
|
|
2950
|
-
}
|
|
2951
|
-
/**
|
|
2952
|
-
* PluggableAuthClient enables the exchange of workload identity pool external credentials for
|
|
2953
|
-
* Google access tokens by retrieving 3rd party tokens through a user supplied executable. These
|
|
2954
|
-
* scripts/executables are completely independent of the Google Cloud Auth libraries. These
|
|
2955
|
-
* credentials plug into ADC and will call the specified executable to retrieve the 3rd party token
|
|
2956
|
-
* to be exchanged for a Google access token.
|
|
2957
|
-
*
|
|
2958
|
-
* <p>To use these credentials, the GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES environment variable
|
|
2959
|
-
* must be set to '1'. This is for security reasons.
|
|
2960
|
-
*
|
|
2961
|
-
* <p>Both OIDC and SAML are supported. The executable must adhere to a specific response format
|
|
2962
|
-
* defined below.
|
|
2963
|
-
*
|
|
2964
|
-
* <p>The executable must print out the 3rd party token to STDOUT in JSON format. When an
|
|
2965
|
-
* output_file is specified in the credential configuration, the executable must also handle writing the
|
|
2966
|
-
* JSON response to this file.
|
|
2967
|
-
*
|
|
2968
|
-
* <pre>
|
|
2969
|
-
* OIDC response sample:
|
|
2970
|
-
* {
|
|
2971
|
-
* "version": 1,
|
|
2972
|
-
* "success": true,
|
|
2973
|
-
* "token_type": "urn:ietf:params:oauth:token-type:id_token",
|
|
2974
|
-
* "id_token": "HEADER.PAYLOAD.SIGNATURE",
|
|
2975
|
-
* "expiration_time": 1620433341
|
|
2976
|
-
* }
|
|
2977
|
-
*
|
|
2978
|
-
* SAML2 response sample:
|
|
2979
|
-
* {
|
|
2980
|
-
* "version": 1,
|
|
2981
|
-
* "success": true,
|
|
2982
|
-
* "token_type": "urn:ietf:params:oauth:token-type:saml2",
|
|
2983
|
-
* "saml_response": "...",
|
|
2984
|
-
* "expiration_time": 1620433341
|
|
2985
|
-
* }
|
|
2986
|
-
*
|
|
2987
|
-
* Error response sample:
|
|
2988
|
-
* {
|
|
2989
|
-
* "version": 1,
|
|
2990
|
-
* "success": false,
|
|
2991
|
-
* "code": "401",
|
|
2992
|
-
* "message": "Error message."
|
|
2993
|
-
* }
|
|
2994
|
-
* </pre>
|
|
2995
|
-
*
|
|
2996
|
-
* <p>The "expiration_time" field in the JSON response is only required for successful
|
|
2997
|
-
* responses when an output file was specified in the credential configuration
|
|
2998
|
-
*
|
|
2999
|
-
* <p>The auth libraries will populate certain environment variables that will be accessible by the
|
|
3000
|
-
* executable, such as: GOOGLE_EXTERNAL_ACCOUNT_AUDIENCE, GOOGLE_EXTERNAL_ACCOUNT_TOKEN_TYPE,
|
|
3001
|
-
* GOOGLE_EXTERNAL_ACCOUNT_INTERACTIVE, GOOGLE_EXTERNAL_ACCOUNT_IMPERSONATED_EMAIL, and
|
|
3002
|
-
* GOOGLE_EXTERNAL_ACCOUNT_OUTPUT_FILE.
|
|
3003
|
-
*
|
|
3004
|
-
* <p>Please see this repositories README for a complete executable request/response specification.
|
|
3005
|
-
*/
|
|
3006
|
-
declare class PluggableAuthClient extends BaseExternalAccountClient {
|
|
3007
|
-
/**
|
|
3008
|
-
* The command used to retrieve the third party token.
|
|
3009
|
-
*/
|
|
3010
|
-
private readonly command;
|
|
3011
|
-
/**
|
|
3012
|
-
* The timeout in milliseconds for running executable,
|
|
3013
|
-
* set to default if none provided.
|
|
3014
|
-
*/
|
|
3015
|
-
private readonly timeoutMillis;
|
|
3016
|
-
/**
|
|
3017
|
-
* The path to file to check for cached executable response.
|
|
3018
|
-
*/
|
|
3019
|
-
private readonly outputFile?;
|
|
3020
|
-
/**
|
|
3021
|
-
* Executable and output file handler.
|
|
3022
|
-
*/
|
|
3023
|
-
private readonly handler;
|
|
3024
|
-
/**
|
|
3025
|
-
* Instantiates a PluggableAuthClient instance using the provided JSON
|
|
3026
|
-
* object loaded from an external account credentials file.
|
|
3027
|
-
* An error is thrown if the credential is not a valid pluggable auth credential.
|
|
3028
|
-
* @param options The external account options object typically loaded from
|
|
3029
|
-
* the external account JSON credential file.
|
|
3030
|
-
*/
|
|
3031
|
-
constructor(options: PluggableAuthClientOptions);
|
|
3032
|
-
/**
|
|
3033
|
-
* Triggered when an external subject token is needed to be exchanged for a
|
|
3034
|
-
* GCP access token via GCP STS endpoint.
|
|
3035
|
-
* This uses the `options.credential_source` object to figure out how
|
|
3036
|
-
* to retrieve the token using the current environment. In this case,
|
|
3037
|
-
* this calls a user provided executable which returns the subject token.
|
|
3038
|
-
* The logic is summarized as:
|
|
3039
|
-
* 1. Validated that the executable is allowed to run. The
|
|
3040
|
-
* GOOGLE_EXTERNAL_ACCOUNT_ALLOW_EXECUTABLES environment must be set to
|
|
3041
|
-
* 1 for security reasons.
|
|
3042
|
-
* 2. If an output file is specified by the user, check the file location
|
|
3043
|
-
* for a response. If the file exists and contains a valid response,
|
|
3044
|
-
* return the subject token from the file.
|
|
3045
|
-
* 3. Call the provided executable and return response.
|
|
3046
|
-
* @return A promise that resolves with the external subject token.
|
|
3047
|
-
*/
|
|
3048
|
-
retrieveSubjectToken(): Promise<string>;
|
|
3049
|
-
}
|
|
3050
|
-
type ExternalAccountClientOptions = IdentityPoolClientOptions | AwsClientOptions | PluggableAuthClientOptions;
|
|
3051
|
-
/**
|
|
3052
|
-
* Dummy class with no constructor. Developers are expected to use fromJSON.
|
|
3053
|
-
*/
|
|
3054
|
-
declare class ExternalAccountClient {
|
|
3055
|
-
constructor();
|
|
3056
|
-
/**
|
|
3057
|
-
* This static method will instantiate the
|
|
3058
|
-
* corresponding type of external account credential depending on the
|
|
3059
|
-
* underlying credential source.
|
|
3060
|
-
*
|
|
3061
|
-
* **IMPORTANT**: This method does not validate the credential configuration.
|
|
3062
|
-
* A security risk occurs when a credential configuration configured with
|
|
3063
|
-
* malicious URLs is used. When the credential configuration is accepted from
|
|
3064
|
-
* an untrusted source, you should validate it before using it with this
|
|
3065
|
-
* method. For more details, see
|
|
3066
|
-
* https://cloud.google.com/docs/authentication/external/externally-sourced-credentials.
|
|
3067
|
-
*
|
|
3068
|
-
* @param options The external account options object typically loaded
|
|
3069
|
-
* from the external account JSON credential file.
|
|
3070
|
-
* @return A BaseExternalAccountClient instance or null if the options
|
|
3071
|
-
* provided do not correspond to an external account credential.
|
|
3072
|
-
*/
|
|
3073
|
-
static fromJSON(options: ExternalAccountClientOptions): BaseExternalAccountClient | null;
|
|
3074
|
-
}
|
|
3075
|
-
/**
|
|
3076
|
-
* The credentials JSON file type for external account authorized user clients.
|
|
3077
|
-
*/
|
|
3078
|
-
declare const EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE = "external_account_authorized_user";
|
|
3079
|
-
/**
|
|
3080
|
-
* External Account Authorized User Credentials JSON interface.
|
|
3081
|
-
*/
|
|
3082
|
-
interface ExternalAccountAuthorizedUserClientOptions extends SharedExternalAccountClientOptions {
|
|
3083
|
-
type: typeof EXTERNAL_ACCOUNT_AUTHORIZED_USER_TYPE;
|
|
3084
|
-
client_id: string;
|
|
3085
|
-
client_secret: string;
|
|
3086
|
-
refresh_token: string;
|
|
3087
|
-
token_info_url: string;
|
|
3088
|
-
revoke_url?: string;
|
|
3089
|
-
}
|
|
3090
|
-
/**
|
|
3091
|
-
* Internal interface for tracking the access token expiration time.
|
|
3092
|
-
*/
|
|
3093
|
-
interface CredentialsWithResponse$1 extends Credentials {
|
|
3094
|
-
res?: GaxiosResponse | null;
|
|
3095
|
-
}
|
|
3096
|
-
/**
|
|
3097
|
-
* External Account Authorized User Client. This is used for OAuth2 credentials
|
|
3098
|
-
* sourced using external identities through Workforce Identity Federation.
|
|
3099
|
-
* Obtaining the initial access and refresh token can be done through the
|
|
3100
|
-
* Google Cloud CLI.
|
|
3101
|
-
*/
|
|
3102
|
-
declare class ExternalAccountAuthorizedUserClient extends AuthClient {
|
|
3103
|
-
private cachedAccessToken;
|
|
3104
|
-
private readonly externalAccountAuthorizedUserHandler;
|
|
3105
|
-
private refreshToken;
|
|
3106
|
-
/**
|
|
3107
|
-
* Instantiates an ExternalAccountAuthorizedUserClient instances using the
|
|
3108
|
-
* provided JSON object loaded from a credentials files.
|
|
3109
|
-
* An error is throws if the credential is not valid.
|
|
3110
|
-
* @param options The external account authorized user option object typically
|
|
3111
|
-
* from the external accoutn authorized user JSON credential file.
|
|
3112
|
-
*/
|
|
3113
|
-
constructor(options: ExternalAccountAuthorizedUserClientOptions);
|
|
3114
|
-
getAccessToken(): Promise<{
|
|
3115
|
-
token?: string | null;
|
|
3116
|
-
res?: GaxiosResponse | null;
|
|
3117
|
-
}>;
|
|
3118
|
-
getRequestHeaders(): Promise<Headers>;
|
|
3119
|
-
request<T>(opts: GaxiosOptions): GaxiosPromise<T>;
|
|
3120
|
-
request<T>(opts: GaxiosOptions, callback: BodyResponseCallback<T>): void;
|
|
3121
|
-
/**
|
|
3122
|
-
* Authenticates the provided HTTP request, processes it and resolves with the
|
|
3123
|
-
* returned response.
|
|
3124
|
-
* @param opts The HTTP request options.
|
|
3125
|
-
* @param reAuthRetried Whether the current attempt is a retry after a failed attempt due to an auth failure.
|
|
3126
|
-
* @return A promise that resolves with the successful response.
|
|
3127
|
-
*/
|
|
3128
|
-
protected requestAsync<T>(opts: GaxiosOptions, reAuthRetried?: boolean): Promise<GaxiosResponse<T>>;
|
|
3129
|
-
/**
|
|
3130
|
-
* Forces token refresh, even if unexpired tokens are currently cached.
|
|
3131
|
-
* @return A promise that resolves with the refreshed credential.
|
|
3132
|
-
*/
|
|
3133
|
-
protected refreshAccessTokenAsync(): Promise<CredentialsWithResponse$1>;
|
|
3134
|
-
/**
|
|
3135
|
-
* Returns whether the provided credentials are expired or not.
|
|
3136
|
-
* If there is no expiry time, assumes the token is not expired or expiring.
|
|
3137
|
-
* @param credentials The credentials to check for expiration.
|
|
3138
|
-
* @return Whether the credentials are expired or not.
|
|
3139
|
-
*/
|
|
3140
|
-
private isExpired;
|
|
3141
|
-
}
|
|
3142
|
-
/**
|
|
3143
|
-
* Defines all types of explicit clients that are determined via ADC JSON
|
|
3144
|
-
* config file.
|
|
3145
|
-
*/
|
|
3146
|
-
type JSONClient = JWT | UserRefreshClient | BaseExternalAccountClient | ExternalAccountAuthorizedUserClient | Impersonated;
|
|
3147
|
-
interface ProjectIdCallback {
|
|
3148
|
-
(err?: Error | null, projectId?: string | null): void;
|
|
3149
|
-
}
|
|
3150
|
-
interface CredentialCallback {
|
|
3151
|
-
(err: Error | null, result?: JSONClient): void;
|
|
3152
|
-
}
|
|
3153
|
-
interface ADCCallback {
|
|
3154
|
-
(err: Error | null, credential?: AuthClient, projectId?: string | null): void;
|
|
3155
|
-
}
|
|
3156
|
-
interface ADCResponse {
|
|
3157
|
-
credential: AuthClient;
|
|
3158
|
-
projectId: string | null;
|
|
3159
|
-
}
|
|
3160
|
-
interface GoogleAuthOptions<T extends AuthClient = AnyAuthClient> {
|
|
3161
|
-
/**
|
|
3162
|
-
* An API key to use, optional. Cannot be used with {@link GoogleAuthOptions.credentials `credentials`}.
|
|
3163
|
-
*/
|
|
3164
|
-
apiKey?: string;
|
|
3165
|
-
/**
|
|
3166
|
-
* An `AuthClient` to use
|
|
3167
|
-
*/
|
|
3168
|
-
authClient?: T;
|
|
3169
|
-
/**
|
|
3170
|
-
* @deprecated This option is being deprecated because of a potential security risk.
|
|
3171
|
-
*
|
|
3172
|
-
* This option does not validate the credential configuration. The security
|
|
3173
|
-
* risk occurs when a credential configuration is accepted from a source that
|
|
3174
|
-
* is not under your control and used without validation on your side.
|
|
3175
|
-
*
|
|
3176
|
-
* The recommended way to provide credentials is to create an `auth` object
|
|
3177
|
-
* using `google-auth-library` and pass it to the client constructor.
|
|
3178
|
-
* This will ensure that unexpected credential types with potential for
|
|
3179
|
-
* malicious intent are not loaded unintentionally. For example:
|
|
3180
|
-
* ```
|
|
3181
|
-
* const {GoogleAuth} = require('google-auth-library');
|
|
3182
|
-
* const auth = new GoogleAuth({
|
|
3183
|
-
* // Scopes can be specified either as an array or as a single, space-delimited string.
|
|
3184
|
-
* scopes: 'https://www.googleapis.com/auth/cloud-platform'
|
|
3185
|
-
* });
|
|
3186
|
-
* const client = new MyClient({ auth: auth });
|
|
3187
|
-
* ```
|
|
3188
|
-
*
|
|
3189
|
-
* If you are loading your credential configuration from an untrusted source and have
|
|
3190
|
-
* not mitigated the risks (e.g. by validating the configuration yourself), make
|
|
3191
|
-
* these changes as soon as possible to prevent security risks to your environment.
|
|
3192
|
-
*
|
|
3193
|
-
* Regardless of the method used, it is always your responsibility to validate
|
|
3194
|
-
* configurations received from external sources.
|
|
3195
|
-
*
|
|
3196
|
-
* For more details, see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials.
|
|
3197
|
-
*/
|
|
3198
|
-
keyFilename?: string;
|
|
3199
|
-
/**
|
|
3200
|
-
* @deprecated This option is being deprecated because of a potential security risk.
|
|
3201
|
-
*
|
|
3202
|
-
* This option does not validate the credential configuration. The security
|
|
3203
|
-
* risk occurs when a credential configuration is accepted from a source that
|
|
3204
|
-
* is not under your control and used without validation on your side.
|
|
3205
|
-
*
|
|
3206
|
-
* The recommended way to provide credentials is to create an `auth` object
|
|
3207
|
-
* using `google-auth-library` and pass it to the client constructor.
|
|
3208
|
-
* This will ensure that unexpected credential types with potential for
|
|
3209
|
-
* malicious intent are not loaded unintentionally. For example:
|
|
3210
|
-
* ```
|
|
3211
|
-
* const {GoogleAuth} = require('google-auth-library');
|
|
3212
|
-
* const auth = new GoogleAuth({
|
|
3213
|
-
* // Scopes can be specified either as an array or as a single, space-delimited string.
|
|
3214
|
-
* scopes: 'https://www.googleapis.com/auth/cloud-platform'
|
|
3215
|
-
* });
|
|
3216
|
-
* const client = new MyClient({ auth: auth });
|
|
3217
|
-
* ```
|
|
3218
|
-
*
|
|
3219
|
-
* If you are loading your credential configuration from an untrusted source and have
|
|
3220
|
-
* not mitigated the risks (e.g. by validating the configuration yourself), make
|
|
3221
|
-
* these changes as soon as possible to prevent security risks to your environment.
|
|
3222
|
-
*
|
|
3223
|
-
* Regardless of the method used, it is always your responsibility to validate
|
|
3224
|
-
* configurations received from external sources.
|
|
3225
|
-
*
|
|
3226
|
-
* For more details, see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials.
|
|
3227
|
-
*/
|
|
3228
|
-
keyFile?: string;
|
|
3229
|
-
/**
|
|
3230
|
-
* @deprecated This option is being deprecated because of a potential security risk.
|
|
3231
|
-
*
|
|
3232
|
-
* This option does not validate the credential configuration. The security
|
|
3233
|
-
* risk occurs when a credential configuration is accepted from a source that
|
|
3234
|
-
* is not under your control and used without validation on your side.
|
|
3235
|
-
*
|
|
3236
|
-
* The recommended way to provide credentials is to create an `auth` object
|
|
3237
|
-
* using `google-auth-library` and pass it to the client constructor.
|
|
3238
|
-
* This will ensure that unexpected credential types with potential for
|
|
3239
|
-
* malicious intent are not loaded unintentionally. For example:
|
|
3240
|
-
* ```
|
|
3241
|
-
* const {GoogleAuth} = require('google-auth-library');
|
|
3242
|
-
* const auth = new GoogleAuth({
|
|
3243
|
-
* // Scopes can be specified either as an array or as a single, space-delimited string.
|
|
3244
|
-
* scopes: 'https://www.googleapis.com/auth/cloud-platform'
|
|
3245
|
-
* });
|
|
3246
|
-
* const client = new MyClient({ auth: auth });
|
|
3247
|
-
* ```
|
|
3248
|
-
*
|
|
3249
|
-
* If you are loading your credential configuration from an untrusted source and have
|
|
3250
|
-
* not mitigated the risks (e.g. by validating the configuration yourself), make
|
|
3251
|
-
* these changes as soon as possible to prevent security risks to your environment.
|
|
3252
|
-
*
|
|
3253
|
-
* Regardless of the method used, it is always your responsibility to validate
|
|
3254
|
-
* configurations received from external sources.
|
|
3255
|
-
*
|
|
3256
|
-
* For more details, see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials.
|
|
3257
|
-
*/
|
|
3258
|
-
credentials?: JWTInput | ExternalAccountClientOptions;
|
|
3259
|
-
/**
|
|
3260
|
-
* `AuthClientOptions` object passed to the constructor of the client
|
|
3261
|
-
*/
|
|
3262
|
-
clientOptions?: Extract<ConstructorParameters<AnyAuthClientConstructor>[0], AuthClientOptions>;
|
|
3263
|
-
/**
|
|
3264
|
-
* Required scopes for the desired API request
|
|
3265
|
-
*/
|
|
3266
|
-
scopes?: string | string[];
|
|
3267
|
-
/**
|
|
3268
|
-
* Your project ID.
|
|
3269
|
-
*/
|
|
3270
|
-
projectId?: string;
|
|
3271
|
-
/**
|
|
3272
|
-
* The default service domain for a given Cloud universe.
|
|
3273
|
-
*
|
|
3274
|
-
* This is an ergonomic equivalent to {@link clientOptions}'s `universeDomain`
|
|
3275
|
-
* property and will be set for all generated {@link AuthClient}s.
|
|
3276
|
-
*/
|
|
3277
|
-
universeDomain?: string;
|
|
3278
|
-
}
|
|
3279
|
-
declare class GoogleAuth<T extends AuthClient = AuthClient> {
|
|
3280
|
-
#private;
|
|
3281
|
-
/**
|
|
3282
|
-
* Caches a value indicating whether the auth layer is running on Google
|
|
3283
|
-
* Compute Engine.
|
|
3284
|
-
* @private
|
|
3285
|
-
*/
|
|
3286
|
-
private checkIsGCE?;
|
|
3287
|
-
useJWTAccessWithScope?: boolean;
|
|
3288
|
-
defaultServicePath?: string;
|
|
3289
|
-
get isGCE(): boolean | undefined;
|
|
3290
|
-
private _findProjectIdPromise?;
|
|
3291
|
-
private _cachedProjectId?;
|
|
3292
|
-
jsonContent: JWTInput | ExternalAccountClientOptions | null;
|
|
3293
|
-
apiKey: string | null;
|
|
3294
|
-
cachedCredential: AnyAuthClient | T | null;
|
|
3295
|
-
/**
|
|
3296
|
-
* Scopes populated by the client library by default. We differentiate between
|
|
3297
|
-
* these and user defined scopes when deciding whether to use a self-signed JWT.
|
|
3298
|
-
*/
|
|
3299
|
-
defaultScopes?: string | string[];
|
|
3300
|
-
private keyFilename?;
|
|
3301
|
-
private scopes?;
|
|
3302
|
-
private clientOptions;
|
|
3303
|
-
/**
|
|
3304
|
-
* Configuration is resolved in the following order of precedence:
|
|
3305
|
-
* - {@link GoogleAuthOptions.credentials `credentials`}
|
|
3306
|
-
* - {@link GoogleAuthOptions.keyFilename `keyFilename`}
|
|
3307
|
-
* - {@link GoogleAuthOptions.keyFile `keyFile`}
|
|
3308
|
-
*
|
|
3309
|
-
* {@link GoogleAuthOptions.clientOptions `clientOptions`} are passed to the
|
|
3310
|
-
* {@link AuthClient `AuthClient`s}.
|
|
3311
|
-
*
|
|
3312
|
-
* @param opts
|
|
3313
|
-
*/
|
|
3314
|
-
constructor(opts?: GoogleAuthOptions<T>);
|
|
3315
|
-
setGapicJWTValues(client: JWT): void;
|
|
3316
|
-
/**
|
|
3317
|
-
* Obtains the default project ID for the application.
|
|
3318
|
-
*
|
|
3319
|
-
* Retrieves in the following order of precedence:
|
|
3320
|
-
* - The `projectId` provided in this object's construction
|
|
3321
|
-
* - GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT environment variable
|
|
3322
|
-
* - GOOGLE_APPLICATION_CREDENTIALS JSON file
|
|
3323
|
-
* - Cloud SDK: `gcloud config config-helper --format json`
|
|
3324
|
-
* - GCE project ID from metadata server
|
|
3325
|
-
*/
|
|
3326
|
-
getProjectId(): Promise<string>;
|
|
3327
|
-
getProjectId(callback: ProjectIdCallback): void;
|
|
3328
|
-
/**
|
|
3329
|
-
* A temporary method for internal `getProjectId` usages where `null` is
|
|
3330
|
-
* acceptable. In a future major release, `getProjectId` should return `null`
|
|
3331
|
-
* (as the `Promise<string | null>` base signature describes) and this private
|
|
3332
|
-
* method should be removed.
|
|
3333
|
-
*
|
|
3334
|
-
* @returns Promise that resolves with project id (or `null`)
|
|
3335
|
-
*/
|
|
3336
|
-
private getProjectIdOptional;
|
|
3337
|
-
/**
|
|
3338
|
-
* A private method for finding and caching a projectId.
|
|
3339
|
-
*
|
|
3340
|
-
* Supports environments in order of precedence:
|
|
3341
|
-
* - GCLOUD_PROJECT or GOOGLE_CLOUD_PROJECT environment variable
|
|
3342
|
-
* - GOOGLE_APPLICATION_CREDENTIALS JSON file
|
|
3343
|
-
* - Cloud SDK: `gcloud config config-helper --format json`
|
|
3344
|
-
* - GCE project ID from metadata server
|
|
3345
|
-
*
|
|
3346
|
-
* @returns projectId
|
|
3347
|
-
*/
|
|
3348
|
-
private findAndCacheProjectId;
|
|
3349
|
-
private getProjectIdAsync;
|
|
3350
|
-
/**
|
|
3351
|
-
* Retrieves a universe domain from the metadata server via
|
|
3352
|
-
* {@link gcpMetadata.universe}.
|
|
3353
|
-
*
|
|
3354
|
-
* @returns a universe domain
|
|
3355
|
-
*/
|
|
3356
|
-
getUniverseDomainFromMetadataServer(): Promise<string>;
|
|
3357
|
-
/**
|
|
3358
|
-
* Retrieves, caches, and returns the universe domain in the following order
|
|
3359
|
-
* of precedence:
|
|
3360
|
-
* - The universe domain in {@link GoogleAuth.clientOptions}
|
|
3361
|
-
* - An existing or ADC {@link AuthClient}'s universe domain
|
|
3362
|
-
* - {@link gcpMetadata.universe}, if {@link Compute} client
|
|
3363
|
-
*
|
|
3364
|
-
* @returns The universe domain
|
|
3365
|
-
*/
|
|
3366
|
-
getUniverseDomain(): Promise<string>;
|
|
3367
|
-
/**
|
|
3368
|
-
* @returns Any scopes (user-specified or default scopes specified by the
|
|
3369
|
-
* client library) that need to be set on the current Auth client.
|
|
3370
|
-
*/
|
|
3371
|
-
private getAnyScopes;
|
|
3372
|
-
/**
|
|
3373
|
-
* Obtains the default service-level credentials for the application.
|
|
3374
|
-
* @param callback Optional callback.
|
|
3375
|
-
* @returns Promise that resolves with the ADCResponse (if no callback was
|
|
3376
|
-
* passed).
|
|
3377
|
-
*/
|
|
3378
|
-
getApplicationDefault(): Promise<ADCResponse>;
|
|
3379
|
-
getApplicationDefault(callback: ADCCallback): void;
|
|
3380
|
-
getApplicationDefault(options: AuthClientOptions): Promise<ADCResponse>;
|
|
3381
|
-
getApplicationDefault(options: AuthClientOptions, callback: ADCCallback): void;
|
|
3382
|
-
private getApplicationDefaultAsync;
|
|
3383
|
-
/**
|
|
3384
|
-
* Determines whether the auth layer is running on Google Compute Engine.
|
|
3385
|
-
* Checks for GCP Residency, then fallback to checking if metadata server
|
|
3386
|
-
* is available.
|
|
3387
|
-
*
|
|
3388
|
-
* @returns A promise that resolves with the boolean.
|
|
3389
|
-
* @api private
|
|
3390
|
-
*/
|
|
3391
|
-
_checkIsGCE(): Promise<boolean>;
|
|
3392
|
-
/**
|
|
3393
|
-
* Attempts to load default credentials from the environment variable path..
|
|
3394
|
-
* @returns Promise that resolves with the OAuth2Client or null.
|
|
3395
|
-
* @api private
|
|
3396
|
-
*/
|
|
3397
|
-
_tryGetApplicationCredentialsFromEnvironmentVariable(options?: AuthClientOptions): Promise<JSONClient | null>;
|
|
3398
|
-
/**
|
|
3399
|
-
* Attempts to load default credentials from a well-known file location
|
|
3400
|
-
* @return Promise that resolves with the OAuth2Client or null.
|
|
3401
|
-
* @api private
|
|
3402
|
-
*/
|
|
3403
|
-
_tryGetApplicationCredentialsFromWellKnownFile(options?: AuthClientOptions): Promise<JSONClient | null>;
|
|
3404
|
-
/**
|
|
3405
|
-
* Attempts to load default credentials from a file at the given path..
|
|
3406
|
-
* @param filePath The path to the file to read.
|
|
3407
|
-
* @returns Promise that resolves with the OAuth2Client
|
|
3408
|
-
* @api private
|
|
3409
|
-
*/
|
|
3410
|
-
_getApplicationCredentialsFromFilePath(filePath: string, options?: AuthClientOptions): Promise<JSONClient>;
|
|
3411
|
-
/**
|
|
3412
|
-
* Create a credentials instance using a given impersonated input options.
|
|
3413
|
-
* @param json The impersonated input object.
|
|
3414
|
-
* @returns JWT or UserRefresh Client with data
|
|
3415
|
-
*/
|
|
3416
|
-
fromImpersonatedJSON(json: ImpersonatedJWTInput): Impersonated;
|
|
3417
|
-
/**
|
|
3418
|
-
* Create a credentials instance using the given input options.
|
|
3419
|
-
* This client is not cached.
|
|
3420
|
-
*
|
|
3421
|
-
* **Important**: If you accept a credential configuration (credential JSON/File/Stream) from an external source for authentication to Google Cloud, you must validate it before providing it to any Google API or library. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data. For more information, refer to {@link https://cloud.google.com/docs/authentication/external/externally-sourced-credentials Validate credential configurations from external sources}.
|
|
3422
|
-
*
|
|
3423
|
-
* @deprecated This method is being deprecated because of a potential security risk.
|
|
3424
|
-
*
|
|
3425
|
-
* This method does not validate the credential configuration. The security
|
|
3426
|
-
* risk occurs when a credential configuration is accepted from a source that
|
|
3427
|
-
* is not under your control and used without validation on your side.
|
|
3428
|
-
*
|
|
3429
|
-
* If you know that you will be loading credential configurations of a
|
|
3430
|
-
* specific type, it is recommended to use a credential-type-specific
|
|
3431
|
-
* constructor. This will ensure that an unexpected credential type with
|
|
3432
|
-
* potential for malicious intent is not loaded unintentionally. You might
|
|
3433
|
-
* still have to do validation for certain credential types. Please follow
|
|
3434
|
-
* the recommendation for that method. For example, if you want to load only
|
|
3435
|
-
* service accounts, you can use the `JWT` constructor:
|
|
3436
|
-
* ```
|
|
3437
|
-
* const {JWT} = require('google-auth-library');
|
|
3438
|
-
* const keys = require('/path/to/key.json');
|
|
3439
|
-
* const client = new JWT({
|
|
3440
|
-
* email: keys.client_email,
|
|
3441
|
-
* key: keys.private_key,
|
|
3442
|
-
* scopes: ['https://www.googleapis.com/auth/cloud-platform'],
|
|
3443
|
-
* });
|
|
3444
|
-
* ```
|
|
3445
|
-
*
|
|
3446
|
-
* If you are loading your credential configuration from an untrusted source and have
|
|
3447
|
-
* not mitigated the risks (e.g. by validating the configuration yourself), make
|
|
3448
|
-
* these changes as soon as possible to prevent security risks to your environment.
|
|
3449
|
-
*
|
|
3450
|
-
* Regardless of the method used, it is always your responsibility to validate
|
|
3451
|
-
* configurations received from external sources.
|
|
3452
|
-
*
|
|
3453
|
-
* For more details, see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials.
|
|
3454
|
-
*
|
|
3455
|
-
* @param json The input object.
|
|
3456
|
-
* @param options The JWT or UserRefresh options for the client
|
|
3457
|
-
* @returns JWT or UserRefresh Client with data
|
|
3458
|
-
*/
|
|
3459
|
-
fromJSON(json: JWTInput | ImpersonatedJWTInput, options?: AuthClientOptions): JSONClient;
|
|
3460
|
-
/**
|
|
3461
|
-
* Return a JWT or UserRefreshClient from JavaScript object, caching both the
|
|
3462
|
-
* object used to instantiate and the client.
|
|
3463
|
-
* @param json The input object.
|
|
3464
|
-
* @param options The JWT or UserRefresh options for the client
|
|
3465
|
-
* @returns JWT or UserRefresh Client with data
|
|
3466
|
-
*/
|
|
3467
|
-
private _cacheClientFromJSON;
|
|
3468
|
-
/**
|
|
3469
|
-
* Create a credentials instance using the given input stream.
|
|
3470
|
-
*
|
|
3471
|
-
* @deprecated This method is being deprecated because of a potential security risk.
|
|
3472
|
-
*
|
|
3473
|
-
* This method does not validate the credential configuration. The security
|
|
3474
|
-
* risk occurs when a credential configuration is accepted from a source that
|
|
3475
|
-
* is not under your control and used without validation on your side.
|
|
3476
|
-
*
|
|
3477
|
-
* If you know that you will be loading credential configurations of a
|
|
3478
|
-
* specific type, it is recommended to read and parse the stream, and then
|
|
3479
|
-
* use a credential-type-specific constructor. This will ensure that an
|
|
3480
|
-
* unexpected credential type with potential for malicious intent is not
|
|
3481
|
-
* loaded unintentionally. You might still have to do validation for certain
|
|
3482
|
-
* credential types. Please follow the recommendation for that method. For
|
|
3483
|
-
* example, if you want to load only service accounts, you can do:
|
|
3484
|
-
* ```
|
|
3485
|
-
* const {JWT} = require('google-auth-library');
|
|
3486
|
-
* const fs = require('fs');
|
|
3487
|
-
*
|
|
3488
|
-
* const stream = fs.createReadStream('path/to/key.json');
|
|
3489
|
-
* const chunks = [];
|
|
3490
|
-
* stream.on('data', (chunk) => chunks.push(chunk));
|
|
3491
|
-
* stream.on('end', () => {
|
|
3492
|
-
* const keys = JSON.parse(Buffer.concat(chunks).toString());
|
|
3493
|
-
* const client = new JWT({
|
|
3494
|
-
* email: keys.client_email,
|
|
3495
|
-
* key: keys.private_key,
|
|
3496
|
-
* scopes: ['https://www.googleapis.com/auth/cloud-platform'],
|
|
3497
|
-
* });
|
|
3498
|
-
* // use client
|
|
3499
|
-
* });
|
|
3500
|
-
* ```
|
|
3501
|
-
*
|
|
3502
|
-
* If you are loading your credential configuration from an untrusted source and have
|
|
3503
|
-
* not mitigated the risks (e.g. by validating the configuration yourself), make
|
|
3504
|
-
* these changes as soon as possible to prevent security risks to your environment.
|
|
3505
|
-
*
|
|
3506
|
-
* Regardless of the method used, it is always your responsibility to validate
|
|
3507
|
-
* configurations received from external sources.
|
|
3508
|
-
*
|
|
3509
|
-
* For more details, see https://cloud.google.com/docs/authentication/external/externally-sourced-credentials.
|
|
3510
|
-
* @param inputStream The input stream.
|
|
3511
|
-
* @param callback Optional callback.
|
|
3512
|
-
*/
|
|
3513
|
-
fromStream(inputStream: stream.Readable): Promise<JSONClient>;
|
|
3514
|
-
fromStream(inputStream: stream.Readable, callback: CredentialCallback): void;
|
|
3515
|
-
fromStream(inputStream: stream.Readable, options: AuthClientOptions): Promise<JSONClient>;
|
|
3516
|
-
fromStream(inputStream: stream.Readable, options: AuthClientOptions, callback: CredentialCallback): void;
|
|
3517
|
-
private fromStreamAsync;
|
|
3518
|
-
/**
|
|
3519
|
-
* Create a credentials instance using the given API key string.
|
|
3520
|
-
* The created client is not cached. In order to create and cache it use the {@link GoogleAuth.getClient `getClient`} method after first providing an {@link GoogleAuth.apiKey `apiKey`}.
|
|
3521
|
-
*
|
|
3522
|
-
* @param apiKey The API key string
|
|
3523
|
-
* @param options An optional options object.
|
|
3524
|
-
* @returns A JWT loaded from the key
|
|
3525
|
-
*/
|
|
3526
|
-
fromAPIKey(apiKey: string, options?: AuthClientOptions): JWT;
|
|
3527
|
-
/**
|
|
3528
|
-
* Determines whether the current operating system is Windows.
|
|
3529
|
-
* @api private
|
|
3530
|
-
*/
|
|
3531
|
-
private _isWindows;
|
|
3532
|
-
/**
|
|
3533
|
-
* Run the Google Cloud SDK command that prints the default project ID
|
|
3534
|
-
*/
|
|
3535
|
-
private getDefaultServiceProjectId;
|
|
3536
|
-
/**
|
|
3537
|
-
* Loads the project id from environment variables.
|
|
3538
|
-
* @api private
|
|
3539
|
-
*/
|
|
3540
|
-
private getProductionProjectId;
|
|
3541
|
-
/**
|
|
3542
|
-
* Loads the project id from the GOOGLE_APPLICATION_CREDENTIALS json file.
|
|
3543
|
-
* @api private
|
|
3544
|
-
*/
|
|
3545
|
-
private getFileProjectId;
|
|
3546
|
-
/**
|
|
3547
|
-
* Gets the project ID from external account client if available.
|
|
3548
|
-
*/
|
|
3549
|
-
private getExternalAccountClientProjectId;
|
|
3550
|
-
/**
|
|
3551
|
-
* Gets the Compute Engine project ID if it can be inferred.
|
|
3552
|
-
*/
|
|
3553
|
-
private getGCEProjectId;
|
|
3554
|
-
/**
|
|
3555
|
-
* The callback function handles a credential object that contains the
|
|
3556
|
-
* client_email and private_key (if exists).
|
|
3557
|
-
* getCredentials first checks if the client is using an external account and
|
|
3558
|
-
* uses the service account email in place of client_email.
|
|
3559
|
-
* If that doesn't exist, it checks for these values from the user JSON.
|
|
3560
|
-
* If the user JSON doesn't exist, and the environment is on GCE, it gets the
|
|
3561
|
-
* client_email from the cloud metadata server.
|
|
3562
|
-
* @param callback Callback that handles the credential object that contains
|
|
3563
|
-
* a client_email and optional private key, or the error.
|
|
3564
|
-
* returned
|
|
3565
|
-
*/
|
|
3566
|
-
getCredentials(): Promise<CredentialBody>;
|
|
3567
|
-
getCredentials(callback: (err: Error | null, credentials?: CredentialBody) => void): void;
|
|
3568
|
-
private getCredentialsAsync;
|
|
3569
|
-
/**
|
|
3570
|
-
* Automatically obtain an {@link AuthClient `AuthClient`} based on the
|
|
3571
|
-
* provided configuration. If no options were passed, use Application
|
|
3572
|
-
* Default Credentials.
|
|
3573
|
-
*/
|
|
3574
|
-
getClient(): Promise<AnyAuthClient | T>;
|
|
3575
|
-
/**
|
|
3576
|
-
* Creates a client which will fetch an ID token for authorization.
|
|
3577
|
-
* @param targetAudience the audience for the fetched ID token.
|
|
3578
|
-
* @returns IdTokenClient for making HTTP calls authenticated with ID tokens.
|
|
3579
|
-
*/
|
|
3580
|
-
getIdTokenClient(targetAudience: string): Promise<IdTokenClient>;
|
|
3581
|
-
/**
|
|
3582
|
-
* Automatically obtain application default credentials, and return
|
|
3583
|
-
* an access token for making requests.
|
|
3584
|
-
*/
|
|
3585
|
-
getAccessToken(): Promise<string | null | undefined>;
|
|
3586
|
-
/**
|
|
3587
|
-
* Obtain the HTTP headers that will provide authorization for a given
|
|
3588
|
-
* request.
|
|
3589
|
-
*/
|
|
3590
|
-
getRequestHeaders(url?: string | URL): Promise<Headers>;
|
|
3591
|
-
/**
|
|
3592
|
-
* Obtain credentials for a request, then attach the appropriate headers to
|
|
3593
|
-
* the request options.
|
|
3594
|
-
* @param opts Axios or Request options on which to attach the headers
|
|
3595
|
-
*/
|
|
3596
|
-
authorizeRequest(opts?: Pick<GaxiosOptions, 'url' | 'headers'>): Promise<Pick<GaxiosOptions, "headers" | "url">>;
|
|
3597
|
-
/**
|
|
3598
|
-
* A {@link fetch `fetch`} compliant API for {@link GoogleAuth}.
|
|
3599
|
-
*
|
|
3600
|
-
* @see {@link GoogleAuth.request} for the classic method.
|
|
3601
|
-
*
|
|
3602
|
-
* @remarks
|
|
3603
|
-
*
|
|
3604
|
-
* This is useful as a drop-in replacement for `fetch` API usage.
|
|
3605
|
-
*
|
|
3606
|
-
* @example
|
|
3607
|
-
*
|
|
3608
|
-
* ```ts
|
|
3609
|
-
* const auth = new GoogleAuth();
|
|
3610
|
-
* const fetchWithAuth: typeof fetch = (...args) => auth.fetch(...args);
|
|
3611
|
-
* await fetchWithAuth('https://example.com');
|
|
3612
|
-
* ```
|
|
3613
|
-
*
|
|
3614
|
-
* @param args `fetch` API or {@link Gaxios.fetch `Gaxios#fetch`} parameters
|
|
3615
|
-
* @returns the {@link GaxiosResponse} with Gaxios-added properties
|
|
3616
|
-
*/
|
|
3617
|
-
fetch<T>(...args: Parameters<AuthClient['fetch']>): Promise<GaxiosResponse<T>>;
|
|
3618
|
-
/**
|
|
3619
|
-
* Automatically obtain application default credentials, and make an
|
|
3620
|
-
* HTTP request using the given options.
|
|
3621
|
-
*
|
|
3622
|
-
* @see {@link GoogleAuth.fetch} for the modern method.
|
|
3623
|
-
*
|
|
3624
|
-
* @param opts Axios request options for the HTTP request.
|
|
3625
|
-
*/
|
|
3626
|
-
request<T>(opts: GaxiosOptions): Promise<GaxiosResponse<T>>;
|
|
3627
|
-
/**
|
|
3628
|
-
* Determine the compute environment in which the code is running.
|
|
3629
|
-
*/
|
|
3630
|
-
getEnv(): Promise<GCPEnv>;
|
|
3631
|
-
/**
|
|
3632
|
-
* Sign the given data with the current private key, or go out
|
|
3633
|
-
* to the IAM API to sign it.
|
|
3634
|
-
* @param data The data to be signed.
|
|
3635
|
-
* @param endpoint A custom endpoint to use.
|
|
3636
|
-
*
|
|
3637
|
-
* @example
|
|
3638
|
-
* ```
|
|
3639
|
-
* sign('data', 'https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/');
|
|
3640
|
-
* ```
|
|
3641
|
-
*/
|
|
3642
|
-
sign(data: string, endpoint?: string): Promise<string>;
|
|
3643
|
-
private signBlob;
|
|
3644
|
-
}
|
|
3645
|
-
interface SignBlobResponse {
|
|
3646
|
-
keyId: string;
|
|
3647
|
-
signedBlob: string;
|
|
3648
|
-
}
|
|
3649
|
-
interface ComputeOptions extends OAuth2ClientOptions {
|
|
3650
|
-
/**
|
|
3651
|
-
* The service account email to use, or 'default'. A Compute Engine instance
|
|
3652
|
-
* may have multiple service accounts.
|
|
3653
|
-
*/
|
|
3654
|
-
serviceAccountEmail?: string;
|
|
3655
|
-
/**
|
|
3656
|
-
* The scopes that will be requested when acquiring service account
|
|
3657
|
-
* credentials. Only applicable to modern App Engine and Cloud Function
|
|
3658
|
-
* runtimes as of March 2019.
|
|
3659
|
-
*/
|
|
3660
|
-
scopes?: string | string[];
|
|
3661
|
-
}
|
|
3662
|
-
declare class Compute extends OAuth2Client {
|
|
3663
|
-
readonly serviceAccountEmail: string;
|
|
3664
|
-
scopes: string[];
|
|
3665
|
-
/**
|
|
3666
|
-
* Google Compute Engine service account credentials.
|
|
3667
|
-
*
|
|
3668
|
-
* Retrieve access token from the metadata server.
|
|
3669
|
-
* See: https://cloud.google.com/compute/docs/access/authenticate-workloads#applications
|
|
3670
|
-
*/
|
|
3671
|
-
constructor(options?: ComputeOptions);
|
|
3672
|
-
/**
|
|
3673
|
-
* Refreshes the access token.
|
|
3674
|
-
* @param refreshToken Unused parameter
|
|
3675
|
-
*/
|
|
3676
|
-
protected refreshTokenNoCache(): Promise<GetTokenResponse>;
|
|
3677
|
-
/**
|
|
3678
|
-
* Fetches an ID token.
|
|
3679
|
-
* @param targetAudience the audience for the fetched ID token.
|
|
3680
|
-
*/
|
|
3681
|
-
fetchIdToken(targetAudience: string): Promise<string>;
|
|
3682
|
-
protected wrapError(e: GaxiosError): void;
|
|
3683
|
-
}
|
|
3684
|
-
interface RequestMetadata {
|
|
3685
|
-
'x-goog-iam-authority-selector': string;
|
|
3686
|
-
'x-goog-iam-authorization-token': string;
|
|
3687
|
-
}
|
|
3688
|
-
declare class IAMAuth {
|
|
3689
|
-
selector: string;
|
|
3690
|
-
token: string;
|
|
3691
|
-
/**
|
|
3692
|
-
* IAM credentials.
|
|
3693
|
-
*
|
|
3694
|
-
* @param selector the iam authority selector
|
|
3695
|
-
* @param token the token
|
|
3696
|
-
* @constructor
|
|
3697
|
-
*/
|
|
3698
|
-
constructor(selector: string, token: string);
|
|
3699
|
-
/**
|
|
3700
|
-
* Acquire the HTTP headers required to make an authenticated request.
|
|
3701
|
-
*/
|
|
3702
|
-
getRequestHeaders(): {
|
|
3703
|
-
'x-goog-iam-authority-selector': string;
|
|
3704
|
-
'x-goog-iam-authorization-token': string;
|
|
3705
|
-
};
|
|
3706
|
-
}
|
|
3707
|
-
interface Claims {
|
|
3708
|
-
[index: string]: string;
|
|
3709
|
-
}
|
|
3710
|
-
declare class JWTAccess {
|
|
3711
|
-
email?: string | null;
|
|
3712
|
-
key?: string | null;
|
|
3713
|
-
keyId?: string | null;
|
|
3714
|
-
projectId?: string;
|
|
3715
|
-
eagerRefreshThresholdMillis: number;
|
|
3716
|
-
private cache;
|
|
3717
|
-
/**
|
|
3718
|
-
* JWTAccess service account credentials.
|
|
3719
|
-
*
|
|
3720
|
-
* Create a new access token by using the credential to create a new JWT token
|
|
3721
|
-
* that's recognized as the access token.
|
|
3722
|
-
*
|
|
3723
|
-
* @param email the service account email address.
|
|
3724
|
-
* @param key the private key that will be used to sign the token.
|
|
3725
|
-
* @param keyId the ID of the private key used to sign the token.
|
|
3726
|
-
*/
|
|
3727
|
-
constructor(email?: string | null, key?: string | null, keyId?: string | null, eagerRefreshThresholdMillis?: number);
|
|
3728
|
-
/**
|
|
3729
|
-
* Ensures that we're caching a key appropriately, giving precedence to scopes vs. url
|
|
3730
|
-
*
|
|
3731
|
-
* @param url The URI being authorized.
|
|
3732
|
-
* @param scopes The scope or scopes being authorized
|
|
3733
|
-
* @returns A string that returns the cached key.
|
|
3734
|
-
*/
|
|
3735
|
-
getCachedKey(url?: string, scopes?: string | string[]): string;
|
|
3736
|
-
/**
|
|
3737
|
-
* Get a non-expired access token, after refreshing if necessary.
|
|
3738
|
-
*
|
|
3739
|
-
* @param url The URI being authorized.
|
|
3740
|
-
* @param additionalClaims An object with a set of additional claims to
|
|
3741
|
-
* include in the payload.
|
|
3742
|
-
* @returns An object that includes the authorization header.
|
|
3743
|
-
*/
|
|
3744
|
-
getRequestHeaders(url?: string, additionalClaims?: Claims, scopes?: string | string[]): Headers;
|
|
3745
|
-
/**
|
|
3746
|
-
* Returns an expiration time for the JWT token.
|
|
3747
|
-
*
|
|
3748
|
-
* @param iat The issued at time for the JWT.
|
|
3749
|
-
* @returns An expiration time for the JWT.
|
|
3750
|
-
*/
|
|
3751
|
-
private static getExpirationTime;
|
|
3752
|
-
/**
|
|
3753
|
-
* Create a JWTAccess credentials instance using the given input options.
|
|
3754
|
-
* @param json The input object.
|
|
3755
|
-
*/
|
|
3756
|
-
fromJSON(json: JWTInput): void;
|
|
3757
|
-
/**
|
|
3758
|
-
* Create a JWTAccess credentials instance using the given input stream.
|
|
3759
|
-
* @param inputStream The input stream.
|
|
3760
|
-
* @param callback Optional callback.
|
|
3761
|
-
*/
|
|
3762
|
-
fromStream(inputStream: stream.Readable): Promise<void>;
|
|
3763
|
-
fromStream(inputStream: stream.Readable, callback: (err?: Error) => void): void;
|
|
3764
|
-
private fromStreamAsync;
|
|
3765
|
-
}
|
|
3766
|
-
/**
|
|
3767
|
-
* Internal interface for tracking the access token expiration time.
|
|
3768
|
-
*/
|
|
3769
|
-
interface CredentialsWithResponse extends Credentials {
|
|
3770
|
-
res?: GaxiosResponse | null;
|
|
3771
|
-
}
|
|
3772
|
-
/**
|
|
3773
|
-
* Internal interface for tracking and returning the Downscoped access token
|
|
3774
|
-
* expiration time in epoch time (seconds).
|
|
3775
|
-
*/
|
|
3776
|
-
interface DownscopedAccessTokenResponse extends GetAccessTokenResponse {
|
|
3777
|
-
expirationTime?: number | null;
|
|
3778
|
-
}
|
|
3779
|
-
/**
|
|
3780
|
-
* Defines an upper bound of permissions available for a GCP credential.
|
|
3781
|
-
*/
|
|
3782
|
-
interface CredentialAccessBoundary {
|
|
3783
|
-
accessBoundary: {
|
|
3784
|
-
accessBoundaryRules: AccessBoundaryRule[];
|
|
3785
|
-
};
|
|
3786
|
-
}
|
|
3787
|
-
/** Defines an upper bound of permissions on a particular resource. */
|
|
3788
|
-
interface AccessBoundaryRule {
|
|
3789
|
-
availablePermissions: string[];
|
|
3790
|
-
availableResource: string;
|
|
3791
|
-
availabilityCondition?: AvailabilityCondition;
|
|
3792
|
-
}
|
|
3793
|
-
/**
|
|
3794
|
-
* An optional condition that can be used as part of a
|
|
3795
|
-
* CredentialAccessBoundary to further restrict permissions.
|
|
3796
|
-
*/
|
|
3797
|
-
interface AvailabilityCondition {
|
|
3798
|
-
expression: string;
|
|
3799
|
-
title?: string;
|
|
3800
|
-
description?: string;
|
|
3801
|
-
}
|
|
3802
|
-
interface DownscopedClientOptions extends AuthClientOptions {
|
|
3803
|
-
/**
|
|
3804
|
-
* The source AuthClient to be downscoped based on the provided Credential Access Boundary rules.
|
|
3805
|
-
*/
|
|
3806
|
-
authClient: AuthClient;
|
|
3807
|
-
/**
|
|
3808
|
-
* The Credential Access Boundary which contains a list of access boundary rules.
|
|
3809
|
-
* Each rule contains information on the resource that the rule applies to, the upper bound of the
|
|
3810
|
-
* permissions that are available on that resource and an optional
|
|
3811
|
-
* condition to further restrict permissions.
|
|
3812
|
-
*/
|
|
3813
|
-
credentialAccessBoundary: CredentialAccessBoundary;
|
|
3814
|
-
}
|
|
3815
|
-
/**
|
|
3816
|
-
* Defines a set of Google credentials that are downscoped from an existing set
|
|
3817
|
-
* of Google OAuth2 credentials. This is useful to restrict the Identity and
|
|
3818
|
-
* Access Management (IAM) permissions that a short-lived credential can use.
|
|
3819
|
-
* The common pattern of usage is to have a token broker with elevated access
|
|
3820
|
-
* generate these downscoped credentials from higher access source credentials
|
|
3821
|
-
* and pass the downscoped short-lived access tokens to a token consumer via
|
|
3822
|
-
* some secure authenticated channel for limited access to Google Cloud Storage
|
|
3823
|
-
* resources.
|
|
3824
|
-
*/
|
|
3825
|
-
declare class DownscopedClient extends AuthClient {
|
|
3826
|
-
private readonly authClient;
|
|
3827
|
-
private readonly credentialAccessBoundary;
|
|
3828
|
-
private cachedDownscopedAccessToken;
|
|
3829
|
-
private readonly stsCredential;
|
|
3830
|
-
/**
|
|
3831
|
-
* Instantiates a downscoped client object using the provided source
|
|
3832
|
-
* AuthClient and credential access boundary rules.
|
|
3833
|
-
* To downscope permissions of a source AuthClient, a Credential Access
|
|
3834
|
-
* Boundary that specifies which resources the new credential can access, as
|
|
3835
|
-
* well as an upper bound on the permissions that are available on each
|
|
3836
|
-
* resource, has to be defined. A downscoped client can then be instantiated
|
|
3837
|
-
* using the source AuthClient and the Credential Access Boundary.
|
|
3838
|
-
* @param options the {@link DownscopedClientOptions `DownscopedClientOptions`} to use. Passing an `AuthClient` directly is **@DEPRECATED**.
|
|
3839
|
-
* @param credentialAccessBoundary **@DEPRECATED**. Provide a {@link DownscopedClientOptions `DownscopedClientOptions`} object in the first parameter instead.
|
|
3840
|
-
*/
|
|
3841
|
-
constructor(
|
|
3842
|
-
/**
|
|
3843
|
-
* AuthClient is for backwards-compatibility.
|
|
3844
|
-
*/
|
|
3845
|
-
|
|
3846
|
-
options: AuthClient | DownscopedClientOptions,
|
|
3847
|
-
/**
|
|
3848
|
-
* @deprecated - provide a {@link DownscopedClientOptions `DownscopedClientOptions`} object in the first parameter instead
|
|
3849
|
-
*/
|
|
3850
|
-
|
|
3851
|
-
credentialAccessBoundary?: CredentialAccessBoundary);
|
|
3852
|
-
/**
|
|
3853
|
-
* Provides a mechanism to inject Downscoped access tokens directly.
|
|
3854
|
-
* The expiry_date field is required to facilitate determination of the token
|
|
3855
|
-
* expiration which would make it easier for the token consumer to handle.
|
|
3856
|
-
* @param credentials The Credentials object to set on the current client.
|
|
3857
|
-
*/
|
|
3858
|
-
setCredentials(credentials: Credentials): void;
|
|
3859
|
-
getAccessToken(): Promise<DownscopedAccessTokenResponse>;
|
|
3860
|
-
/**
|
|
3861
|
-
* The main authentication interface. It takes an optional url which when
|
|
3862
|
-
* present is the endpoint being accessed, and returns a Promise which
|
|
3863
|
-
* resolves with authorization header fields.
|
|
3864
|
-
*
|
|
3865
|
-
* The result has the form:
|
|
3866
|
-
* { authorization: 'Bearer <access_token_value>' }
|
|
3867
|
-
*/
|
|
3868
|
-
getRequestHeaders(): Promise<Headers>;
|
|
3869
|
-
/**
|
|
3870
|
-
* Provides a request implementation with OAuth 2.0 flow. In cases of
|
|
3871
|
-
* HTTP 401 and 403 responses, it automatically asks for a new access token
|
|
3872
|
-
* and replays the unsuccessful request.
|
|
3873
|
-
* @param opts Request options.
|
|
3874
|
-
* @param callback callback.
|
|
3875
|
-
* @return A promise that resolves with the HTTP response when no callback
|
|
3876
|
-
* is provided.
|
|
3877
|
-
*/
|
|
3878
|
-
request<T>(opts: GaxiosOptions): GaxiosPromise<T>;
|
|
3879
|
-
request<T>(opts: GaxiosOptions, callback: BodyResponseCallback<T>): void;
|
|
3880
|
-
/**
|
|
3881
|
-
* Authenticates the provided HTTP request, processes it and resolves with the
|
|
3882
|
-
* returned response.
|
|
3883
|
-
* @param opts The HTTP request options.
|
|
3884
|
-
* @param reAuthRetried Whether the current attempt is a retry after a failed attempt due to an auth failure
|
|
3885
|
-
* @return A promise that resolves with the successful response.
|
|
3886
|
-
*/
|
|
3887
|
-
protected requestAsync<T>(opts: GaxiosOptions, reAuthRetried?: boolean): Promise<GaxiosResponse<T>>;
|
|
3888
|
-
/**
|
|
3889
|
-
* Forces token refresh, even if unexpired tokens are currently cached.
|
|
3890
|
-
* GCP access tokens are retrieved from authclient object/source credential.
|
|
3891
|
-
* Then GCP access tokens are exchanged for downscoped access tokens via the
|
|
3892
|
-
* token exchange endpoint.
|
|
3893
|
-
* @return A promise that resolves with the fresh downscoped access token.
|
|
3894
|
-
*/
|
|
3895
|
-
protected refreshAccessTokenAsync(): Promise<CredentialsWithResponse>;
|
|
3896
|
-
/**
|
|
3897
|
-
* Returns whether the provided credentials are expired or not.
|
|
3898
|
-
* If there is no expiry time, assumes the token is not expired or expiring.
|
|
3899
|
-
* @param downscopedAccessToken The credentials to check for expiration.
|
|
3900
|
-
* @return Whether the credentials are expired or not.
|
|
3901
|
-
*/
|
|
3902
|
-
private isExpired;
|
|
3903
|
-
}
|
|
3904
|
-
/**
|
|
3905
|
-
* An AuthClient without any Authentication information. Useful for:
|
|
3906
|
-
* - Anonymous access
|
|
3907
|
-
* - Local Emulators
|
|
3908
|
-
* - Testing Environments
|
|
3909
|
-
*
|
|
3910
|
-
*/
|
|
3911
|
-
declare class PassThroughClient extends AuthClient {
|
|
3912
|
-
/**
|
|
3913
|
-
* Creates a request without any authentication headers or checks.
|
|
3914
|
-
*
|
|
3915
|
-
* @remarks
|
|
3916
|
-
*
|
|
3917
|
-
* In testing environments it may be useful to change the provided
|
|
3918
|
-
* {@link AuthClient.transporter} for any desired request overrides/handling.
|
|
3919
|
-
*
|
|
3920
|
-
* @param opts
|
|
3921
|
-
* @returns The response of the request.
|
|
3922
|
-
*/
|
|
3923
|
-
request<T>(opts: GaxiosOptions): Promise<GaxiosResponse<T>>;
|
|
3924
|
-
/**
|
|
3925
|
-
* A required method of the base class.
|
|
3926
|
-
* Always will return an empty object.
|
|
3927
|
-
*
|
|
3928
|
-
* @returns {}
|
|
3929
|
-
*/
|
|
3930
|
-
getAccessToken(): Promise<GetAccessTokenResponse>;
|
|
3931
|
-
/**
|
|
3932
|
-
* A required method of the base class.
|
|
3933
|
-
* Always will return an empty object.
|
|
3934
|
-
*
|
|
3935
|
-
* @returns {}
|
|
3936
|
-
*/
|
|
3937
|
-
getRequestHeaders(): Promise<Headers>;
|
|
3938
|
-
}
|
|
3939
|
-
type ALL_EXPORTS = (typeof _$__0)[keyof typeof _$__0];
|
|
3940
|
-
/**
|
|
3941
|
-
* A union type for all {@link AuthClient `AuthClient`} constructors.
|
|
3942
|
-
*/
|
|
3943
|
-
type AnyAuthClientConstructor = Extract<ALL_EXPORTS, typeof AuthClient>;
|
|
3944
|
-
/**
|
|
3945
|
-
* A union type for all {@link AuthClient `AuthClient`}s.
|
|
3946
|
-
*/
|
|
3947
|
-
type AnyAuthClient = InstanceType<AnyAuthClientConstructor>;
|
|
3948
|
-
declare const auth: GoogleAuth<AuthClient>;
|
|
3949
13
|
interface StorageSettings {
|
|
3950
14
|
projectId: string;
|
|
3951
15
|
retryOptions?: RetryConfig;
|
|
@@ -3991,7 +55,7 @@ interface GCStorageOptions extends BaseStorageOptions, Omit<GoogleAuthOptions, "
|
|
|
3991
55
|
interface GCSMetaStorageOptions extends MetaStorageOptions, Omit<GoogleAuthOptions, "authClient" | "projectId">, StorageSettings {
|
|
3992
56
|
bucket?: string;
|
|
3993
57
|
}
|
|
3994
|
-
declare class GCSMetaStorage<T extends File
|
|
58
|
+
declare class GCSMetaStorage<T extends File = File> extends MetaStorage<T> {
|
|
3995
59
|
readonly config: GCSMetaStorageOptions;
|
|
3996
60
|
private authClient;
|
|
3997
61
|
private readonly storageBaseURI;
|
|
@@ -4040,6 +104,7 @@ declare class GCSMetaStorage<T extends File$1 = File$1> extends MetaStorage<T> {
|
|
|
4040
104
|
declare class GCStorage extends BaseStorage<GCSFile> {
|
|
4041
105
|
static override readonly name: string;
|
|
4042
106
|
override checksumTypes: string[];
|
|
107
|
+
override get raw(): GoogleAuth;
|
|
4043
108
|
protected meta: MetaStorage;
|
|
4044
109
|
private readonly bucket;
|
|
4045
110
|
private authClient;
|