@dxos/credentials 2.33.5-dev.ea3876ba → 2.33.5-dev.ebc105f7

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 (49) hide show
  1. package/.rush/temp/package-deps_build.json +13 -13
  2. package/.rush/temp/package-deps_build:test.json +13 -13
  3. package/.rush/temp/package-deps_prerelease.json +13 -13
  4. package/.rush/temp/shrinkwrap-deps.json +24 -15
  5. package/dist/src/auth/auth-plugin.test.js +8 -14
  6. package/dist/src/auth/auth-plugin.test.js.map +1 -1
  7. package/dist/src/auth/auth.test.js +1 -4
  8. package/dist/src/auth/auth.test.js.map +1 -1
  9. package/dist/src/greet/greeter-plugin.test.js +1 -3
  10. package/dist/src/greet/greeter-plugin.test.js.map +1 -1
  11. package/dist/src/greet/greeting-message.d.ts.map +1 -1
  12. package/dist/src/greet/greeting-message.js +5 -7
  13. package/dist/src/greet/greeting-message.js.map +1 -1
  14. package/dist/src/identity/identity-message.d.ts.map +1 -1
  15. package/dist/src/identity/identity-message.js +1 -4
  16. package/dist/src/identity/identity-message.js.map +1 -1
  17. package/dist/src/keys/keyring-helpers.d.ts +1 -1
  18. package/dist/src/keys/keyring-helpers.d.ts.map +1 -1
  19. package/dist/src/keys/keyring-helpers.js +29 -30
  20. package/dist/src/keys/keyring-helpers.js.map +1 -1
  21. package/dist/src/keys/keystore.d.ts.map +1 -1
  22. package/dist/src/keys/keystore.js +2 -6
  23. package/dist/src/keys/keystore.js.map +1 -1
  24. package/dist/src/keys/keytype.d.ts.map +1 -1
  25. package/dist/src/keys/keytype.js +1 -3
  26. package/dist/src/keys/keytype.js.map +1 -1
  27. package/dist/src/party/party-credential.d.ts +4 -4
  28. package/dist/src/party/party-credential.d.ts.map +1 -1
  29. package/dist/src/party/party-credential.js +16 -18
  30. package/dist/src/party/party-credential.js.map +1 -1
  31. package/dist/src/party/party-state.d.ts.map +1 -1
  32. package/dist/src/party/party-state.js +7 -9
  33. package/dist/src/party/party-state.js.map +1 -1
  34. package/dist/src/proto/datetime.d.ts.map +1 -1
  35. package/dist/src/proto/datetime.js +1 -3
  36. package/dist/src/proto/datetime.js.map +1 -1
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/package.json +12 -12
  39. package/src/auth/auth-plugin.test.ts +8 -14
  40. package/src/auth/auth.test.ts +2 -5
  41. package/src/greet/greeter-plugin.test.ts +1 -3
  42. package/src/greet/greeting-message.ts +5 -7
  43. package/src/identity/identity-message.ts +1 -4
  44. package/src/keys/keyring-helpers.ts +23 -24
  45. package/src/keys/keystore.ts +2 -6
  46. package/src/keys/keytype.ts +1 -3
  47. package/src/party/party-credential.ts +7 -9
  48. package/src/party/party-state.ts +7 -9
  49. package/src/proto/datetime.ts +1 -3
@@ -19,7 +19,7 @@ import { SecretKey } from './keytype';
19
19
  * Checks for a valid publicKey Buffer.
20
20
  */
21
21
  // TODO(burdon): Move to dxos/crypto.
22
- export function isValidPublicKey (key: PublicKeyLike, keyType?: KeyType): key is PublicKeyLike {
22
+ export const isValidPublicKey = (key: PublicKeyLike, keyType?: KeyType): key is PublicKeyLike => {
23
23
  try {
24
24
  PublicKey.from(key);
25
25
  if (keyType && [KeyType.PARTY, KeyType.IDENTITY, KeyType.FEED, KeyType.DEVICE].includes(keyType)) {
@@ -29,12 +29,13 @@ export function isValidPublicKey (key: PublicKeyLike, keyType?: KeyType): key is
29
29
  } catch (e: any) {
30
30
  }
31
31
  return false;
32
- }
32
+ };
33
33
 
34
34
  /**
35
35
  * Checks for a valid publicKey Buffer.
36
36
  */
37
37
  // TODO(burdon): Move to dxos/crypto.
38
+ // eslint-disable-next-line @stayradiated/prefer-arrow-functions/prefer-arrow-functions
38
39
  export function assertValidPublicKey (key: PublicKeyLike, keyType?: KeyType): asserts key is PublicKeyLike {
39
40
  assert(key);
40
41
  assert(isValidPublicKey(key, keyType));
@@ -44,6 +45,7 @@ export function assertValidPublicKey (key: PublicKeyLike, keyType?: KeyType): as
44
45
  * Checks for a valid secretKey Buffer.
45
46
  */
46
47
  // TODO(burdon): Move to dxos/crypto.
48
+ // eslint-disable-next-line @stayradiated/prefer-arrow-functions/prefer-arrow-functions
47
49
  export function assertValidSecretKey (key?: SecretKey, keyType?: KeyType): asserts key is SecretKey {
48
50
  assert(key);
49
51
  if (keyType && [KeyType.PARTY, KeyType.IDENTITY, KeyType.FEED, KeyType.DEVICE].includes(keyType)) {
@@ -55,6 +57,7 @@ export function assertValidSecretKey (key?: SecretKey, keyType?: KeyType): asser
55
57
  * Checks for a valid publicKey/secretKey KeyPair.
56
58
  */
57
59
  // TODO(burdon): Move to dxos/crypto.
60
+ // eslint-disable-next-line @stayradiated/prefer-arrow-functions/prefer-arrow-functions
58
61
  export function assertValidKeyPair (keyRecord: any): asserts keyRecord is KeyPair {
59
62
  const { publicKey, secretKey, type } = keyRecord;
60
63
  assertValidPublicKey(publicKey, type);
@@ -128,40 +131,36 @@ export const createKeyRecord = (attributes: Partial<KeyRecord> = {},
128
131
  * Utility method to produce stable output for signing/verifying.
129
132
  */
130
133
  // TODO(burdon): Factor out.
131
- export const canonicalStringify = (obj: any) => {
132
- return stableStringify(obj, {
133
- /* The point of signing and verifying is not that the internal, private state of the objects be
134
+ export const canonicalStringify = (obj: any) => stableStringify(obj, {
135
+ /* The point of signing and verifying is not that the internal, private state of the objects be
134
136
  * identical, but that the public contents can be verified not to have been altered. For that reason,
135
137
  * really private fields (indicated by '__') are not included in the signature.
136
138
  * This gives a mechanism for attaching other attributes to an object without breaking the signature.
137
139
  * We also skip @type.
138
140
  */
139
- replacer: (key: any, value: any) => {
140
- if (key.toString().startsWith('__') || key.toString() === '@type') {
141
- return undefined;
141
+ replacer: (key: any, value: any) => {
142
+ if (key.toString().startsWith('__') || key.toString() === '@type') {
143
+ return undefined;
144
+ }
145
+ if (value) {
146
+ if (PublicKey.isPublicKey(value)) {
147
+ return value.toHex();
148
+ }
149
+ if (Buffer.isBuffer(value)) {
150
+ return value.toString('hex');
142
151
  }
143
- if (value) {
144
- if (PublicKey.isPublicKey(value)) {
145
- return value.toHex();
146
- }
147
- if (Buffer.isBuffer(value)) {
148
- return value.toString('hex');
149
- }
150
- if (value instanceof Uint8Array || (value.data && value.type === 'Buffer')) {
151
- return Buffer.from(value).toString('hex');
152
- }
152
+ if (value instanceof Uint8Array || (value.data && value.type === 'Buffer')) {
153
+ return Buffer.from(value).toString('hex');
153
154
  }
154
- return value;
155
155
  }
156
- });
157
- };
156
+ return value;
157
+ }
158
+ });
158
159
 
159
160
  /**
160
161
  * Is object `key` a KeyChain?
161
162
  */
162
- export const isKeyChain = (key: any = {}): key is KeyChain => {
163
- return isValidPublicKey(key.publicKey) && key.message && key.message.signed && Array.isArray(key.message.signatures);
164
- };
163
+ export const isKeyChain = (key: any = {}): key is KeyChain => isValidPublicKey(key.publicKey) && key.message && key.message.signed && Array.isArray(key.message.signatures);
165
164
 
166
165
  /**
167
166
  * Checks conformity and normalizes the KeyRecord. (Used before storing, so that only well-formed records are stored.)
@@ -17,12 +17,8 @@ import { KeyRecord } from '../proto';
17
17
  const log = debug('dxos:halo:keys:keystore'); // eslint-disable-line unused-imports/no-unused-vars
18
18
 
19
19
  const marshaller = {
20
- marshall (record: KeyRecord) {
21
- return { ...record, publicKey: record.publicKey.asBuffer() };
22
- },
23
- unmarshall (raw: any): KeyRecord {
24
- return { ...raw, publicKey: PublicKey.from(raw.publicKey) };
25
- }
20
+ marshall: (record: KeyRecord) => ({ ...record, publicKey: record.publicKey.asBuffer() }),
21
+ unmarshall: (raw: any): KeyRecord => ({ ...raw, publicKey: PublicKey.from(raw.publicKey) })
26
22
  };
27
23
 
28
24
  /**
@@ -6,6 +6,4 @@ import { KeyType } from '../proto/gen/dxos/halo/keys';
6
6
 
7
7
  export type SecretKey = Buffer;
8
8
 
9
- export const keyTypeName = (keyType: KeyType) => {
10
- return KeyType[keyType];
11
- };
9
+ export const keyTypeName = (keyType: KeyType) => KeyType[keyType];
@@ -143,12 +143,12 @@ export const isPartyCredentialMessage = (message: Message | SignedMessage) => {
143
143
  * @return {boolean}
144
144
  * @private
145
145
  */
146
- export function isEnvelope (message: any) {
146
+ export const isEnvelope = (message: any) => {
147
147
  assert(message);
148
148
  const type = message?.signed?.payload?.type;
149
149
  const envelope = message?.signed?.payload?.envelope;
150
150
  return type === PartyCredential.Type.ENVELOPE && envelope;
151
- }
151
+ };
152
152
 
153
153
  /**
154
154
  * Is this a SignedMessage?
@@ -156,30 +156,28 @@ export function isEnvelope (message: any) {
156
156
  * @return {boolean}
157
157
  * @private
158
158
  */
159
- export function isSignedMessage (message: any): message is SignedMessage {
160
- return message && message.signed && message.signed.payload && message.signatures && Array.isArray(message.signatures);
161
- }
159
+ export const isSignedMessage = (message: any): message is SignedMessage => message && message.signed && message.signed.payload && message.signatures && Array.isArray(message.signatures);
162
160
 
163
161
  /**
164
162
  * Wraps a SignedMessage with a Message.
165
163
  */
166
164
  // TODO(burdon): Typespec is too loose.
167
- export function wrapMessage (message: Message | SignedMessage | Command | Auth): WithTypeUrl<Message> {
165
+ export const wrapMessage = (message: Message | SignedMessage | Command | Auth): WithTypeUrl<Message> => {
168
166
  const payload = message as any;
169
167
  return { '@type': TYPE_URL_MESSAGE, payload } as WithTypeUrl<Message>;
170
- }
168
+ };
171
169
 
172
170
  /**
173
171
  * Unwraps (if necessary) a Message to its contents.
174
172
  */
175
- export function unwrapMessage (message: any): any {
173
+ export const unwrapMessage = (message: any): any => {
176
174
  let result: any = message;
177
175
  while (result.payload) { // TODO(burdon): Recursion!
178
176
  result = result.payload;
179
177
  }
180
178
 
181
179
  return result;
182
- }
180
+ };
183
181
 
184
182
  /**
185
183
  * Unwrap a SignedMessage from its Envelopes.
@@ -516,15 +516,13 @@ export class PartyState extends EventEmitter {
516
516
  publicKey = PublicKey.from(publicKey);
517
517
  const keyStr = publicKey.toHex();
518
518
 
519
- const makeRecord = () => {
520
- return {
521
- type: KeyType.UNKNOWN,
522
- trusted: true,
523
- own: false,
524
- ...attributes, // Let attributes clobber the defaults.
525
- publicKey
526
- };
527
- };
519
+ const makeRecord = () => ({
520
+ type: KeyType.UNKNOWN,
521
+ trusted: true,
522
+ own: false,
523
+ ...attributes, // Let attributes clobber the defaults.
524
+ publicKey
525
+ });
528
526
 
529
527
  let keyRecord = this._keyring.getKey(publicKey);
530
528
  if (!keyRecord) {
@@ -8,6 +8,4 @@ import moment from 'moment';
8
8
  * Creates a properly formatted RFC-3339 date-time string for "now".
9
9
  * @returns {string}
10
10
  */
11
- export const createDateTimeString = () => {
12
- return moment().format('YYYY-MM-DDTHH:mm:ssZ');
13
- };
11
+ export const createDateTimeString = () => moment().format('YYYY-MM-DDTHH:mm:ssZ');