Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
fa7eba48
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fa7eba48
编写于
8月 28, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
extensions - fully provide keytar API
上级
b05051e5
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
33 addition
and
11 deletion
+33
-11
src/vs/base/test/node/keytar.test.ts
src/vs/base/test/node/keytar.test.ts
+2
-0
src/vs/workbench/api/browser/mainThreadKeytar.ts
src/vs/workbench/api/browser/mainThreadKeytar.ts
+4
-0
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+1
-0
src/vs/workbench/api/common/extHostRequireInterceptor.ts
src/vs/workbench/api/common/extHostRequireInterceptor.ts
+4
-0
src/vs/workbench/services/credentials/browser/credentialsService.ts
...kbench/services/credentials/browser/credentialsService.ts
+15
-4
src/vs/workbench/services/credentials/common/credentials.ts
src/vs/workbench/services/credentials/common/credentials.ts
+1
-0
src/vs/workbench/services/credentials/node/credentialsService.ts
...workbench/services/credentials/node/credentialsService.ts
+6
-7
未找到文件。
src/vs/base/test/node/keytar.test.ts
浏览文件 @
fa7eba48
...
...
@@ -18,6 +18,8 @@ suite('Keytar', () => {
const
name
=
`VSCode Test
${
Math
.
floor
(
Math
.
random
()
*
1
e9
)}
`
;
try
{
await
keytar
.
setPassword
(
name
,
'
foo
'
,
'
bar
'
);
assert
.
equal
(
await
keytar
.
findPassword
(
name
),
'
bar
'
);
assert
.
equal
((
await
keytar
.
findCredentials
(
name
)).
length
,
1
);
assert
.
equal
(
await
keytar
.
getPassword
(
name
,
'
foo
'
),
'
bar
'
);
await
keytar
.
deletePassword
(
name
,
'
foo
'
);
assert
.
equal
(
await
keytar
.
getPassword
(
name
,
'
foo
'
),
undefined
);
...
...
src/vs/workbench/api/browser/mainThreadKeytar.ts
浏览文件 @
fa7eba48
...
...
@@ -31,6 +31,10 @@ export class MainThreadKeytar implements MainThreadKeytarShape {
return
this
.
_credentialsService
.
findPassword
(
service
);
}
async
$findCredentials
(
service
:
string
):
Promise
<
Array
<
{
account
:
string
,
password
:
string
}
>>
{
return
this
.
_credentialsService
.
findCredentials
(
service
);
}
dispose
():
void
{
//
}
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
fa7eba48
...
...
@@ -263,6 +263,7 @@ export interface MainThreadKeytarShape extends IDisposable {
$setPassword
(
service
:
string
,
account
:
string
,
password
:
string
):
Promise
<
void
>
;
$deletePassword
(
service
:
string
,
account
:
string
):
Promise
<
boolean
>
;
$findPassword
(
service
:
string
):
Promise
<
string
|
null
>
;
$findCredentials
(
service
:
string
):
Promise
<
Array
<
{
account
:
string
,
password
:
string
}
>>
;
}
export
interface
IRegExpDto
{
...
...
src/vs/workbench/api/common/extHostRequireInterceptor.ts
浏览文件 @
fa7eba48
...
...
@@ -129,6 +129,7 @@ interface IKeytarModule {
setPassword
(
service
:
string
,
account
:
string
,
password
:
string
):
Promise
<
void
>
;
deletePassword
(
service
:
string
,
account
:
string
):
Promise
<
boolean
>
;
findPassword
(
service
:
string
):
Promise
<
string
|
null
>
;
findCredentials
(
service
:
string
):
Promise
<
Array
<
{
account
:
string
,
password
:
string
}
>>
;
}
class
KeytarNodeModuleFactory
implements
INodeModuleFactory
{
...
...
@@ -169,6 +170,9 @@ class KeytarNodeModuleFactory implements INodeModuleFactory {
},
findPassword
:
(
service
:
string
):
Promise
<
string
|
null
>
=>
{
return
mainThreadKeytar
.
$findPassword
(
service
);
},
findCredentials
(
service
:
string
):
Promise
<
Array
<
{
account
:
string
,
password
:
string
}
>>
{
return
mainThreadKeytar
.
$findCredentials
(
service
);
}
};
}
...
...
src/vs/workbench/services/credentials/browser/credentialsService.ts
浏览文件 @
fa7eba48
...
...
@@ -13,6 +13,7 @@ export interface ICredentialsProvider {
setPassword
(
service
:
string
,
account
:
string
,
password
:
string
):
Promise
<
void
>
;
deletePassword
(
service
:
string
,
account
:
string
):
Promise
<
boolean
>
;
findPassword
(
service
:
string
):
Promise
<
string
|
null
>
;
findCredentials
(
service
:
string
):
Promise
<
Array
<
{
account
:
string
,
password
:
string
}
>>
;
}
export
class
BrowserCredentialsService
implements
ICredentialsService
{
...
...
@@ -29,21 +30,25 @@ export class BrowserCredentialsService implements ICredentialsService {
}
}
async
getPassword
(
service
:
string
,
account
:
string
):
Promise
<
string
|
null
>
{
getPassword
(
service
:
string
,
account
:
string
):
Promise
<
string
|
null
>
{
return
this
.
credentialsProvider
.
getPassword
(
service
,
account
);
}
async
setPassword
(
service
:
string
,
account
:
string
,
password
:
string
):
Promise
<
void
>
{
setPassword
(
service
:
string
,
account
:
string
,
password
:
string
):
Promise
<
void
>
{
return
this
.
credentialsProvider
.
setPassword
(
service
,
account
,
password
);
}
async
deletePassword
(
service
:
string
,
account
:
string
):
Promise
<
boolean
>
{
deletePassword
(
service
:
string
,
account
:
string
):
Promise
<
boolean
>
{
return
this
.
credentialsProvider
.
deletePassword
(
service
,
account
);
}
async
findPassword
(
service
:
string
):
Promise
<
string
|
null
>
{
findPassword
(
service
:
string
):
Promise
<
string
|
null
>
{
return
this
.
credentialsProvider
.
findPassword
(
service
);
}
findCredentials
(
service
:
string
):
Promise
<
Array
<
{
account
:
string
,
password
:
string
}
>>
{
return
this
.
credentialsProvider
.
findCredentials
(
service
);
}
}
interface
ICredential
{
...
...
@@ -127,6 +132,12 @@ class LocalStorageCredentialsProvider implements ICredentialsProvider {
async
findPassword
(
service
:
string
):
Promise
<
string
|
null
>
{
return
this
.
doGetPassword
(
service
);
}
async
findCredentials
(
service
:
string
):
Promise
<
Array
<
{
account
:
string
,
password
:
string
}
>>
{
return
this
.
credentials
.
filter
(
credential
=>
credential
.
service
===
service
)
.
map
(({
account
,
password
})
=>
({
account
,
password
}));
}
}
registerSingleton
(
ICredentialsService
,
BrowserCredentialsService
,
true
);
src/vs/workbench/services/credentials/common/credentials.ts
浏览文件 @
fa7eba48
...
...
@@ -15,4 +15,5 @@ export interface ICredentialsService {
setPassword
(
service
:
string
,
account
:
string
,
password
:
string
):
Promise
<
void
>
;
deletePassword
(
service
:
string
,
account
:
string
):
Promise
<
boolean
>
;
findPassword
(
service
:
string
):
Promise
<
string
|
null
>
;
findCredentials
(
service
:
string
):
Promise
<
Array
<
{
account
:
string
,
password
:
string
}
>>
;
}
src/vs/workbench/services/credentials/node/credentialsService.ts
浏览文件 @
fa7eba48
...
...
@@ -8,13 +8,7 @@ import { IdleValue } from 'vs/base/common/async';
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
type
KeytarModule
=
{
getPassword
(
service
:
string
,
account
:
string
):
Promise
<
string
|
null
>
;
setPassword
(
service
:
string
,
account
:
string
,
password
:
string
):
Promise
<
void
>
;
deletePassword
(
service
:
string
,
account
:
string
):
Promise
<
boolean
>
;
findPassword
(
service
:
string
):
Promise
<
string
|
null
>
;
};
type
KeytarModule
=
typeof
import
(
'
keytar
'
);
export
class
KeytarCredentialsService
implements
ICredentialsService
{
_serviceBrand
!
:
ServiceIdentifier
<
any
>
;
...
...
@@ -40,6 +34,11 @@ export class KeytarCredentialsService implements ICredentialsService {
const
keytar
=
await
this
.
_keytar
.
getValue
();
return
keytar
.
findPassword
(
service
);
}
async
findCredentials
(
service
:
string
):
Promise
<
Array
<
{
account
:
string
,
password
:
string
}
>>
{
const
keytar
=
await
this
.
_keytar
.
getValue
();
return
keytar
.
findCredentials
(
service
);
}
}
registerSingleton
(
ICredentialsService
,
KeytarCredentialsService
,
true
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录