UNPKG

@eclipse-ditto/ditto-javascript-client-node

Version:

Node.js(r) implementation of Eclipse Ditto JavaScript API.

77 lines 2.65 kB
"use strict"; /*! * Copyright (c) 2019 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0 * * SPDX-License-Identifier: EPL-2.0 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.NodeHttpBearerAuth = exports.NodeWebSocketBasicAuth = exports.NodeHttpBasicAuth = exports.NodeBase64Encoder = void 0; const basic_auth_1 = require("../../api/src/auth/basic-auth"); const bearer_auth_1 = require("../../api/src/auth/bearer-auth"); /** * Node implementation of base64 encoding. */ class NodeBase64Encoder { encodeBase64(toEncode) { return Buffer.from(toEncode).toString('base64'); } } exports.NodeBase64Encoder = NodeBase64Encoder; /** * Node implementation of basic auth for HTTP connections. */ class NodeHttpBasicAuth extends basic_auth_1.HttpBasicAuth { constructor(username, password, encoder) { super(username, password, encoder); } /** * Create basic authentication for HTTP connections. * @param username - The username. * @param password - the password. */ static newInstance(username, password) { return new NodeHttpBasicAuth(username, password, new NodeBase64Encoder()); } } exports.NodeHttpBasicAuth = NodeHttpBasicAuth; /** * Node implementation of basic auth for WebSocket connections. */ class NodeWebSocketBasicAuth extends basic_auth_1.HttpBasicAuth { constructor(username, password, encoder) { super(username, password, encoder); } /** * Create basic authentication for WebSocket connections. * @param username - The username. * @param password - the password. */ static newInstance(username, password) { return new NodeWebSocketBasicAuth(username, password, new NodeBase64Encoder()); } } exports.NodeWebSocketBasicAuth = NodeWebSocketBasicAuth; /** * Node implementation of basic auth for HTTP connections */ class NodeHttpBearerAuth extends bearer_auth_1.HttpBearerAuth { constructor(tokenSupplier) { super(tokenSupplier); } /** * Create bearer token AuthProvider for HTTP connections * @param tokenSupplier Provides auth tokens to this AuthProvider when needed */ static newInstance(tokenSupplier) { return new NodeHttpBearerAuth(tokenSupplier); } } exports.NodeHttpBearerAuth = NodeHttpBearerAuth; //# sourceMappingURL=node-auth.js.map