@yume-chan/adb-credential-web 0.0.13 → 0.0.16

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.
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "files": {
3
- "libraries/adb-credential-web/.rush/temp/shrinkwrap-deps.json": "33b90fa9ac2c165d2c550be4daa30217e725766d",
4
- "libraries/adb-credential-web/CHANGELOG.json": "4bd9bb01844f5d68579ef4fbbb5757399c86faa5",
5
- "libraries/adb-credential-web/CHANGELOG.md": "1efe083e89e217c2fee3e542ef5ab717ae56769c",
3
+ "libraries/adb-credential-web/.rush/temp/shrinkwrap-deps.json": "7a8b693a797f929a5184cf7a08cda9ced8e4a529",
4
+ "libraries/adb-credential-web/CHANGELOG.json": "349b121b3c7a4225d77f152b2cea51ca176f086f",
5
+ "libraries/adb-credential-web/CHANGELOG.md": "ac6d72956e3a9978d4944b0b53f153eec79688a3",
6
6
  "libraries/adb-credential-web/README.md": "35dc273a753ae6f722bad96ae6e52efe9b2d6840",
7
- "libraries/adb-credential-web/package.json": "4f44ba4eb7d52639bd2f13c49714f775f6762b9c",
7
+ "libraries/adb-credential-web/package.json": "82627075a49184ef9e61ab7c2fbb276a12e0c42a",
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": "33b90fa9ac2c165d2c550be4daa30217e725766d",
4
- "libraries/adb-credential-web/CHANGELOG.json": "4bd9bb01844f5d68579ef4fbbb5757399c86faa5",
5
- "libraries/adb-credential-web/CHANGELOG.md": "1efe083e89e217c2fee3e542ef5ab717ae56769c",
3
+ "libraries/adb-credential-web/.rush/temp/shrinkwrap-deps.json": "7a8b693a797f929a5184cf7a08cda9ced8e4a529",
4
+ "libraries/adb-credential-web/CHANGELOG.json": "349b121b3c7a4225d77f152b2cea51ca176f086f",
5
+ "libraries/adb-credential-web/CHANGELOG.md": "ac6d72956e3a9978d4944b0b53f153eec79688a3",
6
6
  "libraries/adb-credential-web/README.md": "35dc273a753ae6f722bad96ae6e52efe9b2d6840",
7
- "libraries/adb-credential-web/package.json": "4f44ba4eb7d52639bd2f13c49714f775f6762b9c",
7
+ "libraries/adb-credential-web/package.json": "82627075a49184ef9e61ab7c2fbb276a12e0c42a",
8
8
  "libraries/adb-credential-web/src/index.ts": "42f5ead9cfde7266096dce1e82f3c7cc0309986b",
9
9
  "libraries/adb-credential-web/tsconfig.json": "43cb24d0667828c30374e15c5930a55ea1b0bb7e"
10
10
  },
@@ -1,4 +1,4 @@
1
1
  {
2
- "tslib@2.3.1": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==",
3
- "typescript@4.7.0-beta": "sha512-m+CNL8lzHyHDxYYDTI+pm5hw5/bufYVGan2bokPyJY/y9C/4W/PCWMtYZ0vV9fLXbEL57elMeoaz9Evxs8UQ+A=="
2
+ "tslib@2.4.0": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==",
3
+ "typescript@4.7.2": "sha512-Mamb1iX2FDUpcTRzltPxgWMKy3fhg0TN378ylbktPGPK/99KbDtMQ4W1hwgsbPAsG3a0xKa1vmw4VKZQbkvz5A=="
4
4
  }
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.16",
6
+ "tag": "@yume-chan/adb-credential-web_v0.0.16",
7
+ "date": "Sat, 28 May 2022 03:56:37 GMT",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "comment": "Upgrade TypeScript to 4.7.2 to enable Node.js ESM"
12
+ }
13
+ ]
14
+ }
15
+ },
16
+ {
17
+ "version": "0.0.15",
18
+ "tag": "@yume-chan/adb-credential-web_v0.0.15",
19
+ "date": "Mon, 02 May 2022 04:18:01 GMT",
20
+ "comments": {}
21
+ },
22
+ {
23
+ "version": "0.0.14",
24
+ "tag": "@yume-chan/adb-credential-web_v0.0.14",
25
+ "date": "Sat, 30 Apr 2022 14:05:48 GMT",
26
+ "comments": {}
27
+ },
4
28
  {
5
29
  "version": "0.0.13",
6
30
  "tag": "@yume-chan/adb-credential-web_v0.0.13",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,23 @@
1
1
  # Change Log - @yume-chan/adb-credential-web
2
2
 
3
- This log was last generated on Thu, 28 Apr 2022 01:23:53 GMT and should not be manually modified.
3
+ This log was last generated on Sat, 28 May 2022 03:56:37 GMT and should not be manually modified.
4
+
5
+ ## 0.0.16
6
+ Sat, 28 May 2022 03:56:37 GMT
7
+
8
+ ### Updates
9
+
10
+ - Upgrade TypeScript to 4.7.2 to enable Node.js ESM
11
+
12
+ ## 0.0.15
13
+ Mon, 02 May 2022 04:18:01 GMT
14
+
15
+ _Version update only_
16
+
17
+ ## 0.0.14
18
+ Sat, 30 Apr 2022 14:05:48 GMT
19
+
20
+ _Version update only_
4
21
 
5
22
  ## 0.0.13
6
23
  Thu, 28 Apr 2022 01:23:53 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)
@@ -1,2 +1,2 @@
1
- Invoking: build-ts-package
1
+ Invoking: build-ts-package --incremental
2
2
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yume-chan/adb-credential-web",
3
- "version": "0.0.13",
3
+ "version": "0.0.16",
4
4
  "description": "Credential Store for `@yume-chan/adb` using Web LocalStorage API.",
5
5
  "keywords": [
6
6
  "adb"
@@ -24,16 +24,16 @@
24
24
  "main": "esm/index.js",
25
25
  "types": "esm/index.d.ts",
26
26
  "devDependencies": {
27
- "typescript": "4.7.0-beta",
27
+ "typescript": "4.7.2",
28
28
  "@yume-chan/ts-package-builder": "^1.0.0"
29
29
  },
30
30
  "dependencies": {
31
- "@yume-chan/adb": "^0.0.13",
31
+ "@yume-chan/adb": "^0.0.16",
32
32
  "tslib": "^2.3.1"
33
33
  },
34
34
  "scripts": {
35
35
  "build": "build-ts-package",
36
36
  "build:watch": "build-ts-package --incremental"
37
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"
38
+ "readme": "# `@yume-chan/adb-credential-web`\n\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)).\n\n- [`generateKey`](#generatekey)\n- [`iterateKeys`](#iteratekeys)\n\n## `generateKey`\n\n```ts\nasync generateKey(): Promise<Uint8Array>\n```\n\nGenerate a RSA private key and store it into LocalStorage.\n\nCalling this method multiple times will overwrite the previous key.\n\nThe returned `Uint8Array` is the private key in PKCS #8 format.\n\n## `iterateKeys`\n\n```ts\n*iterateKeys(): Generator<Uint8Array, void, void>\n```\n\nReturn the stored RSA private key. (This implementation doesn't support storing multiple keys)\n"
39
39
  }
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
- }