Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@azure-rest/ai-translation-text

Package Overview
Dependencies
Maintainers
2
Versions
174
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure-rest/ai-translation-text - npm Package Compare versions

Comparing version 1.0.0-alpha.20240327.1 to 1.0.0-alpha.20240411.1

1

CHANGELOG.md

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

### Features Added
- Added support for AAD authentication.

@@ -8,0 +9,0 @@ ### Breaking Changes

@@ -5,2 +5,4 @@ // Copyright (c) Microsoft Corporation.

const APIM_REGION_HEADER_NAME = "Ocp-Apim-Subscription-Region";
const APIM_RESOURCE_ID = "Ocp-Apim-ResourceId";
export const DEFAULT_SCOPE = "https://cognitiveservices.azure.com/.default";
export class TranslatorAuthenticationPolicy {

@@ -27,2 +29,13 @@ constructor(credential) {

}
export class TranslatorTokenCredentialAuthenticationPolicy {
constructor(credential) {
this.name = "TranslatorTokenCredentialAuthenticationPolicy";
this.credential = credential;
}
sendRequest(request, next) {
request.headers.set(APIM_REGION_HEADER_NAME, this.credential.region);
request.headers.set(APIM_RESOURCE_ID, this.credential.azureResourceId);
return next(request);
}
}
//# sourceMappingURL=authentication.js.map

@@ -6,4 +6,3 @@ // Copyright (c) Microsoft Corporation.

import * as coreRestPipeline from "@azure/core-rest-pipeline";
import { TranslatorAuthenticationPolicy, TranslatorAzureKeyAuthenticationPolicy, } from "./authentication";
const DEFAULT_SCOPE = "https://cognitiveservices.azure.com/.default";
import { DEFAULT_SCOPE, TranslatorAuthenticationPolicy, TranslatorAzureKeyAuthenticationPolicy, TranslatorTokenCredentialAuthenticationPolicy, } from "./authentication";
const DEFAULT_ENPOINT = "https://api.cognitive.microsofttranslator.com";

@@ -18,2 +17,9 @@ const PLATFORM_HOST = "cognitiveservices";

}
function isTokenCredential(credential) {
return (credential === null || credential === void 0 ? void 0 : credential.getToken) !== undefined;
}
function isTranslatorTokenCredential(credential) {
return ((credential === null || credential === void 0 ? void 0 : credential.tokenCredential) !== undefined &&
(credential === null || credential === void 0 ? void 0 : credential.azureResourceId) !== undefined);
}
/**

@@ -57,3 +63,3 @@ * Initialize a new instance of `TextTranslationClient`

}
else if (credential) {
else if (isTokenCredential(credential)) {
client.pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({

@@ -64,4 +70,11 @@ credential: credential,

}
else if (isTranslatorTokenCredential(credential)) {
client.pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
credential: credential.tokenCredential,
scopes: DEFAULT_SCOPE,
}));
client.pipeline.addPolicy(new TranslatorTokenCredentialAuthenticationPolicy(credential));
}
return client;
}
//# sourceMappingURL=customClient.js.map

@@ -36,2 +36,4 @@ 'use strict';

const APIM_REGION_HEADER_NAME = "Ocp-Apim-Subscription-Region";
const APIM_RESOURCE_ID = "Ocp-Apim-ResourceId";
const DEFAULT_SCOPE = "https://cognitiveservices.azure.com/.default";
class TranslatorAuthenticationPolicy {

@@ -58,6 +60,16 @@ constructor(credential) {

}
class TranslatorTokenCredentialAuthenticationPolicy {
constructor(credential) {
this.name = "TranslatorTokenCredentialAuthenticationPolicy";
this.credential = credential;
}
sendRequest(request, next) {
request.headers.set(APIM_REGION_HEADER_NAME, this.credential.region);
request.headers.set(APIM_RESOURCE_ID, this.credential.azureResourceId);
return next(request);
}
}
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
const DEFAULT_SCOPE = "https://cognitiveservices.azure.com/.default";
const DEFAULT_ENPOINT = "https://api.cognitive.microsofttranslator.com";

@@ -72,2 +84,9 @@ const PLATFORM_HOST = "cognitiveservices";

}
function isTokenCredential(credential) {
return (credential === null || credential === void 0 ? void 0 : credential.getToken) !== undefined;
}
function isTranslatorTokenCredential(credential) {
return ((credential === null || credential === void 0 ? void 0 : credential.tokenCredential) !== undefined &&
(credential === null || credential === void 0 ? void 0 : credential.azureResourceId) !== undefined);
}
/**

@@ -111,3 +130,3 @@ * Initialize a new instance of `TextTranslationClient`

}
else if (credential) {
else if (isTokenCredential(credential)) {
client.pipeline.addPolicy(coreRestPipeline__namespace.bearerTokenAuthenticationPolicy({

@@ -118,2 +137,9 @@ credential: credential,

}
else if (isTranslatorTokenCredential(credential)) {
client.pipeline.addPolicy(coreRestPipeline__namespace.bearerTokenAuthenticationPolicy({
credential: credential.tokenCredential,
scopes: DEFAULT_SCOPE,
}));
client.pipeline.addPolicy(new TranslatorTokenCredentialAuthenticationPolicy(credential));
}
return client;

@@ -120,0 +146,0 @@ }

2

package.json

@@ -5,3 +5,3 @@ {

"author": "Microsoft Corporation",
"version": "1.0.0-alpha.20240327.1",
"version": "1.0.0-alpha.20240411.1",
"description": "An isomorphic client library for the Azure Cognitive Translator Service",

@@ -8,0 +8,0 @@ "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/translation/ai-translation-text-rest/README.md",

@@ -71,3 +71,3 @@ import { Client } from '@azure-rest/core-client';

*/
declare function createClient(endpoint: undefined | string, credential?: undefined | TranslatorCredential | KeyCredential | TokenCredential, options?: ClientOptions): TextTranslationClient;
declare function createClient(endpoint: undefined | string, credential?: undefined | TranslatorCredential | TranslatorTokenCredential | KeyCredential | TokenCredential, options?: ClientOptions): TextTranslationClient;
export default createClient;

@@ -755,2 +755,8 @@

export declare interface TranslatorTokenCredential {
tokenCredential: TokenCredential;
region: string;
azureResourceId: string;
}
/** Script definition with list of script into which given script can be translitered. */

@@ -757,0 +763,0 @@ export declare interface TransliterableScriptOutput extends CommonScriptModelOutput {

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

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