@dxos/protocols 0.1.57 → 0.1.58-main.0e9c99e
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/dist/cjs/src/errors/encoding.d.ts +7 -0
- package/dist/cjs/src/errors/encoding.d.ts.map +1 -0
- package/dist/cjs/src/errors/encoding.js +41 -0
- package/dist/cjs/src/errors/encoding.js.map +1 -0
- package/dist/cjs/src/errors/errors.d.ts +99 -0
- package/dist/cjs/src/errors/errors.d.ts.map +1 -0
- package/dist/cjs/src/errors/errors.js +171 -0
- package/dist/cjs/src/errors/errors.js.map +1 -0
- package/dist/cjs/src/errors/errors.test.d.ts +2 -0
- package/dist/cjs/src/errors/errors.test.d.ts.map +1 -0
- package/dist/cjs/src/errors/errors.test.js +45 -0
- package/dist/cjs/src/errors/errors.test.js.map +1 -0
- package/dist/cjs/src/errors/helpers.d.ts +5 -0
- package/dist/cjs/src/errors/helpers.d.ts.map +1 -0
- package/dist/cjs/src/errors/helpers.js +74 -0
- package/dist/cjs/src/errors/helpers.js.map +1 -0
- package/dist/cjs/src/errors/index.d.ts +4 -0
- package/dist/cjs/src/errors/index.d.ts.map +1 -0
- package/dist/cjs/src/errors/index.js +23 -0
- package/dist/cjs/src/errors/index.js.map +1 -0
- package/dist/cjs/src/proto/gen/dxos/client/services.d.ts +7 -1
- package/dist/cjs/src/proto/gen/dxos/client/services.d.ts.map +1 -1
- package/dist/cjs/src/proto/gen/dxos/client/services.js +1 -0
- package/dist/cjs/src/proto/gen/dxos/client/services.js.map +1 -1
- package/dist/cjs/src/proto/gen/dxos/error.d.ts +6 -0
- package/dist/cjs/src/proto/gen/dxos/error.d.ts.map +1 -1
- package/dist/cjs/src/proto/gen/dxos/halo/credentials.d.ts +14 -1
- package/dist/cjs/src/proto/gen/dxos/halo/credentials.d.ts.map +1 -1
- package/dist/cjs/src/proto/gen/dxos/halo/credentials.js.map +1 -1
- package/dist/cjs/src/proto/gen/dxos/iframe.d.ts +5 -10
- package/dist/cjs/src/proto/gen/dxos/iframe.d.ts.map +1 -1
- package/dist/cjs/src/proto/gen/dxos/iframe.js +5 -3
- package/dist/cjs/src/proto/gen/dxos/iframe.js.map +1 -1
- package/dist/cjs/src/proto/gen/google/protobuf.d.ts +4 -4
- package/dist/cjs/src/proto/gen/google/protobuf.d.ts.map +1 -1
- package/dist/cjs/src/proto/gen/google/protobuf.js.map +1 -1
- package/dist/cjs/src/proto/gen/index.d.ts +1 -0
- package/dist/cjs/src/proto/gen/index.d.ts.map +1 -1
- package/dist/cjs/src/proto/gen/index.js +1 -1
- package/dist/cjs/src/proto/gen/index.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/src/errors/encoding.d.ts +7 -0
- package/dist/esm/src/errors/encoding.d.ts.map +1 -0
- package/dist/esm/src/errors/encoding.js +35 -0
- package/dist/esm/src/errors/encoding.js.map +1 -0
- package/dist/esm/src/errors/errors.d.ts +99 -0
- package/dist/esm/src/errors/errors.d.ts.map +1 -0
- package/dist/esm/src/errors/errors.js +148 -0
- package/dist/esm/src/errors/errors.js.map +1 -0
- package/dist/esm/src/errors/errors.test.d.ts +2 -0
- package/dist/esm/src/errors/errors.test.d.ts.map +1 -0
- package/dist/esm/src/errors/errors.test.js +17 -0
- package/dist/esm/src/errors/errors.test.js.map +1 -0
- package/dist/esm/src/errors/helpers.d.ts +5 -0
- package/dist/esm/src/errors/helpers.d.ts.map +1 -0
- package/dist/esm/src/errors/helpers.js +69 -0
- package/dist/esm/src/errors/helpers.js.map +1 -0
- package/dist/esm/src/errors/index.d.ts +4 -0
- package/dist/esm/src/errors/index.d.ts.map +1 -0
- package/dist/esm/src/errors/index.js +7 -0
- package/dist/esm/src/errors/index.js.map +1 -0
- package/dist/esm/src/proto/gen/dxos/client/services.d.ts +7 -1
- package/dist/esm/src/proto/gen/dxos/client/services.d.ts.map +1 -1
- package/dist/esm/src/proto/gen/dxos/client/services.js +1 -0
- package/dist/esm/src/proto/gen/dxos/client/services.js.map +1 -1
- package/dist/esm/src/proto/gen/dxos/error.d.ts +6 -0
- package/dist/esm/src/proto/gen/dxos/error.d.ts.map +1 -1
- package/dist/esm/src/proto/gen/dxos/halo/credentials.d.ts +14 -1
- package/dist/esm/src/proto/gen/dxos/halo/credentials.d.ts.map +1 -1
- package/dist/esm/src/proto/gen/dxos/halo/credentials.js.map +1 -1
- package/dist/esm/src/proto/gen/dxos/iframe.d.ts +5 -10
- package/dist/esm/src/proto/gen/dxos/iframe.d.ts.map +1 -1
- package/dist/esm/src/proto/gen/dxos/iframe.js +5 -3
- package/dist/esm/src/proto/gen/dxos/iframe.js.map +1 -1
- package/dist/esm/src/proto/gen/google/protobuf.d.ts +4 -4
- package/dist/esm/src/proto/gen/google/protobuf.d.ts.map +1 -1
- package/dist/esm/src/proto/gen/google/protobuf.js.map +1 -1
- package/dist/esm/src/proto/gen/index.d.ts +1 -0
- package/dist/esm/src/proto/gen/index.d.ts.map +1 -1
- package/dist/esm/src/proto/gen/index.js +1 -1
- package/dist/esm/src/proto/gen/index.js.map +1 -1
- package/package.json +5 -4
- package/src/errors/encoding.ts +40 -0
- package/src/errors/errors.test.ts +22 -0
- package/src/errors/errors.ts +166 -0
- package/src/errors/helpers.ts +113 -0
- package/src/errors/index.ts +7 -0
- package/src/proto/dxos/client/services.proto +2 -0
- package/src/proto/dxos/error.proto +1 -0
- package/src/proto/dxos/halo/credentials.proto +8 -1
- package/src/proto/dxos/iframe.proto +6 -5
- package/src/proto/gen/dxos/client/services.ts +7 -1
- package/src/proto/gen/dxos/error.ts +5 -0
- package/src/proto/gen/dxos/halo/credentials.ts +14 -1
- package/src/proto/gen/dxos/iframe.ts +5 -10
- package/src/proto/gen/google/protobuf.ts +4 -4
- package/src/proto/gen/index.ts +2 -1
- package/dist/cjs/src/errors.d.ts +0 -25
- package/dist/cjs/src/errors.d.ts.map +0 -1
- package/dist/cjs/src/errors.js +0 -78
- package/dist/cjs/src/errors.js.map +0 -1
- package/dist/esm/src/errors.d.ts +0 -25
- package/dist/esm/src/errors.d.ts.map +0 -1
- package/dist/esm/src/errors.js +0 -69
- package/dist/esm/src/errors.js.map +0 -1
- package/src/errors.ts +0 -80
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/proto/gen/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAuDhE,OAAO,aAAa,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/proto/gen/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAuDhE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AA+e7C,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,qm0FAAqm0F,CAAC,CAAC,CAAC;AAC9p0F,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAkB,UAAU,EAAE,aAAa,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/protocols",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.58-main.0e9c99e",
|
|
4
4
|
"description": "Protobuf definitions for DXOS protocols.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -33,9 +33,10 @@
|
|
|
33
33
|
"src"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@dxos/codec-protobuf": "0.1.
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
36
|
+
"@dxos/codec-protobuf": "0.1.58-main.0e9c99e",
|
|
37
|
+
"@dxos/invariant": "0.1.58-main.0e9c99e",
|
|
38
|
+
"@dxos/keys": "0.1.58-main.0e9c99e",
|
|
39
|
+
"@dxos/timeframe": "0.1.58-main.0e9c99e"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"glob": "~7.1.6"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Error as SerializedErrorProto } from '../proto/gen/dxos/error';
|
|
6
|
+
import { reconstructError } from './helpers';
|
|
7
|
+
|
|
8
|
+
export const encodeError = (err: any): SerializedErrorProto => {
|
|
9
|
+
if (typeof err === 'object' && err?.message) {
|
|
10
|
+
return {
|
|
11
|
+
name: err.name,
|
|
12
|
+
message: err.message,
|
|
13
|
+
context: err.context,
|
|
14
|
+
stack: err.stack,
|
|
15
|
+
};
|
|
16
|
+
} else if (typeof err === 'string') {
|
|
17
|
+
return {
|
|
18
|
+
message: err,
|
|
19
|
+
};
|
|
20
|
+
} else {
|
|
21
|
+
return {
|
|
22
|
+
message: JSON.stringify(err),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type DecodeOptions = {
|
|
28
|
+
appendStack?: string;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const decodeError = (err: SerializedErrorProto, { appendStack }: DecodeOptions = {}) => {
|
|
32
|
+
const error = reconstructError(err);
|
|
33
|
+
if (appendStack) {
|
|
34
|
+
error.stack = (err.stack ?? `${error.message}\n`) + appendStack;
|
|
35
|
+
} else {
|
|
36
|
+
error.stack = err.stack;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return error;
|
|
40
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2022 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import chai, { expect } from 'chai';
|
|
6
|
+
import chaiAsPromised from 'chai-as-promised';
|
|
7
|
+
|
|
8
|
+
import { describe, test } from '@dxos/test';
|
|
9
|
+
|
|
10
|
+
import { ApiError } from './errors';
|
|
11
|
+
|
|
12
|
+
chai.use(chaiAsPromised);
|
|
13
|
+
|
|
14
|
+
describe('Errors', () => {
|
|
15
|
+
test('test', async () => {
|
|
16
|
+
const runTest = async () => {
|
|
17
|
+
throw new ApiError('Test error');
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
await expect(runTest()).to.be.rejectedWith('Test error');
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2021 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import type { PublicKey } from '@dxos/keys';
|
|
6
|
+
|
|
7
|
+
import type { ItemID } from '../types';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* NOTE: Messages should be sentences (Start with a capital letter and end with a period).
|
|
11
|
+
* Errors can optionally include a JSON context object.
|
|
12
|
+
*/
|
|
13
|
+
class BaseError extends Error {
|
|
14
|
+
constructor(readonly code: string, message?: string, readonly context?: Record<string, any>) {
|
|
15
|
+
super(message ?? code);
|
|
16
|
+
this.name = code;
|
|
17
|
+
// NOTE: Restores prototype chain (https://stackoverflow.com/a/48342359).
|
|
18
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* User facing API Errors.
|
|
24
|
+
* E.g., something was misconfigured.
|
|
25
|
+
*/
|
|
26
|
+
export class ApiError extends BaseError {}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internal system errors.
|
|
30
|
+
* E.g., unexpected/unrecoverable runtime error.
|
|
31
|
+
*/
|
|
32
|
+
export class SystemError extends BaseError {}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Database errors.
|
|
36
|
+
*/
|
|
37
|
+
// TODO(wittjosiah): Same as ApiError?
|
|
38
|
+
export class DatabaseError extends BaseError {}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Thrown when request was terminated because the RPC endpoint has been closed.
|
|
42
|
+
*/
|
|
43
|
+
export class RpcClosedError extends SystemError {
|
|
44
|
+
constructor() {
|
|
45
|
+
super('RPC_CLOSED', 'Request was terminated because the RPC endpoint is closed.');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Thrown when `request` is called when RPC has not been opened.
|
|
51
|
+
*/
|
|
52
|
+
export class RpcNotOpenError extends SystemError {
|
|
53
|
+
constructor() {
|
|
54
|
+
super('RPC_NOT_OPEN', 'RPC has not been opened.');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export class CancelledError extends SystemError {
|
|
59
|
+
constructor(message?: string, context?: Record<string, any>) {
|
|
60
|
+
super('CANCELLED', message, context);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export class InvalidConfigError extends ApiError {
|
|
65
|
+
constructor(message?: string, context?: Record<string, any>) {
|
|
66
|
+
super('INVALID_CONFIG', message, context);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Explicit failure to connect with remote client services.
|
|
72
|
+
*/
|
|
73
|
+
export class RemoteServiceConnectionError extends ApiError {
|
|
74
|
+
constructor(message?: string, context?: Record<string, any>) {
|
|
75
|
+
super('REMOTE_SERVICE_CONNECTION_ERROR', message, context);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Failed to open a connection to remote client services.
|
|
81
|
+
*/
|
|
82
|
+
export class RemoteServiceConnectionTimeout extends ApiError {
|
|
83
|
+
constructor(message?: string, context?: Record<string, any>) {
|
|
84
|
+
super('REMOTE_SERVICE_CONNECTION_TIMEOUT', message, context);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export class DataCorruptionError extends SystemError {
|
|
89
|
+
constructor(message?: string, context?: Record<string, any>) {
|
|
90
|
+
super('DATA_CORRUPTION', message, context);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class InvalidInvitationExtensionRoleError extends SystemError {
|
|
95
|
+
constructor(message?: string, context?: Record<string, any>) {
|
|
96
|
+
super('INVALID_INVITATION_EXTENSION_ROLE', message, context);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export class IdentityNotInitializedError extends DatabaseError {
|
|
101
|
+
constructor(message?: string, context?: Record<string, any>) {
|
|
102
|
+
super('IDENTITY_NOT_INITIALIZED', message, context);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export class InvalidInvitationError extends DatabaseError {
|
|
107
|
+
constructor(message?: string, context?: Record<string, any>) {
|
|
108
|
+
super('INVALID_INVITATION', message, context);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export class ConnectionResetError extends BaseError {
|
|
113
|
+
constructor(message?: string, context?: any) {
|
|
114
|
+
super('CONNECTION_RESET', message, context);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export class TimeoutError extends BaseError {
|
|
119
|
+
constructor(message?: string, context?: any) {
|
|
120
|
+
super('TIMEOUT', message, context);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// General protocol error
|
|
125
|
+
export class ProtocolError extends BaseError {
|
|
126
|
+
constructor(message?: string, context?: any) {
|
|
127
|
+
super('PROTOCOL_ERROR', message, context);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// General connectivity errors
|
|
132
|
+
export class ConnectivityError extends BaseError {
|
|
133
|
+
constructor(message?: string, context?: any) {
|
|
134
|
+
super('CONNECTIVITY_ERROR', message, context);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// TODO(nf): Rename? the protocol isn't what's unknown...
|
|
139
|
+
export class UnknownProtocolError extends BaseError {
|
|
140
|
+
constructor(message?: string, innerError?: Error) {
|
|
141
|
+
super('UNKNOWN_PROTOCOL_ERROR', message, innerError);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export class InvalidStorageVersionError extends DatabaseError {
|
|
145
|
+
constructor(expected: number, actual: number) {
|
|
146
|
+
super('INVALID_STORAGE_VERSION', 'Invalid storage version.', { expected, actual });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export class SpaceNotFoundError extends DatabaseError {
|
|
151
|
+
constructor(spaceKey: PublicKey) {
|
|
152
|
+
super('SPACE_NOT_FOUND', 'Space not found.', { spaceKey });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export class EntityNotFoundError extends DatabaseError {
|
|
157
|
+
constructor(entityId: ItemID) {
|
|
158
|
+
super('ITEM_NOT_FOUND', 'Item not found.', { entityId });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export class UnknownModelError extends DatabaseError {
|
|
163
|
+
constructor(model: string) {
|
|
164
|
+
super('UNKNOWN_MODEL', 'Unknown model.', { model });
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { invariant } from '@dxos/invariant';
|
|
6
|
+
import { PublicKey } from '@dxos/keys';
|
|
7
|
+
|
|
8
|
+
import { Error as SerializedErrorProto } from '../proto/gen/dxos/error';
|
|
9
|
+
import {
|
|
10
|
+
CancelledError,
|
|
11
|
+
ConnectionResetError,
|
|
12
|
+
ConnectivityError,
|
|
13
|
+
DataCorruptionError,
|
|
14
|
+
EntityNotFoundError,
|
|
15
|
+
IdentityNotInitializedError,
|
|
16
|
+
InvalidConfigError,
|
|
17
|
+
InvalidInvitationError,
|
|
18
|
+
InvalidInvitationExtensionRoleError,
|
|
19
|
+
InvalidStorageVersionError,
|
|
20
|
+
ProtocolError,
|
|
21
|
+
RemoteServiceConnectionError,
|
|
22
|
+
RemoteServiceConnectionTimeout,
|
|
23
|
+
RpcClosedError,
|
|
24
|
+
RpcNotOpenError,
|
|
25
|
+
SpaceNotFoundError,
|
|
26
|
+
SystemError,
|
|
27
|
+
TimeoutError,
|
|
28
|
+
UnknownModelError,
|
|
29
|
+
UnknownProtocolError,
|
|
30
|
+
} from './errors';
|
|
31
|
+
|
|
32
|
+
export const reconstructError = (error: SerializedErrorProto) => {
|
|
33
|
+
const { name, message, context } = error;
|
|
34
|
+
return errorFromCode(name, message, context);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const errorFromCode = (code?: string, message?: string, context?: any) => {
|
|
38
|
+
switch (code) {
|
|
39
|
+
case 'RPC_CLOSED':
|
|
40
|
+
return new RpcClosedError();
|
|
41
|
+
|
|
42
|
+
case 'RPC_NOT_OPEN':
|
|
43
|
+
return new RpcNotOpenError();
|
|
44
|
+
|
|
45
|
+
case 'CANCELLED':
|
|
46
|
+
return new CancelledError(message, context);
|
|
47
|
+
|
|
48
|
+
case 'INVALID_CONFIG':
|
|
49
|
+
return new InvalidConfigError(message, context);
|
|
50
|
+
|
|
51
|
+
case 'REMOTE_SERVICE_CONNECTION_ERROR':
|
|
52
|
+
return new RemoteServiceConnectionError(message, context);
|
|
53
|
+
|
|
54
|
+
case 'REMOTE_SERVICE_CONNECTION_TIMEOUT':
|
|
55
|
+
return new RemoteServiceConnectionTimeout(message, context);
|
|
56
|
+
|
|
57
|
+
case 'DATA_CORRUPTION':
|
|
58
|
+
return new DataCorruptionError(message, context);
|
|
59
|
+
|
|
60
|
+
case 'INVALID_INVITATION_EXTENSION_ROLE':
|
|
61
|
+
return new InvalidInvitationExtensionRoleError(message, context);
|
|
62
|
+
|
|
63
|
+
case 'CONNECTION_RESET':
|
|
64
|
+
return new ConnectionResetError(message, context);
|
|
65
|
+
|
|
66
|
+
case 'TIMEOUT':
|
|
67
|
+
return new TimeoutError(message, context);
|
|
68
|
+
|
|
69
|
+
case 'PROTOCOL_ERROR':
|
|
70
|
+
return new ProtocolError(message, context);
|
|
71
|
+
|
|
72
|
+
case 'CONNECTIVITY_ERROR':
|
|
73
|
+
return new ConnectivityError(message, context);
|
|
74
|
+
|
|
75
|
+
case 'UNKNOWN_PROTOCOL_ERROR':
|
|
76
|
+
return new UnknownProtocolError(message, context);
|
|
77
|
+
|
|
78
|
+
case 'IDENTITY_NOT_INITIALIZED':
|
|
79
|
+
return new IdentityNotInitializedError(message, context);
|
|
80
|
+
|
|
81
|
+
case 'INVALID_INVITATION':
|
|
82
|
+
return new InvalidInvitationError(message, context);
|
|
83
|
+
|
|
84
|
+
case 'INVALID_STORAGE_VERSION': {
|
|
85
|
+
const { expected, actual } = context;
|
|
86
|
+
invariant(expected);
|
|
87
|
+
invariant(actual);
|
|
88
|
+
return new InvalidStorageVersionError(expected, actual);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
case 'SPACE_NOT_FOUND': {
|
|
92
|
+
const { spaceKey: key } = context;
|
|
93
|
+
const spaceKey = PublicKey.safeFrom(key);
|
|
94
|
+
invariant(spaceKey);
|
|
95
|
+
return new SpaceNotFoundError(spaceKey);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
case 'ITEM_NOT_FOUND': {
|
|
99
|
+
const { entityId } = context;
|
|
100
|
+
invariant(typeof entityId === 'string');
|
|
101
|
+
return new EntityNotFoundError(entityId);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
case 'UNKNOWN_MODEL': {
|
|
105
|
+
const { model } = context;
|
|
106
|
+
invariant(typeof model === 'string');
|
|
107
|
+
return new UnknownModelError(model);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
default:
|
|
111
|
+
return new SystemError(code ?? 'Error', message, context);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
@@ -163,6 +163,7 @@ message SpaceMember {
|
|
|
163
163
|
enum PresenceState {
|
|
164
164
|
OFFLINE = 0;
|
|
165
165
|
ONLINE = 1;
|
|
166
|
+
REMOVED = 2;
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
Identity identity = 1;
|
|
@@ -301,6 +302,7 @@ message WriteCredentialsRequest {
|
|
|
301
302
|
|
|
302
303
|
message QueryCredentialsRequest {
|
|
303
304
|
dxos.keys.PublicKey space_key = 1;
|
|
305
|
+
optional bool no_tail = 2;
|
|
304
306
|
}
|
|
305
307
|
|
|
306
308
|
message CreateEpochRequest {
|
|
@@ -38,6 +38,13 @@ message SpaceGenesis {
|
|
|
38
38
|
// Claims can be written directly to a feed or used within Credentials.
|
|
39
39
|
//
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Revocation of another credential.
|
|
43
|
+
* Subject must be the credential id being revoked.
|
|
44
|
+
*/
|
|
45
|
+
message Revocation {
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
// TODO(burdon): Reconcile with dxos.client.SpaceMember.
|
|
42
49
|
// [ASSERTION]: Agent is authorized to access Space.
|
|
43
50
|
message SpaceMember {
|
|
@@ -219,7 +226,7 @@ message Credential {
|
|
|
219
226
|
optional google.protobuf.Timestamp expiration_date = 4;
|
|
220
227
|
optional bytes expiration_ref = 5; // Could reference blockchain or epoch number.
|
|
221
228
|
Claim subject = 10;
|
|
222
|
-
Proof proof = 11;
|
|
229
|
+
optional Proof proof = 11;
|
|
223
230
|
}
|
|
224
231
|
|
|
225
232
|
//
|
|
@@ -31,10 +31,9 @@ enum ShellDisplay {
|
|
|
31
31
|
message AppContextRequest {
|
|
32
32
|
/// The display mode that shell should use
|
|
33
33
|
optional ShellDisplay display = 1;
|
|
34
|
+
|
|
34
35
|
/// The key of the joined space
|
|
35
36
|
optional dxos.keys.PublicKey space_key = 2;
|
|
36
|
-
/// The invitation code which has become invalidated
|
|
37
|
-
optional string invalidated_invitation_code = 3;
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
/// App RPCs for the shell.
|
|
@@ -45,9 +44,11 @@ service AppService {
|
|
|
45
44
|
enum ShellLayout {
|
|
46
45
|
DEFAULT = 0;
|
|
47
46
|
INITIALIZE_IDENTITY = 1;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
IDENTITY = 2;
|
|
48
|
+
SHARE_IDENTITY = 3;
|
|
49
|
+
EDIT_PROFILE = 4;
|
|
50
|
+
SPACE = 5;
|
|
51
|
+
JOIN_SPACE = 6;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
54
|
message LayoutRequest {
|
|
@@ -442,7 +442,8 @@ export namespace SpaceMember {
|
|
|
442
442
|
*/
|
|
443
443
|
export enum PresenceState {
|
|
444
444
|
OFFLINE = 0,
|
|
445
|
-
ONLINE = 1
|
|
445
|
+
ONLINE = 1,
|
|
446
|
+
REMOVED = 2
|
|
446
447
|
}
|
|
447
448
|
}
|
|
448
449
|
/**
|
|
@@ -678,6 +679,11 @@ export interface WriteCredentialsRequest {
|
|
|
678
679
|
*/
|
|
679
680
|
export interface QueryCredentialsRequest {
|
|
680
681
|
spaceKey: ReturnType<(typeof substitutions)["dxos.keys.PublicKey"]["decode"]>;
|
|
682
|
+
/**
|
|
683
|
+
* Options:
|
|
684
|
+
* - proto3_optional = true
|
|
685
|
+
*/
|
|
686
|
+
noTail?: boolean;
|
|
681
687
|
}
|
|
682
688
|
/**
|
|
683
689
|
* Defined in:
|
|
@@ -70,6 +70,11 @@ export interface Error {
|
|
|
70
70
|
* - proto3_optional = true
|
|
71
71
|
*/
|
|
72
72
|
message?: string;
|
|
73
|
+
/**
|
|
74
|
+
* Options:
|
|
75
|
+
* - proto3_optional = true
|
|
76
|
+
*/
|
|
77
|
+
context?: ReturnType<(typeof substitutions)["google.protobuf.Struct"]["decode"]>;
|
|
73
78
|
/**
|
|
74
79
|
* Options:
|
|
75
80
|
* - proto3_optional = true
|
|
@@ -60,6 +60,15 @@ import * as google_protobuf from "../../google/protobuf";
|
|
|
60
60
|
export interface SpaceGenesis {
|
|
61
61
|
spaceKey: ReturnType<(typeof substitutions)["dxos.keys.PublicKey"]["decode"]>;
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Revocation of another credential.
|
|
65
|
+
* Subject must be the credential id being revoked.
|
|
66
|
+
*
|
|
67
|
+
* Defined in:
|
|
68
|
+
* {@link file://./../../../dxos/halo/credentials.proto}
|
|
69
|
+
*/
|
|
70
|
+
export interface Revocation {
|
|
71
|
+
}
|
|
63
72
|
/**
|
|
64
73
|
* Defined in:
|
|
65
74
|
* {@link file://./../../../dxos/halo/credentials.proto}
|
|
@@ -314,7 +323,11 @@ export interface Credential {
|
|
|
314
323
|
*/
|
|
315
324
|
expirationRef?: Uint8Array;
|
|
316
325
|
subject: Claim;
|
|
317
|
-
|
|
326
|
+
/**
|
|
327
|
+
* Options:
|
|
328
|
+
* - proto3_optional = true
|
|
329
|
+
*/
|
|
330
|
+
proof?: Proof;
|
|
318
331
|
}
|
|
319
332
|
/**
|
|
320
333
|
* Defined in:
|
|
@@ -104,13 +104,6 @@ export interface AppContextRequest {
|
|
|
104
104
|
* - proto3_optional = true
|
|
105
105
|
*/
|
|
106
106
|
spaceKey?: ReturnType<(typeof substitutions)["dxos.keys.PublicKey"]["decode"]>;
|
|
107
|
-
/**
|
|
108
|
-
* The invitation code which has become invalidated
|
|
109
|
-
*
|
|
110
|
-
* Options:
|
|
111
|
-
* - proto3_optional = true
|
|
112
|
-
*/
|
|
113
|
-
invalidatedInvitationCode?: string;
|
|
114
107
|
}
|
|
115
108
|
/**
|
|
116
109
|
* App RPCs for the shell.
|
|
@@ -128,9 +121,11 @@ export interface AppService {
|
|
|
128
121
|
export enum ShellLayout {
|
|
129
122
|
DEFAULT = 0,
|
|
130
123
|
INITIALIZE_IDENTITY = 1,
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
124
|
+
IDENTITY = 2,
|
|
125
|
+
SHARE_IDENTITY = 3,
|
|
126
|
+
EDIT_PROFILE = 4,
|
|
127
|
+
SPACE = 5,
|
|
128
|
+
JOIN_SPACE = 6
|
|
134
129
|
}
|
|
135
130
|
/**
|
|
136
131
|
* Defined in:
|
|
@@ -55,6 +55,10 @@ import * as example_testing_data from "../example/testing/data";
|
|
|
55
55
|
import * as example_testing_rpc from "../example/testing/rpc";
|
|
56
56
|
export interface Empty {
|
|
57
57
|
}
|
|
58
|
+
export interface Timestamp {
|
|
59
|
+
seconds: string;
|
|
60
|
+
nanos: number;
|
|
61
|
+
}
|
|
58
62
|
export interface Any {
|
|
59
63
|
type_url: string;
|
|
60
64
|
value: Uint8Array;
|
|
@@ -76,10 +80,6 @@ export enum NullValue {
|
|
|
76
80
|
export interface ListValue {
|
|
77
81
|
values?: Value[];
|
|
78
82
|
}
|
|
79
|
-
export interface Timestamp {
|
|
80
|
-
seconds: string;
|
|
81
|
-
nanos: number;
|
|
82
|
-
}
|
|
83
83
|
export interface FileDescriptorSet {
|
|
84
84
|
file?: FileDescriptorProto[];
|
|
85
85
|
}
|