@uhuru/awsiot-thing-creator
Advanced tools
Comparing version 1.0.1-beta.35 to 1.0.1-beta.36
@@ -47,2 +47,3 @@ interface ConfigObject { | ||
private deleteThing; | ||
private removeCertificateFromThingAndDelete; | ||
removeThingCerts({ failOnEmpty }?: { | ||
@@ -49,0 +50,0 @@ failOnEmpty?: boolean; |
@@ -147,2 +147,34 @@ "use strict"; | ||
} | ||
removeCertificateFromThingAndDelete(principal) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const detachPolicyCmd = new client_iot_1.DetachPolicyCommand({ | ||
policyName: this.policyName, | ||
target: principal | ||
}); | ||
yield this.iotClient.send(detachPolicyCmd).catch((error) => { | ||
throw new Error(`Failed to detach policy ${this.policyName} from ${principal}, reason: ${error.message}`); | ||
}); | ||
const detachThingCmd = new client_iot_1.DetachThingPrincipalCommand({ | ||
principal: principal, | ||
thingName: this.thingName | ||
}); | ||
yield this.iotClient.send(detachThingCmd).catch((error) => { | ||
throw new Error(`Failed to detach AWS IoT thing. Please check your AWS IoT configuration, reason: ${error.message}`); | ||
}); | ||
const certificateId = principal.split('/')[1]; | ||
const updateCertCommand = new client_iot_1.UpdateCertificateCommand({ | ||
certificateId: certificateId, | ||
newStatus: 'INACTIVE' | ||
}); | ||
yield this.iotClient.send(updateCertCommand).catch((error) => { | ||
throw new Error(`Failed to update certificate ${certificateId}, reason: ${error.message}`); | ||
}); | ||
const deleteCertCommand = new client_iot_1.DeleteCertificateCommand({ | ||
certificateId | ||
}); | ||
yield this.iotClient.send(deleteCertCommand).catch((error) => { | ||
throw new Error(`Failed to delete certificate ${principal}, reason: ${error.message}`); | ||
}); | ||
}); | ||
} | ||
removeThingCerts({ failOnEmpty = true } = {}) { | ||
@@ -166,22 +198,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
for (const principal of principalsList) { | ||
const detachPolicyCmd = new client_iot_1.DetachPolicyCommand({ | ||
policyName: this.policyName, | ||
target: principal | ||
}); | ||
yield this.iotClient.send(detachPolicyCmd).catch((error) => { | ||
throw new Error(`Failed to detach policy ${this.policyName} from ${principal}, reason: ${error.message}`); | ||
}); | ||
const detachThingCmd = new client_iot_1.DetachThingPrincipalCommand({ | ||
principal: principal, | ||
thingName: this.thingName | ||
}); | ||
yield this.iotClient.send(detachThingCmd).catch((error) => { | ||
throw new Error(`Failed to detach AWS IoT thing. Please check your AWS IoT configuration, reason: ${error.message}`); | ||
}); | ||
const deleteCertCommand = new client_iot_1.DeleteCertificateCommand({ | ||
certificateId: principal.split('/')[1] | ||
}); | ||
yield this.iotClient.send(deleteCertCommand).catch((error) => { | ||
throw new Error(`Failed to delete certificate ${principal}, reason: ${error.message}`); | ||
}); | ||
yield this.removeCertificateFromThingAndDelete(principal); | ||
} | ||
@@ -188,0 +201,0 @@ }); |
{ | ||
"name": "@uhuru/awsiot-thing-creator", | ||
"version": "1.0.1-beta.35", | ||
"version": "1.0.1-beta.36", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
58133
680