@alienplatform/sdk 1.14.1 → 2.0.1

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.
Files changed (160) hide show
  1. package/dist/dist.js +371 -275
  2. package/dist/index.d.ts +22 -28
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +3 -14356
  5. package/dist/native.d.ts +26 -0
  6. package/dist/native.d.ts.map +1 -0
  7. package/dist/native.js +2 -0
  8. package/dist/worker-runtime/channel.d.ts +25 -0
  9. package/dist/worker-runtime/channel.d.ts.map +1 -0
  10. package/dist/worker-runtime/errors.d.ts +79 -0
  11. package/dist/worker-runtime/errors.d.ts.map +1 -0
  12. package/dist/worker-runtime/event-loop.d.ts +43 -0
  13. package/dist/worker-runtime/event-loop.d.ts.map +1 -0
  14. package/dist/{generated → worker-runtime/generated}/control.d.ts +15 -15
  15. package/dist/worker-runtime/generated/control.d.ts.map +1 -0
  16. package/dist/worker-runtime/generated/google/protobuf/duration.d.ts.map +1 -0
  17. package/dist/worker-runtime/generated/google/protobuf/timestamp.d.ts.map +1 -0
  18. package/dist/{generated → worker-runtime/generated}/wait_until.d.ts +29 -29
  19. package/dist/worker-runtime/generated/wait_until.d.ts.map +1 -0
  20. package/dist/worker-runtime/grpc-utils.d.ts +23 -0
  21. package/dist/worker-runtime/grpc-utils.d.ts.map +1 -0
  22. package/dist/worker-runtime/index.d.ts +33 -0
  23. package/dist/worker-runtime/index.d.ts.map +1 -0
  24. package/dist/{src.js → worker-runtime/index.js} +9370 -4035
  25. package/dist/worker-runtime/registry.d.ts +169 -0
  26. package/dist/worker-runtime/registry.d.ts.map +1 -0
  27. package/dist/worker-runtime/service-definitions.d.ts +12 -0
  28. package/dist/worker-runtime/service-definitions.d.ts.map +1 -0
  29. package/dist/worker-runtime/wait-until-manager.d.ts +34 -0
  30. package/dist/worker-runtime/wait-until-manager.d.ts.map +1 -0
  31. package/package.json +18 -38
  32. package/.turbo/turbo-build.log +0 -30
  33. package/AGENTS.md +0 -70
  34. package/dist/bearerTokenAuthenticationPolicy.js +0 -3028
  35. package/dist/bindings/artifact-registry.d.ts +0 -88
  36. package/dist/bindings/artifact-registry.d.ts.map +0 -1
  37. package/dist/bindings/build.d.ts +0 -67
  38. package/dist/bindings/build.d.ts.map +0 -1
  39. package/dist/bindings/index.d.ts +0 -13
  40. package/dist/bindings/index.d.ts.map +0 -1
  41. package/dist/bindings/kv.d.ts +0 -113
  42. package/dist/bindings/kv.d.ts.map +0 -1
  43. package/dist/bindings/postgres.d.ts +0 -90
  44. package/dist/bindings/postgres.d.ts.map +0 -1
  45. package/dist/bindings/postgres.test.d.ts +0 -2
  46. package/dist/bindings/postgres.test.d.ts.map +0 -1
  47. package/dist/bindings/queue.d.ts +0 -81
  48. package/dist/bindings/queue.d.ts.map +0 -1
  49. package/dist/bindings/service-account.d.ts +0 -46
  50. package/dist/bindings/service-account.d.ts.map +0 -1
  51. package/dist/bindings/storage.d.ts +0 -164
  52. package/dist/bindings/storage.d.ts.map +0 -1
  53. package/dist/bindings/vault.d.ts +0 -65
  54. package/dist/bindings/vault.d.ts.map +0 -1
  55. package/dist/bindings/worker.d.ts +0 -72
  56. package/dist/bindings/worker.d.ts.map +0 -1
  57. package/dist/channel.d.ts +0 -39
  58. package/dist/channel.d.ts.map +0 -1
  59. package/dist/checksum.js +0 -6176
  60. package/dist/commands/client.d.ts +0 -47
  61. package/dist/commands/client.d.ts.map +0 -1
  62. package/dist/commands/errors.d.ts +0 -198
  63. package/dist/commands/errors.d.ts.map +0 -1
  64. package/dist/commands/index.d.ts +0 -23
  65. package/dist/commands/index.d.ts.map +0 -1
  66. package/dist/commands/index.js +0 -387
  67. package/dist/commands/types.d.ts +0 -40
  68. package/dist/commands/types.d.ts.map +0 -1
  69. package/dist/commands.d.ts +0 -55
  70. package/dist/commands.d.ts.map +0 -1
  71. package/dist/context.d.ts +0 -182
  72. package/dist/context.d.ts.map +0 -1
  73. package/dist/dist-cjs.js +0 -15258
  74. package/dist/dist2.js +0 -1239
  75. package/dist/errors.d.ts +0 -359
  76. package/dist/errors.d.ts.map +0 -1
  77. package/dist/es5.js +0 -1720
  78. package/dist/esm.js +0 -18068
  79. package/dist/esm2.js +0 -3166
  80. package/dist/event-streams.js +0 -770
  81. package/dist/events.d.ts +0 -163
  82. package/dist/events.d.ts.map +0 -1
  83. package/dist/generated/artifact_registry.d.ts +0 -302
  84. package/dist/generated/artifact_registry.d.ts.map +0 -1
  85. package/dist/generated/build.d.ts +0 -184
  86. package/dist/generated/build.d.ts.map +0 -1
  87. package/dist/generated/container.d.ts +0 -101
  88. package/dist/generated/container.d.ts.map +0 -1
  89. package/dist/generated/control.d.ts.map +0 -1
  90. package/dist/generated/google/protobuf/duration.d.ts.map +0 -1
  91. package/dist/generated/google/protobuf/timestamp.d.ts.map +0 -1
  92. package/dist/generated/kv.d.ts +0 -182
  93. package/dist/generated/kv.d.ts.map +0 -1
  94. package/dist/generated/queue.d.ts +0 -127
  95. package/dist/generated/queue.d.ts.map +0 -1
  96. package/dist/generated/service_account.d.ts +0 -112
  97. package/dist/generated/service_account.d.ts.map +0 -1
  98. package/dist/generated/storage.d.ts +0 -784
  99. package/dist/generated/storage.d.ts.map +0 -1
  100. package/dist/generated/vault.d.ts +0 -107
  101. package/dist/generated/vault.d.ts.map +0 -1
  102. package/dist/generated/wait_until.d.ts.map +0 -1
  103. package/dist/generated/worker.d.ts +0 -107
  104. package/dist/generated/worker.d.ts.map +0 -1
  105. package/dist/global.d.ts +0 -208
  106. package/dist/global.d.ts.map +0 -1
  107. package/dist/grpc-utils.d.ts +0 -25
  108. package/dist/grpc-utils.d.ts.map +0 -1
  109. package/dist/jws.js +0 -611
  110. package/dist/open.js +0 -461
  111. package/dist/rolldown-runtime.js +0 -44
  112. package/dist/src2.js +0 -114032
  113. package/dist/types.d.ts +0 -337
  114. package/dist/types.d.ts.map +0 -1
  115. package/dist/wait-until.d.ts +0 -115
  116. package/dist/wait-until.d.ts.map +0 -1
  117. package/scripts/generate-proto.sh +0 -46
  118. package/src/bindings/AGENTS.md +0 -105
  119. package/src/bindings/artifact-registry.ts +0 -317
  120. package/src/bindings/build.ts +0 -195
  121. package/src/bindings/index.ts +0 -13
  122. package/src/bindings/kv.ts +0 -240
  123. package/src/bindings/postgres.test.ts +0 -17
  124. package/src/bindings/postgres.ts +0 -446
  125. package/src/bindings/queue.ts +0 -191
  126. package/src/bindings/service-account.ts +0 -113
  127. package/src/bindings/storage.ts +0 -536
  128. package/src/bindings/vault.ts +0 -133
  129. package/src/bindings/worker.ts +0 -164
  130. package/src/channel.ts +0 -102
  131. package/src/commands/client.ts +0 -446
  132. package/src/commands/errors.ts +0 -126
  133. package/src/commands/index.ts +0 -41
  134. package/src/commands/types.ts +0 -52
  135. package/src/commands.ts +0 -76
  136. package/src/context.ts +0 -368
  137. package/src/errors.ts +0 -280
  138. package/src/events.ts +0 -511
  139. package/src/generated/artifact_registry.ts +0 -2096
  140. package/src/generated/build.ts +0 -1311
  141. package/src/generated/container.ts +0 -503
  142. package/src/generated/control.ts +0 -2018
  143. package/src/generated/google/protobuf/duration.ts +0 -196
  144. package/src/generated/google/protobuf/timestamp.ts +0 -226
  145. package/src/generated/kv.ts +0 -1169
  146. package/src/generated/queue.ts +0 -753
  147. package/src/generated/service_account.ts +0 -814
  148. package/src/generated/storage.ts +0 -3820
  149. package/src/generated/vault.ts +0 -543
  150. package/src/generated/wait_until.ts +0 -829
  151. package/src/generated/worker.ts +0 -759
  152. package/src/global.ts +0 -287
  153. package/src/grpc-utils.ts +0 -159
  154. package/src/index.ts +0 -160
  155. package/src/types.ts +0 -397
  156. package/src/wait-until.ts +0 -273
  157. package/tsconfig.json +0 -8
  158. package/tsdown.config.ts +0 -17
  159. /package/dist/{generated → worker-runtime/generated}/google/protobuf/duration.d.ts +0 -0
  160. /package/dist/{generated → worker-runtime/generated}/google/protobuf/timestamp.d.ts +0 -0
package/dist/esm2.js DELETED
@@ -1,3166 +0,0 @@
1
- import { B as createTracingClient, C as RestError, D as createHttpHeaders, E as createPipelineRequest, F as delay, L as stringToUint8Array, M as stringToUint8Array$1, N as uint8ArrayToString$1, P as isObjectWithProperties, R as uint8ArrayToString, S as logger$2, T as createEmptyPipeline, V as createClientLogger, _ as decompressResponsePolicy, a as RestError$1, b as logPolicy, c as multipartPolicyName, d as tlsPolicy, f as agentPolicy, h as defaultRetryPolicy, l as isBinaryBody, m as formDataPolicy, n as bearerTokenAuthenticationPolicyName, p as proxyPolicy, r as createPipelineFromOptions$1, s as multipartPolicy, t as bearerTokenAuthenticationPolicy, u as isReadableStream, v as SDK_VERSION$1, w as isRestError, x as createDefaultHttpClient, y as redirectPolicy, z as isNodeLike } from "./bearerTokenAuthenticationPolicy.js";
2
- import os from "node:os";
3
- import process$1 from "node:process";
4
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/util/userAgentPlatform.js
5
- /**
6
- * @internal
7
- */
8
- function getHeaderName() {
9
- return "User-Agent";
10
- }
11
- /**
12
- * @internal
13
- */
14
- async function setPlatformSpecificData(map) {
15
- if (process$1 && process$1.versions) {
16
- const osInfo = `${os.type()} ${os.release()}; ${os.arch()}`;
17
- const versions = process$1.versions;
18
- if (versions.bun) map.set("Bun", `${versions.bun} (${osInfo})`);
19
- else if (versions.deno) map.set("Deno", `${versions.deno} (${osInfo})`);
20
- else if (versions.node) map.set("Node", `${versions.node} (${osInfo})`);
21
- }
22
- }
23
- //#endregion
24
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/util/userAgent.js
25
- function getUserAgentString(telemetryInfo) {
26
- const parts = [];
27
- for (const [key, value] of telemetryInfo) {
28
- const token = value ? `${key}/${value}` : key;
29
- parts.push(token);
30
- }
31
- return parts.join(" ");
32
- }
33
- /**
34
- * @internal
35
- */
36
- function getUserAgentHeaderName() {
37
- return getHeaderName();
38
- }
39
- /**
40
- * @internal
41
- */
42
- async function getUserAgentValue(prefix) {
43
- const runtimeInfo = /* @__PURE__ */ new Map();
44
- runtimeInfo.set("ts-http-runtime", SDK_VERSION$1);
45
- await setPlatformSpecificData(runtimeInfo);
46
- const defaultAgent = getUserAgentString(runtimeInfo);
47
- return prefix ? `${prefix} ${defaultAgent}` : defaultAgent;
48
- }
49
- //#endregion
50
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/policies/userAgentPolicy.js
51
- const UserAgentHeaderName = getUserAgentHeaderName();
52
- /**
53
- * The programmatic identifier of the userAgentPolicy.
54
- */
55
- const userAgentPolicyName = "userAgentPolicy";
56
- /**
57
- * A policy that sets the User-Agent header (or equivalent) to reflect
58
- * the library version.
59
- * @param options - Options to customize the user agent value.
60
- */
61
- function userAgentPolicy(options = {}) {
62
- const userAgentValue = getUserAgentValue(options.userAgentPrefix);
63
- return {
64
- name: userAgentPolicyName,
65
- async sendRequest(request, next) {
66
- if (!request.headers.has(UserAgentHeaderName)) request.headers.set(UserAgentHeaderName, await userAgentValue);
67
- return next(request);
68
- }
69
- };
70
- }
71
- //#endregion
72
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/createPipelineFromOptions.js
73
- /**
74
- * Create a new pipeline with a default set of customizable policies.
75
- * @param options - Options to configure a custom pipeline.
76
- */
77
- function createPipelineFromOptions(options) {
78
- const pipeline = createEmptyPipeline();
79
- if (isNodeLike) {
80
- if (options.agent) pipeline.addPolicy(agentPolicy(options.agent));
81
- if (options.tlsOptions) pipeline.addPolicy(tlsPolicy(options.tlsOptions));
82
- pipeline.addPolicy(proxyPolicy(options.proxyOptions));
83
- pipeline.addPolicy(decompressResponsePolicy());
84
- }
85
- pipeline.addPolicy(formDataPolicy(), { beforePolicies: [multipartPolicyName] });
86
- pipeline.addPolicy(userAgentPolicy(options.userAgentOptions));
87
- pipeline.addPolicy(multipartPolicy(), { afterPhase: "Deserialize" });
88
- pipeline.addPolicy(defaultRetryPolicy(options.retryOptions), { phase: "Retry" });
89
- if (isNodeLike) pipeline.addPolicy(redirectPolicy(options.redirectOptions), { afterPhase: "Retry" });
90
- pipeline.addPolicy(logPolicy(options.loggingOptions), { afterPhase: "Sign" });
91
- return pipeline;
92
- }
93
- //#endregion
94
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/client/apiVersionPolicy.js
95
- const apiVersionPolicyName$1 = "ApiVersionPolicy";
96
- /**
97
- * Creates a policy that sets the apiVersion as a query parameter on every request
98
- * @param options - Client options
99
- * @returns Pipeline policy that sets the apiVersion as a query parameter on every request
100
- */
101
- function apiVersionPolicy$1(options) {
102
- return {
103
- name: apiVersionPolicyName$1,
104
- sendRequest: (req, next) => {
105
- const url = new URL(req.url);
106
- if (!url.searchParams.get("api-version") && options.apiVersion) req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${options.apiVersion}`;
107
- return next(req);
108
- }
109
- };
110
- }
111
- //#endregion
112
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/auth/credentials.js
113
- /**
114
- * Type guard to check if a credential is an OAuth2 token credential.
115
- */
116
- function isOAuth2TokenCredential(credential) {
117
- return "getOAuth2Token" in credential;
118
- }
119
- /**
120
- * Type guard to check if a credential is a Bearer token credential.
121
- */
122
- function isBearerTokenCredential(credential) {
123
- return "getBearerToken" in credential;
124
- }
125
- /**
126
- * Type guard to check if a credential is a Basic auth credential.
127
- */
128
- function isBasicCredential(credential) {
129
- return "username" in credential && "password" in credential;
130
- }
131
- /**
132
- * Type guard to check if a credential is an API key credential.
133
- */
134
- function isApiKeyCredential(credential) {
135
- return "key" in credential;
136
- }
137
- //#endregion
138
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/policies/auth/checkInsecureConnection.js
139
- let insecureConnectionWarningEmmitted = false;
140
- /**
141
- * Checks if the request is allowed to be sent over an insecure connection.
142
- *
143
- * A request is allowed to be sent over an insecure connection when:
144
- * - The `allowInsecureConnection` option is set to `true`.
145
- * - The request has the `allowInsecureConnection` property set to `true`.
146
- * - The request is being sent to `localhost` or `127.0.0.1`
147
- */
148
- function allowInsecureConnection(request, options) {
149
- if (options.allowInsecureConnection && request.allowInsecureConnection) {
150
- const url = new URL(request.url);
151
- if (url.hostname === "localhost" || url.hostname === "127.0.0.1") return true;
152
- }
153
- return false;
154
- }
155
- /**
156
- * Logs a warning about sending a token over an insecure connection.
157
- *
158
- * This function will emit a node warning once, but log the warning every time.
159
- */
160
- function emitInsecureConnectionWarning() {
161
- const warning = "Sending token over insecure transport. Assume any token issued is compromised.";
162
- logger$2.warning(warning);
163
- if (typeof process?.emitWarning === "function" && !insecureConnectionWarningEmmitted) {
164
- insecureConnectionWarningEmmitted = true;
165
- process.emitWarning(warning);
166
- }
167
- }
168
- /**
169
- * Ensures that authentication is only allowed over HTTPS unless explicitly allowed.
170
- * Throws an error if the connection is not secure and not explicitly allowed.
171
- */
172
- function ensureSecureConnection(request, options) {
173
- if (!request.url.toLowerCase().startsWith("https://")) if (allowInsecureConnection(request, options)) emitInsecureConnectionWarning();
174
- else throw new Error("Authentication is not permitted for non-TLS protected (non-https) URLs when allowInsecureConnection is false.");
175
- }
176
- //#endregion
177
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/policies/auth/apiKeyAuthenticationPolicy.js
178
- /**
179
- * Name of the API Key Authentication Policy
180
- */
181
- const apiKeyAuthenticationPolicyName = "apiKeyAuthenticationPolicy";
182
- /**
183
- * Gets a pipeline policy that adds API key authentication to requests
184
- */
185
- function apiKeyAuthenticationPolicy(options) {
186
- return {
187
- name: apiKeyAuthenticationPolicyName,
188
- async sendRequest(request, next) {
189
- ensureSecureConnection(request, options);
190
- const scheme = (request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === "apiKey");
191
- if (!scheme) return next(request);
192
- if (scheme.apiKeyLocation !== "header") throw new Error(`Unsupported API key location: ${scheme.apiKeyLocation}`);
193
- request.headers.set(scheme.name, options.credential.key);
194
- return next(request);
195
- }
196
- };
197
- }
198
- //#endregion
199
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/policies/auth/basicAuthenticationPolicy.js
200
- /**
201
- * Name of the Basic Authentication Policy
202
- */
203
- const basicAuthenticationPolicyName = "bearerAuthenticationPolicy";
204
- /**
205
- * Gets a pipeline policy that adds basic authentication to requests
206
- */
207
- function basicAuthenticationPolicy(options) {
208
- return {
209
- name: basicAuthenticationPolicyName,
210
- async sendRequest(request, next) {
211
- ensureSecureConnection(request, options);
212
- if (!(request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === "http" && x.scheme === "basic")) return next(request);
213
- const { username, password } = options.credential;
214
- const headerValue = uint8ArrayToString(stringToUint8Array(`${username}:${password}`, "utf-8"), "base64");
215
- request.headers.set("Authorization", `Basic ${headerValue}`);
216
- return next(request);
217
- }
218
- };
219
- }
220
- //#endregion
221
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/policies/auth/bearerAuthenticationPolicy.js
222
- /**
223
- * Name of the Bearer Authentication Policy
224
- */
225
- const bearerAuthenticationPolicyName = "bearerAuthenticationPolicy";
226
- /**
227
- * Gets a pipeline policy that adds bearer token authentication to requests
228
- */
229
- function bearerAuthenticationPolicy(options) {
230
- return {
231
- name: bearerAuthenticationPolicyName,
232
- async sendRequest(request, next) {
233
- ensureSecureConnection(request, options);
234
- if (!(request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === "http" && x.scheme === "bearer")) return next(request);
235
- const token = await options.credential.getBearerToken({ abortSignal: request.abortSignal });
236
- request.headers.set("Authorization", `Bearer ${token}`);
237
- return next(request);
238
- }
239
- };
240
- }
241
- //#endregion
242
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/policies/auth/oauth2AuthenticationPolicy.js
243
- /**
244
- * Name of the OAuth2 Authentication Policy
245
- */
246
- const oauth2AuthenticationPolicyName = "oauth2AuthenticationPolicy";
247
- /**
248
- * Gets a pipeline policy that adds authorization header from OAuth2 schemes
249
- */
250
- function oauth2AuthenticationPolicy(options) {
251
- return {
252
- name: oauth2AuthenticationPolicyName,
253
- async sendRequest(request, next) {
254
- ensureSecureConnection(request, options);
255
- const scheme = (request.authSchemes ?? options.authSchemes)?.find((x) => x.kind === "oauth2");
256
- if (!scheme) return next(request);
257
- const token = await options.credential.getOAuth2Token(scheme.flows, { abortSignal: request.abortSignal });
258
- request.headers.set("Authorization", `Bearer ${token}`);
259
- return next(request);
260
- }
261
- };
262
- }
263
- //#endregion
264
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/client/clientHelpers.js
265
- let cachedHttpClient;
266
- /**
267
- * Creates a default rest pipeline to re-use accross Rest Level Clients
268
- */
269
- function createDefaultPipeline$1(options = {}) {
270
- const pipeline = createPipelineFromOptions(options);
271
- pipeline.addPolicy(apiVersionPolicy$1(options));
272
- const { credential, authSchemes, allowInsecureConnection } = options;
273
- if (credential) {
274
- if (isApiKeyCredential(credential)) pipeline.addPolicy(apiKeyAuthenticationPolicy({
275
- authSchemes,
276
- credential,
277
- allowInsecureConnection
278
- }));
279
- else if (isBasicCredential(credential)) pipeline.addPolicy(basicAuthenticationPolicy({
280
- authSchemes,
281
- credential,
282
- allowInsecureConnection
283
- }));
284
- else if (isBearerTokenCredential(credential)) pipeline.addPolicy(bearerAuthenticationPolicy({
285
- authSchemes,
286
- credential,
287
- allowInsecureConnection
288
- }));
289
- else if (isOAuth2TokenCredential(credential)) pipeline.addPolicy(oauth2AuthenticationPolicy({
290
- authSchemes,
291
- credential,
292
- allowInsecureConnection
293
- }));
294
- }
295
- return pipeline;
296
- }
297
- function getCachedDefaultHttpsClient() {
298
- if (!cachedHttpClient) cachedHttpClient = createDefaultHttpClient();
299
- return cachedHttpClient;
300
- }
301
- //#endregion
302
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/client/multipart.js
303
- /**
304
- * Get value of a header in the part descriptor ignoring case
305
- */
306
- function getHeaderValue(descriptor, headerName) {
307
- if (descriptor.headers) {
308
- const actualHeaderName = Object.keys(descriptor.headers).find((x) => x.toLowerCase() === headerName.toLowerCase());
309
- if (actualHeaderName) return descriptor.headers[actualHeaderName];
310
- }
311
- }
312
- function getPartContentType(descriptor) {
313
- const contentTypeHeader = getHeaderValue(descriptor, "content-type");
314
- if (contentTypeHeader) return contentTypeHeader;
315
- if (descriptor.contentType === null) return;
316
- if (descriptor.contentType) return descriptor.contentType;
317
- const { body } = descriptor;
318
- if (body === null || body === void 0) return;
319
- if (typeof body === "string" || typeof body === "number" || typeof body === "boolean") return "text/plain; charset=UTF-8";
320
- if (body instanceof Blob) return body.type || "application/octet-stream";
321
- if (isBinaryBody(body)) return "application/octet-stream";
322
- return "application/json";
323
- }
324
- /**
325
- * Enclose value in quotes and escape special characters, for use in the Content-Disposition header
326
- */
327
- function escapeDispositionField(value) {
328
- return JSON.stringify(value);
329
- }
330
- function getContentDisposition(descriptor) {
331
- const contentDispositionHeader = getHeaderValue(descriptor, "content-disposition");
332
- if (contentDispositionHeader) return contentDispositionHeader;
333
- if (descriptor.dispositionType === void 0 && descriptor.name === void 0 && descriptor.filename === void 0) return;
334
- let disposition = descriptor.dispositionType ?? "form-data";
335
- if (descriptor.name) disposition += `; name=${escapeDispositionField(descriptor.name)}`;
336
- let filename = void 0;
337
- if (descriptor.filename) filename = descriptor.filename;
338
- else if (typeof File !== "undefined" && descriptor.body instanceof File) {
339
- const filenameFromFile = descriptor.body.name;
340
- if (filenameFromFile !== "") filename = filenameFromFile;
341
- }
342
- if (filename) disposition += `; filename=${escapeDispositionField(filename)}`;
343
- return disposition;
344
- }
345
- function normalizeBody(body, contentType) {
346
- if (body === void 0) return new Uint8Array([]);
347
- if (isBinaryBody(body)) return body;
348
- if (typeof body === "string" || typeof body === "number" || typeof body === "boolean") return stringToUint8Array(String(body), "utf-8");
349
- if (contentType && /application\/(.+\+)?json(;.+)?/i.test(String(contentType))) return stringToUint8Array(JSON.stringify(body), "utf-8");
350
- throw new RestError(`Unsupported body/content-type combination: ${body}, ${contentType}`);
351
- }
352
- function buildBodyPart(descriptor) {
353
- const contentType = getPartContentType(descriptor);
354
- const contentDisposition = getContentDisposition(descriptor);
355
- const headers = createHttpHeaders(descriptor.headers ?? {});
356
- if (contentType) headers.set("content-type", contentType);
357
- if (contentDisposition) headers.set("content-disposition", contentDisposition);
358
- return {
359
- headers,
360
- body: normalizeBody(descriptor.body, contentType)
361
- };
362
- }
363
- function buildMultipartBody(parts) {
364
- return { parts: parts.map(buildBodyPart) };
365
- }
366
- //#endregion
367
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/client/sendRequest.js
368
- /**
369
- * Helper function to send request used by the client
370
- * @param method - method to use to send the request
371
- * @param url - url to send the request to
372
- * @param pipeline - pipeline with the policies to run when sending the request
373
- * @param options - request options
374
- * @param customHttpClient - a custom HttpClient to use when making the request
375
- * @returns returns and HttpResponse
376
- */
377
- async function sendRequest(method, url, pipeline, options = {}, customHttpClient) {
378
- const httpClient = customHttpClient ?? getCachedDefaultHttpsClient();
379
- const request = buildPipelineRequest(method, url, options);
380
- try {
381
- const response = await pipeline.sendRequest(httpClient, request);
382
- const headers = response.headers.toJSON();
383
- const stream = response.readableStreamBody ?? response.browserStreamBody;
384
- const parsedBody = options.responseAsStream || stream !== void 0 ? void 0 : getResponseBody(response);
385
- const body = stream ?? parsedBody;
386
- if (options?.onResponse) options.onResponse({
387
- ...response,
388
- request,
389
- rawHeaders: headers,
390
- parsedBody
391
- });
392
- return {
393
- request,
394
- headers,
395
- status: `${response.status}`,
396
- body
397
- };
398
- } catch (e) {
399
- if (isRestError(e) && e.response && options.onResponse) {
400
- const { response } = e;
401
- const rawHeaders = response.headers.toJSON();
402
- options?.onResponse({
403
- ...response,
404
- request,
405
- rawHeaders
406
- }, e);
407
- }
408
- throw e;
409
- }
410
- }
411
- /**
412
- * Function to determine the request content type
413
- * @param options - request options InternalRequestParameters
414
- * @returns returns the content-type
415
- */
416
- function getRequestContentType(options = {}) {
417
- return options.contentType ?? options.headers?.["content-type"] ?? getContentType(options.body);
418
- }
419
- /**
420
- * Function to determine the content-type of a body
421
- * this is used if an explicit content-type is not provided
422
- * @param body - body in the request
423
- * @returns returns the content-type
424
- */
425
- function getContentType(body) {
426
- if (ArrayBuffer.isView(body)) return "application/octet-stream";
427
- if (typeof body === "string") try {
428
- JSON.parse(body);
429
- return "application/json";
430
- } catch (error) {
431
- return;
432
- }
433
- return "application/json";
434
- }
435
- function buildPipelineRequest(method, url, options = {}) {
436
- const requestContentType = getRequestContentType(options);
437
- const { body, multipartBody } = getRequestBody(options.body, requestContentType);
438
- const hasContent = body !== void 0 || multipartBody !== void 0;
439
- return createPipelineRequest({
440
- url,
441
- method,
442
- body,
443
- multipartBody,
444
- headers: createHttpHeaders({
445
- ...options.headers ? options.headers : {},
446
- accept: options.accept ?? options.headers?.accept ?? "application/json",
447
- ...hasContent && requestContentType && { "content-type": requestContentType }
448
- }),
449
- allowInsecureConnection: options.allowInsecureConnection,
450
- abortSignal: options.abortSignal,
451
- onUploadProgress: options.onUploadProgress,
452
- onDownloadProgress: options.onDownloadProgress,
453
- timeout: options.timeout,
454
- enableBrowserStreams: true,
455
- streamResponseStatusCodes: options.responseAsStream ? /* @__PURE__ */ new Set([Number.POSITIVE_INFINITY]) : void 0
456
- });
457
- }
458
- /**
459
- * Prepares the body before sending the request
460
- */
461
- function getRequestBody(body, contentType = "") {
462
- if (body === void 0) return { body: void 0 };
463
- if (typeof FormData !== "undefined" && body instanceof FormData) return { body };
464
- if (isReadableStream(body)) return { body };
465
- if (ArrayBuffer.isView(body)) return { body: body instanceof Uint8Array ? body : JSON.stringify(body) };
466
- switch (contentType.split(";")[0]) {
467
- case "application/json": return { body: JSON.stringify(body) };
468
- case "multipart/form-data":
469
- if (Array.isArray(body)) return { multipartBody: buildMultipartBody(body) };
470
- return { body: JSON.stringify(body) };
471
- case "text/plain": return { body: String(body) };
472
- default:
473
- if (typeof body === "string") return { body };
474
- return { body: JSON.stringify(body) };
475
- }
476
- }
477
- /**
478
- * Prepares the response body
479
- */
480
- function getResponseBody(response) {
481
- const firstType = (response.headers.get("content-type") ?? "").split(";")[0];
482
- const bodyToParse = response.bodyAsText ?? "";
483
- if (firstType === "text/plain") return String(bodyToParse);
484
- try {
485
- return bodyToParse ? JSON.parse(bodyToParse) : void 0;
486
- } catch (error) {
487
- if (firstType === "application/json") throw createParseError(response, error);
488
- return String(bodyToParse);
489
- }
490
- }
491
- function createParseError(response, err) {
492
- return new RestError(`Error "${err}" occurred while parsing the response body - ${response.bodyAsText}.`, {
493
- code: err.code ?? RestError.PARSE_ERROR,
494
- statusCode: response.status,
495
- request: response.request,
496
- response
497
- });
498
- }
499
- //#endregion
500
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/client/urlHelpers.js
501
- function isQueryParameterWithOptions(x) {
502
- const value = x.value;
503
- return value !== void 0 && value.toString !== void 0 && typeof value.toString === "function";
504
- }
505
- /**
506
- * Builds the request url, filling in query and path parameters
507
- * @param endpoint - base url which can be a template url
508
- * @param routePath - path to append to the endpoint
509
- * @param pathParameters - values of the path parameters
510
- * @param options - request parameters including query parameters
511
- * @returns a full url with path and query parameters
512
- */
513
- function buildRequestUrl(endpoint, routePath, pathParameters, options = {}) {
514
- if (routePath.startsWith("https://") || routePath.startsWith("http://")) return routePath;
515
- endpoint = buildBaseUrl(endpoint, options);
516
- routePath = buildRoutePath(routePath, pathParameters, options);
517
- const requestUrl = appendQueryParams(`${endpoint}/${routePath}`, options);
518
- return new URL(requestUrl).toString().replace(/([^:]\/)\/+/g, "$1");
519
- }
520
- function getQueryParamValue(key, allowReserved, style, param) {
521
- let separator;
522
- if (style === "pipeDelimited") separator = "|";
523
- else if (style === "spaceDelimited") separator = "%20";
524
- else separator = ",";
525
- let paramValues;
526
- if (Array.isArray(param)) paramValues = param;
527
- else if (typeof param === "object" && param.toString === Object.prototype.toString) paramValues = Object.entries(param).flat();
528
- else paramValues = [param];
529
- const value = paramValues.map((p) => {
530
- if (p === null || p === void 0) return "";
531
- if (!p.toString || typeof p.toString !== "function") throw new Error(`Query parameters must be able to be represented as string, ${key} can't`);
532
- const rawValue = p.toISOString !== void 0 ? p.toISOString() : p.toString();
533
- return allowReserved ? rawValue : encodeURIComponent(rawValue);
534
- }).join(separator);
535
- return `${allowReserved ? key : encodeURIComponent(key)}=${value}`;
536
- }
537
- function appendQueryParams(url, options = {}) {
538
- if (!options.queryParameters) return url;
539
- const parsedUrl = new URL(url);
540
- const queryParams = options.queryParameters;
541
- const paramStrings = [];
542
- for (const key of Object.keys(queryParams)) {
543
- const param = queryParams[key];
544
- if (param === void 0 || param === null) continue;
545
- const hasMetadata = isQueryParameterWithOptions(param);
546
- const rawValue = hasMetadata ? param.value : param;
547
- const explode = hasMetadata ? param.explode ?? false : false;
548
- const style = hasMetadata && param.style ? param.style : "form";
549
- if (explode) if (Array.isArray(rawValue)) for (const item of rawValue) paramStrings.push(getQueryParamValue(key, options.skipUrlEncoding ?? false, style, item));
550
- else if (typeof rawValue === "object") for (const [actualKey, value] of Object.entries(rawValue)) paramStrings.push(getQueryParamValue(actualKey, options.skipUrlEncoding ?? false, style, value));
551
- else throw new Error("explode can only be set to true for objects and arrays");
552
- else paramStrings.push(getQueryParamValue(key, options.skipUrlEncoding ?? false, style, rawValue));
553
- }
554
- if (parsedUrl.search !== "") parsedUrl.search += "&";
555
- parsedUrl.search += paramStrings.join("&");
556
- return parsedUrl.toString();
557
- }
558
- function buildBaseUrl(endpoint, options) {
559
- if (!options.pathParameters) return endpoint;
560
- const pathParams = options.pathParameters;
561
- for (const [key, param] of Object.entries(pathParams)) {
562
- if (param === void 0 || param === null) throw new Error(`Path parameters ${key} must not be undefined or null`);
563
- if (!param.toString || typeof param.toString !== "function") throw new Error(`Path parameters must be able to be represented as string, ${key} can't`);
564
- let value = param.toISOString !== void 0 ? param.toISOString() : String(param);
565
- if (!options.skipUrlEncoding) value = encodeURIComponent(param);
566
- endpoint = replaceAll(endpoint, `{${key}}`, value) ?? "";
567
- }
568
- return endpoint;
569
- }
570
- function buildRoutePath(routePath, pathParameters, options = {}) {
571
- for (const pathParam of pathParameters) {
572
- const allowReserved = typeof pathParam === "object" && (pathParam.allowReserved ?? false);
573
- let value = typeof pathParam === "object" ? pathParam.value : pathParam;
574
- if (!options.skipUrlEncoding && !allowReserved) value = encodeURIComponent(value);
575
- routePath = routePath.replace(/\{[\w-]+\}/, String(value));
576
- }
577
- return routePath;
578
- }
579
- /**
580
- * Replace all of the instances of searchValue in value with the provided replaceValue.
581
- * @param value - The value to search and replace in.
582
- * @param searchValue - The value to search for in the value argument.
583
- * @param replaceValue - The value to replace searchValue with in the value argument.
584
- * @returns The value where each instance of searchValue was replaced with replacedValue.
585
- */
586
- function replaceAll(value, searchValue, replaceValue) {
587
- return !value || !searchValue ? value : value.split(searchValue).join(replaceValue || "");
588
- }
589
- //#endregion
590
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/client/getClient.js
591
- /**
592
- * Creates a client with a default pipeline
593
- * @param endpoint - Base endpoint for the client
594
- * @param credentials - Credentials to authenticate the requests
595
- * @param options - Client options
596
- */
597
- function getClient$1(endpoint, clientOptions = {}) {
598
- const pipeline = clientOptions.pipeline ?? createDefaultPipeline$1(clientOptions);
599
- if (clientOptions.additionalPolicies?.length) for (const { policy, position } of clientOptions.additionalPolicies) {
600
- const afterPhase = position === "perRetry" ? "Sign" : void 0;
601
- pipeline.addPolicy(policy, { afterPhase });
602
- }
603
- const { allowInsecureConnection, httpClient } = clientOptions;
604
- const endpointUrl = clientOptions.endpoint ?? endpoint;
605
- const client = (path, ...args) => {
606
- const getUrl = (requestOptions) => buildRequestUrl(endpointUrl, path, args, {
607
- allowInsecureConnection,
608
- ...requestOptions
609
- });
610
- return {
611
- get: (requestOptions = {}) => {
612
- return buildOperation("GET", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
613
- },
614
- post: (requestOptions = {}) => {
615
- return buildOperation("POST", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
616
- },
617
- put: (requestOptions = {}) => {
618
- return buildOperation("PUT", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
619
- },
620
- patch: (requestOptions = {}) => {
621
- return buildOperation("PATCH", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
622
- },
623
- delete: (requestOptions = {}) => {
624
- return buildOperation("DELETE", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
625
- },
626
- head: (requestOptions = {}) => {
627
- return buildOperation("HEAD", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
628
- },
629
- options: (requestOptions = {}) => {
630
- return buildOperation("OPTIONS", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
631
- },
632
- trace: (requestOptions = {}) => {
633
- return buildOperation("TRACE", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
634
- }
635
- };
636
- };
637
- return {
638
- path: client,
639
- pathUnchecked: client,
640
- pipeline
641
- };
642
- }
643
- function buildOperation(method, url, pipeline, options, allowInsecureConnection, httpClient) {
644
- allowInsecureConnection = options.allowInsecureConnection ?? allowInsecureConnection;
645
- return {
646
- then: function(onFulfilled, onrejected) {
647
- return sendRequest(method, url, pipeline, {
648
- ...options,
649
- allowInsecureConnection
650
- }, httpClient).then(onFulfilled, onrejected);
651
- },
652
- async asBrowserStream() {
653
- if (isNodeLike) throw new Error("`asBrowserStream` is supported only in the browser environment. Use `asNodeStream` instead to obtain the response body stream. If you require a Web stream of the response in Node, consider using `Readable.toWeb` on the result of `asNodeStream`.");
654
- else return sendRequest(method, url, pipeline, {
655
- ...options,
656
- allowInsecureConnection,
657
- responseAsStream: true
658
- }, httpClient);
659
- },
660
- async asNodeStream() {
661
- if (isNodeLike) return sendRequest(method, url, pipeline, {
662
- ...options,
663
- allowInsecureConnection,
664
- responseAsStream: true
665
- }, httpClient);
666
- else throw new Error("`isNodeStream` is not supported in the browser environment. Use `asBrowserStream` to obtain the response body stream.");
667
- }
668
- };
669
- }
670
- //#endregion
671
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/client/operationOptionHelpers.js
672
- /**
673
- * Helper function to convert OperationOptions to RequestParameters
674
- * @param options - the options that are used by Modular layer to send the request
675
- * @returns the result of the conversion in RequestParameters of RLC layer
676
- */
677
- function operationOptionsToRequestParameters$1(options) {
678
- return {
679
- allowInsecureConnection: options.requestOptions?.allowInsecureConnection,
680
- timeout: options.requestOptions?.timeout,
681
- skipUrlEncoding: options.requestOptions?.skipUrlEncoding,
682
- abortSignal: options.abortSignal,
683
- onUploadProgress: options.requestOptions?.onUploadProgress,
684
- onDownloadProgress: options.requestOptions?.onDownloadProgress,
685
- headers: { ...options.requestOptions?.headers },
686
- onResponse: options.onResponse
687
- };
688
- }
689
- //#endregion
690
- //#region ../../node_modules/.pnpm/@typespec+ts-http-runtime@0.3.2/node_modules/@typespec/ts-http-runtime/dist/esm/client/restError.js
691
- function createRestError$1(messageOrResponse, response) {
692
- const resp = typeof messageOrResponse === "string" ? response : messageOrResponse;
693
- const internalError = resp.body?.error ?? resp.body;
694
- return new RestError(typeof messageOrResponse === "string" ? messageOrResponse : internalError?.message ?? `Unexpected status code: ${resp.status}`, {
695
- statusCode: statusCodeToNumber(resp.status),
696
- code: internalError?.code,
697
- request: resp.request,
698
- response: toPipelineResponse(resp)
699
- });
700
- }
701
- function toPipelineResponse(response) {
702
- return {
703
- headers: createHttpHeaders(response.headers),
704
- request: response.request,
705
- status: statusCodeToNumber(response.status) ?? -1
706
- };
707
- }
708
- function statusCodeToNumber(statusCode) {
709
- const status = Number.parseInt(statusCode);
710
- return Number.isNaN(status) ? void 0 : status;
711
- }
712
- //#endregion
713
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/logger.js
714
- /**
715
- * The \@azure/logger configuration for this package.
716
- */
717
- const logger = createClientLogger("keyvault-secrets");
718
- //#endregion
719
- //#region ../../node_modules/.pnpm/@azure-rest+core-client@2.5.1/node_modules/@azure-rest/core-client/dist/esm/restError.js
720
- function createRestError(messageOrResponse, response) {
721
- if (typeof messageOrResponse === "string") return createRestError$1(messageOrResponse, response);
722
- else return createRestError$1(messageOrResponse);
723
- }
724
- //#endregion
725
- //#region ../../node_modules/.pnpm/@azure+core-auth@1.10.1/node_modules/@azure/core-auth/dist/esm/keyCredential.js
726
- /**
727
- * Tests an object to determine whether it implements KeyCredential.
728
- *
729
- * @param credential - The assumed KeyCredential to be tested.
730
- */
731
- function isKeyCredential$1(credential) {
732
- return isObjectWithProperties(credential, ["key"]) && typeof credential.key === "string";
733
- }
734
- //#endregion
735
- //#region ../../node_modules/.pnpm/@azure+core-auth@1.10.1/node_modules/@azure/core-auth/dist/esm/tokenCredential.js
736
- /**
737
- * Tests an object to determine whether it implements TokenCredential.
738
- *
739
- * @param credential - The assumed TokenCredential to be tested.
740
- */
741
- function isTokenCredential(credential) {
742
- const castCredential = credential;
743
- return castCredential && typeof castCredential.getToken === "function" && (castCredential.signRequest === void 0 || castCredential.getToken.length > 0);
744
- }
745
- //#endregion
746
- //#region ../../node_modules/.pnpm/@azure-rest+core-client@2.5.1/node_modules/@azure-rest/core-client/dist/esm/apiVersionPolicy.js
747
- const apiVersionPolicyName = "ApiVersionPolicy";
748
- /**
749
- * Creates a policy that sets the apiVersion as a query parameter on every request
750
- * @param options - Client options
751
- * @returns Pipeline policy that sets the apiVersion as a query parameter on every request
752
- */
753
- function apiVersionPolicy(options) {
754
- return {
755
- name: apiVersionPolicyName,
756
- sendRequest: (req, next) => {
757
- const url = new URL(req.url);
758
- if (!url.searchParams.get("api-version") && options.apiVersion) req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${options.apiVersion}`;
759
- return next(req);
760
- }
761
- };
762
- }
763
- //#endregion
764
- //#region ../../node_modules/.pnpm/@azure-rest+core-client@2.5.1/node_modules/@azure-rest/core-client/dist/esm/keyCredentialAuthenticationPolicy.js
765
- /**
766
- * The programmatic identifier of the bearerTokenAuthenticationPolicy.
767
- */
768
- const keyCredentialAuthenticationPolicyName = "keyCredentialAuthenticationPolicy";
769
- function keyCredentialAuthenticationPolicy(credential, apiKeyHeaderName) {
770
- return {
771
- name: keyCredentialAuthenticationPolicyName,
772
- async sendRequest(request, next) {
773
- request.headers.set(apiKeyHeaderName, credential.key);
774
- return next(request);
775
- }
776
- };
777
- }
778
- //#endregion
779
- //#region ../../node_modules/.pnpm/@azure-rest+core-client@2.5.1/node_modules/@azure-rest/core-client/dist/esm/clientHelpers.js
780
- /**
781
- * Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.
782
- */
783
- function addCredentialPipelinePolicy(pipeline, endpoint, options = {}) {
784
- const { credential, clientOptions } = options;
785
- if (!credential) return;
786
- if (isTokenCredential(credential)) {
787
- const tokenPolicy = bearerTokenAuthenticationPolicy({
788
- credential,
789
- scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`
790
- });
791
- pipeline.addPolicy(tokenPolicy);
792
- } else if (isKeyCredential(credential)) {
793
- if (!clientOptions?.credentials?.apiKeyHeaderName) throw new Error(`Missing API Key Header Name`);
794
- const keyPolicy = keyCredentialAuthenticationPolicy(credential, clientOptions?.credentials?.apiKeyHeaderName);
795
- pipeline.addPolicy(keyPolicy);
796
- }
797
- }
798
- /**
799
- * Creates a default rest pipeline to re-use accross Rest Level Clients
800
- */
801
- function createDefaultPipeline(endpoint, credential, options = {}) {
802
- const pipeline = createPipelineFromOptions$1(options);
803
- pipeline.addPolicy(apiVersionPolicy(options));
804
- addCredentialPipelinePolicy(pipeline, endpoint, {
805
- credential,
806
- clientOptions: options
807
- });
808
- return pipeline;
809
- }
810
- function isKeyCredential(credential) {
811
- return credential.key !== void 0;
812
- }
813
- //#endregion
814
- //#region ../../node_modules/.pnpm/@azure-rest+core-client@2.5.1/node_modules/@azure-rest/core-client/dist/esm/operationOptionHelpers.js
815
- /**
816
- * Helper function to convert OperationOptions to RequestParameters
817
- * @param options - the options that are used by Modular layer to send the request
818
- * @returns the result of the conversion in RequestParameters of RLC layer
819
- */
820
- function operationOptionsToRequestParameters(options) {
821
- return operationOptionsToRequestParameters$1(options);
822
- }
823
- //#endregion
824
- //#region ../../node_modules/.pnpm/@azure-rest+core-client@2.5.1/node_modules/@azure-rest/core-client/dist/esm/getClient.js
825
- /**
826
- * Function to wrap RequestParameters so that we get the legacy onResponse behavior in core-client-rest
827
- */
828
- function wrapRequestParameters(parameters) {
829
- if (parameters.onResponse) return {
830
- ...parameters,
831
- onResponse(rawResponse, error) {
832
- parameters.onResponse?.(rawResponse, error, error);
833
- }
834
- };
835
- return parameters;
836
- }
837
- function getClient(endpoint, credentialsOrPipelineOptions, clientOptions = {}) {
838
- let credentials;
839
- if (credentialsOrPipelineOptions) if (isCredential(credentialsOrPipelineOptions)) credentials = credentialsOrPipelineOptions;
840
- else clientOptions = credentialsOrPipelineOptions ?? {};
841
- const pipeline = createDefaultPipeline(endpoint, credentials, clientOptions);
842
- const tspClient = getClient$1(endpoint, {
843
- ...clientOptions,
844
- pipeline
845
- });
846
- const client = (path, ...args) => {
847
- return {
848
- get: (requestOptions = {}) => {
849
- return tspClient.path(path, ...args).get(wrapRequestParameters(requestOptions));
850
- },
851
- post: (requestOptions = {}) => {
852
- return tspClient.path(path, ...args).post(wrapRequestParameters(requestOptions));
853
- },
854
- put: (requestOptions = {}) => {
855
- return tspClient.path(path, ...args).put(wrapRequestParameters(requestOptions));
856
- },
857
- patch: (requestOptions = {}) => {
858
- return tspClient.path(path, ...args).patch(wrapRequestParameters(requestOptions));
859
- },
860
- delete: (requestOptions = {}) => {
861
- return tspClient.path(path, ...args).delete(wrapRequestParameters(requestOptions));
862
- },
863
- head: (requestOptions = {}) => {
864
- return tspClient.path(path, ...args).head(wrapRequestParameters(requestOptions));
865
- },
866
- options: (requestOptions = {}) => {
867
- return tspClient.path(path, ...args).options(wrapRequestParameters(requestOptions));
868
- },
869
- trace: (requestOptions = {}) => {
870
- return tspClient.path(path, ...args).trace(wrapRequestParameters(requestOptions));
871
- }
872
- };
873
- };
874
- return {
875
- path: client,
876
- pathUnchecked: client,
877
- pipeline: tspClient.pipeline
878
- };
879
- }
880
- function isCredential(param) {
881
- return isKeyCredential$1(param) || isTokenCredential(param);
882
- }
883
- //#endregion
884
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/constants.js
885
- const SDK_VERSION = "4.11.2";
886
- //#endregion
887
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/api/keyVaultContext.js
888
- /** Creates a new Azure Key Vault Secrets client context. */
889
- function createKeyVault(endpointParam, credential, options = {}) {
890
- const endpointUrl = options.endpoint ?? options.baseUrl ?? String(endpointParam);
891
- const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;
892
- const userAgentInfo = `azsdk-js-keyvault-secrets/${SDK_VERSION}`;
893
- const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}` : `azsdk-js-api ${userAgentInfo}`;
894
- const { apiVersion: _, ...updatedOptions } = {
895
- ...options,
896
- userAgentOptions: { userAgentPrefix },
897
- loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info },
898
- credentials: { scopes: options.credentials?.scopes ?? ["https://vault.azure.net/.default"] }
899
- };
900
- const clientContext = getClient(endpointUrl, credential, updatedOptions);
901
- clientContext.pipeline.removePolicy({ name: "ApiVersionPolicy" });
902
- const apiVersion = options.apiVersion ?? "2025-07-01";
903
- clientContext.pipeline.addPolicy({
904
- name: "ClientApiVersionPolicy",
905
- sendRequest: (req, next) => {
906
- const url = new URL(req.url);
907
- if (!url.searchParams.get("api-version")) req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${apiVersion}`;
908
- return next(req);
909
- }
910
- });
911
- return {
912
- ...clientContext,
913
- apiVersion
914
- };
915
- }
916
- //#endregion
917
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/models/models.js
918
- function secretSetParametersSerializer(item) {
919
- return {
920
- value: item["value"],
921
- tags: item["tags"],
922
- contentType: item["contentType"],
923
- attributes: !item["secretAttributes"] ? item["secretAttributes"] : secretAttributesSerializer(item["secretAttributes"])
924
- };
925
- }
926
- function secretAttributesSerializer(item) {
927
- return {
928
- enabled: item["enabled"],
929
- nbf: !item["notBefore"] ? item["notBefore"] : item["notBefore"].getTime() / 1e3 | 0,
930
- exp: !item["expires"] ? item["expires"] : item["expires"].getTime() / 1e3 | 0
931
- };
932
- }
933
- function secretAttributesDeserializer(item) {
934
- return {
935
- enabled: item["enabled"],
936
- notBefore: !item["nbf"] ? item["nbf"] : /* @__PURE__ */ new Date(item["nbf"] * 1e3),
937
- expires: !item["exp"] ? item["exp"] : /* @__PURE__ */ new Date(item["exp"] * 1e3),
938
- created: !item["created"] ? item["created"] : /* @__PURE__ */ new Date(item["created"] * 1e3),
939
- updated: !item["updated"] ? item["updated"] : /* @__PURE__ */ new Date(item["updated"] * 1e3),
940
- recoverableDays: item["recoverableDays"],
941
- recoveryLevel: item["recoveryLevel"]
942
- };
943
- }
944
- /** Reflects the deletion recovery level currently in effect for secrets in the current vault. If it contains 'Purgeable', the secret can be permanently deleted by a privileged user; otherwise, only the system can purge the secret, at the end of the retention interval. */
945
- var KnownDeletionRecoveryLevel;
946
- (function(KnownDeletionRecoveryLevel) {
947
- /** Denotes a vault state in which deletion is an irreversible operation, without the possibility for recovery. This level corresponds to no protection being available against a Delete operation; the data is irretrievably lost upon accepting a Delete operation at the entity level or higher (vault, resource group, subscription etc.) */
948
- KnownDeletionRecoveryLevel["Purgeable"] = "Purgeable";
949
- /** Denotes a vault state in which deletion is recoverable, and which also permits immediate and permanent deletion (i.e. purge). This level guarantees the recoverability of the deleted entity during the retention interval (90 days), unless a Purge operation is requested, or the subscription is cancelled. System wil permanently delete it after 90 days, if not recovered */
950
- KnownDeletionRecoveryLevel["RecoverablePurgeable"] = "Recoverable+Purgeable";
951
- /** Denotes a vault state in which deletion is recoverable without the possibility for immediate and permanent deletion (i.e. purge). This level guarantees the recoverability of the deleted entity during the retention interval (90 days) and while the subscription is still available. System wil permanently delete it after 90 days, if not recovered */
952
- KnownDeletionRecoveryLevel["Recoverable"] = "Recoverable";
953
- /** Denotes a vault and subscription state in which deletion is recoverable within retention interval (90 days), immediate and permanent deletion (i.e. purge) is not permitted, and in which the subscription itself cannot be permanently canceled. System wil permanently delete it after 90 days, if not recovered */
954
- KnownDeletionRecoveryLevel["RecoverableProtectedSubscription"] = "Recoverable+ProtectedSubscription";
955
- /** Denotes a vault state in which deletion is recoverable, and which also permits immediate and permanent deletion (i.e. purge when 7 <= SoftDeleteRetentionInDays < 90). This level guarantees the recoverability of the deleted entity during the retention interval, unless a Purge operation is requested, or the subscription is cancelled. */
956
- KnownDeletionRecoveryLevel["CustomizedRecoverablePurgeable"] = "CustomizedRecoverable+Purgeable";
957
- /** Denotes a vault state in which deletion is recoverable without the possibility for immediate and permanent deletion (i.e. purge when 7 <= SoftDeleteRetentionInDays < 90).This level guarantees the recoverability of the deleted entity during the retention interval and while the subscription is still available. */
958
- KnownDeletionRecoveryLevel["CustomizedRecoverable"] = "CustomizedRecoverable";
959
- /** Denotes a vault and subscription state in which deletion is recoverable, immediate and permanent deletion (i.e. purge) is not permitted, and in which the subscription itself cannot be permanently canceled when 7 <= SoftDeleteRetentionInDays < 90. This level guarantees the recoverability of the deleted entity during the retention interval, and also reflects the fact that the subscription itself cannot be cancelled. */
960
- KnownDeletionRecoveryLevel["CustomizedRecoverableProtectedSubscription"] = "CustomizedRecoverable+ProtectedSubscription";
961
- })(KnownDeletionRecoveryLevel || (KnownDeletionRecoveryLevel = {}));
962
- function secretBundleDeserializer(item) {
963
- return {
964
- value: item["value"],
965
- id: item["id"],
966
- contentType: item["contentType"],
967
- attributes: !item["attributes"] ? item["attributes"] : secretAttributesDeserializer(item["attributes"]),
968
- tags: item["tags"],
969
- kid: item["kid"],
970
- managed: item["managed"],
971
- previousVersion: item["previousVersion"]
972
- };
973
- }
974
- function keyVaultErrorDeserializer(item) {
975
- return { error: !item["error"] ? item["error"] : _keyVaultErrorErrorDeserializer(item["error"]) };
976
- }
977
- function _keyVaultErrorErrorDeserializer(item) {
978
- return {
979
- code: item["code"],
980
- message: item["message"],
981
- innerError: !item["innererror"] ? item["innererror"] : _keyVaultErrorErrorDeserializer(item["innererror"])
982
- };
983
- }
984
- function deletedSecretBundleDeserializer(item) {
985
- return {
986
- value: item["value"],
987
- id: item["id"],
988
- contentType: item["contentType"],
989
- attributes: !item["attributes"] ? item["attributes"] : secretAttributesDeserializer(item["attributes"]),
990
- tags: item["tags"],
991
- kid: item["kid"],
992
- managed: item["managed"],
993
- previousVersion: item["previousVersion"],
994
- recoveryId: item["recoveryId"],
995
- scheduledPurgeDate: !item["scheduledPurgeDate"] ? item["scheduledPurgeDate"] : /* @__PURE__ */ new Date(item["scheduledPurgeDate"] * 1e3),
996
- deletedDate: !item["deletedDate"] ? item["deletedDate"] : /* @__PURE__ */ new Date(item["deletedDate"] * 1e3)
997
- };
998
- }
999
- function secretUpdateParametersSerializer(item) {
1000
- return {
1001
- contentType: item["contentType"],
1002
- attributes: !item["secretAttributes"] ? item["secretAttributes"] : secretAttributesSerializer(item["secretAttributes"]),
1003
- tags: item["tags"]
1004
- };
1005
- }
1006
- function _secretListResultDeserializer(item) {
1007
- return {
1008
- value: !item["value"] ? item["value"] : secretItemArrayDeserializer(item["value"]),
1009
- nextLink: item["nextLink"]
1010
- };
1011
- }
1012
- function secretItemArrayDeserializer(result) {
1013
- return result.map((item) => {
1014
- return secretItemDeserializer(item);
1015
- });
1016
- }
1017
- function secretItemDeserializer(item) {
1018
- return {
1019
- id: item["id"],
1020
- attributes: !item["attributes"] ? item["attributes"] : secretAttributesDeserializer(item["attributes"]),
1021
- tags: item["tags"],
1022
- contentType: item["contentType"],
1023
- managed: item["managed"]
1024
- };
1025
- }
1026
- function _deletedSecretListResultDeserializer(item) {
1027
- return {
1028
- value: !item["value"] ? item["value"] : deletedSecretItemArrayDeserializer(item["value"]),
1029
- nextLink: item["nextLink"]
1030
- };
1031
- }
1032
- function deletedSecretItemArrayDeserializer(result) {
1033
- return result.map((item) => {
1034
- return deletedSecretItemDeserializer(item);
1035
- });
1036
- }
1037
- function deletedSecretItemDeserializer(item) {
1038
- return {
1039
- id: item["id"],
1040
- attributes: !item["attributes"] ? item["attributes"] : secretAttributesDeserializer(item["attributes"]),
1041
- tags: item["tags"],
1042
- contentType: item["contentType"],
1043
- managed: item["managed"],
1044
- recoveryId: item["recoveryId"],
1045
- scheduledPurgeDate: !item["scheduledPurgeDate"] ? item["scheduledPurgeDate"] : /* @__PURE__ */ new Date(item["scheduledPurgeDate"] * 1e3),
1046
- deletedDate: !item["deletedDate"] ? item["deletedDate"] : /* @__PURE__ */ new Date(item["deletedDate"] * 1e3)
1047
- };
1048
- }
1049
- function backupSecretResultDeserializer(item) {
1050
- return { value: !item["value"] ? item["value"] : typeof item["value"] === "string" ? stringToUint8Array$1(item["value"], "base64url") : item["value"] };
1051
- }
1052
- function secretRestoreParametersSerializer(item) {
1053
- return { value: uint8ArrayToString$1(item["secretBundleBackup"], "base64url") };
1054
- }
1055
- /** Known values of {@link ContentType} that the service accepts. */
1056
- var KnownContentType;
1057
- (function(KnownContentType) {
1058
- /** The PKCS#12 (PFX) certificate format. */
1059
- KnownContentType["PFX"] = "application/x-pkcs12";
1060
- /** The PEM certificate format. */
1061
- KnownContentType["PEM"] = "application/x-pem-file";
1062
- })(KnownContentType || (KnownContentType = {}));
1063
- /** The available API versions. */
1064
- var KnownVersions;
1065
- (function(KnownVersions) {
1066
- /** The 7.5 API version. */
1067
- KnownVersions["V75"] = "7.5";
1068
- /** The 7.6-preview.2 API version. */
1069
- KnownVersions["V76Preview2"] = "7.6-preview.2";
1070
- /** The 7.6 API version. */
1071
- KnownVersions["V76"] = "7.6";
1072
- /** The 2025-07-01 API version. */
1073
- KnownVersions["V20250701"] = "2025-07-01";
1074
- })(KnownVersions || (KnownVersions = {}));
1075
- //#endregion
1076
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/static-helpers/pagingHelpers.js
1077
- /**
1078
- * Helper to paginate results in a generic way and return a PagedAsyncIterableIterator
1079
- */
1080
- function buildPagedAsyncIterator(client, getInitialResponse, processResponseBody, expectedStatuses, options = {}) {
1081
- const itemName = options.itemName ?? "value";
1082
- const nextLinkName = options.nextLinkName ?? "nextLink";
1083
- const pagedResult = {
1084
- getPage: async (pageLink) => {
1085
- const result = pageLink === void 0 ? await getInitialResponse() : await client.pathUnchecked(pageLink).get();
1086
- checkPagingRequest(result, expectedStatuses);
1087
- const results = await processResponseBody(result);
1088
- const nextLink = getNextLink(results, nextLinkName);
1089
- return {
1090
- page: getElements(results, itemName),
1091
- nextPageLink: nextLink
1092
- };
1093
- },
1094
- byPage: (settings) => {
1095
- const { continuationToken } = settings ?? {};
1096
- return getPageAsyncIterator(pagedResult, { pageLink: continuationToken });
1097
- }
1098
- };
1099
- return getPagedAsyncIterator(pagedResult);
1100
- }
1101
- /**
1102
- * returns an async iterator that iterates over results. It also has a `byPage`
1103
- * method that returns pages of items at once.
1104
- *
1105
- * @param pagedResult - an object that specifies how to get pages.
1106
- * @returns a paged async iterator that iterates over results.
1107
- */
1108
- function getPagedAsyncIterator(pagedResult) {
1109
- const iter = getItemAsyncIterator(pagedResult);
1110
- return {
1111
- next() {
1112
- return iter.next();
1113
- },
1114
- [Symbol.asyncIterator]() {
1115
- return this;
1116
- },
1117
- byPage: pagedResult?.byPage ?? ((settings) => {
1118
- const { continuationToken } = settings ?? {};
1119
- return getPageAsyncIterator(pagedResult, { pageLink: continuationToken });
1120
- })
1121
- };
1122
- }
1123
- async function* getItemAsyncIterator(pagedResult) {
1124
- const pages = getPageAsyncIterator(pagedResult);
1125
- for await (const page of pages) yield* page;
1126
- }
1127
- async function* getPageAsyncIterator(pagedResult, options = {}) {
1128
- const { pageLink } = options;
1129
- let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink);
1130
- if (!response) return;
1131
- let result = response.page;
1132
- result.continuationToken = response.nextPageLink;
1133
- yield result;
1134
- while (response.nextPageLink) {
1135
- response = await pagedResult.getPage(response.nextPageLink);
1136
- if (!response) return;
1137
- result = response.page;
1138
- result.continuationToken = response.nextPageLink;
1139
- yield result;
1140
- }
1141
- }
1142
- /**
1143
- * Gets for the value of nextLink in the body
1144
- */
1145
- function getNextLink(body, nextLinkName) {
1146
- if (!nextLinkName) return;
1147
- const nextLink = body[nextLinkName];
1148
- if (typeof nextLink !== "string" && typeof nextLink !== "undefined" && nextLink !== null) throw new RestError$1(`Body Property ${nextLinkName} should be a string or undefined or null but got ${typeof nextLink}`);
1149
- if (nextLink === null) return;
1150
- return nextLink;
1151
- }
1152
- /**
1153
- * Gets the elements of the current request in the body.
1154
- */
1155
- function getElements(body, itemName) {
1156
- const value = body[itemName];
1157
- if (!Array.isArray(value)) throw new RestError$1(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
1158
- return value ?? [];
1159
- }
1160
- /**
1161
- * Checks if a request failed
1162
- */
1163
- function checkPagingRequest(response, expectedStatuses) {
1164
- if (!expectedStatuses.includes(response.status)) throw createRestError(`Pagination failed with unexpected statusCode ${response.status}`, response);
1165
- }
1166
- //#endregion
1167
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/static-helpers/urlTemplate.js
1168
- function encodeComponent(val, reserved, op) {
1169
- return (reserved ?? op === "+") || op === "#" ? encodeReservedComponent(val) : encodeRFC3986URIComponent(val);
1170
- }
1171
- function encodeReservedComponent(str) {
1172
- return str.split(/(%[0-9A-Fa-f]{2})/g).map((part) => !/%[0-9A-Fa-f]/.test(part) ? encodeURI(part) : part).join("");
1173
- }
1174
- function encodeRFC3986URIComponent(str) {
1175
- return encodeURIComponent(str).replace(/[!'()*]/g, (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`);
1176
- }
1177
- function isDefined(val) {
1178
- return val !== void 0 && val !== null;
1179
- }
1180
- function getNamedAndIfEmpty(op) {
1181
- return [!!op && [
1182
- ";",
1183
- "?",
1184
- "&"
1185
- ].includes(op), !!op && ["?", "&"].includes(op) ? "=" : ""];
1186
- }
1187
- function getFirstOrSep(op, isFirst = false) {
1188
- if (isFirst) return !op || op === "+" ? "" : op;
1189
- else if (!op || op === "+" || op === "#") return ",";
1190
- else if (op === "?") return "&";
1191
- else return op;
1192
- }
1193
- function getExpandedValue(option) {
1194
- let isFirst = option.isFirst;
1195
- const { op, varName, varValue: value, reserved } = option;
1196
- const vals = [];
1197
- const [named, ifEmpty] = getNamedAndIfEmpty(op);
1198
- if (Array.isArray(value)) for (const val of value.filter(isDefined)) {
1199
- vals.push(`${getFirstOrSep(op, isFirst)}`);
1200
- if (named && varName) {
1201
- vals.push(`${encodeURIComponent(varName)}`);
1202
- val === "" ? vals.push(ifEmpty) : vals.push("=");
1203
- }
1204
- vals.push(encodeComponent(val, reserved, op));
1205
- isFirst = false;
1206
- }
1207
- else if (typeof value === "object") for (const key of Object.keys(value)) {
1208
- const val = value[key];
1209
- if (!isDefined(val)) continue;
1210
- vals.push(`${getFirstOrSep(op, isFirst)}`);
1211
- if (key) {
1212
- vals.push(`${encodeURIComponent(key)}`);
1213
- named && val === "" ? vals.push(ifEmpty) : vals.push("=");
1214
- }
1215
- vals.push(encodeComponent(val, reserved, op));
1216
- isFirst = false;
1217
- }
1218
- return vals.join("");
1219
- }
1220
- function getNonExpandedValue(option) {
1221
- const { op, varName, varValue: value, isFirst, reserved } = option;
1222
- const vals = [];
1223
- const first = getFirstOrSep(op, isFirst);
1224
- const [named, ifEmpty] = getNamedAndIfEmpty(op);
1225
- if (named && varName) {
1226
- vals.push(encodeComponent(varName, reserved, op));
1227
- if (value === "") {
1228
- if (!ifEmpty) vals.push(ifEmpty);
1229
- return !vals.join("") ? void 0 : `${first}${vals.join("")}`;
1230
- }
1231
- vals.push("=");
1232
- }
1233
- const items = [];
1234
- if (Array.isArray(value)) for (const val of value.filter(isDefined)) items.push(encodeComponent(val, reserved, op));
1235
- else if (typeof value === "object") for (const key of Object.keys(value)) {
1236
- if (!isDefined(value[key])) continue;
1237
- items.push(encodeRFC3986URIComponent(key));
1238
- items.push(encodeComponent(value[key], reserved, op));
1239
- }
1240
- vals.push(items.join(","));
1241
- return !vals.join(",") ? void 0 : `${first}${vals.join("")}`;
1242
- }
1243
- function getVarValue(option) {
1244
- const { op, varName, modifier, isFirst, reserved, varValue: value } = option;
1245
- if (!isDefined(value)) return;
1246
- else if ([
1247
- "string",
1248
- "number",
1249
- "boolean"
1250
- ].includes(typeof value)) {
1251
- let val = value.toString();
1252
- const [named, ifEmpty] = getNamedAndIfEmpty(op);
1253
- const vals = [getFirstOrSep(op, isFirst)];
1254
- if (named && varName) {
1255
- vals.push(varName);
1256
- val === "" ? vals.push(ifEmpty) : vals.push("=");
1257
- }
1258
- if (modifier && modifier !== "*") val = val.substring(0, parseInt(modifier, 10));
1259
- vals.push(encodeComponent(val, reserved, op));
1260
- return vals.join("");
1261
- } else if (modifier === "*") return getExpandedValue(option);
1262
- else return getNonExpandedValue(option);
1263
- }
1264
- function expandUrlTemplate(template, context, option) {
1265
- return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, (_, expr, text) => {
1266
- if (!expr) return encodeReservedComponent(text);
1267
- let op;
1268
- if ([
1269
- "+",
1270
- "#",
1271
- ".",
1272
- "/",
1273
- ";",
1274
- "?",
1275
- "&"
1276
- ].includes(expr[0])) op = expr[0], expr = expr.slice(1);
1277
- const varList = expr.split(/,/g);
1278
- const result = [];
1279
- for (const varSpec of varList) {
1280
- const varMatch = /([^:\*]*)(?::(\d+)|(\*))?/.exec(varSpec);
1281
- if (!varMatch || !varMatch[1]) continue;
1282
- const varValue = getVarValue({
1283
- isFirst: result.length === 0,
1284
- op,
1285
- varValue: context[varMatch[1]],
1286
- varName: varMatch[1],
1287
- modifier: varMatch[2] || varMatch[3],
1288
- reserved: option?.allowReserved
1289
- });
1290
- if (varValue) result.push(varValue);
1291
- }
1292
- return result.join("");
1293
- });
1294
- }
1295
- //#endregion
1296
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/api/operations.js
1297
- function _restoreSecretSend(context, parameters, options = { requestOptions: {} }) {
1298
- const path = expandUrlTemplate("/secrets/restore{?api%2Dversion}", { "api%2Dversion": context.apiVersion }, { allowReserved: options?.requestOptions?.skipUrlEncoding });
1299
- return context.path(path).post({
1300
- ...operationOptionsToRequestParameters(options),
1301
- contentType: "application/json",
1302
- headers: {
1303
- accept: "application/json",
1304
- ...options.requestOptions?.headers
1305
- },
1306
- body: secretRestoreParametersSerializer(parameters)
1307
- });
1308
- }
1309
- async function _restoreSecretDeserialize(result) {
1310
- if (!["200"].includes(result.status)) {
1311
- const error = createRestError(result);
1312
- error.details = keyVaultErrorDeserializer(result.body);
1313
- throw error;
1314
- }
1315
- return secretBundleDeserializer(result.body);
1316
- }
1317
- /** Restores a backed up secret, and all its versions, to a vault. This operation requires the secrets/restore permission. */
1318
- async function restoreSecret(context, parameters, options = { requestOptions: {} }) {
1319
- return _restoreSecretDeserialize(await _restoreSecretSend(context, parameters, options));
1320
- }
1321
- function _backupSecretSend(context, secretName, options = { requestOptions: {} }) {
1322
- const path = expandUrlTemplate("/secrets/{secret-name}/backup{?api%2Dversion}", {
1323
- "secret-name": secretName,
1324
- "api%2Dversion": context.apiVersion
1325
- }, { allowReserved: options?.requestOptions?.skipUrlEncoding });
1326
- return context.path(path).post({
1327
- ...operationOptionsToRequestParameters(options),
1328
- headers: {
1329
- accept: "application/json",
1330
- ...options.requestOptions?.headers
1331
- }
1332
- });
1333
- }
1334
- async function _backupSecretDeserialize(result) {
1335
- if (!["200"].includes(result.status)) {
1336
- const error = createRestError(result);
1337
- error.details = keyVaultErrorDeserializer(result.body);
1338
- throw error;
1339
- }
1340
- return backupSecretResultDeserializer(result.body);
1341
- }
1342
- /** Requests that a backup of the specified secret be downloaded to the client. All versions of the secret will be downloaded. This operation requires the secrets/backup permission. */
1343
- async function backupSecret(context, secretName, options = { requestOptions: {} }) {
1344
- return _backupSecretDeserialize(await _backupSecretSend(context, secretName, options));
1345
- }
1346
- function _recoverDeletedSecretSend(context, secretName, options = { requestOptions: {} }) {
1347
- const path = expandUrlTemplate("/deletedsecrets/{secret-name}/recover{?api%2Dversion}", {
1348
- "secret-name": secretName,
1349
- "api%2Dversion": context.apiVersion
1350
- }, { allowReserved: options?.requestOptions?.skipUrlEncoding });
1351
- return context.path(path).post({
1352
- ...operationOptionsToRequestParameters(options),
1353
- headers: {
1354
- accept: "application/json",
1355
- ...options.requestOptions?.headers
1356
- }
1357
- });
1358
- }
1359
- async function _recoverDeletedSecretDeserialize(result) {
1360
- if (!["200"].includes(result.status)) {
1361
- const error = createRestError(result);
1362
- error.details = keyVaultErrorDeserializer(result.body);
1363
- throw error;
1364
- }
1365
- return secretBundleDeserializer(result.body);
1366
- }
1367
- /** Recovers the deleted secret in the specified vault. This operation can only be performed on a soft-delete enabled vault. This operation requires the secrets/recover permission. */
1368
- async function recoverDeletedSecret(context, secretName, options = { requestOptions: {} }) {
1369
- return _recoverDeletedSecretDeserialize(await _recoverDeletedSecretSend(context, secretName, options));
1370
- }
1371
- function _purgeDeletedSecretSend(context, secretName, options = { requestOptions: {} }) {
1372
- const path = expandUrlTemplate("/deletedsecrets/{secret-name}{?api%2Dversion}", {
1373
- "secret-name": secretName,
1374
- "api%2Dversion": context.apiVersion
1375
- }, { allowReserved: options?.requestOptions?.skipUrlEncoding });
1376
- return context.path(path).delete({
1377
- ...operationOptionsToRequestParameters(options),
1378
- headers: {
1379
- accept: "application/json",
1380
- ...options.requestOptions?.headers
1381
- }
1382
- });
1383
- }
1384
- async function _purgeDeletedSecretDeserialize(result) {
1385
- if (!["204"].includes(result.status)) {
1386
- const error = createRestError(result);
1387
- error.details = keyVaultErrorDeserializer(result.body);
1388
- throw error;
1389
- }
1390
- }
1391
- /** The purge deleted secret operation removes the secret permanently, without the possibility of recovery. This operation can only be enabled on a soft-delete enabled vault. This operation requires the secrets/purge permission. */
1392
- async function purgeDeletedSecret(context, secretName, options = { requestOptions: {} }) {
1393
- return _purgeDeletedSecretDeserialize(await _purgeDeletedSecretSend(context, secretName, options));
1394
- }
1395
- function _getDeletedSecretSend(context, secretName, options = { requestOptions: {} }) {
1396
- const path = expandUrlTemplate("/deletedsecrets/{secret-name}{?api%2Dversion}", {
1397
- "secret-name": secretName,
1398
- "api%2Dversion": context.apiVersion
1399
- }, { allowReserved: options?.requestOptions?.skipUrlEncoding });
1400
- return context.path(path).get({
1401
- ...operationOptionsToRequestParameters(options),
1402
- headers: {
1403
- accept: "application/json",
1404
- ...options.requestOptions?.headers
1405
- }
1406
- });
1407
- }
1408
- async function _getDeletedSecretDeserialize(result) {
1409
- if (!["200"].includes(result.status)) {
1410
- const error = createRestError(result);
1411
- error.details = keyVaultErrorDeserializer(result.body);
1412
- throw error;
1413
- }
1414
- return deletedSecretBundleDeserializer(result.body);
1415
- }
1416
- /** The Get Deleted Secret operation returns the specified deleted secret along with its attributes. This operation requires the secrets/get permission. */
1417
- async function getDeletedSecret(context, secretName, options = { requestOptions: {} }) {
1418
- return _getDeletedSecretDeserialize(await _getDeletedSecretSend(context, secretName, options));
1419
- }
1420
- function _getDeletedSecretsSend(context, options = { requestOptions: {} }) {
1421
- const path = expandUrlTemplate("/deletedsecrets{?api%2Dversion,maxresults}", {
1422
- "api%2Dversion": context.apiVersion,
1423
- maxresults: options?.maxresults
1424
- }, { allowReserved: options?.requestOptions?.skipUrlEncoding });
1425
- return context.path(path).get({
1426
- ...operationOptionsToRequestParameters(options),
1427
- headers: {
1428
- accept: "application/json",
1429
- ...options.requestOptions?.headers
1430
- }
1431
- });
1432
- }
1433
- async function _getDeletedSecretsDeserialize(result) {
1434
- if (!["200"].includes(result.status)) {
1435
- const error = createRestError(result);
1436
- error.details = keyVaultErrorDeserializer(result.body);
1437
- throw error;
1438
- }
1439
- return _deletedSecretListResultDeserializer(result.body);
1440
- }
1441
- /** The Get Deleted Secrets operation returns the secrets that have been deleted for a vault enabled for soft-delete. This operation requires the secrets/list permission. */
1442
- function getDeletedSecrets(context, options = { requestOptions: {} }) {
1443
- return buildPagedAsyncIterator(context, () => _getDeletedSecretsSend(context, options), _getDeletedSecretsDeserialize, ["200"], {
1444
- itemName: "value",
1445
- nextLinkName: "nextLink"
1446
- });
1447
- }
1448
- function _getSecretVersionsSend(context, secretName, options = { requestOptions: {} }) {
1449
- const path = expandUrlTemplate("/secrets/{secret-name}/versions{?api%2Dversion,maxresults}", {
1450
- "secret-name": secretName,
1451
- "api%2Dversion": context.apiVersion,
1452
- maxresults: options?.maxresults
1453
- }, { allowReserved: options?.requestOptions?.skipUrlEncoding });
1454
- return context.path(path).get({
1455
- ...operationOptionsToRequestParameters(options),
1456
- headers: {
1457
- accept: "application/json",
1458
- ...options.requestOptions?.headers
1459
- }
1460
- });
1461
- }
1462
- async function _getSecretVersionsDeserialize(result) {
1463
- if (!["200"].includes(result.status)) {
1464
- const error = createRestError(result);
1465
- error.details = keyVaultErrorDeserializer(result.body);
1466
- throw error;
1467
- }
1468
- return _secretListResultDeserializer(result.body);
1469
- }
1470
- /** The full secret identifier and attributes are provided in the response. No values are returned for the secrets. This operations requires the secrets/list permission. */
1471
- function getSecretVersions(context, secretName, options = { requestOptions: {} }) {
1472
- return buildPagedAsyncIterator(context, () => _getSecretVersionsSend(context, secretName, options), _getSecretVersionsDeserialize, ["200"], {
1473
- itemName: "value",
1474
- nextLinkName: "nextLink"
1475
- });
1476
- }
1477
- function _getSecretsSend(context, options = { requestOptions: {} }) {
1478
- const path = expandUrlTemplate("/secrets{?api%2Dversion,maxresults}", {
1479
- "api%2Dversion": context.apiVersion,
1480
- maxresults: options?.maxresults
1481
- }, { allowReserved: options?.requestOptions?.skipUrlEncoding });
1482
- return context.path(path).get({
1483
- ...operationOptionsToRequestParameters(options),
1484
- headers: {
1485
- accept: "application/json",
1486
- ...options.requestOptions?.headers
1487
- }
1488
- });
1489
- }
1490
- async function _getSecretsDeserialize(result) {
1491
- if (!["200"].includes(result.status)) {
1492
- const error = createRestError(result);
1493
- error.details = keyVaultErrorDeserializer(result.body);
1494
- throw error;
1495
- }
1496
- return _secretListResultDeserializer(result.body);
1497
- }
1498
- /** The Get Secrets operation is applicable to the entire vault. However, only the base secret identifier and its attributes are provided in the response. Individual secret versions are not listed in the response. This operation requires the secrets/list permission. */
1499
- function getSecrets(context, options = { requestOptions: {} }) {
1500
- return buildPagedAsyncIterator(context, () => _getSecretsSend(context, options), _getSecretsDeserialize, ["200"], {
1501
- itemName: "value",
1502
- nextLinkName: "nextLink"
1503
- });
1504
- }
1505
- function _getSecretSend(context, secretName, secretVersion, options = { requestOptions: {} }) {
1506
- const path = expandUrlTemplate("/secrets/{secret-name}/{secret-version}{?api%2Dversion,outContentType}", {
1507
- "secret-name": secretName,
1508
- "secret-version": secretVersion,
1509
- "api%2Dversion": context.apiVersion,
1510
- outContentType: options?.outContentType
1511
- }, { allowReserved: options?.requestOptions?.skipUrlEncoding });
1512
- return context.path(path).get({
1513
- ...operationOptionsToRequestParameters(options),
1514
- headers: {
1515
- accept: "application/json",
1516
- ...options.requestOptions?.headers
1517
- }
1518
- });
1519
- }
1520
- async function _getSecretDeserialize(result) {
1521
- if (!["200"].includes(result.status)) {
1522
- const error = createRestError(result);
1523
- error.details = keyVaultErrorDeserializer(result.body);
1524
- throw error;
1525
- }
1526
- return secretBundleDeserializer(result.body);
1527
- }
1528
- /** The GET operation is applicable to any secret stored in Azure Key Vault. This operation requires the secrets/get permission. */
1529
- async function getSecret(context, secretName, secretVersion, options = { requestOptions: {} }) {
1530
- return _getSecretDeserialize(await _getSecretSend(context, secretName, secretVersion, options));
1531
- }
1532
- function _updateSecretSend(context, secretName, secretVersion, parameters, options = { requestOptions: {} }) {
1533
- const path = expandUrlTemplate("/secrets/{secret-name}/{secret-version}{?api%2Dversion}", {
1534
- "secret-name": secretName,
1535
- "secret-version": secretVersion,
1536
- "api%2Dversion": context.apiVersion
1537
- }, { allowReserved: options?.requestOptions?.skipUrlEncoding });
1538
- return context.path(path).patch({
1539
- ...operationOptionsToRequestParameters(options),
1540
- contentType: "application/json",
1541
- headers: {
1542
- accept: "application/json",
1543
- ...options.requestOptions?.headers
1544
- },
1545
- body: secretUpdateParametersSerializer(parameters)
1546
- });
1547
- }
1548
- async function _updateSecretDeserialize(result) {
1549
- if (!["200"].includes(result.status)) {
1550
- const error = createRestError(result);
1551
- error.details = keyVaultErrorDeserializer(result.body);
1552
- throw error;
1553
- }
1554
- return secretBundleDeserializer(result.body);
1555
- }
1556
- /** The UPDATE operation changes specified attributes of an existing stored secret. Attributes that are not specified in the request are left unchanged. The value of a secret itself cannot be changed. This operation requires the secrets/set permission. */
1557
- async function updateSecret(context, secretName, secretVersion, parameters, options = { requestOptions: {} }) {
1558
- return _updateSecretDeserialize(await _updateSecretSend(context, secretName, secretVersion, parameters, options));
1559
- }
1560
- function _deleteSecretSend(context, secretName, options = { requestOptions: {} }) {
1561
- const path = expandUrlTemplate("/secrets/{secret-name}{?api%2Dversion}", {
1562
- "secret-name": secretName,
1563
- "api%2Dversion": context.apiVersion
1564
- }, { allowReserved: options?.requestOptions?.skipUrlEncoding });
1565
- return context.path(path).delete({
1566
- ...operationOptionsToRequestParameters(options),
1567
- headers: {
1568
- accept: "application/json",
1569
- ...options.requestOptions?.headers
1570
- }
1571
- });
1572
- }
1573
- async function _deleteSecretDeserialize(result) {
1574
- if (!["200"].includes(result.status)) {
1575
- const error = createRestError(result);
1576
- error.details = keyVaultErrorDeserializer(result.body);
1577
- throw error;
1578
- }
1579
- return deletedSecretBundleDeserializer(result.body);
1580
- }
1581
- /** The DELETE operation applies to any secret stored in Azure Key Vault. DELETE cannot be applied to an individual version of a secret. This operation requires the secrets/delete permission. */
1582
- async function deleteSecret(context, secretName, options = { requestOptions: {} }) {
1583
- return _deleteSecretDeserialize(await _deleteSecretSend(context, secretName, options));
1584
- }
1585
- function _setSecretSend(context, secretName, parameters, options = { requestOptions: {} }) {
1586
- const path = expandUrlTemplate("/secrets/{secret-name}{?api%2Dversion}", {
1587
- "secret-name": secretName,
1588
- "api%2Dversion": context.apiVersion
1589
- }, { allowReserved: options?.requestOptions?.skipUrlEncoding });
1590
- return context.path(path).put({
1591
- ...operationOptionsToRequestParameters(options),
1592
- contentType: "application/json",
1593
- headers: {
1594
- accept: "application/json",
1595
- ...options.requestOptions?.headers
1596
- },
1597
- body: secretSetParametersSerializer(parameters)
1598
- });
1599
- }
1600
- async function _setSecretDeserialize(result) {
1601
- if (!["200"].includes(result.status)) {
1602
- const error = createRestError(result);
1603
- error.details = keyVaultErrorDeserializer(result.body);
1604
- throw error;
1605
- }
1606
- return secretBundleDeserializer(result.body);
1607
- }
1608
- /** The SET operation adds a secret to the Azure Key Vault. If the named secret already exists, Azure Key Vault creates a new version of that secret. This operation requires the secrets/set permission. */
1609
- async function setSecret(context, secretName, parameters, options = { requestOptions: {} }) {
1610
- return _setSecretDeserialize(await _setSecretSend(context, secretName, parameters, options));
1611
- }
1612
- //#endregion
1613
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/keyVaultClient.js
1614
- var KeyVaultClient = class {
1615
- _client;
1616
- /** The pipeline used by this client to make requests */
1617
- pipeline;
1618
- /** The key vault client performs cryptographic key operations and vault operations against the Key Vault service. */
1619
- constructor(endpointParam, credential, options = {}) {
1620
- const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix;
1621
- const userAgentPrefix = prefixFromOptions ? `${prefixFromOptions} azsdk-js-client` : `azsdk-js-client`;
1622
- this._client = createKeyVault(endpointParam, credential, {
1623
- ...options,
1624
- userAgentOptions: { userAgentPrefix }
1625
- });
1626
- this.pipeline = this._client.pipeline;
1627
- }
1628
- /** Restores a backed up secret, and all its versions, to a vault. This operation requires the secrets/restore permission. */
1629
- restoreSecret(parameters, options = { requestOptions: {} }) {
1630
- return restoreSecret(this._client, parameters, options);
1631
- }
1632
- /** Requests that a backup of the specified secret be downloaded to the client. All versions of the secret will be downloaded. This operation requires the secrets/backup permission. */
1633
- backupSecret(secretName, options = { requestOptions: {} }) {
1634
- return backupSecret(this._client, secretName, options);
1635
- }
1636
- /** Recovers the deleted secret in the specified vault. This operation can only be performed on a soft-delete enabled vault. This operation requires the secrets/recover permission. */
1637
- recoverDeletedSecret(secretName, options = { requestOptions: {} }) {
1638
- return recoverDeletedSecret(this._client, secretName, options);
1639
- }
1640
- /** The purge deleted secret operation removes the secret permanently, without the possibility of recovery. This operation can only be enabled on a soft-delete enabled vault. This operation requires the secrets/purge permission. */
1641
- purgeDeletedSecret(secretName, options = { requestOptions: {} }) {
1642
- return purgeDeletedSecret(this._client, secretName, options);
1643
- }
1644
- /** The Get Deleted Secret operation returns the specified deleted secret along with its attributes. This operation requires the secrets/get permission. */
1645
- getDeletedSecret(secretName, options = { requestOptions: {} }) {
1646
- return getDeletedSecret(this._client, secretName, options);
1647
- }
1648
- /** The Get Deleted Secrets operation returns the secrets that have been deleted for a vault enabled for soft-delete. This operation requires the secrets/list permission. */
1649
- getDeletedSecrets(options = { requestOptions: {} }) {
1650
- return getDeletedSecrets(this._client, options);
1651
- }
1652
- /** The full secret identifier and attributes are provided in the response. No values are returned for the secrets. This operations requires the secrets/list permission. */
1653
- getSecretVersions(secretName, options = { requestOptions: {} }) {
1654
- return getSecretVersions(this._client, secretName, options);
1655
- }
1656
- /** The Get Secrets operation is applicable to the entire vault. However, only the base secret identifier and its attributes are provided in the response. Individual secret versions are not listed in the response. This operation requires the secrets/list permission. */
1657
- getSecrets(options = { requestOptions: {} }) {
1658
- return getSecrets(this._client, options);
1659
- }
1660
- /** The GET operation is applicable to any secret stored in Azure Key Vault. This operation requires the secrets/get permission. */
1661
- getSecret(secretName, secretVersion, options = { requestOptions: {} }) {
1662
- return getSecret(this._client, secretName, secretVersion, options);
1663
- }
1664
- /** The UPDATE operation changes specified attributes of an existing stored secret. Attributes that are not specified in the request are left unchanged. The value of a secret itself cannot be changed. This operation requires the secrets/set permission. */
1665
- updateSecret(secretName, secretVersion, parameters, options = { requestOptions: {} }) {
1666
- return updateSecret(this._client, secretName, secretVersion, parameters, options);
1667
- }
1668
- /** The DELETE operation applies to any secret stored in Azure Key Vault. DELETE cannot be applied to an individual version of a secret. This operation requires the secrets/delete permission. */
1669
- deleteSecret(secretName, options = { requestOptions: {} }) {
1670
- return deleteSecret(this._client, secretName, options);
1671
- }
1672
- /** The SET operation adds a secret to the Azure Key Vault. If the named secret already exists, Azure Key Vault creates a new version of that secret. This operation requires the secrets/set permission. */
1673
- setSecret(secretName, parameters, options = { requestOptions: {} }) {
1674
- return setSecret(this._client, secretName, parameters, options);
1675
- }
1676
- };
1677
- //#endregion
1678
- //#region ../../node_modules/.pnpm/@azure+keyvault-common@2.1.0/node_modules/@azure/keyvault-common/dist/esm/parseWWWAuthenticate.js
1679
- const validWWWAuthenticateProperties = [
1680
- "authorization",
1681
- "authorization_url",
1682
- "resource",
1683
- "scope",
1684
- "tenantId",
1685
- "claims",
1686
- "error"
1687
- ];
1688
- /**
1689
- * Parses an WWW-Authenticate response header.
1690
- * This transforms a string value like:
1691
- * `Bearer authorization="https://some.url/tenantId", resource="https://some.url"`
1692
- * into an object like:
1693
- * `{ authorization: "https://some.url/tenantId", resource: "https://some.url" }`
1694
- * @param headerValue - String value in the WWW-Authenticate header
1695
- */
1696
- function parseWWWAuthenticateHeader(headerValue) {
1697
- const parsed = headerValue.split(/,? +/).reduce((kvPairs, p) => {
1698
- if (p.match(/\w="/)) {
1699
- const [key, ...value] = p.split("=");
1700
- if (validWWWAuthenticateProperties.includes(key)) return {
1701
- ...kvPairs,
1702
- [key]: value.join("=").slice(1, -1)
1703
- };
1704
- }
1705
- return kvPairs;
1706
- }, {});
1707
- if (parsed.authorization) try {
1708
- const tenantId = new URL(parsed.authorization).pathname.substring(1);
1709
- if (tenantId) parsed.tenantId = tenantId;
1710
- } catch (_) {
1711
- throw new Error(`The challenge authorization URI '${parsed.authorization}' is invalid.`);
1712
- }
1713
- return parsed;
1714
- }
1715
- //#endregion
1716
- //#region ../../node_modules/.pnpm/@azure+keyvault-common@2.1.0/node_modules/@azure/keyvault-common/dist/esm/tokenCycler.js
1717
- const DEFAULT_CYCLER_OPTIONS = {
1718
- forcedRefreshWindowInMs: 1e3,
1719
- retryIntervalInMs: 3e3,
1720
- refreshWindowInMs: 1e3 * 60 * 2
1721
- };
1722
- /**
1723
- * Converts an an unreliable access token getter (which may resolve with null)
1724
- * into an AccessTokenGetter by retrying the unreliable getter in a regular
1725
- * interval.
1726
- *
1727
- * @param getAccessToken - A function that produces a promise of an access token that may fail by returning null.
1728
- * @param retryIntervalInMs - The time (in milliseconds) to wait between retry attempts.
1729
- * @param refreshTimeout - The timestamp after which the refresh attempt will fail, throwing an exception.
1730
- * @returns - A promise that, if it resolves, will resolve with an access token.
1731
- */
1732
- async function beginRefresh(getAccessToken, retryIntervalInMs, refreshTimeout) {
1733
- async function tryGetAccessToken() {
1734
- if (Date.now() < refreshTimeout) try {
1735
- return await getAccessToken();
1736
- } catch {
1737
- return null;
1738
- }
1739
- else {
1740
- const finalToken = await getAccessToken();
1741
- if (finalToken === null) throw new Error("Failed to refresh access token.");
1742
- return finalToken;
1743
- }
1744
- }
1745
- let token = await tryGetAccessToken();
1746
- while (token === null) {
1747
- await delay(retryIntervalInMs);
1748
- token = await tryGetAccessToken();
1749
- }
1750
- return token;
1751
- }
1752
- /**
1753
- * Creates a token cycler from a credential, scopes, and optional settings.
1754
- *
1755
- * A token cycler represents a way to reliably retrieve a valid access token
1756
- * from a TokenCredential. It will handle initializing the token, refreshing it
1757
- * when it nears expiration, and synchronizes refresh attempts to avoid
1758
- * concurrency hazards.
1759
- *
1760
- * @param credential - the underlying TokenCredential that provides the access
1761
- * token
1762
- * @param tokenCyclerOptions - optionally override default settings for the cycler
1763
- *
1764
- * @returns - a function that reliably produces a valid access token
1765
- */
1766
- function createTokenCycler(credential, tokenCyclerOptions) {
1767
- let refreshWorker = null;
1768
- let token = null;
1769
- let tenantId;
1770
- const options = {
1771
- ...DEFAULT_CYCLER_OPTIONS,
1772
- ...tokenCyclerOptions
1773
- };
1774
- /**
1775
- * This little holder defines several predicates that we use to construct
1776
- * the rules of refreshing the token.
1777
- */
1778
- const cycler = {
1779
- /**
1780
- * Produces true if a refresh job is currently in progress.
1781
- */
1782
- get isRefreshing() {
1783
- return refreshWorker !== null;
1784
- },
1785
- /**
1786
- * Produces true if the cycler SHOULD refresh (we are within the refresh
1787
- * window and not already refreshing)
1788
- */
1789
- get shouldRefresh() {
1790
- if (cycler.isRefreshing) return false;
1791
- if (token?.refreshAfterTimestamp && token.refreshAfterTimestamp < Date.now()) return true;
1792
- return (token?.expiresOnTimestamp ?? 0) - options.refreshWindowInMs < Date.now();
1793
- },
1794
- /**
1795
- * Produces true if the cycler MUST refresh (null or nearly-expired
1796
- * token).
1797
- */
1798
- get mustRefresh() {
1799
- return token === null || token.expiresOnTimestamp - options.forcedRefreshWindowInMs < Date.now();
1800
- }
1801
- };
1802
- /**
1803
- * Starts a refresh job or returns the existing job if one is already
1804
- * running.
1805
- */
1806
- function refresh(scopes, getTokenOptions) {
1807
- if (!cycler.isRefreshing) {
1808
- const tryGetAccessToken = () => credential.getToken(scopes, getTokenOptions);
1809
- refreshWorker = beginRefresh(tryGetAccessToken, options.retryIntervalInMs, token?.expiresOnTimestamp ?? Date.now()).then((_token) => {
1810
- refreshWorker = null;
1811
- token = _token;
1812
- tenantId = getTokenOptions.tenantId;
1813
- return token;
1814
- }).catch((reason) => {
1815
- refreshWorker = null;
1816
- token = null;
1817
- tenantId = void 0;
1818
- throw reason;
1819
- });
1820
- }
1821
- return refreshWorker;
1822
- }
1823
- return async (scopes, tokenOptions) => {
1824
- const hasClaimChallenge = Boolean(tokenOptions.claims);
1825
- const tenantIdChanged = tenantId !== tokenOptions.tenantId;
1826
- if (hasClaimChallenge) token = null;
1827
- if (tenantIdChanged || hasClaimChallenge || cycler.mustRefresh) return refresh(scopes, tokenOptions);
1828
- if (cycler.shouldRefresh) refresh(scopes, tokenOptions);
1829
- return token;
1830
- };
1831
- }
1832
- //#endregion
1833
- //#region ../../node_modules/.pnpm/@azure+keyvault-common@2.1.0/node_modules/@azure/keyvault-common/dist/esm/logger.js
1834
- const logger$1 = createClientLogger("keyvault-common");
1835
- //#endregion
1836
- //#region ../../node_modules/.pnpm/@azure+keyvault-common@2.1.0/node_modules/@azure/keyvault-common/dist/esm/keyVaultAuthenticationPolicy.js
1837
- function verifyChallengeResource(scope, request) {
1838
- let scopeAsUrl;
1839
- try {
1840
- scopeAsUrl = new URL(scope);
1841
- } catch (e) {
1842
- throw new Error(`The challenge contains invalid scope '${scope}'`);
1843
- }
1844
- if (!new URL(request.url).hostname.endsWith(`.${scopeAsUrl.hostname}`)) throw new Error(`The challenge resource '${scopeAsUrl.hostname}' does not match the requested domain. Set disableChallengeResourceVerification to true in your client options to disable. See https://aka.ms/azsdk/blog/vault-uri for more information.`);
1845
- }
1846
- /**
1847
- * Name of the Key Vault authentication policy.
1848
- */
1849
- const keyVaultAuthenticationPolicyName = "keyVaultAuthenticationPolicy";
1850
- /**
1851
- * A custom implementation of the bearer-token authentication policy that handles Key Vault and CAE challenges.
1852
- *
1853
- * Key Vault supports other authentication schemes, but we ensure challenge authentication
1854
- * is used by first sending a copy of the request, without authorization or content.
1855
- *
1856
- * when the challenge is received, it will be authenticated and used to send the original
1857
- * request with authorization.
1858
- *
1859
- * Following the first request of a client, follow-up requests will get the cached token
1860
- * if possible.
1861
- *
1862
- */
1863
- function keyVaultAuthenticationPolicy(credential, options = {}) {
1864
- const { disableChallengeResourceVerification } = options;
1865
- let challengeState = { status: "none" };
1866
- const getAccessToken = createTokenCycler(credential);
1867
- function requestToOptions(request) {
1868
- return {
1869
- abortSignal: request.abortSignal,
1870
- requestOptions: { timeout: request.timeout > 0 ? request.timeout : void 0 },
1871
- tracingOptions: request.tracingOptions
1872
- };
1873
- }
1874
- async function authorizeRequest(request) {
1875
- const requestOptions = requestToOptions(request);
1876
- switch (challengeState.status) {
1877
- case "none":
1878
- challengeState = {
1879
- status: "started",
1880
- originalBody: request.body
1881
- };
1882
- request.body = null;
1883
- break;
1884
- case "started": break;
1885
- case "complete": {
1886
- const token = await getAccessToken(challengeState.scopes, {
1887
- ...requestOptions,
1888
- enableCae: true,
1889
- tenantId: challengeState.tenantId
1890
- });
1891
- if (token) request.headers.set("authorization", `Bearer ${token.token}`);
1892
- break;
1893
- }
1894
- }
1895
- }
1896
- async function handleChallenge(request, response, next) {
1897
- if (response.status !== 401) return response;
1898
- if (request.body === null && challengeState.status === "started") request.body = challengeState.originalBody;
1899
- const getTokenOptions = requestToOptions(request);
1900
- const challenge = response.headers.get("WWW-Authenticate");
1901
- if (!challenge) {
1902
- logger$1.warning("keyVaultAuthentication policy encountered a 401 response without a corresponding WWW-Authenticate header. This is unexpected. Not handling the 401 response.");
1903
- return response;
1904
- }
1905
- const parsedChallenge = parseWWWAuthenticateHeader(challenge);
1906
- const scope = parsedChallenge.resource ? parsedChallenge.resource + "/.default" : parsedChallenge.scope;
1907
- if (!scope) return response;
1908
- if (!disableChallengeResourceVerification) verifyChallengeResource(scope, request);
1909
- const accessToken = await getAccessToken([scope], {
1910
- ...getTokenOptions,
1911
- enableCae: true,
1912
- tenantId: parsedChallenge.tenantId
1913
- });
1914
- if (!accessToken) return response;
1915
- request.headers.set("Authorization", `Bearer ${accessToken.token}`);
1916
- challengeState = {
1917
- status: "complete",
1918
- scopes: [scope],
1919
- tenantId: parsedChallenge.tenantId
1920
- };
1921
- return next(request);
1922
- }
1923
- async function handleCaeChallenge(request, response, next) {
1924
- if (challengeState.status !== "complete") return response;
1925
- if (response.status !== 401) return response;
1926
- const getTokenOptions = requestToOptions(request);
1927
- const challenge = response.headers.get("WWW-Authenticate");
1928
- if (!challenge) return response;
1929
- const { claims: base64EncodedClaims, error } = parseWWWAuthenticateHeader(challenge);
1930
- if (error !== "insufficient_claims" || base64EncodedClaims === void 0) return response;
1931
- const claims = atob(base64EncodedClaims);
1932
- const accessToken = await getAccessToken(challengeState.scopes, {
1933
- ...getTokenOptions,
1934
- enableCae: true,
1935
- tenantId: challengeState.tenantId,
1936
- claims
1937
- });
1938
- request.headers.set("Authorization", `Bearer ${accessToken.token}`);
1939
- return next(request);
1940
- }
1941
- async function sendRequest(request, next) {
1942
- await authorizeRequest(request);
1943
- let response = await next(request);
1944
- response = await handleChallenge(request, response, next);
1945
- response = await handleCaeChallenge(request, response, next);
1946
- return response;
1947
- }
1948
- return {
1949
- name: keyVaultAuthenticationPolicyName,
1950
- sendRequest
1951
- };
1952
- }
1953
- //#endregion
1954
- //#region ../../node_modules/.pnpm/@azure+keyvault-common@2.1.0/node_modules/@azure/keyvault-common/dist/esm/parseKeyVaultIdentifier.js
1955
- /**
1956
- * Parses a Key Vault identifier into its components.
1957
- *
1958
- * @param collection - The collection of the Key Vault identifier.
1959
- * @param identifier - The Key Vault identifier to be parsed.
1960
- */
1961
- function parseKeyVaultIdentifier(collection, identifier) {
1962
- if (typeof collection !== "string" || !(collection = collection.trim())) throw new Error("Invalid collection argument");
1963
- if (typeof identifier !== "string" || !(identifier = identifier.trim())) throw new Error("Invalid identifier argument");
1964
- let baseUri;
1965
- try {
1966
- baseUri = new URL(identifier);
1967
- } catch (e) {
1968
- throw new Error(`Invalid ${collection} identifier: ${identifier}. Not a valid URI`);
1969
- }
1970
- const segments = (baseUri.pathname || "").split("/");
1971
- if (segments.length !== 3 && segments.length !== 4) throw new Error(`Invalid ${collection} identifier: ${identifier}. Bad number of segments: ${segments.length}`);
1972
- if (collection !== segments[1]) throw new Error(`Invalid ${collection} identifier: ${identifier}. segment [1] should be "${collection}", found "${segments[1]}"`);
1973
- return {
1974
- vaultUrl: `${baseUri.protocol}//${baseUri.host}`,
1975
- name: segments[2],
1976
- version: segments.length === 4 ? segments[3] : void 0
1977
- };
1978
- }
1979
- //#endregion
1980
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/identifier.js
1981
- /**
1982
- * Parses the given Key Vault Secret Id. An example is:
1983
- *
1984
- * https://<keyvault-name>.vault.azure.net/secrets/<secret-name>/<unique-version-id>
1985
- *
1986
- * On parsing the above Id, this function returns:
1987
- *```ts snippet:ignore
1988
- * {
1989
- * sourceId: "https://<keyvault-name>.vault.azure.net/secrets/<secret-name>/<unique-version-id>",
1990
- * vaultUrl: "https://<keyvault-name>.vault.azure.net",
1991
- * version: "<unique-version-id>",
1992
- * name: "<secret-name>"
1993
- * }
1994
- *```
1995
- * @param id - The Id of the Key Vault Secret.
1996
- */
1997
- function parseKeyVaultSecretIdentifier(id) {
1998
- const collection = id.split("/")[3];
1999
- return {
2000
- sourceId: id,
2001
- ...parseKeyVaultIdentifier(collection, id)
2002
- };
2003
- }
2004
- //#endregion
2005
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/transformations.js
2006
- /**
2007
- * @internal
2008
- * Shapes the exposed {@link KeyVaultKey} based on either a received secret bundle or deleted secret bundle.
2009
- */
2010
- function getSecretFromSecretBundle(bundle) {
2011
- const secretBundle = bundle;
2012
- const deletedSecretBundle = bundle;
2013
- const parsedId = parseKeyVaultSecretIdentifier(secretBundle.id);
2014
- const attributes = secretBundle.attributes;
2015
- delete secretBundle.attributes;
2016
- const resultObject = {
2017
- value: secretBundle.value,
2018
- name: parsedId.name,
2019
- properties: {
2020
- expiresOn: attributes?.expires,
2021
- createdOn: attributes?.created,
2022
- updatedOn: attributes?.updated,
2023
- enabled: attributes?.enabled,
2024
- notBefore: attributes?.notBefore,
2025
- recoverableDays: attributes?.recoverableDays,
2026
- recoveryLevel: attributes?.recoveryLevel,
2027
- id: secretBundle.id,
2028
- contentType: secretBundle.contentType,
2029
- tags: secretBundle.tags,
2030
- managed: secretBundle.managed,
2031
- previousVersion: secretBundle.previousVersion,
2032
- vaultUrl: parsedId.vaultUrl,
2033
- version: parsedId.version,
2034
- name: parsedId.name,
2035
- certificateKeyId: secretBundle.kid
2036
- }
2037
- };
2038
- if (deletedSecretBundle.recoveryId) {
2039
- resultObject.properties.recoveryId = deletedSecretBundle.recoveryId;
2040
- resultObject.properties.scheduledPurgeDate = deletedSecretBundle.scheduledPurgeDate;
2041
- resultObject.properties.deletedOn = deletedSecretBundle.deletedDate;
2042
- resultObject.recoveryId = deletedSecretBundle.recoveryId;
2043
- resultObject.scheduledPurgeDate = deletedSecretBundle.scheduledPurgeDate;
2044
- resultObject.deletedOn = deletedSecretBundle.deletedDate;
2045
- }
2046
- if (attributes) {
2047
- if (attributes.vaultUrl) delete resultObject.properties.vaultUrl;
2048
- if (attributes.expires) delete resultObject.properties.expires;
2049
- if (attributes.created) delete resultObject.properties.created;
2050
- if (attributes.updated) delete resultObject.properties.updated;
2051
- }
2052
- return resultObject;
2053
- }
2054
- /**
2055
- * A helper supporting compatibility between modular and legacy paged async iterables.
2056
- *
2057
- * Provides the following compatibility:
2058
- * 1. Maps the values of the paged async iterable using the provided mapper function.
2059
- * 2. Supports `maxPageSize` operation on the paged async iterable.
2060
- *
2061
- * TODO: move this to keyvault-common once everything is merged
2062
- */
2063
- function mapPagedAsyncIterable(operation, operationOptions, mapper) {
2064
- let iter = void 0;
2065
- return {
2066
- async next() {
2067
- iter ??= operation({
2068
- ...operationOptions,
2069
- maxresults: void 0
2070
- });
2071
- const result = await iter.next();
2072
- return {
2073
- ...result,
2074
- value: result.value && mapper(result.value)
2075
- };
2076
- },
2077
- [Symbol.asyncIterator]() {
2078
- return this;
2079
- },
2080
- async *byPage(settings) {
2081
- const iteratorByPage = operation({
2082
- ...operationOptions,
2083
- maxresults: settings?.maxPageSize
2084
- }).byPage(settings);
2085
- for await (const page of iteratorByPage) yield page.map(mapper);
2086
- }
2087
- };
2088
- }
2089
- //#endregion
2090
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/tracing.js
2091
- const tracingClient = createTracingClient({
2092
- namespace: "Microsoft.KeyVault",
2093
- packageName: "@azure/keyvault-secrets",
2094
- packageVersion: SDK_VERSION
2095
- });
2096
- //#endregion
2097
- //#region ../../node_modules/.pnpm/@azure+core-lro@2.7.2/node_modules/@azure/core-lro/dist/esm/legacy/poller.js
2098
- /**
2099
- * When a poller is manually stopped through the `stopPolling` method,
2100
- * the poller will be rejected with an instance of the PollerStoppedError.
2101
- */
2102
- var PollerStoppedError = class PollerStoppedError extends Error {
2103
- constructor(message) {
2104
- super(message);
2105
- this.name = "PollerStoppedError";
2106
- Object.setPrototypeOf(this, PollerStoppedError.prototype);
2107
- }
2108
- };
2109
- /**
2110
- * When the operation is cancelled, the poller will be rejected with an instance
2111
- * of the PollerCancelledError.
2112
- */
2113
- var PollerCancelledError = class PollerCancelledError extends Error {
2114
- constructor(message) {
2115
- super(message);
2116
- this.name = "PollerCancelledError";
2117
- Object.setPrototypeOf(this, PollerCancelledError.prototype);
2118
- }
2119
- };
2120
- /**
2121
- * A class that represents the definition of a program that polls through consecutive requests
2122
- * until it reaches a state of completion.
2123
- *
2124
- * A poller can be executed manually, by polling request by request by calling to the `poll()` method repeatedly, until its operation is completed.
2125
- * It also provides a way to wait until the operation completes, by calling `pollUntilDone()` and waiting until the operation finishes.
2126
- * Pollers can also request the cancellation of the ongoing process to whom is providing the underlying long running operation.
2127
- *
2128
- * ```ts
2129
- * const poller = new MyPoller();
2130
- *
2131
- * // Polling just once:
2132
- * await poller.poll();
2133
- *
2134
- * // We can try to cancel the request here, by calling:
2135
- * //
2136
- * // await poller.cancelOperation();
2137
- * //
2138
- *
2139
- * // Getting the final result:
2140
- * const result = await poller.pollUntilDone();
2141
- * ```
2142
- *
2143
- * The Poller is defined by two types, a type representing the state of the poller, which
2144
- * must include a basic set of properties from `PollOperationState<TResult>`,
2145
- * and a return type defined by `TResult`, which can be anything.
2146
- *
2147
- * The Poller class implements the `PollerLike` interface, which allows poller implementations to avoid having
2148
- * to export the Poller's class directly, and instead only export the already instantiated poller with the PollerLike type.
2149
- *
2150
- * ```ts
2151
- * class Client {
2152
- * public async makePoller: PollerLike<MyOperationState, MyResult> {
2153
- * const poller = new MyPoller({});
2154
- * // It might be preferred to return the poller after the first request is made,
2155
- * // so that some information can be obtained right away.
2156
- * await poller.poll();
2157
- * return poller;
2158
- * }
2159
- * }
2160
- *
2161
- * const poller: PollerLike<MyOperationState, MyResult> = myClient.makePoller();
2162
- * ```
2163
- *
2164
- * A poller can be created through its constructor, then it can be polled until it's completed.
2165
- * At any point in time, the state of the poller can be obtained without delay through the getOperationState method.
2166
- * At any point in time, the intermediate forms of the result type can be requested without delay.
2167
- * Once the underlying operation is marked as completed, the poller will stop and the final value will be returned.
2168
- *
2169
- * ```ts
2170
- * const poller = myClient.makePoller();
2171
- * const state: MyOperationState = poller.getOperationState();
2172
- *
2173
- * // The intermediate result can be obtained at any time.
2174
- * const result: MyResult | undefined = poller.getResult();
2175
- *
2176
- * // The final result can only be obtained after the poller finishes.
2177
- * const result: MyResult = await poller.pollUntilDone();
2178
- * ```
2179
- *
2180
- */
2181
- var Poller = class {
2182
- /**
2183
- * A poller needs to be initialized by passing in at least the basic properties of the `PollOperation<TState, TResult>`.
2184
- *
2185
- * When writing an implementation of a Poller, this implementation needs to deal with the initialization
2186
- * of any custom state beyond the basic definition of the poller. The basic poller assumes that the poller's
2187
- * operation has already been defined, at least its basic properties. The code below shows how to approach
2188
- * the definition of the constructor of a new custom poller.
2189
- *
2190
- * ```ts
2191
- * export class MyPoller extends Poller<MyOperationState, string> {
2192
- * constructor({
2193
- * // Anything you might need outside of the basics
2194
- * }) {
2195
- * let state: MyOperationState = {
2196
- * privateProperty: private,
2197
- * publicProperty: public,
2198
- * };
2199
- *
2200
- * const operation = {
2201
- * state,
2202
- * update,
2203
- * cancel,
2204
- * toString
2205
- * }
2206
- *
2207
- * // Sending the operation to the parent's constructor.
2208
- * super(operation);
2209
- *
2210
- * // You can assign more local properties here.
2211
- * }
2212
- * }
2213
- * ```
2214
- *
2215
- * Inside of this constructor, a new promise is created. This will be used to
2216
- * tell the user when the poller finishes (see `pollUntilDone()`). The promise's
2217
- * resolve and reject methods are also used internally to control when to resolve
2218
- * or reject anyone waiting for the poller to finish.
2219
- *
2220
- * The constructor of a custom implementation of a poller is where any serialized version of
2221
- * a previous poller's operation should be deserialized into the operation sent to the
2222
- * base constructor. For example:
2223
- *
2224
- * ```ts
2225
- * export class MyPoller extends Poller<MyOperationState, string> {
2226
- * constructor(
2227
- * baseOperation: string | undefined
2228
- * ) {
2229
- * let state: MyOperationState = {};
2230
- * if (baseOperation) {
2231
- * state = {
2232
- * ...JSON.parse(baseOperation).state,
2233
- * ...state
2234
- * };
2235
- * }
2236
- * const operation = {
2237
- * state,
2238
- * // ...
2239
- * }
2240
- * super(operation);
2241
- * }
2242
- * }
2243
- * ```
2244
- *
2245
- * @param operation - Must contain the basic properties of `PollOperation<State, TResult>`.
2246
- */
2247
- constructor(operation) {
2248
- /** controls whether to throw an error if the operation failed or was canceled. */
2249
- this.resolveOnUnsuccessful = false;
2250
- this.stopped = true;
2251
- this.pollProgressCallbacks = [];
2252
- this.operation = operation;
2253
- this.promise = new Promise((resolve, reject) => {
2254
- this.resolve = resolve;
2255
- this.reject = reject;
2256
- });
2257
- this.promise.catch(() => {});
2258
- }
2259
- /**
2260
- * Starts a loop that will break only if the poller is done
2261
- * or if the poller is stopped.
2262
- */
2263
- async startPolling(pollOptions = {}) {
2264
- if (this.stopped) this.stopped = false;
2265
- while (!this.isStopped() && !this.isDone()) {
2266
- await this.poll(pollOptions);
2267
- await this.delay();
2268
- }
2269
- }
2270
- /**
2271
- * pollOnce does one polling, by calling to the update method of the underlying
2272
- * poll operation to make any relevant change effective.
2273
- *
2274
- * It only optionally receives an object with an abortSignal property, from \@azure/abort-controller's AbortSignalLike.
2275
- *
2276
- * @param options - Optional properties passed to the operation's update method.
2277
- */
2278
- async pollOnce(options = {}) {
2279
- if (!this.isDone()) this.operation = await this.operation.update({
2280
- abortSignal: options.abortSignal,
2281
- fireProgress: this.fireProgress.bind(this)
2282
- });
2283
- this.processUpdatedState();
2284
- }
2285
- /**
2286
- * fireProgress calls the functions passed in via onProgress the method of the poller.
2287
- *
2288
- * It loops over all of the callbacks received from onProgress, and executes them, sending them
2289
- * the current operation state.
2290
- *
2291
- * @param state - The current operation state.
2292
- */
2293
- fireProgress(state) {
2294
- for (const callback of this.pollProgressCallbacks) callback(state);
2295
- }
2296
- /**
2297
- * Invokes the underlying operation's cancel method.
2298
- */
2299
- async cancelOnce(options = {}) {
2300
- this.operation = await this.operation.cancel(options);
2301
- }
2302
- /**
2303
- * Returns a promise that will resolve once a single polling request finishes.
2304
- * It does this by calling the update method of the Poller's operation.
2305
- *
2306
- * It only optionally receives an object with an abortSignal property, from \@azure/abort-controller's AbortSignalLike.
2307
- *
2308
- * @param options - Optional properties passed to the operation's update method.
2309
- */
2310
- poll(options = {}) {
2311
- if (!this.pollOncePromise) {
2312
- this.pollOncePromise = this.pollOnce(options);
2313
- const clearPollOncePromise = () => {
2314
- this.pollOncePromise = void 0;
2315
- };
2316
- this.pollOncePromise.then(clearPollOncePromise, clearPollOncePromise).catch(this.reject);
2317
- }
2318
- return this.pollOncePromise;
2319
- }
2320
- processUpdatedState() {
2321
- if (this.operation.state.error) {
2322
- this.stopped = true;
2323
- if (!this.resolveOnUnsuccessful) {
2324
- this.reject(this.operation.state.error);
2325
- throw this.operation.state.error;
2326
- }
2327
- }
2328
- if (this.operation.state.isCancelled) {
2329
- this.stopped = true;
2330
- if (!this.resolveOnUnsuccessful) {
2331
- const error = new PollerCancelledError("Operation was canceled");
2332
- this.reject(error);
2333
- throw error;
2334
- }
2335
- }
2336
- if (this.isDone() && this.resolve) this.resolve(this.getResult());
2337
- }
2338
- /**
2339
- * Returns a promise that will resolve once the underlying operation is completed.
2340
- */
2341
- async pollUntilDone(pollOptions = {}) {
2342
- if (this.stopped) this.startPolling(pollOptions).catch(this.reject);
2343
- this.processUpdatedState();
2344
- return this.promise;
2345
- }
2346
- /**
2347
- * Invokes the provided callback after each polling is completed,
2348
- * sending the current state of the poller's operation.
2349
- *
2350
- * It returns a method that can be used to stop receiving updates on the given callback function.
2351
- */
2352
- onProgress(callback) {
2353
- this.pollProgressCallbacks.push(callback);
2354
- return () => {
2355
- this.pollProgressCallbacks = this.pollProgressCallbacks.filter((c) => c !== callback);
2356
- };
2357
- }
2358
- /**
2359
- * Returns true if the poller has finished polling.
2360
- */
2361
- isDone() {
2362
- const state = this.operation.state;
2363
- return Boolean(state.isCompleted || state.isCancelled || state.error);
2364
- }
2365
- /**
2366
- * Stops the poller from continuing to poll.
2367
- */
2368
- stopPolling() {
2369
- if (!this.stopped) {
2370
- this.stopped = true;
2371
- if (this.reject) this.reject(new PollerStoppedError("This poller is already stopped"));
2372
- }
2373
- }
2374
- /**
2375
- * Returns true if the poller is stopped.
2376
- */
2377
- isStopped() {
2378
- return this.stopped;
2379
- }
2380
- /**
2381
- * Attempts to cancel the underlying operation.
2382
- *
2383
- * It only optionally receives an object with an abortSignal property, from \@azure/abort-controller's AbortSignalLike.
2384
- *
2385
- * If it's called again before it finishes, it will throw an error.
2386
- *
2387
- * @param options - Optional properties passed to the operation's update method.
2388
- */
2389
- cancelOperation(options = {}) {
2390
- if (!this.cancelPromise) this.cancelPromise = this.cancelOnce(options);
2391
- else if (options.abortSignal) throw new Error("A cancel request is currently pending");
2392
- return this.cancelPromise;
2393
- }
2394
- /**
2395
- * Returns the state of the operation.
2396
- *
2397
- * Even though TState will be the same type inside any of the methods of any extension of the Poller class,
2398
- * implementations of the pollers can customize what's shared with the public by writing their own
2399
- * version of the `getOperationState` method, and by defining two types, one representing the internal state of the poller
2400
- * and a public type representing a safe to share subset of the properties of the internal state.
2401
- * Their definition of getOperationState can then return their public type.
2402
- *
2403
- * Example:
2404
- *
2405
- * ```ts
2406
- * // Let's say we have our poller's operation state defined as:
2407
- * interface MyOperationState extends PollOperationState<ResultType> {
2408
- * privateProperty?: string;
2409
- * publicProperty?: string;
2410
- * }
2411
- *
2412
- * // To allow us to have a true separation of public and private state, we have to define another interface:
2413
- * interface PublicState extends PollOperationState<ResultType> {
2414
- * publicProperty?: string;
2415
- * }
2416
- *
2417
- * // Then, we define our Poller as follows:
2418
- * export class MyPoller extends Poller<MyOperationState, ResultType> {
2419
- * // ... More content is needed here ...
2420
- *
2421
- * public getOperationState(): PublicState {
2422
- * const state: PublicState = this.operation.state;
2423
- * return {
2424
- * // Properties from PollOperationState<TResult>
2425
- * isStarted: state.isStarted,
2426
- * isCompleted: state.isCompleted,
2427
- * isCancelled: state.isCancelled,
2428
- * error: state.error,
2429
- * result: state.result,
2430
- *
2431
- * // The only other property needed by PublicState.
2432
- * publicProperty: state.publicProperty
2433
- * }
2434
- * }
2435
- * }
2436
- * ```
2437
- *
2438
- * You can see this in the tests of this repository, go to the file:
2439
- * `../test/utils/testPoller.ts`
2440
- * and look for the getOperationState implementation.
2441
- */
2442
- getOperationState() {
2443
- return this.operation.state;
2444
- }
2445
- /**
2446
- * Returns the result value of the operation,
2447
- * regardless of the state of the poller.
2448
- * It can return undefined or an incomplete form of the final TResult value
2449
- * depending on the implementation.
2450
- */
2451
- getResult() {
2452
- return this.operation.state.result;
2453
- }
2454
- /**
2455
- * Returns a serialized version of the poller's operation
2456
- * by invoking the operation's toString method.
2457
- */
2458
- toString() {
2459
- return this.operation.toString();
2460
- }
2461
- };
2462
- //#endregion
2463
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/lro/keyVaultSecretPoller.js
2464
- /**
2465
- * Common properties and methods of the Key Vault Secret Pollers.
2466
- */
2467
- var KeyVaultSecretPoller = class extends Poller {
2468
- /**
2469
- * Defines how much time the poller is going to wait before making a new request to the service.
2470
- */
2471
- intervalInMs = 2e3;
2472
- /**
2473
- * The method used by the poller to wait before attempting to update its operation.
2474
- */
2475
- async delay() {
2476
- return delay(this.intervalInMs);
2477
- }
2478
- };
2479
- /**
2480
- * Common properties and methods of the Key Vault Secret Poller operations.
2481
- */
2482
- var KeyVaultSecretPollOperation = class {
2483
- state;
2484
- cancelMessage = "";
2485
- constructor(state, options = {}) {
2486
- this.state = state;
2487
- if (options.cancelMessage) this.cancelMessage = options.cancelMessage;
2488
- }
2489
- /**
2490
- * Meant to reach to the service and update the Poller operation.
2491
- * @param options - The optional parameters, which is only an abortSignal from \@azure/abort-controller
2492
- */
2493
- async update() {
2494
- throw new Error("Operation not supported.");
2495
- }
2496
- /**
2497
- * Meant to reach to the service and cancel the Poller operation.
2498
- * @param options - The optional parameters, which is only an abortSignal from \@azure/abort-controller
2499
- */
2500
- async cancel() {
2501
- throw new Error(this.cancelMessage);
2502
- }
2503
- /**
2504
- * Serializes the Poller operation.
2505
- */
2506
- toString() {
2507
- return JSON.stringify({ state: this.state });
2508
- }
2509
- };
2510
- //#endregion
2511
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/lro/delete/operation.js
2512
- /**
2513
- * An interface representing a delete secret's poll operation
2514
- */
2515
- var DeleteSecretPollOperation = class extends KeyVaultSecretPollOperation {
2516
- state;
2517
- client;
2518
- operationOptions;
2519
- constructor(state, client, operationOptions = {}) {
2520
- super(state, { cancelMessage: "Canceling the deletion of a secret is not supported." });
2521
- this.state = state;
2522
- this.client = client;
2523
- this.operationOptions = operationOptions;
2524
- }
2525
- /**
2526
- * Sends a delete request for the given Key Vault Key's name to the Key Vault service.
2527
- * Since the Key Vault Key won't be immediately deleted, we have {@link beginDeleteKey}.
2528
- */
2529
- deleteSecret(name, options = {}) {
2530
- return tracingClient.withSpan("DeleteSecretPoller.deleteSecret", options, async (updatedOptions) => {
2531
- return getSecretFromSecretBundle(await this.client.deleteSecret(name, updatedOptions));
2532
- });
2533
- }
2534
- /**
2535
- * The getDeletedSecret method returns the specified deleted secret along with its properties.
2536
- * This operation requires the secrets/get permission.
2537
- */
2538
- getDeletedSecret(name, options = {}) {
2539
- return tracingClient.withSpan("DeleteSecretPoller.getDeletedSecret", options, async (updatedOptions) => {
2540
- return getSecretFromSecretBundle(await this.client.getDeletedSecret(name, updatedOptions));
2541
- });
2542
- }
2543
- /**
2544
- * Reaches to the service and updates the delete secret's poll operation.
2545
- */
2546
- async update(options = {}) {
2547
- const state = this.state;
2548
- const { name } = state;
2549
- if (options.abortSignal) this.operationOptions.abortSignal = options.abortSignal;
2550
- if (!state.isStarted) {
2551
- const deletedSecret = await this.deleteSecret(name, this.operationOptions);
2552
- state.isStarted = true;
2553
- state.result = deletedSecret;
2554
- if (!deletedSecret.properties.recoveryId) state.isCompleted = true;
2555
- }
2556
- if (!state.isCompleted) try {
2557
- state.result = await this.getDeletedSecret(name, this.operationOptions);
2558
- state.isCompleted = true;
2559
- } catch (error) {
2560
- if (error.statusCode === 403) state.isCompleted = true;
2561
- else if (error.statusCode !== 404) {
2562
- state.error = error;
2563
- state.isCompleted = true;
2564
- throw error;
2565
- }
2566
- }
2567
- return this;
2568
- }
2569
- };
2570
- //#endregion
2571
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/lro/delete/poller.js
2572
- /**
2573
- * Class that creates a poller that waits until a secret finishes being deleted.
2574
- */
2575
- var DeleteSecretPoller = class extends KeyVaultSecretPoller {
2576
- constructor(options) {
2577
- const { client, name, operationOptions, intervalInMs = 2e3, resumeFrom } = options;
2578
- let state;
2579
- if (resumeFrom) state = JSON.parse(resumeFrom).state;
2580
- const operation = new DeleteSecretPollOperation({
2581
- ...state,
2582
- name
2583
- }, client, operationOptions);
2584
- super(operation);
2585
- this.intervalInMs = intervalInMs;
2586
- }
2587
- };
2588
- //#endregion
2589
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/lro/recover/operation.js
2590
- /**
2591
- * An interface representing a delete secret's poll operation
2592
- */
2593
- var RecoverDeletedSecretPollOperation = class extends KeyVaultSecretPollOperation {
2594
- state;
2595
- client;
2596
- options;
2597
- constructor(state, client, options = {}) {
2598
- super(state, { cancelMessage: "Canceling the recovery of a deleted secret is not supported." });
2599
- this.state = state;
2600
- this.client = client;
2601
- this.options = options;
2602
- }
2603
- /**
2604
- * The getSecret method returns the specified secret along with its properties.
2605
- * This operation requires the secrets/get permission.
2606
- */
2607
- getSecret(name, options = {}) {
2608
- return tracingClient.withSpan("RecoverDeletedSecretPoller.getSecret", options, async (updatedOptions) => {
2609
- return getSecretFromSecretBundle(await this.client.getSecret(name, options && options.version ? options.version : "", updatedOptions));
2610
- });
2611
- }
2612
- /**
2613
- * The recoverDeletedSecret method recovers the specified deleted secret along with its properties.
2614
- * This operation requires the secrets/recover permission.
2615
- */
2616
- recoverDeletedSecret(name, options = {}) {
2617
- return tracingClient.withSpan("RecoverDeletedSecretPoller.recoverDeletedSecret", options, async (updatedOptions) => {
2618
- return getSecretFromSecretBundle(await this.client.recoverDeletedSecret(name, updatedOptions));
2619
- });
2620
- }
2621
- /**
2622
- * Reaches to the service and updates the delete secret's poll operation.
2623
- */
2624
- async update(options = {}) {
2625
- const state = this.state;
2626
- const { name } = state;
2627
- if (options.abortSignal) this.options.abortSignal = options.abortSignal;
2628
- if (!state.isStarted) {
2629
- try {
2630
- state.result = (await this.getSecret(name, this.options)).properties;
2631
- state.isCompleted = true;
2632
- } catch {}
2633
- if (!state.isCompleted) {
2634
- state.result = (await this.recoverDeletedSecret(name, this.options)).properties;
2635
- state.isStarted = true;
2636
- }
2637
- }
2638
- if (!state.isCompleted) try {
2639
- state.result = (await this.getSecret(name, this.options)).properties;
2640
- state.isCompleted = true;
2641
- } catch (error) {
2642
- if (error.statusCode === 403) state.isCompleted = true;
2643
- else if (error.statusCode !== 404) {
2644
- state.error = error;
2645
- state.isCompleted = true;
2646
- throw error;
2647
- }
2648
- }
2649
- return this;
2650
- }
2651
- };
2652
- //#endregion
2653
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/lro/recover/poller.js
2654
- /**
2655
- * Class that deletes a poller that waits until a secret finishes being deleted
2656
- */
2657
- var RecoverDeletedSecretPoller = class extends KeyVaultSecretPoller {
2658
- constructor(options) {
2659
- const { client, name, operationOptions, intervalInMs = 2e3, resumeFrom } = options;
2660
- let state;
2661
- if (resumeFrom) state = JSON.parse(resumeFrom).state;
2662
- const operation = new RecoverDeletedSecretPollOperation({
2663
- ...state,
2664
- name
2665
- }, client, operationOptions);
2666
- super(operation);
2667
- this.intervalInMs = intervalInMs;
2668
- }
2669
- };
2670
- //#endregion
2671
- //#region ../../node_modules/.pnpm/@azure+keyvault-secrets@4.11.2/node_modules/@azure/keyvault-secrets/dist/esm/index.js
2672
- /**
2673
- * The SecretClient provides methods to manage {@link KeyVaultSecret} in
2674
- * the Azure Key Vault. The client supports creating, retrieving, updating,
2675
- * deleting, purging, backing up, restoring and listing KeyVaultSecrets. The
2676
- * client also supports listing {@link DeletedSecret} for a soft-delete enabled Azure
2677
- * Key Vault.
2678
- */
2679
- var SecretClient = class {
2680
- /**
2681
- * The base URL to the vault
2682
- */
2683
- vaultUrl;
2684
- /**
2685
- * A reference to the auto-generated KeyVault HTTP client.
2686
- */
2687
- client;
2688
- /**
2689
- * Creates an instance of SecretClient.
2690
- *
2691
- * Example usage:
2692
- * ```ts snippet:ReadmeSampleCreateClient
2693
- * import { DefaultAzureCredential } from "@azure/identity";
2694
- * import { SecretClient } from "@azure/keyvault-secrets";
2695
- *
2696
- * const credential = new DefaultAzureCredential();
2697
- *
2698
- * // Build the URL to reach your key vault
2699
- * const vaultName = "<YOUR KEYVAULT NAME>";
2700
- * const url = `https://${vaultName}.vault.azure.net`;
2701
- *
2702
- * // Lastly, create our secrets client and connect to the service
2703
- * const client = new SecretClient(url, credential);
2704
- * ```
2705
- * @param vaultUrl - The base URL to the vault. You should validate that this URL references a valid Key Vault resource. See https://aka.ms/azsdk/blog/vault-uri for details.
2706
- * @param credential - An object that implements the `TokenCredential` interface used to authenticate requests to the service. Use the \@azure/identity package to create a credential that suits your needs.
2707
- * @param pipelineOptions - Pipeline options used to configure Key Vault API requests.
2708
- * Omit this parameter to use the default pipeline configuration.
2709
- */
2710
- constructor(vaultUrl, credential, pipelineOptions = {}) {
2711
- this.vaultUrl = vaultUrl;
2712
- const internalPipelineOptions = {
2713
- ...pipelineOptions,
2714
- userAgentOptions: { userAgentPrefix: `${pipelineOptions.userAgentOptions?.userAgentPrefix ?? ""} azsdk-js-keyvault-secrets/${SDK_VERSION}` },
2715
- apiVersion: pipelineOptions.serviceVersion || "2025-07-01",
2716
- loggingOptions: {
2717
- logger: logger.info,
2718
- additionalAllowedHeaderNames: [
2719
- "x-ms-keyvault-region",
2720
- "x-ms-keyvault-network-info",
2721
- "x-ms-keyvault-service-version"
2722
- ]
2723
- }
2724
- };
2725
- this.client = new KeyVaultClient(this.vaultUrl, credential, internalPipelineOptions);
2726
- this.client.pipeline.removePolicy({ name: bearerTokenAuthenticationPolicyName });
2727
- this.client.pipeline.addPolicy(keyVaultAuthenticationPolicy(credential, pipelineOptions), {});
2728
- this.client.pipeline.addPolicy({
2729
- name: "ContentTypePolicy",
2730
- sendRequest(request, next) {
2731
- if ((request.headers.get("Content-Type") ?? "").startsWith("application/json")) request.headers.set("Content-Type", "application/json");
2732
- return next(request);
2733
- }
2734
- });
2735
- }
2736
- /**
2737
- * The setSecret method adds a secret or secret version to the Azure Key Vault. If the named secret
2738
- * already exists, Azure Key Vault creates a new version of that secret.
2739
- * This operation requires the secrets/set permission.
2740
- *
2741
- * Example usage:
2742
- * ```ts snippet:ReadmeSampleCreateSecret
2743
- * import { DefaultAzureCredential } from "@azure/identity";
2744
- * import { SecretClient } from "@azure/keyvault-secrets";
2745
- *
2746
- * const credential = new DefaultAzureCredential();
2747
- *
2748
- * const vaultName = "<YOUR KEYVAULT NAME>";
2749
- * const url = `https://${vaultName}.vault.azure.net`;
2750
- *
2751
- * const client = new SecretClient(url, credential);
2752
- *
2753
- * const secretName = "MySecretName";
2754
- *
2755
- * const result = await client.setSecret(secretName, "MySecretValue");
2756
- * console.log("result: ", result);
2757
- * ```
2758
- * Adds a secret in a specified key vault.
2759
- * @param secretName - The name of the secret.
2760
- * @param value - The value of the secret.
2761
- * @param options - The optional parameters.
2762
- */
2763
- setSecret(secretName, value, options = {}) {
2764
- const { contentType, enabled, notBefore, expiresOn: expires, tags, ...remainingOptions } = options;
2765
- return tracingClient.withSpan("SecretClient.setSecret", remainingOptions, async (updatedOptions) => {
2766
- return getSecretFromSecretBundle(await this.client.setSecret(secretName, {
2767
- value,
2768
- contentType,
2769
- secretAttributes: {
2770
- enabled,
2771
- notBefore,
2772
- expires
2773
- },
2774
- tags
2775
- }, updatedOptions));
2776
- });
2777
- }
2778
- /**
2779
- * Deletes a secret stored in Azure Key Vault.
2780
- * This function returns a Long Running Operation poller that allows you to wait indefinitely until the secret is deleted.
2781
- *
2782
- * This operation requires the secrets/delete permission.
2783
- *
2784
- * Example usage:
2785
- * ```ts snippet:ReadmeSampleDeleteSecret
2786
- * import { DefaultAzureCredential } from "@azure/identity";
2787
- * import { SecretClient } from "@azure/keyvault-secrets";
2788
- *
2789
- * const credential = new DefaultAzureCredential();
2790
- *
2791
- * const vaultName = "<YOUR KEYVAULT NAME>";
2792
- * const url = `https://${vaultName}.vault.azure.net`;
2793
- *
2794
- * const client = new SecretClient(url, credential);
2795
- *
2796
- * const secretName = "MySecretName";
2797
- *
2798
- * await client.beginDeleteSecret(secretName);
2799
- * ```
2800
- * Deletes a secret from a specified key vault.
2801
- * @param secretName - The name of the secret.
2802
- * @param options - The optional parameters.
2803
- */
2804
- async beginDeleteSecret(name, options = {}) {
2805
- const poller = new DeleteSecretPoller({
2806
- name,
2807
- client: this.client,
2808
- ...options,
2809
- operationOptions: options
2810
- });
2811
- await poller.poll();
2812
- return poller;
2813
- }
2814
- /**
2815
- * The updateSecret method changes specified attributes of an existing stored secret. Properties that
2816
- * are not specified in the request are left unchanged. The value of a secret itself cannot be
2817
- * changed. This operation requires the secrets/set permission.
2818
- *
2819
- * Example usage:
2820
- * ```ts snippet:ReadmeSampleUpdateSecretAttributes
2821
- * import { DefaultAzureCredential } from "@azure/identity";
2822
- * import { SecretClient } from "@azure/keyvault-secrets";
2823
- *
2824
- * const credential = new DefaultAzureCredential();
2825
- *
2826
- * const vaultName = "<YOUR KEYVAULT NAME>";
2827
- * const url = `https://${vaultName}.vault.azure.net`;
2828
- *
2829
- * const client = new SecretClient(url, credential);
2830
- *
2831
- * const secretName = "MySecretName";
2832
- *
2833
- * const result = await client.getSecret(secretName);
2834
- * await client.updateSecretProperties(secretName, result.properties.version, { enabled: false });
2835
- * ```
2836
- * Updates the attributes associated with a specified secret in a given key vault.
2837
- * @param secretName - The name of the secret.
2838
- * @param secretVersion - The version of the secret.
2839
- * @param options - The optional parameters.
2840
- */
2841
- async updateSecretProperties(secretName, secretVersion, options = {}) {
2842
- const { contentType, enabled, notBefore, expiresOn: expires, tags, ...remainingOptions } = options;
2843
- return tracingClient.withSpan("SecretClient.updateSecretProperties", remainingOptions, async (updatedOptions) => {
2844
- return getSecretFromSecretBundle(await this.client.updateSecret(secretName, secretVersion, {
2845
- contentType,
2846
- secretAttributes: {
2847
- enabled,
2848
- notBefore,
2849
- expires
2850
- },
2851
- tags
2852
- }, updatedOptions)).properties;
2853
- });
2854
- }
2855
- /**
2856
- * The getSecret method is applicable to any secret stored in Azure Key Vault. This operation requires
2857
- * the secrets/get permission.
2858
- *
2859
- * Example usage:
2860
- * ```ts snippet:ReadmeSampleGetSecret
2861
- * import { DefaultAzureCredential } from "@azure/identity";
2862
- * import { SecretClient } from "@azure/keyvault-secrets";
2863
- *
2864
- * const credential = new DefaultAzureCredential();
2865
- *
2866
- * const vaultName = "<YOUR KEYVAULT NAME>";
2867
- * const url = `https://${vaultName}.vault.azure.net`;
2868
- *
2869
- * const client = new SecretClient(url, credential);
2870
- *
2871
- * const secretName = "MySecretName";
2872
- *
2873
- * const latestSecret = await client.getSecret(secretName);
2874
- * console.log(`Latest version of the secret ${secretName}: `, latestSecret);
2875
- *
2876
- * const specificSecret = await client.getSecret(secretName, {
2877
- * version: latestSecret.properties.version!,
2878
- * });
2879
- * console.log(
2880
- * `The secret ${secretName} at the version ${latestSecret.properties.version!}: `,
2881
- * specificSecret,
2882
- * );
2883
- * ```
2884
- * Get a specified secret from a given key vault.
2885
- * @param secretName - The name of the secret.
2886
- * @param options - The optional parameters.
2887
- */
2888
- getSecret(secretName, options = {}) {
2889
- return tracingClient.withSpan("SecretClient.getSecret", options, async (updatedOptions) => {
2890
- return getSecretFromSecretBundle(await this.client.getSecret(secretName, options && options.version ? options.version : "", updatedOptions));
2891
- });
2892
- }
2893
- /**
2894
- * The getDeletedSecret method returns the specified deleted secret along with its attributes.
2895
- * This operation requires the secrets/get permission.
2896
- *
2897
- * Example usage:
2898
- * ```ts snippet:ReadmeSampleGetDeletedSecret
2899
- * import { DefaultAzureCredential } from "@azure/identity";
2900
- * import { SecretClient } from "@azure/keyvault-secrets";
2901
- *
2902
- * const credential = new DefaultAzureCredential();
2903
- *
2904
- * const vaultName = "<YOUR KEYVAULT NAME>";
2905
- * const url = `https://${vaultName}.vault.azure.net`;
2906
- *
2907
- * const client = new SecretClient(url, credential);
2908
- *
2909
- * const secretName = "MySecretName";
2910
- *
2911
- * const result = await client.getDeletedSecret("MyDeletedSecret");
2912
- * ```
2913
- * Gets the specified deleted secret.
2914
- * @param secretName - The name of the secret.
2915
- * @param options - The optional parameters.
2916
- */
2917
- getDeletedSecret(secretName, options = {}) {
2918
- return tracingClient.withSpan("SecretClient.getDeletedSecret", options, async (updatedOptions) => {
2919
- return getSecretFromSecretBundle(await this.client.getDeletedSecret(secretName, updatedOptions));
2920
- });
2921
- }
2922
- /**
2923
- * The purge deleted secret operation removes the secret permanently, without the possibility of
2924
- * recovery. This operation can only be enabled on a soft-delete enabled vault. This operation
2925
- * requires the secrets/purge permission.
2926
- *
2927
- * Example usage:
2928
- * ```ts snippet:ReadmeSamplePurgeDeletedSecret
2929
- * import { DefaultAzureCredential } from "@azure/identity";
2930
- * import { SecretClient } from "@azure/keyvault-secrets";
2931
- *
2932
- * const credential = new DefaultAzureCredential();
2933
- *
2934
- * const vaultName = "<YOUR KEYVAULT NAME>";
2935
- * const url = `https://${vaultName}.vault.azure.net`;
2936
- *
2937
- * const client = new SecretClient(url, credential);
2938
- *
2939
- * const secretName = "MySecretName";
2940
- *
2941
- * const deletePoller = await client.beginDeleteSecret(secretName);
2942
- * await deletePoller.pollUntilDone();
2943
- *
2944
- * await client.purgeDeletedSecret(secretName);
2945
- * ```
2946
- * Permanently deletes the specified secret.
2947
- * @param secretName - The name of the secret.
2948
- * @param options - The optional parameters.
2949
- */
2950
- purgeDeletedSecret(secretName, options = {}) {
2951
- return tracingClient.withSpan("SecretClient.purgeDeletedSecret", options, async (updatedOptions) => {
2952
- await this.client.purgeDeletedSecret(secretName, updatedOptions);
2953
- });
2954
- }
2955
- /**
2956
- * Recovers the deleted secret in the specified vault.
2957
- * This function returns a Long Running Operation poller that allows you to wait indefinitely until the secret is recovered.
2958
- *
2959
- * This operation requires the secrets/recover permission.
2960
- *
2961
- * Example usage:
2962
- * ```ts snippet:ReadmeSampleRecoverDeletedSecret
2963
- * import { DefaultAzureCredential } from "@azure/identity";
2964
- * import { SecretClient } from "@azure/keyvault-secrets";
2965
- *
2966
- * const credential = new DefaultAzureCredential();
2967
- *
2968
- * const vaultName = "<YOUR KEYVAULT NAME>";
2969
- * const url = `https://${vaultName}.vault.azure.net`;
2970
- *
2971
- * const client = new SecretClient(url, credential);
2972
- *
2973
- * const secretName = "MySecretName";
2974
- *
2975
- * const deletePoller = await client.beginDeleteSecret(secretName);
2976
- * await deletePoller.pollUntilDone();
2977
- *
2978
- * const recoverPoller = await client.beginRecoverDeletedSecret(secretName);
2979
- * const deletedSecret = await recoverPoller.pollUntilDone();
2980
- * console.log(deletedSecret);
2981
- * ```
2982
- * Recovers the deleted secret to the latest version.
2983
- * @param secretName - The name of the deleted secret.
2984
- * @param options - The optional parameters.
2985
- */
2986
- async beginRecoverDeletedSecret(name, options = {}) {
2987
- const poller = new RecoverDeletedSecretPoller({
2988
- name,
2989
- client: this.client,
2990
- ...options,
2991
- operationOptions: options
2992
- });
2993
- await poller.poll();
2994
- return poller;
2995
- }
2996
- /**
2997
- * Requests that a backup of the specified secret be downloaded to the client. All versions of the
2998
- * secret will be downloaded. This operation requires the secrets/backup permission.
2999
- *
3000
- * Example usage:
3001
- * ```ts snippet:ReadmeSampleBackupSecret
3002
- * import { DefaultAzureCredential } from "@azure/identity";
3003
- * import { SecretClient } from "@azure/keyvault-secrets";
3004
- *
3005
- * const credential = new DefaultAzureCredential();
3006
- *
3007
- * const vaultName = "<YOUR KEYVAULT NAME>";
3008
- * const url = `https://${vaultName}.vault.azure.net`;
3009
- *
3010
- * const client = new SecretClient(url, credential);
3011
- *
3012
- * const secretName = "MySecretName";
3013
- *
3014
- * const backupResult = await client.backupSecret(secretName);
3015
- * ```
3016
- * Backs up the specified secret.
3017
- * @param secretName - The name of the secret.
3018
- * @param options - The optional parameters.
3019
- */
3020
- backupSecret(secretName, options = {}) {
3021
- return tracingClient.withSpan("SecretClient.backupSecret", options, async (updatedOptions) => {
3022
- return (await this.client.backupSecret(secretName, updatedOptions)).value;
3023
- });
3024
- }
3025
- /**
3026
- * Restores a backed up secret, and all its versions, to a vault. This operation requires the
3027
- * secrets/restore permission.
3028
- *
3029
- * Example usage:
3030
- * ```ts snippet:ReadmeSampleRestoreSecret
3031
- * import { DefaultAzureCredential } from "@azure/identity";
3032
- * import { SecretClient } from "@azure/keyvault-secrets";
3033
- *
3034
- * const credential = new DefaultAzureCredential();
3035
- *
3036
- * const vaultName = "<YOUR KEYVAULT NAME>";
3037
- * const url = `https://${vaultName}.vault.azure.net`;
3038
- *
3039
- * const client = new SecretClient(url, credential);
3040
- *
3041
- * const secretName = "MySecretName";
3042
- *
3043
- * const backupResult = await client.backupSecret(secretName);
3044
- *
3045
- * await client.restoreSecretBackup(backupResult);
3046
- * ```
3047
- * Restores a backed up secret to a vault.
3048
- * @param secretBundleBackup - The backup blob associated with a secret bundle.
3049
- * @param options - The optional parameters.
3050
- */
3051
- restoreSecretBackup(secretBundleBackup, options = {}) {
3052
- return tracingClient.withSpan("SecretClient.restoreSecretBackup", options, async (updatedOptions) => {
3053
- return getSecretFromSecretBundle(await this.client.restoreSecret({ secretBundleBackup }, updatedOptions)).properties;
3054
- });
3055
- }
3056
- /**
3057
- * Iterates all versions of the given secret in the vault. The full secret identifier and attributes are provided
3058
- * in the response. No values are returned for the secrets. This operations requires the secrets/list permission.
3059
- *
3060
- * Example usage:
3061
- * ```ts snippet:ReadmeSampleListSecrets
3062
- * import { DefaultAzureCredential } from "@azure/identity";
3063
- * import { SecretClient } from "@azure/keyvault-secrets";
3064
- *
3065
- * const credential = new DefaultAzureCredential();
3066
- *
3067
- * const vaultName = "<YOUR KEYVAULT NAME>";
3068
- * const url = `https://${vaultName}.vault.azure.net`;
3069
- *
3070
- * const client = new SecretClient(url, credential);
3071
- *
3072
- * const secretName = "MySecretName";
3073
- *
3074
- * for await (const secretProperties of client.listPropertiesOfSecrets()) {
3075
- * console.log("Secret properties: ", secretProperties);
3076
- * }
3077
- *
3078
- * for await (const deletedSecret of client.listDeletedSecrets()) {
3079
- * console.log("Deleted secret: ", deletedSecret);
3080
- * }
3081
- *
3082
- * for await (const versionProperties of client.listPropertiesOfSecretVersions(secretName)) {
3083
- * console.log("Version properties: ", versionProperties);
3084
- * }
3085
- * ```
3086
- * @param secretName - Name of the secret to fetch versions for.
3087
- * @param options - The optional parameters.
3088
- */
3089
- listPropertiesOfSecretVersions(secretName, options = {}) {
3090
- return mapPagedAsyncIterable((updatedOptions) => this.client.getSecretVersions(secretName, updatedOptions), options, (item) => getSecretFromSecretBundle(item).properties);
3091
- }
3092
- /**
3093
- * Iterates the latest version of all secrets in the vault. The full secret identifier and attributes are provided
3094
- * in the response. No values are returned for the secrets. This operations requires the secrets/list permission.
3095
- *
3096
- * Example usage:
3097
- * ```ts snippet:ReadmeSampleListSecrets
3098
- * import { DefaultAzureCredential } from "@azure/identity";
3099
- * import { SecretClient } from "@azure/keyvault-secrets";
3100
- *
3101
- * const credential = new DefaultAzureCredential();
3102
- *
3103
- * const vaultName = "<YOUR KEYVAULT NAME>";
3104
- * const url = `https://${vaultName}.vault.azure.net`;
3105
- *
3106
- * const client = new SecretClient(url, credential);
3107
- *
3108
- * const secretName = "MySecretName";
3109
- *
3110
- * for await (const secretProperties of client.listPropertiesOfSecrets()) {
3111
- * console.log("Secret properties: ", secretProperties);
3112
- * }
3113
- *
3114
- * for await (const deletedSecret of client.listDeletedSecrets()) {
3115
- * console.log("Deleted secret: ", deletedSecret);
3116
- * }
3117
- *
3118
- * for await (const versionProperties of client.listPropertiesOfSecretVersions(secretName)) {
3119
- * console.log("Version properties: ", versionProperties);
3120
- * }
3121
- * ```
3122
- * List all secrets in the vault.
3123
- * @param options - The optional parameters.
3124
- */
3125
- listPropertiesOfSecrets(options = {}) {
3126
- return mapPagedAsyncIterable(this.client.getSecrets.bind(this.client), options, (item) => getSecretFromSecretBundle(item).properties);
3127
- }
3128
- /**
3129
- * Iterates the deleted secrets in the vault. The full secret identifier and attributes are provided
3130
- * in the response. No values are returned for the secrets. This operations requires the secrets/list permission.
3131
- *
3132
- * Example usage:
3133
- * ```ts snippet:ReadmeSampleListSecrets
3134
- * import { DefaultAzureCredential } from "@azure/identity";
3135
- * import { SecretClient } from "@azure/keyvault-secrets";
3136
- *
3137
- * const credential = new DefaultAzureCredential();
3138
- *
3139
- * const vaultName = "<YOUR KEYVAULT NAME>";
3140
- * const url = `https://${vaultName}.vault.azure.net`;
3141
- *
3142
- * const client = new SecretClient(url, credential);
3143
- *
3144
- * const secretName = "MySecretName";
3145
- *
3146
- * for await (const secretProperties of client.listPropertiesOfSecrets()) {
3147
- * console.log("Secret properties: ", secretProperties);
3148
- * }
3149
- *
3150
- * for await (const deletedSecret of client.listDeletedSecrets()) {
3151
- * console.log("Deleted secret: ", deletedSecret);
3152
- * }
3153
- *
3154
- * for await (const versionProperties of client.listPropertiesOfSecretVersions(secretName)) {
3155
- * console.log("Version properties: ", versionProperties);
3156
- * }
3157
- * ```
3158
- * List all secrets in the vault.
3159
- * @param options - The optional parameters.
3160
- */
3161
- listDeletedSecrets(options = {}) {
3162
- return mapPagedAsyncIterable(this.client.getDeletedSecrets.bind(this.client), options, getSecretFromSecretBundle);
3163
- }
3164
- };
3165
- //#endregion
3166
- export { KnownContentType, KnownDeletionRecoveryLevel, SecretClient, logger, parseKeyVaultSecretIdentifier };