@dxos/credentials 2.33.1-dev.0a5ae2e2 → 2.33.1-dev.376de34c
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:test.json +11 -11
- package/.rush/temp/package-deps_prerelease.json +11 -11
- package/dist/src/auth/auth-message.js +1 -1
- package/dist/src/auth/auth-message.js.map +1 -1
- package/dist/src/auth/auth.test.js +8 -8
- package/dist/src/auth/auth.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/greeter.d.ts +15 -15
- package/dist/src/greet/greeter.js +5 -5
- package/dist/src/greet/greeter.js.map +1 -1
- package/dist/src/greet/greeter.test.js +12 -12
- package/dist/src/greet/greeter.test.js.map +1 -1
- package/dist/src/greet/greeting-message.d.ts +2 -2
- package/dist/src/greet/greeting-message.js +9 -9
- package/dist/src/greet/greeting-message.js.map +1 -1
- package/dist/src/identity/identity-message.js +4 -4
- package/dist/src/identity/identity-message.js.map +1 -1
- package/dist/src/keys/keyring-helpers.d.ts.map +1 -1
- package/dist/src/keys/keyring-helpers.js +4 -3
- package/dist/src/keys/keyring-helpers.js.map +1 -1
- package/dist/src/keys/keyring.js +2 -2
- package/dist/src/keys/keyring.js.map +1 -1
- package/dist/src/party/party-credential.d.ts +1 -1
- package/dist/src/party/party-credential.js +10 -10
- package/dist/src/party/party-credential.js.map +1 -1
- package/dist/src/proto/any.d.ts +3 -3
- package/dist/src/proto/any.d.ts.map +1 -1
- package/dist/src/proto/substitutions.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/src/auth/auth-message.ts +1 -1
- package/src/auth/auth.test.ts +8 -8
- package/src/greet/greeter-plugin.test.ts +4 -4
- package/src/greet/greeter.test.js +12 -12
- package/src/greet/greeter.ts +5 -5
- package/src/greet/greeting-message.ts +9 -9
- package/src/identity/identity-message.ts +4 -4
- package/src/keys/keyring-helpers.ts +4 -3
- package/src/keys/keyring.ts +2 -2
- package/src/party/party-credential.ts +10 -10
- package/src/proto/any.ts +3 -3
|
@@ -10,11 +10,11 @@ const TYPE_URL_GREETING_COMMAND = 'dxos.credentials.greet.Command';
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Create a Greeting 'BEGIN' command message.
|
|
13
|
-
* @returns {{
|
|
13
|
+
* @returns {{'@type': string, command: *}}
|
|
14
14
|
*/
|
|
15
15
|
export const createGreetingBeginMessage = (): WithTypeUrl<Command> => {
|
|
16
16
|
return {
|
|
17
|
-
|
|
17
|
+
'@type': TYPE_URL_GREETING_COMMAND,
|
|
18
18
|
command: Command.Type.BEGIN,
|
|
19
19
|
params: []
|
|
20
20
|
};
|
|
@@ -28,7 +28,7 @@ export const createGreetingHandshakeMessage = (secret: Buffer, params = []): Wit
|
|
|
28
28
|
assert(Array.isArray(params));
|
|
29
29
|
|
|
30
30
|
return {
|
|
31
|
-
|
|
31
|
+
'@type': TYPE_URL_GREETING_COMMAND,
|
|
32
32
|
command: Command.Type.HANDSHAKE,
|
|
33
33
|
params,
|
|
34
34
|
secret
|
|
@@ -43,7 +43,7 @@ export const createGreetingNotarizeMessage = (secret: Buffer, credentialMessages
|
|
|
43
43
|
assert(Array.isArray(credentialMessages));
|
|
44
44
|
|
|
45
45
|
return {
|
|
46
|
-
|
|
46
|
+
'@type': TYPE_URL_GREETING_COMMAND,
|
|
47
47
|
command: Command.Type.NOTARIZE,
|
|
48
48
|
params: credentialMessages,
|
|
49
49
|
secret
|
|
@@ -57,7 +57,7 @@ export const createGreetingFinishMessage = (secret: Buffer): WithTypeUrl<Command
|
|
|
57
57
|
assert(Buffer.isBuffer(secret), 'Secret is not a buffer.');
|
|
58
58
|
|
|
59
59
|
return {
|
|
60
|
-
|
|
60
|
+
'@type': TYPE_URL_GREETING_COMMAND,
|
|
61
61
|
command: Command.Type.FINISH,
|
|
62
62
|
secret,
|
|
63
63
|
params: []
|
|
@@ -71,11 +71,11 @@ export const createGreetingClaimMessage = (invitationID: Buffer): WithTypeUrl<Co
|
|
|
71
71
|
assert(Buffer.isBuffer(invitationID), 'invitationID is not a buffer.');
|
|
72
72
|
|
|
73
73
|
return {
|
|
74
|
-
|
|
74
|
+
'@type': TYPE_URL_GREETING_COMMAND,
|
|
75
75
|
command: Command.Type.CLAIM,
|
|
76
76
|
params: [
|
|
77
77
|
{
|
|
78
|
-
|
|
78
|
+
'@type': 'google.protobuf.BytesValue',
|
|
79
79
|
value: invitationID
|
|
80
80
|
}
|
|
81
81
|
]
|
|
@@ -86,14 +86,14 @@ export const createGreetingClaimMessage = (invitationID: Buffer): WithTypeUrl<Co
|
|
|
86
86
|
* Crate a Greeting ClaimResponse message.
|
|
87
87
|
* @param {Buffer} id The ID of the new invitation.
|
|
88
88
|
* @param {Buffer} rendezvousKey The swarm key to use for Greeting.
|
|
89
|
-
* @returns {{
|
|
89
|
+
* @returns {{'@type': string, payload: {'@type': string, rendezvousKey: *, id: *}}}
|
|
90
90
|
*/
|
|
91
91
|
export const createGreetingClaimResponse = (id: Buffer, rendezvousKey: Buffer): WithTypeUrl<ClaimResponse> => {
|
|
92
92
|
assert(id);
|
|
93
93
|
assert(Buffer.isBuffer(rendezvousKey), 'rendezvousKey is not a buffer.');
|
|
94
94
|
|
|
95
95
|
return {
|
|
96
|
-
|
|
96
|
+
'@type': 'dxos.credentials.greet.ClaimResponse',
|
|
97
97
|
id,
|
|
98
98
|
rendezvousKey
|
|
99
99
|
};
|
|
@@ -9,12 +9,12 @@ import { unwrapEnvelopes, extractContents, unwrapMessage, wrapMessage } from '..
|
|
|
9
9
|
import { DeviceInfo, IdentityInfo, KeyRecord, Message, SignedMessage, WithTypeUrl } from '../proto';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Return the
|
|
12
|
+
* Return the @type, if present.
|
|
13
13
|
* @param message
|
|
14
14
|
*/
|
|
15
15
|
function getTypeUrl (message: any) {
|
|
16
16
|
// eslint-disable-next-line camelcase
|
|
17
|
-
return message?.
|
|
17
|
+
return message?.['@type'];
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
@@ -26,7 +26,7 @@ export const createDeviceInfoMessage = (keyring: Keyring, displayName: string, d
|
|
|
26
26
|
assert(deviceKey);
|
|
27
27
|
|
|
28
28
|
const message: WithTypeUrl<DeviceInfo> = {
|
|
29
|
-
|
|
29
|
+
'@type': 'dxos.credentials.identity.DeviceInfo',
|
|
30
30
|
publicKey: deviceKey.publicKey,
|
|
31
31
|
displayName
|
|
32
32
|
};
|
|
@@ -43,7 +43,7 @@ export const createIdentityInfoMessage = (keyring: Keyring, displayName: string,
|
|
|
43
43
|
assert(identityKey);
|
|
44
44
|
|
|
45
45
|
const message: WithTypeUrl<IdentityInfo> = {
|
|
46
|
-
|
|
46
|
+
'@type': 'dxos.credentials.identity.IdentityInfo',
|
|
47
47
|
publicKey: identityKey.publicKey,
|
|
48
48
|
displayName
|
|
49
49
|
};
|
|
@@ -132,11 +132,12 @@ export const canonicalStringify = (obj: any) => {
|
|
|
132
132
|
return stableStringify(obj, {
|
|
133
133
|
/* The point of signing and verifying is not that the internal, private state of the objects be
|
|
134
134
|
* identical, but that the public contents can be verified not to have been altered. For that reason,
|
|
135
|
-
* really private fields (indicated by '__') are not included in the signature.
|
|
136
|
-
*
|
|
135
|
+
* really private fields (indicated by '__') are not included in the signature.
|
|
136
|
+
* This gives a mechanism for attaching other attributes to an object without breaking the signature.
|
|
137
|
+
* We also skip @type.
|
|
137
138
|
*/
|
|
138
139
|
replacer: (key: any, value: any) => {
|
|
139
|
-
if (key.toString().startsWith('__')) {
|
|
140
|
+
if (key.toString().startsWith('__') || key.toString() === '@type') {
|
|
140
141
|
return undefined;
|
|
141
142
|
}
|
|
142
143
|
if (value) {
|
package/src/keys/keyring.ts
CHANGED
|
@@ -140,7 +140,7 @@ export class Keyring implements Signer {
|
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
return {
|
|
143
|
-
|
|
143
|
+
'@type': 'dxos.credentials.SignedMessage',
|
|
144
144
|
signed,
|
|
145
145
|
signatures
|
|
146
146
|
};
|
|
@@ -564,7 +564,7 @@ export class Keyring implements Signer {
|
|
|
564
564
|
});
|
|
565
565
|
|
|
566
566
|
return canonicalStringify({
|
|
567
|
-
|
|
567
|
+
'@type': 'dxos.credentials.keys.KeyRecordList',
|
|
568
568
|
keys
|
|
569
569
|
});
|
|
570
570
|
}
|
|
@@ -34,7 +34,7 @@ export const createPartyGenesisMessage = (
|
|
|
34
34
|
assert(typeof admitKeyPair.type !== 'undefined');
|
|
35
35
|
|
|
36
36
|
const message: WithTypeUrl<PartyCredential> = {
|
|
37
|
-
|
|
37
|
+
'@type': TYPE_URL_PARTY_CREDENTIAL,
|
|
38
38
|
type: PartyCredential.Type.PARTY_GENESIS,
|
|
39
39
|
partyGenesis: {
|
|
40
40
|
partyKey: partyKeyPair.publicKey,
|
|
@@ -61,7 +61,7 @@ export const createKeyAdmitMessage = (
|
|
|
61
61
|
partyKey = PublicKey.from(partyKey);
|
|
62
62
|
|
|
63
63
|
const message: WithTypeUrl<PartyCredential> = {
|
|
64
|
-
|
|
64
|
+
'@type': TYPE_URL_PARTY_CREDENTIAL,
|
|
65
65
|
type: PartyCredential.Type.KEY_ADMIT,
|
|
66
66
|
keyAdmit: {
|
|
67
67
|
partyKey,
|
|
@@ -87,7 +87,7 @@ export const createFeedAdmitMessage = (
|
|
|
87
87
|
partyKey = PublicKey.from(partyKey);
|
|
88
88
|
|
|
89
89
|
const message: WithTypeUrl<PartyCredential> = {
|
|
90
|
-
|
|
90
|
+
'@type': TYPE_URL_PARTY_CREDENTIAL,
|
|
91
91
|
type: PartyCredential.Type.FEED_ADMIT,
|
|
92
92
|
feedAdmit: {
|
|
93
93
|
partyKey,
|
|
@@ -115,7 +115,7 @@ export const createEnvelopeMessage = (
|
|
|
115
115
|
partyKey = PublicKey.from(partyKey);
|
|
116
116
|
|
|
117
117
|
const message: WithTypeUrl<PartyCredential> = {
|
|
118
|
-
|
|
118
|
+
'@type': TYPE_URL_PARTY_CREDENTIAL,
|
|
119
119
|
type: PartyCredential.Type.ENVELOPE,
|
|
120
120
|
envelope: {
|
|
121
121
|
partyKey,
|
|
@@ -134,7 +134,7 @@ export const createEnvelopeMessage = (
|
|
|
134
134
|
export const isPartyCredentialMessage = (message: Message | SignedMessage) => {
|
|
135
135
|
const signed = unwrapMessage(message) as SignedMessage;
|
|
136
136
|
// eslint-disable-next-line camelcase
|
|
137
|
-
return signed?.signed?.payload?.
|
|
137
|
+
return signed?.signed?.payload?.['@type'] === TYPE_URL_PARTY_CREDENTIAL;
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
/**
|
|
@@ -166,7 +166,7 @@ export function isSignedMessage (message: any): message is SignedMessage {
|
|
|
166
166
|
// TODO(burdon): Typespec is too loose.
|
|
167
167
|
export function wrapMessage (message: Message | SignedMessage | Command | Auth): WithTypeUrl<Message> {
|
|
168
168
|
const payload = message as any;
|
|
169
|
-
return {
|
|
169
|
+
return { '@type': TYPE_URL_MESSAGE, payload } as WithTypeUrl<Message>;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
/**
|
|
@@ -286,10 +286,10 @@ export const createPartyInvitationMessage = (
|
|
|
286
286
|
inviteeKey = PublicKey.from(inviteeKey);
|
|
287
287
|
|
|
288
288
|
return {
|
|
289
|
-
|
|
289
|
+
'@type': TYPE_URL_MESSAGE,
|
|
290
290
|
payload:
|
|
291
291
|
signer.sign({
|
|
292
|
-
|
|
292
|
+
'@type': TYPE_URL_PARTY_INVITATION,
|
|
293
293
|
id: randomBytes(),
|
|
294
294
|
partyKey,
|
|
295
295
|
issuerKey: issuerKey.publicKey,
|
|
@@ -307,8 +307,8 @@ export const isPartyInvitationMessage = (message: Message | SignedMessage) => {
|
|
|
307
307
|
const signed = unwrapMessage(message);
|
|
308
308
|
|
|
309
309
|
// eslint-disable-next-line camelcase
|
|
310
|
-
const payloadType = signed?.
|
|
310
|
+
const payloadType = signed?.['@type'];
|
|
311
311
|
// eslint-disable-next-line camelcase
|
|
312
|
-
const signedType = signed?.signed?.payload?.
|
|
312
|
+
const signedType = signed?.signed?.payload?.['@type'];
|
|
313
313
|
return payloadType === TYPE_URL_SIGNED_MESSAGE && signedType === TYPE_URL_PARTY_INVITATION;
|
|
314
314
|
};
|
package/src/proto/any.ts
CHANGED
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
import { TYPES } from './gen';
|
|
6
6
|
|
|
7
7
|
// eslint-disable-next-line camelcase
|
|
8
|
-
export type WithTypeUrl<T> = T & {
|
|
8
|
+
export type WithTypeUrl<T> = T & { '@type': string }
|
|
9
9
|
|
|
10
10
|
export interface DecodedAny {
|
|
11
11
|
// eslint-disable-next-line camelcase
|
|
12
|
-
|
|
12
|
+
'@type': string,
|
|
13
13
|
[key: string]: any,
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export type KnownAny = {
|
|
17
17
|
[K in keyof TYPES]: {
|
|
18
18
|
// eslint-disable-next-line camelcase
|
|
19
|
-
|
|
19
|
+
'@type': K,
|
|
20
20
|
} & TYPES[K]
|
|
21
21
|
}[keyof TYPES]
|