livekit-server-sdk 1.1.2 → 1.1.3
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 +1 -1
- package/dist/AccessToken.d.ts +0 -56
- package/dist/AccessToken.js +0 -118
- package/dist/AccessToken.js.map +0 -1
- package/dist/AccessToken.test.d.ts +0 -1
- package/dist/AccessToken.test.js +0 -72
- package/dist/AccessToken.test.js.map +0 -1
- package/dist/EgressClient.d.ts +0 -128
- package/dist/EgressClient.js +0 -263
- package/dist/EgressClient.js.map +0 -1
- package/dist/IngressClient.d.ts +0 -84
- package/dist/IngressClient.js +0 -112
- package/dist/IngressClient.js.map +0 -1
- package/dist/RoomServiceClient.d.ts +0 -132
- package/dist/RoomServiceClient.js +0 -189
- package/dist/RoomServiceClient.js.map +0 -1
- package/dist/ServiceBase.d.ts +0 -16
- package/dist/ServiceBase.js +0 -27
- package/dist/ServiceBase.js.map +0 -1
- package/dist/TwirpRPC.d.ts +0 -16
- package/dist/TwirpRPC.js +0 -37
- package/dist/TwirpRPC.js.map +0 -1
- package/dist/WebhookReceiver.d.ts +0 -14
- package/dist/WebhookReceiver.js +0 -40
- package/dist/WebhookReceiver.js.map +0 -1
- package/dist/WebhookReceiver.test.d.ts +0 -1
- package/dist/WebhookReceiver.test.js +0 -39
- package/dist/WebhookReceiver.test.js.map +0 -1
- package/dist/grants.d.ts +0 -38
- package/dist/grants.js +0 -3
- package/dist/grants.js.map +0 -1
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -45
- package/dist/index.js.map +0 -1
- package/dist/proto/google/protobuf/timestamp.d.ts +0 -132
- package/dist/proto/google/protobuf/timestamp.js +0 -92
- package/dist/proto/google/protobuf/timestamp.js.map +0 -1
- package/dist/proto/livekit_egress.d.ts +0 -11266
- package/dist/proto/livekit_egress.js +0 -2869
- package/dist/proto/livekit_egress.js.map +0 -1
- package/dist/proto/livekit_ingress.d.ts +0 -2163
- package/dist/proto/livekit_ingress.js +0 -1264
- package/dist/proto/livekit_ingress.js.map +0 -1
- package/dist/proto/livekit_models.d.ts +0 -1356
- package/dist/proto/livekit_models.js +0 -2893
- package/dist/proto/livekit_models.js.map +0 -1
- package/dist/proto/livekit_room.d.ts +0 -3273
- package/dist/proto/livekit_room.js +0 -1057
- package/dist/proto/livekit_room.js.map +0 -1
- package/dist/proto/livekit_webhook.d.ts +0 -4837
- package/dist/proto/livekit_webhook.js +0 -169
- package/dist/proto/livekit_webhook.js.map +0 -1
package/dist/WebhookReceiver.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.WebhookReceiver = exports.authorizeHeader = void 0;
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
const AccessToken_1 = require("./AccessToken");
|
|
9
|
-
const livekit_webhook_1 = require("./proto/livekit_webhook");
|
|
10
|
-
exports.authorizeHeader = 'Authorize';
|
|
11
|
-
class WebhookReceiver {
|
|
12
|
-
constructor(apiKey, apiSecret) {
|
|
13
|
-
this.verifier = new AccessToken_1.TokenVerifier(apiKey, apiSecret);
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @param body string of the posted body
|
|
18
|
-
* @param authHeader `Authorization` header from the request
|
|
19
|
-
* @param skipAuth true to skip auth validation
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
receive(body, authHeader, skipAuth = false) {
|
|
23
|
-
// verify token
|
|
24
|
-
if (!skipAuth) {
|
|
25
|
-
if (!authHeader) {
|
|
26
|
-
throw new Error('authorization header is empty');
|
|
27
|
-
}
|
|
28
|
-
const claims = this.verifier.verify(authHeader);
|
|
29
|
-
// confirm sha
|
|
30
|
-
const hash = crypto_1.default.createHash('sha256');
|
|
31
|
-
hash.update(body);
|
|
32
|
-
if (claims.sha256 !== hash.digest('base64')) {
|
|
33
|
-
throw new Error('sha256 checksum of body does not match');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return livekit_webhook_1.WebhookEvent.fromJSON(JSON.parse(body));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.WebhookReceiver = WebhookReceiver;
|
|
40
|
-
//# sourceMappingURL=WebhookReceiver.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebhookReceiver.js","sourceRoot":"","sources":["../src/WebhookReceiver.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,+CAA8C;AAC9C,6DAAuD;AAE1C,QAAA,eAAe,GAAG,WAAW,CAAC;AAE3C,MAAa,eAAe;IAG1B,YAAY,MAAc,EAAE,SAAiB;QAC3C,IAAI,CAAC,QAAQ,GAAG,IAAI,2BAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;IAED;;;;;;OAMG;IACH,OAAO,CAAC,IAAY,EAAE,UAAmB,EAAE,WAAoB,KAAK;QAClE,eAAe;QACf,IAAI,CAAC,QAAQ,EAAE;YACb,IAAI,CAAC,UAAU,EAAE;gBACf,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;aAClD;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAChD,cAAc;YACd,MAAM,IAAI,GAAG,gBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAElB,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE;gBAC3C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;aAC3D;SACF;QAED,OAAO,8BAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,CAAC;CACF;AAhCD,0CAgCC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const AccessToken_1 = require("./AccessToken");
|
|
4
|
-
const livekit_webhook_1 = require("./proto/livekit_webhook");
|
|
5
|
-
const WebhookReceiver_1 = require("./WebhookReceiver");
|
|
6
|
-
const testApiKey = 'abcdefg';
|
|
7
|
-
const testSecret = 'abababa';
|
|
8
|
-
describe('webhook receiver', () => {
|
|
9
|
-
const body = '{"event":"room_started", "room":{"sid":"RM_TkVjUvAqgzKz", "name":"mytestroom", "emptyTimeout":300, "creationTime":"1628545903", "turnPassword":"ICkSr2rEeslkN6e9bXL4Ji5zzMD5Z7zzr6ulOaxMj6N", "enabledCodecs":[{"mime":"audio/opus"}, {"mime":"video/VP8"}]}}';
|
|
10
|
-
const sha = 'CoEQz1chqJ9bnZRcORddjplkvpjmPujmLTR42DbefYI=';
|
|
11
|
-
const t = new AccessToken_1.AccessToken(testApiKey, testSecret);
|
|
12
|
-
t.sha256 = sha;
|
|
13
|
-
const token = t.toJwt();
|
|
14
|
-
const receiver = new WebhookReceiver_1.WebhookReceiver(testApiKey, testSecret);
|
|
15
|
-
it('should receive and decode WebhookEvent', () => {
|
|
16
|
-
var _a;
|
|
17
|
-
const event = receiver.receive(body, token);
|
|
18
|
-
expect(event).toBeTruthy();
|
|
19
|
-
expect((_a = event.room) === null || _a === void 0 ? void 0 : _a.name).toBe('mytestroom');
|
|
20
|
-
expect(event.event).toBe('room_started');
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
describe('decoding json payload', () => {
|
|
24
|
-
it('should allow server to return extra fields', () => {
|
|
25
|
-
var _a;
|
|
26
|
-
const obj = {
|
|
27
|
-
type: 'room_started',
|
|
28
|
-
room: {
|
|
29
|
-
sid: 'RM_TkVjUvAqgzKz',
|
|
30
|
-
name: 'mytestroom',
|
|
31
|
-
},
|
|
32
|
-
extra: 'extra',
|
|
33
|
-
};
|
|
34
|
-
const event = livekit_webhook_1.WebhookEvent.fromJSON(obj);
|
|
35
|
-
expect(event).toBeTruthy();
|
|
36
|
-
expect((_a = event.room) === null || _a === void 0 ? void 0 : _a.name).toBe('mytestroom');
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=WebhookReceiver.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WebhookReceiver.test.js","sourceRoot":"","sources":["../src/WebhookReceiver.test.ts"],"names":[],"mappings":";;AAAA,+CAA4C;AAC5C,6DAAuD;AACvD,uDAAoD;AAEpD,MAAM,UAAU,GAAG,SAAS,CAAC;AAC7B,MAAM,UAAU,GAAG,SAAS,CAAC;AAE7B,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,MAAM,IAAI,GACR,+PAA+P,CAAC;IAClQ,MAAM,GAAG,GAAG,8CAA8C,CAAC;IAC3D,MAAM,CAAC,GAAG,IAAI,yBAAW,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAClD,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC;IACf,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;IACxB,MAAM,QAAQ,GAAG,IAAI,iCAAe,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAE7D,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;;QAChD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC5C,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC;QAC3B,MAAM,CAAC,MAAA,KAAK,CAAC,IAAI,0CAAE,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC5C,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;;QACpD,MAAM,GAAG,GAAG;YACV,IAAI,EAAE,cAAc;YACpB,IAAI,EAAE;gBACJ,GAAG,EAAE,iBAAiB;gBACtB,IAAI,EAAE,YAAY;aACnB;YACD,KAAK,EAAE,OAAO;SACf,CAAC;QAEF,MAAM,KAAK,GAAG,8BAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACzC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,CAAC;QAC3B,MAAM,CAAC,MAAA,KAAK,CAAC,IAAI,0CAAE,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/grants.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export interface VideoGrant {
|
|
2
|
-
/** permission to create a room */
|
|
3
|
-
roomCreate?: boolean;
|
|
4
|
-
/** permission to join a room as a participant, room must be set */
|
|
5
|
-
roomJoin?: boolean;
|
|
6
|
-
/** permission to list rooms */
|
|
7
|
-
roomList?: boolean;
|
|
8
|
-
/** permission to start a recording */
|
|
9
|
-
roomRecord?: boolean;
|
|
10
|
-
/** permission to control a specific room, room must be set */
|
|
11
|
-
roomAdmin?: boolean;
|
|
12
|
-
/** name of the room, must be set for admin or join permissions */
|
|
13
|
-
room?: string;
|
|
14
|
-
/** permissions to control ingress, not specific to any room or ingress */
|
|
15
|
-
ingressAdmin?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* allow participant to publish. If neither canPublish or canSubscribe is set,
|
|
18
|
-
* both publish and subscribe are enabled
|
|
19
|
-
*/
|
|
20
|
-
canPublish?: boolean;
|
|
21
|
-
/** allow participant to subscribe to other tracks */
|
|
22
|
-
canSubscribe?: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* allow participants to publish data, defaults to true if not set
|
|
25
|
-
*/
|
|
26
|
-
canPublishData?: boolean;
|
|
27
|
-
/** participant isn't visible to others */
|
|
28
|
-
hidden?: boolean;
|
|
29
|
-
/** participant is recording the room, when set, allows room to indicate it's being recorded */
|
|
30
|
-
recorder?: boolean;
|
|
31
|
-
}
|
|
32
|
-
/** @internal */
|
|
33
|
-
export interface ClaimGrants {
|
|
34
|
-
name?: string;
|
|
35
|
-
video?: VideoGrant;
|
|
36
|
-
metadata?: string;
|
|
37
|
-
sha256?: string;
|
|
38
|
-
}
|
package/dist/grants.js
DELETED
package/dist/grants.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"grants.js","sourceRoot":"","sources":["../src/grants.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './AccessToken';
|
|
2
|
-
export * from './EgressClient';
|
|
3
|
-
export * from './grants';
|
|
4
|
-
export * from './IngressClient';
|
|
5
|
-
export { DirectFileOutput, EgressInfo, EncodedFileOutput, EncodedFileType, EncodingOptions, EncodingOptionsPreset, SegmentedFileOutput, SegmentedFileProtocol, StreamOutput, StreamProtocol, } from './proto/livekit_egress';
|
|
6
|
-
export { IngressAudioOptions, IngressInfo, IngressInput, IngressState, IngressVideoOptions, } from './proto/livekit_ingress';
|
|
7
|
-
export { DataPacket_Kind, ParticipantInfo, ParticipantInfo_State, ParticipantPermission, Room, TrackInfo, TrackType, } from './proto/livekit_models';
|
|
8
|
-
export * from './RoomServiceClient';
|
|
9
|
-
export * from './WebhookReceiver';
|
package/dist/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
-
};
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.TrackType = exports.TrackInfo = exports.Room = exports.ParticipantPermission = exports.ParticipantInfo_State = exports.ParticipantInfo = exports.DataPacket_Kind = exports.IngressVideoOptions = exports.IngressState = exports.IngressInput = exports.IngressInfo = exports.IngressAudioOptions = exports.StreamProtocol = exports.StreamOutput = exports.SegmentedFileProtocol = exports.SegmentedFileOutput = exports.EncodingOptionsPreset = exports.EncodingOptions = exports.EncodedFileType = exports.EncodedFileOutput = exports.EgressInfo = exports.DirectFileOutput = void 0;
|
|
14
|
-
__exportStar(require("./AccessToken"), exports);
|
|
15
|
-
__exportStar(require("./EgressClient"), exports);
|
|
16
|
-
__exportStar(require("./grants"), exports);
|
|
17
|
-
__exportStar(require("./IngressClient"), exports);
|
|
18
|
-
var livekit_egress_1 = require("./proto/livekit_egress");
|
|
19
|
-
Object.defineProperty(exports, "DirectFileOutput", { enumerable: true, get: function () { return livekit_egress_1.DirectFileOutput; } });
|
|
20
|
-
Object.defineProperty(exports, "EgressInfo", { enumerable: true, get: function () { return livekit_egress_1.EgressInfo; } });
|
|
21
|
-
Object.defineProperty(exports, "EncodedFileOutput", { enumerable: true, get: function () { return livekit_egress_1.EncodedFileOutput; } });
|
|
22
|
-
Object.defineProperty(exports, "EncodedFileType", { enumerable: true, get: function () { return livekit_egress_1.EncodedFileType; } });
|
|
23
|
-
Object.defineProperty(exports, "EncodingOptions", { enumerable: true, get: function () { return livekit_egress_1.EncodingOptions; } });
|
|
24
|
-
Object.defineProperty(exports, "EncodingOptionsPreset", { enumerable: true, get: function () { return livekit_egress_1.EncodingOptionsPreset; } });
|
|
25
|
-
Object.defineProperty(exports, "SegmentedFileOutput", { enumerable: true, get: function () { return livekit_egress_1.SegmentedFileOutput; } });
|
|
26
|
-
Object.defineProperty(exports, "SegmentedFileProtocol", { enumerable: true, get: function () { return livekit_egress_1.SegmentedFileProtocol; } });
|
|
27
|
-
Object.defineProperty(exports, "StreamOutput", { enumerable: true, get: function () { return livekit_egress_1.StreamOutput; } });
|
|
28
|
-
Object.defineProperty(exports, "StreamProtocol", { enumerable: true, get: function () { return livekit_egress_1.StreamProtocol; } });
|
|
29
|
-
var livekit_ingress_1 = require("./proto/livekit_ingress");
|
|
30
|
-
Object.defineProperty(exports, "IngressAudioOptions", { enumerable: true, get: function () { return livekit_ingress_1.IngressAudioOptions; } });
|
|
31
|
-
Object.defineProperty(exports, "IngressInfo", { enumerable: true, get: function () { return livekit_ingress_1.IngressInfo; } });
|
|
32
|
-
Object.defineProperty(exports, "IngressInput", { enumerable: true, get: function () { return livekit_ingress_1.IngressInput; } });
|
|
33
|
-
Object.defineProperty(exports, "IngressState", { enumerable: true, get: function () { return livekit_ingress_1.IngressState; } });
|
|
34
|
-
Object.defineProperty(exports, "IngressVideoOptions", { enumerable: true, get: function () { return livekit_ingress_1.IngressVideoOptions; } });
|
|
35
|
-
var livekit_models_1 = require("./proto/livekit_models");
|
|
36
|
-
Object.defineProperty(exports, "DataPacket_Kind", { enumerable: true, get: function () { return livekit_models_1.DataPacket_Kind; } });
|
|
37
|
-
Object.defineProperty(exports, "ParticipantInfo", { enumerable: true, get: function () { return livekit_models_1.ParticipantInfo; } });
|
|
38
|
-
Object.defineProperty(exports, "ParticipantInfo_State", { enumerable: true, get: function () { return livekit_models_1.ParticipantInfo_State; } });
|
|
39
|
-
Object.defineProperty(exports, "ParticipantPermission", { enumerable: true, get: function () { return livekit_models_1.ParticipantPermission; } });
|
|
40
|
-
Object.defineProperty(exports, "Room", { enumerable: true, get: function () { return livekit_models_1.Room; } });
|
|
41
|
-
Object.defineProperty(exports, "TrackInfo", { enumerable: true, get: function () { return livekit_models_1.TrackInfo; } });
|
|
42
|
-
Object.defineProperty(exports, "TrackType", { enumerable: true, get: function () { return livekit_models_1.TrackType; } });
|
|
43
|
-
__exportStar(require("./RoomServiceClient"), exports);
|
|
44
|
-
__exportStar(require("./WebhookReceiver"), exports);
|
|
45
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,iDAA+B;AAC/B,2CAAyB;AACzB,kDAAgC;AAChC,yDAWgC;AAV9B,kHAAA,gBAAgB,OAAA;AAChB,4GAAA,UAAU,OAAA;AACV,mHAAA,iBAAiB,OAAA;AACjB,iHAAA,eAAe,OAAA;AACf,iHAAA,eAAe,OAAA;AACf,uHAAA,qBAAqB,OAAA;AACrB,qHAAA,mBAAmB,OAAA;AACnB,uHAAA,qBAAqB,OAAA;AACrB,8GAAA,YAAY,OAAA;AACZ,gHAAA,cAAc,OAAA;AAEhB,2DAMiC;AAL/B,sHAAA,mBAAmB,OAAA;AACnB,8GAAA,WAAW,OAAA;AACX,+GAAA,YAAY,OAAA;AACZ,+GAAA,YAAY,OAAA;AACZ,sHAAA,mBAAmB,OAAA;AAErB,yDAQgC;AAP9B,iHAAA,eAAe,OAAA;AACf,iHAAA,eAAe,OAAA;AACf,uHAAA,qBAAqB,OAAA;AACrB,uHAAA,qBAAqB,OAAA;AACrB,sGAAA,IAAI,OAAA;AACJ,2GAAA,SAAS,OAAA;AACT,2GAAA,SAAS,OAAA;AAEX,sDAAoC;AACpC,oDAAkC"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import _m0 from "protobufjs/minimal";
|
|
2
|
-
export declare const protobufPackage = "google.protobuf";
|
|
3
|
-
/**
|
|
4
|
-
* A Timestamp represents a point in time independent of any time zone or local
|
|
5
|
-
* calendar, encoded as a count of seconds and fractions of seconds at
|
|
6
|
-
* nanosecond resolution. The count is relative to an epoch at UTC midnight on
|
|
7
|
-
* January 1, 1970, in the proleptic Gregorian calendar which extends the
|
|
8
|
-
* Gregorian calendar backwards to year one.
|
|
9
|
-
*
|
|
10
|
-
* All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
|
|
11
|
-
* second table is needed for interpretation, using a [24-hour linear
|
|
12
|
-
* smear](https://developers.google.com/time/smear).
|
|
13
|
-
*
|
|
14
|
-
* The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
|
|
15
|
-
* restricting to that range, we ensure that we can convert to and from [RFC
|
|
16
|
-
* 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
|
|
17
|
-
*
|
|
18
|
-
* # Examples
|
|
19
|
-
*
|
|
20
|
-
* Example 1: Compute Timestamp from POSIX `time()`.
|
|
21
|
-
*
|
|
22
|
-
* Timestamp timestamp;
|
|
23
|
-
* timestamp.set_seconds(time(NULL));
|
|
24
|
-
* timestamp.set_nanos(0);
|
|
25
|
-
*
|
|
26
|
-
* Example 2: Compute Timestamp from POSIX `gettimeofday()`.
|
|
27
|
-
*
|
|
28
|
-
* struct timeval tv;
|
|
29
|
-
* gettimeofday(&tv, NULL);
|
|
30
|
-
*
|
|
31
|
-
* Timestamp timestamp;
|
|
32
|
-
* timestamp.set_seconds(tv.tv_sec);
|
|
33
|
-
* timestamp.set_nanos(tv.tv_usec * 1000);
|
|
34
|
-
*
|
|
35
|
-
* Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
|
|
36
|
-
*
|
|
37
|
-
* FILETIME ft;
|
|
38
|
-
* GetSystemTimeAsFileTime(&ft);
|
|
39
|
-
* UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
|
|
40
|
-
*
|
|
41
|
-
* // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
|
|
42
|
-
* // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
|
|
43
|
-
* Timestamp timestamp;
|
|
44
|
-
* timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
|
|
45
|
-
* timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
|
|
46
|
-
*
|
|
47
|
-
* Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
|
|
48
|
-
*
|
|
49
|
-
* long millis = System.currentTimeMillis();
|
|
50
|
-
*
|
|
51
|
-
* Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
|
|
52
|
-
* .setNanos((int) ((millis % 1000) * 1000000)).build();
|
|
53
|
-
*
|
|
54
|
-
* Example 5: Compute Timestamp from Java `Instant.now()`.
|
|
55
|
-
*
|
|
56
|
-
* Instant now = Instant.now();
|
|
57
|
-
*
|
|
58
|
-
* Timestamp timestamp =
|
|
59
|
-
* Timestamp.newBuilder().setSeconds(now.getEpochSecond())
|
|
60
|
-
* .setNanos(now.getNano()).build();
|
|
61
|
-
*
|
|
62
|
-
* Example 6: Compute Timestamp from current time in Python.
|
|
63
|
-
*
|
|
64
|
-
* timestamp = Timestamp()
|
|
65
|
-
* timestamp.GetCurrentTime()
|
|
66
|
-
*
|
|
67
|
-
* # JSON Mapping
|
|
68
|
-
*
|
|
69
|
-
* In JSON format, the Timestamp type is encoded as a string in the
|
|
70
|
-
* [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
|
|
71
|
-
* format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
|
|
72
|
-
* where {year} is always expressed using four digits while {month}, {day},
|
|
73
|
-
* {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
|
|
74
|
-
* seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
|
|
75
|
-
* are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
|
|
76
|
-
* is required. A proto3 JSON serializer should always use UTC (as indicated by
|
|
77
|
-
* "Z") when printing the Timestamp type and a proto3 JSON parser should be
|
|
78
|
-
* able to accept both UTC and other timezones (as indicated by an offset).
|
|
79
|
-
*
|
|
80
|
-
* For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
|
|
81
|
-
* 01:30 UTC on January 15, 2017.
|
|
82
|
-
*
|
|
83
|
-
* In JavaScript, one can convert a Date object to this format using the
|
|
84
|
-
* standard
|
|
85
|
-
* [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
|
|
86
|
-
* method. In Python, a standard `datetime.datetime` object can be converted
|
|
87
|
-
* to this format using
|
|
88
|
-
* [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
|
|
89
|
-
* the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
|
|
90
|
-
* the Joda Time's [`ISODateTimeFormat.dateTime()`](
|
|
91
|
-
* http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D
|
|
92
|
-
* ) to obtain a formatter capable of generating timestamps in this format.
|
|
93
|
-
*/
|
|
94
|
-
export interface Timestamp {
|
|
95
|
-
/**
|
|
96
|
-
* Represents seconds of UTC time since Unix epoch
|
|
97
|
-
* 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to
|
|
98
|
-
* 9999-12-31T23:59:59Z inclusive.
|
|
99
|
-
*/
|
|
100
|
-
seconds: number;
|
|
101
|
-
/**
|
|
102
|
-
* Non-negative fractions of a second at nanosecond resolution. Negative
|
|
103
|
-
* second values with fractions must still have non-negative nanos values
|
|
104
|
-
* that count forward in time. Must be from 0 to 999,999,999
|
|
105
|
-
* inclusive.
|
|
106
|
-
*/
|
|
107
|
-
nanos: number;
|
|
108
|
-
}
|
|
109
|
-
export declare const Timestamp: {
|
|
110
|
-
encode(message: Timestamp, writer?: _m0.Writer): _m0.Writer;
|
|
111
|
-
decode(input: _m0.Reader | Uint8Array, length?: number | undefined): Timestamp;
|
|
112
|
-
fromJSON(object: any): Timestamp;
|
|
113
|
-
toJSON(message: Timestamp): unknown;
|
|
114
|
-
fromPartial<I extends {
|
|
115
|
-
seconds?: number | undefined;
|
|
116
|
-
nanos?: number | undefined;
|
|
117
|
-
} & {
|
|
118
|
-
seconds?: number | undefined;
|
|
119
|
-
nanos?: number | undefined;
|
|
120
|
-
} & { [K in Exclude<keyof I, keyof Timestamp>]: never; }>(object: I): Timestamp;
|
|
121
|
-
};
|
|
122
|
-
declare type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
123
|
-
export declare type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
124
|
-
[K in keyof T]?: DeepPartial<T[K]>;
|
|
125
|
-
} : Partial<T>;
|
|
126
|
-
declare type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
127
|
-
export declare type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
128
|
-
[K in keyof P]: Exact<P[K], I[K]>;
|
|
129
|
-
} & {
|
|
130
|
-
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
131
|
-
};
|
|
132
|
-
export {};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Timestamp = exports.protobufPackage = void 0;
|
|
7
|
-
/* eslint-disable */
|
|
8
|
-
const long_1 = __importDefault(require("long"));
|
|
9
|
-
const minimal_1 = __importDefault(require("protobufjs/minimal"));
|
|
10
|
-
exports.protobufPackage = "google.protobuf";
|
|
11
|
-
function createBaseTimestamp() {
|
|
12
|
-
return { seconds: 0, nanos: 0 };
|
|
13
|
-
}
|
|
14
|
-
exports.Timestamp = {
|
|
15
|
-
encode(message, writer = minimal_1.default.Writer.create()) {
|
|
16
|
-
if (message.seconds !== 0) {
|
|
17
|
-
writer.uint32(8).int64(message.seconds);
|
|
18
|
-
}
|
|
19
|
-
if (message.nanos !== 0) {
|
|
20
|
-
writer.uint32(16).int32(message.nanos);
|
|
21
|
-
}
|
|
22
|
-
return writer;
|
|
23
|
-
},
|
|
24
|
-
decode(input, length) {
|
|
25
|
-
const reader = input instanceof minimal_1.default.Reader ? input : new minimal_1.default.Reader(input);
|
|
26
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
|
27
|
-
const message = createBaseTimestamp();
|
|
28
|
-
while (reader.pos < end) {
|
|
29
|
-
const tag = reader.uint32();
|
|
30
|
-
switch (tag >>> 3) {
|
|
31
|
-
case 1:
|
|
32
|
-
message.seconds = longToNumber(reader.int64());
|
|
33
|
-
break;
|
|
34
|
-
case 2:
|
|
35
|
-
message.nanos = reader.int32();
|
|
36
|
-
break;
|
|
37
|
-
default:
|
|
38
|
-
reader.skipType(tag & 7);
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return message;
|
|
43
|
-
},
|
|
44
|
-
fromJSON(object) {
|
|
45
|
-
return {
|
|
46
|
-
seconds: isSet(object.seconds) ? Number(object.seconds) : 0,
|
|
47
|
-
nanos: isSet(object.nanos) ? Number(object.nanos) : 0,
|
|
48
|
-
};
|
|
49
|
-
},
|
|
50
|
-
toJSON(message) {
|
|
51
|
-
const obj = {};
|
|
52
|
-
message.seconds !== undefined && (obj.seconds = Math.round(message.seconds));
|
|
53
|
-
message.nanos !== undefined && (obj.nanos = Math.round(message.nanos));
|
|
54
|
-
return obj;
|
|
55
|
-
},
|
|
56
|
-
fromPartial(object) {
|
|
57
|
-
var _a, _b;
|
|
58
|
-
const message = createBaseTimestamp();
|
|
59
|
-
message.seconds = (_a = object.seconds) !== null && _a !== void 0 ? _a : 0;
|
|
60
|
-
message.nanos = (_b = object.nanos) !== null && _b !== void 0 ? _b : 0;
|
|
61
|
-
return message;
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
var globalThis = (() => {
|
|
65
|
-
if (typeof globalThis !== "undefined") {
|
|
66
|
-
return globalThis;
|
|
67
|
-
}
|
|
68
|
-
if (typeof self !== "undefined") {
|
|
69
|
-
return self;
|
|
70
|
-
}
|
|
71
|
-
if (typeof window !== "undefined") {
|
|
72
|
-
return window;
|
|
73
|
-
}
|
|
74
|
-
if (typeof global !== "undefined") {
|
|
75
|
-
return global;
|
|
76
|
-
}
|
|
77
|
-
throw "Unable to locate global object";
|
|
78
|
-
})();
|
|
79
|
-
function longToNumber(long) {
|
|
80
|
-
if (long.gt(Number.MAX_SAFE_INTEGER)) {
|
|
81
|
-
throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");
|
|
82
|
-
}
|
|
83
|
-
return long.toNumber();
|
|
84
|
-
}
|
|
85
|
-
if (minimal_1.default.util.Long !== long_1.default) {
|
|
86
|
-
minimal_1.default.util.Long = long_1.default;
|
|
87
|
-
minimal_1.default.configure();
|
|
88
|
-
}
|
|
89
|
-
function isSet(value) {
|
|
90
|
-
return value !== null && value !== undefined;
|
|
91
|
-
}
|
|
92
|
-
//# sourceMappingURL=timestamp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timestamp.js","sourceRoot":"","sources":["../../../../src/proto/google/protobuf/timestamp.ts"],"names":[],"mappings":";;;;;;AAAA,oBAAoB;AACpB,gDAAwB;AACxB,iEAAqC;AAExB,QAAA,eAAe,GAAG,iBAAiB,CAAC;AA6GjD,SAAS,mBAAmB;IAC1B,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAClC,CAAC;AAEY,QAAA,SAAS,GAAG;IACvB,MAAM,CAAC,OAAkB,EAAE,SAAq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