@alienplatform/sdk 1.10.7 → 1.11.0

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