UNPKG

@eclipse-ditto/ditto-javascript-client-dom

Version:

DOM implementation of Eclipse Ditto JavaScript API to be used in browsers.

65 lines 2.24 kB
/*! * 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 */ import { AuthProvider, DittoHeaders, DittoURL } from './auth-provider'; /** * Basic authentication provider. */ export declare abstract class BasicAuth implements AuthProvider { readonly username: string; readonly password: string; readonly encoder: Base64Encoder; /** * Build a new instance for basic auth. * @param username - the username. * @param password - the password. * @param encoder - the encoder. */ constructor(username: string, password: string, encoder: Base64Encoder); /** * The string to encode. */ getStringToEncode(): string; /** * Encodes 'getStringToEncode()'. */ getEncodedAuthentication(): string; abstract authenticateWithUrl(originalUrl: DittoURL): DittoURL; abstract authenticateWithHeaders(originalHeaders: DittoHeaders): DittoHeaders; } /** * Encoder for Base64. */ export interface Base64Encoder { /** * Encode the string into base64. * @param toEncode - the string to encode. * @return the encoded string. */ encodeBase64(toEncode: string): string; } /** * HTTP implementation of basic auth using the Authorization HTTP header. */ export declare class HttpBasicAuth extends BasicAuth { protected constructor(username: string, password: string, encoder: Base64Encoder); /** * Create basic authentication for Http connections. * @param username - The username. * @param password - the password. * @param encoder - the encoder to use when encoding the authentication in Base64. */ static newInstance(username: string, password: string, encoder: Base64Encoder): BasicAuth; authenticateWithUrl(originalUrl: DittoURL): DittoURL; authenticateWithHeaders(originalHeaders: DittoHeaders): DittoHeaders; } //# sourceMappingURL=basic-auth.d.ts.map