Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
一杯枸杞茶ya
csdn-workflow
提交
58c26f20
C
csdn-workflow
项目概览
一杯枸杞茶ya
/
csdn-workflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
csdn-workflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
58c26f20
编写于
1月 25, 2021
作者:
T
Tomas Vik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(network): new API logic supports custom certificates
上级
34e37cf1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
62 addition
and
67 deletion
+62
-67
src/check_deprecated_certificate_settings.js
src/check_deprecated_certificate_settings.js
+0
-29
src/extension.js
src/extension.js
+0
-2
src/gitlab/gitlab_new_service.ts
src/gitlab/gitlab_new_service.ts
+14
-3
src/gitlab_service.ts
src/gitlab_service.ts
+2
-33
src/utils/get_http_agent_options.ts
src/utils/get_http_agent_options.ts
+46
-0
未找到文件。
src/check_deprecated_certificate_settings.js
已删除
100644 → 0
浏览文件 @
34e37cf1
const
vscode
=
require
(
'
vscode
'
);
const
{
openUrl
}
=
require
(
'
./openers
'
);
const
WARNED_FLAG_NAME
=
'
warnedAboutCertDeprecation
'
;
const
checkDeprecatedCertificateSettings
=
async
context
=>
{
const
{
ignoreCertificateErrors
,
ca
,
cert
,
certKey
}
=
vscode
.
workspace
.
getConfiguration
(
'
gitlab
'
,
);
if
(
(
ignoreCertificateErrors
||
ca
||
cert
||
certKey
)
&&
!
context
.
globalState
.
get
(
WARNED_FLAG_NAME
)
)
{
const
response
=
await
vscode
.
window
.
showWarningMessage
(
`
You are using settings to set custom certificate for connecting to your GitLab instance.
This configuration is going to get removed in the next major version of GitLab Workflow extension.`
,
'
See more details
'
,
"
Don't show again
"
,
);
if
(
response
===
"
Don't show again
"
)
{
context
.
globalState
.
update
(
WARNED_FLAG_NAME
,
true
);
}
else
if
(
response
===
'
See more details
'
)
{
openUrl
(
'
https://gitlab.com/gitlab-org/gitlab-vscode-extension/-/issues/247
'
);
}
}
};
module
.
exports
=
checkDeprecatedCertificateSettings
;
src/extension.js
浏览文件 @
58c26f20
...
...
@@ -13,7 +13,6 @@ const webviewController = require('./webview_controller');
const
IssuableDataProvider
=
require
(
'
./data_providers/issuable
'
).
DataProvider
;
const
CurrentBranchDataProvider
=
require
(
'
./data_providers/current_branch
'
).
DataProvider
;
const
{
initializeLogging
,
handleError
}
=
require
(
'
./log
'
);
const
checkDeprecatedCertificateSettings
=
require
(
'
./check_deprecated_certificate_settings
'
);
const
{
ApiContentProvider
}
=
require
(
'
./review/api_content_provider
'
);
const
{
REVIEW_URI_SCHEME
}
=
require
(
'
./constants
'
);
const
{
USER_COMMANDS
,
PROGRAMMATIC_COMMANDS
}
=
require
(
'
./command_names
'
);
...
...
@@ -98,7 +97,6 @@ const activate = context => {
webviewController
.
addDeps
(
context
);
tokenService
.
init
(
context
);
tokenServiceWrapper
.
init
(
context
);
checkDeprecatedCertificateSettings
(
context
);
registerCiCompletion
(
context
);
};
...
...
src/gitlab/gitlab_new_service.ts
浏览文件 @
58c26f20
import
*
as
vscode
from
'
vscode
'
;
import
*
as
https
from
'
https
'
;
import
{
GraphQLClient
,
gql
}
from
'
graphql-request
'
;
import
crossFetch
from
'
cross-fetch
'
;
import
{
URL
}
from
'
url
'
;
...
...
@@ -8,6 +9,7 @@ import { tokenService } from '../services/token_service';
import
{
FetchError
}
from
'
../errors/fetch_error
'
;
import
{
getUserAgentHeader
}
from
'
../utils/get_user_agent_header
'
;
import
{
getAvatarUrl
}
from
'
../utils/get_avatar_url
'
;
import
{
getHttpAgentOptions
}
from
'
../utils/get_http_agent_options
'
;
interface
Node
<
T
>
{
pageInfo
?:
{
...
...
@@ -214,16 +216,25 @@ export class GitLabNewService {
this
.
client
=
new
GraphQLClient
(
endpoint
,
this
.
fetchOptions
);
}
private
get
httpAgent
()
{
const
agentOptions
=
getHttpAgentOptions
();
if
(
agentOptions
.
proxy
)
{
return
createHttpProxyAgent
(
agentOptions
.
proxy
);
}
if
(
this
.
instanceUrl
.
startsWith
(
'
https://
'
))
{
return
new
https
.
Agent
(
agentOptions
);
}
return
undefined
;
}
private
get
fetchOptions
()
{
const
token
=
tokenService
.
getToken
(
this
.
instanceUrl
);
const
{
proxy
}
=
vscode
.
workspace
.
getConfiguration
(
'
http
'
);
const
agent
=
proxy
?
createHttpProxyAgent
(
proxy
)
:
undefined
;
return
{
headers
:
{
Authorization
:
`Bearer
${
token
}
`
,
...
getUserAgentHeader
(),
},
agent
,
agent
:
this
.
httpAgent
,
};
}
...
...
src/gitlab_service.ts
浏览文件 @
58c26f20
...
...
@@ -12,6 +12,7 @@ import { getUserAgentHeader } from './utils/get_user_agent_header';
import
{
CustomQueryType
}
from
'
./gitlab/custom_query_type
'
;
import
{
CustomQuery
}
from
'
./gitlab/custom_query
'
;
import
{
getAvatarUrl
}
from
'
./utils/get_avatar_url
'
;
import
{
getHttpAgentOptions
}
from
'
./utils/get_http_agent_options
'
;
interface
GitLabProject
{
id
:
number
;
...
...
@@ -53,11 +54,7 @@ const getInstanceUrl = async () =>
).
fetchCurrentInstanceUrl
();
async
function
fetch
(
path
:
string
,
method
=
'
GET
'
,
data
?:
Record
<
string
,
unknown
>
)
{
const
{
ignoreCertificateErrors
,
ca
,
cert
,
certKey
}
=
vscode
.
workspace
.
getConfiguration
(
'
gitlab
'
,
);
const
instanceUrl
=
await
getInstanceUrl
();
const
{
proxy
}
=
vscode
.
workspace
.
getConfiguration
(
'
http
'
);
const
apiRoot
=
`
${
instanceUrl
}
/api/v4`
;
const
glToken
=
tokenService
.
getToken
(
instanceUrl
);
const
tokens
=
tokenService
.
getInstanceUrls
().
join
(
'
,
'
);
...
...
@@ -83,37 +80,9 @@ async function fetch(path: string, method = 'GET', data?: Record<string, unknown
'
PRIVATE-TOKEN
'
:
glToken
,
...
getUserAgentHeader
(),
},
rejectUnauthorized
:
!
ignoreCertificateErrors
,
...
getHttpAgentOptions
()
,
};
if
(
proxy
)
{
config
.
proxy
=
proxy
;
}
if
(
ca
)
{
try
{
config
.
ca
=
fs
.
readFileSync
(
ca
);
}
catch
(
e
)
{
handleError
(
new
UserFriendlyError
(
`Cannot read CA '
${
ca
}
'`
,
e
));
}
}
if
(
cert
)
{
try
{
config
.
cert
=
fs
.
readFileSync
(
cert
);
}
catch
(
e
)
{
handleError
(
new
UserFriendlyError
(
`Cannot read CA '
${
cert
}
'`
,
e
));
}
}
if
(
certKey
)
{
try
{
config
.
key
=
fs
.
readFileSync
(
certKey
);
}
catch
(
e
)
{
handleError
(
new
UserFriendlyError
(
`Cannot read CA '
${
certKey
}
'`
,
e
));
}
}
if
(
data
)
{
config
.
formData
=
data
;
}
...
...
src/utils/get_http_agent_options.ts
0 → 100644
浏览文件 @
58c26f20
import
*
as
vscode
from
'
vscode
'
;
import
*
as
fs
from
'
fs
'
;
import
{
UserFriendlyError
}
from
'
../errors/user_friendly_error
'
;
import
{
handleError
}
from
'
../log
'
;
interface
GitLabHttpAgentOptions
{
ca
?:
Buffer
;
cert
?:
Buffer
;
key
?:
Buffer
;
proxy
?:
string
;
rejectUnauthorized
?:
boolean
;
}
export
const
getHttpAgentOptions
=
():
GitLabHttpAgentOptions
=>
{
const
result
:
GitLabHttpAgentOptions
=
{};
const
{
ignoreCertificateErrors
,
ca
,
cert
,
certKey
}
=
vscode
.
workspace
.
getConfiguration
(
'
gitlab
'
,
);
result
.
rejectUnauthorized
=
!
ignoreCertificateErrors
;
if
(
ca
)
{
try
{
result
.
ca
=
fs
.
readFileSync
(
ca
);
}
catch
(
e
)
{
handleError
(
new
UserFriendlyError
(
`Cannot read CA '
${
ca
}
'`
,
e
));
}
}
if
(
cert
)
{
try
{
result
.
cert
=
fs
.
readFileSync
(
cert
);
}
catch
(
e
)
{
handleError
(
new
UserFriendlyError
(
`Cannot read Certificate '
${
cert
}
'`
,
e
));
}
}
if
(
certKey
)
{
try
{
result
.
key
=
fs
.
readFileSync
(
certKey
);
}
catch
(
e
)
{
handleError
(
new
UserFriendlyError
(
`Cannot read Certificate Key '
${
certKey
}
'`
,
e
));
}
}
const
{
proxy
}
=
vscode
.
workspace
.
getConfiguration
(
'
http
'
);
result
.
proxy
=
proxy
||
undefined
;
return
result
;
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录