@azure/keyvault-certificates 4.4.0-beta.2 → 4.4.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.
- package/CHANGELOG.md +7 -1
- package/README.md +14 -11
- package/dist/index.js +286 -153
- package/dist/index.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/certificatesModels.js +42 -2
- package/dist-esm/keyvault-certificates/src/certificatesModels.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/constants.js +1 -1
- package/dist-esm/keyvault-certificates/src/constants.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/generated/keyVaultClient.js +1 -1
- package/dist-esm/keyvault-certificates/src/generated/keyVaultClient.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/generated/keyVaultClientContext.js +6 -7
- package/dist-esm/keyvault-certificates/src/generated/keyVaultClientContext.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/generated/models/index.js +55 -1
- package/dist-esm/keyvault-certificates/src/generated/models/index.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/identifier.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/index.js +27 -23
- package/dist-esm/keyvault-certificates/src/index.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/lro/create/operation.js +2 -2
- package/dist-esm/keyvault-certificates/src/lro/create/operation.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/lro/create/poller.js +2 -2
- package/dist-esm/keyvault-certificates/src/lro/create/poller.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/lro/delete/operation.js +1 -1
- package/dist-esm/keyvault-certificates/src/lro/delete/operation.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/lro/delete/poller.js +2 -2
- package/dist-esm/keyvault-certificates/src/lro/delete/poller.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/lro/keyVaultCertificatePoller.js +2 -2
- package/dist-esm/keyvault-certificates/src/lro/keyVaultCertificatePoller.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/lro/operation/operation.js +3 -3
- package/dist-esm/keyvault-certificates/src/lro/operation/operation.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/lro/operation/poller.js +2 -2
- package/dist-esm/keyvault-certificates/src/lro/operation/poller.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/lro/recover/operation.js +2 -2
- package/dist-esm/keyvault-certificates/src/lro/recover/operation.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/lro/recover/poller.js +3 -3
- package/dist-esm/keyvault-certificates/src/lro/recover/poller.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/transformations.js +23 -23
- package/dist-esm/keyvault-certificates/src/transformations.js.map +1 -1
- package/dist-esm/keyvault-certificates/src/utils.js.map +1 -1
- package/dist-esm/keyvault-common/src/challengeBasedAuthenticationPolicy.js +4 -4
- package/dist-esm/keyvault-common/src/challengeBasedAuthenticationPolicy.js.map +1 -1
- package/dist-esm/keyvault-common/src/parseKeyvaultIdentifier.js +1 -1
- package/dist-esm/keyvault-common/src/parseKeyvaultIdentifier.js.map +1 -1
- package/dist-esm/keyvault-common/src/parseWWWAuthenticate.js +1 -1
- package/dist-esm/keyvault-common/src/parseWWWAuthenticate.js.map +1 -1
- package/dist-esm/keyvault-common/src/tracingHelpers.js +4 -4
- package/dist-esm/keyvault-common/src/tracingHelpers.js.map +1 -1
- package/package.json +13 -28
- package/types/keyvault-certificates.d.ts +12 -8
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
|
-
import { cleanState, KeyVaultCertificatePollOperation } from "../keyVaultCertificatePoller";
|
|
4
|
-
import { getCertificateOperationFromCoreOperation, getCertificateWithPolicyFromCertificateBundle } from "../../transformations";
|
|
3
|
+
import { cleanState, KeyVaultCertificatePollOperation, } from "../keyVaultCertificatePoller";
|
|
4
|
+
import { getCertificateOperationFromCoreOperation, getCertificateWithPolicyFromCertificateBundle, } from "../../transformations";
|
|
5
5
|
import { createTraceFunction } from "../../../../keyvault-common/src";
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
@@ -91,7 +91,7 @@ export class CertificateOperationPollOperation extends KeyVaultCertificatePollOp
|
|
|
91
91
|
toString() {
|
|
92
92
|
const state = Object.assign({ certificateOperation: this.state.certificateOperation }, cleanState(this.state));
|
|
93
93
|
return JSON.stringify({
|
|
94
|
-
state
|
|
94
|
+
state,
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../../src/lro/operation/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAWlC,OAAO,EACL,UAAU,EACV,gCAAgC,
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../../src/lro/operation/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAWlC,OAAO,EACL,UAAU,EACV,gCAAgC,GAEjC,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EACL,wCAAwC,EACxC,6CAA6C,GAC9C,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE;;GAEG;AACH,MAAM,SAAS,GAAG,mBAAmB,CAAC,wDAAwD,CAAC,CAAC;AAahG;;;GAGG;AACH,MAAM,OAAO,iCAAkC,SAAQ,gCAGtD;IACC,YACS,KAAgC,EAC/B,QAAgB,EAChB,MAAsB,EACtB,mBAAqC,EAAE;QAE/C,KAAK,CAAC,KAAK,CAAC,CAAC;QALN,UAAK,GAAL,KAAK,CAA2B;QAC/B,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAgB;QACtB,qBAAgB,GAAhB,gBAAgB,CAAuB;IAGjD,CAAC;IAED;;OAEG;IACK,0BAA0B,CAChC,eAAuB,EACvB,UAA6C,EAAE;QAE/C,OAAO,SAAS,CAAC,4BAA4B,E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C,WAAW,CAAC;SACzD;QAED,KAAK,CAAC,oBAAoB,GAAG,MAAM,IAAI,CAAC,0BAA0B,CAChE,eAAe,EACf,IAAI,CAAC,gBAAgB,CACtB,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACI,QAAQ;QACb,MAAM,KAAK,mBACT,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,oBAAoB,IAClD,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAC1B,CAAC;QACF,OAAO,IAAI,CAAC,SAAS,CAAC;YACpB,KAAK;SACN,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignalLike, AbortSignal } from \"@azure/abort-controller\";\nimport { OperationOptions } from \"@azure/core-http\";\nimport {\n CancelCertificateOperationOptions,\n CertificateOperation,\n GetCertificateOptions,\n GetPlainCertificateOperationOptions,\n KeyVaultCertificateWithPolicy,\n} from \"../../certificatesModels\";\nimport {\n cleanState,\n KeyVaultCertificatePollOperation,\n KeyVaultCertificatePollOperationState,\n} from \"../keyVaultCertificatePoller\";\nimport { KeyVaultClient } from \"../../generated/keyVaultClient\";\nimport {\n getCertificateOperationFromCoreOperation,\n getCertificateWithPolicyFromCertificateBundle,\n} from \"../../transformations\";\nimport { createTraceFunction } from \"../../../../keyvault-common/src\";\n\n/**\n * @internal\n */\nconst withTrace = createTraceFunction(\"Azure.KeyVault.Certificates.CertificateOperationPoller\");\n\n/**\n * An interface representing the publicly available properties of the state of the CertificateOperationPoller.\n */\nexport interface CertificateOperationState\n extends KeyVaultCertificatePollOperationState<KeyVaultCertificateWithPolicy> {\n /**\n * The operation of the certificate\n */\n certificateOperation?: CertificateOperation;\n}\n\n/**\n * An interface representing the active operation of a certificate's creation,\n * which is represented locally as the \"operation\" of an active LRO Poller.\n */\nexport class CertificateOperationPollOperation extends KeyVaultCertificatePollOperation<\n CertificateOperationState,\n KeyVaultCertificateWithPolicy\n> {\n constructor(\n public state: CertificateOperationState,\n private vaultUrl: string,\n private client: KeyVaultClient,\n private operationOptions: OperationOptions = {}\n ) {\n super(state);\n }\n\n /**\n * Cancels a certificate creation operation that is already in progress. This operation requires the certificates/update permission.\n */\n private cancelCertificateOperation(\n certificateName: string,\n options: CancelCertificateOperationOptions = {}\n ): Promise<CertificateOperation> {\n return withTrace(\"cancelCertificateOperation\", options, async (updatedOptions) => {\n const result = await this.client.updateCertificateOperation(\n this.vaultUrl,\n certificateName,\n true,\n updatedOptions\n );\n return getCertificateOperationFromCoreOperation(\n certificateName,\n this.vaultUrl,\n result._response.parsedBody\n );\n });\n }\n\n /**\n * Gets the latest information available from a specific certificate, including the certificate's policy. This operation requires the certificates/get permission.\n */\n private getCertificate(\n certificateName: string,\n options: GetCertificateOptions = {}\n ): Promise<KeyVaultCertificateWithPolicy> {\n return withTrace(\"getCertificate\", options, async (updatedOptions) => {\n const result = await this.client.getCertificate(\n this.vaultUrl,\n certificateName,\n \"\",\n updatedOptions\n );\n return getCertificateWithPolicyFromCertificateBundle(result);\n });\n }\n\n /**\n * Gets the certificate operation.\n */\n private getPlainCertificateOperation(\n certificateName: string,\n options: GetPlainCertificateOperationOptions = {}\n ): Promise<CertificateOperation> {\n return withTrace(\"getPlainCertificateOperation\", options, async (updatedOptions) => {\n const result = await this.client.getCertificateOperation(\n this.vaultUrl,\n certificateName,\n updatedOptions\n );\n return getCertificateOperationFromCoreOperation(\n certificateName,\n this.vaultUrl,\n result._response.parsedBody\n );\n });\n }\n\n /**\n * Reaches to the service and updates the poll operation.\n */\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: CertificateOperationState) => void;\n } = {}\n ): Promise<CertificateOperationPollOperation> {\n const state = this.state;\n const certificateName = state.certificateName!;\n\n if (options.abortSignal) {\n this.operationOptions.abortSignal = options.abortSignal;\n }\n\n if (!state.isStarted) {\n state.isStarted = true;\n state.result = await this.getCertificate(certificateName, this.operationOptions);\n state.certificateOperation = await this.getPlainCertificateOperation(\n certificateName,\n this.operationOptions\n );\n } else if (!state.isCompleted) {\n state.certificateOperation = await this.getPlainCertificateOperation(\n certificateName,\n this.operationOptions\n );\n }\n\n if (state.certificateOperation && state.certificateOperation.status !== \"inProgress\") {\n state.isCompleted = true;\n state.result = await this.getCertificate(certificateName, this.operationOptions);\n if (state.certificateOperation.error) {\n state.error = new Error(state.certificateOperation.error.message);\n }\n }\n\n return this;\n }\n\n /**\n * Reaches to the service and cancels the certificate's operation, also updating the poll operation.\n */\n async cancel(\n this: CertificateOperationPollOperation,\n options: { abortSignal?: AbortSignal } = {}\n ): Promise<CertificateOperationPollOperation> {\n const state = this.state;\n const certificateName = state.certificateName!;\n\n if (options.abortSignal) {\n this.operationOptions.abortSignal = options.abortSignal;\n }\n\n state.certificateOperation = await this.cancelCertificateOperation(\n certificateName,\n this.operationOptions\n );\n\n this.state.isCancelled = true;\n return this;\n }\n\n /**\n * Serializes the certificate's poll operation\n */\n public toString(): string {\n const state: CertificateOperationState = {\n certificateOperation: this.state.certificateOperation,\n ...cleanState(this.state),\n };\n return JSON.stringify({\n state,\n });\n }\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
import { CertificateOperationPollOperation } from "./operation";
|
|
4
|
-
import { KeyVaultCertificatePoller, cleanState } from "../keyVaultCertificatePoller";
|
|
4
|
+
import { KeyVaultCertificatePoller, cleanState, } from "../keyVaultCertificatePoller";
|
|
5
5
|
/**
|
|
6
6
|
* Class that creates a poller that waits until a certificate finishes being created
|
|
7
7
|
*/
|
|
8
8
|
export class CertificateOperationPoller extends KeyVaultCertificatePoller {
|
|
9
9
|
constructor(options) {
|
|
10
|
-
const { vaultUrl, client, certificateName, operationOptions, intervalInMs = 2000, resumeFrom } = options;
|
|
10
|
+
const { vaultUrl, client, certificateName, operationOptions, intervalInMs = 2000, resumeFrom, } = options;
|
|
11
11
|
let state;
|
|
12
12
|
if (resumeFrom) {
|
|
13
13
|
state = JSON.parse(resumeFrom).state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../../../src/lro/operation/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,iCAAiC,EAA6B,MAAM,aAAa,CAAC;AAE3F,OAAO,EACL,yBAAyB,EAEzB,UAAU,
|
|
1
|
+
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../../../src/lro/operation/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,iCAAiC,EAA6B,MAAM,aAAa,CAAC;AAE3F,OAAO,EACL,yBAAyB,EAEzB,UAAU,GACX,MAAM,8BAA8B,CAAC;AAItC;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,yBAG/C;IACC,YAAY,OAA0C;QACpD,MAAM,EACJ,QAAQ,EACR,MAAM,EACN,eAAe,EACf,gBAAgB,EAChB,YAAY,GAAG,IAAI,EACnB,UAAU,GACX,GAAG,OAAO,CAAC;QAEZ,IAAI,KAA4C,CAAC;QAEjD,IAAI,UAAU,EAAE;YACd,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC;SACtC;QAED,MAAM,SAAS,GAAG,IAAI,iCAAiC,iCAEhD,KAAK,KACR,eAAe,KAEjB,QAAQ,EACR,MAAM,EACN,gBAAgB,CACjB,CAAC;QAEF,KAAK,CAAC,SAAS,CAAC,CAAC;QAEjB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;OAEG;IACI,iBAAiB;QACtB,uCACK,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KACnC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,oBAAoB,IAC/D;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CertificateOperationPollOperation, CertificateOperationState } from \"./operation\";\nimport { KeyVaultCertificateWithPolicy } from \"../../certificatesModels\";\nimport {\n KeyVaultCertificatePoller,\n KeyVaultCertificatePollerOptions,\n cleanState,\n} from \"../keyVaultCertificatePoller\";\n\nexport interface CertificateOperationPollerOptions extends KeyVaultCertificatePollerOptions {}\n\n/**\n * Class that creates a poller that waits until a certificate finishes being created\n */\nexport class CertificateOperationPoller extends KeyVaultCertificatePoller<\n CertificateOperationState,\n KeyVaultCertificateWithPolicy\n> {\n constructor(options: CertificateOperationPollerOptions) {\n const {\n vaultUrl,\n client,\n certificateName,\n operationOptions,\n intervalInMs = 2000,\n resumeFrom,\n } = options;\n\n let state: CertificateOperationState | undefined;\n\n if (resumeFrom) {\n state = JSON.parse(resumeFrom).state;\n }\n\n const operation = new CertificateOperationPollOperation(\n {\n ...state,\n certificateName,\n },\n vaultUrl,\n client,\n operationOptions\n );\n\n super(operation);\n\n this.intervalInMs = intervalInMs;\n }\n\n /**\n * Gets the public state of the polling operation\n */\n public getOperationState(): CertificateOperationState {\n return {\n ...cleanState(this.operation.state),\n certificateOperation: this.operation.state.certificateOperation,\n };\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
import { createTraceFunction } from "../../../../keyvault-common/src";
|
|
4
4
|
import { getCertificateWithPolicyFromCertificateBundle } from "../../transformations";
|
|
5
|
-
import { KeyVaultCertificatePollOperation } from "../keyVaultCertificatePoller";
|
|
5
|
+
import { KeyVaultCertificatePollOperation, } from "../keyVaultCertificatePoller";
|
|
6
6
|
/**
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
@@ -13,7 +13,7 @@ const withTrace = createTraceFunction("Azure.KeyVault.Certificates.RecoverDelete
|
|
|
13
13
|
export class RecoverDeletedCertificatePollOperation extends KeyVaultCertificatePollOperation {
|
|
14
14
|
constructor(state, vaultUrl, client, operationOptions = {}) {
|
|
15
15
|
super(state, {
|
|
16
|
-
cancelMessage: "Canceling the recovery of a deleted certificate is not supported."
|
|
16
|
+
cancelMessage: "Canceling the recovery of a deleted certificate is not supported.",
|
|
17
17
|
});
|
|
18
18
|
this.state = state;
|
|
19
19
|
this.vaultUrl = vaultUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../../src/lro/recover/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAOtE,OAAO,EAAE,6CAA6C,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EACL,gCAAgC,
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../../../src/lro/recover/operation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAOtE,OAAO,EAAE,6CAA6C,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,EACL,gCAAgC,GAEjC,MAAM,8BAA8B,CAAC;AAEtC;;GAEG;AACH,MAAM,SAAS,GAAG,mBAAmB,CACnC,6DAA6D,CAC9D,CAAC;AAQF;;GAEG;AACH,MAAM,OAAO,sCAAuC,SAAQ,gCAG3D;IACC,YACS,KAAqC,EACpC,QAAgB,EAChB,MAAsB,EACtB,mBAAqC,EAAE;QAE/C,KAAK,CAAC,KAAK,EAAE;YACX,aAAa,EAAE,mEAAmE;SACnF,CAAC,CAAC;QAPI,UAAK,GAAL,KAAK,CAAgC;QACpC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAgB;QACtB,qBAAgB,GAAhB,gBAAgB,CAAuB;IAKjD,CAAC;IAED;;OAE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KAAK,CAAC,WAAW,EAAE;gBACtB,KAAK,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;gBAC5F,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC;aACxB;SACF;QAED,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;YACtB,IAAI;gBACF,KAAK,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;gBACjF,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;aAC1B;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,KAAK,CAAC,UAAU,KAAK,GAAG,EAAE;oBAC5B,6EAA6E;oBAC7E,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;iBAC1B;qBAAM,IAAI,KAAK,CAAC,UAAU,KAAK,GAAG,EAAE;oBACnC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;oBACpB,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;oBACzB,MAAM,KAAK,CAAC;iBACb;aACF;SACF;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { OperationOptions } from \"@azure/core-http\";\nimport { createTraceFunction } from \"../../../../keyvault-common/src\";\nimport {\n GetCertificateOptions,\n KeyVaultCertificateWithPolicy,\n RecoverDeletedCertificateOptions,\n} from \"../../certificatesModels\";\nimport { KeyVaultClient } from \"../../generated/keyVaultClient\";\nimport { getCertificateWithPolicyFromCertificateBundle } from \"../../transformations\";\nimport {\n KeyVaultCertificatePollOperation,\n KeyVaultCertificatePollOperationState,\n} from \"../keyVaultCertificatePoller\";\n\n/**\n * @internal\n */\nconst withTrace = createTraceFunction(\n \"Azure.KeyVault.Certificates.RecoverDeletedCertificatePoller\"\n);\n\n/**\n * Deprecated: Public representation of the recovery of a deleted certificate poll operation\n */\nexport type RecoverDeletedCertificateState =\n KeyVaultCertificatePollOperationState<KeyVaultCertificateWithPolicy>;\n\n/**\n * An interface representing the recovery of a deleted certificate's poll operation\n */\nexport class RecoverDeletedCertificatePollOperation extends KeyVaultCertificatePollOperation<\n RecoverDeletedCertificateState,\n KeyVaultCertificateWithPolicy\n> {\n constructor(\n public state: RecoverDeletedCertificateState,\n private vaultUrl: string,\n private client: KeyVaultClient,\n private operationOptions: OperationOptions = {}\n ) {\n super(state, {\n cancelMessage: \"Canceling the recovery of a deleted certificate is not supported.\",\n });\n }\n\n /**\n * Gets the latest information available from a specific certificate, including the certificate's policy. This operation requires the certificates/get permission.\n */\n private getCertificate(\n certificateName: string,\n options: GetCertificateOptions = {}\n ): Promise<KeyVaultCertificateWithPolicy> {\n return withTrace(\"getCertificate\", options, async (updatedOptions) => {\n const result = await this.client.getCertificate(\n this.vaultUrl,\n certificateName,\n \"\",\n updatedOptions\n );\n return getCertificateWithPolicyFromCertificateBundle(result);\n });\n }\n\n /**\n * Recovers the deleted certificate in the specified vault. This operation can only be performed on a soft-delete enabled vault. This operation\n * requires the certificate/recover permission.\n */\n private recoverDeletedCertificate(\n certificateName: string,\n options: RecoverDeletedCertificateOptions = {}\n ): Promise<KeyVaultCertificateWithPolicy> {\n return withTrace(\"recoverDeletedCertificate\", options, async (updatedOptions) => {\n const result = await this.client.recoverDeletedCertificate(\n this.vaultUrl,\n certificateName,\n updatedOptions\n );\n return getCertificateWithPolicyFromCertificateBundle(result._response.parsedBody);\n });\n }\n\n /**\n * Reaches to the service and updates the poll operation.\n */\n async update(\n options: {\n abortSignal?: AbortSignalLike;\n fireProgress?: (state: RecoverDeletedCertificateState) => void;\n } = {}\n ): Promise<RecoverDeletedCertificatePollOperation> {\n const state = this.state;\n const { certificateName } = state;\n\n if (options.abortSignal) {\n this.operationOptions.abortSignal = options.abortSignal;\n }\n\n if (!state.isStarted) {\n try {\n state.result = await this.getCertificate(certificateName, this.operationOptions);\n state.isCompleted = true;\n } catch (e) {\n // getCertificate will only work once the LRO is completed.\n }\n if (!state.isCompleted) {\n state.result = await this.recoverDeletedCertificate(certificateName, this.operationOptions);\n state.isStarted = true;\n }\n }\n\n if (!state.isCompleted) {\n try {\n state.result = await this.getCertificate(certificateName, this.operationOptions);\n state.isCompleted = true;\n } catch (error) {\n if (error.statusCode === 403) {\n // At this point, the resource exists but the user doesn't have access to it.\n state.isCompleted = true;\n } else if (error.statusCode !== 404) {\n state.error = error;\n state.isCompleted = true;\n throw error;\n }\n }\n }\n\n return this;\n }\n}\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
|
-
import { RecoverDeletedCertificatePollOperation } from "./operation";
|
|
4
|
-
import { KeyVaultCertificatePoller } from "../keyVaultCertificatePoller";
|
|
3
|
+
import { RecoverDeletedCertificatePollOperation, } from "./operation";
|
|
4
|
+
import { KeyVaultCertificatePoller, } from "../keyVaultCertificatePoller";
|
|
5
5
|
/**
|
|
6
6
|
* Class that creates a poller that waits until a deleted certificate is fully recovered.
|
|
7
7
|
*/
|
|
8
8
|
export class RecoverDeletedCertificatePoller extends KeyVaultCertificatePoller {
|
|
9
9
|
constructor(options) {
|
|
10
|
-
const { vaultUrl, client, certificateName, operationOptions, intervalInMs = 2000, resumeFrom } = options;
|
|
10
|
+
const { vaultUrl, client, certificateName, operationOptions, intervalInMs = 2000, resumeFrom, } = options;
|
|
11
11
|
let state;
|
|
12
12
|
if (resumeFrom) {
|
|
13
13
|
state = JSON.parse(resumeFrom).state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../../../src/lro/recover/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,sCAAsC,
|
|
1
|
+
{"version":3,"file":"poller.js","sourceRoot":"","sources":["../../../../../src/lro/recover/poller.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,sCAAsC,GAEvC,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,yBAAyB,GAE1B,MAAM,8BAA8B,CAAC;AAItC;;GAEG;AACH,MAAM,OAAO,+BAAgC,SAAQ,yBAGpD;IACC,YAAY,OAA+C;QACzD,MAAM,EACJ,QAAQ,EACR,MAAM,EACN,eAAe,EACf,gBAAgB,EAChB,YAAY,GAAG,IAAI,EACnB,UAAU,GACX,GAAG,OAAO,CAAC;QAEZ,IAAI,KAAiD,CAAC;QAEtD,IAAI,UAAU,EAAE;YACd,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC;SACtC;QAED,MAAM,SAAS,GAAG,IAAI,sCAAsC,iCAErD,KAAK,KACR,eAAe,KAEjB,QAAQ,EACR,MAAM,EACN,gBAAgB,CACjB,CAAC;QAEF,KAAK,CAAC,SAAS,CAAC,CAAC;QAEjB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n RecoverDeletedCertificatePollOperation,\n RecoverDeletedCertificateState,\n} from \"./operation\";\nimport { KeyVaultCertificateWithPolicy } from \"../../certificatesModels\";\nimport {\n KeyVaultCertificatePoller,\n KeyVaultCertificatePollerOptions,\n} from \"../keyVaultCertificatePoller\";\n\nexport interface RecoverDeletedCertificatePollerOptions extends KeyVaultCertificatePollerOptions {}\n\n/**\n * Class that creates a poller that waits until a deleted certificate is fully recovered.\n */\nexport class RecoverDeletedCertificatePoller extends KeyVaultCertificatePoller<\n RecoverDeletedCertificateState,\n KeyVaultCertificateWithPolicy\n> {\n constructor(options: RecoverDeletedCertificatePollerOptions) {\n const {\n vaultUrl,\n client,\n certificateName,\n operationOptions,\n intervalInMs = 2000,\n resumeFrom,\n } = options;\n\n let state: RecoverDeletedCertificateState | undefined;\n\n if (resumeFrom) {\n state = JSON.parse(resumeFrom).state;\n }\n\n const operation = new RecoverDeletedCertificatePollOperation(\n {\n ...state,\n certificateName,\n },\n vaultUrl,\n client,\n operationOptions\n );\n\n super(operation);\n\n this.intervalInMs = intervalInMs;\n }\n}\n"]}
|
|
@@ -8,7 +8,7 @@ export function toCoreAttributes(properties) {
|
|
|
8
8
|
notBefore: properties.notBefore,
|
|
9
9
|
expires: properties.expiresOn,
|
|
10
10
|
created: properties.createdOn,
|
|
11
|
-
updated: properties.updatedOn
|
|
11
|
+
updated: properties.updatedOn,
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
14
|
export function toCorePolicy(id, policy, attributes = {}) {
|
|
@@ -17,7 +17,7 @@ export function toCorePolicy(id, policy, attributes = {}) {
|
|
|
17
17
|
subjectAlternativeNames = {
|
|
18
18
|
emails: policy.subjectAlternativeNames.emails,
|
|
19
19
|
dnsNames: policy.subjectAlternativeNames.dnsNames,
|
|
20
|
-
upns: policy.subjectAlternativeNames.userPrincipalNames
|
|
20
|
+
upns: policy.subjectAlternativeNames.userPrincipalNames,
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
return {
|
|
@@ -27,8 +27,8 @@ export function toCorePolicy(id, policy, attributes = {}) {
|
|
|
27
27
|
action: { actionType: action.action },
|
|
28
28
|
trigger: {
|
|
29
29
|
lifetimePercentage: action.lifetimePercentage,
|
|
30
|
-
daysBeforeExpiry: action.daysBeforeExpiry
|
|
31
|
-
}
|
|
30
|
+
daysBeforeExpiry: action.daysBeforeExpiry,
|
|
31
|
+
},
|
|
32
32
|
}))
|
|
33
33
|
: undefined,
|
|
34
34
|
keyProperties: {
|
|
@@ -36,24 +36,24 @@ export function toCorePolicy(id, policy, attributes = {}) {
|
|
|
36
36
|
keySize: policy.keySize,
|
|
37
37
|
reuseKey: policy.reuseKey,
|
|
38
38
|
curve: policy.keyCurveName,
|
|
39
|
-
exportable: policy.exportable
|
|
39
|
+
exportable: policy.exportable,
|
|
40
40
|
},
|
|
41
41
|
secretProperties: {
|
|
42
|
-
contentType: policy.contentType
|
|
42
|
+
contentType: policy.contentType,
|
|
43
43
|
},
|
|
44
44
|
x509CertificateProperties: {
|
|
45
45
|
subject: policy.subject,
|
|
46
46
|
ekus: policy.enhancedKeyUsage,
|
|
47
47
|
subjectAlternativeNames,
|
|
48
48
|
keyUsage: policy.keyUsage,
|
|
49
|
-
validityInMonths: policy.validityInMonths
|
|
49
|
+
validityInMonths: policy.validityInMonths,
|
|
50
50
|
},
|
|
51
51
|
issuerParameters: {
|
|
52
52
|
name: policy.issuerName,
|
|
53
53
|
certificateType: policy.certificateType,
|
|
54
|
-
certificateTransparency: policy.certificateTransparency
|
|
54
|
+
certificateTransparency: policy.certificateTransparency,
|
|
55
55
|
},
|
|
56
|
-
attributes
|
|
56
|
+
attributes,
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
export function toPublicPolicy(policy = {}) {
|
|
@@ -78,7 +78,7 @@ export function toPublicPolicy(policy = {}) {
|
|
|
78
78
|
? policy.lifetimeActions.map((action) => ({
|
|
79
79
|
action: action.action ? action.action.actionType : undefined,
|
|
80
80
|
daysBeforeExpiry: action.trigger ? action.trigger.daysBeforeExpiry : undefined,
|
|
81
|
-
lifetimePercentage: action.trigger ? action.trigger.lifetimePercentage : undefined
|
|
81
|
+
lifetimePercentage: action.trigger ? action.trigger.lifetimePercentage : undefined,
|
|
82
82
|
}))
|
|
83
83
|
: undefined,
|
|
84
84
|
contentType: policy.secretProperties
|
|
@@ -88,7 +88,7 @@ export function toPublicPolicy(policy = {}) {
|
|
|
88
88
|
keyUsage: x509Properties.keyUsage,
|
|
89
89
|
validityInMonths: x509Properties.validityInMonths,
|
|
90
90
|
subject: x509Properties.subject,
|
|
91
|
-
subjectAlternativeNames: subjectAlternativeNames
|
|
91
|
+
subjectAlternativeNames: subjectAlternativeNames,
|
|
92
92
|
};
|
|
93
93
|
if (policy.attributes) {
|
|
94
94
|
certificatePolicy.enabled = policy.attributes.enabled;
|
|
@@ -119,7 +119,7 @@ export function toPublicIssuer(issuer = {}) {
|
|
|
119
119
|
password: issuer.credentials && issuer.credentials.password,
|
|
120
120
|
enabled: attributes.enabled,
|
|
121
121
|
createdOn: attributes.created,
|
|
122
|
-
updatedOn: attributes.updated
|
|
122
|
+
updatedOn: attributes.updated,
|
|
123
123
|
};
|
|
124
124
|
if (issuer.organizationDetails) {
|
|
125
125
|
publicIssuer.organizationId = issuer.organizationDetails.id;
|
|
@@ -128,7 +128,7 @@ export function toPublicIssuer(issuer = {}) {
|
|
|
128
128
|
email: x.emailAddress,
|
|
129
129
|
phone: x.phone,
|
|
130
130
|
firstName: x.firstName,
|
|
131
|
-
lastName: x.lastName
|
|
131
|
+
lastName: x.lastName,
|
|
132
132
|
}))
|
|
133
133
|
: undefined;
|
|
134
134
|
}
|
|
@@ -150,14 +150,14 @@ export function getCertificateFromCertificateBundle(certificateBundle) {
|
|
|
150
150
|
version: parsedId.version,
|
|
151
151
|
tags: certificateBundle.tags,
|
|
152
152
|
x509Thumbprint: certificateBundle.x509Thumbprint,
|
|
153
|
-
recoverableDays: attributes.recoverableDays
|
|
153
|
+
recoverableDays: attributes.recoverableDays,
|
|
154
154
|
};
|
|
155
155
|
return {
|
|
156
156
|
keyId: certificateBundle.kid,
|
|
157
157
|
secretId: certificateBundle.sid,
|
|
158
158
|
name: parsedId.name,
|
|
159
159
|
cer: certificateBundle.cer,
|
|
160
|
-
properties: abstractProperties
|
|
160
|
+
properties: abstractProperties,
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
export function getCertificateWithPolicyFromCertificateBundle(certificateBundle) {
|
|
@@ -177,7 +177,7 @@ export function getCertificateWithPolicyFromCertificateBundle(certificateBundle)
|
|
|
177
177
|
version: parsedId.version,
|
|
178
178
|
tags: certificateBundle.tags,
|
|
179
179
|
x509Thumbprint: certificateBundle.x509Thumbprint,
|
|
180
|
-
recoverableDays: attributes.recoverableDays
|
|
180
|
+
recoverableDays: attributes.recoverableDays,
|
|
181
181
|
};
|
|
182
182
|
return {
|
|
183
183
|
keyId: certificateBundle.kid,
|
|
@@ -185,7 +185,7 @@ export function getCertificateWithPolicyFromCertificateBundle(certificateBundle)
|
|
|
185
185
|
name: parsedId.name,
|
|
186
186
|
cer: certificateBundle.cer,
|
|
187
187
|
policy,
|
|
188
|
-
properties: abstractProperties
|
|
188
|
+
properties: abstractProperties,
|
|
189
189
|
};
|
|
190
190
|
}
|
|
191
191
|
export function getDeletedCertificateFromDeletedCertificateBundle(certificateBundle) {
|
|
@@ -200,7 +200,7 @@ export function getDeletedCertificateFromDeletedCertificateBundle(certificateBun
|
|
|
200
200
|
properties: certificate.properties,
|
|
201
201
|
recoveryId: certificateBundle.recoveryId,
|
|
202
202
|
scheduledPurgeDate: certificateBundle.scheduledPurgeDate,
|
|
203
|
-
deletedOn: certificateBundle.deletedDate
|
|
203
|
+
deletedOn: certificateBundle.deletedDate,
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
206
|
export function getDeletedCertificateFromItem(item) {
|
|
@@ -218,14 +218,14 @@ export function getDeletedCertificateFromItem(item) {
|
|
|
218
218
|
tags: item.tags,
|
|
219
219
|
x509Thumbprint: item.x509Thumbprint,
|
|
220
220
|
recoverableDays: (_a = item.attributes) === null || _a === void 0 ? void 0 : _a.recoverableDays,
|
|
221
|
-
recoveryLevel: (_b = item.attributes) === null || _b === void 0 ? void 0 : _b.recoveryLevel
|
|
221
|
+
recoveryLevel: (_b = item.attributes) === null || _b === void 0 ? void 0 : _b.recoveryLevel,
|
|
222
222
|
};
|
|
223
223
|
return {
|
|
224
224
|
deletedOn: item.deletedDate,
|
|
225
225
|
recoveryId: item.recoveryId,
|
|
226
226
|
scheduledPurgeDate: item.scheduledPurgeDate,
|
|
227
227
|
name: parsedId.name,
|
|
228
|
-
properties: abstractProperties
|
|
228
|
+
properties: abstractProperties,
|
|
229
229
|
};
|
|
230
230
|
}
|
|
231
231
|
function getCertificateOperationErrorFromErrorModel(error) {
|
|
@@ -233,7 +233,7 @@ function getCertificateOperationErrorFromErrorModel(error) {
|
|
|
233
233
|
return {
|
|
234
234
|
code: error.code,
|
|
235
235
|
innerError: getCertificateOperationErrorFromErrorModel(error.innerError),
|
|
236
|
-
message: error.message
|
|
236
|
+
message: error.message,
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
239
|
return undefined;
|
|
@@ -256,7 +256,7 @@ export function getCertificateOperationFromCoreOperation(certificateName, vaultU
|
|
|
256
256
|
status: operation.status,
|
|
257
257
|
statusDetails: operation.statusDetails,
|
|
258
258
|
target: operation.target,
|
|
259
|
-
vaultUrl: vaultUrl
|
|
259
|
+
vaultUrl: vaultUrl,
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
262
|
export function coreContactsToCertificateContacts(contacts) {
|
|
@@ -280,7 +280,7 @@ export function getPropertiesFromCertificateBundle(certificateBundle) {
|
|
|
280
280
|
version: parsedId.version,
|
|
281
281
|
tags: certificateBundle.tags,
|
|
282
282
|
x509Thumbprint: certificateBundle.x509Thumbprint,
|
|
283
|
-
recoverableDays: attributes.recoverableDays
|
|
283
|
+
recoverableDays: attributes.recoverableDays,
|
|
284
284
|
};
|
|
285
285
|
return abstractProperties;
|
|
286
286
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformations.js","sourceRoot":"","sources":["../../../src/transformations.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AA+BlC,OAAO,EAAE,kCAAkC,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,UAAU,gBAAgB,CAAC,UAAiC;IAChE,OAAO;QACL,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,OAAO,EAAE,UAAU,CAAC,SAAS;QAC7B,OAAO,EAAE,UAAU,CAAC,SAAS;QAC7B,OAAO,EAAE,UAAU,C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D,SAAS,EAAE,UAAU,CAAC,OAAO;QAC7B,SAAS,EAAE,UAAU,CAAC,OAAO;QAC7B,SAAS,EAAE,UAAU,CAAC,OAAO;QAC7B,EAAE,EAAE,iBAAiB,CAAC,EAAE;QACxB,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,IAAI,EAAE,iBAAiB,CAAC,IAAI;QAC5B,cAAc,EAAE,iBAAiB,CAAC,cAAc;QAChD,eAAe,EAAE,UAAU,CAAC,eAAe;KAC5C,CAAC;IAEF,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ArrayOneOrMore,\n CertificateContentType,\n CertificateOperation,\n CertificateIssuer,\n CertificatePolicy,\n CertificateProperties,\n DeletedCertificate,\n KeyVaultCertificate,\n KeyVaultCertificateWithPolicy,\n SubjectAlternativeNames,\n CertificateContact,\n CertificateOperationError\n} from \"./certificatesModels\";\nimport {\n CertificateAttributes,\n CertificateBundle,\n CertificatePolicy as CoreCertificatePolicy,\n DeletedCertificateBundle,\n DeletedCertificateItem,\n IssuerAttributes,\n IssuerBundle,\n SubjectAlternativeNames as CoreSubjectAlternativeNames,\n X509CertificateProperties,\n CertificateOperation as CoreCertificateOperation,\n Contacts as CoreContacts,\n JsonWebKeyType as CertificateKeyType,\n ErrorModel\n} from \"./generated/models\";\nimport { parseKeyVaultCertificateIdentifier } from \"./identifier\";\n\nexport function toCoreAttributes(properties: CertificateProperties): CertificateAttributes {\n return {\n recoveryLevel: properties.recoveryLevel,\n enabled: properties.enabled,\n notBefore: properties.notBefore,\n expires: properties.expiresOn,\n created: properties.createdOn,\n updated: properties.updatedOn\n };\n}\n\nexport function toCorePolicy(\n id: string | undefined,\n policy: CertificatePolicy,\n attributes: CertificateAttributes = {}\n): CoreCertificatePolicy {\n let subjectAlternativeNames: CoreSubjectAlternativeNames = {};\n if (policy.subjectAlternativeNames) {\n subjectAlternativeNames = {\n emails: policy.subjectAlternativeNames.emails,\n dnsNames: policy.subjectAlternativeNames.dnsNames,\n upns: policy.subjectAlternativeNames.userPrincipalNames\n };\n }\n\n return {\n id,\n lifetimeActions: policy.lifetimeActions\n ? policy.lifetimeActions.map((action) => ({\n action: { actionType: action.action },\n trigger: {\n lifetimePercentage: action.lifetimePercentage,\n daysBeforeExpiry: action.daysBeforeExpiry\n }\n }))\n : undefined,\n keyProperties: {\n keyType: policy.keyType,\n keySize: policy.keySize,\n reuseKey: policy.reuseKey,\n curve: policy.keyCurveName,\n exportable: policy.exportable\n },\n secretProperties: {\n contentType: policy.contentType\n },\n x509CertificateProperties: {\n subject: policy.subject,\n ekus: policy.enhancedKeyUsage,\n subjectAlternativeNames,\n keyUsage: policy.keyUsage,\n validityInMonths: policy.validityInMonths\n },\n issuerParameters: {\n name: policy.issuerName,\n certificateType: policy.certificateType,\n certificateTransparency: policy.certificateTransparency\n },\n attributes\n };\n}\n\nexport function toPublicPolicy(policy: CoreCertificatePolicy = {}): CertificatePolicy {\n let subjectAlternativeNames: SubjectAlternativeNames | undefined;\n const x509Properties: X509CertificateProperties = policy.x509CertificateProperties || {};\n\n if (policy.x509CertificateProperties) {\n if (x509Properties.subjectAlternativeNames) {\n const names = x509Properties.subjectAlternativeNames;\n if (names.emails && names.emails.length) {\n subjectAlternativeNames = {\n ...subjectAlternativeNames,\n emails: names.emails as ArrayOneOrMore<string>\n };\n }\n if (names.dnsNames && names.dnsNames.length) {\n subjectAlternativeNames = {\n ...subjectAlternativeNames,\n dnsNames: names.dnsNames as ArrayOneOrMore<string>\n };\n }\n if (names.upns && names.upns.length) {\n subjectAlternativeNames = {\n ...subjectAlternativeNames,\n userPrincipalNames: names.upns as ArrayOneOrMore<string>\n };\n }\n }\n }\n\n const certificatePolicy: CertificatePolicy = {\n lifetimeActions: policy.lifetimeActions\n ? policy.lifetimeActions.map((action) => ({\n action: action.action ? action.action.actionType : undefined,\n daysBeforeExpiry: action.trigger ? action.trigger.daysBeforeExpiry : undefined,\n lifetimePercentage: action.trigger ? action.trigger.lifetimePercentage : undefined\n }))\n : undefined,\n contentType: policy.secretProperties\n ? (policy.secretProperties.contentType as CertificateContentType)\n : undefined,\n enhancedKeyUsage: x509Properties.ekus,\n keyUsage: x509Properties.keyUsage,\n validityInMonths: x509Properties.validityInMonths,\n subject: x509Properties.subject,\n subjectAlternativeNames: subjectAlternativeNames!\n };\n\n if (policy.attributes) {\n certificatePolicy.enabled = policy.attributes.enabled;\n }\n\n if (policy.keyProperties) {\n certificatePolicy.keyType = policy.keyProperties.keyType as CertificateKeyType;\n certificatePolicy.keySize = policy.keyProperties.keySize;\n certificatePolicy.reuseKey = policy.keyProperties.reuseKey;\n certificatePolicy.keyCurveName = policy.keyProperties.curve;\n certificatePolicy.exportable = policy.keyProperties.exportable;\n }\n\n if (policy.issuerParameters) {\n certificatePolicy.issuerName = policy.issuerParameters && policy.issuerParameters.name;\n certificatePolicy.certificateType = policy.issuerParameters\n .certificateType as CertificateContentType;\n certificatePolicy.certificateTransparency = policy.issuerParameters.certificateTransparency;\n }\n\n return certificatePolicy;\n}\n\nexport function toPublicIssuer(issuer: IssuerBundle = {}): CertificateIssuer {\n const parsedId = parseKeyVaultCertificateIdentifier(issuer.id!);\n const attributes: IssuerAttributes = issuer.attributes || {};\n\n const publicIssuer: CertificateIssuer = {\n id: issuer.id,\n name: parsedId.name,\n provider: issuer.provider,\n accountId: issuer.credentials && issuer.credentials.accountId,\n password: issuer.credentials && issuer.credentials.password,\n enabled: attributes.enabled,\n createdOn: attributes.created,\n updatedOn: attributes.updated\n };\n\n if (issuer.organizationDetails) {\n publicIssuer.organizationId = issuer.organizationDetails.id;\n publicIssuer.administratorContacts = issuer.organizationDetails.adminDetails\n ? issuer.organizationDetails.adminDetails.map((x) => ({\n email: x.emailAddress,\n phone: x.phone,\n firstName: x.firstName,\n lastName: x.lastName\n }))\n : undefined;\n }\n return publicIssuer;\n}\n\nexport function getCertificateFromCertificateBundle(\n certificateBundle: CertificateBundle\n): KeyVaultCertificate {\n const parsedId = parseKeyVaultCertificateIdentifier(certificateBundle.id!);\n\n const attributes: CertificateAttributes = certificateBundle.attributes || {};\n\n const abstractProperties: CertificateProperties = {\n createdOn: attributes.created,\n updatedOn: attributes.updated,\n expiresOn: attributes.expires,\n id: certificateBundle.id,\n enabled: attributes.enabled,\n notBefore: attributes.notBefore,\n recoveryLevel: attributes.recoveryLevel,\n name: parsedId.name,\n vaultUrl: parsedId.vaultUrl,\n version: parsedId.version,\n tags: certificateBundle.tags,\n x509Thumbprint: certificateBundle.x509Thumbprint,\n recoverableDays: attributes.recoverableDays\n };\n\n return {\n keyId: certificateBundle.kid,\n secretId: certificateBundle.sid,\n name: parsedId.name,\n cer: certificateBundle.cer,\n properties: abstractProperties\n };\n}\n\nexport function getCertificateWithPolicyFromCertificateBundle(\n certificateBundle: CertificateBundle\n): KeyVaultCertificateWithPolicy {\n const parsedId = parseKeyVaultCertificateIdentifier(certificateBundle.id!);\n\n const attributes: CertificateAttributes = certificateBundle.attributes || {};\n const policy = toPublicPolicy(certificateBundle.policy || {});\n\n const abstractProperties: CertificateProperties = {\n createdOn: attributes.created,\n updatedOn: attributes.updated,\n expiresOn: attributes.expires,\n id: certificateBundle.id,\n enabled: attributes.enabled,\n notBefore: attributes.notBefore,\n recoveryLevel: attributes.recoveryLevel,\n name: parsedId.name,\n vaultUrl: parsedId.vaultUrl,\n version: parsedId.version,\n tags: certificateBundle.tags,\n x509Thumbprint: certificateBundle.x509Thumbprint,\n recoverableDays: attributes.recoverableDays\n };\n\n return {\n keyId: certificateBundle.kid,\n secretId: certificateBundle.sid,\n name: parsedId.name,\n cer: certificateBundle.cer,\n policy,\n properties: abstractProperties\n };\n}\n\nexport function getDeletedCertificateFromDeletedCertificateBundle(\n certificateBundle: DeletedCertificateBundle\n): DeletedCertificate {\n const certificate: KeyVaultCertificateWithPolicy = getCertificateWithPolicyFromCertificateBundle(\n certificateBundle\n );\n\n return {\n policy: certificate.policy,\n cer: certificate.cer,\n id: certificate.id,\n keyId: certificate.keyId,\n secretId: certificate.secretId,\n name: certificate.name,\n properties: certificate.properties,\n recoveryId: certificateBundle.recoveryId,\n scheduledPurgeDate: certificateBundle.scheduledPurgeDate,\n deletedOn: certificateBundle.deletedDate\n };\n}\n\nexport function getDeletedCertificateFromItem(item: DeletedCertificateItem): DeletedCertificate {\n const parsedId = parseKeyVaultCertificateIdentifier(item.id!);\n\n const attributes: any = item.attributes || {};\n\n const abstractProperties: CertificateProperties = {\n createdOn: attributes.created,\n updatedOn: attributes.updated,\n expiresOn: attributes.expires,\n\n vaultUrl: parsedId.vaultUrl,\n version: parsedId.version,\n name: parsedId.name,\n\n id: item.id,\n tags: item.tags,\n x509Thumbprint: item.x509Thumbprint,\n\n recoverableDays: item.attributes?.recoverableDays,\n recoveryLevel: item.attributes?.recoveryLevel\n };\n\n return {\n deletedOn: item.deletedDate,\n recoveryId: item.recoveryId,\n scheduledPurgeDate: item.scheduledPurgeDate,\n name: parsedId.name,\n properties: abstractProperties\n };\n}\n\nfunction getCertificateOperationErrorFromErrorModel(\n error?: ErrorModel | null\n): CertificateOperationError | undefined {\n if (error) {\n return {\n code: error.code,\n innerError: getCertificateOperationErrorFromErrorModel(error.innerError),\n message: error.message\n };\n }\n return undefined;\n}\n\nexport function getCertificateOperationFromCoreOperation(\n certificateName: string,\n vaultUrl: string,\n operation: CoreCertificateOperation\n): CertificateOperation {\n return {\n cancellationRequested: operation.cancellationRequested,\n name: certificateName,\n issuerName: operation.issuerParameters ? operation.issuerParameters.name : undefined,\n certificateTransparency: operation.issuerParameters\n ? operation.issuerParameters.certificateTransparency\n : undefined,\n certificateType: operation.issuerParameters\n ? operation.issuerParameters.certificateType\n : undefined,\n csr: operation.csr,\n error: getCertificateOperationErrorFromErrorModel(operation.error),\n id: operation.id,\n requestId: operation.requestId,\n status: operation.status,\n statusDetails: operation.statusDetails,\n target: operation.target,\n vaultUrl: vaultUrl\n };\n}\n\nexport function coreContactsToCertificateContacts(contacts: CoreContacts): CertificateContact[] {\n return contacts.contactList\n ? contacts.contactList.map(\n (x) => ({ email: x.emailAddress, phone: x.phone, name: x.name } as CertificateContact)\n )\n : [];\n}\n\nexport function getPropertiesFromCertificateBundle(\n certificateBundle: CertificateBundle\n): CertificateProperties {\n const parsedId = parseKeyVaultCertificateIdentifier(certificateBundle.id!);\n const attributes: CertificateAttributes = certificateBundle.attributes || {};\n\n const abstractProperties: CertificateProperties = {\n createdOn: attributes.created,\n updatedOn: attributes.updated,\n expiresOn: attributes.expires,\n id: certificateBundle.id,\n name: parsedId.name,\n enabled: attributes.enabled,\n notBefore: attributes.notBefore,\n recoveryLevel: attributes.recoveryLevel,\n vaultUrl: parsedId.vaultUrl,\n version: parsedId.version,\n tags: certificateBundle.tags,\n x509Thumbprint: certificateBundle.x509Thumbprint,\n recoverableDays: attributes.recoverableDays\n };\n\n return abstractProperties;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"transformations.js","sourceRoot":"","sources":["../../../src/transformations.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AA+BlC,OAAO,EAAE,kCAAkC,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,UAAU,gBAAgB,CAAC,UAAiC;IAChE,OAAO;QACL,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,OAAO,EAAE,UAAU,CAAC,SAAS;QAC7B,OAAO,EAAE,UAAU,CAAC,SAAS;QAC7B,OAAO,EAAE,UAAU,CAAC,SAAS;KAC9B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,EAAsB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B,SAAS,EAAE,UAAU,CAAC,OAAO;QAC7B,EAAE,EAAE,iBAAiB,CAAC,EAAE;QACxB,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,SAAS,EAAE,UAAU,CAAC,SAAS;QAC/B,aAAa,EAAE,UAAU,CAAC,aAAa;QACvC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,IAAI,EAAE,iBAAiB,CAAC,IAAI;QAC5B,cAAc,EAAE,iBAAiB,CAAC,cAAc;QAChD,eAAe,EAAE,UAAU,CAAC,eAAe;KAC5C,CAAC;IAEF,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ArrayOneOrMore,\n CertificateContentType,\n CertificateOperation,\n CertificateIssuer,\n CertificatePolicy,\n CertificateProperties,\n DeletedCertificate,\n KeyVaultCertificate,\n KeyVaultCertificateWithPolicy,\n SubjectAlternativeNames,\n CertificateContact,\n CertificateOperationError,\n} from \"./certificatesModels\";\nimport {\n CertificateAttributes,\n CertificateBundle,\n CertificatePolicy as CoreCertificatePolicy,\n DeletedCertificateBundle,\n DeletedCertificateItem,\n IssuerAttributes,\n IssuerBundle,\n SubjectAlternativeNames as CoreSubjectAlternativeNames,\n X509CertificateProperties,\n CertificateOperation as CoreCertificateOperation,\n Contacts as CoreContacts,\n JsonWebKeyType as CertificateKeyType,\n ErrorModel,\n} from \"./generated/models\";\nimport { parseKeyVaultCertificateIdentifier } from \"./identifier\";\n\nexport function toCoreAttributes(properties: CertificateProperties): CertificateAttributes {\n return {\n recoveryLevel: properties.recoveryLevel,\n enabled: properties.enabled,\n notBefore: properties.notBefore,\n expires: properties.expiresOn,\n created: properties.createdOn,\n updated: properties.updatedOn,\n };\n}\n\nexport function toCorePolicy(\n id: string | undefined,\n policy: CertificatePolicy,\n attributes: CertificateAttributes = {}\n): CoreCertificatePolicy {\n let subjectAlternativeNames: CoreSubjectAlternativeNames = {};\n if (policy.subjectAlternativeNames) {\n subjectAlternativeNames = {\n emails: policy.subjectAlternativeNames.emails,\n dnsNames: policy.subjectAlternativeNames.dnsNames,\n upns: policy.subjectAlternativeNames.userPrincipalNames,\n };\n }\n\n return {\n id,\n lifetimeActions: policy.lifetimeActions\n ? policy.lifetimeActions.map((action) => ({\n action: { actionType: action.action },\n trigger: {\n lifetimePercentage: action.lifetimePercentage,\n daysBeforeExpiry: action.daysBeforeExpiry,\n },\n }))\n : undefined,\n keyProperties: {\n keyType: policy.keyType,\n keySize: policy.keySize,\n reuseKey: policy.reuseKey,\n curve: policy.keyCurveName,\n exportable: policy.exportable,\n },\n secretProperties: {\n contentType: policy.contentType,\n },\n x509CertificateProperties: {\n subject: policy.subject,\n ekus: policy.enhancedKeyUsage,\n subjectAlternativeNames,\n keyUsage: policy.keyUsage,\n validityInMonths: policy.validityInMonths,\n },\n issuerParameters: {\n name: policy.issuerName,\n certificateType: policy.certificateType,\n certificateTransparency: policy.certificateTransparency,\n },\n attributes,\n };\n}\n\nexport function toPublicPolicy(policy: CoreCertificatePolicy = {}): CertificatePolicy {\n let subjectAlternativeNames: SubjectAlternativeNames | undefined;\n const x509Properties: X509CertificateProperties = policy.x509CertificateProperties || {};\n\n if (policy.x509CertificateProperties) {\n if (x509Properties.subjectAlternativeNames) {\n const names = x509Properties.subjectAlternativeNames;\n if (names.emails && names.emails.length) {\n subjectAlternativeNames = {\n ...subjectAlternativeNames,\n emails: names.emails as ArrayOneOrMore<string>,\n };\n }\n if (names.dnsNames && names.dnsNames.length) {\n subjectAlternativeNames = {\n ...subjectAlternativeNames,\n dnsNames: names.dnsNames as ArrayOneOrMore<string>,\n };\n }\n if (names.upns && names.upns.length) {\n subjectAlternativeNames = {\n ...subjectAlternativeNames,\n userPrincipalNames: names.upns as ArrayOneOrMore<string>,\n };\n }\n }\n }\n\n const certificatePolicy: CertificatePolicy = {\n lifetimeActions: policy.lifetimeActions\n ? policy.lifetimeActions.map((action) => ({\n action: action.action ? action.action.actionType : undefined,\n daysBeforeExpiry: action.trigger ? action.trigger.daysBeforeExpiry : undefined,\n lifetimePercentage: action.trigger ? action.trigger.lifetimePercentage : undefined,\n }))\n : undefined,\n contentType: policy.secretProperties\n ? (policy.secretProperties.contentType as CertificateContentType)\n : undefined,\n enhancedKeyUsage: x509Properties.ekus,\n keyUsage: x509Properties.keyUsage,\n validityInMonths: x509Properties.validityInMonths,\n subject: x509Properties.subject,\n subjectAlternativeNames: subjectAlternativeNames!,\n };\n\n if (policy.attributes) {\n certificatePolicy.enabled = policy.attributes.enabled;\n }\n\n if (policy.keyProperties) {\n certificatePolicy.keyType = policy.keyProperties.keyType as CertificateKeyType;\n certificatePolicy.keySize = policy.keyProperties.keySize;\n certificatePolicy.reuseKey = policy.keyProperties.reuseKey;\n certificatePolicy.keyCurveName = policy.keyProperties.curve;\n certificatePolicy.exportable = policy.keyProperties.exportable;\n }\n\n if (policy.issuerParameters) {\n certificatePolicy.issuerName = policy.issuerParameters && policy.issuerParameters.name;\n certificatePolicy.certificateType = policy.issuerParameters\n .certificateType as CertificateContentType;\n certificatePolicy.certificateTransparency = policy.issuerParameters.certificateTransparency;\n }\n\n return certificatePolicy;\n}\n\nexport function toPublicIssuer(issuer: IssuerBundle = {}): CertificateIssuer {\n const parsedId = parseKeyVaultCertificateIdentifier(issuer.id!);\n const attributes: IssuerAttributes = issuer.attributes || {};\n\n const publicIssuer: CertificateIssuer = {\n id: issuer.id,\n name: parsedId.name,\n provider: issuer.provider,\n accountId: issuer.credentials && issuer.credentials.accountId,\n password: issuer.credentials && issuer.credentials.password,\n enabled: attributes.enabled,\n createdOn: attributes.created,\n updatedOn: attributes.updated,\n };\n\n if (issuer.organizationDetails) {\n publicIssuer.organizationId = issuer.organizationDetails.id;\n publicIssuer.administratorContacts = issuer.organizationDetails.adminDetails\n ? issuer.organizationDetails.adminDetails.map((x) => ({\n email: x.emailAddress,\n phone: x.phone,\n firstName: x.firstName,\n lastName: x.lastName,\n }))\n : undefined;\n }\n return publicIssuer;\n}\n\nexport function getCertificateFromCertificateBundle(\n certificateBundle: CertificateBundle\n): KeyVaultCertificate {\n const parsedId = parseKeyVaultCertificateIdentifier(certificateBundle.id!);\n\n const attributes: CertificateAttributes = certificateBundle.attributes || {};\n\n const abstractProperties: CertificateProperties = {\n createdOn: attributes.created,\n updatedOn: attributes.updated,\n expiresOn: attributes.expires,\n id: certificateBundle.id,\n enabled: attributes.enabled,\n notBefore: attributes.notBefore,\n recoveryLevel: attributes.recoveryLevel,\n name: parsedId.name,\n vaultUrl: parsedId.vaultUrl,\n version: parsedId.version,\n tags: certificateBundle.tags,\n x509Thumbprint: certificateBundle.x509Thumbprint,\n recoverableDays: attributes.recoverableDays,\n };\n\n return {\n keyId: certificateBundle.kid,\n secretId: certificateBundle.sid,\n name: parsedId.name,\n cer: certificateBundle.cer,\n properties: abstractProperties,\n };\n}\n\nexport function getCertificateWithPolicyFromCertificateBundle(\n certificateBundle: CertificateBundle\n): KeyVaultCertificateWithPolicy {\n const parsedId = parseKeyVaultCertificateIdentifier(certificateBundle.id!);\n\n const attributes: CertificateAttributes = certificateBundle.attributes || {};\n const policy = toPublicPolicy(certificateBundle.policy || {});\n\n const abstractProperties: CertificateProperties = {\n createdOn: attributes.created,\n updatedOn: attributes.updated,\n expiresOn: attributes.expires,\n id: certificateBundle.id,\n enabled: attributes.enabled,\n notBefore: attributes.notBefore,\n recoveryLevel: attributes.recoveryLevel,\n name: parsedId.name,\n vaultUrl: parsedId.vaultUrl,\n version: parsedId.version,\n tags: certificateBundle.tags,\n x509Thumbprint: certificateBundle.x509Thumbprint,\n recoverableDays: attributes.recoverableDays,\n };\n\n return {\n keyId: certificateBundle.kid,\n secretId: certificateBundle.sid,\n name: parsedId.name,\n cer: certificateBundle.cer,\n policy,\n properties: abstractProperties,\n };\n}\n\nexport function getDeletedCertificateFromDeletedCertificateBundle(\n certificateBundle: DeletedCertificateBundle\n): DeletedCertificate {\n const certificate: KeyVaultCertificateWithPolicy =\n getCertificateWithPolicyFromCertificateBundle(certificateBundle);\n\n return {\n policy: certificate.policy,\n cer: certificate.cer,\n id: certificate.id,\n keyId: certificate.keyId,\n secretId: certificate.secretId,\n name: certificate.name,\n properties: certificate.properties,\n recoveryId: certificateBundle.recoveryId,\n scheduledPurgeDate: certificateBundle.scheduledPurgeDate,\n deletedOn: certificateBundle.deletedDate,\n };\n}\n\nexport function getDeletedCertificateFromItem(item: DeletedCertificateItem): DeletedCertificate {\n const parsedId = parseKeyVaultCertificateIdentifier(item.id!);\n\n const attributes: any = item.attributes || {};\n\n const abstractProperties: CertificateProperties = {\n createdOn: attributes.created,\n updatedOn: attributes.updated,\n expiresOn: attributes.expires,\n\n vaultUrl: parsedId.vaultUrl,\n version: parsedId.version,\n name: parsedId.name,\n\n id: item.id,\n tags: item.tags,\n x509Thumbprint: item.x509Thumbprint,\n\n recoverableDays: item.attributes?.recoverableDays,\n recoveryLevel: item.attributes?.recoveryLevel,\n };\n\n return {\n deletedOn: item.deletedDate,\n recoveryId: item.recoveryId,\n scheduledPurgeDate: item.scheduledPurgeDate,\n name: parsedId.name,\n properties: abstractProperties,\n };\n}\n\nfunction getCertificateOperationErrorFromErrorModel(\n error?: ErrorModel | null\n): CertificateOperationError | undefined {\n if (error) {\n return {\n code: error.code,\n innerError: getCertificateOperationErrorFromErrorModel(error.innerError),\n message: error.message,\n };\n }\n return undefined;\n}\n\nexport function getCertificateOperationFromCoreOperation(\n certificateName: string,\n vaultUrl: string,\n operation: CoreCertificateOperation\n): CertificateOperation {\n return {\n cancellationRequested: operation.cancellationRequested,\n name: certificateName,\n issuerName: operation.issuerParameters ? operation.issuerParameters.name : undefined,\n certificateTransparency: operation.issuerParameters\n ? operation.issuerParameters.certificateTransparency\n : undefined,\n certificateType: operation.issuerParameters\n ? operation.issuerParameters.certificateType\n : undefined,\n csr: operation.csr,\n error: getCertificateOperationErrorFromErrorModel(operation.error),\n id: operation.id,\n requestId: operation.requestId,\n status: operation.status,\n statusDetails: operation.statusDetails,\n target: operation.target,\n vaultUrl: vaultUrl,\n };\n}\n\nexport function coreContactsToCertificateContacts(contacts: CoreContacts): CertificateContact[] {\n return contacts.contactList\n ? contacts.contactList.map(\n (x) => ({ email: x.emailAddress, phone: x.phone, name: x.name } as CertificateContact)\n )\n : [];\n}\n\nexport function getPropertiesFromCertificateBundle(\n certificateBundle: CertificateBundle\n): CertificateProperties {\n const parsedId = parseKeyVaultCertificateIdentifier(certificateBundle.id!);\n const attributes: CertificateAttributes = certificateBundle.attributes || {};\n\n const abstractProperties: CertificateProperties = {\n createdOn: attributes.created,\n updatedOn: attributes.updated,\n expiresOn: attributes.expires,\n id: certificateBundle.id,\n name: parsedId.name,\n enabled: attributes.enabled,\n notBefore: attributes.notBefore,\n recoveryLevel: attributes.recoveryLevel,\n vaultUrl: parsedId.vaultUrl,\n version: parsedId.version,\n tags: certificateBundle.tags,\n x509Thumbprint: certificateBundle.x509Thumbprint,\n recoverableDays: attributes.recoverableDays,\n };\n\n return abstractProperties;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAiB;IACxC,IAAI,MAAM,EAAE;QACV,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KAC9C;SAAM;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE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,EAAE;QAC5C,iEAAiE;QACjE,OAAO,OAAO,CAAC,gBAAgB,CAAC,CAAC;KAClC;SAAM;QACL,OAAO,QAAQ,CAAC,gBAAgB,CAAC,CAAC;KACnC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isNode } from \"@azure/core-http\";\nimport { CertificateContentType } from \"./certificatesModels\";\n\n/**\n * Decodes a Uint8Array into a Base64 string.\n * @internal\n */\nexport function toBase64(bytes: Uint8Array): string {\n if (isNode) {\n return Buffer.from(bytes).toString(\"base64\");\n } else {\n return btoa(String.fromCharCode.apply(null, bytes as any as number[]));\n }\n}\n\n/**\n * Decodes a Uint8Array into an ASCII string.\n * @internal\n */\nexport function toAscii(bytes: Uint8Array): string {\n if (isNode) {\n return Buffer.from(bytes).toString(\"ascii\");\n } else {\n return new TextDecoder(\"ascii\").decode(bytes);\n }\n}\n\n/**\n * Encodes a JavaScript string into a Uint8Array.\n * @internal\n */\nexport function stringToUint8Array(value: string): Uint8Array {\n if (isNode) {\n return Buffer.from(value);\n } else {\n return new TextEncoder().encode(value);\n }\n}\n\n/**\n * Encodes a Base64 string into a Uint8Array.\n * @internal\n */\nexport function base64ToUint8Array(value: string): Uint8Array {\n if (isNode) {\n return Buffer.from(value, \"base64\");\n } else {\n return Uint8Array.from(atob(value), (c) => c.charCodeAt(0));\n }\n}\n\n/**\n * Parses the PFX or ASCII PEM formatted value of the certificate containing both the X.509 certificates and the private key\n * into a Base64 encoded string.\n *\n * @internal\n * @param certificateBytes - The PFX or ASCII PEM formatted value of the certificate containing both the X.509 certificates and the private key\n * @param contentType - \"application/x-pem-file\", \"application/x-pkcs12\" or undefined\n */\nexport function parseCertificateBytes(\n certificateBytes: Uint8Array,\n contentType: CertificateContentType\n): string {\n if (contentType === \"application/x-pem-file\") {\n // PEM files have the certificate bytes already Base64 formatted.\n return toAscii(certificateBytes);\n } else {\n return toBase64(certificateBytes);\n }\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
/* eslint-disable @azure/azure-sdk/ts-use-interface-parameters */
|
|
4
|
-
import { BaseRequestPolicy } from "@azure/core-http";
|
|
5
|
-
import { Constants } from "@azure/core-http";
|
|
6
4
|
import { ExpiringAccessTokenCache } from "@azure/core-http";
|
|
5
|
+
import { BaseRequestPolicy, } from "@azure/core-http";
|
|
7
6
|
import { parseWWWAuthenticate } from "./parseWWWAuthenticate";
|
|
7
|
+
import { Constants } from "@azure/core-http";
|
|
8
8
|
/**
|
|
9
9
|
* Representation of the Authentication Challenge
|
|
10
10
|
*/
|
|
@@ -50,7 +50,7 @@ export function challengeBasedAuthenticationPolicy(credential) {
|
|
|
50
50
|
return {
|
|
51
51
|
create: (nextPolicy, options) => {
|
|
52
52
|
return new ChallengeBasedAuthenticationPolicy(nextPolicy, options, credential, tokenCache, challengeCache);
|
|
53
|
-
}
|
|
53
|
+
},
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
@@ -84,7 +84,7 @@ export class ChallengeBasedAuthenticationPolicy extends BaseRequestPolicy {
|
|
|
84
84
|
// If there's no cached token in the cache, we try to get a new one.
|
|
85
85
|
if (accessToken === undefined) {
|
|
86
86
|
const receivedToken = await this.credential.getToken(this.challengeCache.challenge.scope, {
|
|
87
|
-
tenantId: this.challengeCache.challenge.tenantId
|
|
87
|
+
tenantId: this.challengeCache.challenge.tenantId,
|
|
88
88
|
});
|
|
89
89
|
accessToken = receivedToken || undefined;
|
|
90
90
|
this.tokenCache.setCachedToken(accessToken);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"challengeBasedAuthenticationPolicy.js","sourceRoot":"","sources":["../../../../keyvault-common/src/challengeBasedAuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,iEAAiE;AAGjE,OAAO,EACL,iBAAiB,EAIlB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IAAI;gBACF,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;aAC5D;oBAAS;gBACR,WAAW,CAAC,IAAI,GAAG,YAAY,CAAC;aACjC;SACF;aAAM;YACL,wCAAwC;YACxC,kGAAkG;YAClG,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAClC,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;SAC5D;QAED,yDAAyD;QACzD,gGAAgG;QAChG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;YAC3B,OAAO,QAAQ,CAAC;SACjB;QAED,oGAAoG;QACpG,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QACjE,IAAI,CAAC,eAAe,EAAE;YACpB,OAAO,QAAQ,CAAC;SACjB;QAED,sEAAsE;QACtE,OAAO,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable @azure/azure-sdk/ts-use-interface-parameters */\n\nimport { TokenCredential } from \"@azure/core-http\";\nimport {\n BaseRequestPolicy,\n RequestPolicy,\n RequestPolicyOptions,\n RequestPolicyFactory\n} from \"@azure/core-http\";\nimport { Constants } from \"@azure/core-http\";\nimport { HttpOperationResponse } from \"@azure/core-http\";\nimport { WebResource } from \"@azure/core-http\";\nimport { AccessTokenCache, ExpiringAccessTokenCache } from \"@azure/core-http\";\nimport { parseWWWAuthenticate, ParsedWWWAuthenticate } from \"./parseWWWAuthenticate\";\n\n/**\n * Representation of the Authentication Challenge\n */\nexport class AuthenticationChallenge {\n constructor(public authorization: string, public scope: string, public tenantId?: string) {}\n\n /**\n * Checks that this AuthenticationChallenge is equal to another one given.\n * Only compares the scope.\n * This is exactly what C# is doing, as we can see here:\n * https://github.com/Azure/azure-sdk-for-net/blob/70e54b878ff1d01a45266fb3674a396b4ab9c1d2/sdk/keyvault/Azure.Security.KeyVault.Shared/src/ChallengeBasedAuthenticationPolicy.cs#L143-L147\n * @param other - The other AuthenticationChallenge\n */\n public equalTo(other: AuthenticationChallenge | undefined): boolean {\n return other\n ? this.scope.toLowerCase() === other.scope.toLowerCase() &&\n this.authorization.toLowerCase() === other.authorization.toLowerCase() &&\n this.tenantId?.toLowerCase() === other.tenantId?.toLowerCase()\n : false;\n }\n}\n\n/**\n * Helps keep a copy of any previous authentication challenges,\n * so that we can compare on any further request.\n */\nexport class AuthenticationChallengeCache {\n public challenge?: AuthenticationChallenge;\n\n public setCachedChallenge(challenge: AuthenticationChallenge): void {\n this.challenge = challenge;\n }\n}\n\n/**\n * Creates a new ChallengeBasedAuthenticationPolicy factory.\n *\n * @param credential - The TokenCredential implementation that can supply the challenge token.\n */\nexport function challengeBasedAuthenticationPolicy(\n credential: TokenCredential\n): RequestPolicyFactory {\n const tokenCache: AccessTokenCache = new ExpiringAccessTokenCache();\n const challengeCache = new AuthenticationChallengeCache();\n return {\n create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => {\n return new ChallengeBasedAuthenticationPolicy(\n nextPolicy,\n options,\n credential,\n tokenCache,\n challengeCache\n );\n }\n };\n}\n\n/**\n *\n * Provides a RequestPolicy that can request a token from a TokenCredential\n * implementation and then apply it to the Authorization header of a request\n * as a Bearer token.\n *\n */\nexport class ChallengeBasedAuthenticationPolicy extends BaseRequestPolicy {\n private parseWWWAuthenticate: (\n wwwAuthenticate: string\n ) => ParsedWWWAuthenticate = parseWWWAuthenticate;\n\n /**\n * Creates a new ChallengeBasedAuthenticationPolicy object.\n *\n * @param nextPolicy - The next RequestPolicy in the request pipeline.\n * @param options - Options for this RequestPolicy.\n * @param credential - The TokenCredential implementation that can supply the bearer token.\n * @param tokenCache - The cache for the most recent AccessToken returned by the TokenCredential.\n */\n constructor(\n nextPolicy: RequestPolicy,\n options: RequestPolicyOptions,\n private credential: TokenCredential,\n private tokenCache: AccessTokenCache,\n private challengeCache: AuthenticationChallengeCache\n ) {\n super(nextPolicy, options);\n }\n\n /**\n * Gets or updates the token from the token cache into the headers of the received web resource.\n */\n private async loadToken(webResource: WebResource): Promise<void> {\n let accessToken = this.tokenCache.getCachedToken();\n\n // If there's no cached token in the cache, we try to get a new one.\n if (accessToken === undefined) {\n const receivedToken = await this.credential.getToken(this.challengeCache.challenge!.scope, {\n tenantId: this.challengeCache.challenge!.tenantId\n });\n accessToken = receivedToken || undefined;\n this.tokenCache.setCachedToken(accessToken);\n }\n\n if (accessToken) {\n webResource.headers.set(\n Constants.HeaderConstants.AUTHORIZATION,\n `Bearer ${accessToken.token}`\n );\n }\n }\n\n /**\n * Parses the given WWW-Authenticate header, generates a new AuthenticationChallenge,\n * then if the challenge is different from the one cached, resets the token and forces\n * a re-authentication, otherwise continues with the existing challenge and token.\n * @param wwwAuthenticate - Value of the incoming WWW-Authenticate header.\n * @param webResource - Ongoing HTTP request.\n */\n private async regenerateChallenge(\n wwwAuthenticate: string,\n webResource: WebResource\n ): Promise<HttpOperationResponse> {\n // The challenge based authentication will contain both:\n // - An authorization URI with a token,\n // - The resource to which that token is valid against (also called the scope).\n const parsedWWWAuth = this.parseWWWAuthenticate(wwwAuthenticate);\n const authorization = parsedWWWAuth.authorization!;\n const resource = parsedWWWAuth.resource! || parsedWWWAuth.scope!;\n const tenantId = parsedWWWAuth.tenantId;\n\n if (!(authorization && resource)) {\n return this._nextPolicy.sendRequest(webResource);\n }\n\n const challenge = new AuthenticationChallenge(authorization, resource + \"/.default\", tenantId);\n\n // Either if there's no cached challenge at this point (could have happen in parallel),\n // or if the cached challenge has a different scope,\n // we store the just received challenge and reset the cached token, to force a re-authentication.\n if (!this.challengeCache.challenge?.equalTo(challenge)) {\n this.challengeCache.setCachedChallenge(challenge);\n this.tokenCache.setCachedToken(undefined);\n }\n\n await this.loadToken(webResource);\n return this._nextPolicy.sendRequest(webResource);\n }\n\n /**\n * Applies the Bearer token to the request through the Authorization header.\n * @param webResource - Ongoing HTTP request.\n */\n public async sendRequest(webResource: WebResource): Promise<HttpOperationResponse> {\n // Ensure that we're about to use a secure connection.\n if (!webResource.url.startsWith(\"https:\")) {\n throw new Error(\"The resource address for authorization must use the 'https' protocol.\");\n }\n\n // The next request will happen differently whether we have a challenge or not.\n let response: HttpOperationResponse;\n\n if (\n this.challengeCache.challenge === undefined ||\n this.challengeCache.challenge === undefined\n ) {\n // If there's no challenge in cache, a blank body will start the challenge.\n const originalBody = webResource.body;\n webResource.body = \"\";\n try {\n response = await this._nextPolicy.sendRequest(webResource);\n } finally {\n webResource.body = originalBody;\n }\n } else {\n // If we did have a challenge in memory,\n // we attempt to load the token from the cache into the request before we try to send the request.\n await this.loadToken(webResource);\n response = await this._nextPolicy.sendRequest(webResource);\n }\n\n // If we don't receive a response with a 401 status code,\n // then we can assume this response has nothing to do with the challenge authentication process.\n if (response.status !== 401) {\n return response;\n }\n\n // If the response status is 401, we only re-authenticate if the WWW-Authenticate header is present.\n const wwwAuthenticate = response.headers.get(\"WWW-Authenticate\");\n if (!wwwAuthenticate) {\n return response;\n }\n\n // We re-generate the challenge and see if we have to re-authenticate.\n return this.regenerateChallenge(wwwAuthenticate, webResource);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"challengeBasedAuthenticationPolicy.js","sourceRoot":"","sources":["../../../../keyvault-common/src/challengeBasedAuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,iEAAiE;AAEjE,OAAO,EAAoB,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EACL,iBAAiB,GAIlB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAyB,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAK7C;;GAEG;AACH,MAAM,OAAO,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AS,CAAC,WAAW,CAAC,CAAC;YAClC,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;SAC5D;QAED,yDAAyD;QACzD,gGAAgG;QAChG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;YAC3B,OAAO,QAAQ,CAAC;SACjB;QAED,oGAAoG;QACpG,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QACjE,IAAI,CAAC,eAAe,EAAE;YACpB,OAAO,QAAQ,CAAC;SACjB;QAED,sEAAsE;QACtE,OAAO,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable @azure/azure-sdk/ts-use-interface-parameters */\n\nimport { AccessTokenCache, ExpiringAccessTokenCache } from \"@azure/core-http\";\nimport {\n BaseRequestPolicy,\n RequestPolicy,\n RequestPolicyFactory,\n RequestPolicyOptions,\n} from \"@azure/core-http\";\nimport { ParsedWWWAuthenticate, parseWWWAuthenticate } from \"./parseWWWAuthenticate\";\nimport { Constants } from \"@azure/core-http\";\nimport { HttpOperationResponse } from \"@azure/core-http\";\nimport { TokenCredential } from \"@azure/core-http\";\nimport { WebResource } from \"@azure/core-http\";\n\n/**\n * Representation of the Authentication Challenge\n */\nexport class AuthenticationChallenge {\n constructor(public authorization: string, public scope: string, public tenantId?: string) {}\n\n /**\n * Checks that this AuthenticationChallenge is equal to another one given.\n * Only compares the scope.\n * This is exactly what C# is doing, as we can see here:\n * https://github.com/Azure/azure-sdk-for-net/blob/70e54b878ff1d01a45266fb3674a396b4ab9c1d2/sdk/keyvault/Azure.Security.KeyVault.Shared/src/ChallengeBasedAuthenticationPolicy.cs#L143-L147\n * @param other - The other AuthenticationChallenge\n */\n public equalTo(other: AuthenticationChallenge | undefined): boolean {\n return other\n ? this.scope.toLowerCase() === other.scope.toLowerCase() &&\n this.authorization.toLowerCase() === other.authorization.toLowerCase() &&\n this.tenantId?.toLowerCase() === other.tenantId?.toLowerCase()\n : false;\n }\n}\n\n/**\n * Helps keep a copy of any previous authentication challenges,\n * so that we can compare on any further request.\n */\nexport class AuthenticationChallengeCache {\n public challenge?: AuthenticationChallenge;\n\n public setCachedChallenge(challenge: AuthenticationChallenge): void {\n this.challenge = challenge;\n }\n}\n\n/**\n * Creates a new ChallengeBasedAuthenticationPolicy factory.\n *\n * @param credential - The TokenCredential implementation that can supply the challenge token.\n */\nexport function challengeBasedAuthenticationPolicy(\n credential: TokenCredential\n): RequestPolicyFactory {\n const tokenCache: AccessTokenCache = new ExpiringAccessTokenCache();\n const challengeCache = new AuthenticationChallengeCache();\n return {\n create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => {\n return new ChallengeBasedAuthenticationPolicy(\n nextPolicy,\n options,\n credential,\n tokenCache,\n challengeCache\n );\n },\n };\n}\n\n/**\n *\n * Provides a RequestPolicy that can request a token from a TokenCredential\n * implementation and then apply it to the Authorization header of a request\n * as a Bearer token.\n *\n */\nexport class ChallengeBasedAuthenticationPolicy extends BaseRequestPolicy {\n private parseWWWAuthenticate: (wwwAuthenticate: string) => ParsedWWWAuthenticate =\n parseWWWAuthenticate;\n\n /**\n * Creates a new ChallengeBasedAuthenticationPolicy object.\n *\n * @param nextPolicy - The next RequestPolicy in the request pipeline.\n * @param options - Options for this RequestPolicy.\n * @param credential - The TokenCredential implementation that can supply the bearer token.\n * @param tokenCache - The cache for the most recent AccessToken returned by the TokenCredential.\n */\n constructor(\n nextPolicy: RequestPolicy,\n options: RequestPolicyOptions,\n private credential: TokenCredential,\n private tokenCache: AccessTokenCache,\n private challengeCache: AuthenticationChallengeCache\n ) {\n super(nextPolicy, options);\n }\n\n /**\n * Gets or updates the token from the token cache into the headers of the received web resource.\n */\n private async loadToken(webResource: WebResource): Promise<void> {\n let accessToken = this.tokenCache.getCachedToken();\n\n // If there's no cached token in the cache, we try to get a new one.\n if (accessToken === undefined) {\n const receivedToken = await this.credential.getToken(this.challengeCache.challenge!.scope, {\n tenantId: this.challengeCache.challenge!.tenantId,\n });\n accessToken = receivedToken || undefined;\n this.tokenCache.setCachedToken(accessToken);\n }\n\n if (accessToken) {\n webResource.headers.set(\n Constants.HeaderConstants.AUTHORIZATION,\n `Bearer ${accessToken.token}`\n );\n }\n }\n\n /**\n * Parses the given WWW-Authenticate header, generates a new AuthenticationChallenge,\n * then if the challenge is different from the one cached, resets the token and forces\n * a re-authentication, otherwise continues with the existing challenge and token.\n * @param wwwAuthenticate - Value of the incoming WWW-Authenticate header.\n * @param webResource - Ongoing HTTP request.\n */\n private async regenerateChallenge(\n wwwAuthenticate: string,\n webResource: WebResource\n ): Promise<HttpOperationResponse> {\n // The challenge based authentication will contain both:\n // - An authorization URI with a token,\n // - The resource to which that token is valid against (also called the scope).\n const parsedWWWAuth = this.parseWWWAuthenticate(wwwAuthenticate);\n const authorization = parsedWWWAuth.authorization!;\n const resource = parsedWWWAuth.resource! || parsedWWWAuth.scope!;\n const tenantId = parsedWWWAuth.tenantId;\n\n if (!(authorization && resource)) {\n return this._nextPolicy.sendRequest(webResource);\n }\n\n const challenge = new AuthenticationChallenge(authorization, resource + \"/.default\", tenantId);\n\n // Either if there's no cached challenge at this point (could have happen in parallel),\n // or if the cached challenge has a different scope,\n // we store the just received challenge and reset the cached token, to force a re-authentication.\n if (!this.challengeCache.challenge?.equalTo(challenge)) {\n this.challengeCache.setCachedChallenge(challenge);\n this.tokenCache.setCachedToken(undefined);\n }\n\n await this.loadToken(webResource);\n return this._nextPolicy.sendRequest(webResource);\n }\n\n /**\n * Applies the Bearer token to the request through the Authorization header.\n * @param webResource - Ongoing HTTP request.\n */\n public async sendRequest(webResource: WebResource): Promise<HttpOperationResponse> {\n // Ensure that we're about to use a secure connection.\n if (!webResource.url.startsWith(\"https:\")) {\n throw new Error(\"The resource address for authorization must use the 'https' protocol.\");\n }\n\n // The next request will happen differently whether we have a challenge or not.\n let response: HttpOperationResponse;\n\n if (\n this.challengeCache.challenge === undefined ||\n this.challengeCache.challenge === undefined\n ) {\n // If there's no challenge in cache, a blank body will start the challenge.\n const originalBody = webResource.body;\n webResource.body = \"\";\n try {\n response = await this._nextPolicy.sendRequest(webResource);\n } finally {\n webResource.body = originalBody;\n }\n } else {\n // If we did have a challenge in memory,\n // we attempt to load the token from the cache into the request before we try to send the request.\n await this.loadToken(webResource);\n response = await this._nextPolicy.sendRequest(webResource);\n }\n\n // If we don't receive a response with a 401 status code,\n // then we can assume this response has nothing to do with the challenge authentication process.\n if (response.status !== 401) {\n return response;\n }\n\n // If the response status is 401, we only re-authenticate if the WWW-Authenticate header is present.\n const wwwAuthenticate = response.headers.get(\"WWW-Authenticate\");\n if (!wwwAuthenticate) {\n return response;\n }\n\n // We re-generate the challenge and see if we have to re-authenticate.\n return this.regenerateChallenge(wwwAuthenticate, webResource);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseKeyvaultIdentifier.js","sourceRoot":"","sources":["../../../../keyvault-common/src/parseKeyvaultIdentifier.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAgB3B,MAAM,UAAU,uBAAuB,CACrC,UAAkB,EAClB,UAA8B;IAE9B,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE;QACvE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAED,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE;QACvE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAED,IAAI,OAAO,CAAC;IACZ,IAAI;QACF,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;KAC7C;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,WAAW,UAAU,gBAAgB,UAAU,mBAAmB,CAAC,CAAC;KACrF;IAED,mDAAmD;IACnD,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAClD,MAAM,IAAI,KAAK,CACb,WAAW,UAAU,gBAAgB,UAAU,6BAA6B,QAAQ,CAAC,MAAM,EAAE,CAC9F,CAAC;KACH;IAED,IAAI,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE;QAC9B,MAAM,IAAI,KAAK,CACb,WAAW,UAAU,gBAAgB,UAAU,4BAA4B,UAAU,aAAa,QAAQ,CAAC,CAAC,CAAC,GAAG,CACjH,CAAC;KACH;IAED,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC;IACxD,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAChE,OAAO;QACL,QAAQ;QACR,IAAI;QACJ,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as url from \"url\";\n\nexport interface ParsedKeyVaultEntityIdentifier {\n /**\n * The vault URI.\n */\n vaultUrl: string;\n /**\n * The version of key/secret/certificate. May be undefined.\n */\n version?: string;\n /**\n * The name of key/secret/certificate.\n */\n name: string;\n}\nexport function parseKeyvaultIdentifier(\n collection: string,\n identifier: string | undefined\n): ParsedKeyVaultEntityIdentifier {\n if (typeof collection !== \"string\" || !(collection = collection.trim())) {\n throw new Error(\"Invalid collection argument\");\n }\n\n if (typeof identifier !== \"string\" || !(identifier = identifier.trim())) {\n throw new Error(\"Invalid identifier argument\");\n }\n\n let baseUri;\n try {\n baseUri = url.parse(identifier, true, true);\n } catch (e) {\n throw new Error(`Invalid ${collection} identifier: ${identifier}. Not a valid URI`);\n }\n\n // Path is of the form '/collection/name[/version]'\n const segments = (baseUri.pathname || \"\").split(\"/\");\n if (segments.length !== 3 && segments.length !== 4) {\n throw new Error(\n `Invalid ${collection} identifier: ${identifier}. Bad number of segments: ${segments.length}`\n );\n }\n\n if (collection !== segments[1]) {\n throw new Error(\n `Invalid ${collection} identifier: ${identifier}. segment [1] should be \"${collection}\", found \"${segments[1]}\"`\n );\n }\n\n const vaultUrl = `${baseUri.protocol}//${baseUri.host}`;\n const name = segments[2];\n const version = segments.length === 4 ? segments[3] : undefined;\n return {\n vaultUrl,\n name,\n version
|
|
1
|
+
{"version":3,"file":"parseKeyvaultIdentifier.js","sourceRoot":"","sources":["../../../../keyvault-common/src/parseKeyvaultIdentifier.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,GAAG,MAAM,KAAK,CAAC;AAgB3B,MAAM,UAAU,uBAAuB,CACrC,UAAkB,EAClB,UAA8B;IAE9B,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE;QACvE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAED,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,CAAC,UAAU,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,EAAE;QACvE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;KAChD;IAED,IAAI,OAAO,CAAC;IACZ,IAAI;QACF,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;KAC7C;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,WAAW,UAAU,gBAAgB,UAAU,mBAAmB,CAAC,CAAC;KACrF;IAED,mDAAmD;IACnD,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QAClD,MAAM,IAAI,KAAK,CACb,WAAW,UAAU,gBAAgB,UAAU,6BAA6B,QAAQ,CAAC,MAAM,EAAE,CAC9F,CAAC;KACH;IAED,IAAI,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE;QAC9B,MAAM,IAAI,KAAK,CACb,WAAW,UAAU,gBAAgB,UAAU,4BAA4B,UAAU,aAAa,QAAQ,CAAC,CAAC,CAAC,GAAG,CACjH,CAAC;KACH;IAED,MAAM,QAAQ,GAAG,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC;IACxD,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACzB,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAChE,OAAO;QACL,QAAQ;QACR,IAAI;QACJ,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as url from \"url\";\n\nexport interface ParsedKeyVaultEntityIdentifier {\n /**\n * The vault URI.\n */\n vaultUrl: string;\n /**\n * The version of key/secret/certificate. May be undefined.\n */\n version?: string;\n /**\n * The name of key/secret/certificate.\n */\n name: string;\n}\nexport function parseKeyvaultIdentifier(\n collection: string,\n identifier: string | undefined\n): ParsedKeyVaultEntityIdentifier {\n if (typeof collection !== \"string\" || !(collection = collection.trim())) {\n throw new Error(\"Invalid collection argument\");\n }\n\n if (typeof identifier !== \"string\" || !(identifier = identifier.trim())) {\n throw new Error(\"Invalid identifier argument\");\n }\n\n let baseUri;\n try {\n baseUri = url.parse(identifier, true, true);\n } catch (e) {\n throw new Error(`Invalid ${collection} identifier: ${identifier}. Not a valid URI`);\n }\n\n // Path is of the form '/collection/name[/version]'\n const segments = (baseUri.pathname || \"\").split(\"/\");\n if (segments.length !== 3 && segments.length !== 4) {\n throw new Error(\n `Invalid ${collection} identifier: ${identifier}. Bad number of segments: ${segments.length}`\n );\n }\n\n if (collection !== segments[1]) {\n throw new Error(\n `Invalid ${collection} identifier: ${identifier}. segment [1] should be \"${collection}\", found \"${segments[1]}\"`\n );\n }\n\n const vaultUrl = `${baseUri.protocol}//${baseUri.host}`;\n const name = segments[2];\n const version = segments.length === 4 ? segments[3] : undefined;\n return {\n vaultUrl,\n name,\n version,\n };\n}\n"]}
|