@miradorlabs/web-grpc 4.20.0 → 4.21.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miradorlabs/web-grpc",
3
- "version": "4.20.0",
3
+ "version": "4.21.0",
4
4
  "description": "Generated gRPC (grpc-js) client stubs for the Mirador web gateway.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -0,0 +1,615 @@
1
+ // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
2
+ // versions:
3
+ // protoc-gen-ts_proto v2.18.4
4
+ // protoc v3.21.12
5
+ // source: proto/gateway/web/v1/desktop_auth_gateway.proto
6
+
7
+ /* eslint-disable */
8
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
9
+ import type { Metadata } from "@grpc/grpc-js";
10
+ import { Timestamp } from "../../../../google/protobuf/timestamp";
11
+ import { ResponseStatus } from "../../common/v1/status";
12
+
13
+ export const protobufPackage = "gateway.web.v1";
14
+
15
+ export const protobufFileName = "proto/gateway/web/v1/desktop_auth_gateway.proto";
16
+
17
+ export interface AuthorizeDesktopLoginRequest {
18
+ organizationId: string;
19
+ /** code_challenge is the base64url-encoded SHA-256 of the desktop's PKCE verifier. */
20
+ codeChallenge: string;
21
+ /** redirect_port is the loopback port the desktop is listening on. */
22
+ redirectPort: number;
23
+ label: string;
24
+ }
25
+
26
+ export interface AuthorizeDesktopLoginResponse {
27
+ status: ResponseStatus | undefined;
28
+ code: string;
29
+ expiresAt: Date | undefined;
30
+ }
31
+
32
+ export interface AuthorizeDesktopFreshSessionRequest {
33
+ /** code_challenge is the base64url-encoded SHA-256 of the desktop's PKCE verifier. */
34
+ codeChallenge: string;
35
+ /** redirect_port is the loopback port the desktop is listening on. */
36
+ redirectPort: number;
37
+ label: string;
38
+ }
39
+
40
+ export interface AuthorizeDesktopFreshSessionResponse {
41
+ status: ResponseStatus | undefined;
42
+ code: string;
43
+ expiresAt: Date | undefined;
44
+ }
45
+
46
+ function createBaseAuthorizeDesktopLoginRequest(): AuthorizeDesktopLoginRequest {
47
+ return { organizationId: "", codeChallenge: "", redirectPort: 0, label: "" };
48
+ }
49
+
50
+ export const AuthorizeDesktopLoginRequest: MessageFns<AuthorizeDesktopLoginRequest> = {
51
+ encode(message: AuthorizeDesktopLoginRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
52
+ if (message.organizationId !== "") {
53
+ writer.uint32(10).string(message.organizationId);
54
+ }
55
+ if (message.codeChallenge !== "") {
56
+ writer.uint32(18).string(message.codeChallenge);
57
+ }
58
+ if (message.redirectPort !== 0) {
59
+ writer.uint32(24).int32(message.redirectPort);
60
+ }
61
+ if (message.label !== "") {
62
+ writer.uint32(34).string(message.label);
63
+ }
64
+ return writer;
65
+ },
66
+
67
+ decode(input: BinaryReader | Uint8Array, length?: number): AuthorizeDesktopLoginRequest {
68
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
69
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
70
+ if (previousRecursionDepth >= 100) {
71
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
72
+ }
73
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
74
+ try {
75
+ const end = length === undefined ? reader.len : reader.pos + length;
76
+ const message = createBaseAuthorizeDesktopLoginRequest();
77
+ while (reader.pos < end) {
78
+ const tag = reader.uint32();
79
+ switch (tag >>> 3) {
80
+ case 1: {
81
+ if (tag !== 10) {
82
+ break;
83
+ }
84
+
85
+ message.organizationId = reader.string();
86
+ continue;
87
+ }
88
+ case 2: {
89
+ if (tag !== 18) {
90
+ break;
91
+ }
92
+
93
+ message.codeChallenge = reader.string();
94
+ continue;
95
+ }
96
+ case 3: {
97
+ if (tag !== 24) {
98
+ break;
99
+ }
100
+
101
+ message.redirectPort = reader.int32();
102
+ continue;
103
+ }
104
+ case 4: {
105
+ if (tag !== 34) {
106
+ break;
107
+ }
108
+
109
+ message.label = reader.string();
110
+ continue;
111
+ }
112
+ }
113
+ if ((tag & 7) === 4 || tag === 0) {
114
+ break;
115
+ }
116
+ reader.skip(tag & 7);
117
+ }
118
+ return message;
119
+ } finally {
120
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
121
+ }
122
+ },
123
+
124
+ fromJSON(object: any): AuthorizeDesktopLoginRequest {
125
+ return {
126
+ organizationId: isSet(object.organizationId)
127
+ ? globalThis.String(object.organizationId)
128
+ : isSet(object.organization_id)
129
+ ? globalThis.String(object.organization_id)
130
+ : "",
131
+ codeChallenge: isSet(object.codeChallenge)
132
+ ? globalThis.String(object.codeChallenge)
133
+ : isSet(object.code_challenge)
134
+ ? globalThis.String(object.code_challenge)
135
+ : "",
136
+ redirectPort: isSet(object.redirectPort)
137
+ ? globalThis.Number(object.redirectPort)
138
+ : isSet(object.redirect_port)
139
+ ? globalThis.Number(object.redirect_port)
140
+ : 0,
141
+ label: isSet(object.label) ? globalThis.String(object.label) : "",
142
+ };
143
+ },
144
+
145
+ toJSON(message: AuthorizeDesktopLoginRequest): unknown {
146
+ const obj: any = {};
147
+ if (message.organizationId !== "") {
148
+ obj.organizationId = message.organizationId;
149
+ }
150
+ if (message.codeChallenge !== "") {
151
+ obj.codeChallenge = message.codeChallenge;
152
+ }
153
+ if (message.redirectPort !== 0) {
154
+ obj.redirectPort = Math.round(message.redirectPort);
155
+ }
156
+ if (message.label !== "") {
157
+ obj.label = message.label;
158
+ }
159
+ return obj;
160
+ },
161
+
162
+ create<I extends Exact<DeepPartial<AuthorizeDesktopLoginRequest>, I>>(base?: I): AuthorizeDesktopLoginRequest {
163
+ return AuthorizeDesktopLoginRequest.fromPartial(base ?? ({} as any));
164
+ },
165
+ fromPartial<I extends Exact<DeepPartial<AuthorizeDesktopLoginRequest>, I>>(object: I): AuthorizeDesktopLoginRequest {
166
+ const message = createBaseAuthorizeDesktopLoginRequest();
167
+ message.organizationId = object.organizationId ?? "";
168
+ message.codeChallenge = object.codeChallenge ?? "";
169
+ message.redirectPort = object.redirectPort ?? 0;
170
+ message.label = object.label ?? "";
171
+ return message;
172
+ },
173
+ };
174
+
175
+ function createBaseAuthorizeDesktopLoginResponse(): AuthorizeDesktopLoginResponse {
176
+ return { status: undefined, code: "", expiresAt: undefined };
177
+ }
178
+
179
+ export const AuthorizeDesktopLoginResponse: MessageFns<AuthorizeDesktopLoginResponse> = {
180
+ encode(message: AuthorizeDesktopLoginResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
181
+ if (message.status !== undefined) {
182
+ ResponseStatus.encode(message.status, writer.uint32(10).fork()).join();
183
+ }
184
+ if (message.code !== "") {
185
+ writer.uint32(18).string(message.code);
186
+ }
187
+ if (message.expiresAt !== undefined) {
188
+ Timestamp.encode(toTimestamp(message.expiresAt), writer.uint32(26).fork()).join();
189
+ }
190
+ return writer;
191
+ },
192
+
193
+ decode(input: BinaryReader | Uint8Array, length?: number): AuthorizeDesktopLoginResponse {
194
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
195
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
196
+ if (previousRecursionDepth >= 100) {
197
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
198
+ }
199
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
200
+ try {
201
+ const end = length === undefined ? reader.len : reader.pos + length;
202
+ const message = createBaseAuthorizeDesktopLoginResponse();
203
+ while (reader.pos < end) {
204
+ const tag = reader.uint32();
205
+ switch (tag >>> 3) {
206
+ case 1: {
207
+ if (tag !== 10) {
208
+ break;
209
+ }
210
+
211
+ message.status = ResponseStatus.decode(reader, reader.uint32());
212
+ continue;
213
+ }
214
+ case 2: {
215
+ if (tag !== 18) {
216
+ break;
217
+ }
218
+
219
+ message.code = reader.string();
220
+ continue;
221
+ }
222
+ case 3: {
223
+ if (tag !== 26) {
224
+ break;
225
+ }
226
+
227
+ message.expiresAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
228
+ continue;
229
+ }
230
+ }
231
+ if ((tag & 7) === 4 || tag === 0) {
232
+ break;
233
+ }
234
+ reader.skip(tag & 7);
235
+ }
236
+ return message;
237
+ } finally {
238
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
239
+ }
240
+ },
241
+
242
+ fromJSON(object: any): AuthorizeDesktopLoginResponse {
243
+ return {
244
+ status: isSet(object.status) ? ResponseStatus.fromJSON(object.status) : undefined,
245
+ code: isSet(object.code) ? globalThis.String(object.code) : "",
246
+ expiresAt: isSet(object.expiresAt)
247
+ ? fromJsonTimestamp(object.expiresAt)
248
+ : isSet(object.expires_at)
249
+ ? fromJsonTimestamp(object.expires_at)
250
+ : undefined,
251
+ };
252
+ },
253
+
254
+ toJSON(message: AuthorizeDesktopLoginResponse): unknown {
255
+ const obj: any = {};
256
+ if (message.status !== undefined) {
257
+ obj.status = ResponseStatus.toJSON(message.status);
258
+ }
259
+ if (message.code !== "") {
260
+ obj.code = message.code;
261
+ }
262
+ if (message.expiresAt !== undefined) {
263
+ obj.expiresAt = message.expiresAt.toISOString();
264
+ }
265
+ return obj;
266
+ },
267
+
268
+ create<I extends Exact<DeepPartial<AuthorizeDesktopLoginResponse>, I>>(base?: I): AuthorizeDesktopLoginResponse {
269
+ return AuthorizeDesktopLoginResponse.fromPartial(base ?? ({} as any));
270
+ },
271
+ fromPartial<I extends Exact<DeepPartial<AuthorizeDesktopLoginResponse>, I>>(
272
+ object: I,
273
+ ): AuthorizeDesktopLoginResponse {
274
+ const message = createBaseAuthorizeDesktopLoginResponse();
275
+ message.status = (object.status !== undefined && object.status !== null)
276
+ ? ResponseStatus.fromPartial(object.status)
277
+ : undefined;
278
+ message.code = object.code ?? "";
279
+ message.expiresAt = object.expiresAt ?? undefined;
280
+ return message;
281
+ },
282
+ };
283
+
284
+ function createBaseAuthorizeDesktopFreshSessionRequest(): AuthorizeDesktopFreshSessionRequest {
285
+ return { codeChallenge: "", redirectPort: 0, label: "" };
286
+ }
287
+
288
+ export const AuthorizeDesktopFreshSessionRequest: MessageFns<AuthorizeDesktopFreshSessionRequest> = {
289
+ encode(message: AuthorizeDesktopFreshSessionRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
290
+ if (message.codeChallenge !== "") {
291
+ writer.uint32(10).string(message.codeChallenge);
292
+ }
293
+ if (message.redirectPort !== 0) {
294
+ writer.uint32(16).int32(message.redirectPort);
295
+ }
296
+ if (message.label !== "") {
297
+ writer.uint32(26).string(message.label);
298
+ }
299
+ return writer;
300
+ },
301
+
302
+ decode(input: BinaryReader | Uint8Array, length?: number): AuthorizeDesktopFreshSessionRequest {
303
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
304
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
305
+ if (previousRecursionDepth >= 100) {
306
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
307
+ }
308
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
309
+ try {
310
+ const end = length === undefined ? reader.len : reader.pos + length;
311
+ const message = createBaseAuthorizeDesktopFreshSessionRequest();
312
+ while (reader.pos < end) {
313
+ const tag = reader.uint32();
314
+ switch (tag >>> 3) {
315
+ case 1: {
316
+ if (tag !== 10) {
317
+ break;
318
+ }
319
+
320
+ message.codeChallenge = reader.string();
321
+ continue;
322
+ }
323
+ case 2: {
324
+ if (tag !== 16) {
325
+ break;
326
+ }
327
+
328
+ message.redirectPort = reader.int32();
329
+ continue;
330
+ }
331
+ case 3: {
332
+ if (tag !== 26) {
333
+ break;
334
+ }
335
+
336
+ message.label = reader.string();
337
+ continue;
338
+ }
339
+ }
340
+ if ((tag & 7) === 4 || tag === 0) {
341
+ break;
342
+ }
343
+ reader.skip(tag & 7);
344
+ }
345
+ return message;
346
+ } finally {
347
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
348
+ }
349
+ },
350
+
351
+ fromJSON(object: any): AuthorizeDesktopFreshSessionRequest {
352
+ return {
353
+ codeChallenge: isSet(object.codeChallenge)
354
+ ? globalThis.String(object.codeChallenge)
355
+ : isSet(object.code_challenge)
356
+ ? globalThis.String(object.code_challenge)
357
+ : "",
358
+ redirectPort: isSet(object.redirectPort)
359
+ ? globalThis.Number(object.redirectPort)
360
+ : isSet(object.redirect_port)
361
+ ? globalThis.Number(object.redirect_port)
362
+ : 0,
363
+ label: isSet(object.label) ? globalThis.String(object.label) : "",
364
+ };
365
+ },
366
+
367
+ toJSON(message: AuthorizeDesktopFreshSessionRequest): unknown {
368
+ const obj: any = {};
369
+ if (message.codeChallenge !== "") {
370
+ obj.codeChallenge = message.codeChallenge;
371
+ }
372
+ if (message.redirectPort !== 0) {
373
+ obj.redirectPort = Math.round(message.redirectPort);
374
+ }
375
+ if (message.label !== "") {
376
+ obj.label = message.label;
377
+ }
378
+ return obj;
379
+ },
380
+
381
+ create<I extends Exact<DeepPartial<AuthorizeDesktopFreshSessionRequest>, I>>(
382
+ base?: I,
383
+ ): AuthorizeDesktopFreshSessionRequest {
384
+ return AuthorizeDesktopFreshSessionRequest.fromPartial(base ?? ({} as any));
385
+ },
386
+ fromPartial<I extends Exact<DeepPartial<AuthorizeDesktopFreshSessionRequest>, I>>(
387
+ object: I,
388
+ ): AuthorizeDesktopFreshSessionRequest {
389
+ const message = createBaseAuthorizeDesktopFreshSessionRequest();
390
+ message.codeChallenge = object.codeChallenge ?? "";
391
+ message.redirectPort = object.redirectPort ?? 0;
392
+ message.label = object.label ?? "";
393
+ return message;
394
+ },
395
+ };
396
+
397
+ function createBaseAuthorizeDesktopFreshSessionResponse(): AuthorizeDesktopFreshSessionResponse {
398
+ return { status: undefined, code: "", expiresAt: undefined };
399
+ }
400
+
401
+ export const AuthorizeDesktopFreshSessionResponse: MessageFns<AuthorizeDesktopFreshSessionResponse> = {
402
+ encode(message: AuthorizeDesktopFreshSessionResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
403
+ if (message.status !== undefined) {
404
+ ResponseStatus.encode(message.status, writer.uint32(10).fork()).join();
405
+ }
406
+ if (message.code !== "") {
407
+ writer.uint32(18).string(message.code);
408
+ }
409
+ if (message.expiresAt !== undefined) {
410
+ Timestamp.encode(toTimestamp(message.expiresAt), writer.uint32(26).fork()).join();
411
+ }
412
+ return writer;
413
+ },
414
+
415
+ decode(input: BinaryReader | Uint8Array, length?: number): AuthorizeDesktopFreshSessionResponse {
416
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
417
+ const previousRecursionDepth = (reader as any).__tsProtoDecodeDepth ?? 0;
418
+ if (previousRecursionDepth >= 100) {
419
+ throw new globalThis.Error("protobuf decode recursion limit exceeded");
420
+ }
421
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth + 1;
422
+ try {
423
+ const end = length === undefined ? reader.len : reader.pos + length;
424
+ const message = createBaseAuthorizeDesktopFreshSessionResponse();
425
+ while (reader.pos < end) {
426
+ const tag = reader.uint32();
427
+ switch (tag >>> 3) {
428
+ case 1: {
429
+ if (tag !== 10) {
430
+ break;
431
+ }
432
+
433
+ message.status = ResponseStatus.decode(reader, reader.uint32());
434
+ continue;
435
+ }
436
+ case 2: {
437
+ if (tag !== 18) {
438
+ break;
439
+ }
440
+
441
+ message.code = reader.string();
442
+ continue;
443
+ }
444
+ case 3: {
445
+ if (tag !== 26) {
446
+ break;
447
+ }
448
+
449
+ message.expiresAt = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
450
+ continue;
451
+ }
452
+ }
453
+ if ((tag & 7) === 4 || tag === 0) {
454
+ break;
455
+ }
456
+ reader.skip(tag & 7);
457
+ }
458
+ return message;
459
+ } finally {
460
+ (reader as any).__tsProtoDecodeDepth = previousRecursionDepth;
461
+ }
462
+ },
463
+
464
+ fromJSON(object: any): AuthorizeDesktopFreshSessionResponse {
465
+ return {
466
+ status: isSet(object.status) ? ResponseStatus.fromJSON(object.status) : undefined,
467
+ code: isSet(object.code) ? globalThis.String(object.code) : "",
468
+ expiresAt: isSet(object.expiresAt)
469
+ ? fromJsonTimestamp(object.expiresAt)
470
+ : isSet(object.expires_at)
471
+ ? fromJsonTimestamp(object.expires_at)
472
+ : undefined,
473
+ };
474
+ },
475
+
476
+ toJSON(message: AuthorizeDesktopFreshSessionResponse): unknown {
477
+ const obj: any = {};
478
+ if (message.status !== undefined) {
479
+ obj.status = ResponseStatus.toJSON(message.status);
480
+ }
481
+ if (message.code !== "") {
482
+ obj.code = message.code;
483
+ }
484
+ if (message.expiresAt !== undefined) {
485
+ obj.expiresAt = message.expiresAt.toISOString();
486
+ }
487
+ return obj;
488
+ },
489
+
490
+ create<I extends Exact<DeepPartial<AuthorizeDesktopFreshSessionResponse>, I>>(
491
+ base?: I,
492
+ ): AuthorizeDesktopFreshSessionResponse {
493
+ return AuthorizeDesktopFreshSessionResponse.fromPartial(base ?? ({} as any));
494
+ },
495
+ fromPartial<I extends Exact<DeepPartial<AuthorizeDesktopFreshSessionResponse>, I>>(
496
+ object: I,
497
+ ): AuthorizeDesktopFreshSessionResponse {
498
+ const message = createBaseAuthorizeDesktopFreshSessionResponse();
499
+ message.status = (object.status !== undefined && object.status !== null)
500
+ ? ResponseStatus.fromPartial(object.status)
501
+ : undefined;
502
+ message.code = object.code ?? "";
503
+ message.expiresAt = object.expiresAt ?? undefined;
504
+ return message;
505
+ },
506
+ };
507
+
508
+ /**
509
+ * DesktopAuthGatewayService is the desktop's approval page. A refusal is a non-success status whose reason clients
510
+ * branch on (status.reason); the message is for people.
511
+ */
512
+ export interface DesktopAuthGatewayService {
513
+ /**
514
+ * AuthorizeDesktopLogin is the click, for any organization the caller belongs to. A caller who is not an active member,
515
+ * or whose organization is suspended, is denied: VALIDATION_ERROR with reason ORG_NOT_ACCESSIBLE, or with no reason
516
+ * when the gateway's own organization check refuses first.
517
+ */
518
+ AuthorizeDesktopLogin(
519
+ request: AuthorizeDesktopLoginRequest,
520
+ metadata?: Metadata,
521
+ ): Promise<AuthorizeDesktopLoginResponse>;
522
+ /**
523
+ * AuthorizeDesktopFreshSession is the clickless approval right after a sign-in in the desktop's window, for the
524
+ * caller's PERSONAL organization, which the server resolves, and a Clerk session under five minutes old, taken from
525
+ * the verified token and never from the request. Refusals: VALIDATION_ERROR with reason PERSONAL_ORG_REQUIRED or
526
+ * CONSENT_REQUIRED (show the click), or PERMISSION_DENIED or ORG_NOT_ACCESSIBLE (denied, no click).
527
+ */
528
+ AuthorizeDesktopFreshSession(
529
+ request: AuthorizeDesktopFreshSessionRequest,
530
+ metadata?: Metadata,
531
+ ): Promise<AuthorizeDesktopFreshSessionResponse>;
532
+ }
533
+
534
+ export const DesktopAuthGatewayServiceServiceName = "gateway.web.v1.DesktopAuthGatewayService";
535
+ export class DesktopAuthGatewayServiceClientImpl implements DesktopAuthGatewayService {
536
+ private readonly rpc: Rpc;
537
+ private readonly service: string;
538
+ constructor(rpc: Rpc, opts?: { service?: string }) {
539
+ this.service = opts?.service || DesktopAuthGatewayServiceServiceName;
540
+ this.rpc = rpc;
541
+ this.AuthorizeDesktopLogin = this.AuthorizeDesktopLogin.bind(this);
542
+ this.AuthorizeDesktopFreshSession = this.AuthorizeDesktopFreshSession.bind(this);
543
+ }
544
+ AuthorizeDesktopLogin(
545
+ request: AuthorizeDesktopLoginRequest,
546
+ metadata?: Metadata,
547
+ ): Promise<AuthorizeDesktopLoginResponse> {
548
+ const data = AuthorizeDesktopLoginRequest.encode(request).finish();
549
+ const promise = this.rpc.request(this.service, "AuthorizeDesktopLogin", data, metadata);
550
+ return promise.then((data) => AuthorizeDesktopLoginResponse.decode(new BinaryReader(data)));
551
+ }
552
+
553
+ AuthorizeDesktopFreshSession(
554
+ request: AuthorizeDesktopFreshSessionRequest,
555
+ metadata?: Metadata,
556
+ ): Promise<AuthorizeDesktopFreshSessionResponse> {
557
+ const data = AuthorizeDesktopFreshSessionRequest.encode(request).finish();
558
+ const promise = this.rpc.request(this.service, "AuthorizeDesktopFreshSession", data, metadata);
559
+ return promise.then((data) => AuthorizeDesktopFreshSessionResponse.decode(new BinaryReader(data)));
560
+ }
561
+ }
562
+
563
+ interface Rpc {
564
+ request(service: string, method: string, data: Uint8Array, metadata?: Metadata): Promise<Uint8Array>;
565
+ }
566
+
567
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
568
+
569
+ export type DeepPartial<T> = T extends Builtin ? T
570
+ : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
571
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
572
+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
573
+ : Partial<T>;
574
+
575
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
576
+ export type Exact<P, I> = P extends Builtin ? P
577
+ :
578
+ & P
579
+ & { [K in keyof P as Extract<K, keyof I>]: Exact<P[K], I[K & keyof I]> }
580
+ & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
581
+
582
+ function toTimestamp(date: Date): Timestamp {
583
+ const seconds = Math.trunc(date.getTime() / 1_000);
584
+ const nanos = (date.getTime() % 1_000) * 1_000_000;
585
+ return { seconds, nanos };
586
+ }
587
+
588
+ function fromTimestamp(t: Timestamp): Date {
589
+ let millis = (t.seconds || 0) * 1_000;
590
+ millis += (t.nanos || 0) / 1_000_000;
591
+ return new globalThis.Date(millis);
592
+ }
593
+
594
+ function fromJsonTimestamp(o: any): Date {
595
+ if (o instanceof globalThis.Date) {
596
+ return o;
597
+ } else if (typeof o === "string") {
598
+ return new globalThis.Date(o);
599
+ } else {
600
+ return fromTimestamp(Timestamp.fromJSON(o));
601
+ }
602
+ }
603
+
604
+ function isSet(value: any): boolean {
605
+ return value !== null && value !== undefined;
606
+ }
607
+
608
+ export interface MessageFns<T> {
609
+ encode(message: T, writer?: BinaryWriter): BinaryWriter;
610
+ decode(input: BinaryReader | Uint8Array, length?: number): T;
611
+ fromJSON(object: any): T;
612
+ toJSON(message: T): unknown;
613
+ create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
614
+ fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
615
+ }