@microsoft/ads-adal-library
Advanced tools
Comparing version 1.0.16 to 1.0.17
@@ -1,4 +0,4 @@ | ||
import { ProviderSettings, SecureStorageProvider, Tenant, AADResource, LoginResponse, AzureAccount, Logger, MessageDisplayer, ErrorLookup, CachingProvider, RefreshTokenPostData, AuthorizationCodePostData, TokenPostData, AccountKey, StringLookup, DeviceCodeStartPostData, DeviceCodeCheckPostData, AzureAuthType, UserInteraction } from '../models'; | ||
import { AxiosResponse } from 'axios'; | ||
import { AccessToken, Token, TokenClaims, RefreshToken, OAuthTokenResponse } from '../models/auth'; | ||
import { AADResource, AccountKey, AuthorizationCodePostData, AzureAccount, AzureAuthType, CachingProvider, DeviceCodeCheckPostData, DeviceCodeStartPostData, ErrorLookup, Logger, LoginResponse, MessageDisplayer, ProviderSettings, RefreshTokenPostData, SecureStorageProvider, StringLookup, Tenant, TokenPostData, UserInteraction } from '../models'; | ||
import { AccessToken, OAuthTokenResponse, RefreshToken, Token, TokenClaims } from '../models/auth'; | ||
export declare abstract class AzureAuth { | ||
@@ -5,0 +5,0 @@ protected readonly providerSettings: ProviderSettings; |
@@ -30,8 +30,8 @@ "use strict"; | ||
* ------------------------------------------------------------------------------------------ */ | ||
const models_1 = require("../models"); | ||
const AzureAuthError_1 = require("../errors/AzureAuthError"); | ||
const errors_1 = require("../errors/errors"); | ||
const axios_1 = __importDefault(require("axios")); | ||
const qs = __importStar(require("qs")); | ||
const url = __importStar(require("url")); | ||
const AzureAuthError_1 = require("../errors/AzureAuthError"); | ||
const errors_1 = require("../errors/errors"); | ||
const models_1 = require("../models"); | ||
class AzureAuth { | ||
@@ -79,11 +79,7 @@ constructor(providerSettings, secureStorage, cachingProvider, logger, messageDisplayer, errorLookup, userInteraction, stringLookup, azureAuthType) { | ||
getHomeTenant(account) { | ||
var _a, _b; | ||
// Home is defined by the API | ||
// Lets pick the home tenant - and fall back to commonTenant if they don't exist | ||
return (_b = (_a = account.properties.tenants.find(t => t.tenantCategory === 'Home')) !== null && _a !== void 0 ? _a : account.properties.tenants[0]) !== null && _b !== void 0 ? _b : this.commonTenant; | ||
var _a; | ||
return (_a = account.properties.owningTenant) !== null && _a !== void 0 ? _a : this.commonTenant; | ||
} | ||
async refreshAccess(account) { | ||
// Deprecated account - delete it. | ||
if (account.key.accountVersion !== AzureAuth.ACCOUNT_VERSION) { | ||
account.delete = true; | ||
return account; | ||
@@ -305,2 +301,3 @@ } | ||
async getSavedToken(tenant, resource, accountKey) { | ||
var _a; | ||
if (!tenant.id || !resource.id) { | ||
@@ -317,3 +314,3 @@ this.logger.pii('Tenant ID or resource ID was undefined', tenant, resource); | ||
refreshTokenString = await this.cachingProvider.get(`${accountKey.id}_refresh_${resource.id}_${tenant.id}`); | ||
expiresOn = await this.cachingProvider.get(`${accountKey.id}_${tenant.id}_${resource.id}`); | ||
expiresOn = (_a = await this.cachingProvider.get(`${accountKey.id}_${tenant.id}_${resource.id}`)) !== null && _a !== void 0 ? _a : ''; | ||
} | ||
@@ -376,3 +373,3 @@ catch (ex) { | ||
createAccount(tokenClaims, key, tenants) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
// Determine if this is a microsoft account | ||
@@ -388,2 +385,3 @@ let accountType; | ||
const email = (_c = tokenClaims.email) !== null && _c !== void 0 ? _c : tokenClaims.unique_name; | ||
const owningTenant = (_d = tenants.find(t => t.id === tokenClaims.tid)) !== null && _d !== void 0 ? _d : { 'id': tokenClaims.tid, 'displayName': 'Microsoft Account' }; | ||
let displayName = name; | ||
@@ -410,2 +408,3 @@ if (email) { | ||
tenants, | ||
owningTenant: owningTenant, | ||
azureAuthType: this.azureAuthType | ||
@@ -448,3 +447,3 @@ }, | ||
const split = accessToken.split('.'); | ||
return JSON.parse(Buffer.from(split[1], 'base64').toString('binary')); | ||
return JSON.parse(Buffer.from(split[1], 'base64').toString('utf8')); | ||
} | ||
@@ -451,0 +450,0 @@ catch (ex) { |
@@ -28,3 +28,3 @@ "use strict"; | ||
let authCompletePromise = new Promise((resolve, reject) => authCompleteDeferred = { resolve, reject }); | ||
const uri = `${this.loginEndpointUrl}/${this.commonTenant.id}/oauth2/devicecode`; | ||
const uri = `${this.loginEndpointUrl}/${tenant.id}/oauth2/devicecode`; | ||
const postData = { | ||
@@ -31,0 +31,0 @@ client_id: this.clientId, |
@@ -8,3 +8,2 @@ import { ProviderSettings } from '.'; | ||
isSignedIn?: boolean; | ||
delete?: boolean; | ||
} | ||
@@ -47,2 +46,3 @@ export interface AccountKey { | ||
isMsAccount: boolean; | ||
owningTenant: Tenant; | ||
/** | ||
@@ -49,0 +49,0 @@ * A list of tenants (aka directories) that the account belongs to |
interface KVProvider { | ||
set(key: string, value: string): Promise<void>; | ||
get(key: string): Promise<string>; | ||
get(key: string): Promise<string | undefined | null>; | ||
clear(): Promise<void>; | ||
@@ -13,4 +13,4 @@ remove(key: string): Promise<boolean>; | ||
password: string; | ||
}[]>; | ||
}[] | undefined>; | ||
} | ||
export {}; |
/// <reference types="vscode" /> | ||
export interface ProviderSettings { | ||
scopes: string[]; | ||
displayName: string; | ||
@@ -4,0 +5,0 @@ id: string; |
{ | ||
"name": "@microsoft/ads-adal-library", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"description": "ADAL NodeJS authentication library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
These steps should be followed to publish a new version of the package to npmjs. | ||
1. Bump version if needed | ||
2. Download ads-adal-library-X.X.X.tgz package from [Official Build Pipeline](https://mssqltools.visualstudio.com/CrossPlatBuildScripts/_build?definitionId=522) artifacts | ||
3. Run `npm publish <PATH_TO_PACKAGE>/microsoft-ads-adal-library-X.X.X.tgz` | ||
* If you do not have permissions to publish see [Publishing Microsoft scoped packages](https://docs.opensource.microsoft.com/releasing/publish/npm/#publish-microsoft-scoped-packages) to get access | ||
2. Run the [Official Build Pipeline](https://mssqltools.visualstudio.com/CrossPlatBuildScripts/_build?definitionId=522) against main | ||
3. Download ads-adal-library-X.X.X.tgz package from the artifacts of the completed build | ||
4. Run `npm publish <PATH_TO_PACKAGE>/microsoft-ads-adal-library-X.X.X.tgz` | ||
* If you do not have permissions to publish contact the team to get added to the [azure-data-studio](https://www.npmjs.com/settings/microsoft/teams/team/azure-data-studio/users) team on NPM | ||
* See [the docs](https://docs.opensource.microsoft.com/releasing/publish-binaries/npm/#publish-microsoft-scoped-packages) for more info about the publishing process | ||
5. Create a [release](https://github.com/microsoft/vscode-mssql/releases) with a tag pointing to the commit the build is from (should be the latest from main) with a link to the package version that was just released (e.g. https://www.npmjs.com/package/@microsoft/ads-adal-library/v/1.0.15) |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
82480
1