@bwi-mentorspaces/application-utils-npm 0.0.6 → 0.0.9

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 (122) hide show
  1. package/chat/index.d.ts +36 -36
  2. package/chat/index.js +58 -58
  3. package/chat/stream/enum/index.d.ts +33 -27
  4. package/chat/stream/enum/index.js +41 -34
  5. package/chat/stream/enum/index.js.map +1 -1
  6. package/chat/stream/index.d.ts +9 -9
  7. package/chat/stream/index.js +17 -17
  8. package/chat/stream/models/_/channel.data.d.ts +19 -19
  9. package/chat/stream/models/_/channel.data.js +2 -2
  10. package/chat/stream/models/_/channel.member.d.ts +14 -14
  11. package/chat/stream/models/_/channel.member.js +11 -11
  12. package/chat/stream/models/_/channel.response.d.ts +8 -8
  13. package/chat/stream/models/_/channel.response.js +2 -2
  14. package/chat/stream/models/_/event.data.d.ts +16 -0
  15. package/chat/stream/models/_/event.data.js +4 -0
  16. package/chat/stream/models/_/event.data.js.map +1 -0
  17. package/chat/stream/models/_/message.response.d.ts +8 -8
  18. package/chat/stream/models/_/message.response.js +2 -2
  19. package/chat/stream/models/_/stream.config.d.ts +22 -22
  20. package/chat/stream/models/_/stream.config.js +2 -2
  21. package/chat/stream/models/_/user.response.d.ts +8 -8
  22. package/chat/stream/models/_/user.response.js +2 -2
  23. package/chat/stream/models/index.d.ts +9 -7
  24. package/chat/stream/models/index.js +5 -5
  25. package/chat/stream/models/index.js.map +1 -1
  26. package/chat/stream/stream.api.d.ts +63 -63
  27. package/chat/stream/stream.api.js +76 -76
  28. package/chat/stream/stream.auth.d.ts +70 -70
  29. package/chat/stream/stream.auth.js +80 -80
  30. package/chat/stream/stream.base.d.ts +56 -56
  31. package/chat/stream/stream.base.js +93 -93
  32. package/chat/stream/stream.channel.d.ts +132 -118
  33. package/chat/stream/stream.channel.js +306 -285
  34. package/chat/stream/stream.channel.js.map +1 -1
  35. package/chat/stream/stream.error.d.ts +19 -19
  36. package/chat/stream/stream.error.js +17 -17
  37. package/chat/stream/stream.member.d.ts +75 -75
  38. package/chat/stream/stream.member.js +175 -175
  39. package/chat/stream/stream.message.d.ts +59 -59
  40. package/chat/stream/stream.message.js +112 -112
  41. package/chat/stream/stream.user.d.ts +49 -49
  42. package/chat/stream/stream.user.js +90 -90
  43. package/core/_/api-error.d.ts +24 -24
  44. package/core/_/api-error.js +21 -21
  45. package/core/_/api-response.d.ts +25 -25
  46. package/core/_/api-response.js +21 -21
  47. package/core/_/cors-headers.d.ts +16 -16
  48. package/core/_/cors-headers.js +32 -32
  49. package/core/_/model.d.ts +39 -31
  50. package/core/_/model.js +2 -2
  51. package/core/_/service-request.d.ts +66 -66
  52. package/core/_/service-request.js +104 -104
  53. package/core/_/service-request.js.map +1 -1
  54. package/core/index.d.ts +10 -10
  55. package/core/index.js +11 -11
  56. package/coverage/coverage-final.json +4 -0
  57. package/deployment/_/serverless.d.ts +26 -26
  58. package/deployment/_/serverless.js +43 -43
  59. package/deployment/index.d.ts +2 -2
  60. package/deployment/index.js +5 -5
  61. package/endpoint-test-factory/_/test-factory.d.ts +45 -45
  62. package/endpoint-test-factory/_/test-factory.js +91 -91
  63. package/endpoint-test-factory/index.d.ts +2 -2
  64. package/endpoint-test-factory/index.js +5 -5
  65. package/enums/index.d.ts +92 -92
  66. package/enums/index.js +2 -2
  67. package/jest.config.d.ts +12 -0
  68. package/jest.config.js +16 -0
  69. package/jest.config.js.map +1 -0
  70. package/meet/index.d.ts +36 -36
  71. package/meet/index.js +58 -58
  72. package/meet/tests/unit/twilio/twilio.room.test.d.ts +1 -0
  73. package/meet/tests/unit/twilio/twilio.room.test.js +33 -0
  74. package/meet/tests/unit/twilio/twilio.room.test.js.map +1 -0
  75. package/meet/twilio/enum/index.d.ts +6 -6
  76. package/meet/twilio/enum/index.js +10 -10
  77. package/meet/twilio/index.d.ts +5 -5
  78. package/meet/twilio/index.js +11 -11
  79. package/meet/twilio/models/_/room.data.d.ts +6 -6
  80. package/meet/twilio/models/_/room.data.js +2 -2
  81. package/meet/twilio/models/_/twilio.config.d.ts +29 -29
  82. package/meet/twilio/models/_/twilio.config.js +2 -2
  83. package/meet/twilio/models/index.d.ts +3 -3
  84. package/meet/twilio/models/index.js +2 -2
  85. package/meet/twilio/twilio.api.d.ts +28 -28
  86. package/meet/twilio/twilio.api.js +45 -45
  87. package/meet/twilio/twilio.auth.d.ts +55 -55
  88. package/meet/twilio/twilio.auth.js +83 -83
  89. package/meet/twilio/twilio.base.d.ts +41 -41
  90. package/meet/twilio/twilio.base.js +53 -53
  91. package/meet/twilio/twilio.room.d.ts +58 -46
  92. package/meet/twilio/twilio.room.js +141 -124
  93. package/meet/twilio/twilio.room.js.map +1 -1
  94. package/package.json +64 -57
  95. package/swagger/_/swagger.config.d.ts +21 -21
  96. package/swagger/_/swagger.config.js +2 -2
  97. package/swagger/_/swagger.d.ts +37 -37
  98. package/swagger/_/swagger.js +78 -78
  99. package/swagger/index.d.ts +3 -3
  100. package/swagger/index.js +5 -5
  101. package/types/index.d.ts +19 -19
  102. package/types/index.js +2 -2
  103. package/utils/_/encoder.d.ts +19 -19
  104. package/utils/_/encoder.js +27 -27
  105. package/utils/_/encryptor.d.ts +26 -26
  106. package/utils/_/encryptor.js +67 -67
  107. package/utils/_/hasher.d.ts +25 -25
  108. package/utils/_/hasher.js +63 -63
  109. package/utils/_/object-mapper.d.ts +12 -12
  110. package/utils/_/object-mapper.js +22 -22
  111. package/utils/_/string-formatter.d.ts +34 -34
  112. package/utils/_/string-formatter.js +49 -49
  113. package/utils/_/utc-date.d.ts +35 -35
  114. package/utils/_/utc-date.js +84 -84
  115. package/utils/index.d.ts +7 -7
  116. package/utils/index.js +15 -15
  117. package/validators/_/checker.d.ts +62 -62
  118. package/validators/_/checker.js +98 -98
  119. package/validators/_/regex.d.ts +98 -98
  120. package/validators/_/regex.js +142 -142
  121. package/validators/index.d.ts +3 -3
  122. package/validators/index.js +7 -7
@@ -1,7 +1,9 @@
1
- import { IChannelData } from "./_/channel.data";
2
- import { IMemberRole, StreamDefaultChannelRole } from "./_/channel.member";
3
- import { IChannelAPIResponse } from "./_/channel.response";
4
- import { IMessageResponse } from "./_/message.response";
5
- import { IStreamConfig, IChatConfig } from "./_/stream.config";
6
- import { IUserResponse } from "./_/user.response";
7
- export { IChannelData, IChannelAPIResponse, IMessageResponse, IStreamConfig, IChatConfig, IUserResponse, IMemberRole, StreamDefaultChannelRole };
1
+ import { IChannelData } from "./_/channel.data";
2
+ import { IMemberRole, StreamDefaultChannelRole } from "./_/channel.member";
3
+ import { IChannelAPIResponse } from "./_/channel.response";
4
+ import { IMessageResponse } from "./_/message.response";
5
+ import { IStreamConfig, IChatConfig } from "./_/stream.config";
6
+ import { IUserResponse } from "./_/user.response";
7
+ import { IEventTypes, IEventTypesData } from "./_/event.data";
8
+ export type { IChannelData, IChannelAPIResponse, IMessageResponse, IStreamConfig, IChatConfig, IUserResponse, IMemberRole, IEventTypes, IEventTypesData };
9
+ export { StreamDefaultChannelRole };
@@ -1,6 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StreamDefaultChannelRole = void 0;
4
- const channel_member_1 = require("./_/channel.member");
5
- Object.defineProperty(exports, "StreamDefaultChannelRole", { enumerable: true, get: function () { return channel_member_1.StreamDefaultChannelRole; } });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamDefaultChannelRole = void 0;
4
+ const channel_member_1 = require("./_/channel.member");
5
+ Object.defineProperty(exports, "StreamDefaultChannelRole", { enumerable: true, get: function () { return channel_member_1.StreamDefaultChannelRole; } });
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../chat/stream/models/index.ts"],"names":[],"mappings":";;;AACA,uDAA2E;AAcvE,yGAdkB,yCAAwB,OAclB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../chat/stream/models/index.ts"],"names":[],"mappings":";;;AACA,uDAA2E;AAkBlE,yGAlBa,yCAAwB,OAkBb"}
@@ -1,63 +1,63 @@
1
- import { IChatConfig } from "./models";
2
- import { StreamBase } from "./stream.base";
3
- import { StreamMember } from "./stream.member";
4
- import { StreamChannel } from "./stream.channel";
5
- import { StreamMessage } from "./stream.message";
6
- import { StreamUser } from "./stream.user";
7
- /**
8
- * Stream declarations
9
- */
10
- interface IStreamApi {
11
- streamChannel: StreamChannel;
12
- streamMember: StreamMember;
13
- streamMessage: StreamMessage;
14
- streamUser: StreamUser;
15
- }
16
- /**
17
- * Stream implementation
18
- */
19
- export declare class StreamApi extends StreamBase implements IStreamApi {
20
- private _config;
21
- private _streamChannel;
22
- private _streamMember;
23
- private _streamMessage;
24
- private _streamUser;
25
- /**
26
- * Steam api constructor
27
- *
28
- * @param {IApiConfig} config api configuration
29
- */
30
- constructor(config: IChatConfig);
31
- /**
32
- * getter for Stream API Channel
33
- *
34
- * @returns {StreamChannel} stream channel instance
35
- */
36
- get streamChannel(): StreamChannel;
37
- /**
38
-
39
- * getter for Stream API Member
40
- *
41
- * @returns {StreamMember} stream member instance
42
- */
43
- get streamMember(): StreamMember;
44
- /**
45
- * getter for Stream API Message
46
- *
47
- * @returns {StreamMessage} stream message instance
48
- */
49
- get streamMessage(): StreamMessage;
50
- /**
51
- * getter for Stream API User
52
- *
53
- * @returns {StreamUser} stream user instance
54
- */
55
- get streamUser(): StreamUser;
56
- /**
57
- * initialize method
58
- *
59
- * @returns {void} promise of type void
60
- */
61
- private init;
62
- }
63
- export {};
1
+ import { IChatConfig } from "./models";
2
+ import { StreamBase } from "./stream.base";
3
+ import { StreamMember } from "./stream.member";
4
+ import { StreamChannel } from "./stream.channel";
5
+ import { StreamMessage } from "./stream.message";
6
+ import { StreamUser } from "./stream.user";
7
+ /**
8
+ * Stream declarations
9
+ */
10
+ interface IStreamApi {
11
+ streamChannel: StreamChannel;
12
+ streamMember: StreamMember;
13
+ streamMessage: StreamMessage;
14
+ streamUser: StreamUser;
15
+ }
16
+ /**
17
+ * Stream implementation
18
+ */
19
+ export declare class StreamApi extends StreamBase implements IStreamApi {
20
+ private _config;
21
+ private _streamChannel;
22
+ private _streamMember;
23
+ private _streamMessage;
24
+ private _streamUser;
25
+ /**
26
+ * Steam api constructor
27
+ *
28
+ * @param {IApiConfig} config api configuration
29
+ */
30
+ constructor(config: IChatConfig);
31
+ /**
32
+ * getter for Stream API Channel
33
+ *
34
+ * @returns {StreamChannel} stream channel instance
35
+ */
36
+ get streamChannel(): StreamChannel;
37
+ /**
38
+
39
+ * getter for Stream API Member
40
+ *
41
+ * @returns {StreamMember} stream member instance
42
+ */
43
+ get streamMember(): StreamMember;
44
+ /**
45
+ * getter for Stream API Message
46
+ *
47
+ * @returns {StreamMessage} stream message instance
48
+ */
49
+ get streamMessage(): StreamMessage;
50
+ /**
51
+ * getter for Stream API User
52
+ *
53
+ * @returns {StreamUser} stream user instance
54
+ */
55
+ get streamUser(): StreamUser;
56
+ /**
57
+ * initialize method
58
+ *
59
+ * @returns {void} promise of type void
60
+ */
61
+ private init;
62
+ }
63
+ export {};
@@ -1,77 +1,77 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StreamApi = void 0;
4
- const stream_chat_1 = require("stream-chat");
5
- const stream_base_1 = require("./stream.base");
6
- const stream_member_1 = require("./stream.member");
7
- const stream_auth_1 = require("./stream.auth");
8
- const stream_channel_1 = require("./stream.channel");
9
- const stream_message_1 = require("./stream.message");
10
- const stream_user_1 = require("./stream.user");
11
- /**
12
- * Stream implementation
13
- */
14
- class StreamApi extends stream_base_1.StreamBase {
15
- /**
16
- * Steam api constructor
17
- *
18
- * @param {IApiConfig} config api configuration
19
- */
20
- constructor(config) {
21
- super();
22
- this._config = config;
23
- this.init();
24
- }
25
- /**
26
- * getter for Stream API Channel
27
- *
28
- * @returns {StreamChannel} stream channel instance
29
- */
30
- get streamChannel() {
31
- return this._streamChannel;
32
- }
33
- /**
34
-
35
- * getter for Stream API Member
36
- *
37
- * @returns {StreamMember} stream member instance
38
- */
39
- get streamMember() {
40
- return this._streamMember;
41
- }
42
- /**
43
- * getter for Stream API Message
44
- *
45
- * @returns {StreamMessage} stream message instance
46
- */
47
- get streamMessage() {
48
- return this._streamMessage;
49
- }
50
- /**
51
- * getter for Stream API User
52
- *
53
- * @returns {StreamUser} stream user instance
54
- */
55
- get streamUser() {
56
- return this._streamUser;
57
- }
58
- // method
59
- /**
60
- * initialize method
61
- *
62
- * @returns {void} promise of type void
63
- */
64
- init() {
65
- // instance the client
66
- super.server = stream_chat_1.StreamChat.getInstance(this._config.key, this._config.secret);
67
- super.auth = new stream_auth_1.StreamAuth(this._config);
68
- // create instances of all sub-api classes
69
- this._streamChannel = new stream_channel_1.StreamChannel(super.auth, super.server);
70
- this._streamMember = new stream_member_1.StreamMember(super.server);
71
- this._streamMessage = new stream_message_1.StreamMessage(super.server);
72
- this._streamUser = new stream_user_1.StreamUser(super.server);
73
- }
74
- }
75
- exports.StreamApi = StreamApi;
76
- module.exports = { StreamApi };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StreamApi = void 0;
4
+ const stream_chat_1 = require("stream-chat");
5
+ const stream_base_1 = require("./stream.base");
6
+ const stream_member_1 = require("./stream.member");
7
+ const stream_auth_1 = require("./stream.auth");
8
+ const stream_channel_1 = require("./stream.channel");
9
+ const stream_message_1 = require("./stream.message");
10
+ const stream_user_1 = require("./stream.user");
11
+ /**
12
+ * Stream implementation
13
+ */
14
+ class StreamApi extends stream_base_1.StreamBase {
15
+ /**
16
+ * Steam api constructor
17
+ *
18
+ * @param {IApiConfig} config api configuration
19
+ */
20
+ constructor(config) {
21
+ super();
22
+ this._config = config;
23
+ this.init();
24
+ }
25
+ /**
26
+ * getter for Stream API Channel
27
+ *
28
+ * @returns {StreamChannel} stream channel instance
29
+ */
30
+ get streamChannel() {
31
+ return this._streamChannel;
32
+ }
33
+ /**
34
+
35
+ * getter for Stream API Member
36
+ *
37
+ * @returns {StreamMember} stream member instance
38
+ */
39
+ get streamMember() {
40
+ return this._streamMember;
41
+ }
42
+ /**
43
+ * getter for Stream API Message
44
+ *
45
+ * @returns {StreamMessage} stream message instance
46
+ */
47
+ get streamMessage() {
48
+ return this._streamMessage;
49
+ }
50
+ /**
51
+ * getter for Stream API User
52
+ *
53
+ * @returns {StreamUser} stream user instance
54
+ */
55
+ get streamUser() {
56
+ return this._streamUser;
57
+ }
58
+ // method
59
+ /**
60
+ * initialize method
61
+ *
62
+ * @returns {void} promise of type void
63
+ */
64
+ init() {
65
+ // instance the client
66
+ super.server = stream_chat_1.StreamChat.getInstance(this._config.key, this._config.secret);
67
+ super.auth = new stream_auth_1.StreamAuth(this._config);
68
+ // create instances of all sub-api classes
69
+ this._streamChannel = new stream_channel_1.StreamChannel(super.auth, super.server);
70
+ this._streamMember = new stream_member_1.StreamMember(super.server);
71
+ this._streamMessage = new stream_message_1.StreamMessage(super.server);
72
+ this._streamUser = new stream_user_1.StreamUser(super.server);
73
+ }
74
+ }
75
+ exports.StreamApi = StreamApi;
76
+ module.exports = { StreamApi };
77
77
  //# sourceMappingURL=stream.api.js.map
@@ -1,70 +1,70 @@
1
- import { StreamChat } from "stream-chat";
2
- import { IChatConfig } from "./models";
3
- /**
4
- * Stream Auth middleware
5
- */
6
- interface IStreamAuth {
7
- /**
8
- * Authentication initialization
9
- *
10
- * @param {string} apiKey api key
11
- * @param {string} apiSecret api secret
12
- * @param {number} expMins expiration time for token, in minutes.
13
- * @returns {StreamChat} stream client
14
- */
15
- init(apiKey: string, apiSecret: string, expMins: number): StreamChat;
16
- /**
17
- * Create a new token for a specific userId
18
- *
19
- * @param {string} userId user id
20
- * @returns {string} stream token string
21
- */
22
- create(userId: string): string;
23
- /**
24
- * Get token, is token is expired automatically generate new one
25
- *
26
- * @param userId user id
27
- * @param refresh refresh token or not
28
- */
29
- token(userId: string, refresh?: boolean): string;
30
- }
31
- /**
32
- * Chat Auth implementation
33
- */
34
- export declare class StreamAuth implements IStreamAuth {
35
- private _server;
36
- private _expMinutes;
37
- private _tokenProvider;
38
- /**
39
- * Stream auth constructor
40
- *
41
- * @param {IChatConfig} config chat config
42
- */
43
- constructor(config: IChatConfig);
44
- /**
45
- * Generate the instance of the stream API Client.
46
- * After the first call, the client configuration will not change if the key or options parameters change
47
- *
48
- * @param {string} apiKey api key
49
- * @param {string} apiSecret api secret
50
- * @param {number} expMins expiration time for token, in minutes.
51
- * @returns {StreamChat} stream client
52
- */
53
- init(apiKey: string, apiSecret: string, expMins: number): StreamChat;
54
- /**
55
- * Create a new token for a specific user id
56
- *
57
- * @param {string} userId user id which needs a new token
58
- * @returns {string} new token
59
- */
60
- create(userId: string): string;
61
- /**
62
- * Get and refresh token manager
63
- *
64
- * @param {string} userId user id
65
- * @param {boolean} refresh refresh token
66
- * @returns {string} returns token value
67
- */
68
- token(userId: string, refresh?: boolean): string;
69
- }
70
- export {};
1
+ import { StreamChat } from "stream-chat";
2
+ import { IChatConfig } from "./models";
3
+ /**
4
+ * Stream Auth middleware
5
+ */
6
+ interface IStreamAuth {
7
+ /**
8
+ * Authentication initialization
9
+ *
10
+ * @param {string} apiKey api key
11
+ * @param {string} apiSecret api secret
12
+ * @param {number} expMins expiration time for token, in minutes.
13
+ * @returns {StreamChat} stream client
14
+ */
15
+ init(apiKey: string, apiSecret: string, expMins: number): StreamChat;
16
+ /**
17
+ * Create a new token for a specific userId
18
+ *
19
+ * @param {string} userId user id
20
+ * @returns {string} stream token string
21
+ */
22
+ create(userId: string): string;
23
+ /**
24
+ * Get token, is token is expired automatically generate new one
25
+ *
26
+ * @param userId user id
27
+ * @param refresh refresh token or not
28
+ */
29
+ token(userId: string, refresh?: boolean): string;
30
+ }
31
+ /**
32
+ * Chat Auth implementation
33
+ */
34
+ export declare class StreamAuth implements IStreamAuth {
35
+ private _server;
36
+ private _expMinutes;
37
+ private _tokenProvider;
38
+ /**
39
+ * Stream auth constructor
40
+ *
41
+ * @param {IChatConfig} config chat config
42
+ */
43
+ constructor(config: IChatConfig);
44
+ /**
45
+ * Generate the instance of the stream API Client.
46
+ * After the first call, the client configuration will not change if the key or options parameters change
47
+ *
48
+ * @param {string} apiKey api key
49
+ * @param {string} apiSecret api secret
50
+ * @param {number} expMins expiration time for token, in minutes.
51
+ * @returns {StreamChat} stream client
52
+ */
53
+ init(apiKey: string, apiSecret: string, expMins: number): StreamChat;
54
+ /**
55
+ * Create a new token for a specific user id
56
+ *
57
+ * @param {string} userId user id which needs a new token
58
+ * @returns {string} new token
59
+ */
60
+ create(userId: string): string;
61
+ /**
62
+ * Get and refresh token manager
63
+ *
64
+ * @param {string} userId user id
65
+ * @param {boolean} refresh refresh token
66
+ * @returns {string} returns token value
67
+ */
68
+ token(userId: string, refresh?: boolean): string;
69
+ }
70
+ export {};
@@ -1,81 +1,81 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.StreamAuth = void 0;
13
- const tsyringe_1 = require("tsyringe");
14
- const stream_chat_1 = require("stream-chat");
15
- const utils_1 = require("../../utils");
16
- /**
17
- * Chat Auth implementation
18
- */
19
- let StreamAuth = class StreamAuth {
20
- // methods
21
- /**
22
- * Stream auth constructor
23
- *
24
- * @param {IChatConfig} config chat config
25
- */
26
- constructor(config) {
27
- this.init(config.key, config.secret, config.options.token.expiration);
28
- }
29
- /**
30
- * Generate the instance of the stream API Client.
31
- * After the first call, the client configuration will not change if the key or options parameters change
32
- *
33
- * @param {string} apiKey api key
34
- * @param {string} apiSecret api secret
35
- * @param {number} expMins expiration time for token, in minutes.
36
- * @returns {StreamChat} stream client
37
- */
38
- init(apiKey, apiSecret, expMins) {
39
- this._expMinutes = expMins;
40
- this._server = stream_chat_1.StreamChat.getInstance(apiKey, apiSecret);
41
- this._tokenProvider = new Map();
42
- return this._server;
43
- }
44
- /**
45
- * Create a new token for a specific user id
46
- *
47
- * @param {string} userId user id which needs a new token
48
- * @returns {string} new token
49
- */
50
- create(userId) {
51
- //Create the timestamp, this._expMinutes is in minutes, and it is in global.config.json
52
- const timestamp = utils_1.UtcDate.timestamp(this._expMinutes);
53
- return this._server.createToken(userId, timestamp);
54
- }
55
- /**
56
- * Get and refresh token manager
57
- *
58
- * @param {string} userId user id
59
- * @param {boolean} refresh refresh token
60
- * @returns {string} returns token value
61
- */
62
- token(userId, refresh = false) {
63
- let token;
64
- if (this._tokenProvider[userId] !== undefined && !refresh) {
65
- return this._tokenProvider[userId];
66
- }
67
- else {
68
- token = this.create(userId);
69
- if (token) {
70
- this._tokenProvider[userId] = token;
71
- }
72
- return token;
73
- }
74
- }
75
- };
76
- StreamAuth = __decorate([
77
- (0, tsyringe_1.injectable)(),
78
- __metadata("design:paramtypes", [Object])
79
- ], StreamAuth);
80
- exports.StreamAuth = StreamAuth;
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.StreamAuth = void 0;
13
+ const tsyringe_1 = require("tsyringe");
14
+ const stream_chat_1 = require("stream-chat");
15
+ const utils_1 = require("../../utils");
16
+ /**
17
+ * Chat Auth implementation
18
+ */
19
+ let StreamAuth = class StreamAuth {
20
+ // methods
21
+ /**
22
+ * Stream auth constructor
23
+ *
24
+ * @param {IChatConfig} config chat config
25
+ */
26
+ constructor(config) {
27
+ this.init(config.key, config.secret, config.options.token.expiration);
28
+ }
29
+ /**
30
+ * Generate the instance of the stream API Client.
31
+ * After the first call, the client configuration will not change if the key or options parameters change
32
+ *
33
+ * @param {string} apiKey api key
34
+ * @param {string} apiSecret api secret
35
+ * @param {number} expMins expiration time for token, in minutes.
36
+ * @returns {StreamChat} stream client
37
+ */
38
+ init(apiKey, apiSecret, expMins) {
39
+ this._expMinutes = expMins;
40
+ this._server = stream_chat_1.StreamChat.getInstance(apiKey, apiSecret);
41
+ this._tokenProvider = new Map();
42
+ return this._server;
43
+ }
44
+ /**
45
+ * Create a new token for a specific user id
46
+ *
47
+ * @param {string} userId user id which needs a new token
48
+ * @returns {string} new token
49
+ */
50
+ create(userId) {
51
+ //Create the timestamp, this._expMinutes is in minutes, and it is in global.config.json
52
+ const timestamp = utils_1.UtcDate.timestamp(this._expMinutes);
53
+ return this._server.createToken(userId, timestamp);
54
+ }
55
+ /**
56
+ * Get and refresh token manager
57
+ *
58
+ * @param {string} userId user id
59
+ * @param {boolean} refresh refresh token
60
+ * @returns {string} returns token value
61
+ */
62
+ token(userId, refresh = false) {
63
+ let token;
64
+ if (this._tokenProvider[userId] !== undefined && !refresh) {
65
+ return this._tokenProvider[userId];
66
+ }
67
+ else {
68
+ token = this.create(userId);
69
+ if (token) {
70
+ this._tokenProvider[userId] = token;
71
+ }
72
+ return token;
73
+ }
74
+ }
75
+ };
76
+ StreamAuth = __decorate([
77
+ (0, tsyringe_1.injectable)(),
78
+ __metadata("design:paramtypes", [Object])
79
+ ], StreamAuth);
80
+ exports.StreamAuth = StreamAuth;
81
81
  //# sourceMappingURL=stream.auth.js.map