@dtelecom/livekit-client 1.12.4 → 1.12.6

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 (159) hide show
  1. package/README.md +3 -39
  2. package/dist/livekit-client.e2ee.worker.js +1 -1
  3. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  4. package/dist/livekit-client.e2ee.worker.mjs +301 -389
  5. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  6. package/dist/livekit-client.esm.mjs +15291 -13060
  7. package/dist/livekit-client.esm.mjs.map +1 -1
  8. package/dist/livekit-client.umd.js +1 -1
  9. package/dist/livekit-client.umd.js.map +1 -1
  10. package/dist/src/api/SignalClient.d.ts +2 -2
  11. package/dist/src/api/SignalClient.d.ts.map +1 -1
  12. package/dist/src/connectionHelper/ConnectionCheck.d.ts +2 -3
  13. package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -1
  14. package/dist/src/connectionHelper/checks/Checker.d.ts +2 -3
  15. package/dist/src/connectionHelper/checks/Checker.d.ts.map +1 -1
  16. package/dist/src/connectionHelper/checks/webrtc.d.ts.map +1 -1
  17. package/dist/src/connectionHelper/checks/websocket.d.ts.map +1 -1
  18. package/dist/src/e2ee/E2eeManager.d.ts +2 -4
  19. package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
  20. package/dist/src/e2ee/KeyProvider.d.ts +2 -4
  21. package/dist/src/e2ee/KeyProvider.d.ts.map +1 -1
  22. package/dist/src/e2ee/constants.d.ts +0 -1
  23. package/dist/src/e2ee/constants.d.ts.map +1 -1
  24. package/dist/src/e2ee/types.d.ts +0 -1
  25. package/dist/src/e2ee/types.d.ts.map +1 -1
  26. package/dist/src/e2ee/worker/FrameCryptor.d.ts +2 -4
  27. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  28. package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts +3 -14
  29. package/dist/src/e2ee/worker/ParticipantKeyHandler.d.ts.map +1 -1
  30. package/dist/src/index.d.ts +1 -1
  31. package/dist/src/index.d.ts.map +1 -1
  32. package/dist/src/proto/google/protobuf/timestamp.d.ts +146 -0
  33. package/dist/src/proto/google/protobuf/timestamp.d.ts.map +1 -0
  34. package/dist/src/proto/livekit_models.d.ts +2399 -0
  35. package/dist/src/proto/livekit_models.d.ts.map +1 -0
  36. package/dist/src/proto/livekit_rtc.d.ts +14352 -0
  37. package/dist/src/proto/livekit_rtc.d.ts.map +1 -0
  38. package/dist/src/room/PCTransport.d.ts +1 -2
  39. package/dist/src/room/PCTransport.d.ts.map +1 -1
  40. package/dist/src/room/RTCEngine.d.ts +5 -9
  41. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  42. package/dist/src/room/RegionUrlProvider.d.ts +1 -4
  43. package/dist/src/room/RegionUrlProvider.d.ts.map +1 -1
  44. package/dist/src/room/Room.d.ts +11 -15
  45. package/dist/src/room/Room.d.ts.map +1 -1
  46. package/dist/src/room/participant/LocalParticipant.d.ts +2 -2
  47. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  48. package/dist/src/room/participant/Participant.d.ts +3 -5
  49. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  50. package/dist/src/room/participant/ParticipantTrackPermission.d.ts +1 -1
  51. package/dist/src/room/participant/ParticipantTrackPermission.d.ts.map +1 -1
  52. package/dist/src/room/participant/RemoteParticipant.d.ts +3 -2
  53. package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
  54. package/dist/src/room/timers.d.ts +4 -5
  55. package/dist/src/room/timers.d.ts.map +1 -1
  56. package/dist/src/room/track/LocalTrackPublication.d.ts +1 -1
  57. package/dist/src/room/track/LocalTrackPublication.d.ts.map +1 -1
  58. package/dist/src/room/track/LocalVideoTrack.d.ts +2 -2
  59. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  60. package/dist/src/room/track/RemoteTrackPublication.d.ts +1 -1
  61. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  62. package/dist/src/room/track/Track.d.ts +4 -6
  63. package/dist/src/room/track/Track.d.ts.map +1 -1
  64. package/dist/src/room/track/TrackPublication.d.ts +5 -7
  65. package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
  66. package/dist/src/room/track/create.d.ts.map +1 -1
  67. package/dist/src/room/track/options.d.ts +0 -7
  68. package/dist/src/room/track/options.d.ts.map +1 -1
  69. package/dist/src/room/track/utils.d.ts +1 -5
  70. package/dist/src/room/track/utils.d.ts.map +1 -1
  71. package/dist/src/room/utils.d.ts +1 -3
  72. package/dist/src/room/utils.d.ts.map +1 -1
  73. package/dist/src/test/mocks.d.ts +4 -4
  74. package/dist/src/test/mocks.d.ts.map +1 -1
  75. package/dist/ts4.2/src/api/SignalClient.d.ts +2 -2
  76. package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +2 -3
  77. package/dist/ts4.2/src/connectionHelper/checks/Checker.d.ts +2 -3
  78. package/dist/ts4.2/src/e2ee/E2eeManager.d.ts +2 -4
  79. package/dist/ts4.2/src/e2ee/KeyProvider.d.ts +2 -4
  80. package/dist/ts4.2/src/e2ee/constants.d.ts +0 -1
  81. package/dist/ts4.2/src/e2ee/types.d.ts +0 -1
  82. package/dist/ts4.2/src/e2ee/worker/FrameCryptor.d.ts +2 -4
  83. package/dist/ts4.2/src/e2ee/worker/ParticipantKeyHandler.d.ts +3 -14
  84. package/dist/ts4.2/src/index.d.ts +1 -1
  85. package/dist/ts4.2/src/proto/google/protobuf/timestamp.d.ts +150 -0
  86. package/dist/ts4.2/src/proto/livekit_models.d.ts +2659 -0
  87. package/dist/ts4.2/src/proto/livekit_rtc.d.ts +15764 -0
  88. package/dist/ts4.2/src/room/PCTransport.d.ts +1 -2
  89. package/dist/ts4.2/src/room/RTCEngine.d.ts +5 -9
  90. package/dist/ts4.2/src/room/RegionUrlProvider.d.ts +1 -4
  91. package/dist/ts4.2/src/room/Room.d.ts +11 -15
  92. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +2 -2
  93. package/dist/ts4.2/src/room/participant/Participant.d.ts +3 -5
  94. package/dist/ts4.2/src/room/participant/ParticipantTrackPermission.d.ts +1 -1
  95. package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +3 -2
  96. package/dist/ts4.2/src/room/timers.d.ts +4 -5
  97. package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +1 -1
  98. package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +2 -2
  99. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +1 -1
  100. package/dist/ts4.2/src/room/track/Track.d.ts +4 -6
  101. package/dist/ts4.2/src/room/track/TrackPublication.d.ts +5 -7
  102. package/dist/ts4.2/src/room/track/options.d.ts +0 -7
  103. package/dist/ts4.2/src/room/track/utils.d.ts +1 -5
  104. package/dist/ts4.2/src/room/utils.d.ts +1 -3
  105. package/dist/ts4.2/src/test/mocks.d.ts +4 -4
  106. package/package.json +11 -11
  107. package/src/api/SignalClient.ts +101 -104
  108. package/src/connectionHelper/ConnectionCheck.ts +2 -3
  109. package/src/connectionHelper/checks/Checker.ts +3 -3
  110. package/src/connectionHelper/checks/webrtc.ts +2 -66
  111. package/src/connectionHelper/checks/websocket.ts +0 -4
  112. package/src/e2ee/E2eeManager.ts +3 -4
  113. package/src/e2ee/KeyProvider.ts +2 -3
  114. package/src/e2ee/constants.ts +0 -4
  115. package/src/e2ee/types.ts +0 -1
  116. package/src/e2ee/worker/FrameCryptor.test.ts +3 -1
  117. package/src/e2ee/worker/FrameCryptor.ts +5 -5
  118. package/src/e2ee/worker/ParticipantKeyHandler.ts +6 -37
  119. package/src/e2ee/worker/e2ee.worker.ts +1 -1
  120. package/src/index.ts +1 -1
  121. package/src/proto/google/protobuf/timestamp.ts +230 -0
  122. package/src/proto/livekit_models.ts +4006 -0
  123. package/src/proto/livekit_rtc.ts +4672 -0
  124. package/src/room/PCTransport.ts +1 -1
  125. package/src/room/RTCEngine.ts +18 -24
  126. package/src/room/RegionUrlProvider.ts +2 -11
  127. package/src/room/Room.test.ts +0 -1
  128. package/src/room/Room.ts +79 -158
  129. package/src/room/participant/LocalParticipant.ts +59 -43
  130. package/src/room/participant/Participant.ts +4 -6
  131. package/src/room/participant/ParticipantTrackPermission.ts +3 -3
  132. package/src/room/participant/RemoteParticipant.ts +6 -5
  133. package/src/room/participant/publishUtils.test.ts +0 -1
  134. package/src/room/track/LocalTrackPublication.ts +1 -1
  135. package/src/room/track/LocalVideoTrack.test.ts +1 -2
  136. package/src/room/track/LocalVideoTrack.ts +22 -22
  137. package/src/room/track/RemoteTrackPublication.ts +7 -12
  138. package/src/room/track/RemoteVideoTrack.test.ts +4 -5
  139. package/src/room/track/Track.ts +6 -9
  140. package/src/room/track/TrackPublication.ts +5 -7
  141. package/src/room/track/create.ts +17 -9
  142. package/src/room/track/facingMode.test.ts +0 -1
  143. package/src/room/track/options.ts +0 -6
  144. package/src/room/track/utils.test.ts +0 -1
  145. package/src/room/track/utils.ts +2 -44
  146. package/src/room/utils.ts +4 -20
  147. package/src/test/mocks.ts +5 -7
  148. package/src/utils/AsyncQueue.test.ts +0 -1
  149. package/src/utils/browserParser.test.ts +3 -33
  150. package/src/utils/browserParser.ts +1 -1
  151. package/dist/src/proto/livekit_models_pb.d.ts +0 -1264
  152. package/dist/src/proto/livekit_models_pb.d.ts.map +0 -1
  153. package/dist/src/proto/livekit_rtc_pb.d.ts +0 -1373
  154. package/dist/src/proto/livekit_rtc_pb.d.ts.map +0 -1
  155. package/dist/ts4.2/src/proto/livekit_models_pb.d.ts +0 -1264
  156. package/dist/ts4.2/src/proto/livekit_rtc_pb.d.ts +0 -1373
  157. package/src/proto/livekit_models_pb.ts +0 -2096
  158. package/src/proto/livekit_rtc_pb.ts +0 -2332
  159. package/src/room/utils.test.ts +0 -16
@@ -1,7 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-unused-vars */
2
2
  // TODO code inspired by https://github.com/webrtc/samples/blob/gh-pages/src/content/insertable-streams/endtoend-encryption/js/worker.js
3
- import { EventEmitter } from 'events';
4
- import type TypedEventEmitter from 'typed-emitter';
3
+ import EventEmitter from 'eventemitter3';
5
4
  import { workerLogger } from '../../logger';
6
5
  import type { VideoCodec } from '../../room/track/options';
7
6
  import { ENCRYPTION_ALGORITHM, IV_LENGTH, UNENCRYPTED_BYTES } from '../constants';
@@ -27,7 +26,7 @@ export interface TransformerInfo {
27
26
  abortController: AbortController;
28
27
  }
29
28
 
30
- export class BaseFrameCryptor extends (EventEmitter as new () => TypedEventEmitter<CryptorCallbacks>) {
29
+ export class BaseFrameCryptor extends EventEmitter<CryptorCallbacks> {
31
30
  encodeFunction(
32
31
  encodedFrame: RTCEncodedVideoFrame | RTCEncodedAudioFrame,
33
32
  controller: TransformStreamDefaultController,
@@ -272,7 +271,6 @@ export class FrameCryptor extends BaseFrameCryptor {
272
271
  if (this.keys.getKeySet(keyIndex) && this.keys.hasValidKey) {
273
272
  try {
274
273
  const decodedFrame = await this.decryptFrame(encodedFrame, keyIndex);
275
- this.keys.decryptionSuccess();
276
274
  if (decodedFrame) {
277
275
  return controller.enqueue(decodedFrame);
278
276
  }
@@ -287,7 +285,7 @@ export class FrameCryptor extends BaseFrameCryptor {
287
285
  CryptorErrorReason.InvalidKey,
288
286
  ),
289
287
  );
290
- this.keys.decryptionFailure();
288
+ this.keys.hasValidKey = false;
291
289
  }
292
290
  } else {
293
291
  workerLogger.warn('decoding frame failed', { error });
@@ -397,6 +395,8 @@ export class FrameCryptor extends BaseFrameCryptor {
397
395
  this.keys.setKeyFromMaterial(initialMaterial.material, keyIndex);
398
396
  }
399
397
 
398
+ this.keys.hasValidKey = false;
399
+
400
400
  workerLogger.warn('maximum ratchet attempts exceeded, resetting key');
401
401
  this.emit(
402
402
  CryptorEvent.Error,
@@ -1,5 +1,4 @@
1
- import { EventEmitter } from 'events';
2
- import type TypedEventEmitter from 'typed-emitter';
1
+ import EventEmitter from 'eventemitter3';
3
2
  import { workerLogger } from '../../logger';
4
3
  import { KEYRING_SIZE } from '../constants';
5
4
  import type { KeyProviderOptions, KeySet, ParticipantKeyHandlerCallbacks } from '../types';
@@ -16,7 +15,7 @@ import { deriveKeys, importKey, ratchet } from '../utils';
16
15
  * if decryption fails or can be triggered manually on both sender and receiver side.
17
16
  *
18
17
  */
19
- export class ParticipantKeyHandler extends (EventEmitter as new () => TypedEventEmitter<ParticipantKeyHandlerCallbacks>) {
18
+ export class ParticipantKeyHandler extends EventEmitter<ParticipantKeyHandlerCallbacks> {
20
19
  private currentKeyIndex: number;
21
20
 
22
21
  private cryptoKeyRing: Array<KeySet>;
@@ -29,13 +28,7 @@ export class ParticipantKeyHandler extends (EventEmitter as new () => TypedEvent
29
28
 
30
29
  private participantId: string | undefined;
31
30
 
32
- private decryptionFailureCount = 0;
33
-
34
- private _hasValidKey: boolean = true;
35
-
36
- get hasValidKey() {
37
- return this._hasValidKey;
38
- }
31
+ hasValidKey: boolean;
39
32
 
40
33
  constructor(
41
34
  participantId: string | undefined,
@@ -49,37 +42,13 @@ export class ParticipantKeyHandler extends (EventEmitter as new () => TypedEvent
49
42
  this.keyProviderOptions = keyProviderOptions;
50
43
  this.ratchetPromiseMap = new Map();
51
44
  this.participantId = participantId;
52
- this.resetKeyStatus();
45
+ this.hasValidKey = false;
53
46
  }
54
47
 
55
48
  setEnabled(enabled: boolean) {
56
49
  this.enabled = enabled;
57
50
  }
58
51
 
59
- decryptionFailure() {
60
- if (this.keyProviderOptions.failureTolerance < 0) {
61
- return;
62
- }
63
- this.decryptionFailureCount += 1;
64
-
65
- if (this.decryptionFailureCount > this.keyProviderOptions.failureTolerance) {
66
- this._hasValidKey = false;
67
- }
68
- }
69
-
70
- decryptionSuccess() {
71
- this.resetKeyStatus();
72
- }
73
-
74
- /**
75
- * Call this after user initiated ratchet or a new key has been set in order to make sure to mark potentially
76
- * invalid keys as valid again
77
- */
78
- resetKeyStatus() {
79
- this.decryptionFailureCount = 0;
80
- this._hasValidKey = true;
81
- }
82
-
83
52
  /**
84
53
  * Ratchets the current key (or the one at keyIndex if provided) and
85
54
  * returns the ratcheted material
@@ -126,7 +95,7 @@ export class ParticipantKeyHandler extends (EventEmitter as new () => TypedEvent
126
95
  */
127
96
  async setKey(material: CryptoKey, keyIndex = 0) {
128
97
  await this.setKeyFromMaterial(material, keyIndex);
129
- this.resetKeyStatus();
98
+ this.hasValidKey = true;
130
99
  }
131
100
 
132
101
  /**
@@ -153,7 +122,7 @@ export class ParticipantKeyHandler extends (EventEmitter as new () => TypedEvent
153
122
 
154
123
  async setCurrentKeyIndex(index: number) {
155
124
  this.currentKeyIndex = index % this.cryptoKeyRing.length;
156
- this.resetKeyStatus();
125
+ this.hasValidKey = true;
157
126
  }
158
127
 
159
128
  isEnabled() {
@@ -102,7 +102,7 @@ onmessage = (ev) => {
102
102
  async function handleRatchetRequest(data: RatchetRequestMessage['data']) {
103
103
  const keyHandler = getParticipantKeyHandler(data.participantId);
104
104
  await keyHandler.ratchetKey(data.keyIndex);
105
- keyHandler.resetKeyStatus();
105
+ keyHandler.hasValidKey = true;
106
106
  }
107
107
 
108
108
  function getTrackCryptor(participantId: string, trackId: string) {
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { LogLevel, setLogExtension, setLogLevel } from './logger';
2
- import { DataPacket_Kind, DisconnectReason, VideoQuality } from './proto/livekit_models_pb';
2
+ import { DataPacket_Kind, DisconnectReason, VideoQuality } from './proto/livekit_models';
3
3
  import DefaultReconnectPolicy from './room/DefaultReconnectPolicy';
4
4
  import Room, { ConnectionState, RoomState } from './room/Room';
5
5
  import LocalParticipant from './room/participant/LocalParticipant';
@@ -0,0 +1,230 @@
1
+ /* eslint-disable */
2
+ import Long from "long";
3
+ import _m0 from "protobufjs/minimal";
4
+
5
+ export const protobufPackage = "google.protobuf";
6
+
7
+ /**
8
+ * A Timestamp represents a point in time independent of any time zone or local
9
+ * calendar, encoded as a count of seconds and fractions of seconds at
10
+ * nanosecond resolution. The count is relative to an epoch at UTC midnight on
11
+ * January 1, 1970, in the proleptic Gregorian calendar which extends the
12
+ * Gregorian calendar backwards to year one.
13
+ *
14
+ * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
15
+ * second table is needed for interpretation, using a [24-hour linear
16
+ * smear](https://developers.google.com/time/smear).
17
+ *
18
+ * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
19
+ * restricting to that range, we ensure that we can convert to and from [RFC
20
+ * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
21
+ *
22
+ * # Examples
23
+ *
24
+ * Example 1: Compute Timestamp from POSIX `time()`.
25
+ *
26
+ * Timestamp timestamp;
27
+ * timestamp.set_seconds(time(NULL));
28
+ * timestamp.set_nanos(0);
29
+ *
30
+ * Example 2: Compute Timestamp from POSIX `gettimeofday()`.
31
+ *
32
+ * struct timeval tv;
33
+ * gettimeofday(&tv, NULL);
34
+ *
35
+ * Timestamp timestamp;
36
+ * timestamp.set_seconds(tv.tv_sec);
37
+ * timestamp.set_nanos(tv.tv_usec * 1000);
38
+ *
39
+ * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
40
+ *
41
+ * FILETIME ft;
42
+ * GetSystemTimeAsFileTime(&ft);
43
+ * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
44
+ *
45
+ * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
46
+ * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
47
+ * Timestamp timestamp;
48
+ * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
49
+ * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
50
+ *
51
+ * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
52
+ *
53
+ * long millis = System.currentTimeMillis();
54
+ *
55
+ * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
56
+ * .setNanos((int) ((millis % 1000) * 1000000)).build();
57
+ *
58
+ * Example 5: Compute Timestamp from Java `Instant.now()`.
59
+ *
60
+ * Instant now = Instant.now();
61
+ *
62
+ * Timestamp timestamp =
63
+ * Timestamp.newBuilder().setSeconds(now.getEpochSecond())
64
+ * .setNanos(now.getNano()).build();
65
+ *
66
+ * Example 6: Compute Timestamp from current time in Python.
67
+ *
68
+ * timestamp = Timestamp()
69
+ * timestamp.GetCurrentTime()
70
+ *
71
+ * # JSON Mapping
72
+ *
73
+ * In JSON format, the Timestamp type is encoded as a string in the
74
+ * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
75
+ * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
76
+ * where {year} is always expressed using four digits while {month}, {day},
77
+ * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
78
+ * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
79
+ * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
80
+ * is required. A proto3 JSON serializer should always use UTC (as indicated by
81
+ * "Z") when printing the Timestamp type and a proto3 JSON parser should be
82
+ * able to accept both UTC and other timezones (as indicated by an offset).
83
+ *
84
+ * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
85
+ * 01:30 UTC on January 15, 2017.
86
+ *
87
+ * In JavaScript, one can convert a Date object to this format using the
88
+ * standard
89
+ * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
90
+ * method. In Python, a standard `datetime.datetime` object can be converted
91
+ * to this format using
92
+ * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
93
+ * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
94
+ * the Joda Time's [`ISODateTimeFormat.dateTime()`](
95
+ * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
96
+ * ) to obtain a formatter capable of generating timestamps in this format.
97
+ */
98
+ export interface Timestamp {
99
+ /**
100
+ * Represents seconds of UTC time since Unix epoch
101
+ * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
102
+ * 9999-12-31T23:59:59Z inclusive.
103
+ */
104
+ seconds: number;
105
+ /**
106
+ * Non-negative fractions of a second at nanosecond resolution. Negative
107
+ * second values with fractions must still have non-negative nanos values
108
+ * that count forward in time. Must be from 0 to 999,999,999
109
+ * inclusive.
110
+ */
111
+ nanos: number;
112
+ }
113
+
114
+ function createBaseTimestamp(): Timestamp {
115
+ return { seconds: 0, nanos: 0 };
116
+ }
117
+
118
+ export const Timestamp = {
119
+ encode(message: Timestamp, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
120
+ if (message.seconds !== 0) {
121
+ writer.uint32(8).int64(message.seconds);
122
+ }
123
+ if (message.nanos !== 0) {
124
+ writer.uint32(16).int32(message.nanos);
125
+ }
126
+ return writer;
127
+ },
128
+
129
+ decode(input: _m0.Reader | Uint8Array, length?: number): Timestamp {
130
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
131
+ let end = length === undefined ? reader.len : reader.pos + length;
132
+ const message = createBaseTimestamp();
133
+ while (reader.pos < end) {
134
+ const tag = reader.uint32();
135
+ switch (tag >>> 3) {
136
+ case 1:
137
+ if (tag !== 8) {
138
+ break;
139
+ }
140
+
141
+ message.seconds = longToNumber(reader.int64() as Long);
142
+ continue;
143
+ case 2:
144
+ if (tag !== 16) {
145
+ break;
146
+ }
147
+
148
+ message.nanos = reader.int32();
149
+ continue;
150
+ }
151
+ if ((tag & 7) === 4 || tag === 0) {
152
+ break;
153
+ }
154
+ reader.skipType(tag & 7);
155
+ }
156
+ return message;
157
+ },
158
+
159
+ fromJSON(object: any): Timestamp {
160
+ return {
161
+ seconds: isSet(object.seconds) ? Number(object.seconds) : 0,
162
+ nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
163
+ };
164
+ },
165
+
166
+ toJSON(message: Timestamp): unknown {
167
+ const obj: any = {};
168
+ message.seconds !== undefined && (obj.seconds = Math.round(message.seconds));
169
+ message.nanos !== undefined && (obj.nanos = Math.round(message.nanos));
170
+ return obj;
171
+ },
172
+
173
+ create<I extends Exact<DeepPartial<Timestamp>, I>>(base?: I): Timestamp {
174
+ return Timestamp.fromPartial(base ?? {});
175
+ },
176
+
177
+ fromPartial<I extends Exact<DeepPartial<Timestamp>, I>>(object: I): Timestamp {
178
+ const message = createBaseTimestamp();
179
+ message.seconds = object.seconds ?? 0;
180
+ message.nanos = object.nanos ?? 0;
181
+ return message;
182
+ },
183
+ };
184
+
185
+ declare var self: any | undefined;
186
+ declare var window: any | undefined;
187
+ declare var global: any | undefined;
188
+ var tsProtoGlobalThis: any = (() => {
189
+ if (typeof globalThis !== "undefined") {
190
+ return globalThis;
191
+ }
192
+ if (typeof self !== "undefined") {
193
+ return self;
194
+ }
195
+ if (typeof window !== "undefined") {
196
+ return window;
197
+ }
198
+ if (typeof global !== "undefined") {
199
+ return global;
200
+ }
201
+ throw "Unable to locate global object";
202
+ })();
203
+
204
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
205
+
206
+ export type DeepPartial<T> = T extends Builtin ? T
207
+ : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
208
+ : T extends { $case: string } ? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { $case: T["$case"] }
209
+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
210
+ : Partial<T>;
211
+
212
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
213
+ export type Exact<P, I extends P> = P extends Builtin ? P
214
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
215
+
216
+ function longToNumber(long: Long): number {
217
+ if (long.gt(Number.MAX_SAFE_INTEGER)) {
218
+ throw new tsProtoGlobalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
219
+ }
220
+ return long.toNumber();
221
+ }
222
+
223
+ if (_m0.util.Long !== Long) {
224
+ _m0.util.Long = Long as any;
225
+ _m0.configure();
226
+ }
227
+
228
+ function isSet(value: any): boolean {
229
+ return value !== null && value !== undefined;
230
+ }