Skip to content

Commit

Permalink
fix(invoke): use sessionToken
Browse files Browse the repository at this point in the history
use sessionToken
  • Loading branch information
louiswu committed Apr 30, 2019
1 parent 1ab4ee0 commit c31d3d7
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 22 deletions.
1 change: 1 addition & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as services from './services';
interface InitConfig {
secretId: any;
secretKey: any;
token?: any;
region: any;
}
declare class SDK {
Expand Down
1 change: 1 addition & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SDK {
const __config = Object.assign({}, {
secretId: process.env.TENCENTCLOUD_SECRETID,
secretKey: process.env.TENCENTCLOUD_SECRETKEY,
token: process.env.TENCENTCLOUD_SESSIONTOKEN,
region: 'ap-guangzhou'
}, config);
if (!__config.secretId || !__config.secretKey)
Expand Down
8 changes: 5 additions & 3 deletions dist/services/invoke.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const utils_1 = require("../helper/utils");
async function default_1(params) {
const requestHelper = this.requestHelper;
const region = this.config.region;
const __params = utils_1.caseForObject(Object.assign({
let __params = Object.assign({
region,
namespace: 'default',
qualifier: '$LATEST'
Expand All @@ -13,8 +13,10 @@ async function default_1(params) {
logType: 'Tail',
version: '2018-04-16',
action: 'Invoke'
}), 'upper');
return await requestHelper(__params, {
});
if (this.config.token)
__params.token = this.config.token;
return await requestHelper(utils_1.caseForObject(__params, 'upper'), {
serviceType: 'scf'
});
}
Expand Down
2 changes: 1 addition & 1 deletion node_modules/qcloudapi-sdk/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as util from 'util'
interface InitConfig {
secretId
secretKey
token?
region
}

Expand All @@ -18,6 +19,7 @@ class SDK {
{
secretId: process.env.TENCENTCLOUD_SECRETID,
secretKey: process.env.TENCENTCLOUD_SECRETKEY,
token: process.env.TENCENTCLOUD_SESSIONTOKEN,
region: 'ap-guangzhou'
},
config
Expand Down
36 changes: 18 additions & 18 deletions src/services/invoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ export default async function(params: Params): Promise<Res> {
const requestHelper = this.requestHelper
const region = this.config.region

const __params = caseForObject(
Object.assign(
{
region,
namespace: 'default',
qualifier: '$LATEST'
},
params,
{
invocationType: 'RequestResponse',
logType: 'Tail',
version: '2018-04-16',
action: 'Invoke'
}
),
'upper'
)
return await requestHelper(__params, {
let __params = Object.assign(
{
region,
namespace: 'default',
qualifier: '$LATEST'
},
params,
{
invocationType: 'RequestResponse',
logType: 'Tail',
version: '2018-04-16',
action: 'Invoke'
}
) as any

if (this.config.token) __params.token = this.config.token

return await requestHelper(caseForObject(__params, 'upper'), {
serviceType: 'scf'
})
}

0 comments on commit c31d3d7

Please sign in to comment.