@dxos/credentials 2.12.20 → 2.13.0

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.
Files changed (52) hide show
  1. package/.rush/temp/package-deps_build:test.json +17 -18
  2. package/credentials.build.log +15 -15
  3. package/dist/src/auth/auth-plugin.test.js +7 -14
  4. package/dist/src/auth/auth-plugin.test.js.map +1 -1
  5. package/dist/src/auth/auth.test.js +12 -12
  6. package/dist/src/auth/auth.test.js.map +1 -1
  7. package/dist/src/greet/error-codes.d.ts +10 -0
  8. package/dist/src/greet/error-codes.d.ts.map +1 -1
  9. package/dist/src/greet/error-codes.js +11 -1
  10. package/dist/src/greet/error-codes.js.map +1 -1
  11. package/dist/src/greet/index.d.ts +1 -0
  12. package/dist/src/greet/index.d.ts.map +1 -1
  13. package/dist/src/greet/index.js +1 -0
  14. package/dist/src/greet/index.js.map +1 -1
  15. package/dist/src/keys/keyring.d.ts +1 -1
  16. package/dist/src/keys/keyring.d.ts.map +1 -1
  17. package/dist/src/keys/keyring.js +1 -1
  18. package/dist/src/keys/keyring.js.map +1 -1
  19. package/dist/src/keys/signer.d.ts +2 -1
  20. package/dist/src/keys/signer.d.ts.map +1 -1
  21. package/dist/src/party/party-credential.d.ts +3 -3
  22. package/dist/src/party/party-credential.d.ts.map +1 -1
  23. package/dist/src/party/party-credential.js +7 -7
  24. package/dist/src/party/party-credential.js.map +1 -1
  25. package/dist/src/party/party-invitations.test.js +1 -1
  26. package/dist/src/party/party-invitations.test.js.map +1 -1
  27. package/dist/src/party/party-state.test.js +14 -14
  28. package/dist/src/party/party-state.test.js.map +1 -1
  29. package/dist/src/proto/gen/google/protobuf.d.ts +2 -2
  30. package/dist/src/proto/index.d.ts.map +1 -1
  31. package/dist/src/proto/index.js.map +1 -1
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +10 -10
  34. package/src/auth/auth-plugin.test.ts +8 -13
  35. package/src/auth/auth.test.js +12 -12
  36. package/src/greet/error-codes.ts +12 -0
  37. package/src/greet/index.ts +1 -0
  38. package/src/keys/keyring.ts +2 -2
  39. package/src/keys/signer.ts +3 -1
  40. package/src/party/party-credential.ts +7 -7
  41. package/src/party/party-invitations.test.js +1 -1
  42. package/src/party/party-state.test.js +14 -14
  43. package/src/proto/{auth.proto → defs/auth.proto} +0 -0
  44. package/src/proto/{greet.proto → defs/greet.proto} +0 -0
  45. package/src/proto/{identity.proto → defs/identity.proto} +0 -0
  46. package/src/proto/{keys.proto → defs/keys.proto} +0 -0
  47. package/src/proto/{party.proto → defs/party.proto} +0 -0
  48. package/src/proto/defs/signed.proto +41 -0
  49. package/src/proto/gen/google/protobuf.ts +2 -2
  50. package/src/proto/index.ts +1 -0
  51. package/.eslintrc.js +0 -6
  52. package/src/proto/signed.proto +0 -41
@@ -21,14 +21,14 @@ export const TYPE_URL_PARTY_INVITATION = 'dxos.credentials.party.PartyInvitation
21
21
  * signing this message.
22
22
  * @param signer
23
23
  * @param partyKeyPair
24
- * @param feedKeyPair
24
+ * @param feedKey
25
25
  * @param admitKeyPair
26
26
  * @returns Signed message
27
27
  */
28
28
  export const createPartyGenesisMessage = (
29
29
  signer: Signer,
30
30
  partyKeyPair: KeyRecord,
31
- feedKeyPair: KeyRecord,
31
+ feedKey: PublicKey,
32
32
  admitKeyPair: KeyRecord
33
33
  ): Message => {
34
34
  assert(typeof admitKeyPair.type !== 'undefined');
@@ -38,13 +38,13 @@ export const createPartyGenesisMessage = (
38
38
  type: PartyCredential.Type.PARTY_GENESIS,
39
39
  partyGenesis: {
40
40
  partyKey: partyKeyPair.publicKey,
41
- feedKey: feedKeyPair.publicKey,
41
+ feedKey: feedKey,
42
42
  admitKey: admitKeyPair.publicKey,
43
43
  admitKeyType: admitKeyPair.type
44
44
  }
45
45
  };
46
46
 
47
- return wrapMessage(signer.sign(message, [partyKeyPair, feedKeyPair, admitKeyPair]));
47
+ return wrapMessage(signer.sign(message, [partyKeyPair, feedKey, admitKeyPair]));
48
48
  };
49
49
 
50
50
  /**
@@ -80,7 +80,7 @@ export const createKeyAdmitMessage = (
80
80
  export const createFeedAdmitMessage = (
81
81
  signer: Signer,
82
82
  partyKey: PublicKeyLike,
83
- feedKeyPair: KeyRecord,
83
+ feedKey: PublicKey,
84
84
  signingKeys: (KeyRecord | KeyChain)[] = [],
85
85
  nonce?: Buffer
86
86
  ): Message => {
@@ -91,11 +91,11 @@ export const createFeedAdmitMessage = (
91
91
  type: PartyCredential.Type.FEED_ADMIT,
92
92
  feedAdmit: {
93
93
  partyKey,
94
- feedKey: feedKeyPair.publicKey
94
+ feedKey: feedKey
95
95
  }
96
96
  };
97
97
 
98
- return wrapMessage(signer.sign(message, [feedKeyPair, ...signingKeys], nonce));
98
+ return wrapMessage(signer.sign(message, [feedKey, ...signingKeys], nonce));
99
99
  };
100
100
 
101
101
  /**
@@ -52,7 +52,7 @@ it('PartyInvitation messages', async () => {
52
52
  const party = new PartyState(partyKey.publicKey);
53
53
 
54
54
  // First, configure the Party.
55
- const genesisMessage = createPartyGenesisMessage(keyring, partyKey, feedKey, identityKey);
55
+ const genesisMessage = createPartyGenesisMessage(keyring, partyKey, feedKey.publicKey, identityKey);
56
56
  await party.processMessages([genesisMessage]);
57
57
 
58
58
  // Now 'write' an invitation message.
@@ -55,7 +55,7 @@ it('Process basic message types', async () => {
55
55
  let deviceKeyChain;
56
56
  {
57
57
  const haloMessages = new Map();
58
- const haloGenesis = createPartyGenesisMessage(keyring, identityKeyB, haloFeedKey, deviceKey);
58
+ const haloGenesis = createPartyGenesisMessage(keyring, identityKeyB, haloFeedKey.publicKey, deviceKey);
59
59
  haloMessages.set(identityKeyB.publicKey.toHex(), haloGenesis);
60
60
  haloMessages.set(haloFeedKey.publicKey.toHex(), haloGenesis);
61
61
  haloMessages.set(deviceKey.publicKey.toHex(), haloGenesis);
@@ -66,11 +66,11 @@ it('Process basic message types', async () => {
66
66
 
67
67
  const messages = [
68
68
  // The Genesis message is signed by the party private key, the feed key, and one admitted key (IdentityA).
69
- createPartyGenesisMessage(keyring, partyKey, feedKeyA, identityKeyA),
69
+ createPartyGenesisMessage(keyring, partyKey, feedKeyA.publicKey, identityKeyA),
70
70
  // Admit IdentityB using a KeyAdmit message.
71
71
  createKeyAdmitMessage(keyring, partyKey.publicKey, identityKeyB, [identityKeyA]),
72
72
  // Add another feed, and sign for it using the Device KeyChain associated with IdentityB.
73
- createFeedAdmitMessage(keyring, partyKey.publicKey, feedKeyB, [deviceKeyChain]),
73
+ createFeedAdmitMessage(keyring, partyKey.publicKey, feedKeyB.publicKey, [deviceKeyChain]),
74
74
  // Add an IdentityInfo, wrapped in an Envelope signed by the device KeyChain, as when copied from the HALO.
75
75
  createEnvelopeMessage(
76
76
  keyring,
@@ -120,7 +120,7 @@ it('GreetingCommandPlugin envelopes', async () => {
120
120
  const genesis = codecLoop(
121
121
  createPartyGenesisMessage(greeterKeyring,
122
122
  greeterKeyring.findKey(Filter.matches({ type: KeyType.PARTY })),
123
- greeterKeyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0],
123
+ greeterKeyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0].publicKey,
124
124
  greeterKeyring.findKey(Keyring.signingFilter({ type: KeyType.IDENTITY }))
125
125
  )
126
126
  );
@@ -155,7 +155,7 @@ it('Reject message from unknown source', async () => {
155
155
  const messages = [
156
156
  createPartyGenesisMessage(keyring,
157
157
  keyring.findKey(Filter.matches({ type: KeyType.PARTY })),
158
- keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0],
158
+ keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0].publicKey,
159
159
  keyring.findKey(Keyring.signingFilter({ type: KeyType.IDENTITY }))),
160
160
  createKeyAdmitMessage(keyring,
161
161
  keyring.findKey(Filter.matches({ type: KeyType.PARTY })).publicKey,
@@ -181,7 +181,7 @@ it('Message signed by known and unknown key should not admit unknown key', async
181
181
  const messages = [
182
182
  createPartyGenesisMessage(keyring,
183
183
  keyring.findKey(Filter.matches({ type: KeyType.PARTY })),
184
- keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0],
184
+ keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0].publicKey,
185
185
  keyring.findKey(Keyring.signingFilter({ type: KeyType.IDENTITY }))),
186
186
  createKeyAdmitMessage(keyring,
187
187
  keyring.findKey(Filter.matches({ type: KeyType.PARTY })).publicKey,
@@ -208,7 +208,7 @@ it('Reject Genesis not signed by Party key', async () => {
208
208
  const messages = [
209
209
  createPartyGenesisMessage(keyring,
210
210
  wrongKey,
211
- keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0],
211
+ keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0].publicKey,
212
212
  keyring.findKey(Keyring.signingFilter({ type: KeyType.IDENTITY }))
213
213
  )
214
214
  ].map(codecLoop);
@@ -231,7 +231,7 @@ it('Reject admit key message with wrong Party', async () => {
231
231
  let messages = [
232
232
  createPartyGenesisMessage(keyring,
233
233
  keyring.findKey(Filter.matches({ type: KeyType.PARTY })),
234
- keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0],
234
+ keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0].publicKey,
235
235
  keyring.findKey(Keyring.signingFilter({ type: KeyType.IDENTITY }))
236
236
  )
237
237
  ].map(codecLoop);
@@ -268,7 +268,7 @@ it('Reject admit feed message with wrong Party', async () => {
268
268
  let messages = [
269
269
  createPartyGenesisMessage(keyring,
270
270
  keyring.findKey(Filter.matches({ type: KeyType.PARTY })),
271
- keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0],
271
+ keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0].publicKey,
272
272
  keyring.findKey(Keyring.signingFilter({ type: KeyType.IDENTITY }))
273
273
  )
274
274
  ].map(codecLoop);
@@ -284,7 +284,7 @@ it('Reject admit feed message with wrong Party', async () => {
284
284
  messages = [
285
285
  createFeedAdmitMessage(keyring,
286
286
  wrongParty.publicKey,
287
- keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[1],
287
+ keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[1].publicKey,
288
288
  [keyring.findKey(Keyring.signingFilter({ type: KeyType.IDENTITY }))]
289
289
  )
290
290
  ].map(codecLoop);
@@ -303,7 +303,7 @@ it('Reject tampered Genesis message', async () => {
303
303
  const messages = [
304
304
  createPartyGenesisMessage(keyring,
305
305
  keyring.findKey(Filter.matches({ type: KeyType.PARTY })),
306
- keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0],
306
+ keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0].publicKey,
307
307
  keyring.findKey(Keyring.signingFilter({ type: KeyType.IDENTITY }))
308
308
  )
309
309
  ].map(codecLoop);
@@ -328,7 +328,7 @@ it('Reject tampered admit feed message', async () => {
328
328
  let messages = [
329
329
  createPartyGenesisMessage(keyring,
330
330
  keyring.findKey(Filter.matches({ type: KeyType.PARTY })),
331
- keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0],
331
+ keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0].publicKey,
332
332
  keyring.findKey(Keyring.signingFilter({ type: KeyType.IDENTITY }))
333
333
  )
334
334
  ].map(codecLoop);
@@ -344,7 +344,7 @@ it('Reject tampered admit feed message', async () => {
344
344
  messages = [
345
345
  createFeedAdmitMessage(keyring,
346
346
  keyring.findKey(Filter.matches({ type: KeyType.PARTY })).publicKey,
347
- keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[1],
347
+ keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[1].publicKey,
348
348
  [keyring.findKey(Keyring.signingFilter({ type: KeyType.IDENTITY }))]
349
349
  )
350
350
  ].map(codecLoop);
@@ -365,7 +365,7 @@ it('Reject tampered admit key message', async () => {
365
365
  let messages = [
366
366
  createPartyGenesisMessage(keyring,
367
367
  keyring.findKey(Filter.matches({ type: KeyType.PARTY })),
368
- keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0],
368
+ keyring.findKeys(Keyring.signingFilter({ type: KeyType.FEED }))[0].publicKey,
369
369
  keyring.findKey(Keyring.signingFilter({ type: KeyType.IDENTITY })))
370
370
  ].map(codecLoop);
371
371
 
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,41 @@
1
+ //
2
+ // Copyright 2020 DXOS.org
3
+ //
4
+
5
+ syntax = "proto3";
6
+
7
+ package dxos.credentials;
8
+
9
+ import "keys.proto";
10
+ import "google/protobuf/any.proto";
11
+
12
+ // TODO(burdon): Use default from codec-protobuf
13
+ message Message {
14
+ required google.protobuf.Any payload = 1;
15
+ }
16
+
17
+ //
18
+ // A generic container message used whenever messages are signed (e.g. PartyCredential)
19
+ //
20
+ message SignedMessage {
21
+ //
22
+ // Provides the common metadata needed for all signed objects.
23
+ //
24
+ message Signed {
25
+ required string created = 1; // RFC-3339 datetime string.
26
+ required bytes nonce = 2;
27
+ required google.protobuf.Any payload = 10; // The payload to be signed.
28
+ }
29
+
30
+ //
31
+ // The signature data itself.
32
+ //
33
+ message Signature {
34
+ required PubKey key = 1; // The publicKey of the keypair that made this signature.
35
+ required bytes signature = 2; // The bytes of the signature.
36
+ KeyChain keyChain = 3; // Optional. The certification chain of SignedMessages for this key.
37
+ }
38
+
39
+ required Signed signed = 1; // The signed message contents.
40
+ repeated Signature signatures = 2; // An array of Signatures, one for each key that signed the message.
41
+ }
@@ -17,10 +17,10 @@ export interface FloatValue {
17
17
  value?: number;
18
18
  }
19
19
  export interface Int64Value {
20
- value?: number;
20
+ value?: string;
21
21
  }
22
22
  export interface UInt64Value {
23
- value?: number;
23
+ value?: string;
24
24
  }
25
25
  export interface Int32Value {
26
26
  value?: number;
@@ -5,6 +5,7 @@
5
5
  export * from './any';
6
6
  export * from './codec';
7
7
  export * from './datetime';
8
+
8
9
  export * from './gen/dxos/credentials';
9
10
  export * from './gen/dxos/credentials/auth';
10
11
  export * from './gen/dxos/credentials/greet';
package/.eslintrc.js DELETED
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- extends: 'plugin:@dxos/recomended',
3
- ignorePatterns: [
4
- 'src/proto/gen/*'
5
- ]
6
- }
@@ -1,41 +0,0 @@
1
- //
2
- // Copyright 2020 DXOS.org
3
- //
4
-
5
- syntax = "proto3";
6
-
7
- package dxos.credentials;
8
-
9
- import "keys.proto";
10
- import "google/protobuf/any.proto";
11
-
12
- // TODO(burdon): Use default from codec-protobuf
13
- message Message {
14
- required google.protobuf.Any payload = 1;
15
- }
16
-
17
- //
18
- // A generic container message used whenever messages are signed (e.g. PartyCredential)
19
- //
20
- message SignedMessage {
21
- //
22
- // Provides the common metadata needed for all signed objects.
23
- //
24
- message Signed {
25
- required string created = 1; // RFC-3339 datetime string.
26
- required bytes nonce = 2;
27
- required google.protobuf.Any payload = 10; // The payload to be signed.
28
- }
29
-
30
- //
31
- // The signature data itself.
32
- //
33
- message Signature {
34
- required PubKey key = 1; // The publicKey of the keypair that made this signature.
35
- required bytes signature = 2; // The bytes of the signature.
36
- KeyChain keyChain = 3; // Optional. The certification chain of SignedMessages for this key.
37
- }
38
-
39
- required Signed signed = 1; // The signed message contents.
40
- repeated Signature signatures = 2; // An array of Signatures, one for each key that signed the message.
41
- }