Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core AMQP cleanup for v2 #12210

Merged
merged 5 commits into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions sdk/core/core-amqp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,39 @@

- `AmqpAnnotatedMessage` interface that closely represents the AMQP annotated message from the [AMQP spec](https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format) has been added. New `AmqpMessageHeaders` and `AmqpMessageProperties` interfaces(properties with camelCasing) have been added in the place of re-exports from "rhea" library(properties with snake_casing).
[PR 12091](https://github.com/Azure/azure-sdk-for-js/pull/12091)
- `Message` from "rhea" library which was being exported as `AmqpMessage` is removed.
[PR 12169](https://github.com/Azure/azure-sdk-for-js/pull/12169)

### Breaking changes

We are cleaning the public API surface by

- removing exports that are either not used by either `@azure/event-hubs` and `@azure/service-bus` packages (which are the two main consumers of this package)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT

Suggested change
- removing exports that are either not used by either `@azure/event-hubs` and `@azure/service-bus` packages (which are the two main consumers of this package)
- removing exports that are neither used by `@azure/event-hubs` nor `@azure/service-bus` package (which are the two main consumers of this package)

- AsyncLockOptions
- executePromisesSequentially
- Func
- getNewAsyncLock
- isNode
- randomNumberFromInterval
- Timeout
- moving the clases/methods/interfaces that are very specific to Event Hubs/Service Bus to their corresponding packages.
- SharedKeyCredential
- As part of this move the `negotiateClaim()` method now takes the token string directly instead of the `AccessToken` object.
- EventHubConnectionConfig
- avoid re-exporting things from `rhea-promise` and `@azure/core-auth`
- Dictionary
- isAmqpError
- Message
- TokenCredential
- isTokenCredential
- AccessToken
- removing all IotHub related artifacts. These existed to support the IotHub support we had in Event Hubs v2 which has since been removed in Event Hubs v5 for a better separation of concerns
- IotHubConnectionConfig
- IotHubConnectionStringModel
- IotSharedKeyCredential
- isIotHubConnectionString
- removing all Event Hubs, Storage and Service Bus interfaces meant to be used with the `parseConnectionString()` method
- ServiceBusConnectionStringModel
- StorageConnectionStringModel
- EventHubsConnectionStringModel

## 1.1.7 (2020-10-28)

Expand Down
1 change: 0 additions & 1 deletion sdk/core/core-amqp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
},
"dependencies": {
"@azure/abort-controller": "^1.0.0",
"@azure/core-auth": "^1.1.3",
"@azure/logger": "^1.0.0",
"@types/async-lock": "^1.1.0",
"@types/is-buffer": "^2.0.0",
Expand Down
164 changes: 1 addition & 163 deletions sdk/core/core-amqp/review/core-amqp.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
```ts

import { AbortSignalLike } from '@azure/abort-controller';
import { AccessToken } from '@azure/core-auth';
import { AmqpError } from 'rhea-promise';
import AsyncLock from 'async-lock';
import { Connection } from 'rhea-promise';
import { Dictionary } from 'rhea-promise';
import { isAmqpError } from 'rhea-promise';
import { isTokenCredential } from '@azure/core-auth';
import { Message } from 'rhea-promise';
import { MessageHeader } from 'rhea-promise';
import { MessageProperties } from 'rhea-promise';
Expand All @@ -21,11 +17,8 @@ import { ReqResLink } from 'rhea-promise';
import { Sender } from 'rhea-promise';
import { SenderOptions } from 'rhea-promise';
import { Session } from 'rhea-promise';
import { TokenCredential } from '@azure/core-auth';
import { WebSocketImpl } from 'rhea-promise';

export { AccessToken }

// @public
export interface AmqpAnnotatedMessage {
applicationProperties?: {
Expand Down Expand Up @@ -90,14 +83,6 @@ export const AmqpMessageProperties: {

export { AsyncLock }

// @public
export interface AsyncLockOptions {
domainReentrant?: boolean;
maxPending?: number;
Promise?: any;
timeout?: number;
}

// @public
export class CbsClient {
constructor(connection: Connection, connectionLock: string);
Expand All @@ -107,7 +92,7 @@ export class CbsClient {
readonly connectionLock: string;
readonly endpoint: string;
init(): Promise<void>;
negotiateClaim(audience: string, tokenObject: AccessToken, tokenType: TokenType): Promise<CbsResponse>;
negotiateClaim(audience: string, token: string, tokenType: TokenType): Promise<CbsResponse>;
remove(): void;
readonly replyTo: string;
}
Expand Down Expand Up @@ -251,7 +236,6 @@ export interface ConnectionContextBase {
dataTransformer: DataTransformer;
negotiateClaimLock: string;
refreshConnection: () => void;
readonly tokenCredential: SharedKeyCredential | TokenCredential;
wasConnectionCloseCalled: boolean;
}

Expand Down Expand Up @@ -393,7 +377,6 @@ export interface CreateConnectionContextBaseParameters {
dataTransformer?: DataTransformer;
isEntityPathRequired?: boolean;
operationTimeoutInMs?: number;
tokenCredential?: SharedKeyCredential | TokenCredential;
}

// @public
Expand All @@ -414,8 +397,6 @@ export const defaultLock: AsyncLock;
// @public
export function delay<T>(delayInMs: number, abortSignal?: AbortSignalLike, abortErrorMsg?: string, value?: T): Promise<T>;

export { Dictionary }

// @public
export enum ErrorNameConditionMapper {
AddressAlreadyInUseError = "com.microsoft:address-already-in-use",
Expand Down Expand Up @@ -465,98 +446,12 @@ export enum ErrorNameConditionMapper {
UnauthorizedError = "amqp:unauthorized-access"
}

// @public
export interface EventHubConnectionConfig extends ConnectionConfig {
entityPath: string;
getManagementAddress(): string;
getManagementAudience(): string;
getReceiverAddress(partitionId: string | number, consumergroup?: string): string;
getReceiverAudience(partitionId: string | number, consumergroup?: string): string;
getSenderAddress(partitionId?: string | number): string;
getSenderAudience(partitionId?: string | number): string;
}

// @public
export const EventHubConnectionConfig: {
create(connectionString: string, path?: string | undefined): EventHubConnectionConfig;
createFromConnectionConfig(config: ConnectionConfig): EventHubConnectionConfig;
validate(config: EventHubConnectionConfig): void;
};

// @public
export interface EventHubConnectionStringModel {
// (undocumented)
[x: string]: any;
// (undocumented)
Endpoint: string;
// (undocumented)
EntityPath?: string;
// (undocumented)
SharedAccessKey: string;
// (undocumented)
SharedAccessKeyName: string;
}

// @public (undocumented)
export function executePromisesSequentially(promiseFactories: Array<any>, kickstart?: any): Promise<any>;

// @public
export type Func<T, V> = (a: T) => V;

// @public
export function getNewAsyncLock(options?: AsyncLockOptions): AsyncLock;

// @public (undocumented)
export interface IotHubConnectionConfig {
connectionString: string;
deviceId?: string;
entityPath: string;
host: string;
hostName: string;
sharedAccessKey: string;
sharedAccessKeyName: string;
}

// @public
export const IotHubConnectionConfig: {
create(connectionString: string, path?: string | undefined): IotHubConnectionConfig;
validate(config: IotHubConnectionConfig): void;
convertToEventHubConnectionConfig(iotHubConfig: IotHubConnectionConfig): EventHubConnectionConfig;
};

// @public
export interface IotHubConnectionStringModel {
// (undocumented)
DeviceId?: string;
// (undocumented)
HostName: string;
// (undocumented)
SharedAccessKey: string;
// (undocumented)
SharedAccessKeyName: string;
}

// @public
export class IotSharedKeyCredential extends SharedKeyCredential {
getToken(audience: string): AccessToken;
}

export { isAmqpError }

// @public
export function isIotHubConnectionString(connectionString: string): boolean;

// @public
export function isMessagingError(error: Error | MessagingError): error is MessagingError;

// @public
export const isNode: boolean;

// @public
export function isSystemError(err: any): err is NetworkSystemError;

export { isTokenCredential }

// @public
export const logger: import("@azure/logger").AzureLogger;

Expand Down Expand Up @@ -606,9 +501,6 @@ export type ParsedOutput<T> = {
[P in keyof T]: T[P];
};

// @public
export function randomNumberFromInterval(min: number, max: number): number;

// @public
export class RequestResponseLink implements ReqResLink {
constructor(session: Session, sender: Sender, receiver: Receiver);
Expand Down Expand Up @@ -686,44 +578,6 @@ export interface SendRequestOptions {
timeoutInMs?: number;
}

// @public
export interface ServiceBusConnectionStringModel {
// (undocumented)
[x: string]: any;
// (undocumented)
Endpoint: string;
// (undocumented)
EntityPath?: string;
// (undocumented)
SharedAccessKey: string;
// (undocumented)
SharedAccessKeyName: string;
}

// @public
export class SharedKeyCredential {
constructor(keyName: string, key: string);
protected _createToken(expiry: number, audience: string, hashInput?: string | Buffer): AccessToken;
static fromConnectionString(connectionString: string): SharedKeyCredential;
getToken(audience: string): AccessToken;
key: string;
keyName: string;
}

// @public
export interface StorageConnectionStringModel {
// (undocumented)
[x: string]: any;
// (undocumented)
AccountKey: string;
// (undocumented)
AccountName: string;
// (undocumented)
DefaultEndpointsProtocol: string;
// (undocumented)
EndpointSuffix: string;
}

// @public
export enum SystemErrorConditionMapper {
// (undocumented)
Expand All @@ -748,22 +602,6 @@ export enum SystemErrorConditionMapper {
ETIMEDOUT = "com.microsoft:timeout"
}

// @public
export class Timeout {
// (undocumented)
clear(): void;
// (undocumented)
set<T>(t: number, value?: T): Promise<T>;
// (undocumented)
static set<T>(t: number, value?: T): Promise<T>;
// (undocumented)
wrap<T>(promise: Promise<T>, t: number, value?: T): Promise<T>;
// (undocumented)
static wrap<T>(promise: Promise<T>, t: number, value?: T): Promise<T>;
}

export { TokenCredential }

// @public
export enum TokenType {
CbsTokenTypeJwt = "jwt",
Expand Down
18 changes: 0 additions & 18 deletions sdk/core/core-amqp/src/ConnectionContextBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import { Connection, ConnectionOptions, generate_uuid } from "rhea-promise";
import { CbsClient } from "./cbs";
import { DataTransformer, DefaultDataTransformer } from "./dataTransformer";
import { TokenCredential } from "@azure/core-auth";
import { ConnectionConfig } from "./connectionConfig/connectionConfig";
import { SharedKeyCredential } from "./auth/sas";

import { Constants } from "./util/constants";
import { getFrameworkInfo, getPlatformInfo } from "./util/runtimeInfo";
Expand All @@ -32,11 +30,6 @@ export interface ConnectionContextBase {
* acquire the lock for negotiating cbs claim by an entity on that connection.
*/
negotiateClaimLock: string;
/**
* @property {SharedKeyCredential | TokenCredential} tokenCredential The credential to be used for getting tokens
* for authentication for the EventHub client.
*/
readonly tokenCredential: SharedKeyCredential | TokenCredential;
/**
* @property {Connection} connection The underlying AMQP connection.
*/
Expand Down Expand Up @@ -102,11 +95,6 @@ export interface CreateConnectionContextBaseParameters {
* the AMQP connection.
*/
connectionProperties: ConnectionProperties;
/**
* @property {SharedKeyCredential | TokenCredential} [tokenCredential] The credential to be used for Authentication.
* Default value: SharedKeyCredentials.
*/
tokenCredential?: SharedKeyCredential | TokenCredential;
/**
* @property {DataTransformer} [dataTransformer] The datatransformer to be used for encoding and
* decoding messages. Default value: DefaultDataTransformer
Expand Down Expand Up @@ -190,12 +178,6 @@ export const ConnectionContextBase = {
connectionId: connection.id,
cbsSession: new CbsClient(connection, connectionLock),
config: parameters.config,
tokenCredential:
parameters.tokenCredential ||
new SharedKeyCredential(
parameters.config.sharedAccessKeyName,
parameters.config.sharedAccessKey
),
dataTransformer: parameters.dataTransformer || new DefaultDataTransformer(),
refreshConnection() {
const connection = new Connection(connectionOptions);
Expand Down
27 changes: 0 additions & 27 deletions sdk/core/core-amqp/src/auth/iotSas.ts

This file was deleted.

Loading