@salesforce/core
Advanced tools
Comparing version 2.1.3 to 2.1.4
@@ -0,1 +1,8 @@ | ||
## [2.1.4](https://github.com/forcedotcom/sfdx-core/compare/v2.1.3...v2.1.4) (2019-11-04) | ||
### Bug Fixes | ||
* contrib ([7e91751](https://github.com/forcedotcom/sfdx-core/commit/7e91751e1dcb1d3ca18d083262ae675503a7614b)) | ||
## [2.1.3](https://github.com/forcedotcom/sfdx-core/compare/v2.1.2...v2.1.3) (2019-10-09) | ||
@@ -2,0 +9,0 @@ |
import { AsyncCreatable } from '@salesforce/kit'; | ||
import { Nullable, Optional } from '@salesforce/ts-types'; | ||
import { OAuth2Options } from 'jsforce'; | ||
import { AnyFunction, Nullable, Optional } from '@salesforce/ts-types'; | ||
import { OAuth2, OAuth2Options, TokenResponse } from 'jsforce'; | ||
import { Connection } from './connection'; | ||
@@ -57,2 +57,36 @@ /** | ||
/** | ||
* Extend OAuth2 to add code verifier support for the auth code (web auth) flow | ||
* const oauth2 = new OAuth2WithVerifier({ loginUrl, clientSecret, clientId, redirectUri }); | ||
* | ||
* const authUrl = oauth2.getAuthorizationUrl({ | ||
* state: 'foo', | ||
* prompt: 'login', | ||
* scope: 'api web' | ||
* }); | ||
* console.log(authUrl); | ||
* const authCode = await retrieveCode(); | ||
* const authInfo = await AuthInfo.create({ oauth2Options: { clientId, clientSecret, loginUrl, authCode }, oauth2}); | ||
* console.log(`access token: ${authInfo.getFields().accessToken}`); | ||
*/ | ||
export declare class OAuth2WithVerifier extends OAuth2 { | ||
readonly codeVerifier: string; | ||
constructor(options: OAuth2Options); | ||
/** | ||
* Overrides jsforce.OAuth2.getAuthorizationUrl. Get Salesforce OAuth2 authorization page | ||
* URL to redirect user agent, adding a verification code for added security. | ||
* | ||
* @param params | ||
*/ | ||
getAuthorizationUrl(params: object): string; | ||
requestToken(code: string, callback?: (err: Error, tokenResponse: TokenResponse) => void): Promise<TokenResponse>; | ||
/** | ||
* Overrides jsforce.OAuth2._postParams because jsforce's oauth impl doesn't support | ||
* coder_verifier and code_challenge. This enables the server to disallow trading a one-time auth code | ||
* for an access/refresh token when the verifier and challenge are out of alignment. | ||
* | ||
* See https://github.com/jsforce/jsforce/issues/665 | ||
*/ | ||
protected _postParams(params: object, callback: AnyFunction): Promise<any>; | ||
} | ||
/** | ||
* Salesforce URLs. | ||
@@ -199,3 +233,8 @@ */ | ||
private buildRefreshTokenConfig; | ||
private buildWebAuthConfig; | ||
/** | ||
* Performs an authCode exchange but the Oauth2 feature of jsforce is extended to include a code_challenge | ||
* @param options The oauth options | ||
* @param oauth2 The oauth2 extension that includes a code_challenge | ||
*/ | ||
private exchangeToken; | ||
private lookup; | ||
@@ -220,3 +259,4 @@ } | ||
accessTokenOptions?: AccessTokenOptions; | ||
oauth2?: OAuth2; | ||
} | ||
} |
@@ -40,4 +40,17 @@ "use strict"; | ||
} | ||
// Extend OAuth2 to add code verifier support for the auth code (web auth) flow | ||
class AuthCodeOAuth2 extends jsforce_1.OAuth2 { | ||
/** | ||
* Extend OAuth2 to add code verifier support for the auth code (web auth) flow | ||
* const oauth2 = new OAuth2WithVerifier({ loginUrl, clientSecret, clientId, redirectUri }); | ||
* | ||
* const authUrl = oauth2.getAuthorizationUrl({ | ||
* state: 'foo', | ||
* prompt: 'login', | ||
* scope: 'api web' | ||
* }); | ||
* console.log(authUrl); | ||
* const authCode = await retrieveCode(); | ||
* const authInfo = await AuthInfo.create({ oauth2Options: { clientId, clientSecret, loginUrl, authCode }, oauth2}); | ||
* console.log(`access token: ${authInfo.getFields().accessToken}`); | ||
*/ | ||
class OAuth2WithVerifier extends jsforce_1.OAuth2 { | ||
constructor(options) { | ||
@@ -80,2 +93,3 @@ super(options); | ||
} | ||
exports.OAuth2WithVerifier = OAuth2WithVerifier; | ||
/** | ||
@@ -266,3 +280,3 @@ * Salesforce URLs. | ||
static getAuthorizationUrl(options) { | ||
const oauth2 = new AuthCodeOAuth2(options); | ||
const oauth2 = new OAuth2WithVerifier(options); | ||
// The state parameter allows the redirectUri callback listener to ignore request | ||
@@ -492,4 +506,9 @@ // that don't contain the state value. | ||
else { | ||
// authcode exchange / web auth flow | ||
authConfig = await this.buildWebAuthConfig(options); | ||
if (this.options.oauth2 instanceof OAuth2WithVerifier) { | ||
// authcode exchange / web auth flow | ||
authConfig = await this.exchangeToken(options, this.options.oauth2); | ||
} | ||
else { | ||
authConfig = await this.exchangeToken(options); | ||
} | ||
} | ||
@@ -628,5 +647,8 @@ } | ||
} | ||
// build an OAuth config given an auth code. | ||
async buildWebAuthConfig(options) { | ||
const oauth2 = new AuthCodeOAuth2(options); | ||
/** | ||
* Performs an authCode exchange but the Oauth2 feature of jsforce is extended to include a code_challenge | ||
* @param options The oauth options | ||
* @param oauth2 The oauth2 extension that includes a code_challenge | ||
*/ | ||
async exchangeToken(options, oauth2 = new jsforce_1.OAuth2(options)) { | ||
// Exchange the auth code for an access token and refresh token. | ||
@@ -633,0 +655,0 @@ let _authFields; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { Stats as fsStats } from 'fs'; | ||
@@ -3,0 +2,0 @@ import { BaseConfigStore, ConfigContents } from './configStore'; |
@@ -9,3 +9,3 @@ export { Aliases, AliasGroup } from './config/aliases'; | ||
export { ConfigInfo, ConfigAggregator } from './config/configAggregator'; | ||
export { AuthFields, AuthInfo, SfdcUrl } from './authInfo'; | ||
export { AuthFields, AuthInfo, OAuth2WithVerifier, SfdcUrl } from './authInfo'; | ||
export { Connection, SFDX_HTTP_HEADERS } from './connection'; | ||
@@ -12,0 +12,0 @@ export { Mode, Global } from './global'; |
@@ -33,2 +33,3 @@ "use strict"; | ||
exports.AuthInfo = authInfo_1.AuthInfo; | ||
exports.OAuth2WithVerifier = authInfo_1.OAuth2WithVerifier; | ||
exports.SfdcUrl = authInfo_1.SfdcUrl; | ||
@@ -35,0 +36,0 @@ var connection_1 = require("./connection"); |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { Nullable } from '@salesforce/ts-types'; | ||
@@ -3,0 +2,0 @@ import * as childProcess from 'child_process'; |
@@ -105,8 +105,12 @@ "use strict"; | ||
let stderr = ''; | ||
credManager.stdout.on('data', data => { | ||
stdout += data; | ||
}); | ||
credManager.stderr.on('data', data => { | ||
stderr += data; | ||
}); | ||
if (credManager.stdout) { | ||
credManager.stdout.on('data', data => { | ||
stdout += data; | ||
}); | ||
} | ||
if (credManager.stderr) { | ||
credManager.stderr.on('data', data => { | ||
stderr += data; | ||
}); | ||
} | ||
credManager.on('close', async (code) => { | ||
@@ -129,3 +133,5 @@ try { | ||
}); | ||
credManager.stdin.end(); | ||
if (credManager.stdin) { | ||
credManager.stdin.end(); | ||
} | ||
} | ||
@@ -154,10 +160,16 @@ /** | ||
let stderr = ''; | ||
credManager.stdout.on('data', (data) => { | ||
stdout += data; | ||
}); | ||
credManager.stderr.on('data', (data) => { | ||
stderr += data; | ||
}); | ||
if (credManager.stdout) { | ||
credManager.stdout.on('data', (data) => { | ||
stdout += data; | ||
}); | ||
} | ||
if (credManager.stderr) { | ||
credManager.stderr.on('data', (data) => { | ||
stderr += data; | ||
}); | ||
} | ||
credManager.on('close', async (code) => await this.osImpl.onSetCommandClose(code, stdout, stderr, opts, fn)); | ||
credManager.stdin.end(); | ||
if (credManager.stdin) { | ||
credManager.stdin.end(); | ||
} | ||
} | ||
@@ -206,3 +218,5 @@ } | ||
const secretTool = fn(_linuxImpl.getProgram(), _linuxImpl.setProgramOptions(opts)); | ||
secretTool.stdin.write(`${opts.password}\n`); | ||
if (secretTool.stdin) { | ||
secretTool.stdin.write(`${opts.password}\n`); | ||
} | ||
return secretTool; | ||
@@ -209,0 +223,0 @@ }, |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { Writable } from 'stream'; | ||
@@ -264,3 +263,3 @@ /** | ||
*/ | ||
addFilter(filter: (...args: Array<unknown>) => unknown): void; | ||
addFilter(filter: (...args: unknown[]) => unknown): void; | ||
/** | ||
@@ -298,3 +297,3 @@ * Close the logger, including any streams, and remove all listeners. | ||
*/ | ||
debug(...args: Array<unknown>): Logger; | ||
debug(...args: unknown[]): Logger; | ||
/** | ||
@@ -305,3 +304,3 @@ * Logs at `debug` level with filtering applied. | ||
*/ | ||
debugCallback(cb: () => Array<unknown> | string): void; | ||
debugCallback(cb: () => unknown[] | string): void; | ||
/** | ||
@@ -312,3 +311,3 @@ * Logs at `info` level with filtering applied. For convenience `this` object is returned. | ||
*/ | ||
info(...args: Array<unknown>): Logger; | ||
info(...args: unknown[]): Logger; | ||
/** | ||
@@ -319,3 +318,3 @@ * Logs at `warn` level with filtering applied. For convenience `this` object is returned. | ||
*/ | ||
warn(...args: Array<unknown>): Logger; | ||
warn(...args: unknown[]): Logger; | ||
/** | ||
@@ -326,3 +325,3 @@ * Logs at `error` level with filtering applied. For convenience `this` object is returned. | ||
*/ | ||
error(...args: Array<unknown>): Logger; | ||
error(...args: unknown[]): Logger; | ||
/** | ||
@@ -333,3 +332,3 @@ * Logs at `fatal` level with filtering applied. For convenience `this` object is returned. | ||
*/ | ||
fatal(...args: Array<unknown>): Logger; | ||
fatal(...args: unknown[]): Logger; | ||
private applyFilters; | ||
@@ -336,0 +335,0 @@ private uncaughtExceptionHandler; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { Optional } from '@salesforce/ts-types'; | ||
@@ -3,0 +2,0 @@ /** |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { URL } from 'url'; | ||
@@ -3,0 +2,0 @@ import { AsyncOptionalCreatable, Duration } from '@salesforce/kit'; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { AsyncOptionalCreatable, Duration, Env } from '@salesforce/kit'; | ||
@@ -3,0 +2,0 @@ import { AnyFunction, AnyJson, JsonMap } from '@salesforce/ts-types'; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import * as sinonType from 'sinon'; | ||
@@ -287,2 +286,3 @@ import { AnyJson, JsonMap, Optional } from '@salesforce/ts-types'; | ||
userId: string; | ||
redirectUri: string; | ||
constructor(id?: string); | ||
@@ -289,0 +289,0 @@ createDevHubUsername(username: string): void; |
@@ -329,2 +329,3 @@ "use strict"; | ||
this.refreshToken = `${this.testId}/refreshToken`; | ||
this.redirectUri = `http://${this.testId}/localhost:1717/OauthRedirect`; | ||
} | ||
@@ -347,2 +348,3 @@ createDevHubUsername(username) { | ||
userMock.clientSecret = this.clientSecret; | ||
userMock.redirectUri = this.redirectUri; | ||
return userMock; | ||
@@ -349,0 +351,0 @@ } |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { AnyJson, JsonMap } from '@salesforce/ts-types'; | ||
@@ -3,0 +2,0 @@ import * as fsLib from 'fs'; |
{ | ||
"name": "@salesforce/core", | ||
"version": "2.1.3", | ||
"version": "2.1.4", | ||
"description": "Core libraries to interact with SFDX projects, orgs, and APIs.", | ||
@@ -48,3 +48,3 @@ "main": "lib/exported", | ||
"jsen": "0.6.6", | ||
"jsforce": "1.8.5", | ||
"jsforce": "1.9.3", | ||
"jsonwebtoken": "8.5.0", | ||
@@ -51,0 +51,0 @@ "mkdirp": "0.5.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
444632
11120
+ Addedbase64-url@2.3.3(transitive)
+ Addedcsv-parse@4.16.3(transitive)
+ Addedjsforce@1.9.3(transitive)
- Removedcsv-parse@1.3.3(transitive)
- Removedjsforce@1.8.5(transitive)
Updatedjsforce@1.9.3