@dxos/credentials 2.33.8-dev.c77ba621 → 2.33.8
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 +11 -10
- package/.rush/temp/package-deps_build_test.json +11 -10
- package/.rush/temp/shrinkwrap-deps.json +11 -1
- package/credentials.build.log +10 -8
- package/dist/src/auth/auth-plugin.test.js +4 -4
- package/dist/src/auth/auth-plugin.test.js.map +1 -1
- package/dist/src/greet/greeter-plugin.test.js +4 -4
- package/dist/src/greet/greeter-plugin.test.js.map +1 -1
- package/dist/src/greet/greeting-command-plugin.d.ts.map +1 -1
- package/dist/src/greet/greeting-command-plugin.js +3 -3
- package/dist/src/greet/greeting-command-plugin.js.map +1 -1
- package/dist/src/identity/index.d.ts +1 -0
- package/dist/src/identity/index.d.ts.map +1 -1
- package/dist/src/identity/index.js +1 -0
- package/dist/src/identity/index.js.map +1 -1
- package/dist/src/identity/seedphrase.d.ts +9 -0
- package/dist/src/identity/seedphrase.d.ts.map +1 -0
- package/dist/src/identity/seedphrase.js +28 -0
- package/dist/src/identity/seedphrase.js.map +1 -0
- package/dist/src/identity/seedphrase.test.js +18 -3
- package/dist/src/identity/seedphrase.test.js.map +1 -1
- package/dist/src/keys/keyring-helpers.d.ts.map +1 -1
- package/dist/src/keys/keyring-helpers.js +2 -2
- package/dist/src/keys/keyring-helpers.js.map +1 -1
- package/dist/src/keys/keyring.js +1 -1
- package/dist/src/keys/keyring.js.map +1 -1
- package/dist/src/keys/keyring.test.js +3 -3
- package/dist/src/keys/keyring.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -12
- package/src/auth/auth-plugin.test.ts +5 -5
- package/src/greet/greeter-plugin.test.ts +5 -5
- package/src/greet/greeting-command-plugin.ts +3 -3
- package/src/identity/index.ts +1 -0
- package/src/identity/seedphrase.test.ts +19 -1
- package/src/identity/seedphrase.ts +24 -0
- package/src/keys/keyring-helpers.ts +2 -2
- package/src/keys/keyring.test.ts +4 -4
- package/src/keys/keyring.ts +2 -2
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2020 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import assert from 'assert';
|
|
6
|
+
import { generateMnemonic, mnemonicToSeedSync } from 'bip39';
|
|
7
|
+
|
|
8
|
+
import { createKeyPair } from '@dxos/crypto';
|
|
9
|
+
|
|
10
|
+
// Util functions for Identity: export, import, create.
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Generate bip39 seed phrase (aka mnemonic).
|
|
14
|
+
*/
|
|
15
|
+
export const generateSeedPhrase = (): string => generateMnemonic();
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Generate key pair from seed phrase.
|
|
19
|
+
*/
|
|
20
|
+
export const keyPairFromSeedPhrase = (seedPhrase: string) => {
|
|
21
|
+
assert(seedPhrase);
|
|
22
|
+
const seed = mnemonicToSeedSync(seedPhrase);
|
|
23
|
+
return createKeyPair(seed);
|
|
24
|
+
};
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
import assert from 'assert';
|
|
10
10
|
import stableStringify from 'json-stable-stringify';
|
|
11
11
|
|
|
12
|
-
import { createKeyPair, KeyPair
|
|
13
|
-
import { PublicKey, PublicKeyLike } from '@dxos/protocols';
|
|
12
|
+
import { createKeyPair, KeyPair } from '@dxos/crypto';
|
|
13
|
+
import { PublicKey, PublicKeyLike, PUBLIC_KEY_LENGTH, SECRET_KEY_LENGTH } from '@dxos/protocols';
|
|
14
14
|
|
|
15
15
|
import { KeyChain, KeyRecord, KeyType, createDateTimeString } from '../proto';
|
|
16
16
|
import { MakeOptional } from '../typedefs';
|
package/src/keys/keyring.test.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import assert from 'assert';
|
|
8
8
|
import expect from 'expect';
|
|
9
9
|
|
|
10
|
-
import { createKeyPair,
|
|
10
|
+
import { createKeyPair, randomBytes, verify } from '@dxos/crypto';
|
|
11
11
|
import { PublicKey } from '@dxos/protocols';
|
|
12
12
|
|
|
13
13
|
import { KeyType, schema } from '../proto';
|
|
@@ -90,7 +90,7 @@ it('Add/retrieve a publicKey from an external source (without secret present)',
|
|
|
90
90
|
|
|
91
91
|
it('Retrieve a non-existent key', async () => {
|
|
92
92
|
const keyring = new Keyring();
|
|
93
|
-
const internal = keyring.findKey(Filter.matches({ key:
|
|
93
|
+
const internal = keyring.findKey(Filter.matches({ key: PublicKey.stringify(randomBytes(32)) }));
|
|
94
94
|
expect(internal).toBeUndefined();
|
|
95
95
|
});
|
|
96
96
|
|
|
@@ -194,8 +194,8 @@ it('Attempt to add a badly formatted key', async () => {
|
|
|
194
194
|
const keyring = new Keyring();
|
|
195
195
|
const good = createKeyPair();
|
|
196
196
|
const bad = {
|
|
197
|
-
publicKey:
|
|
198
|
-
secretKey:
|
|
197
|
+
publicKey: PublicKey.stringify(good.publicKey),
|
|
198
|
+
secretKey: PublicKey.stringify(good.secretKey),
|
|
199
199
|
type: KeyType.IDENTITY
|
|
200
200
|
};
|
|
201
201
|
|
package/src/keys/keyring.ts
CHANGED
|
@@ -7,7 +7,7 @@ import memdown from 'memdown';
|
|
|
7
7
|
|
|
8
8
|
import { Event } from '@dxos/async';
|
|
9
9
|
import {
|
|
10
|
-
KeyPair,
|
|
10
|
+
KeyPair, randomBytes, sign as cryptoSign, verify as cryptoVerify
|
|
11
11
|
} from '@dxos/crypto';
|
|
12
12
|
import { PublicKey, PublicKeyLike } from '@dxos/protocols';
|
|
13
13
|
import { arraysEqual } from '@dxos/util';
|
|
@@ -583,7 +583,7 @@ export class Keyring implements Signer {
|
|
|
583
583
|
item.publicKey = PublicKey.from(item.publicKey);
|
|
584
584
|
}
|
|
585
585
|
if (item.secretKey) {
|
|
586
|
-
item.secretKey =
|
|
586
|
+
item.secretKey = PublicKey.bufferize(item.secretKey);
|
|
587
587
|
}
|
|
588
588
|
|
|
589
589
|
if (item.secretKey) {
|