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

Renamed IdentityClientOptions->TokenCredentialOptions #5797

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 16 additions & 16 deletions sdk/identity/identity/review/identity.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export const AuthenticationErrorName = "AuthenticationError";

// @public
export class AuthorizationCodeCredential implements TokenCredential {
constructor(tenantId: string | "common", clientId: string, clientSecret: string, authorizationCode: string, redirectUri: string, options?: IdentityClientOptions);
constructor(tenantId: string | "common", clientId: string, authorizationCode: string, redirectUri: string, options?: IdentityClientOptions);
constructor(tenantId: string | "common", clientId: string, clientSecret: string, authorizationCode: string, redirectUri: string, options?: TokenCredentialOptions);
constructor(tenantId: string | "common", clientId: string, authorizationCode: string, redirectUri: string, options?: TokenCredentialOptions);
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
}

Expand All @@ -48,24 +48,24 @@ export class ChainedTokenCredential implements TokenCredential {

// @public
export class ClientCertificateCredential implements TokenCredential {
constructor(tenantId: string, clientId: string, certificatePath: string, options?: IdentityClientOptions);
constructor(tenantId: string, clientId: string, certificatePath: string, options?: TokenCredentialOptions);
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
}

// @public
export class ClientSecretCredential implements TokenCredential {
constructor(tenantId: string, clientId: string, clientSecret: string, options?: IdentityClientOptions);
constructor(tenantId: string, clientId: string, clientSecret: string, options?: TokenCredentialOptions);
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
}

// @public
export class DefaultAzureCredential extends ChainedTokenCredential {
constructor(identityClientOptions?: IdentityClientOptions);
constructor(tokenCredentialOptions?: TokenCredentialOptions);
}

// @public
export class DeviceCodeCredential implements TokenCredential {
constructor(tenantId: string | "organizations", clientId: string, userPromptCallback: DeviceCodePromptCallback, options?: IdentityClientOptions);
constructor(tenantId: string | "organizations", clientId: string, userPromptCallback: DeviceCodePromptCallback, options?: TokenCredentialOptions);
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
}

Expand All @@ -81,7 +81,7 @@ export type DeviceCodePromptCallback = (deviceCodeInfo: DeviceCodeInfo) => void;

// @public
export class EnvironmentCredential implements TokenCredential {
constructor(options?: IdentityClientOptions);
constructor(options?: TokenCredentialOptions);
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
}

Expand All @@ -100,19 +100,14 @@ export function getDefaultAzureCredential(): TokenCredential;

export { GetTokenOptions }

// @public
export interface IdentityClientOptions extends PipelineOptions {
authorityHost?: string;
}

// @public
export class InteractiveBrowserCredential implements TokenCredential {
constructor(options?: InteractiveBrowserCredentialOptions);
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
}

// @public
export interface InteractiveBrowserCredentialOptions extends IdentityClientOptions {
export interface InteractiveBrowserCredentialOptions extends TokenCredentialOptions {
clientId?: string;
loginStyle?: BrowserLoginStyle;
postLogoutRedirectUri?: string | (() => string);
Expand All @@ -125,16 +120,21 @@ export const logger: import("@azure/logger").AzureLogger;

// @public
export class ManagedIdentityCredential implements TokenCredential {
constructor(clientId: string, options?: IdentityClientOptions);
constructor(options?: IdentityClientOptions);
constructor(clientId: string, options?: TokenCredentialOptions);
constructor(options?: TokenCredentialOptions);
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
}

export { TokenCredential }

// @public
export interface TokenCredentialOptions extends PipelineOptions {
authorityHost?: string;
}

// @public
export class UsernamePasswordCredential implements TokenCredential {
constructor(tenantIdOrName: string, clientId: string, username: string, password: string, options?: IdentityClientOptions);
constructor(tenantIdOrName: string, clientId: string, username: string, password: string, options?: TokenCredentialOptions);
getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;
}

Expand Down
6 changes: 3 additions & 3 deletions sdk/identity/identity/src/client/identityClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface TokenResponse {
export class IdentityClient extends ServiceClient {
public authorityHost: string;

constructor(options?: IdentityClientOptions) {
constructor(options?: TokenCredentialOptions) {
options = options || IdentityClient.getDefaultOptions();
super(undefined, createPipelineFromOptions(options));

Expand Down Expand Up @@ -158,7 +158,7 @@ export class IdentityClient extends ServiceClient {
}
}

static getDefaultOptions(): IdentityClientOptions {
static getDefaultOptions(): TokenCredentialOptions {
return {
authorityHost: DefaultAuthorityHost
};
Expand All @@ -169,7 +169,7 @@ export class IdentityClient extends ServiceClient {
* Provides options to configure how the Identity library makes authentication
* requests to Azure Active Directory.
*/
export interface IdentityClientOptions extends PipelineOptions {
export interface TokenCredentialOptions extends PipelineOptions {
/**
* The authority host to use for authentication requests. The default is
* "https://login.microsoftonline.com".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";
import { IdentityClientOptions } from '../client/identityClient';
import { TokenCredentialOptions } from '../client/identityClient';

const BrowserNotSupportedError = new Error(
"AuthorizationCodeCredential is not supported in the browser. InteractiveBrowserCredential is more appropriate for this use case."
Expand All @@ -17,22 +17,22 @@ export class AuthorizationCodeCredential implements TokenCredential {
clientSecret: string,
authorizationCode: string,
redirectUri: string,
options?: IdentityClientOptions
options?: TokenCredentialOptions
);
constructor(
tenantId: string | "common",
clientId: string,
authorizationCode: string,
redirectUri: string,
options?: IdentityClientOptions
options?: TokenCredentialOptions
);
constructor(
tenantId: string | "common",
clientId: string,
clientSecretOrAuthorizationCode: string,
authorizationCodeOrRedirectUri: string,
redirectUriOrOptions: string | IdentityClientOptions | undefined,
options?: IdentityClientOptions
redirectUriOrOptions: string | TokenCredentialOptions | undefined,
options?: TokenCredentialOptions
) {
throw BrowserNotSupportedError;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import qs from "qs";
import { createSpan } from "../util/tracing";
import { AuthenticationErrorName } from "../client/errors";
import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";
import { IdentityClient, TokenResponse, IdentityClientOptions } from "../client/identityClient";
import { IdentityClient, TokenResponse, TokenCredentialOptions } from "../client/identityClient";
import { CanonicalCode } from "@azure/core-tracing";

/**
Expand Down Expand Up @@ -53,7 +53,7 @@ export class AuthorizationCodeCredential implements TokenCredential {
clientSecret: string,
authorizationCode: string,
redirectUri: string,
options?: IdentityClientOptions
options?: TokenCredentialOptions
);
/**
* Creates an instance of CodeFlowCredential with the details needed
Expand Down Expand Up @@ -81,7 +81,7 @@ export class AuthorizationCodeCredential implements TokenCredential {
clientId: string,
authorizationCode: string,
redirectUri: string,
options?: IdentityClientOptions
options?: TokenCredentialOptions
);
/**
* @ignore
Expand All @@ -92,8 +92,8 @@ export class AuthorizationCodeCredential implements TokenCredential {
clientId: string,
clientSecretOrAuthorizationCode: string,
authorizationCodeOrRedirectUri: string,
redirectUriOrOptions: string | IdentityClientOptions | undefined,
options?: IdentityClientOptions
redirectUriOrOptions: string | TokenCredentialOptions | undefined,
options?: TokenCredentialOptions
) {
this.clientId = clientId;
this.tenantId = tenantId;
Expand All @@ -109,7 +109,7 @@ export class AuthorizationCodeCredential implements TokenCredential {
this.clientSecret = undefined;
this.authorizationCode = clientSecretOrAuthorizationCode;
this.redirectUri = authorizationCodeOrRedirectUri as string;
options = redirectUriOrOptions as IdentityClientOptions;
options = redirectUriOrOptions as TokenCredentialOptions;
}

this.identityClient = new IdentityClient(options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";
import { IdentityClientOptions } from "../client/identityClient";
import { TokenCredentialOptions } from "../client/identityClient";

const BrowserNotSupportedError = new Error(
"ClientCertificateCredential is not supported in the browser."
Expand All @@ -15,7 +15,7 @@ export class ClientCertificateCredential implements TokenCredential {
tenantId: string,
clientId: string,
certificatePath: string,
options?: IdentityClientOptions
options?: TokenCredentialOptions
) {
throw BrowserNotSupportedError;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import uuid from "uuid";
import { readFileSync } from "fs";
import { createHash } from "crypto";
import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";
import { IdentityClientOptions, IdentityClient } from "../client/identityClient";
import { TokenCredentialOptions, IdentityClient } from "../client/identityClient";
import { createSpan } from "../util/tracing";
import { AuthenticationErrorName } from "../client/errors";
import { CanonicalCode } from "@azure/core-tracing";
Expand Down Expand Up @@ -52,7 +52,7 @@ export class ClientCertificateCredential implements TokenCredential {
tenantId: string,
clientId: string,
certificatePath: string,
options?: IdentityClientOptions
options?: TokenCredentialOptions
) {
this.identityClient = new IdentityClient(options);
this.tenantId = tenantId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import qs from "qs";
import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";
import { IdentityClientOptions, IdentityClient } from "../client/identityClient";
import { TokenCredentialOptions, IdentityClient } from "../client/identityClient";
import { createSpan } from "../util/tracing";
import { AuthenticationErrorName } from "../client/errors";
import { CanonicalCode } from "@azure/core-tracing";
Expand Down Expand Up @@ -36,7 +36,7 @@ export class ClientSecretCredential implements TokenCredential {
tenantId: string,
clientId: string,
clientSecret: string,
options?: IdentityClientOptions
options?: TokenCredentialOptions
) {
this.identityClient = new IdentityClient(options);
this.tenantId = tenantId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { IdentityClientOptions } from "../client/identityClient";
import { TokenCredentialOptions } from "../client/identityClient";
import { ChainedTokenCredential } from "./chainedTokenCredential";
import { EnvironmentCredential } from "./environmentCredential";
import { ManagedIdentityCredential } from "./managedIdentityCredential";
Expand All @@ -23,10 +23,10 @@ export class DefaultAzureCredential extends ChainedTokenCredential {
*
* @param options Options for configuring the client which makes the authentication request.
*/
constructor(identityClientOptions?: IdentityClientOptions) {
constructor(tokenCredentialOptions?: TokenCredentialOptions) {
super(
new EnvironmentCredential(identityClientOptions),
new ManagedIdentityCredential(identityClientOptions)
new EnvironmentCredential(tokenCredentialOptions),
new ManagedIdentityCredential(tokenCredentialOptions)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";
import { DeviceCodePromptCallback } from './deviceCodeCredential';
import { IdentityClientOptions } from '../client/identityClient';
import { TokenCredentialOptions } from '../client/identityClient';

const BrowserNotSupportedError = new Error("DeviceCodeCredential is not supported in the browser.");

Expand All @@ -14,7 +14,7 @@ export class DeviceCodeCredential implements TokenCredential {
tenantId: string | "organizations",
clientId: string,
userPromptCallback: DeviceCodePromptCallback,
options?: IdentityClientOptions
options?: TokenCredentialOptions
) {
throw BrowserNotSupportedError;
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/identity/identity/src/credentials/deviceCodeCredential.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import qs from "qs";
import { TokenCredential, GetTokenOptions, AccessToken } from "@azure/core-http";
import { IdentityClient, TokenResponse, IdentityClientOptions } from "../client/identityClient";
import { IdentityClient, TokenResponse, TokenCredentialOptions } from "../client/identityClient";
import { AuthenticationError, AuthenticationErrorName } from "../client/errors";
import { createSpan } from "../util/tracing";
import { delay } from "../util/delay";
Expand Down Expand Up @@ -82,7 +82,7 @@ export class DeviceCodeCredential implements TokenCredential {
tenantId: string | "organizations",
clientId: string,
userPromptCallback: DeviceCodePromptCallback,
options?: IdentityClientOptions
options?: TokenCredentialOptions
) {
this.identityClient = new IdentityClient(options);
this.tenantId = tenantId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

import { AccessToken, TokenCredential, GetTokenOptions } from "@azure/core-http";
import { IdentityClientOptions } from "../client/identityClient";
import { TokenCredentialOptions } from "../client/identityClient";

const BrowserNotSupportedError = new Error(
"EnvironmentCredential is not supported in the browser."
);

export class EnvironmentCredential implements TokenCredential {
constructor(options?: IdentityClientOptions) {
constructor(options?: TokenCredentialOptions) {
throw BrowserNotSupportedError;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.

import { AccessToken, TokenCredential, GetTokenOptions } from "@azure/core-http";
import { IdentityClientOptions } from "../client/identityClient";
import { TokenCredentialOptions } from "../client/identityClient";
import { ClientSecretCredential } from "./clientSecretCredential";
import { createSpan } from "../util/tracing";
import { AuthenticationErrorName } from "../client/errors";
Expand Down Expand Up @@ -31,7 +31,7 @@ export class EnvironmentCredential implements TokenCredential {
*
* @param options Options for configuring the client which makes the authentication request.
*/
constructor(options?: IdentityClientOptions) {
constructor(options?: TokenCredentialOptions) {
const tenantId = process.env.AZURE_TENANT_ID,
clientId = process.env.AZURE_CLIENT_ID,
clientSecret = process.env.AZURE_CLIENT_SECRET;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { IdentityClientOptions } from "../client/identityClient";
import { TokenCredentialOptions } from "../client/identityClient";

/**
* The "login style" to use in the authentication flow:
Expand All @@ -16,7 +16,7 @@ export type BrowserLoginStyle = "redirect" | "popup";
/**
* Defines options for the InteractiveBrowserCredential class.
*/
export interface InteractiveBrowserCredentialOptions extends IdentityClientOptions {
export interface InteractiveBrowserCredentialOptions extends TokenCredentialOptions {
/**
* Specifies whether a redirect or a popup window should be used to
* initiate the user authentication flow. Possible values are "redirect"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

import { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-http";
import { IdentityClientOptions } from "../client/identityClient";
import { TokenCredentialOptions } from "../client/identityClient";

const BrowserNotSupportedError = new Error(
"ManagedIdentityCredential is not supported in the browser."
);

export class ManagedIdentityCredential implements TokenCredential {
constructor(clientId: string, options?: IdentityClientOptions);
constructor(options?: IdentityClientOptions);
constructor(clientIdOrOptions: string | IdentityClientOptions | undefined, options?: IdentityClientOptions) {
constructor(clientId: string, options?: TokenCredentialOptions);
constructor(options?: TokenCredentialOptions);
constructor(clientIdOrOptions: string | TokenCredentialOptions | undefined, options?: TokenCredentialOptions) {
throw BrowserNotSupportedError;
}

Expand Down