@twentyhq/meet 0.0.0-stage → 1.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 (172) hide show
  1. package/README.md +48 -2
  2. package/dependencies/yarn.lock +1863 -0
  3. package/manifest.json +1901 -0
  4. package/package.json +44 -4
  5. package/public/gallery/meet-cover-image-1.png +0 -0
  6. package/public/gallery/meet-cover-image-2.png +0 -0
  7. package/public/gallery/meet-cover-image-3.png +0 -0
  8. package/public/logo.svg +1 -0
  9. package/src/constants/meet-call-summary-prompt.constant.ts +54 -0
  10. package/src/constants/meet.constant.ts +17 -0
  11. package/src/constants/universal-identifiers.ts +35 -0
  12. package/src/logic-functions/constants/calendar-event-matching.constant.ts +3 -0
  13. package/src/logic-functions/constants/google-docs-api.constant.ts +10 -0
  14. package/src/logic-functions/constants/google-drive-api.constant.ts +1 -0
  15. package/src/logic-functions/constants/google-pubsub-push.constant.ts +7 -0
  16. package/src/logic-functions/constants/google-user-info.constant.ts +2 -0
  17. package/src/logic-functions/constants/google-workspace-events.constant.ts +17 -0
  18. package/src/logic-functions/constants/meet-api.constant.ts +9 -0
  19. package/src/logic-functions/constants/meet-call-summary.constant.ts +3 -0
  20. package/src/logic-functions/constants/meet-import.constant.ts +7 -0
  21. package/src/logic-functions/constants/meet-recording-import.constant.ts +7 -0
  22. package/src/logic-functions/constants/restricted-field-placeholder.constant.ts +2 -0
  23. package/src/logic-functions/meet-events-resolver.mjs +1345 -0
  24. package/src/logic-functions/meet-events-resolver.mjs.map +7 -0
  25. package/src/logic-functions/meet-events-resolver.ts +89 -0
  26. package/src/logic-functions/meet-handle-event.mjs +665 -0
  27. package/src/logic-functions/meet-handle-event.mjs.map +7 -0
  28. package/src/logic-functions/meet-handle-event.ts +86 -0
  29. package/src/logic-functions/meet-identify-account.mjs +369 -0
  30. package/src/logic-functions/meet-identify-account.mjs.map +7 -0
  31. package/src/logic-functions/meet-identify-account.ts +42 -0
  32. package/src/logic-functions/meet-import-conference.mjs +1465 -0
  33. package/src/logic-functions/meet-import-conference.mjs.map +7 -0
  34. package/src/logic-functions/meet-import-conference.ts +101 -0
  35. package/src/logic-functions/meet-import-recording.mjs +794 -0
  36. package/src/logic-functions/meet-import-recording.mjs.map +7 -0
  37. package/src/logic-functions/meet-import-recording.ts +99 -0
  38. package/src/logic-functions/meet-queue-conference-imports.mjs +711 -0
  39. package/src/logic-functions/meet-queue-conference-imports.mjs.map +7 -0
  40. package/src/logic-functions/meet-queue-conference-imports.ts +62 -0
  41. package/src/logic-functions/meet-refresh-connections.mjs +457 -0
  42. package/src/logic-functions/meet-refresh-connections.mjs.map +7 -0
  43. package/src/logic-functions/meet-refresh-connections.ts +64 -0
  44. package/src/logic-functions/meet-register-connection.mjs +837 -0
  45. package/src/logic-functions/meet-register-connection.mjs.map +7 -0
  46. package/src/logic-functions/meet-register-connection.ts +81 -0
  47. package/src/logic-functions/meet-summarize-call-recording.mjs +645 -0
  48. package/src/logic-functions/meet-summarize-call-recording.mjs.map +7 -0
  49. package/src/logic-functions/meet-summarize-call-recording.ts +111 -0
  50. package/src/logic-functions/meet-unregister-connection.mjs +610 -0
  51. package/src/logic-functions/meet-unregister-connection.mjs.map +7 -0
  52. package/src/logic-functions/meet-unregister-connection.ts +57 -0
  53. package/src/logic-functions/types/calendar-event-candidate.type.ts +6 -0
  54. package/src/logic-functions/types/call-recording-for-summary.type.ts +5 -0
  55. package/src/logic-functions/types/call-recording-sync-fields.type.ts +12 -0
  56. package/src/logic-functions/types/call-recording-upsert-outcome.type.ts +4 -0
  57. package/src/logic-functions/types/google-doc-lists.type.ts +4 -0
  58. package/src/logic-functions/types/google-doc-markdown-segment.type.ts +5 -0
  59. package/src/logic-functions/types/google-doc-paragraph-element.type.ts +8 -0
  60. package/src/logic-functions/types/google-doc-paragraph.type.ts +7 -0
  61. package/src/logic-functions/types/google-doc-tab.type.ts +10 -0
  62. package/src/logic-functions/types/google-doc.type.ts +6 -0
  63. package/src/logic-functions/types/google-pubsub-push-body.type.ts +6 -0
  64. package/src/logic-functions/types/google-request-method.type.ts +1 -0
  65. package/src/logic-functions/types/google-user-info.type.ts +4 -0
  66. package/src/logic-functions/types/google-workspace-events-operation.type.ts +8 -0
  67. package/src/logic-functions/types/meet-call-summary-outcome.type.ts +6 -0
  68. package/src/logic-functions/types/meet-collection-page.type.ts +3 -0
  69. package/src/logic-functions/types/meet-conference-record.type.ts +7 -0
  70. package/src/logic-functions/types/meet-conference-sync-outcome.type.ts +5 -0
  71. package/src/logic-functions/types/meet-conference-sync-result.type.ts +7 -0
  72. package/src/logic-functions/types/meet-daily-job-name.type.ts +1 -0
  73. package/src/logic-functions/types/meet-event-data.type.ts +5 -0
  74. package/src/logic-functions/types/meet-event-outcome.type.ts +4 -0
  75. package/src/logic-functions/types/meet-event-subscription.type.ts +8 -0
  76. package/src/logic-functions/types/meet-event.type.ts +5 -0
  77. package/src/logic-functions/types/meet-exception-code.type.ts +12 -0
  78. package/src/logic-functions/types/meet-exception.type.ts +25 -0
  79. package/src/logic-functions/types/meet-participant.type.ts +8 -0
  80. package/src/logic-functions/types/meet-recording-import-outcome.type.ts +6 -0
  81. package/src/logic-functions/types/meet-recording.type.ts +7 -0
  82. package/src/logic-functions/types/meet-smart-note.type.ts +7 -0
  83. package/src/logic-functions/types/meet-space.type.ts +5 -0
  84. package/src/logic-functions/types/meet-transcript-entry.type.ts +8 -0
  85. package/src/logic-functions/types/meet-transcript.type.ts +7 -0
  86. package/src/logic-functions/types/transcript-entry.type.ts +7 -0
  87. package/src/logic-functions/utils/build-google-api-url-or-throw.util.ts +30 -0
  88. package/src/logic-functions/utils/build-google-doc-markdown-segment.util.ts +67 -0
  89. package/src/logic-functions/utils/build-meet-artifact-import-job.util.ts +25 -0
  90. package/src/logic-functions/utils/build-meet-call-recording-sync-fields.util.ts +48 -0
  91. package/src/logic-functions/utils/build-meet-call-summary-job.util.ts +19 -0
  92. package/src/logic-functions/utils/build-meet-call-summary-prompt.util.ts +50 -0
  93. package/src/logic-functions/utils/build-meet-conference-import-job.util.ts +26 -0
  94. package/src/logic-functions/utils/build-meet-conference-import-payload.util.ts +18 -0
  95. package/src/logic-functions/utils/build-meet-conference-record-filter.util.ts +8 -0
  96. package/src/logic-functions/utils/build-meet-daily-job.util.ts +17 -0
  97. package/src/logic-functions/utils/build-meet-recording-import-job.util.ts +20 -0
  98. package/src/logic-functions/utils/build-meet-url-or-throw.util.ts +15 -0
  99. package/src/logic-functions/utils/build-meet-user-target-resource.util.ts +2 -0
  100. package/src/logic-functions/utils/can-renew-meet-event-subscription.util.ts +18 -0
  101. package/src/logic-functions/utils/chunk-into-batches.util.ts +10 -0
  102. package/src/logic-functions/utils/claim-meet-event-subscription.util.ts +10 -0
  103. package/src/logic-functions/utils/compute-call-recording-id-for-meet-conference.util.ts +16 -0
  104. package/src/logic-functions/utils/convert-google-doc-paragraph-to-markdown.util.ts +62 -0
  105. package/src/logic-functions/utils/convert-google-doc-tab-to-markdown.util.ts +49 -0
  106. package/src/logic-functions/utils/create-meet-event-subscription-or-throw.util.ts +41 -0
  107. package/src/logic-functions/utils/delete-meet-event-subscription.util.ts +22 -0
  108. package/src/logic-functions/utils/enqueue-meet-conference-imports-or-throw.util.ts +39 -0
  109. package/src/logic-functions/utils/enqueue-meet-daily-jobs-or-throw.util.ts +35 -0
  110. package/src/logic-functions/utils/ensure-meet-event-subscription-or-throw.util.ts +51 -0
  111. package/src/logic-functions/utils/escape-markdown-text.util.ts +4 -0
  112. package/src/logic-functions/utils/escape-sql-like-pattern.util.ts +2 -0
  113. package/src/logic-functions/utils/extract-bearer-token.util.ts +23 -0
  114. package/src/logic-functions/utils/extract-meet-name-from-doc-title.util.ts +16 -0
  115. package/src/logic-functions/utils/fetch-meet-json.util.ts +107 -0
  116. package/src/logic-functions/utils/find-call-recording-for-summary.util.ts +38 -0
  117. package/src/logic-functions/utils/find-call-recording-video-state.util.ts +25 -0
  118. package/src/logic-functions/utils/find-meet-calendar-event.util.ts +74 -0
  119. package/src/logic-functions/utils/find-meet-conference-title.util.ts +38 -0
  120. package/src/logic-functions/utils/find-meet-event-subscription.util.ts +32 -0
  121. package/src/logic-functions/utils/find-meet-smart-notes-markdown.util.ts +32 -0
  122. package/src/logic-functions/utils/format-seconds-as-clock-timestamp.util.ts +20 -0
  123. package/src/logic-functions/utils/get-conference-record-name-from-artifact-name.util.ts +6 -0
  124. package/src/logic-functions/utils/get-connection-access-token-or-throw.util.ts +18 -0
  125. package/src/logic-functions/utils/get-google-doc-title.util.ts +31 -0
  126. package/src/logic-functions/utils/get-google-doc.util.ts +30 -0
  127. package/src/logic-functions/utils/get-google-drive-file-size-bytes-or-throw.util.ts +31 -0
  128. package/src/logic-functions/utils/get-meet-conference-record.util.ts +18 -0
  129. package/src/logic-functions/utils/get-meet-connection-subscription-key.util.ts +3 -0
  130. package/src/logic-functions/utils/get-meet-event-subscription-key.util.ts +2 -0
  131. package/src/logic-functions/utils/get-meet-participant-display-name.util.ts +20 -0
  132. package/src/logic-functions/utils/get-meet-recording-drive-file-id.util.ts +16 -0
  133. package/src/logic-functions/utils/get-meet-recording.util.ts +18 -0
  134. package/src/logic-functions/utils/get-meet-space.util.ts +15 -0
  135. package/src/logic-functions/utils/get-random-delay-milliseconds.util.ts +4 -0
  136. package/src/logic-functions/utils/is-google-doc-unreadable-error.util.ts +9 -0
  137. package/src/logic-functions/utils/is-google-pubsub-push-authorized.util.ts +31 -0
  138. package/src/logic-functions/utils/is-meet-ai-summary-enabled-for-member.util.ts +22 -0
  139. package/src/logic-functions/utils/is-transcript-entry-list.util.ts +16 -0
  140. package/src/logic-functions/utils/join-google-doc-markdown-segments.util.ts +102 -0
  141. package/src/logic-functions/utils/list-calendar-events-in-window.util.ts +142 -0
  142. package/src/logic-functions/utils/list-meet-collection.util.ts +79 -0
  143. package/src/logic-functions/utils/list-meet-conference-records.util.ts +22 -0
  144. package/src/logic-functions/utils/list-meet-participants.util.ts +15 -0
  145. package/src/logic-functions/utils/list-meet-recordings.util.ts +15 -0
  146. package/src/logic-functions/utils/list-meet-smart-notes.util.ts +15 -0
  147. package/src/logic-functions/utils/list-meet-transcript-entries.util.ts +15 -0
  148. package/src/logic-functions/utils/list-meet-transcripts.util.ts +15 -0
  149. package/src/logic-functions/utils/map-meet-transcript-entries.util.ts +64 -0
  150. package/src/logic-functions/utils/normalize-meeting-url.util.ts +18 -0
  151. package/src/logic-functions/utils/open-google-drive-file-download-or-throw.util.ts +36 -0
  152. package/src/logic-functions/utils/parse-meet-call-summary-response.util.ts +36 -0
  153. package/src/logic-functions/utils/parse-meet-event-data-or-throw.util.ts +36 -0
  154. package/src/logic-functions/utils/parse-meet-event-or-throw.util.ts +35 -0
  155. package/src/logic-functions/utils/parse-retry-after-milliseconds.util.ts +27 -0
  156. package/src/logic-functions/utils/put-stream-to-upload-url-or-throw.util.ts +73 -0
  157. package/src/logic-functions/utils/read-meet-event-subscription-or-throw.util.ts +24 -0
  158. package/src/logic-functions/utils/release-meet-event-subscription.util.ts +29 -0
  159. package/src/logic-functions/utils/renew-meet-event-subscription-or-throw.util.ts +32 -0
  160. package/src/logic-functions/utils/run-meet-call-summarizer-or-throw.util.ts +28 -0
  161. package/src/logic-functions/utils/save-call-recording-summary-if-empty.util.ts +29 -0
  162. package/src/logic-functions/utils/save-call-recording-video.util.ts +23 -0
  163. package/src/logic-functions/utils/should-generate-meet-ai-summary.util.ts +17 -0
  164. package/src/logic-functions/utils/sleep-for-milliseconds.util.ts +2 -0
  165. package/src/logic-functions/utils/split-surrounding-whitespace.util.ts +10 -0
  166. package/src/logic-functions/utils/store-meet-connection-subscription.util.ts +46 -0
  167. package/src/logic-functions/utils/sync-meet-conference-or-throw.util.ts +129 -0
  168. package/src/logic-functions/utils/upload-google-drive-file-as-call-recording-video-or-throw.util.ts +73 -0
  169. package/src/logic-functions/utils/upsert-call-recording-or-throw.util.ts +104 -0
  170. package/src/logic-functions/utils/verify-google-pubsub-push-token-or-throw.util.ts +71 -0
  171. package/src/logic-functions/utils/wait-for-google-workspace-events-operation-or-throw.util.ts +53 -0
  172. package/tsconfig.json +39 -0
@@ -0,0 +1,1345 @@
1
+ import { createRequire as __createRequire } from 'module';
2
+ const require = __createRequire(import.meta.url);
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __commonJS = (cb, mod) => function __require() {
10
+ try {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ } catch (e3) {
13
+ throw mod = 0, e3;
14
+ }
15
+ };
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
+ // If the importer is in node compatibility mode or this is not an ESM
30
+ // file that has been converted to a CommonJS file using a Babel-
31
+ // compatible transform (i.e. "__esModule" has not been set), then set
32
+ // "default" to the CommonJS "module.exports" for node compatibility.
33
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
+ mod
35
+ ));
36
+
37
+ // node_modules/@sniptt/guards/build/guards/primitives.js
38
+ var require_primitives = __commonJS({
39
+ "node_modules/@sniptt/guards/build/guards/primitives.js"(exports) {
40
+ "use strict";
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.isSymbol = exports.isBigInt = exports.isString = exports.isNumber = exports.isBoolean = exports.isUndefined = void 0;
43
+ var isUndefined = (term) => {
44
+ return typeof term === "undefined";
45
+ };
46
+ exports.isUndefined = isUndefined;
47
+ var isBoolean = (term) => {
48
+ return typeof term === "boolean";
49
+ };
50
+ exports.isBoolean = isBoolean;
51
+ var isNumber = (term) => {
52
+ return typeof term === "number" && !Number.isNaN(term);
53
+ };
54
+ exports.isNumber = isNumber;
55
+ var isString = (term) => {
56
+ return typeof term === "string";
57
+ };
58
+ exports.isString = isString;
59
+ var isBigInt = (term) => {
60
+ return typeof term === "bigint";
61
+ };
62
+ exports.isBigInt = isBigInt;
63
+ var isSymbol = (term) => {
64
+ return typeof term === "symbol";
65
+ };
66
+ exports.isSymbol = isSymbol;
67
+ }
68
+ });
69
+
70
+ // node_modules/@sniptt/guards/build/guards/structural.js
71
+ var require_structural = __commonJS({
72
+ "node_modules/@sniptt/guards/build/guards/structural.js"(exports) {
73
+ "use strict";
74
+ Object.defineProperty(exports, "__esModule", { value: true });
75
+ exports.isDate = exports.isWeakSet = exports.isWeakMap = exports.isSet = exports.isMap = exports.isArray = exports.isObject = exports.isFunction = exports.isNull = void 0;
76
+ var isNull = (term) => {
77
+ return term === null;
78
+ };
79
+ exports.isNull = isNull;
80
+ var isFunction = (term) => {
81
+ return typeof term === "function";
82
+ };
83
+ exports.isFunction = isFunction;
84
+ var isObject3 = (term) => {
85
+ return !exports.isNull(term) && typeof term === "object";
86
+ };
87
+ exports.isObject = isObject3;
88
+ var isArray = (term) => {
89
+ return Array.isArray(term);
90
+ };
91
+ exports.isArray = isArray;
92
+ var isMap = (term) => {
93
+ return term instanceof Map;
94
+ };
95
+ exports.isMap = isMap;
96
+ var isSet = (term) => {
97
+ return term instanceof Set;
98
+ };
99
+ exports.isSet = isSet;
100
+ var isWeakMap = (term) => {
101
+ return term instanceof WeakMap;
102
+ };
103
+ exports.isWeakMap = isWeakMap;
104
+ var isWeakSet = (term) => {
105
+ return term instanceof WeakSet;
106
+ };
107
+ exports.isWeakSet = isWeakSet;
108
+ var isDate = (term) => {
109
+ return term instanceof Date;
110
+ };
111
+ exports.isDate = isDate;
112
+ }
113
+ });
114
+
115
+ // node_modules/@sniptt/guards/build/guards/convenience.js
116
+ var require_convenience = __commonJS({
117
+ "node_modules/@sniptt/guards/build/guards/convenience.js"(exports) {
118
+ "use strict";
119
+ Object.defineProperty(exports, "__esModule", { value: true });
120
+ exports.isNegativeInteger = exports.isNonNegativeInteger = exports.isPositiveInteger = exports.isInteger = exports.isNumberOrNaN = exports.isNonEmptyString = exports.isNonEmptyArray = exports.isObjectOrNull = void 0;
121
+ var primitives_1 = require_primitives();
122
+ var structural_1 = require_structural();
123
+ var isObjectOrNull = (term) => {
124
+ return typeof term === "object";
125
+ };
126
+ exports.isObjectOrNull = isObjectOrNull;
127
+ var isNonEmptyArray = (term) => {
128
+ return structural_1.isArray(term) && term.length > 0;
129
+ };
130
+ exports.isNonEmptyArray = isNonEmptyArray;
131
+ var isNonEmptyString6 = (term) => {
132
+ return primitives_1.isString(term) && term.length > 0;
133
+ };
134
+ exports.isNonEmptyString = isNonEmptyString6;
135
+ var isNumberOrNaN = (term) => {
136
+ return typeof term === "number";
137
+ };
138
+ exports.isNumberOrNaN = isNumberOrNaN;
139
+ var isInteger = (term) => {
140
+ return primitives_1.isNumber(term) && Number.isInteger(term);
141
+ };
142
+ exports.isInteger = isInteger;
143
+ var isPositiveInteger = (term) => {
144
+ return exports.isInteger(term) && term > 0;
145
+ };
146
+ exports.isPositiveInteger = isPositiveInteger;
147
+ var isNonNegativeInteger = (term) => {
148
+ return exports.isInteger(term) && term >= 0;
149
+ };
150
+ exports.isNonNegativeInteger = isNonNegativeInteger;
151
+ var isNegativeInteger = (term) => {
152
+ return exports.isInteger(term) && term < 0;
153
+ };
154
+ exports.isNegativeInteger = isNegativeInteger;
155
+ }
156
+ });
157
+
158
+ // node_modules/@sniptt/guards/build/index.js
159
+ var require_build = __commonJS({
160
+ "node_modules/@sniptt/guards/build/index.js"(exports) {
161
+ "use strict";
162
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o2, m, k, k2) {
163
+ if (k2 === void 0) k2 = k;
164
+ Object.defineProperty(o2, k2, { enumerable: true, get: function() {
165
+ return m[k];
166
+ } });
167
+ }) : (function(o2, m, k, k2) {
168
+ if (k2 === void 0) k2 = k;
169
+ o2[k2] = m[k];
170
+ }));
171
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o2, v2) {
172
+ Object.defineProperty(o2, "default", { enumerable: true, value: v2 });
173
+ }) : function(o2, v2) {
174
+ o2["default"] = v2;
175
+ });
176
+ var __importStar = exports && exports.__importStar || function(mod) {
177
+ if (mod && mod.__esModule) return mod;
178
+ var result = {};
179
+ if (mod != null) {
180
+ for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
181
+ }
182
+ __setModuleDefault(result, mod);
183
+ return result;
184
+ };
185
+ var __exportStar = exports && exports.__exportStar || function(m, exports2) {
186
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
187
+ };
188
+ Object.defineProperty(exports, "__esModule", { value: true });
189
+ exports.structural = exports.primitives = exports.convenience = void 0;
190
+ exports.convenience = __importStar(require_convenience());
191
+ __exportStar(require_convenience(), exports);
192
+ exports.primitives = __importStar(require_primitives());
193
+ __exportStar(require_primitives(), exports);
194
+ exports.structural = __importStar(require_structural());
195
+ __exportStar(require_structural(), exports);
196
+ }
197
+ });
198
+
199
+ // src/logic-functions/meet-events-resolver.ts
200
+ var import_guards7 = __toESM(require_build());
201
+
202
+ // twenty-sdk-define-stub:__twenty-sdk-define-stub__
203
+ var __defineFactoryStub = (config) => ({
204
+ success: true,
205
+ config,
206
+ errors: []
207
+ });
208
+ var __anyHandler = {
209
+ get(_target, prop) {
210
+ if (prop === "__esModule") return true;
211
+ if (prop === Symbol.toPrimitive) return () => "";
212
+ if (typeof prop === "symbol") return void 0;
213
+ return new Proxy(() => void 0, __anyHandler);
214
+ },
215
+ apply() {
216
+ return new Proxy(() => void 0, __anyHandler);
217
+ }
218
+ };
219
+ var __anyStub = new Proxy(() => void 0, __anyHandler);
220
+ var defineLogicFunction = __defineFactoryStub;
221
+
222
+ // node_modules/twenty-sdk/dist/logic-function/index.mjs
223
+ var import_guards = __toESM(require_build(), 1);
224
+ import { MetadataApiClient as o } from "twenty-client-sdk/metadata";
225
+ var h = "TWENTY_API_URL";
226
+ var g = "TWENTY_APP_ACCESS_TOKEN";
227
+ var ee = "TWENTY_APP_APPLICATION_ACCESS_TOKEN";
228
+ var te = "TWENTY_INTERNAL_API_URL";
229
+ var re = (e3) => {
230
+ let n3 = e3[te];
231
+ return (0, import_guards.isNonEmptyString)(n3) ? n3 : e3[h];
232
+ };
233
+ var v = () => process.env.TWENTY_APP_APPLICATION_ACCESS_TOKEN ?? process.env.TWENTY_APP_ACCESS_TOKEN;
234
+ var y = () => process.env.TWENTY_APP_ACCESS_TOKEN ?? process.env.TWENTY_APP_APPLICATION_ACCESS_TOKEN;
235
+ var b = ({ caller: e3, isActingAsCaller: n3 = false }) => {
236
+ let r2 = re(process.env), i2 = n3 ? y() : v();
237
+ if (!(0, import_guards.isNonEmptyString)(r2) || !(0, import_guards.isNonEmptyString)(i2)) throw Error(`${e3}() requires the app runtime env vars ${h} and ${ee} (or ${g}).`);
238
+ return {
239
+ apiUrl: r2,
240
+ accessToken: i2
241
+ };
242
+ };
243
+ var x = async ({ query: e3, variables: t3, caller: n3, signal: r2, isActingAsCaller: i2 = false }) => {
244
+ let { apiUrl: a2, accessToken: o2 } = b({
245
+ caller: n3,
246
+ isActingAsCaller: i2
247
+ }), s = await fetch(`${a2}/metadata`, {
248
+ method: "POST",
249
+ headers: {
250
+ "Content-Type": "application/json",
251
+ Authorization: `Bearer ${o2}`
252
+ },
253
+ body: JSON.stringify({
254
+ query: e3,
255
+ variables: t3
256
+ }),
257
+ signal: r2
258
+ });
259
+ if (!s.ok) throw Error(`${n3}() failed: HTTP ${s.status} ${s.statusText}`);
260
+ let c = await s.json();
261
+ if (c.errors && c.errors.length > 0) throw Error(`${n3}() failed: ${c.errors.map((e4) => e4.message).join(", ")}`);
262
+ if (!c.data) throw Error(`${n3}() failed: response contained no data.`);
263
+ return c.data;
264
+ };
265
+ var S = ({ objectNameSingular: e3, recordId: t3, displayName: n3 }) => `[[record:${e3}:${t3}:${n3}]]`;
266
+ var C = "\n id\n handle\n displayName\n visibility\n connectedAccountId\n isSyncEnabled\n participantHandleFieldUniversalIdentifier\n messagingProviderUniversalIdentifier\n";
267
+ var w = `
268
+ mutation CreateAppMessageChannel($input: CreateAppMessageChannelInput!) {
269
+ createAppMessageChannel(input: $input) {
270
+ ${C}
271
+ }
272
+ }
273
+ `;
274
+ var E = `
275
+ query ListAppMessageChannels($filter: ListAppMessageChannelsInput) {
276
+ appMessageChannels(filter: $filter) {
277
+ ${C}
278
+ }
279
+ }
280
+ `;
281
+ var O = `
282
+ mutation UpdateAppMessageChannel($input: UpdateAppMessageChannelInput!) {
283
+ updateAppMessageChannel(input: $input) {
284
+ ${C}
285
+ }
286
+ }
287
+ `;
288
+ var A = `
289
+ mutation DeleteAppMessageChannel($id: UUID!) {
290
+ deleteAppMessageChannel(id: $id) {
291
+ ${C}
292
+ }
293
+ }
294
+ `;
295
+ var L = "\n id\n externalId\n name\n isSynced\n messageChannelId\n";
296
+ var R = `
297
+ query ListAppMessageFolders($filter: ListAppMessageFoldersInput) {
298
+ appMessageFolders(filter: $filter) {
299
+ ${L}
300
+ }
301
+ }
302
+ `;
303
+ var B = `
304
+ mutation SyncAppMessageFolders($input: SyncAppMessageFoldersInput!) {
305
+ syncAppMessageFolders(input: $input) {
306
+ ${L}
307
+ }
308
+ }
309
+ `;
310
+ var U = "agentChatAssistant";
311
+ var ze = S({
312
+ objectNameSingular: U,
313
+ recordId: U,
314
+ displayName: "Ada"
315
+ });
316
+ var qe = "\n query GetAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n appKeyValue(key: $key, scope: $scope) {\n key\n value\n scope\n }\n }\n";
317
+ var Je = "\n mutation SetAppKeyValue($input: SetAppKeyValueInput!) {\n setAppKeyValue(input: $input) {\n key\n value\n scope\n }\n }\n";
318
+ var Ye = "\n mutation DeleteAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n deleteAppKeyValue(key: $key, scope: $scope)\n }\n";
319
+ var $ = "WORKSPACE";
320
+ var Xe = {
321
+ async get(e3, t3) {
322
+ let { appKeyValue: n3 } = await x({
323
+ query: qe,
324
+ variables: {
325
+ key: e3,
326
+ scope: t3?.scope ?? $
327
+ },
328
+ caller: "kv.get"
329
+ });
330
+ return n3?.value ?? null;
331
+ },
332
+ async set(e3, t3, n3) {
333
+ await x({
334
+ query: Je,
335
+ variables: { input: {
336
+ key: e3,
337
+ value: t3,
338
+ scope: n3?.scope ?? $
339
+ } },
340
+ caller: "kv.set"
341
+ });
342
+ },
343
+ async delete(e3, t3) {
344
+ let { deleteAppKeyValue: n3 } = await x({
345
+ query: Ye,
346
+ variables: {
347
+ key: e3,
348
+ scope: t3?.scope ?? $
349
+ },
350
+ caller: "kv.delete"
351
+ });
352
+ return n3;
353
+ }
354
+ };
355
+ var Ze = class {
356
+ constructor(e3, t3) {
357
+ this.__twentyHttpResponse = true, this.body = e3, this.status = t3?.status, this.headers = t3?.headers;
358
+ }
359
+ };
360
+
361
+ // node_modules/twenty-sdk/dist/utils/index.mjs
362
+ var import_guards2 = __toESM(require_build(), 1);
363
+ var l = (e3) => !(0, import_guards2.isUndefined)(e3) && !(0, import_guards2.isNull)(e3);
364
+
365
+ // src/constants/meet.constant.ts
366
+ var MEET_PUBSUB_AUDIENCE_SERVER_VARIABLE_NAME = "GOOGLE_MEET_PUBSUB_AUDIENCE";
367
+ var MEET_PUBSUB_SERVICE_ACCOUNT_EMAIL_SERVER_VARIABLE_NAME = "GOOGLE_MEET_PUBSUB_SERVICE_ACCOUNT_EMAIL";
368
+
369
+ // src/constants/universal-identifiers.ts
370
+ var MEET_HANDLE_EVENT_UNIVERSAL_IDENTIFIER = "7f40cfd3-93f1-4e50-9846-e25b4119c8f9";
371
+ var MEET_EVENTS_RESOLVER_UNIVERSAL_IDENTIFIER = "99d08b46-5857-4d4c-bf6a-62ccf90305cd";
372
+
373
+ // src/logic-functions/utils/get-meet-event-subscription-key.util.ts
374
+ var getMeetEventSubscriptionKey = (subscriptionName) => `google-meet-event-subscription:${subscriptionName}`;
375
+
376
+ // src/logic-functions/types/meet-exception.type.ts
377
+ var MeetException = class extends Error {
378
+ constructor({
379
+ message: message2,
380
+ code,
381
+ httpStatus,
382
+ googleStatus
383
+ }) {
384
+ super(message2);
385
+ this.name = "MeetException";
386
+ this.code = code;
387
+ this.httpStatus = httpStatus;
388
+ this.googleStatus = googleStatus;
389
+ }
390
+ };
391
+
392
+ // src/logic-functions/utils/verify-google-pubsub-push-token-or-throw.util.ts
393
+ var import_guards4 = __toESM(require_build());
394
+
395
+ // node_modules/jose/dist/webapi/lib/buffer_utils.js
396
+ var encoder = new TextEncoder();
397
+ var decoder = new TextDecoder();
398
+ var strictDecoder = new TextDecoder("utf-8", { fatal: true });
399
+ var UINT32_RANGE = 2 ** 32;
400
+ function concat(...buffers) {
401
+ const size = buffers.reduce((acc, { length }) => acc + length, 0), buf = new Uint8Array(size);
402
+ let i2 = 0;
403
+ for (const buffer of buffers)
404
+ buf.set(buffer, i2), i2 += buffer.length;
405
+ return buf;
406
+ }
407
+ var NON_ASCII = /[^\x00-\x7f]/;
408
+ function encode(string) {
409
+ if (typeof string == "string" && string.length >= 128) {
410
+ if (NON_ASCII.test(string))
411
+ throw new TypeError("non-ASCII string encountered in encode()");
412
+ return encoder.encode(string);
413
+ }
414
+ const bytes = new Uint8Array(string.length);
415
+ for (let i2 = 0; i2 < string.length; i2++) {
416
+ const code = string.charCodeAt(i2);
417
+ if (code > 127)
418
+ throw new TypeError("non-ASCII string encountered in encode()");
419
+ bytes[i2] = code;
420
+ }
421
+ return bytes;
422
+ }
423
+ function decodeBase64(encoded, url = false) {
424
+ if (Uint8Array.fromBase64)
425
+ return Uint8Array.fromBase64(encoded, { alphabet: url ? "base64url" : "base64" });
426
+ if (url) {
427
+ if (encoded.includes("+") || encoded.includes("/"))
428
+ throw new TypeError("Invalid base64url");
429
+ encoded = encoded.replace(/-/g, "+").replace(/_/g, "/");
430
+ }
431
+ const binary = atob(encoded), bytes = new Uint8Array(binary.length);
432
+ for (let i2 = 0; i2 < binary.length; i2++)
433
+ bytes[i2] = binary.charCodeAt(i2);
434
+ return bytes;
435
+ }
436
+
437
+ // node_modules/jose/dist/webapi/util/errors.js
438
+ var errors_exports = {};
439
+ __export(errors_exports, {
440
+ JOSEAlgNotAllowed: () => JOSEAlgNotAllowed,
441
+ JOSEError: () => JOSEError,
442
+ JOSENotSupported: () => JOSENotSupported,
443
+ JWEDecryptionFailed: () => JWEDecryptionFailed,
444
+ JWEInvalid: () => JWEInvalid,
445
+ JWKInvalid: () => JWKInvalid,
446
+ JWKSInvalid: () => JWKSInvalid,
447
+ JWKSMultipleMatchingKeys: () => JWKSMultipleMatchingKeys,
448
+ JWKSNoMatchingKey: () => JWKSNoMatchingKey,
449
+ JWKSTimeout: () => JWKSTimeout,
450
+ JWSInvalid: () => JWSInvalid,
451
+ JWSSignatureVerificationFailed: () => JWSSignatureVerificationFailed,
452
+ JWTClaimValidationFailed: () => JWTClaimValidationFailed,
453
+ JWTExpired: () => JWTExpired,
454
+ JWTInvalid: () => JWTInvalid
455
+ });
456
+ var JOSEError = class extends Error {
457
+ static code = "ERR_JOSE_GENERIC";
458
+ code = "ERR_JOSE_GENERIC";
459
+ constructor(message2, options) {
460
+ super(message2, options), this.name = this.constructor.name, Error.captureStackTrace?.(this, this.constructor);
461
+ }
462
+ };
463
+ var JWTClaimValidationFailed = class extends JOSEError {
464
+ static code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
465
+ code = "ERR_JWT_CLAIM_VALIDATION_FAILED";
466
+ claim;
467
+ reason;
468
+ payload;
469
+ constructor(message2, payload, claim = "unspecified", reason = "unspecified") {
470
+ super(message2, { cause: { claim, reason, payload } }), this.claim = claim, this.reason = reason, this.payload = payload;
471
+ }
472
+ };
473
+ var JWTExpired = class extends JOSEError {
474
+ static code = "ERR_JWT_EXPIRED";
475
+ code = "ERR_JWT_EXPIRED";
476
+ claim;
477
+ reason;
478
+ payload;
479
+ constructor(message2, payload, claim = "unspecified", reason = "unspecified") {
480
+ super(message2, { cause: { claim, reason, payload } }), this.claim = claim, this.reason = reason, this.payload = payload;
481
+ }
482
+ };
483
+ var JOSEAlgNotAllowed = class extends JOSEError {
484
+ static code = "ERR_JOSE_ALG_NOT_ALLOWED";
485
+ code = "ERR_JOSE_ALG_NOT_ALLOWED";
486
+ };
487
+ var JOSENotSupported = class extends JOSEError {
488
+ static code = "ERR_JOSE_NOT_SUPPORTED";
489
+ code = "ERR_JOSE_NOT_SUPPORTED";
490
+ };
491
+ var JWEDecryptionFailed = class extends JOSEError {
492
+ static code = "ERR_JWE_DECRYPTION_FAILED";
493
+ code = "ERR_JWE_DECRYPTION_FAILED";
494
+ constructor(message2 = "decryption operation failed", options) {
495
+ super(message2, options);
496
+ }
497
+ };
498
+ var JWEInvalid = class extends JOSEError {
499
+ static code = "ERR_JWE_INVALID";
500
+ code = "ERR_JWE_INVALID";
501
+ };
502
+ var JWSInvalid = class extends JOSEError {
503
+ static code = "ERR_JWS_INVALID";
504
+ code = "ERR_JWS_INVALID";
505
+ };
506
+ var JWTInvalid = class extends JOSEError {
507
+ static code = "ERR_JWT_INVALID";
508
+ code = "ERR_JWT_INVALID";
509
+ };
510
+ var JWKInvalid = class extends JOSEError {
511
+ static code = "ERR_JWK_INVALID";
512
+ code = "ERR_JWK_INVALID";
513
+ };
514
+ var JWKSInvalid = class extends JOSEError {
515
+ static code = "ERR_JWKS_INVALID";
516
+ code = "ERR_JWKS_INVALID";
517
+ };
518
+ var JWKSNoMatchingKey = class extends JOSEError {
519
+ static code = "ERR_JWKS_NO_MATCHING_KEY";
520
+ code = "ERR_JWKS_NO_MATCHING_KEY";
521
+ constructor(message2 = "no applicable key found in the JSON Web Key Set", options) {
522
+ super(message2, options);
523
+ }
524
+ };
525
+ var JWKSMultipleMatchingKeys = class extends JOSEError {
526
+ [Symbol.asyncIterator] = async function* () {
527
+ };
528
+ static code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
529
+ code = "ERR_JWKS_MULTIPLE_MATCHING_KEYS";
530
+ constructor(message2 = "multiple matching keys found in the JSON Web Key Set", options) {
531
+ super(message2, options);
532
+ }
533
+ };
534
+ var JWKSTimeout = class extends JOSEError {
535
+ static code = "ERR_JWKS_TIMEOUT";
536
+ code = "ERR_JWKS_TIMEOUT";
537
+ constructor(message2 = "request timed out", options) {
538
+ super(message2, options);
539
+ }
540
+ };
541
+ var JWSSignatureVerificationFailed = class extends JOSEError {
542
+ static code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
543
+ code = "ERR_JWS_SIGNATURE_VERIFICATION_FAILED";
544
+ constructor(message2 = "signature verification failed", options) {
545
+ super(message2, options);
546
+ }
547
+ };
548
+
549
+ // node_modules/jose/dist/webapi/util/base64url.js
550
+ var invalid = "The input to be decoded is not correctly encoded.";
551
+ function decode(input) {
552
+ try {
553
+ return decodeBase64(typeof input == "string" ? input : decoder.decode(input), true);
554
+ } catch (cause) {
555
+ throw new TypeError(invalid, { cause });
556
+ }
557
+ }
558
+
559
+ // node_modules/jose/dist/webapi/lib/validate.js
560
+ function isObject(input) {
561
+ if (typeof input != "object" || input === null || Object.prototype.toString.call(input) !== "[object Object]")
562
+ return false;
563
+ const prototype = Object.getPrototypeOf(input);
564
+ return prototype === null || Object.getPrototypeOf(prototype) === null;
565
+ }
566
+ function isJwkSet(input) {
567
+ return isObject(input) && Array.isArray(input.keys) && Array.from(input.keys).every(isObject);
568
+ }
569
+ function isDisjoint(...headers) {
570
+ const parameters = /* @__PURE__ */ new Set();
571
+ for (const header of headers)
572
+ if (header)
573
+ for (const parameter of Object.keys(header)) {
574
+ if (parameters.has(parameter))
575
+ return false;
576
+ parameters.add(parameter);
577
+ }
578
+ return true;
579
+ }
580
+ function decodeBase64url(value, label, ErrorClass) {
581
+ try {
582
+ return decode(value);
583
+ } catch (cause) {
584
+ throw new ErrorClass(`Failed to base64url decode the ${label}`, { cause });
585
+ }
586
+ }
587
+ function encodeAsciiMember(value, label, ErrorClass) {
588
+ try {
589
+ return encode(value);
590
+ } catch (cause) {
591
+ throw new ErrorClass(`The ${label} is not a valid base64url string`, { cause });
592
+ }
593
+ }
594
+ function parseJoseHeader(encodedProtectedHeader, ErrorClass, message2) {
595
+ let parsed;
596
+ try {
597
+ parsed = JSON.parse(strictDecoder.decode(decode(encodedProtectedHeader)));
598
+ } catch (cause) {
599
+ throw new ErrorClass(message2, { cause });
600
+ }
601
+ if (!isObject(parsed))
602
+ throw new ErrorClass(message2);
603
+ return parsed;
604
+ }
605
+ var JWS_RECOGNIZED = { __proto__: null, b64: true };
606
+ function validateAlgorithms(option, algorithms) {
607
+ if (algorithms !== void 0 && (!Array.isArray(algorithms) || algorithms.some((s) => typeof s != "string")))
608
+ throw new TypeError(`"${option}" option must be an array of strings`);
609
+ return algorithms === void 0 ? void 0 : new Set(algorithms);
610
+ }
611
+ function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {
612
+ if (joseHeader.crit !== void 0 && protectedHeader?.crit === void 0)
613
+ throw new Err('"crit" (Critical) Header Parameter MUST be integrity protected');
614
+ if (!protectedHeader || protectedHeader.crit === void 0)
615
+ return [];
616
+ if (!Array.isArray(protectedHeader.crit) || protectedHeader.crit.length === 0 || protectedHeader.crit.some((input) => typeof input != "string" || input.length === 0))
617
+ throw new Err('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');
618
+ const recognized = recognizedOption === void 0 ? recognizedDefault : { __proto__: null, ...recognizedOption, ...recognizedDefault };
619
+ for (const parameter of protectedHeader.crit) {
620
+ if (!(parameter in recognized))
621
+ throw new JOSENotSupported(`Extension Header Parameter "${parameter}" is not recognized`);
622
+ if (!Object.hasOwn(joseHeader, parameter) || joseHeader[parameter] === void 0)
623
+ throw new Err(`Extension Header Parameter "${parameter}" is missing`);
624
+ if (recognized[parameter] && (!Object.hasOwn(protectedHeader, parameter) || protectedHeader[parameter] === void 0))
625
+ throw new Err(`Extension Header Parameter "${parameter}" MUST be integrity protected`);
626
+ }
627
+ return protectedHeader.crit;
628
+ }
629
+ function validateB64(protectedHeader, extensions) {
630
+ if (extensions.includes("b64")) {
631
+ const b64 = protectedHeader.b64;
632
+ if (typeof b64 != "boolean")
633
+ throw new JWSInvalid('The "b64" (base64url-encode payload) Header Parameter must be a boolean');
634
+ return b64;
635
+ }
636
+ return true;
637
+ }
638
+
639
+ // node_modules/jose/dist/webapi/lib/key.js
640
+ var tag = (key) => key[Symbol.toStringTag];
641
+ var jwkMatchesOp = (entry, key, usage) => {
642
+ const { alg } = entry;
643
+ if (key.use !== void 0) {
644
+ const expected = usage === "sign" || usage === "verify" ? "sig" : "enc";
645
+ if (key.use !== expected)
646
+ throw new TypeError(`Invalid key for this operation, its "use" must be "${expected}" when present`);
647
+ }
648
+ if (key.alg !== void 0 && key.alg !== alg)
649
+ throw new TypeError(`Invalid key for this operation, its "alg" must be "${alg}" when present`);
650
+ if (Array.isArray(key.key_ops)) {
651
+ const expectedKeyOp = usage === "encrypt" || usage === "decrypt" ? entry.ops?.[usage === "encrypt" ? 0 : 1] : usage;
652
+ if (expectedKeyOp && !key.key_ops.includes(expectedKeyOp))
653
+ throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${expectedKeyOp}" when present`);
654
+ }
655
+ };
656
+ async function prepareKey(entry, key, usage) {
657
+ const { alg, secret } = entry, requiresPrivateKey = usage === "decrypt" || usage === "sign";
658
+ if (secret && key instanceof Uint8Array)
659
+ return key;
660
+ let normalized, keyObject;
661
+ if (isObject(key)) {
662
+ if (normalized = normalizeJwk(key), typeof normalized.kty != "string")
663
+ throw invalidKeyType(alg, key, secret);
664
+ if (!(secret ? normalized.kty === "oct" && typeof normalized.k == "string" : normalized.kty !== "oct" && (requiresPrivateKey ? normalized.kty === "AKP" && typeof normalized.priv == "string" || typeof normalized.d == "string" : normalized.d === void 0 && normalized.priv === void 0)))
665
+ throw new TypeError(secret ? 'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present' : `JSON Web Key for this operation must be a ${requiresPrivateKey ? "private" : "public"} JWK`);
666
+ if (jwkMatchesOp(entry, normalized, usage), normalized.kty === "oct")
667
+ return decode(normalized.k);
668
+ if (!Object.isFrozen(key)) {
669
+ const { key_ops } = key;
670
+ Array.isArray(key_ops) && Object.freeze(key_ops), Object.freeze(key);
671
+ }
672
+ } else {
673
+ if (!isKeyLike(key))
674
+ throw invalidKeyType(alg, key, secret);
675
+ const expectedType = secret ? "secret" : requiresPrivateKey ? "private" : "public";
676
+ if (key.type !== expectedType && (secret || ["secret", "public", "private"].includes(key.type)))
677
+ throw new TypeError(`${tag(key)} instances must be of type "${expectedType}" for the ${alg} algorithm`);
678
+ if (isCryptoKey(key))
679
+ return key;
680
+ if (keyObject = key, keyObject.type === "secret")
681
+ return keyObject.export();
682
+ }
683
+ cache ||= /* @__PURE__ */ new WeakMap();
684
+ const cacheKey = key;
685
+ let cached = cache.get(cacheKey);
686
+ if (cached?.[alg])
687
+ return cached[alg];
688
+ if (cached || cache.set(cacheKey, cached = {}), keyObject && typeof keyObject.toCryptoKey == "function") {
689
+ const isPublic = keyObject.type === "public", crv = nist[keyObject.asymmetricKeyDetails?.namedCurve], params = entry.resolve?.({ crv, asymmetricKeyType: keyObject.asymmetricKeyType }) ?? entry.subtle;
690
+ return cached[alg] = keyObject.toCryptoKey(params, isPublic, entry.usages[isPublic ? 0 : 1]);
691
+ }
692
+ return normalized ??= keyObject.export({ format: "jwk" }), normalized.alg = alg, cached[alg] = await jwkToKey(entry, normalized);
693
+ }
694
+ var cache;
695
+ var nist = {
696
+ __proto__: null,
697
+ prime256v1: "P-256",
698
+ secp384r1: "P-384",
699
+ secp521r1: "P-521"
700
+ };
701
+ var isCryptoKey = (key) => {
702
+ if (key?.[Symbol.toStringTag] === "CryptoKey")
703
+ return true;
704
+ try {
705
+ return key instanceof CryptoKey;
706
+ } catch {
707
+ return false;
708
+ }
709
+ };
710
+ var isKeyObject = (key) => key?.[Symbol.toStringTag] === "KeyObject";
711
+ var isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);
712
+ function message(msg, actual, ...types) {
713
+ if (types.length > 2) {
714
+ const last = types.pop();
715
+ msg += `one of type ${types.join(", ")}, or ${last}.`;
716
+ } else types.length === 2 ? msg += `one of type ${types[0]} or ${types[1]}.` : msg += `of type ${types[0]}.`;
717
+ return actual == null ? msg += ` Received ${actual}` : typeof actual == "function" && actual.name ? msg += ` Received function ${actual.name}` : typeof actual == "object" && actual != null && actual.constructor?.name && (msg += ` Received an instance of ${actual.constructor.name}`), msg;
718
+ }
719
+ function invalidKeyType(alg, actual, secret) {
720
+ const types = ["CryptoKey", "KeyObject", "JSON Web Key"];
721
+ return secret && types.push("Uint8Array"), new TypeError(message(`Key for the ${alg} algorithm must be `, actual, ...types));
722
+ }
723
+ var unusable = (name, prop = "algorithm.name") => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);
724
+ function checkUsage(key, usage) {
725
+ if (usage && !key.usages.includes(usage))
726
+ throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);
727
+ }
728
+ function checkModulusLength(alg, key) {
729
+ const { modulusLength } = key.algorithm;
730
+ if (typeof modulusLength != "number" || modulusLength < 2048)
731
+ throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);
732
+ }
733
+ function checkCryptoKey(key, expected, usage) {
734
+ const algorithm = key.algorithm;
735
+ if (algorithm.name !== expected.name)
736
+ throw unusable(expected.name);
737
+ if (expected.hash && algorithm.hash?.name !== expected.hash)
738
+ throw unusable(expected.hash, "algorithm.hash");
739
+ if (expected.namedCurve && algorithm.namedCurve !== expected.namedCurve)
740
+ throw unusable(expected.namedCurve, "algorithm.namedCurve");
741
+ if (expected.length !== void 0 && algorithm.length !== expected.length)
742
+ throw unusable(expected.length, "algorithm.length");
743
+ checkUsage(key, usage);
744
+ }
745
+ function snapshotJwk(jwk) {
746
+ return { __proto__: null, ...jwk };
747
+ }
748
+ function normalizeJwk(jwk) {
749
+ const normalized = snapshotJwk(jwk);
750
+ if (normalized.ext !== void 0 && typeof normalized.ext != "boolean")
751
+ throw new TypeError('"ext" (Extractable) Parameter must be a boolean');
752
+ if (normalized.key_ops !== void 0) {
753
+ const value = normalized.key_ops, keyOps = Array.isArray(value) ? [...value] : void 0;
754
+ if (!keyOps || keyOps.some((operation) => typeof operation != "string") || new Set(keyOps).size !== keyOps.length)
755
+ throw new TypeError('"key_ops" (Key Operations) Parameter must be an array of unique strings');
756
+ normalized.key_ops = keyOps;
757
+ }
758
+ return normalized;
759
+ }
760
+ async function jwkToKey(entry, jwk, extractable) {
761
+ if (!entry.kty.includes(jwk.kty))
762
+ throw new JOSENotSupported('Invalid or unsupported JWK "alg" (Algorithm) Parameter value');
763
+ const algorithm = entry.resolve?.({ kty: jwk.kty, crv: jwk.crv }) ?? entry.subtle, isPrivate = !!(jwk.d || jwk.priv), keyData = { ...jwk, ext: extractable ?? jwk.ext };
764
+ return keyData.kty !== "AKP" && delete keyData.alg, delete keyData.use, crypto.subtle.importKey("jwk", keyData, algorithm, keyData.ext ?? !isPrivate, jwk.key_ops ?? entry.usages[isPrivate ? 1 : 0]);
765
+ }
766
+ async function rawKey(key, expected, usage, extractable = false) {
767
+ return key instanceof Uint8Array && (key = await crypto.subtle.importKey("raw", key, expected, extractable, [usage])), checkCryptoKey(key, expected, usage), key;
768
+ }
769
+
770
+ // node_modules/jose/dist/webapi/lib/key_descriptor.js
771
+ function table(entries) {
772
+ const out = { __proto__: null };
773
+ for (const alg in entries)
774
+ out[alg] = { ...entries[alg], alg };
775
+ return out;
776
+ }
777
+
778
+ // node_modules/jose/dist/webapi/lib/jws_algorithms.js
779
+ var sig = [["verify"], ["sign"]];
780
+ function hmac(bits) {
781
+ const subtle = { name: "HMAC", hash: `SHA-${bits}` };
782
+ return { kty: ["oct"], secret: true, subtle, signing: subtle, usages: sig };
783
+ }
784
+ function rsa(bits, saltLength) {
785
+ const subtle = { name: saltLength ? "RSA-PSS" : "RSASSA-PKCS1-v1_5", hash: `SHA-${bits}` };
786
+ return {
787
+ kty: ["RSA"],
788
+ subtle,
789
+ signing: saltLength ? { ...subtle, saltLength } : subtle,
790
+ usages: sig,
791
+ minRsaBits: 2048
792
+ };
793
+ }
794
+ function ecdsa(crv, bits) {
795
+ return {
796
+ kty: ["EC"],
797
+ crv,
798
+ subtle: { name: "ECDSA", namedCurve: crv },
799
+ signing: { name: "ECDSA", hash: `SHA-${bits}` },
800
+ usages: sig
801
+ };
802
+ }
803
+ function eddsa() {
804
+ const subtle = { name: "Ed25519" };
805
+ return {
806
+ kty: ["OKP"],
807
+ crv: "Ed25519",
808
+ subtle,
809
+ signing: subtle,
810
+ usages: sig
811
+ };
812
+ }
813
+ function mldsa(parameterSet) {
814
+ const subtle = { name: `ML-DSA-${parameterSet}` };
815
+ return {
816
+ kty: ["AKP"],
817
+ subtle,
818
+ signing: subtle,
819
+ usages: sig
820
+ };
821
+ }
822
+ var JWS = table({
823
+ HS256: hmac(256),
824
+ HS384: hmac(384),
825
+ HS512: hmac(512),
826
+ RS256: rsa(256),
827
+ RS384: rsa(384),
828
+ RS512: rsa(512),
829
+ PS256: rsa(256, 32),
830
+ PS384: rsa(384, 48),
831
+ PS512: rsa(512, 64),
832
+ ES256: ecdsa("P-256", 256),
833
+ ES384: ecdsa("P-384", 384),
834
+ ES512: ecdsa("P-521", 512),
835
+ EdDSA: eddsa(),
836
+ Ed25519: eddsa(),
837
+ "ML-DSA-44": mldsa(44),
838
+ "ML-DSA-65": mldsa(65),
839
+ "ML-DSA-87": mldsa(87)
840
+ });
841
+ function jwsAlgorithm(alg) {
842
+ const entry = typeof alg == "string" ? JWS[alg] : void 0;
843
+ if (!entry)
844
+ throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);
845
+ return entry;
846
+ }
847
+
848
+ // node_modules/jose/dist/webapi/lib/jws_verify.js
849
+ function prepareVerify(options) {
850
+ return [options && validateAlgorithms("algorithms", options.algorithms), options?.crit];
851
+ }
852
+ function parseProtectedHeader(encodedProtectedHeader) {
853
+ return encodedProtectedHeader === void 0 ? {} : parseJoseHeader(encodedProtectedHeader, JWSInvalid, "JWS Protected Header is invalid");
854
+ }
855
+ function encodeCompactUnencodedPayload(payload) {
856
+ try {
857
+ return encode(payload);
858
+ } catch (cause) {
859
+ throw new JWSInvalid("JWS Compact Serialization payload must use only ASCII characters", {
860
+ cause
861
+ });
862
+ }
863
+ }
864
+ async function verifySignature(jws, shared, key, encodeUnencodedPayload, parsedProtected) {
865
+ const { protected: encodedProtectedHeader, header, payload: inputPayload } = jws, protectedHeader = parsedProtected ?? parseProtectedHeader(encodedProtectedHeader);
866
+ if (!isDisjoint(protectedHeader, header))
867
+ throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
868
+ const joseHeader = { ...protectedHeader, ...header }, b64 = validateB64(protectedHeader, validateCrit(JWSInvalid, JWS_RECOGNIZED, shared[1], protectedHeader, joseHeader)), { alg } = joseHeader;
869
+ if (typeof alg != "string" || !alg)
870
+ throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
871
+ if (shared[0] && !shared[0].has(alg))
872
+ throw new JOSEAlgNotAllowed('"alg" (Algorithm) Header Parameter value not allowed');
873
+ if (b64) {
874
+ if (typeof inputPayload != "string")
875
+ throw new JWSInvalid("JWS Payload must be a string");
876
+ } else if (typeof inputPayload != "string" && !(inputPayload instanceof Uint8Array))
877
+ throw new JWSInvalid("JWS Payload must be a string or an Uint8Array instance");
878
+ const signingPayload = b64 || typeof inputPayload != "string" ? inputPayload : encodeUnencodedPayload(inputPayload);
879
+ let resolvedKey = false;
880
+ typeof key == "function" && (key = await key(protectedHeader, jws), resolvedKey = true);
881
+ const entry = jwsAlgorithm(alg), signingInput = concat(encodedProtectedHeader !== void 0 ? encode(encodedProtectedHeader) : new Uint8Array(), encode("."), typeof signingPayload == "string" ? shared[2] ??= encodeAsciiMember(signingPayload, "payload", JWSInvalid) : signingPayload), signature = decodeBase64url(jws.signature, "signature", JWSInvalid), verificationKey = await prepareKey(entry, key, "verify"), cryptoKey = await rawKey(verificationKey, entry.subtle, "verify");
882
+ entry.minRsaBits && checkModulusLength(entry.alg, cryptoKey);
883
+ let verified = false;
884
+ try {
885
+ verified = await crypto.subtle.verify(entry.signing, cryptoKey, signature, signingInput);
886
+ } catch (cause) {
887
+ throw new JWSSignatureVerificationFailed(void 0, { cause });
888
+ }
889
+ if (!verified)
890
+ throw new JWSSignatureVerificationFailed();
891
+ const result = { payload: typeof signingPayload == "string" ? decodeBase64url(signingPayload, "payload", JWSInvalid) : signingPayload };
892
+ return encodedProtectedHeader !== void 0 && (result.protectedHeader = protectedHeader), header !== void 0 && (result.unprotectedHeader = header), resolvedKey ? [{ ...result, key: verificationKey }, b64] : [result, b64];
893
+ }
894
+ async function verifyCompact(jws, shared, key) {
895
+ if (jws instanceof Uint8Array && (jws = decoder.decode(jws)), typeof jws != "string")
896
+ throw new JWSInvalid("Compact JWS must be a string or Uint8Array");
897
+ const { 0: protectedHeader, 1: payload, 2: signature, length } = jws.split(".");
898
+ if (length !== 3)
899
+ throw new JWSInvalid("Invalid Compact JWS");
900
+ return verifySignature({ payload, protected: protectedHeader, signature }, shared, key, encodeCompactUnencodedPayload);
901
+ }
902
+
903
+ // node_modules/jose/dist/webapi/lib/jwt_claims_set.js
904
+ var epoch = (date) => Math.floor(date.getTime() / 1e3);
905
+ var multipliers = {
906
+ s: 1,
907
+ m: 60,
908
+ h: 3600,
909
+ d: 86400,
910
+ w: 604800,
911
+ y: 31557600
912
+ };
913
+ var REGEX = /^(\+|\-)? ?(\d+|\d+\.\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;
914
+ var checkFailed = "check_failed";
915
+ function invalidDuration() {
916
+ throw new TypeError("Invalid time period format");
917
+ }
918
+ function secs(str) {
919
+ typeof str != "string" && invalidDuration();
920
+ const matched = REGEX.exec(str);
921
+ (!matched || matched[4] && matched[1]) && invalidDuration();
922
+ const value = parseFloat(matched[2]), durationSeconds = Math.round(value * multipliers[matched[3][0].toLowerCase()]);
923
+ return Number.isFinite(durationSeconds) || invalidDuration(), matched[1] === "-" || matched[4] === "ago" ? -durationSeconds : durationSeconds;
924
+ }
925
+ function validateInput(label, input) {
926
+ if (!Number.isFinite(input))
927
+ throw new TypeError(`Invalid ${label} input`);
928
+ return input;
929
+ }
930
+ var normalizeTyp = (value) => {
931
+ const normalized = value.toLowerCase();
932
+ return value.includes("/") ? normalized : `application/${normalized}`;
933
+ };
934
+ var checkAudiencePresence = (audPayload, audOption) => typeof audPayload == "string" ? audOption.includes(audPayload) : Array.isArray(audPayload) ? audOption.some((aud) => audPayload.includes(aud)) : false;
935
+ function validateNumericDate(claimsSet, claim, required = false) {
936
+ const value = claimsSet[claim];
937
+ if (!(value === void 0 && !required)) {
938
+ if (typeof value != "number")
939
+ throw new JWTClaimValidationFailed(`"${claim}" claim must be a number`, claimsSet, claim, "invalid");
940
+ return value;
941
+ }
942
+ }
943
+ function unexpectedClaim(claimsSet, claim) {
944
+ throw new JWTClaimValidationFailed(`unexpected "${claim}" claim value`, claimsSet, claim, checkFailed);
945
+ }
946
+ function validateClaimsSet(protectedHeader, claimsSetBytes, options = {}) {
947
+ let claimsSet;
948
+ try {
949
+ claimsSet = JSON.parse(strictDecoder.decode(claimsSetBytes));
950
+ } catch (cause) {
951
+ throw new JWTInvalid("JWT Claims Set must be a top-level JSON object", { cause });
952
+ }
953
+ if (!isObject(claimsSet))
954
+ throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
955
+ const { typ } = options;
956
+ if (typ !== void 0 && (typeof protectedHeader.typ != "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ)))
957
+ throw new JWTClaimValidationFailed('unexpected "typ" JWT header value', claimsSet, "typ", checkFailed);
958
+ const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options, presenceCheck = [...requiredClaims];
959
+ maxTokenAge !== void 0 && presenceCheck.push("iat"), audience !== void 0 && presenceCheck.push("aud"), subject !== void 0 && presenceCheck.push("sub"), issuer !== void 0 && presenceCheck.push("iss");
960
+ for (const claim of new Set(presenceCheck.reverse()))
961
+ if (!Object.hasOwn(claimsSet, claim))
962
+ throw new JWTClaimValidationFailed(`missing required "${claim}" claim`, claimsSet, claim, "missing");
963
+ issuer !== void 0 && !(Array.isArray(issuer) ? issuer : [issuer]).includes(claimsSet.iss) && unexpectedClaim(claimsSet, "iss"), subject !== void 0 && claimsSet.sub !== subject && unexpectedClaim(claimsSet, "sub"), audience !== void 0 && !checkAudiencePresence(claimsSet.aud, typeof audience == "string" ? [audience] : audience) && unexpectedClaim(claimsSet, "aud");
964
+ const { clockTolerance } = options;
965
+ let tolerance = 0;
966
+ if (typeof clockTolerance == "string")
967
+ tolerance = secs(clockTolerance);
968
+ else if (clockTolerance !== void 0) {
969
+ if (typeof clockTolerance != "number")
970
+ throw new TypeError("Invalid clockTolerance option type");
971
+ tolerance = clockTolerance;
972
+ }
973
+ if (validateInput("clockTolerance option", tolerance), tolerance < 0)
974
+ throw new TypeError("Invalid clockTolerance option input");
975
+ const { currentDate } = options, now = validateInput("currentDate option", epoch(currentDate === void 0 ? /* @__PURE__ */ new Date() : currentDate)), iat = validateNumericDate(claimsSet, "iat", maxTokenAge !== void 0), nbf = validateNumericDate(claimsSet, "nbf");
976
+ if (nbf !== void 0 && nbf > now + tolerance)
977
+ throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', claimsSet, "nbf", checkFailed);
978
+ const exp = validateNumericDate(claimsSet, "exp");
979
+ if (exp !== void 0 && exp <= now - tolerance)
980
+ throw new JWTExpired('"exp" claim timestamp check failed', claimsSet, "exp", checkFailed);
981
+ if (maxTokenAge !== void 0) {
982
+ const age = now - iat, max = validateInput("maxTokenAge option", typeof maxTokenAge == "number" ? maxTokenAge : secs(maxTokenAge));
983
+ if (max < 0)
984
+ throw new TypeError("Invalid maxTokenAge option input");
985
+ if (age - tolerance > max)
986
+ throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', claimsSet, "iat", checkFailed);
987
+ if (age < -tolerance)
988
+ throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', claimsSet, "iat", checkFailed);
989
+ }
990
+ return claimsSet;
991
+ }
992
+
993
+ // node_modules/jose/dist/webapi/jwt/verify.js
994
+ async function jwtVerify(jwt, key, options) {
995
+ const [verified, b64] = await verifyCompact(jwt, prepareVerify(options), key);
996
+ if (!b64)
997
+ throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
998
+ const payload = validateClaimsSet(verified.protectedHeader, verified.payload, options);
999
+ return { ...verified, payload };
1000
+ }
1001
+
1002
+ // node_modules/jose/dist/webapi/jwks/local.js
1003
+ function isUsableJWK(jwk, entry, alg, kid) {
1004
+ const { kty, key_ops: keyOps, ext, kid: jwkKid, alg: jwkAlg, use, crv } = jwk;
1005
+ return (ext === void 0 || typeof ext == "boolean") && (keyOps === void 0 || Array.isArray(keyOps) && keyOps.every((operation, index) => typeof operation == "string" && keyOps.indexOf(operation) === index) && keyOps.includes("verify")) && entry.kty.includes(kty) && (kid === void 0 || typeof kid == "string" && kid === jwkKid) && (jwkAlg === void 0 ? kty !== "AKP" : alg === jwkAlg) && (use === void 0 || use === "sig") && (!entry.crv || crv === entry.crv);
1006
+ }
1007
+ async function importWithAlgCache(cache2, jwk, entry) {
1008
+ const cached = cache2.get(jwk) || cache2.set(jwk, {}).get(jwk), { alg } = entry;
1009
+ if (cached[alg] === void 0) {
1010
+ const pending = jwkToKey(entry, jwk, true).then((key) => {
1011
+ if (key.type !== "public")
1012
+ throw new JWKSInvalid("JSON Web Key Set members must be public keys");
1013
+ return cached[alg] = key, key;
1014
+ }).catch((error) => {
1015
+ throw cached[alg] === pending && delete cached[alg], error;
1016
+ });
1017
+ cached[alg] = pending;
1018
+ }
1019
+ return cached[alg];
1020
+ }
1021
+ function createLocalJWKSet(jwks) {
1022
+ let snapshot;
1023
+ try {
1024
+ snapshot = structuredClone(jwks);
1025
+ } catch (cause) {
1026
+ throw new JWKSInvalid("JSON Web Key Set malformed", { cause });
1027
+ }
1028
+ if (!isJwkSet(snapshot))
1029
+ throw new JWKSInvalid("JSON Web Key Set malformed");
1030
+ const metadata = snapshot.keys.map((jwk) => {
1031
+ const normalized = snapshotJwk(jwk);
1032
+ return Array.isArray(normalized.key_ops) && (normalized.key_ops = [...normalized.key_ops]), normalized;
1033
+ }), cached = /* @__PURE__ */ new WeakMap();
1034
+ return Object.defineProperty(async (protectedHeader, token) => {
1035
+ const { alg, kid } = { ...protectedHeader, ...token?.header }, entry = typeof alg == "string" ? JWS[alg] : void 0;
1036
+ if (!entry || entry.secret)
1037
+ throw new JOSENotSupported('Unsupported "alg" value for a JSON Web Key Set');
1038
+ const candidates = snapshot.keys.filter((_, index) => isUsableJWK(metadata[index], entry, alg, kid)), { 0: jwk, length } = candidates;
1039
+ if (!length)
1040
+ throw new JWKSNoMatchingKey();
1041
+ if (length !== 1) {
1042
+ const error = new JWKSMultipleMatchingKeys();
1043
+ throw error[Symbol.asyncIterator] = async function* () {
1044
+ for (const jwk2 of candidates)
1045
+ try {
1046
+ yield await importWithAlgCache(cached, jwk2, entry);
1047
+ } catch {
1048
+ }
1049
+ }, error;
1050
+ }
1051
+ return importWithAlgCache(cached, jwk, entry);
1052
+ }, "jwks", {
1053
+ value: () => structuredClone(snapshot)
1054
+ });
1055
+ }
1056
+
1057
+ // node_modules/jose/dist/webapi/jwks/remote.js
1058
+ function isCloudflareWorkers() {
1059
+ return typeof WebSocketPair < "u" || typeof navigator < "u" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime < "u" && EdgeRuntime === "vercel";
1060
+ }
1061
+ var USER_AGENT;
1062
+ (typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (USER_AGENT = "jose/v6.2.17");
1063
+ var customFetch = /* @__PURE__ */ Symbol();
1064
+ async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
1065
+ const response = await fetchImpl(url, {
1066
+ method: "GET",
1067
+ signal,
1068
+ redirect: "manual",
1069
+ headers
1070
+ }).catch((err) => {
1071
+ throw err.name === "TimeoutError" ? new JWKSTimeout(void 0, { cause: err }) : err;
1072
+ });
1073
+ if (response.status !== 200)
1074
+ throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
1075
+ try {
1076
+ return await response.json();
1077
+ } catch (cause) {
1078
+ throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON", { cause });
1079
+ }
1080
+ }
1081
+ var jwksCache = /* @__PURE__ */ Symbol();
1082
+ function isFreshFor(timestamp, duration) {
1083
+ return Number.isFinite(timestamp) && Date.now() < timestamp + duration;
1084
+ }
1085
+ function validateDuration(value, fallback, option) {
1086
+ if (Number.isNaN(value))
1087
+ throw new TypeError(`"${option}" option must not be NaN`);
1088
+ if (typeof value == "number" && value < 0)
1089
+ throw new TypeError(`"${option}" option must not be negative`);
1090
+ return typeof value == "number" ? value : fallback;
1091
+ }
1092
+ function createRemoteJWKSet(url, options) {
1093
+ if (!(url instanceof URL))
1094
+ throw new TypeError("url must be an instance of URL");
1095
+ const href = new URL(url.href).href, opts = options ?? {}, timeoutOption = opts.timeoutDuration;
1096
+ if (typeof timeoutOption == "number" && (!Number.isInteger(timeoutOption) || timeoutOption < 0))
1097
+ throw new TypeError('"timeoutDuration" option must be a non-negative integer');
1098
+ const timeoutDuration = typeof timeoutOption == "number" ? timeoutOption : 5e3, cooldownDuration = validateDuration(opts.cooldownDuration, 3e4, "cooldownDuration"), cacheMaxAge = validateDuration(opts.cacheMaxAge, 6e5, "cacheMaxAge"), headers = new Headers(opts.headers);
1099
+ USER_AGENT && !headers.has("User-Agent") && headers.set("User-Agent", USER_AGENT), headers.has("accept") || headers.set("accept", "application/json, application/jwk-set+json");
1100
+ const fetchImpl = opts[customFetch], cache2 = opts[jwksCache];
1101
+ let jwksTimestamp, pendingFetch, reloadSequence = 0, appliedSequence = 0, local;
1102
+ if (cache2 && typeof cache2 == "object") {
1103
+ const { uat, jwks } = cache2;
1104
+ isFreshFor(uat, cacheMaxAge) && isJwkSet(jwks) && (jwksTimestamp = uat, local = createLocalJWKSet(jwks));
1105
+ }
1106
+ const reload = async () => {
1107
+ if (pendingFetch && isCloudflareWorkers() && (pendingFetch = void 0), !pendingFetch) {
1108
+ const sequence = ++reloadSequence, current = pendingFetch = fetchJwks(href, headers, AbortSignal.timeout(timeoutDuration), fetchImpl).then((json) => {
1109
+ const next = createLocalJWKSet(json);
1110
+ if (sequence <= appliedSequence)
1111
+ return;
1112
+ local = next;
1113
+ const updatedAt = Date.now();
1114
+ cache2 && (cache2.uat = updatedAt, cache2.jwks = json), jwksTimestamp = updatedAt, appliedSequence = sequence;
1115
+ }).finally(() => {
1116
+ pendingFetch === current && (pendingFetch = void 0);
1117
+ });
1118
+ }
1119
+ await pendingFetch;
1120
+ };
1121
+ return Object.defineProperties(async (protectedHeader, token) => {
1122
+ (!local || !isFreshFor(jwksTimestamp, cacheMaxAge)) && await reload();
1123
+ try {
1124
+ return await local(protectedHeader, token);
1125
+ } catch (err) {
1126
+ if (err instanceof JWKSNoMatchingKey && !isFreshFor(jwksTimestamp, cooldownDuration))
1127
+ return await reload(), local(protectedHeader, token);
1128
+ throw err;
1129
+ }
1130
+ }, {
1131
+ coolingDown: {
1132
+ get: () => isFreshFor(jwksTimestamp, cooldownDuration),
1133
+ enumerable: true
1134
+ },
1135
+ fresh: {
1136
+ get: () => isFreshFor(jwksTimestamp, cacheMaxAge),
1137
+ enumerable: true
1138
+ },
1139
+ reload: {
1140
+ value: reload,
1141
+ enumerable: true
1142
+ },
1143
+ reloading: {
1144
+ get: () => !!pendingFetch,
1145
+ enumerable: true
1146
+ },
1147
+ jwks: {
1148
+ value: () => local?.jwks(),
1149
+ enumerable: true
1150
+ }
1151
+ });
1152
+ }
1153
+
1154
+ // src/logic-functions/constants/google-pubsub-push.constant.ts
1155
+ var GOOGLE_SIGNING_KEYS_URL = "https://www.googleapis.com/oauth2/v3/certs";
1156
+ var GOOGLE_TOKEN_ISSUERS = [
1157
+ "https://accounts.google.com",
1158
+ "accounts.google.com"
1159
+ ];
1160
+ var GOOGLE_PUBSUB_PUSH_TOKEN_CLOCK_TOLERANCE_SECONDS = 60;
1161
+
1162
+ // src/logic-functions/utils/extract-bearer-token.util.ts
1163
+ var import_guards3 = __toESM(require_build());
1164
+ var extractBearerToken = (authorizationHeader) => {
1165
+ if (!(0, import_guards3.isNonEmptyString)(authorizationHeader)) {
1166
+ return void 0;
1167
+ }
1168
+ const [scheme, token, ...otherParts] = authorizationHeader.trim().split(/\s+/);
1169
+ if (scheme.toLowerCase() !== "bearer" || !(0, import_guards3.isNonEmptyString)(token) || otherParts.length > 0) {
1170
+ return void 0;
1171
+ }
1172
+ return token;
1173
+ };
1174
+
1175
+ // src/logic-functions/utils/verify-google-pubsub-push-token-or-throw.util.ts
1176
+ var getGoogleSigningKey = createRemoteJWKSet(
1177
+ new URL(GOOGLE_SIGNING_KEYS_URL)
1178
+ );
1179
+ var verifyGooglePubsubPushTokenOrThrow = async ({
1180
+ authorizationHeader,
1181
+ audience,
1182
+ serviceAccountEmail,
1183
+ getSigningKey
1184
+ }) => {
1185
+ const token = extractBearerToken(authorizationHeader);
1186
+ if (!(0, import_guards4.isNonEmptyString)(token)) {
1187
+ throw new MeetException({
1188
+ message: "The Pub/Sub push request has no bearer token",
1189
+ code: "PUSH_TOKEN_INVALID"
1190
+ });
1191
+ }
1192
+ const { payload } = await jwtVerify(
1193
+ token,
1194
+ getSigningKey ?? getGoogleSigningKey,
1195
+ {
1196
+ issuer: GOOGLE_TOKEN_ISSUERS,
1197
+ audience,
1198
+ algorithms: ["RS256"],
1199
+ clockTolerance: GOOGLE_PUBSUB_PUSH_TOKEN_CLOCK_TOLERANCE_SECONDS
1200
+ }
1201
+ ).catch((error) => {
1202
+ if (error instanceof errors_exports.JOSEError) {
1203
+ throw new MeetException({
1204
+ message: `The Pub/Sub push token is invalid: ${error.message}`,
1205
+ code: "PUSH_TOKEN_INVALID"
1206
+ });
1207
+ }
1208
+ throw error;
1209
+ });
1210
+ if (payload.email !== serviceAccountEmail || payload.email_verified !== true) {
1211
+ throw new MeetException({
1212
+ message: "The Pub/Sub push token was not issued to the configured service account",
1213
+ code: "PUSH_TOKEN_INVALID"
1214
+ });
1215
+ }
1216
+ };
1217
+
1218
+ // src/logic-functions/utils/is-google-pubsub-push-authorized.util.ts
1219
+ var isGooglePubsubPushAuthorized = async ({
1220
+ authorizationHeader,
1221
+ audience,
1222
+ serviceAccountEmail
1223
+ }) => {
1224
+ try {
1225
+ await verifyGooglePubsubPushTokenOrThrow({
1226
+ authorizationHeader,
1227
+ audience,
1228
+ serviceAccountEmail
1229
+ });
1230
+ return true;
1231
+ } catch (error) {
1232
+ if (error instanceof MeetException && error.code === "PUSH_TOKEN_INVALID") {
1233
+ return false;
1234
+ }
1235
+ throw error;
1236
+ }
1237
+ };
1238
+
1239
+ // src/logic-functions/utils/parse-meet-event-or-throw.util.ts
1240
+ var import_guards6 = __toESM(require_build());
1241
+
1242
+ // src/logic-functions/constants/google-workspace-events.constant.ts
1243
+ var GOOGLE_WORKSPACE_EVENTS_SOURCE_PREFIX = "//workspaceevents.googleapis.com/";
1244
+
1245
+ // src/logic-functions/utils/parse-meet-event-data-or-throw.util.ts
1246
+ var import_guards5 = __toESM(require_build());
1247
+ var decodeMeetEventData = (encodedData) => {
1248
+ try {
1249
+ return JSON.parse(Buffer.from(encodedData, "base64").toString("utf8"));
1250
+ } catch (error) {
1251
+ throw new MeetException({
1252
+ message: `The Google Meet event data is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,
1253
+ code: "EVENT_DATA_UNREADABLE"
1254
+ });
1255
+ }
1256
+ };
1257
+ var parseMeetEventDataOrThrow = (encodedData) => {
1258
+ if (!(0, import_guards5.isNonEmptyString)(encodedData)) {
1259
+ return {};
1260
+ }
1261
+ const eventData = decodeMeetEventData(encodedData);
1262
+ if (!(0, import_guards5.isObject)(eventData)) {
1263
+ throw new MeetException({
1264
+ message: "The Google Meet event data is not an object",
1265
+ code: "EVENT_DATA_UNREADABLE"
1266
+ });
1267
+ }
1268
+ return eventData;
1269
+ };
1270
+
1271
+ // src/logic-functions/utils/parse-meet-event-or-throw.util.ts
1272
+ var parseMeetEventOrThrow = (pushBody) => {
1273
+ const source = pushBody?.message?.attributes?.["ce-source"];
1274
+ const eventType = pushBody?.message?.attributes?.["ce-type"];
1275
+ if (!(0, import_guards6.isNonEmptyString)(source) || !source.startsWith(GOOGLE_WORKSPACE_EVENTS_SOURCE_PREFIX) || !(0, import_guards6.isNonEmptyString)(eventType)) {
1276
+ return void 0;
1277
+ }
1278
+ const eventData = parseMeetEventDataOrThrow(pushBody?.message?.data);
1279
+ const artifactName = eventData.transcript?.name ?? eventData.smartNote?.name ?? eventData.recording?.name;
1280
+ return {
1281
+ subscriptionName: source.slice(
1282
+ GOOGLE_WORKSPACE_EVENTS_SOURCE_PREFIX.length
1283
+ ),
1284
+ eventType,
1285
+ ...(0, import_guards6.isNonEmptyString)(artifactName) ? { artifactName } : {}
1286
+ };
1287
+ };
1288
+
1289
+ // src/logic-functions/meet-events-resolver.ts
1290
+ var meetEventsResolverHandler = async ({
1291
+ headers,
1292
+ body
1293
+ }) => {
1294
+ const audience = process.env[MEET_PUBSUB_AUDIENCE_SERVER_VARIABLE_NAME];
1295
+ const serviceAccountEmail = process.env[MEET_PUBSUB_SERVICE_ACCOUNT_EMAIL_SERVER_VARIABLE_NAME];
1296
+ if (!(0, import_guards7.isNonEmptyString)(audience) || !(0, import_guards7.isNonEmptyString)(serviceAccountEmail)) {
1297
+ return new Ze(
1298
+ { error: "Google Meet events are not configured" },
1299
+ { status: 503 }
1300
+ );
1301
+ }
1302
+ const isAuthorized = await isGooglePubsubPushAuthorized({
1303
+ authorizationHeader: headers.authorization,
1304
+ audience,
1305
+ serviceAccountEmail
1306
+ });
1307
+ if (!isAuthorized) {
1308
+ return new Ze({ error: "Unauthorized" }, { status: 401 });
1309
+ }
1310
+ const event = parseMeetEventOrThrow(body);
1311
+ if (!l(event)) {
1312
+ return new Ze({ ok: true, skipped: "Not a Google Meet event" });
1313
+ }
1314
+ const workspaceId = await Xe.get(
1315
+ getMeetEventSubscriptionKey(event.subscriptionName),
1316
+ { scope: "SERVER" }
1317
+ );
1318
+ if (!(0, import_guards7.isNonEmptyString)(workspaceId)) {
1319
+ return new Ze({
1320
+ ok: true,
1321
+ skipped: "No workspace claims this subscription"
1322
+ });
1323
+ }
1324
+ return {
1325
+ workspaceId,
1326
+ targetLogicFunctionUniversalIdentifier: MEET_HANDLE_EVENT_UNIVERSAL_IDENTIFIER,
1327
+ payload: event
1328
+ };
1329
+ };
1330
+ var meet_events_resolver_default = defineLogicFunction({
1331
+ universalIdentifier: MEET_EVENTS_RESOLVER_UNIVERSAL_IDENTIFIER,
1332
+ name: "meet-events-resolver",
1333
+ description: "Checks that a Google Meet event comes from the configured Pub/Sub subscription and routes it to the workspace that owns the Google account.",
1334
+ timeoutSeconds: 15,
1335
+ handler: meetEventsResolverHandler,
1336
+ serverRouteTriggerSettings: {
1337
+ httpMethods: ["POST"],
1338
+ forwardedRequestHeaders: ["authorization"]
1339
+ }
1340
+ });
1341
+ export {
1342
+ meet_events_resolver_default as default,
1343
+ meetEventsResolverHandler
1344
+ };
1345
+ //# sourceMappingURL=meet-events-resolver.mjs.map