New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@azure/ai-text-analytics

Package Overview
Dependencies
Maintainers
3
Versions
437
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/ai-text-analytics - npm Package Compare versions

Comparing version 1.0.0-dev.20200326.1 to 1.0.0-dev.20200328.1

dist-esm/src/azureKeyCredentialPolicy.js

1

CHANGELOG.md

@@ -6,2 +6,3 @@ # Release History

- [Breaking] Removed PII entity detection methods from `TextAnalyticsClient` as well as all associated samples and documentation
- [Breaking] Replaced `TextAnalyticsApiKeyCredential` with `AzureKeyCredential` (re-exported through this package from `@azure/core-auth`).

@@ -8,0 +9,0 @@ ## 1.0.0-preview.3 (2020-03-10)

2

dist-esm/src/index.js
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
export { AzureKeyCredential } from "@azure/core-auth";
export { TextAnalyticsClient } from "./textAnalyticsClient";
export { TextAnalyticsApiKeyCredential } from "./textAnalyticsApiKeyCredential";
//# sourceMappingURL=index.js.map
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import { __awaiter, __rest } from "tslib";
import { createPipelineFromOptions, signingPolicy, isTokenCredential, bearerTokenAuthenticationPolicy, operationOptionsToRequestOptionsBase } from "@azure/core-http";
import { createPipelineFromOptions, isTokenCredential, bearerTokenAuthenticationPolicy, operationOptionsToRequestOptionsBase } from "@azure/core-http";
import { SDK_VERSION } from "./constants";

@@ -15,2 +15,3 @@ import { GeneratedClient } from "./generated/generatedClient";

import { CanonicalCode } from "@opentelemetry/types";
import { createTextAnalyticsAzureKeyCredentialPolicy } from "./azureKeyCredentialPolicy";
const DEFAULT_COGNITIVE_SCOPE = "https://cognitiveservices.azure.com/.default";

@@ -26,11 +27,11 @@ /**

* ```ts
* import { TextAnalyticsClient, TextAnalyticsApiKeyCredential } from "@azure/ai-text-analytics";
* import { TextAnalyticsClient, KeyCredential } from "@azure/ai-text-analytics";
*
* const client = new TextAnalyticsClient(
* "<service endpoint>",
* new TextAnalyticsApiKeyCredential("<api key>")
* new KeyCredential("<api key>")
* );
* ```
* @param {string} endpointUrl The URL to the TextAnalytics endpoint
* @param {TokenCredential | TextAnalyticsApiKeyCredential} credential Used to authenticate requests to the service.
* @param {TokenCredential | KeyCredential} credential Used to authenticate requests to the service.
* @param {TextAnalyticsClientOptions} [options] Used to configure the TextAnalytics client.

@@ -55,3 +56,3 @@ */

? bearerTokenAuthenticationPolicy(credential, DEFAULT_COGNITIVE_SCOPE)
: signingPolicy(credential);
: createTextAnalyticsAzureKeyCredentialPolicy(credential);
const internalPipelineOptions = Object.assign(Object.assign({}, pipelineOptions), {

@@ -64,3 +65,11 @@ loggingOptions: {

const pipeline = createPipelineFromOptions(internalPipelineOptions, authPolicy);
this.client = new GeneratedClient(credential, this.endpointUrl, pipeline);
// The contract with the generated client requires a credential, even though it is never used
// when a pipeline is provided. Until that contract can be changed, this dummy credential will
// throw an error if the client ever attempts to use it.
const dummyCredential = {
signRequest() {
throw new Error("Internal error: Attempted to use credential from service client, but a pipeline was provided.");
}
};
this.client = new GeneratedClient(dummyCredential, this.endpointUrl, pipeline);
}

@@ -67,0 +76,0 @@ detectLanguage(documents, countryHintOrOptions, options) {

@@ -5,2 +5,3 @@ 'use strict';

var coreAuth = require('@azure/core-auth');
var tslib = require('tslib');

@@ -1555,2 +1556,35 @@ var coreHttp = require('@azure/core-http');

// Copyright (c) Microsoft Corporation.
const API_KEY_HEADER_NAME = "Ocp-Apim-Subscription-Key";
/**
* Create an HTTP pipeline policy to authenticate a request
* using an `AzureKeyCredential` for Text Analytics
*/
function createTextAnalyticsAzureKeyCredentialPolicy(credential) {
return {
create: (nextPolicy, options) => {
return new TextAnalyticsAzureKeyCredentialPolicy(nextPolicy, options, credential);
}
};
}
/**
* A concrete implementation of an AzureKeyCredential policy
* using the appropriate header for TextAnalytics
*/
class TextAnalyticsAzureKeyCredentialPolicy extends coreHttp.BaseRequestPolicy {
constructor(nextPolicy, options, credential) {
super(nextPolicy, options);
this.credential = credential;
}
sendRequest(webResource) {
return tslib.__awaiter(this, void 0, void 0, function* () {
if (!webResource) {
throw new Error("webResource cannot be null or undefined");
}
webResource.headers.set(API_KEY_HEADER_NAME, this.credential.key);
return this._nextPolicy.sendRequest(webResource);
});
}
}
// Copyright (c) Microsoft Corporation.
const DEFAULT_COGNITIVE_SCOPE = "https://cognitiveservices.azure.com/.default";

@@ -1566,11 +1600,11 @@ /**

* ```ts
* import { TextAnalyticsClient, TextAnalyticsApiKeyCredential } from "@azure/ai-text-analytics";
* import { TextAnalyticsClient, KeyCredential } from "@azure/ai-text-analytics";
*
* const client = new TextAnalyticsClient(
* "<service endpoint>",
* new TextAnalyticsApiKeyCredential("<api key>")
* new KeyCredential("<api key>")
* );
* ```
* @param {string} endpointUrl The URL to the TextAnalytics endpoint
* @param {TokenCredential | TextAnalyticsApiKeyCredential} credential Used to authenticate requests to the service.
* @param {TokenCredential | KeyCredential} credential Used to authenticate requests to the service.
* @param {TextAnalyticsClientOptions} [options] Used to configure the TextAnalytics client.

@@ -1595,3 +1629,3 @@ */

? coreHttp.bearerTokenAuthenticationPolicy(credential, DEFAULT_COGNITIVE_SCOPE)
: coreHttp.signingPolicy(credential);
: createTextAnalyticsAzureKeyCredentialPolicy(credential);
const internalPipelineOptions = Object.assign(Object.assign({}, pipelineOptions), {

@@ -1604,3 +1638,11 @@ loggingOptions: {

const pipeline = coreHttp.createPipelineFromOptions(internalPipelineOptions, authPolicy);
this.client = new GeneratedClient(credential, this.endpointUrl, pipeline);
// The contract with the generated client requires a credential, even though it is never used
// when a pipeline is provided. Until that contract can be changed, this dummy credential will
// throw an error if the client ever attempts to use it.
const dummyCredential = {
signRequest() {
throw new Error("Internal error: Attempted to use credential from service client, but a pipeline was provided.");
}
};
this.client = new GeneratedClient(dummyCredential, this.endpointUrl, pipeline);
}

@@ -1794,48 +1836,9 @@ detectLanguage(documents, countryHintOrOptions, options) {

// Copyright (c) Microsoft Corporation.
const API_KEY_HEADER_NAME = "Ocp-Apim-Subscription-Key";
/**
* This class is used to authenticate to Text Analytics using an API Key retrieved
* from the Azure portal. Sometimes this is referred to as a "Subscription Key".
*/
class TextAnalyticsApiKeyCredential {
/**
* Creates a new apiKeyCredential object.
*
* @param {string} apiKey The Text Analytics API key for authentication.
*/
constructor(apiKey) {
this.updateKey(apiKey);
Object.defineProperty(exports, 'AzureKeyCredential', {
enumerable: true,
get: function () {
return coreAuth.AzureKeyCredential;
}
/**
* Updates the API Key used for authentication. Use this method to roll credentials.
* @param apiKey The Text Analytics API key for authentication.
*/
updateKey(apiKey) {
if (!apiKey || typeof apiKey !== "string") {
throw new Error("apiKey must be a non-empty string");
}
this.apiKey = apiKey;
}
/* eslint-disable @azure/azure-sdk/ts-use-interface-parameters */
/**
* Signs a request with the provided API Key.
*
* @param {WebResource} webResource The WebResource to be signed.
* @returns {Promise<WebResource>} The signed request object.
*/
signRequest(webResource) {
return tslib.__awaiter(this, void 0, void 0, function* () {
if (!webResource) {
throw new Error("webResource cannot be null or undefined.");
}
webResource.headers.set(API_KEY_HEADER_NAME, this.apiKey);
return webResource;
});
}
}
/* eslint-enable @azure/azure-sdk/ts-use-interface-parameters */
exports.TextAnalyticsApiKeyCredential = TextAnalyticsApiKeyCredential;
});
exports.TextAnalyticsClient = TextAnalyticsClient;
//# sourceMappingURL=index.js.map

@@ -6,3 +6,3 @@ {

"description": "An isomorphic client library for the Azure Text Analytics service.",
"version": "1.0.0-dev.20200326.1",
"version": "1.0.0-dev.20200328.1",
"keywords": [

@@ -77,2 +77,3 @@ "node",

"dependencies": {
"@azure/core-auth": "^1.1.0-dev",
"@azure/core-http": "^1.0.0",

@@ -79,0 +80,0 @@ "@azure/core-tracing": "^1.0.0-dev",

@@ -69,10 +69,10 @@ # Azure Text Analytics client library for JavaScript

Once you have an API key and endpoint, you can use it as follows:
Once you have an API key and endpoint, you can use the `AzureKeyCredential` class to authenticate the client as follows:
```js
const { TextAnalyticsClient, TextAnalyticsApiKeyCredential } = require("@azure/ai-text-analytics");
const { TextAnalyticsClient, AzureKeyCredential } = require("@azure/ai-text-analytics");
const client = new TextAnalyticsClient(
"<endpoint>",
new TextAnalyticsApiKeyCredential("<API key>")
new AzureKeyCredential("<API key>")
);

@@ -173,7 +173,7 @@ ```

```javascript
const { TextAnalyticsClient, TextAnalyticsApiKeyCredential } = require("@azure/ai-text-analytics");
const { TextAnalyticsClient, AzureKeyCredential } = require("@azure/ai-text-analytics");
const client = new TextAnalyticsClient(
"<endpoint>",
new TextAnalyticsApiKeyCredential("<API key>")
new AzureKeyCredential("<API key>")
);

@@ -210,7 +210,7 @@

```javascript
const { TextAnalyticsClient, TextAnalyticsApiKeyCredential } = require("@azure/ai-text-analytics");
const { TextAnalyticsClient, AzureKeyCredential } = require("@azure/ai-text-analytics");
const client = new TextAnalyticsClient(
"<endpoint>",
new TextAnalyticsApiKeyCredential("<API key>")
new AzureKeyCredential("<API key>")
);

@@ -247,7 +247,7 @@

```javascript
const { TextAnalyticsClient, TextAnalyticsApiKeyCredential } = require("@azure/ai-text-analytics");
const { TextAnalyticsClient, AzureKeyCredential } = require("@azure/ai-text-analytics");
const client = new TextAnalyticsClient(
"<endpoint>",
new TextAnalyticsApiKeyCredential("<API key>")
new AzureKeyCredential("<API key>")
);

@@ -287,7 +287,7 @@

```javascript
const { TextAnalyticsClient, TextAnalyticsApiKeyCredential } = require("@azure/ai-text-analytics");
const { TextAnalyticsClient, AzureKeyCredential } = require("@azure/ai-text-analytics");
const client = new TextAnalyticsClient(
"<endpoint>",
new TextAnalyticsApiKeyCredential("<API key>")
new AzureKeyCredential("<API key>")
);

@@ -324,7 +324,7 @@

```javascript
const { TextAnalyticsClient, TextAnalyticsApiKeyCredential } = require("@azure/ai-text-analytics");
const { TextAnalyticsClient, AzureKeyCredential } = require("@azure/ai-text-analytics");
const client = new TextAnalyticsClient(
"<endpoint>",
new TextAnalyticsApiKeyCredential("<API key>")
new AzureKeyCredential("<API key>")
);

@@ -331,0 +331,0 @@

@@ -0,6 +1,6 @@

import { AzureKeyCredential } from '@azure/core-auth';
import { KeyCredential } from '@azure/core-auth';
import { OperationOptions } from '@azure/core-http';
import { PipelineOptions } from '@azure/core-http';
import { ServiceClientCredentials } from '@azure/core-http';
import { TokenCredential } from '@azure/identity';
import { WebResource } from '@azure/core-http';
import { TokenCredential } from '@azure/core-auth';

@@ -59,2 +59,3 @@ /**

}
export { AzureKeyCredential }

@@ -441,31 +442,2 @@ /**

/**
* This class is used to authenticate to Text Analytics using an API Key retrieved
* from the Azure portal. Sometimes this is referred to as a "Subscription Key".
*/
export declare class TextAnalyticsApiKeyCredential implements ServiceClientCredentials {
/**
* Used to authenticate to Text Analytics
*/
private apiKey;
/**
* Creates a new apiKeyCredential object.
*
* @param {string} apiKey The Text Analytics API key for authentication.
*/
constructor(apiKey: string);
/**
* Updates the API Key used for authentication. Use this method to roll credentials.
* @param apiKey The Text Analytics API key for authentication.
*/
updateKey(apiKey: string): void;
/**
* Signs a request with the provided API Key.
*
* @param {WebResource} webResource The WebResource to be signed.
* @returns {Promise<WebResource>} The signed request object.
*/
signRequest(webResource: WebResource): Promise<WebResource>;
}
/**
* Client class for interacting with Azure Text Analytics.

@@ -492,14 +464,14 @@ */

* ```ts
* import { TextAnalyticsClient, TextAnalyticsApiKeyCredential } from "@azure/ai-text-analytics";
* import { TextAnalyticsClient, KeyCredential } from "@azure/ai-text-analytics";
*
* const client = new TextAnalyticsClient(
* "<service endpoint>",
* new TextAnalyticsApiKeyCredential("<api key>")
* new KeyCredential("<api key>")
* );
* ```
* @param {string} endpointUrl The URL to the TextAnalytics endpoint
* @param {TokenCredential | TextAnalyticsApiKeyCredential} credential Used to authenticate requests to the service.
* @param {TokenCredential | KeyCredential} credential Used to authenticate requests to the service.
* @param {TextAnalyticsClientOptions} [options] Used to configure the TextAnalytics client.
*/
constructor(endpointUrl: string, credential: TokenCredential | TextAnalyticsApiKeyCredential, options?: TextAnalyticsClientOptions);
constructor(endpointUrl: string, credential: TokenCredential | KeyCredential, options?: TextAnalyticsClientOptions);
/**

@@ -506,0 +478,0 @@ * Runs a predictive model to determine the language that the passed-in

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc