@yume-chan/adb-credential-web 0.0.15 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.rush/temp/package-deps_build.json +4 -4
- package/.rush/temp/package-deps_build_watch.json +4 -4
- package/.rush/temp/shrinkwrap-deps.json +3 -2
- package/CHANGELOG.json +24 -0
- package/CHANGELOG.md +15 -1
- package/README.md +26 -26
- package/adb-credential-web.build.log +0 -1
- package/package.json +6 -7
- package/src/index.ts +51 -51
- package/tsconfig.json +14 -14
- package/.rush/temp/package-deps_build +0 -0
- package/.rush/temp/package-deps_postinstall.json +0 -12
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
|
-
"libraries/adb-credential-web/.rush/temp/shrinkwrap-deps.json": "
|
|
4
|
-
"libraries/adb-credential-web/CHANGELOG.json": "
|
|
5
|
-
"libraries/adb-credential-web/CHANGELOG.md": "
|
|
3
|
+
"libraries/adb-credential-web/.rush/temp/shrinkwrap-deps.json": "286b484a6229121d661cebc7b6a84931db8ee1a4",
|
|
4
|
+
"libraries/adb-credential-web/CHANGELOG.json": "a726d5109dba989d17f82682be500328707f031e",
|
|
5
|
+
"libraries/adb-credential-web/CHANGELOG.md": "d30f3da170a29d165274a922b2a990eb75a27928",
|
|
6
6
|
"libraries/adb-credential-web/README.md": "35dc273a753ae6f722bad96ae6e52efe9b2d6840",
|
|
7
|
-
"libraries/adb-credential-web/package.json": "
|
|
7
|
+
"libraries/adb-credential-web/package.json": "cdb381649b4019a27d45fc9ff074459c5b85ba47",
|
|
8
8
|
"libraries/adb-credential-web/src/index.ts": "42f5ead9cfde7266096dce1e82f3c7cc0309986b",
|
|
9
9
|
"libraries/adb-credential-web/tsconfig.json": "43cb24d0667828c30374e15c5930a55ea1b0bb7e"
|
|
10
10
|
},
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
|
-
"libraries/adb-credential-web/.rush/temp/shrinkwrap-deps.json": "
|
|
4
|
-
"libraries/adb-credential-web/CHANGELOG.json": "
|
|
5
|
-
"libraries/adb-credential-web/CHANGELOG.md": "
|
|
3
|
+
"libraries/adb-credential-web/.rush/temp/shrinkwrap-deps.json": "286b484a6229121d661cebc7b6a84931db8ee1a4",
|
|
4
|
+
"libraries/adb-credential-web/CHANGELOG.json": "a726d5109dba989d17f82682be500328707f031e",
|
|
5
|
+
"libraries/adb-credential-web/CHANGELOG.md": "d30f3da170a29d165274a922b2a990eb75a27928",
|
|
6
6
|
"libraries/adb-credential-web/README.md": "35dc273a753ae6f722bad96ae6e52efe9b2d6840",
|
|
7
|
-
"libraries/adb-credential-web/package.json": "
|
|
7
|
+
"libraries/adb-credential-web/package.json": "cdb381649b4019a27d45fc9ff074459c5b85ba47",
|
|
8
8
|
"libraries/adb-credential-web/src/index.ts": "42f5ead9cfde7266096dce1e82f3c7cc0309986b",
|
|
9
9
|
"libraries/adb-credential-web/tsconfig.json": "43cb24d0667828c30374e15c5930a55ea1b0bb7e"
|
|
10
10
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
2
|
+
"../../libraries/adb-credential-web": "../../libraries/adb-credential-web:FyPocPToKIuA8/ZaRCmucFT4fiudVUg4sA09EqNBROg=:",
|
|
3
|
+
"/tslib/2.4.0": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==",
|
|
4
|
+
"/typescript/4.7.4": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ=="
|
|
4
5
|
}
|
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yume-chan/adb-credential-web",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.0.17",
|
|
6
|
+
"tag": "@yume-chan/adb-credential-web_v0.0.17",
|
|
7
|
+
"date": "Tue, 18 Oct 2022 09:32:30 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Update to use new stream util package"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"version": "0.0.16",
|
|
18
|
+
"tag": "@yume-chan/adb-credential-web_v0.0.16",
|
|
19
|
+
"date": "Sat, 28 May 2022 03:56:37 GMT",
|
|
20
|
+
"comments": {
|
|
21
|
+
"none": [
|
|
22
|
+
{
|
|
23
|
+
"comment": "Upgrade TypeScript to 4.7.2 to enable Node.js ESM"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
4
28
|
{
|
|
5
29
|
"version": "0.0.15",
|
|
6
30
|
"tag": "@yume-chan/adb-credential-web_v0.0.15",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Change Log - @yume-chan/adb-credential-web
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 18 Oct 2022 09:32:30 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.0.17
|
|
6
|
+
Tue, 18 Oct 2022 09:32:30 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- Update to use new stream util package
|
|
11
|
+
|
|
12
|
+
## 0.0.16
|
|
13
|
+
Sat, 28 May 2022 03:56:37 GMT
|
|
14
|
+
|
|
15
|
+
### Updates
|
|
16
|
+
|
|
17
|
+
- Upgrade TypeScript to 4.7.2 to enable Node.js ESM
|
|
4
18
|
|
|
5
19
|
## 0.0.15
|
|
6
20
|
Mon, 02 May 2022 04:18:01 GMT
|
package/README.md
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
# `@yume-chan/adb-credential-web`
|
|
2
|
-
|
|
3
|
-
Generate RSA keys using Web Crypto API ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)) and store them in LocalStorage ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API)).
|
|
4
|
-
|
|
5
|
-
- [`generateKey`](#generatekey)
|
|
6
|
-
- [`iterateKeys`](#iteratekeys)
|
|
7
|
-
|
|
8
|
-
## `generateKey`
|
|
9
|
-
|
|
10
|
-
```ts
|
|
11
|
-
async generateKey(): Promise<Uint8Array>
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Generate a RSA private key and store it into LocalStorage.
|
|
15
|
-
|
|
16
|
-
Calling this method multiple times will overwrite the previous key.
|
|
17
|
-
|
|
18
|
-
The returned `Uint8Array` is the private key in PKCS #8 format.
|
|
19
|
-
|
|
20
|
-
## `iterateKeys`
|
|
21
|
-
|
|
22
|
-
```ts
|
|
23
|
-
*iterateKeys(): Generator<Uint8Array, void, void>
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Return the stored RSA private key. (This implementation doesn't support storing multiple keys)
|
|
1
|
+
# `@yume-chan/adb-credential-web`
|
|
2
|
+
|
|
3
|
+
Generate RSA keys using Web Crypto API ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)) and store them in LocalStorage ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API)).
|
|
4
|
+
|
|
5
|
+
- [`generateKey`](#generatekey)
|
|
6
|
+
- [`iterateKeys`](#iteratekeys)
|
|
7
|
+
|
|
8
|
+
## `generateKey`
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
async generateKey(): Promise<Uint8Array>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Generate a RSA private key and store it into LocalStorage.
|
|
15
|
+
|
|
16
|
+
Calling this method multiple times will overwrite the previous key.
|
|
17
|
+
|
|
18
|
+
The returned `Uint8Array` is the private key in PKCS #8 format.
|
|
19
|
+
|
|
20
|
+
## `iterateKeys`
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
*iterateKeys(): Generator<Uint8Array, void, void>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Return the stored RSA private key. (This implementation doesn't support storing multiple keys)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yume-chan/adb-credential-web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "Credential Store for `@yume-chan/adb` using Web LocalStorage API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adb"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"email": "cnsimonchan@live.com",
|
|
12
12
|
"url": "https://chensi.moe/blog"
|
|
13
13
|
},
|
|
14
|
-
"homepage": "https://github.com/yume-chan/ya-webadb/tree/
|
|
14
|
+
"homepage": "https://github.com/yume-chan/ya-webadb/tree/main/libraries/adb-credential-web#readme",
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "git+https://github.com/yume-chan/ya-webadb.git",
|
|
@@ -24,16 +24,15 @@
|
|
|
24
24
|
"main": "esm/index.js",
|
|
25
25
|
"types": "esm/index.d.ts",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"typescript": "4.7.
|
|
27
|
+
"typescript": "^4.7.4",
|
|
28
28
|
"@yume-chan/ts-package-builder": "^1.0.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@yume-chan/adb": "^0.0.
|
|
32
|
-
"tslib": "^2.
|
|
31
|
+
"@yume-chan/adb": "^0.0.17",
|
|
32
|
+
"tslib": "^2.4.0"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "build-ts-package",
|
|
36
36
|
"build:watch": "build-ts-package --incremental"
|
|
37
|
-
}
|
|
38
|
-
"readme": "# `@yume-chan/adb-credential-web`\r\n\r\nGenerate RSA keys using Web Crypto API ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)) and store them in LocalStorage ([MDN](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API)).\r\n\r\n- [`generateKey`](#generatekey)\r\n- [`iterateKeys`](#iteratekeys)\r\n\r\n## `generateKey`\r\n\r\n```ts\r\nasync generateKey(): Promise<Uint8Array>\r\n```\r\n\r\nGenerate a RSA private key and store it into LocalStorage.\r\n\r\nCalling this method multiple times will overwrite the previous key.\r\n\r\nThe returned `Uint8Array` is the private key in PKCS #8 format.\r\n\r\n## `iterateKeys`\r\n\r\n```ts\r\n*iterateKeys(): Generator<Uint8Array, void, void>\r\n```\r\n\r\nReturn the stored RSA private key. (This implementation doesn't support storing multiple keys)\r\n"
|
|
37
|
+
}
|
|
39
38
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
// cspell: ignore RSASSA
|
|
2
|
-
|
|
3
|
-
import { calculateBase64EncodedLength, calculatePublicKey, calculatePublicKeyLength, decodeBase64, decodeUtf8, encodeBase64, type AdbCredentialStore } from "@yume-chan/adb";
|
|
4
|
-
|
|
5
|
-
export default class AdbWebCredentialStore implements AdbCredentialStore {
|
|
6
|
-
public readonly localStorageKey: string;
|
|
7
|
-
|
|
8
|
-
public constructor(localStorageKey = 'private-key') {
|
|
9
|
-
this.localStorageKey = localStorageKey;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
public *iterateKeys(): Generator<Uint8Array, void, void> {
|
|
13
|
-
const privateKey = window.localStorage.getItem(this.localStorageKey);
|
|
14
|
-
if (privateKey) {
|
|
15
|
-
yield decodeBase64(privateKey);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public async generateKey(): Promise<Uint8Array> {
|
|
20
|
-
const { privateKey: cryptoKey } = await crypto.subtle.generateKey(
|
|
21
|
-
{
|
|
22
|
-
name: 'RSASSA-PKCS1-v1_5',
|
|
23
|
-
modulusLength: 2048,
|
|
24
|
-
// 65537
|
|
25
|
-
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
|
|
26
|
-
hash: 'SHA-1',
|
|
27
|
-
},
|
|
28
|
-
true,
|
|
29
|
-
['sign', 'verify']
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const privateKey = new Uint8Array(await crypto.subtle.exportKey('pkcs8', cryptoKey!));
|
|
33
|
-
window.localStorage.setItem(this.localStorageKey, decodeUtf8(encodeBase64(privateKey)));
|
|
34
|
-
|
|
35
|
-
// The authentication module in core doesn't need public keys.
|
|
36
|
-
// It will generate the public key from private key every time.
|
|
37
|
-
// However, maybe there are people want to manually put this public key onto their device,
|
|
38
|
-
// so also save the public key for their convenience.
|
|
39
|
-
const publicKeyLength = calculatePublicKeyLength();
|
|
40
|
-
const [publicKeyBase64Length] = calculateBase64EncodedLength(publicKeyLength);
|
|
41
|
-
const publicKeyBuffer = new Uint8Array(publicKeyBase64Length);
|
|
42
|
-
calculatePublicKey(privateKey, publicKeyBuffer);
|
|
43
|
-
encodeBase64(
|
|
44
|
-
publicKeyBuffer.subarray(0, publicKeyLength),
|
|
45
|
-
publicKeyBuffer
|
|
46
|
-
);
|
|
47
|
-
window.localStorage.setItem(this.localStorageKey + '.pub', decodeUtf8(publicKeyBuffer));
|
|
48
|
-
|
|
49
|
-
return privateKey;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
1
|
+
// cspell: ignore RSASSA
|
|
2
|
+
|
|
3
|
+
import { calculateBase64EncodedLength, calculatePublicKey, calculatePublicKeyLength, decodeBase64, decodeUtf8, encodeBase64, type AdbCredentialStore } from "@yume-chan/adb";
|
|
4
|
+
|
|
5
|
+
export default class AdbWebCredentialStore implements AdbCredentialStore {
|
|
6
|
+
public readonly localStorageKey: string;
|
|
7
|
+
|
|
8
|
+
public constructor(localStorageKey = 'private-key') {
|
|
9
|
+
this.localStorageKey = localStorageKey;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public *iterateKeys(): Generator<Uint8Array, void, void> {
|
|
13
|
+
const privateKey = window.localStorage.getItem(this.localStorageKey);
|
|
14
|
+
if (privateKey) {
|
|
15
|
+
yield decodeBase64(privateKey);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public async generateKey(): Promise<Uint8Array> {
|
|
20
|
+
const { privateKey: cryptoKey } = await crypto.subtle.generateKey(
|
|
21
|
+
{
|
|
22
|
+
name: 'RSASSA-PKCS1-v1_5',
|
|
23
|
+
modulusLength: 2048,
|
|
24
|
+
// 65537
|
|
25
|
+
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
|
|
26
|
+
hash: 'SHA-1',
|
|
27
|
+
},
|
|
28
|
+
true,
|
|
29
|
+
['sign', 'verify']
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const privateKey = new Uint8Array(await crypto.subtle.exportKey('pkcs8', cryptoKey!));
|
|
33
|
+
window.localStorage.setItem(this.localStorageKey, decodeUtf8(encodeBase64(privateKey)));
|
|
34
|
+
|
|
35
|
+
// The authentication module in core doesn't need public keys.
|
|
36
|
+
// It will generate the public key from private key every time.
|
|
37
|
+
// However, maybe there are people want to manually put this public key onto their device,
|
|
38
|
+
// so also save the public key for their convenience.
|
|
39
|
+
const publicKeyLength = calculatePublicKeyLength();
|
|
40
|
+
const [publicKeyBase64Length] = calculateBase64EncodedLength(publicKeyLength);
|
|
41
|
+
const publicKeyBuffer = new Uint8Array(publicKeyBase64Length);
|
|
42
|
+
calculatePublicKey(privateKey, publicKeyBuffer);
|
|
43
|
+
encodeBase64(
|
|
44
|
+
publicKeyBuffer.subarray(0, publicKeyLength),
|
|
45
|
+
publicKeyBuffer
|
|
46
|
+
);
|
|
47
|
+
window.localStorage.setItem(this.localStorageKey + '.pub', decodeUtf8(publicKeyBuffer));
|
|
48
|
+
|
|
49
|
+
return privateKey;
|
|
50
|
+
}
|
|
51
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./node_modules/@yume-chan/ts-package-builder/tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"lib": [
|
|
5
|
-
"ESNext",
|
|
6
|
-
"DOM"
|
|
7
|
-
],
|
|
8
|
-
},
|
|
9
|
-
"references": [
|
|
10
|
-
{
|
|
11
|
-
"path": "../adb/tsconfig.build.json"
|
|
12
|
-
}
|
|
13
|
-
]
|
|
14
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "./node_modules/@yume-chan/ts-package-builder/tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"lib": [
|
|
5
|
+
"ESNext",
|
|
6
|
+
"DOM"
|
|
7
|
+
],
|
|
8
|
+
},
|
|
9
|
+
"references": [
|
|
10
|
+
{
|
|
11
|
+
"path": "../adb/tsconfig.build.json"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
File without changes
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"files": {
|
|
3
|
-
"libraries/adb-credential-web/.rush/temp/shrinkwrap-deps.json": "7af6854cfa1793d25c7925569515eabafc855d04",
|
|
4
|
-
"libraries/adb-credential-web/CHANGELOG.json": "bdb99f8ca3eff53b8b260fae2e230e34d55a6902",
|
|
5
|
-
"libraries/adb-credential-web/CHANGELOG.md": "89f2ed92996da15a9f5ac27a7ff3d64b58b72f35",
|
|
6
|
-
"libraries/adb-credential-web/README.md": "842d937a3588938e938cc11ec157f820a8825418",
|
|
7
|
-
"libraries/adb-credential-web/package.json": "1ffae23b46edfaf644734e9dcf5cc15eaeb150ba",
|
|
8
|
-
"libraries/adb-credential-web/src/index.ts": "665518496f9ef6f8cc212e7a0636533b39763516",
|
|
9
|
-
"libraries/adb-credential-web/tsconfig.json": "07f9242b115ab18b8e8d2564d25d32349ffb21cb"
|
|
10
|
-
},
|
|
11
|
-
"arguments": ""
|
|
12
|
-
}
|