@todoist/ui-extensions-server 0.0.1 → 4.0.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.
Files changed (281) hide show
  1. package/README.md +2 -44
  2. package/dist/analytics/events.d.ts +8 -0
  3. package/dist/analytics/events.js +15 -0
  4. package/dist/analytics/events.js.map +1 -0
  5. package/dist/buffer/cloneBuffer.d.ts +1 -0
  6. package/dist/buffer/cloneBuffer.js +12 -0
  7. package/dist/buffer/cloneBuffer.js.map +1 -0
  8. package/dist/buffer/incomingMessageWithRawBody.d.ts +4 -0
  9. package/dist/buffer/incomingMessageWithRawBody.js +8 -0
  10. package/dist/buffer/incomingMessageWithRawBody.js.map +1 -0
  11. package/dist/buffer/index.d.ts +2 -0
  12. package/dist/buffer/index.js +19 -0
  13. package/dist/buffer/index.js.map +1 -0
  14. package/dist/config/configurationBase.d.ts +29 -0
  15. package/dist/config/configurationBase.js +58 -0
  16. package/dist/config/configurationBase.js.map +1 -0
  17. package/dist/constants/card-actions.d.ts +12 -0
  18. package/dist/constants/card-actions.js +17 -0
  19. package/dist/constants/card-actions.js.map +1 -0
  20. package/dist/constants/core-strings.d.ts +61 -0
  21. package/dist/constants/core-strings.js +66 -0
  22. package/dist/constants/core-strings.js.map +1 -0
  23. package/dist/constants/images.d.ts +25 -0
  24. package/dist/constants/images.js +29 -0
  25. package/dist/constants/images.js.map +1 -0
  26. package/dist/constants/index.d.ts +4 -0
  27. package/dist/constants/index.js +21 -0
  28. package/dist/constants/index.js.map +1 -0
  29. package/dist/constants/ui-constants.d.ts +1 -0
  30. package/dist/constants/ui-constants.js +5 -0
  31. package/dist/constants/ui-constants.js.map +1 -0
  32. package/dist/controllers/app.controller.d.ts +15 -0
  33. package/dist/controllers/app.controller.js +76 -0
  34. package/dist/controllers/app.controller.js.map +1 -0
  35. package/dist/controllers/auth.controller.d.ts +47 -0
  36. package/dist/controllers/auth.controller.js +348 -0
  37. package/dist/controllers/auth.controller.js.map +1 -0
  38. package/dist/controllers/index.d.ts +3 -0
  39. package/dist/controllers/index.js +20 -0
  40. package/dist/controllers/index.js.map +1 -0
  41. package/dist/controllers/ping.controller.d.ts +3 -0
  42. package/dist/controllers/ping.controller.js +30 -0
  43. package/dist/controllers/ping.controller.js.map +1 -0
  44. package/dist/decorators/action-decorators.d.ts +12 -0
  45. package/dist/decorators/action-decorators.js +12 -0
  46. package/dist/decorators/action-decorators.js.map +1 -0
  47. package/dist/decorators/app-token.decorator.d.ts +1 -0
  48. package/dist/decorators/app-token.decorator.js +12 -0
  49. package/dist/decorators/app-token.decorator.js.map +1 -0
  50. package/dist/decorators/index.d.ts +2 -0
  51. package/dist/decorators/index.js +19 -0
  52. package/dist/decorators/index.js.map +1 -0
  53. package/dist/decorators/typed-method-decorator.d.ts +1 -0
  54. package/dist/decorators/typed-method-decorator.js +3 -0
  55. package/dist/decorators/typed-method-decorator.js.map +1 -0
  56. package/dist/entities/User.d.ts +24 -0
  57. package/dist/entities/User.js +89 -0
  58. package/dist/entities/User.js.map +1 -0
  59. package/dist/entities/index.d.ts +1 -0
  60. package/dist/entities/index.js +18 -0
  61. package/dist/entities/index.js.map +1 -0
  62. package/dist/exceptions/index.d.ts +1 -0
  63. package/dist/exceptions/index.js +18 -0
  64. package/dist/exceptions/index.js.map +1 -0
  65. package/dist/exceptions/integration.exception.d.ts +32 -0
  66. package/dist/exceptions/integration.exception.js +17 -0
  67. package/dist/exceptions/integration.exception.js.map +1 -0
  68. package/dist/filters/index.d.ts +1 -0
  69. package/dist/filters/index.js +18 -0
  70. package/dist/filters/index.js.map +1 -0
  71. package/dist/filters/integration-exception.filter.d.ts +10 -0
  72. package/dist/filters/integration-exception.filter.js +83 -0
  73. package/dist/filters/integration-exception.filter.js.map +1 -0
  74. package/dist/guards/extensionVerification.guard.d.ts +6 -0
  75. package/dist/guards/extensionVerification.guard.js +55 -0
  76. package/dist/guards/extensionVerification.guard.js.map +1 -0
  77. package/dist/guards/index.d.ts +1 -0
  78. package/dist/guards/index.js +18 -0
  79. package/dist/guards/index.js.map +1 -0
  80. package/dist/index.d.ts +17 -0
  81. package/dist/index.js +34 -0
  82. package/dist/index.js.map +1 -0
  83. package/dist/interceptors/sentry.interceptor.d.ts +5 -0
  84. package/dist/interceptors/sentry.interceptor.js +30 -0
  85. package/dist/interceptors/sentry.interceptor.js.map +1 -0
  86. package/dist/logging/index.d.ts +1 -0
  87. package/dist/logging/index.js +18 -0
  88. package/dist/logging/index.js.map +1 -0
  89. package/dist/logging/json.logger.d.ts +7 -0
  90. package/dist/logging/json.logger.js +23 -0
  91. package/dist/logging/json.logger.js.map +1 -0
  92. package/dist/middleware/index.d.ts +1 -0
  93. package/dist/middleware/index.js +18 -0
  94. package/dist/middleware/index.js.map +1 -0
  95. package/dist/middleware/request-header.middleware.d.ts +8 -0
  96. package/dist/middleware/request-header.middleware.js +29 -0
  97. package/dist/middleware/request-header.middleware.js.map +1 -0
  98. package/dist/middleware/workflow-initial-action.middleware.d.ts +13 -0
  99. package/dist/middleware/workflow-initial-action.middleware.js +23 -0
  100. package/dist/middleware/workflow-initial-action.middleware.js.map +1 -0
  101. package/dist/modules/analytics.module.d.ts +5 -0
  102. package/dist/modules/analytics.module.js +37 -0
  103. package/dist/modules/analytics.module.js.map +1 -0
  104. package/dist/modules/app-token.module.d.ts +2 -0
  105. package/dist/modules/app-token.module.js +22 -0
  106. package/dist/modules/app-token.module.js.map +1 -0
  107. package/dist/modules/auth.module.d.ts +17 -0
  108. package/dist/modules/auth.module.js +44 -0
  109. package/dist/modules/auth.module.js.map +1 -0
  110. package/dist/modules/core.module.d.ts +4 -0
  111. package/dist/modules/core.module.js +38 -0
  112. package/dist/modules/core.module.js.map +1 -0
  113. package/dist/modules/error.module.d.ts +7 -0
  114. package/dist/modules/error.module.js +39 -0
  115. package/dist/modules/error.module.js.map +1 -0
  116. package/dist/modules/index.d.ts +3 -0
  117. package/dist/modules/index.js +20 -0
  118. package/dist/modules/index.js.map +1 -0
  119. package/dist/modules/request-headers.module.d.ts +2 -0
  120. package/dist/modules/request-headers.module.js +22 -0
  121. package/dist/modules/request-headers.module.js.map +1 -0
  122. package/dist/server.d.ts +11 -0
  123. package/dist/server.js +52 -0
  124. package/dist/server.js.map +1 -0
  125. package/dist/services/actions.service.d.ts +19 -0
  126. package/dist/services/actions.service.js +126 -0
  127. package/dist/services/actions.service.js.map +1 -0
  128. package/dist/services/adaptive-card.service.d.ts +57 -0
  129. package/dist/services/adaptive-card.service.js +284 -0
  130. package/dist/services/adaptive-card.service.js.map +1 -0
  131. package/dist/services/analytics.service.d.ts +7 -0
  132. package/dist/services/analytics.service.js +20 -0
  133. package/dist/services/analytics.service.js.map +1 -0
  134. package/dist/services/app-token.service.d.ts +6 -0
  135. package/dist/services/app-token.service.js +47 -0
  136. package/dist/services/app-token.service.js.map +1 -0
  137. package/dist/services/authentication-client.d.ts +42 -0
  138. package/dist/services/authentication-client.js +95 -0
  139. package/dist/services/authentication-client.js.map +1 -0
  140. package/dist/services/composer-append-formatting.service.d.ts +9 -0
  141. package/dist/services/composer-append-formatting.service.js +37 -0
  142. package/dist/services/composer-append-formatting.service.js.map +1 -0
  143. package/dist/services/composer-append-settings.service.d.ts +7 -0
  144. package/dist/services/composer-append-settings.service.js +39 -0
  145. package/dist/services/composer-append-settings.service.js.map +1 -0
  146. package/dist/services/errorCard.service.d.ts +14 -0
  147. package/dist/services/errorCard.service.js +129 -0
  148. package/dist/services/errorCard.service.js.map +1 -0
  149. package/dist/services/google-analytics.service.d.ts +10 -0
  150. package/dist/services/google-analytics.service.js +56 -0
  151. package/dist/services/google-analytics.service.js.map +1 -0
  152. package/dist/services/index.d.ts +15 -0
  153. package/dist/services/index.js +32 -0
  154. package/dist/services/index.js.map +1 -0
  155. package/dist/services/legacy-google-analytics.service.d.ts +10 -0
  156. package/dist/services/legacy-google-analytics.service.js +56 -0
  157. package/dist/services/legacy-google-analytics.service.js.map +1 -0
  158. package/dist/services/login.service.d.ts +31 -0
  159. package/dist/services/login.service.js +165 -0
  160. package/dist/services/login.service.js.map +1 -0
  161. package/dist/services/request-headers.service.d.ts +9 -0
  162. package/dist/services/request-headers.service.js +53 -0
  163. package/dist/services/request-headers.service.js.map +1 -0
  164. package/dist/services/state.service.d.ts +18 -0
  165. package/dist/services/state.service.js +96 -0
  166. package/dist/services/state.service.js.map +1 -0
  167. package/dist/services/theme.service.d.ts +5 -0
  168. package/dist/services/theme.service.js +28 -0
  169. package/dist/services/theme.service.js.map +1 -0
  170. package/dist/services/translation.service.d.ts +3 -0
  171. package/dist/services/translation.service.js +20 -0
  172. package/dist/services/translation.service.js.map +1 -0
  173. package/dist/services/user-database.service.d.ts +18 -0
  174. package/dist/services/user-database.service.js +87 -0
  175. package/dist/services/user-database.service.js.map +1 -0
  176. package/dist/tsconfig.build.tsbuildinfo +1 -0
  177. package/dist/types/auth.d.ts +8 -0
  178. package/dist/types/auth.js +3 -0
  179. package/dist/types/auth.js.map +1 -0
  180. package/dist/types/data.d.ts +12 -0
  181. package/dist/types/data.js +10 -0
  182. package/dist/types/data.js.map +1 -0
  183. package/dist/types/endpoints.d.ts +1 -0
  184. package/dist/types/endpoints.js +3 -0
  185. package/dist/types/endpoints.js.map +1 -0
  186. package/dist/types/error-card-options.d.ts +11 -0
  187. package/dist/types/error-card-options.js +3 -0
  188. package/dist/types/error-card-options.js.map +1 -0
  189. package/dist/types/error.d.ts +2 -0
  190. package/dist/types/error.js +12 -0
  191. package/dist/types/error.js.map +1 -0
  192. package/dist/types/index.d.ts +7 -0
  193. package/dist/types/index.js +24 -0
  194. package/dist/types/index.js.map +1 -0
  195. package/dist/types/logging.d.ts +1 -0
  196. package/dist/types/logging.js +3 -0
  197. package/dist/types/logging.js.map +1 -0
  198. package/dist/types/product.d.ts +1 -0
  199. package/dist/types/product.js +3 -0
  200. package/dist/types/product.js.map +1 -0
  201. package/dist/types/retry.d.ts +11 -0
  202. package/dist/types/retry.js +12 -0
  203. package/dist/types/retry.js.map +1 -0
  204. package/dist/ui/back-button.d.ts +7 -0
  205. package/dist/ui/back-button.js +33 -0
  206. package/dist/ui/back-button.js.map +1 -0
  207. package/dist/ui/button.d.ts +15 -0
  208. package/dist/ui/button.js +27 -0
  209. package/dist/ui/button.js.map +1 -0
  210. package/dist/ui/column.d.ts +4 -0
  211. package/dist/ui/column.js +23 -0
  212. package/dist/ui/column.js.map +1 -0
  213. package/dist/ui/container.d.ts +11 -0
  214. package/dist/ui/container.js +31 -0
  215. package/dist/ui/container.js.map +1 -0
  216. package/dist/ui/date-time-input.d.ts +17 -0
  217. package/dist/ui/date-time-input.js +59 -0
  218. package/dist/ui/date-time-input.js.map +1 -0
  219. package/dist/ui/index.d.ts +9 -0
  220. package/dist/ui/index.js +26 -0
  221. package/dist/ui/index.js.map +1 -0
  222. package/dist/ui/profile-details.d.ts +3 -0
  223. package/dist/ui/profile-details.js +16 -0
  224. package/dist/ui/profile-details.js.map +1 -0
  225. package/dist/ui/stock-button.d.ts +20 -0
  226. package/dist/ui/stock-button.js +131 -0
  227. package/dist/ui/stock-button.js.map +1 -0
  228. package/dist/ui/text-block.d.ts +9 -0
  229. package/dist/ui/text-block.js +24 -0
  230. package/dist/ui/text-block.js.map +1 -0
  231. package/dist/ui/ui-builder-context.d.ts +7 -0
  232. package/dist/ui/ui-builder-context.js +3 -0
  233. package/dist/ui/ui-builder-context.js.map +1 -0
  234. package/dist/utils/action-utils.d.ts +5 -0
  235. package/dist/utils/action-utils.js +29 -0
  236. package/dist/utils/action-utils.js.map +1 -0
  237. package/dist/utils/card-bridge.d.ts +7 -0
  238. package/dist/utils/card-bridge.js +30 -0
  239. package/dist/utils/card-bridge.js.map +1 -0
  240. package/dist/utils/context-utils.d.ts +3 -0
  241. package/dist/utils/context-utils.js +21 -0
  242. package/dist/utils/context-utils.js.map +1 -0
  243. package/dist/utils/dateUtils.d.ts +10 -0
  244. package/dist/utils/dateUtils.js +88 -0
  245. package/dist/utils/dateUtils.js.map +1 -0
  246. package/dist/utils/encryption.d.ts +10 -0
  247. package/dist/utils/encryption.js +70 -0
  248. package/dist/utils/encryption.js.map +1 -0
  249. package/dist/utils/endpointUtils.d.ts +2 -0
  250. package/dist/utils/endpointUtils.js +7 -0
  251. package/dist/utils/endpointUtils.js.map +1 -0
  252. package/dist/utils/envUtils.d.ts +1 -0
  253. package/dist/utils/envUtils.js +7 -0
  254. package/dist/utils/envUtils.js.map +1 -0
  255. package/dist/utils/errorUtils.d.ts +6 -0
  256. package/dist/utils/errorUtils.js +51 -0
  257. package/dist/utils/errorUtils.js.map +1 -0
  258. package/dist/utils/header-utils.d.ts +9 -0
  259. package/dist/utils/header-utils.js +24 -0
  260. package/dist/utils/header-utils.js.map +1 -0
  261. package/dist/utils/index.d.ts +13 -0
  262. package/dist/utils/index.js +30 -0
  263. package/dist/utils/index.js.map +1 -0
  264. package/dist/utils/logger.d.ts +10 -0
  265. package/dist/utils/logger.js +50 -0
  266. package/dist/utils/logger.js.map +1 -0
  267. package/dist/utils/paginationDataUtils.d.ts +6 -0
  268. package/dist/utils/paginationDataUtils.js +52 -0
  269. package/dist/utils/paginationDataUtils.js.map +1 -0
  270. package/dist/utils/urlUtils.d.ts +2 -0
  271. package/dist/utils/urlUtils.js +20 -0
  272. package/dist/utils/urlUtils.js.map +1 -0
  273. package/dist/utils/validationUtils.d.ts +3 -0
  274. package/dist/utils/validationUtils.js +22 -0
  275. package/dist/utils/validationUtils.js.map +1 -0
  276. package/package.json +62 -8
  277. package/views/authDetails.hbs +97 -0
  278. package/views/partials/errorBody.hbs +7 -0
  279. package/views/partials/errorTitle.hbs +1 -0
  280. package/views/partials/successBody.hbs +2 -0
  281. package/views/partials/successTitle.hbs +1 -0
@@ -0,0 +1,57 @@
1
+ import { CardElement, ColumnSet, HorizontalAlignment, Image, RichTextBlock, Spacing, TodoistCard } from '@todoist/ui-extensions-core';
2
+ import { ErrorCardOptions } from '../types';
3
+ import type { DoistProduct } from '../types/product';
4
+ import { UIBuilderContext } from '../ui';
5
+ import { ThemeService } from './theme.service';
6
+ import { TranslationService } from './translation.service';
7
+ export declare const ERROR_CONTENT_ID = "ErrorContent";
8
+ export type ConfirmationInformation = {
9
+ title: string;
10
+ body: string;
11
+ confirmationText?: string;
12
+ confirmationActionId: string;
13
+ confirmationData?: Record<string, unknown>;
14
+ cancelData?: Record<string, unknown>;
15
+ cancelActionId?: string;
16
+ };
17
+ export type TextWithLearnMoreOptions = {
18
+ textKey: string;
19
+ learnMoreUrl: string;
20
+ spacing?: Spacing;
21
+ horizontalAlignment?: HorizontalAlignment;
22
+ };
23
+ export type ConfirmAndCancelOptions = {
24
+ confirmationButtonKey?: string;
25
+ confirmationButtonId?: string;
26
+ confirmationButtonActionUrl?: string;
27
+ cancelButtonKey?: string;
28
+ cancelButtonId?: string;
29
+ };
30
+ export type NotFoundCardOptions = {
31
+ textKey: string;
32
+ learnMoreUrl: string;
33
+ };
34
+ export type ProOnlyCardOptions = {
35
+ learnMoreUrl: string;
36
+ product: DoistProduct;
37
+ };
38
+ export declare class AdaptiveCardService implements UIBuilderContext {
39
+ readonly translationService: TranslationService;
40
+ readonly themeService: ThemeService;
41
+ constructor(translationService: TranslationService, themeService: ThemeService);
42
+ get spacingImageUrl(): string;
43
+ createStaticUrl(path: string): string;
44
+ createThemeBasedUrl(pathFormat: string): string;
45
+ createEmptyCard(): TodoistCard;
46
+ createHeader(leftColumnItems: CardElement[], middleColumnItems: CardElement[], rightColumnItems: CardElement[], includeEmptySpacing?: boolean): CardElement;
47
+ createCardWithItems(items: CardElement[]): TodoistCard;
48
+ errorCard(errorCardOptions?: ErrorCardOptions): TodoistCard;
49
+ confirmationCard(options: ConfirmationInformation): TodoistCard;
50
+ createTextWithLearnMore(options: TextWithLearnMoreOptions): RichTextBlock;
51
+ notFoundImage(): Image;
52
+ createNotFoundCard(options: NotFoundCardOptions): TodoistCard;
53
+ noResultsImage(): Image;
54
+ createProOnlyCard(options: ProOnlyCardOptions): TodoistCard;
55
+ createConfirmAndCancelActions(options: ConfirmAndCancelOptions): CardElement;
56
+ createWarningMessage(textKey: string): ColumnSet;
57
+ }
@@ -0,0 +1,284 @@
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.AdaptiveCardService = exports.ERROR_CONTENT_ID = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const integrations_common_1 = require("@todoist/integrations-common");
15
+ const ui_extensions_core_1 = require("@todoist/ui-extensions-core");
16
+ const constants_1 = require("../constants");
17
+ const types_1 = require("../types");
18
+ const ui_1 = require("../ui");
19
+ const utils_1 = require("../utils");
20
+ const theme_service_1 = require("./theme.service");
21
+ const translation_service_1 = require("./translation.service");
22
+ exports.ERROR_CONTENT_ID = 'ErrorContent';
23
+ let AdaptiveCardService = class AdaptiveCardService {
24
+ constructor(translationService, themeService) {
25
+ this.translationService = translationService;
26
+ this.themeService = themeService;
27
+ }
28
+ get spacingImageUrl() {
29
+ return this.createStaticUrl(constants_1.SPACING_IMAGE);
30
+ }
31
+ createStaticUrl(path) {
32
+ return (0, utils_1.createStaticUrl)(path);
33
+ }
34
+ createThemeBasedUrl(pathFormat) {
35
+ return this.themeService.createThemeBasedUrl(pathFormat);
36
+ }
37
+ createEmptyCard() {
38
+ const emptyCard = new ui_extensions_core_1.TodoistCard();
39
+ emptyCard.todoistCardVersion = '0.3';
40
+ return emptyCard;
41
+ }
42
+ createHeader(leftColumnItems, middleColumnItems, rightColumnItems, includeEmptySpacing = true) {
43
+ return (0, ui_extensions_core_1.createHeader)({
44
+ leftColumnItems,
45
+ middleColumnItems,
46
+ rightColumnItems,
47
+ emptySpaceImageUrl: includeEmptySpacing ? this.spacingImageUrl : undefined,
48
+ });
49
+ }
50
+ createCardWithItems(items) {
51
+ const card = this.createEmptyCard();
52
+ items.forEach((item) => {
53
+ card.addItem(item);
54
+ });
55
+ return card;
56
+ }
57
+ errorCard(errorCardOptions) {
58
+ const { showSignout = true, showGoHome = true, errorMessage = this.translationService.getTranslation(constants_1.Core.ERROR_CONTENT), retryRequest, helpCenterLink, errorId, maximumDoistCardVersion = 0.3, } = errorCardOptions !== null && errorCardOptions !== void 0 ? errorCardOptions : {};
59
+ const card = this.createEmptyCard();
60
+ card.verticalContentAlignment = 'center';
61
+ card.minHeight = 200;
62
+ const errorImage = new ui_extensions_core_1.Image();
63
+ errorImage.pixelWidth = 200;
64
+ errorImage.url = this.createThemeBasedUrl(constants_1.ERROR_IMAGE);
65
+ errorImage.horizontalAlignment = 'center';
66
+ const content = new ui_extensions_core_1.TextBlock(errorMessage);
67
+ content.id = exports.ERROR_CONTENT_ID;
68
+ content.horizontalAlignment = 'center';
69
+ content.wrap = true;
70
+ card.addItem(errorImage);
71
+ card.addItem(content);
72
+ if (retryRequest) {
73
+ const data = {
74
+ [types_1.RetryAttributes.ORIGINAL_DATA]: retryRequest.retryAction.data,
75
+ [types_1.RetryAttributes.ORIGINAL_INPUTS]: retryRequest.retryAction.inputs,
76
+ [types_1.RetryAttributes.COMMAND]: retryRequest.retryAction.actionId,
77
+ [types_1.RetryAttributes.ACTION_TYPE]: retryRequest.retryAction.actionType,
78
+ };
79
+ const retryButton = new ui_extensions_core_1.SubmitAction();
80
+ retryButton.id = constants_1.CardActions.Retry;
81
+ retryButton.data = data;
82
+ retryButton.style = 'positive';
83
+ retryButton.title = this.translationService.getTranslation(constants_1.Core.RETRY);
84
+ const column = new ui_extensions_core_1.Column(new ui_extensions_core_1.SizeAndUnit(100, 'pixel'));
85
+ const actions = new ui_extensions_core_1.ActionSet();
86
+ actions.id = 'RetryActions';
87
+ actions.addAction(retryButton);
88
+ column.addItem(actions);
89
+ const columns = new ui_extensions_core_1.ColumnSet();
90
+ columns.horizontalAlignment = 'center';
91
+ columns.spacing = 'medium';
92
+ columns.addColumn(column);
93
+ card.addItem(columns);
94
+ }
95
+ const actionSet = new ui_extensions_core_1.ActionSet();
96
+ actionSet.spacing = 'medium';
97
+ if (showGoHome) {
98
+ const goHomeButton = new ui_extensions_core_1.SubmitAction();
99
+ goHomeButton.id = constants_1.CardActions.GoHome;
100
+ goHomeButton.title = this.translationService.getTranslation(constants_1.Core.GO_BACK);
101
+ goHomeButton.associatedInputs = 'none';
102
+ actionSet.addAction(goHomeButton);
103
+ }
104
+ if (helpCenterLink) {
105
+ const contactUsButton = new ui_extensions_core_1.OpenUrlAction();
106
+ contactUsButton.title = this.translationService.getTranslation(constants_1.Core.CONTACT_US);
107
+ contactUsButton.url = helpCenterLink;
108
+ actionSet.addAction(contactUsButton);
109
+ }
110
+ if (errorId && maximumDoistCardVersion >= 0.6) {
111
+ const copySupportDataButton = new ui_extensions_core_1.ClipboardAction();
112
+ copySupportDataButton.id = constants_1.CardActions.CopySupportInfo;
113
+ copySupportDataButton.title = this.translationService.getTranslation(constants_1.Core.COPY_SUPPORT_INFORMATION);
114
+ copySupportDataButton.text = JSON.stringify({ errorId });
115
+ actionSet.addAction(copySupportDataButton);
116
+ }
117
+ if (showSignout) {
118
+ const signOutButton = new ui_extensions_core_1.SubmitAction();
119
+ signOutButton.id = constants_1.CardActions.LogOut;
120
+ signOutButton.title = this.translationService.getTranslation(constants_1.Core.LOGOUT);
121
+ signOutButton.style = 'destructive';
122
+ actionSet.addAction(signOutButton);
123
+ }
124
+ card.addItem(actionSet);
125
+ return card;
126
+ }
127
+ confirmationCard(options) {
128
+ const { title, body, confirmationText, confirmationData, confirmationActionId, cancelData, cancelActionId, } = options;
129
+ const card = this.createEmptyCard();
130
+ const titleText = (0, ui_1.createTitleTextBlock)({ text: title });
131
+ const bodyText = ui_extensions_core_1.TextBlock.from({
132
+ text: body,
133
+ wrap: true,
134
+ });
135
+ card.addItem(titleText);
136
+ card.addItem(bodyText);
137
+ const confirmationButton = new ui_extensions_core_1.SubmitAction();
138
+ confirmationButton.title =
139
+ confirmationText !== null && confirmationText !== void 0 ? confirmationText : this.translationService.getTranslation(constants_1.Core.YES);
140
+ confirmationButton.data = confirmationData;
141
+ confirmationButton.id = confirmationActionId;
142
+ confirmationButton.style = 'positive';
143
+ const cancelButton = new ui_extensions_core_1.SubmitAction();
144
+ cancelButton.id = cancelActionId !== null && cancelActionId !== void 0 ? cancelActionId : constants_1.CardActions.GoHome;
145
+ cancelButton.title = this.translationService.getTranslation(constants_1.Core.CANCEL);
146
+ cancelButton.associatedInputs = 'none';
147
+ cancelButton.data = cancelData;
148
+ const actions = new ui_extensions_core_1.ActionSet();
149
+ actions.addAction(cancelButton);
150
+ actions.addAction(confirmationButton);
151
+ card.addItem((0, ui_1.pageActions)(actions));
152
+ return card;
153
+ }
154
+ createTextWithLearnMore(options) {
155
+ var _a, _b;
156
+ return ui_extensions_core_1.RichTextBlock.fromWithInlines({
157
+ spacing: (_a = options.spacing) !== null && _a !== void 0 ? _a : 'medium',
158
+ horizontalAlignment: (_b = options.horizontalAlignment) !== null && _b !== void 0 ? _b : 'left',
159
+ inlines: [
160
+ ui_extensions_core_1.TextRun.from({
161
+ text: this.translationService.getTranslation(options.textKey),
162
+ isSubtle: true,
163
+ size: 'small',
164
+ }),
165
+ ui_extensions_core_1.TextRun.from({ text: ' ' }),
166
+ ui_extensions_core_1.TextRun.from({
167
+ text: this.translationService.getTranslation(constants_1.Core.LEARN_MORE),
168
+ selectAction: ui_extensions_core_1.OpenUrlAction.from({
169
+ url: options.learnMoreUrl,
170
+ }),
171
+ size: 'small',
172
+ color: 'attention',
173
+ }),
174
+ ],
175
+ });
176
+ }
177
+ notFoundImage() {
178
+ const notFoundImage = new ui_extensions_core_1.Image();
179
+ notFoundImage.pixelWidth = 200;
180
+ notFoundImage.url = this.createThemeBasedUrl(constants_1.ERROR_IMAGE);
181
+ notFoundImage.horizontalAlignment = 'center';
182
+ return notFoundImage;
183
+ }
184
+ createNotFoundCard(options) {
185
+ return ui_extensions_core_1.TodoistCard.fromWithItems({
186
+ items: [
187
+ this.notFoundImage(),
188
+ this.createTextWithLearnMore({
189
+ textKey: options.textKey,
190
+ learnMoreUrl: options.learnMoreUrl,
191
+ }),
192
+ ],
193
+ });
194
+ }
195
+ noResultsImage() {
196
+ const noResultsImage = new ui_extensions_core_1.Image();
197
+ noResultsImage.pixelWidth = 200;
198
+ noResultsImage.url = this.createThemeBasedUrl(constants_1.NO_RESULTS_IMAGE);
199
+ noResultsImage.horizontalAlignment = 'center';
200
+ return noResultsImage;
201
+ }
202
+ createProOnlyCard(options) {
203
+ const proOnlyImage = new ui_extensions_core_1.Image();
204
+ proOnlyImage.pixelWidth = 200;
205
+ proOnlyImage.url = this.createThemeBasedUrl(constants_1.PRO_ONLY_IMAGE);
206
+ proOnlyImage.horizontalAlignment = 'center';
207
+ return ui_extensions_core_1.TodoistCard.fromWithItems({
208
+ items: [
209
+ proOnlyImage,
210
+ ui_extensions_core_1.TextBlock.from({
211
+ text: this.translationService.getTranslation(constants_1.Core.CANNOT_ACCESS_EXTENSION),
212
+ horizontalAlignment: 'center',
213
+ }),
214
+ this.createTextWithLearnMore({
215
+ textKey: constants_1.Core.PRO_USERS_ONLY,
216
+ learnMoreUrl: options.learnMoreUrl,
217
+ spacing: 'small',
218
+ horizontalAlignment: 'center',
219
+ }),
220
+ ui_extensions_core_1.Container.from({ minHeight: 12 }),
221
+ this.createConfirmAndCancelActions({
222
+ confirmationButtonKey: constants_1.Core.UPGRADE_TO_PRO,
223
+ confirmationButtonActionUrl: (0, integrations_common_1.formatString)(constants_1.Core.PRICING_URL, options.product),
224
+ }),
225
+ ],
226
+ });
227
+ }
228
+ createConfirmAndCancelActions(options) {
229
+ var _a, _b, _c, _d;
230
+ const confirmActionProps = {
231
+ id: (_a = options.confirmationButtonId) !== null && _a !== void 0 ? _a : constants_1.CardActions.Confirm,
232
+ title: this.translationService.getTranslation((_b = options.confirmationButtonKey) !== null && _b !== void 0 ? _b : constants_1.Core.CONFIRM),
233
+ style: 'positive',
234
+ };
235
+ return (0, ui_1.pageActions)(ui_extensions_core_1.ActionSet.fromWithActions({
236
+ actions: [
237
+ ui_extensions_core_1.SubmitAction.from({
238
+ id: (_c = options.cancelButtonId) !== null && _c !== void 0 ? _c : constants_1.CardActions.Close,
239
+ title: this.translationService.getTranslation((_d = options.cancelButtonKey) !== null && _d !== void 0 ? _d : constants_1.Core.CANCEL),
240
+ }),
241
+ options.confirmationButtonActionUrl
242
+ ? ui_extensions_core_1.OpenUrlAction.from({
243
+ ...confirmActionProps,
244
+ url: options.confirmationButtonActionUrl,
245
+ })
246
+ : ui_extensions_core_1.SubmitAction.from(confirmActionProps),
247
+ ],
248
+ }));
249
+ }
250
+ createWarningMessage(textKey) {
251
+ return ui_extensions_core_1.ColumnSet.fromWithColumns({
252
+ columns: [
253
+ ui_extensions_core_1.Column.fromWithItems({
254
+ width: 'auto',
255
+ items: [
256
+ ui_extensions_core_1.Image.from({
257
+ url: (0, utils_1.createStaticUrl)('icons/shared/warning-icon.svg'),
258
+ width: '24px',
259
+ aspectRatio: 1,
260
+ }),
261
+ ],
262
+ }),
263
+ ui_extensions_core_1.Column.fromWithItems({
264
+ width: 'auto',
265
+ items: [
266
+ ui_extensions_core_1.TextBlock.from({
267
+ text: this.translationService.getTranslation(textKey),
268
+ color: 'attention',
269
+ size: 'small',
270
+ wrap: true,
271
+ }),
272
+ ],
273
+ }),
274
+ ],
275
+ });
276
+ }
277
+ };
278
+ exports.AdaptiveCardService = AdaptiveCardService;
279
+ exports.AdaptiveCardService = AdaptiveCardService = __decorate([
280
+ (0, common_1.Injectable)(),
281
+ __metadata("design:paramtypes", [translation_service_1.TranslationService,
282
+ theme_service_1.ThemeService])
283
+ ], AdaptiveCardService);
284
+ //# sourceMappingURL=adaptive-card.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adaptive-card.service.js","sourceRoot":"","sources":["../../src/services/adaptive-card.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA2C;AAC3C,sEAA2D;AAC3D,oEAoBoC;AAEpC,4CAOqB;AACrB,oCAA4D;AAE5D,8BAA2E;AAC3E,oCAA0C;AAC1C,mDAA8C;AAC9C,+DAA0D;AAI7C,QAAA,gBAAgB,GAAG,cAAc,CAAA;AAsCvC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAC5B,YACa,kBAAsC,EACtC,YAA0B;QAD1B,uBAAkB,GAAlB,kBAAkB,CAAoB;QACtC,iBAAY,GAAZ,YAAY,CAAc;IACpC,CAAC;IAEJ,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,eAAe,CAAC,yBAAa,CAAC,CAAA;IAC9C,CAAC;IAED,eAAe,CAAC,IAAY;QACxB,OAAO,IAAA,uBAAe,EAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAED,mBAAmB,CAAC,UAAkB;QAClC,OAAO,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;IAC5D,CAAC;IAED,eAAe;QACX,MAAM,SAAS,GAAG,IAAI,gCAAW,EAAE,CAAA;QACnC,SAAS,CAAC,kBAAkB,GAAG,KAAK,CAAA;QAEpC,OAAO,SAAS,CAAA;IACpB,CAAC;IAWD,YAAY,CACR,eAA8B,EAC9B,iBAAgC,EAChC,gBAA+B,EAC/B,mBAAmB,GAAG,IAAI;QAE1B,OAAO,IAAA,iCAAY,EAAC;YAChB,eAAe;YACf,iBAAiB;YACjB,gBAAgB;YAChB,kBAAkB,EAAE,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC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;oBACJ,CAAC,CAAC,iCAAY,CAAC,IAAI,CAAC,kBAAkB,CAAC;aAC9C;SACJ,CAAC,CACL,CAAA;IACL,CAAC;IAED,oBAAoB,CAAC,OAAe;QAChC,OAAO,8BAAS,CAAC,eAAe,CAAC;YAC7B,OAAO,EAAE;gBACL,2BAAM,CAAC,aAAa,CAAC;oBACjB,KAAK,EAAE,MAAM;oBACb,KAAK,EAAE;wBACH,0BAAK,CAAC,IAAI,CAAC;4BACP,GAAG,EAAE,IAAA,uBAAe,EAAC,+BAA+B,CAAC;4BACrD,KAAK,EAAE,MAAM;4BACb,WAAW,EAAE,CAAC;yBACjB,CAAC;qBACL;iBACJ,CAAC;gBACF,2BAAM,CAAC,aAAa,CAAC;oBACjB,KAAK,EAAE,MAAM;oBACb,KAAK,EAAE;wBACH,8BAAS,CAAC,IAAI,CAAC;4BACX,IAAI,EAAE,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,OAAO,CAAC;4BACrD,KAAK,EAAE,WAAW;4BAClB,IAAI,EAAE,OAAO;4BACb,IAAI,EAAE,IAAI;yBACb,CAAC;qBACL;iBACJ,CAAC;aACL;SACJ,CAAC,CAAA;IACN,CAAC;CACJ,CAAA;AA/VY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,GAAE;qCAGwB,wCAAkB;QACxB,4BAAY;GAH9B,mBAAmB,CA+V/B"}
@@ -0,0 +1,7 @@
1
+ import type { AnalyticsEvent } from '@todoist/integrations-common';
2
+ export declare class AnalyticsError extends Error {
3
+ }
4
+ export declare abstract class AnalyticsService {
5
+ abstract setUserId(userId: number): void;
6
+ abstract trackEvents(events: AnalyticsEvent[]): void;
7
+ }
@@ -0,0 +1,20 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.AnalyticsService = exports.AnalyticsError = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ class AnalyticsError extends Error {
12
+ }
13
+ exports.AnalyticsError = AnalyticsError;
14
+ let AnalyticsService = class AnalyticsService {
15
+ };
16
+ exports.AnalyticsService = AnalyticsService;
17
+ exports.AnalyticsService = AnalyticsService = __decorate([
18
+ (0, common_1.Injectable)({ scope: common_1.Scope.REQUEST })
19
+ ], AnalyticsService);
20
+ //# sourceMappingURL=analytics.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.service.js","sourceRoot":"","sources":["../../src/services/analytics.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAkD;AAGlD,MAAa,cAAe,SAAQ,KAAK;CAAG;AAA5C,wCAA4C;AAGrC,IAAe,gBAAgB,GAA/B,MAAe,gBAAgB;CAGrC,CAAA;AAHqB,4CAAgB;2BAAhB,gBAAgB;IADrC,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,OAAO,EAAE,CAAC;GACf,gBAAgB,CAGrC"}
@@ -0,0 +1,6 @@
1
+ import type { AppAuthToken } from '../types';
2
+ export declare class AppTokenService {
3
+ #private;
4
+ get appToken(): AppAuthToken | never;
5
+ set appToken(appToken: AppAuthToken | undefined);
6
+ }
@@ -0,0 +1,47 @@
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 __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
14
+ if (kind === "m") throw new TypeError("Private method is not writable");
15
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
16
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
17
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
18
+ };
19
+ var _AppTokenService_appToken;
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.AppTokenService = void 0;
22
+ const common_1 = require("@nestjs/common");
23
+ const exceptions_1 = require("../exceptions");
24
+ let AppTokenService = class AppTokenService {
25
+ constructor() {
26
+ _AppTokenService_appToken.set(this, void 0);
27
+ }
28
+ get appToken() {
29
+ if (!__classPrivateFieldGet(this, _AppTokenService_appToken, "f")) {
30
+ throw new exceptions_1.IntegrationException({
31
+ error: new common_1.UnauthorizedException('Missing authentication token'),
32
+ });
33
+ }
34
+ return __classPrivateFieldGet(this, _AppTokenService_appToken, "f");
35
+ }
36
+ set appToken(appToken) {
37
+ __classPrivateFieldSet(this, _AppTokenService_appToken, appToken, "f");
38
+ }
39
+ };
40
+ exports.AppTokenService = AppTokenService;
41
+ _AppTokenService_appToken = new WeakMap();
42
+ exports.AppTokenService = AppTokenService = __decorate([
43
+ (0, common_1.Injectable)({
44
+ scope: common_1.Scope.REQUEST,
45
+ })
46
+ ], AppTokenService);
47
+ //# sourceMappingURL=app-token.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-token.service.js","sourceRoot":"","sources":["../../src/services/app-token.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,2CAAyE;AAEzE,8CAAoD;AAc7C,IAAM,eAAe,GAArB,MAAM,eAAe;IAArB;QACH,4CAAmC;IAmBvC,CAAC;IAZG,IAAI,QAAQ;QACR,IAAI,CAAC,uBAAA,IAAI,iCAAU,EAAE,CAAC;YAClB,MAAM,IAAI,iCAAoB,CAAC;gBAC3B,KAAK,EAAE,IAAI,8BAAqB,CAAC,8BAA8B,CAAC;aACnE,CAAC,CAAA;QACN,CAAC;QACD,OAAO,uBAAA,IAAI,iCAAU,CAAA;IACzB,CAAC;IAED,IAAI,QAAQ,CAAC,QAAkC;QAC3C,uBAAA,IAAI,6BAAa,QAAQ,MAAA,CAAA;IAC7B,CAAC;CACJ,CAAA;AApBY,0CAAe;;0BAAf,eAAe;IAH3B,IAAA,mBAAU,EAAC;QACR,KAAK,EAAE,cAAK,CAAC,OAAO;KACvB,CAAC;GACW,eAAe,CAoB3B"}
@@ -0,0 +1,42 @@
1
+ import type { User } from '../entities';
2
+ import type { StateService } from './state.service';
3
+ import type { UserDatabaseService } from './user-database.service';
4
+ export type GrantType = 'refresh_token' | 'authorization_code';
5
+ export type AccessTokenData = {
6
+ accessToken: string;
7
+ refreshToken?: string;
8
+ expiresAt?: Date;
9
+ };
10
+ export type AuthenticatedUser = {
11
+ id: string;
12
+ email?: string;
13
+ name?: string;
14
+ };
15
+ export type AuthData = {
16
+ redirect_uri?: string;
17
+ code?: string;
18
+ grant_type: GrantType;
19
+ refresh_token?: string;
20
+ };
21
+ type TokenRefreshData = {
22
+ token: string;
23
+ userId: string;
24
+ };
25
+ export declare abstract class AuthenticationClient {
26
+ private readonly clientId;
27
+ protected readonly stateService: StateService;
28
+ protected readonly userDatabaseService: UserDatabaseService<User>;
29
+ static AUTH_PATH: string;
30
+ private readonly path;
31
+ constructor(clientId: string, stateService: StateService, userDatabaseService: UserDatabaseService<User>);
32
+ abstract getAuthorizationUrl(userId: number): Promise<string>;
33
+ abstract getAuthenticatedUser(authToken: string): Promise<AuthenticatedUser>;
34
+ exchangeToken(code: string): Promise<AccessTokenData>;
35
+ refreshToken(refreshToken: string): Promise<AccessTokenData | undefined>;
36
+ protected authenticate(_data: AuthData): Promise<AccessTokenData>;
37
+ protected createAuthorizationUrl(userId: number, authorizationUrl: string, scope?: string): Promise<string>;
38
+ protected createRedirectUrl(): string;
39
+ getCurrentOrRefreshedToken(userId: number): Promise<TokenRefreshData | undefined>;
40
+ shouldVerifyUserIdMatch(): boolean;
41
+ }
42
+ export {};
@@ -0,0 +1,95 @@
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.AuthenticationClient = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const node_1 = require("@sentry/node");
15
+ const utils_1 = require("../utils");
16
+ class AuthenticationClient {
17
+ constructor(clientId, stateService, userDatabaseService) {
18
+ this.clientId = clientId;
19
+ this.stateService = stateService;
20
+ this.userDatabaseService = userDatabaseService;
21
+ this.path = 'auth';
22
+ }
23
+ exchangeToken(code) {
24
+ const data = {
25
+ grant_type: 'authorization_code',
26
+ code,
27
+ redirect_uri: this.createRedirectUrl(),
28
+ };
29
+ return this.authenticate(data);
30
+ }
31
+ refreshToken(refreshToken) {
32
+ const data = {
33
+ grant_type: 'refresh_token',
34
+ refresh_token: refreshToken,
35
+ };
36
+ return this.authenticate(data);
37
+ }
38
+ authenticate(_data) {
39
+ throw new Error('Method not implemented.');
40
+ }
41
+ async createAuthorizationUrl(userId, authorizationUrl, scope) {
42
+ const authUrl = new URL(authorizationUrl);
43
+ const params = new URLSearchParams(authUrl.search);
44
+ const user = await this.userDatabaseService.getUser(userId);
45
+ const externalUserId = user === null || user === void 0 ? void 0 : user.externalUserId;
46
+ params.set('response_type', 'code');
47
+ params.set('redirect_uri', this.createRedirectUrl());
48
+ params.set('client_id', this.clientId);
49
+ params.set('state', await this.stateService.createState(userId, externalUserId));
50
+ if (scope) {
51
+ params.set('scope', scope);
52
+ }
53
+ authUrl.search = params.toString();
54
+ return Promise.resolve(authUrl.toString());
55
+ }
56
+ createRedirectUrl() {
57
+ const redirectUrl = new URL(this.path, (0, utils_1.getIntegrationBaseUrl)());
58
+ return redirectUrl.toString();
59
+ }
60
+ async getCurrentOrRefreshedToken(userId) {
61
+ const currentData = await this.userDatabaseService.getUser(userId);
62
+ if (!(currentData === null || currentData === void 0 ? void 0 : currentData.authToken)) {
63
+ return;
64
+ }
65
+ if (!(0, utils_1.hasAuthTokenExpired)(currentData.tokenExpiresAt)) {
66
+ return { token: currentData.authToken, userId: currentData.externalUserId };
67
+ }
68
+ try {
69
+ if (!currentData.refreshToken) {
70
+ return;
71
+ }
72
+ const refreshedData = await this.refreshToken(currentData.refreshToken);
73
+ if (!refreshedData) {
74
+ return;
75
+ }
76
+ await this.userDatabaseService.setToken(userId, { tokenData: refreshedData });
77
+ return { token: refreshedData.accessToken, userId: currentData.externalUserId };
78
+ }
79
+ catch (error) {
80
+ (0, node_1.captureException)(error);
81
+ return undefined;
82
+ }
83
+ }
84
+ shouldVerifyUserIdMatch() {
85
+ return false;
86
+ }
87
+ }
88
+ exports.AuthenticationClient = AuthenticationClient;
89
+ AuthenticationClient.AUTH_PATH = 'AuthenticationClient.PATH';
90
+ __decorate([
91
+ (0, common_1.Optional)(),
92
+ (0, common_1.Inject)(AuthenticationClient.AUTH_PATH),
93
+ __metadata("design:type", Object)
94
+ ], AuthenticationClient.prototype, "path", void 0);
95
+ //# sourceMappingURL=authentication-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authentication-client.js","sourceRoot":"","sources":["../../src/services/authentication-client.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AACjD,uCAA+C;AAE/C,oCAAqE;AA8BrE,MAAsB,oBAAoB;IAKtC,YACqB,QAAgB,EACd,YAA0B,EAC1B,mBAA8C;QAFhD,aAAQ,GAAR,QAAQ,CAAQ;QACd,iBAAY,GAAZ,YAAY,CAAc;QAC1B,wBAAmB,GAAnB,mBAAmB,CAA2B;QALA,SAAI,GAAG,MAAM,CAAA;IAM/E,CAAC;IAMJ,aAAa,CAAC,IAAY;QACtB,MAAM,IAAI,GAAa;YACnB,UAAU,EAAE,oBAAoB;YAChC,IAAI;YACJ,YAAY,EAAE,IAAI,CAAC,iBAAiB,EAAE;SACzC,CAAA;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IAED,YAAY,CAAC,YAAoB;QAC7B,MAAM,IAAI,GAAa;YACnB,UAAU,EAAE,eAAe;YAC3B,aAAa,EAAE,YAAY;SAC9B,CAAA;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;IAClC,CAAC;IAES,YAAY,CAAC,KAAe;QAClC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;IAES,KAAK,CAAC,sBAAsB,CAClC,MAAc,EACd,gBAAwB,EACxB,KAAc;QAEd,MAAM,OAAO,GAAG,IAAI,GAAG,CAA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OAAM;QACV,CAAC;QAED,IAAI,CAAC,IAAA,2BAAmB,EAAC,WAAW,CAAC,cAAc,CAAC,EAAE,CAAC;YACnD,OAAO,EAAE,KAAK,EAAE,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,CAAC,cAAc,EAAE,CAAA;QAC/E,CAAC;QAED,IAAI,CAAC;YACD,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;gBAC5B,OAAM;YACV,CAAC;YAED,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,YAAY,CAAC,CAAA;YACvE,IAAI,CAAC,aAAa,EAAE,CAAC;gBACjB,OAAM;YACV,CAAC;YACD,MAAM,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAA;YAE7E,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,WAAW,EAAE,MAAM,EAAE,WAAW,CAAC,cAAc,EAAE,CAAA;QACnF,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACtB,IAAA,uBAAgB,EAAC,KAAK,CAAC,CAAA;YAEvB,OAAO,SAAS,CAAA;QACpB,CAAC;IACL,CAAC;IAYD,uBAAuB;QACnB,OAAO,KAAK,CAAA;IAChB,CAAC;;AA/GL,oDAgHC;AA/GU,8BAAS,GAAG,2BAA2B,AAA9B,CAA8B;AAEuB;IAApE,IAAA,iBAAQ,GAAE;IAAE,IAAA,eAAM,EAAC,oBAAoB,CAAC,SAAS,CAAC;;kDAA+B"}
@@ -0,0 +1,9 @@
1
+ export declare abstract class ComposerAppendConfigurationService {
2
+ abstract getSignatureText(): string;
3
+ abstract canAddSignature(userId: number): Promise<boolean>;
4
+ }
5
+ export declare class ComposerAppendFormattingService {
6
+ private readonly configuration;
7
+ constructor(configuration: ComposerAppendConfigurationService);
8
+ formatForAppend(message: string, userId?: number): Promise<string>;
9
+ }
@@ -0,0 +1,37 @@
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.ComposerAppendFormattingService = exports.ComposerAppendConfigurationService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ class ComposerAppendConfigurationService {
15
+ }
16
+ exports.ComposerAppendConfigurationService = ComposerAppendConfigurationService;
17
+ let ComposerAppendFormattingService = class ComposerAppendFormattingService {
18
+ constructor(configuration) {
19
+ this.configuration = configuration;
20
+ }
21
+ async formatForAppend(message, userId) {
22
+ const canAddSignature = userId
23
+ ? await this.configuration.canAddSignature(userId)
24
+ : undefined;
25
+ if (!canAddSignature) {
26
+ return message;
27
+ }
28
+ const signature = this.configuration.getSignatureText();
29
+ return `${message}\n\n${signature}`;
30
+ }
31
+ };
32
+ exports.ComposerAppendFormattingService = ComposerAppendFormattingService;
33
+ exports.ComposerAppendFormattingService = ComposerAppendFormattingService = __decorate([
34
+ (0, common_1.Injectable)(),
35
+ __metadata("design:paramtypes", [ComposerAppendConfigurationService])
36
+ ], ComposerAppendFormattingService);
37
+ //# sourceMappingURL=composer-append-formatting.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composer-append-formatting.service.js","sourceRoot":"","sources":["../../src/services/composer-append-formatting.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA2C;AAE3C,MAAsB,kCAAkC;CAGvD;AAHD,gFAGC;AAGM,IAAM,+BAA+B,GAArC,MAAM,+BAA+B;IACxC,YAA6B,aAAiD;QAAjD,kBAAa,GAAb,aAAa,CAAoC;IAAG,CAAC;IAElF,KAAK,CAAC,eAAe,CAAC,OAAe,EAAE,MAAe;QAClD,MAAM,eAAe,GAAG,MAAM;YAC1B,CAAC,CAAC,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,CAAC;YAClD,CAAC,CAAC,SAAS,CAAA;QAEf,IAAI,CAAC,eAAe,EAAE,CAAC;YACnB,OAAO,OAAO,CAAA;QAClB,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,gBAAgB,EAAE,CAAA;QAEvD,OAAO,GAAG,OAAO,OAAO,SAAS,EAAE,CAAA;IACvC,CAAC;CACJ,CAAA;AAhBY,0EAA+B;0CAA/B,+BAA+B;IAD3C,IAAA,mBAAU,GAAE;qCAEmC,kCAAkC;GADrE,+BAA+B,CAgB3C"}