UNPKG

aws-iot-device-sdk-v2

Version:
163 lines 7.04 kB
"use strict"; /* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. * * This file is generated */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.IotIdentityClientv2 = void 0; const aws_crt_1 = require("aws-crt"); const mqtt_request_response_utils = __importStar(require("../mqtt_request_response_utils")); const v2utils = __importStar(require("./v2utils")); /** * An AWS IoT service that assists with provisioning a device and installing unique client certificates on it * * AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html * * @category IotIdentity */ class IotIdentityClientv2 { constructor(rrClient) { this.rrClient = rrClient; this.serviceModel = v2utils.makeServiceModel(); } /** * Creates a new service client that will use an SDK MQTT 311 client as transport. * * @param protocolClient the MQTT 311 client to use for transport * @param options additional service client configuration options * * @return a new service client * */ static newFromMqtt311(protocolClient, options) { let rrClient = aws_crt_1.mqtt_request_response.RequestResponseClient.newFromMqtt311(protocolClient, options); return new IotIdentityClientv2(rrClient); } /** * Creates a new service client that will use an SDK MQTT 5 client as transport. * * @param protocolClient the MQTT 5 client to use for transport * @param options additional service client configuration options * * @return a new service client * */ static newFromMqtt5(protocolClient, options) { let rrClient = aws_crt_1.mqtt_request_response.RequestResponseClient.newFromMqtt5(protocolClient, options); return new IotIdentityClientv2(rrClient); } /** * Triggers cleanup of all resources associated with the service client. Closing a client will fail * all incomplete requests and close all unclosed streaming operations. * * This must be called when finished with a client; otherwise, native resources will leak. */ close() { this.rrClient.close(); } /** * Creates a certificate from a certificate signing request (CSR). AWS IoT provides client certificates that are signed by the Amazon Root certificate authority (CA). The new certificate has a PENDING_ACTIVATION status. When you call RegisterThing to provision a thing with this certificate, the certificate status changes to ACTIVE or INACTIVE as described in the template. * * * AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api * * @param request operation to perform * * @return Promise which resolves into the response to the request * * @category IotIdentity */ createCertificateFromCsr(request) { return __awaiter(this, void 0, void 0, function* () { let config = { operationName: "createCertificateFromCsr", serviceModel: this.serviceModel, client: this.rrClient, request: request }; return yield mqtt_request_response_utils.doRequestResponse(config); }); } /** * Creates new keys and a certificate. AWS IoT provides client certificates that are signed by the Amazon Root certificate authority (CA). The new certificate has a PENDING_ACTIVATION status. When you call RegisterThing to provision a thing with this certificate, the certificate status changes to ACTIVE or INACTIVE as described in the template. * * * AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api * * @param request operation to perform * * @return Promise which resolves into the response to the request * * @category IotIdentity */ createKeysAndCertificate(request) { return __awaiter(this, void 0, void 0, function* () { let config = { operationName: "createKeysAndCertificate", serviceModel: this.serviceModel, client: this.rrClient, request: request }; return yield mqtt_request_response_utils.doRequestResponse(config); }); } /** * Provisions an AWS IoT thing using a pre-defined template. * * * AWS documentation: https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html#fleet-provision-api * * @param request operation to perform * * @return Promise which resolves into the response to the request * * @category IotIdentity */ registerThing(request) { return __awaiter(this, void 0, void 0, function* () { let config = { operationName: "registerThing", serviceModel: this.serviceModel, client: this.rrClient, request: request }; return yield mqtt_request_response_utils.doRequestResponse(config); }); } } exports.IotIdentityClientv2 = IotIdentityClientv2; //# sourceMappingURL=iotidentityclientv2.js.map