assembly-kit 0.0.1

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 (272) hide show
  1. package/CLAUDE.md +205 -0
  2. package/LICENSE +21 -0
  3. package/README.md +516 -0
  4. package/dist/bridge-ui/index.d.mts +4 -0
  5. package/dist/bridge-ui/index.mjs +5 -0
  6. package/dist/bridge-ui/use-actions-menu.d.mts +16 -0
  7. package/dist/bridge-ui/use-actions-menu.mjs +33 -0
  8. package/dist/bridge-ui/use-actions-menu.mjs.map +1 -0
  9. package/dist/bridge-ui/use-primary-cta.d.mts +16 -0
  10. package/dist/bridge-ui/use-primary-cta.mjs +34 -0
  11. package/dist/bridge-ui/use-primary-cta.mjs.map +1 -0
  12. package/dist/bridge-ui/use-secondary-cta.d.mts +16 -0
  13. package/dist/bridge-ui/use-secondary-cta.mjs +34 -0
  14. package/dist/bridge-ui/use-secondary-cta.mjs.map +1 -0
  15. package/dist/client/index.d.mts +108 -0
  16. package/dist/client/index.mjs +168 -0
  17. package/dist/client/index.mjs.map +1 -0
  18. package/dist/client/options.d.mts +40 -0
  19. package/dist/constants/kit-mode.d.mts +15 -0
  20. package/dist/constants/kit-mode.mjs +15 -0
  21. package/dist/constants/kit-mode.mjs.map +1 -0
  22. package/dist/errors/base.d.mts +29 -0
  23. package/dist/errors/base.mjs +16 -0
  24. package/dist/errors/base.mjs.map +1 -0
  25. package/dist/errors/connection.d.mts +12 -0
  26. package/dist/errors/connection.mjs +16 -0
  27. package/dist/errors/connection.mjs.map +1 -0
  28. package/dist/errors/forbidden.d.mts +12 -0
  29. package/dist/errors/forbidden.mjs +16 -0
  30. package/dist/errors/forbidden.mjs.map +1 -0
  31. package/dist/errors/index.d.mts +13 -0
  32. package/dist/errors/index.mjs +13 -0
  33. package/dist/errors/invalid-token.d.mts +12 -0
  34. package/dist/errors/invalid-token.mjs +16 -0
  35. package/dist/errors/invalid-token.mjs.map +1 -0
  36. package/dist/errors/missing-api-key.d.mts +12 -0
  37. package/dist/errors/missing-api-key.mjs +16 -0
  38. package/dist/errors/missing-api-key.mjs.map +1 -0
  39. package/dist/errors/no-token.d.mts +12 -0
  40. package/dist/errors/no-token.mjs +16 -0
  41. package/dist/errors/no-token.mjs.map +1 -0
  42. package/dist/errors/not-found.d.mts +12 -0
  43. package/dist/errors/not-found.mjs +16 -0
  44. package/dist/errors/not-found.mjs.map +1 -0
  45. package/dist/errors/rate-limit.d.mts +17 -0
  46. package/dist/errors/rate-limit.mjs +18 -0
  47. package/dist/errors/rate-limit.mjs.map +1 -0
  48. package/dist/errors/response-parse.d.mts +19 -0
  49. package/dist/errors/response-parse.mjs +23 -0
  50. package/dist/errors/response-parse.mjs.map +1 -0
  51. package/dist/errors/server.d.mts +12 -0
  52. package/dist/errors/server.mjs +16 -0
  53. package/dist/errors/server.mjs.map +1 -0
  54. package/dist/errors/unauthorized.d.mts +12 -0
  55. package/dist/errors/unauthorized.mjs +16 -0
  56. package/dist/errors/unauthorized.mjs.map +1 -0
  57. package/dist/errors/validation.d.mts +12 -0
  58. package/dist/errors/validation.mjs +16 -0
  59. package/dist/errors/validation.mjs.map +1 -0
  60. package/dist/index.d.mts +49 -0
  61. package/dist/index.mjs +51 -0
  62. package/dist/lib/modules/app-connections/resource.d.mts +28 -0
  63. package/dist/lib/modules/app-connections/resource.mjs +33 -0
  64. package/dist/lib/modules/app-connections/resource.mjs.map +1 -0
  65. package/dist/lib/modules/app-connections/schema.d.mts +37 -0
  66. package/dist/lib/modules/app-connections/schema.mjs +30 -0
  67. package/dist/lib/modules/app-connections/schema.mjs.map +1 -0
  68. package/dist/lib/modules/app-installs/resource.d.mts +21 -0
  69. package/dist/lib/modules/app-installs/resource.mjs +31 -0
  70. package/dist/lib/modules/app-installs/resource.mjs.map +1 -0
  71. package/dist/lib/modules/app-installs/schema.d.mts +22 -0
  72. package/dist/lib/modules/app-installs/schema.mjs +23 -0
  73. package/dist/lib/modules/app-installs/schema.mjs.map +1 -0
  74. package/dist/lib/modules/clients/resource.d.mts +43 -0
  75. package/dist/lib/modules/clients/resource.mjs +62 -0
  76. package/dist/lib/modules/clients/resource.mjs.map +1 -0
  77. package/dist/lib/modules/clients/schema.d.mts +50 -0
  78. package/dist/lib/modules/clients/schema.mjs +52 -0
  79. package/dist/lib/modules/clients/schema.mjs.map +1 -0
  80. package/dist/lib/modules/companies/resource.d.mts +37 -0
  81. package/dist/lib/modules/companies/resource.mjs +60 -0
  82. package/dist/lib/modules/companies/resource.mjs.map +1 -0
  83. package/dist/lib/modules/companies/schema.d.mts +39 -0
  84. package/dist/lib/modules/companies/schema.mjs +34 -0
  85. package/dist/lib/modules/companies/schema.mjs.map +1 -0
  86. package/dist/lib/modules/contract-templates/resource.d.mts +27 -0
  87. package/dist/lib/modules/contract-templates/resource.mjs +40 -0
  88. package/dist/lib/modules/contract-templates/resource.mjs.map +1 -0
  89. package/dist/lib/modules/contract-templates/schema.d.mts +21 -0
  90. package/dist/lib/modules/contract-templates/schema.mjs +18 -0
  91. package/dist/lib/modules/contract-templates/schema.mjs.map +1 -0
  92. package/dist/lib/modules/contracts/resource.d.mts +29 -0
  93. package/dist/lib/modules/contracts/resource.mjs +40 -0
  94. package/dist/lib/modules/contracts/resource.mjs.map +1 -0
  95. package/dist/lib/modules/contracts/schema.d.mts +50 -0
  96. package/dist/lib/modules/contracts/schema.mjs +45 -0
  97. package/dist/lib/modules/contracts/schema.mjs.map +1 -0
  98. package/dist/lib/modules/custom-field-options/index.d.mts +1 -0
  99. package/dist/lib/modules/custom-field-options/index.mjs +2 -0
  100. package/dist/lib/modules/custom-field-options/resource.d.mts +22 -0
  101. package/dist/lib/modules/custom-field-options/resource.mjs +25 -0
  102. package/dist/lib/modules/custom-field-options/resource.mjs.map +1 -0
  103. package/dist/lib/modules/custom-field-options/schema.d.mts +18 -0
  104. package/dist/lib/modules/custom-field-options/schema.mjs +13 -0
  105. package/dist/lib/modules/custom-field-options/schema.mjs.map +1 -0
  106. package/dist/lib/modules/custom-fields/resource.d.mts +21 -0
  107. package/dist/lib/modules/custom-fields/resource.mjs +24 -0
  108. package/dist/lib/modules/custom-fields/resource.mjs.map +1 -0
  109. package/dist/lib/modules/custom-fields/schema.d.mts +43 -0
  110. package/dist/lib/modules/custom-fields/schema.mjs +44 -0
  111. package/dist/lib/modules/custom-fields/schema.mjs.map +1 -0
  112. package/dist/lib/modules/events/resource.d.mts +33 -0
  113. package/dist/lib/modules/events/resource.mjs +49 -0
  114. package/dist/lib/modules/events/resource.mjs.map +1 -0
  115. package/dist/lib/modules/events/schema.d.mts +52 -0
  116. package/dist/lib/modules/events/schema.mjs +49 -0
  117. package/dist/lib/modules/events/schema.mjs.map +1 -0
  118. package/dist/lib/modules/file-channels/resource.d.mts +26 -0
  119. package/dist/lib/modules/file-channels/resource.mjs +48 -0
  120. package/dist/lib/modules/file-channels/resource.mjs.map +1 -0
  121. package/dist/lib/modules/file-channels/schema.d.mts +33 -0
  122. package/dist/lib/modules/file-channels/schema.mjs +28 -0
  123. package/dist/lib/modules/file-channels/schema.mjs.map +1 -0
  124. package/dist/lib/modules/files/resource.d.mts +40 -0
  125. package/dist/lib/modules/files/resource.mjs +52 -0
  126. package/dist/lib/modules/files/resource.mjs.map +1 -0
  127. package/dist/lib/modules/files/schema.d.mts +27 -0
  128. package/dist/lib/modules/files/schema.mjs +27 -0
  129. package/dist/lib/modules/files/schema.mjs.map +1 -0
  130. package/dist/lib/modules/form-responses/resource.d.mts +24 -0
  131. package/dist/lib/modules/form-responses/resource.mjs +34 -0
  132. package/dist/lib/modules/form-responses/resource.mjs.map +1 -0
  133. package/dist/lib/modules/form-responses/schema.d.mts +29 -0
  134. package/dist/lib/modules/form-responses/schema.mjs +23 -0
  135. package/dist/lib/modules/form-responses/schema.mjs.map +1 -0
  136. package/dist/lib/modules/forms/resource.d.mts +24 -0
  137. package/dist/lib/modules/forms/resource.mjs +40 -0
  138. package/dist/lib/modules/forms/resource.mjs.map +1 -0
  139. package/dist/lib/modules/forms/schema.d.mts +22 -0
  140. package/dist/lib/modules/forms/schema.mjs +19 -0
  141. package/dist/lib/modules/forms/schema.mjs.map +1 -0
  142. package/dist/lib/modules/index.d.mts +28 -0
  143. package/dist/lib/modules/index.mjs +29 -0
  144. package/dist/lib/modules/internal-users/resource.d.mts +24 -0
  145. package/dist/lib/modules/internal-users/resource.mjs +37 -0
  146. package/dist/lib/modules/internal-users/resource.mjs.map +1 -0
  147. package/dist/lib/modules/internal-users/schema.d.mts +27 -0
  148. package/dist/lib/modules/internal-users/schema.mjs +24 -0
  149. package/dist/lib/modules/internal-users/schema.mjs.map +1 -0
  150. package/dist/lib/modules/invoice-templates/resource.d.mts +22 -0
  151. package/dist/lib/modules/invoice-templates/resource.mjs +32 -0
  152. package/dist/lib/modules/invoice-templates/resource.mjs.map +1 -0
  153. package/dist/lib/modules/invoice-templates/schema.d.mts +21 -0
  154. package/dist/lib/modules/invoice-templates/schema.mjs +18 -0
  155. package/dist/lib/modules/invoice-templates/schema.mjs.map +1 -0
  156. package/dist/lib/modules/invoices/resource.d.mts +30 -0
  157. package/dist/lib/modules/invoices/resource.mjs +48 -0
  158. package/dist/lib/modules/invoices/resource.mjs.map +1 -0
  159. package/dist/lib/modules/invoices/schema.d.mts +81 -0
  160. package/dist/lib/modules/invoices/schema.mjs +75 -0
  161. package/dist/lib/modules/invoices/schema.mjs.map +1 -0
  162. package/dist/lib/modules/message-channels/resource.d.mts +26 -0
  163. package/dist/lib/modules/message-channels/resource.mjs +48 -0
  164. package/dist/lib/modules/message-channels/resource.mjs.map +1 -0
  165. package/dist/lib/modules/message-channels/schema.d.mts +35 -0
  166. package/dist/lib/modules/message-channels/schema.mjs +30 -0
  167. package/dist/lib/modules/message-channels/schema.mjs.map +1 -0
  168. package/dist/lib/modules/messages/resource.d.mts +27 -0
  169. package/dist/lib/modules/messages/resource.mjs +40 -0
  170. package/dist/lib/modules/messages/resource.mjs.map +1 -0
  171. package/dist/lib/modules/messages/schema.d.mts +30 -0
  172. package/dist/lib/modules/messages/schema.mjs +26 -0
  173. package/dist/lib/modules/messages/schema.mjs.map +1 -0
  174. package/dist/lib/modules/notes/resource.d.mts +37 -0
  175. package/dist/lib/modules/notes/resource.mjs +60 -0
  176. package/dist/lib/modules/notes/resource.mjs.map +1 -0
  177. package/dist/lib/modules/notes/schema.d.mts +34 -0
  178. package/dist/lib/modules/notes/schema.mjs +27 -0
  179. package/dist/lib/modules/notes/schema.mjs.map +1 -0
  180. package/dist/lib/modules/notifications/resource.d.mts +27 -0
  181. package/dist/lib/modules/notifications/resource.mjs +52 -0
  182. package/dist/lib/modules/notifications/resource.mjs.map +1 -0
  183. package/dist/lib/modules/notifications/schema.d.mts +52 -0
  184. package/dist/lib/modules/notifications/schema.mjs +43 -0
  185. package/dist/lib/modules/notifications/schema.mjs.map +1 -0
  186. package/dist/lib/modules/payments/resource.d.mts +26 -0
  187. package/dist/lib/modules/payments/resource.mjs +32 -0
  188. package/dist/lib/modules/payments/resource.mjs.map +1 -0
  189. package/dist/lib/modules/payments/schema.d.mts +23 -0
  190. package/dist/lib/modules/payments/schema.mjs +20 -0
  191. package/dist/lib/modules/payments/schema.mjs.map +1 -0
  192. package/dist/lib/modules/prices/resource.d.mts +27 -0
  193. package/dist/lib/modules/prices/resource.mjs +40 -0
  194. package/dist/lib/modules/prices/resource.mjs.map +1 -0
  195. package/dist/lib/modules/prices/schema.d.mts +22 -0
  196. package/dist/lib/modules/prices/schema.mjs +19 -0
  197. package/dist/lib/modules/prices/schema.mjs.map +1 -0
  198. package/dist/lib/modules/products/resource.d.mts +24 -0
  199. package/dist/lib/modules/products/resource.mjs +40 -0
  200. package/dist/lib/modules/products/resource.mjs.map +1 -0
  201. package/dist/lib/modules/products/schema.d.mts +22 -0
  202. package/dist/lib/modules/products/schema.mjs +19 -0
  203. package/dist/lib/modules/products/schema.mjs.map +1 -0
  204. package/dist/lib/modules/subscription-templates/resource.d.mts +22 -0
  205. package/dist/lib/modules/subscription-templates/resource.mjs +32 -0
  206. package/dist/lib/modules/subscription-templates/resource.mjs.map +1 -0
  207. package/dist/lib/modules/subscription-templates/schema.d.mts +21 -0
  208. package/dist/lib/modules/subscription-templates/schema.mjs +18 -0
  209. package/dist/lib/modules/subscription-templates/schema.mjs.map +1 -0
  210. package/dist/lib/modules/subscriptions/resource.d.mts +32 -0
  211. package/dist/lib/modules/subscriptions/resource.mjs +56 -0
  212. package/dist/lib/modules/subscriptions/resource.mjs.map +1 -0
  213. package/dist/lib/modules/subscriptions/schema.d.mts +31 -0
  214. package/dist/lib/modules/subscriptions/schema.mjs +26 -0
  215. package/dist/lib/modules/subscriptions/schema.mjs.map +1 -0
  216. package/dist/lib/modules/task-templates/resource.d.mts +24 -0
  217. package/dist/lib/modules/task-templates/resource.mjs +40 -0
  218. package/dist/lib/modules/task-templates/resource.mjs.map +1 -0
  219. package/dist/lib/modules/task-templates/schema.d.mts +22 -0
  220. package/dist/lib/modules/task-templates/schema.mjs +19 -0
  221. package/dist/lib/modules/task-templates/schema.mjs.map +1 -0
  222. package/dist/lib/modules/tasks/resource.d.mts +38 -0
  223. package/dist/lib/modules/tasks/resource.mjs +60 -0
  224. package/dist/lib/modules/tasks/resource.mjs.map +1 -0
  225. package/dist/lib/modules/tasks/schema.d.mts +45 -0
  226. package/dist/lib/modules/tasks/schema.mjs +43 -0
  227. package/dist/lib/modules/tasks/schema.mjs.map +1 -0
  228. package/dist/lib/modules/workspace/resource.d.mts +19 -0
  229. package/dist/lib/modules/workspace/resource.mjs +23 -0
  230. package/dist/lib/modules/workspace/resource.mjs.map +1 -0
  231. package/dist/lib/modules/workspace/schema.d.mts +23 -0
  232. package/dist/lib/modules/workspace/schema.mjs +21 -0
  233. package/dist/lib/modules/workspace/schema.mjs.map +1 -0
  234. package/dist/lib/pagination/paginate.d.mts +8 -0
  235. package/dist/lib/pagination/paginate.mjs +24 -0
  236. package/dist/lib/pagination/paginate.mjs.map +1 -0
  237. package/dist/logger/index.d.mts +26 -0
  238. package/dist/logger/index.mjs +45 -0
  239. package/dist/logger/index.mjs.map +1 -0
  240. package/dist/schemas/index.d.mts +32 -0
  241. package/dist/schemas/index.mjs +34 -0
  242. package/dist/schemas/shared/hex-color.d.mts +8 -0
  243. package/dist/schemas/shared/hex-color.mjs +7 -0
  244. package/dist/schemas/shared/hex-color.mjs.map +1 -0
  245. package/dist/schemas/shared/index.d.mts +3 -0
  246. package/dist/schemas/shared/index.mjs +4 -0
  247. package/dist/schemas/shared/membership-type.d.mts +9 -0
  248. package/dist/schemas/shared/membership-type.mjs +11 -0
  249. package/dist/schemas/shared/membership-type.mjs.map +1 -0
  250. package/dist/schemas/shared/token.d.mts +22 -0
  251. package/dist/schemas/shared/token.mjs +21 -0
  252. package/dist/schemas/shared/token.mjs.map +1 -0
  253. package/dist/token/assembly-token.d.mts +96 -0
  254. package/dist/token/assembly-token.mjs +117 -0
  255. package/dist/token/assembly-token.mjs.map +1 -0
  256. package/dist/token/crypto.mjs +98 -0
  257. package/dist/token/crypto.mjs.map +1 -0
  258. package/dist/token/index.d.mts +3 -0
  259. package/dist/token/index.mjs +3 -0
  260. package/dist/token/parse.d.mts +24 -0
  261. package/dist/token/parse.mjs +62 -0
  262. package/dist/token/parse.mjs.map +1 -0
  263. package/dist/transport/build-search-params.mjs +16 -0
  264. package/dist/transport/build-search-params.mjs.map +1 -0
  265. package/dist/transport/http.d.mts +14 -0
  266. package/dist/transport/http.mjs +142 -0
  267. package/dist/transport/http.mjs.map +1 -0
  268. package/dist/transport/parse-response.mjs +17 -0
  269. package/dist/transport/parse-response.mjs.map +1 -0
  270. package/dist/version.mjs +7 -0
  271. package/dist/version.mjs.map +1 -0
  272. package/package.json +93 -0
@@ -0,0 +1,34 @@
1
+ import { MembershipTypeSchema } from "./shared/membership-type.mjs";
2
+ import { AppConnectionCreateRequestSchema, AppConnectionResponseSchema, AppConnectionSchema, AppConnectionTypeSchema, AppConnectionsResponseSchema } from "../lib/modules/app-connections/schema.mjs";
3
+ import { AppInstallResponseSchema, AppInstallSchema, AppInstallTypeSchema, AppInstallsResponseSchema } from "../lib/modules/app-installs/schema.mjs";
4
+ import { ClientCreateRequestSchema, ClientResponseSchema, ClientSchema, ClientUpdateRequestSchema, ClientsResponseSchema } from "../lib/modules/clients/schema.mjs";
5
+ import { HexColorSchema } from "./shared/hex-color.mjs";
6
+ import { CompaniesResponseSchema, CompanyCreateRequestSchema, CompanyResponseSchema, CompanySchema, CompanyUpdateRequestSchema } from "../lib/modules/companies/schema.mjs";
7
+ import { ContractTemplateResponseSchema, ContractTemplateSchema, ContractTemplatesResponseSchema } from "../lib/modules/contract-templates/schema.mjs";
8
+ import { ContractFieldInputTypeSchema, ContractFieldSchema, ContractResponseSchema, ContractSchema, ContractSendRequestSchema, ContractStatusSchema, ContractsResponseSchema } from "../lib/modules/contracts/schema.mjs";
9
+ import { CustomFieldOptionSchema, ListCustomFieldOptionResponseSchema } from "../lib/modules/custom-field-options/schema.mjs";
10
+ import { AddressValueSchema, CustomFieldEntityTypeSchema, CustomFieldSchema, CustomFieldTypeSchema, CustomFieldValueSchema, ListCustomFieldResponseSchema } from "../lib/modules/custom-fields/schema.mjs";
11
+ import { AuditLogEventResponseSchema, AuditLogEventSchema, AuditLogEventsResponseSchema, EventActorTypeSchema, EventCreateRequestSchema, EventSourceSchema } from "../lib/modules/events/schema.mjs";
12
+ import { FileChannelCreateRequestSchema, FileChannelResponseSchema, FileChannelSchema, FileChannelsResponseSchema } from "../lib/modules/file-channels/schema.mjs";
13
+ import { AssemblyFileResponseSchema, AssemblyFileSchema, AssemblyFilesResponseSchema, FileTypeSchema } from "../lib/modules/files/schema.mjs";
14
+ import { FormResponseCreateRequestSchema, FormResponseItemResponseSchema, FormResponseSchema, FormResponsesResponseSchema } from "../lib/modules/form-responses/schema.mjs";
15
+ import { FormDataResponseSchema, FormSchema, FormsDataResponseSchema } from "../lib/modules/forms/schema.mjs";
16
+ import { InternalUserResponseSchema, InternalUserSchema, InternalUsersResponseSchema } from "../lib/modules/internal-users/schema.mjs";
17
+ import { InvoiceTemplateResponseSchema, InvoiceTemplateSchema, InvoiceTemplatesResponseSchema } from "../lib/modules/invoice-templates/schema.mjs";
18
+ import { InvoiceCreateRequestSchema, InvoiceLineItemRequestSchema, InvoiceLineItemSchema, InvoicePaymentMethodPreferenceRequestSchema, InvoiceResponseSchema, InvoiceSchema, InvoiceStatusSchema, InvoicesResponseSchema, PaymentMethodPreferenceSchema, PaymentMethodTypeSchema } from "../lib/modules/invoices/schema.mjs";
19
+ import { MessageChannelCreateRequestSchema, MessageChannelResponseSchema, MessageChannelSchema, MessageChannelsResponseSchema } from "../lib/modules/message-channels/schema.mjs";
20
+ import { MessageResponseSchema, MessageSchema, MessagesResponseSchema, SendMessageRequestSchema } from "../lib/modules/messages/schema.mjs";
21
+ import { NoteCreateRequestSchema, NoteResponseSchema, NoteSchema, NoteUpdateRequestSchema, NotesResponseSchema } from "../lib/modules/notes/schema.mjs";
22
+ import { EmailDeliveryTargetSchema, InProductDeliveryTargetSchema, NotificationCreateRequestSchema, NotificationDeliveryTargetsSchema, NotificationResponseSchema, NotificationSchema, NotificationsResponseSchema } from "../lib/modules/notifications/schema.mjs";
23
+ import { PaymentResponseSchema, PaymentSchema, PaymentsResponseSchema } from "../lib/modules/payments/schema.mjs";
24
+ import { PriceResponseSchema, PriceSchema, PricesResponseSchema } from "../lib/modules/prices/schema.mjs";
25
+ import { ProductResponseSchema, ProductSchema, ProductsResponseSchema } from "../lib/modules/products/schema.mjs";
26
+ import { SubscriptionTemplateResponseSchema, SubscriptionTemplateSchema, SubscriptionTemplatesResponseSchema } from "../lib/modules/subscription-templates/schema.mjs";
27
+ import { SubscriptionCreateRequestSchema, SubscriptionResponseSchema, SubscriptionSchema, SubscriptionsResponseSchema } from "../lib/modules/subscriptions/schema.mjs";
28
+ import { TaskTemplateResponseSchema, TaskTemplateSchema, TaskTemplatesResponseSchema } from "../lib/modules/task-templates/schema.mjs";
29
+ import { TaskCreateRequestSchema, TaskResponseSchema, TaskSchema, TaskStatusSchema, TaskUpdateRequestSchema, TasksResponseSchema } from "../lib/modules/tasks/schema.mjs";
30
+ import { WorkspaceResponseSchema, WorkspaceSchema } from "../lib/modules/workspace/schema.mjs";
31
+ import { TokenPayloadSchema } from "./shared/token.mjs";
32
+ import "../lib/modules/index.mjs";
33
+ import "./shared/index.mjs";
34
+ export { AddressValueSchema, AppConnectionCreateRequestSchema, AppConnectionResponseSchema, AppConnectionSchema, AppConnectionTypeSchema, AppConnectionsResponseSchema, AppInstallResponseSchema, AppInstallSchema, AppInstallTypeSchema, AppInstallsResponseSchema, AssemblyFileResponseSchema, AssemblyFileSchema, AssemblyFilesResponseSchema, AuditLogEventResponseSchema, AuditLogEventSchema, AuditLogEventsResponseSchema, ClientCreateRequestSchema, ClientResponseSchema, ClientSchema, ClientUpdateRequestSchema, ClientsResponseSchema, CompaniesResponseSchema, CompanyCreateRequestSchema, CompanyResponseSchema, CompanySchema, CompanyUpdateRequestSchema, ContractFieldInputTypeSchema, ContractFieldSchema, ContractResponseSchema, ContractSchema, ContractSendRequestSchema, ContractStatusSchema, ContractTemplateResponseSchema, ContractTemplateSchema, ContractTemplatesResponseSchema, ContractsResponseSchema, CustomFieldEntityTypeSchema, CustomFieldOptionSchema, CustomFieldSchema, CustomFieldTypeSchema, CustomFieldValueSchema, EmailDeliveryTargetSchema, EventActorTypeSchema, EventCreateRequestSchema, EventSourceSchema, FileChannelCreateRequestSchema, FileChannelResponseSchema, FileChannelSchema, FileChannelsResponseSchema, FileTypeSchema, FormDataResponseSchema, FormResponseCreateRequestSchema, FormResponseItemResponseSchema, FormResponseSchema, FormResponsesResponseSchema, FormSchema, FormsDataResponseSchema, HexColorSchema, InProductDeliveryTargetSchema, InternalUserResponseSchema, InternalUserSchema, InternalUsersResponseSchema, InvoiceCreateRequestSchema, InvoiceLineItemRequestSchema, InvoiceLineItemSchema, InvoicePaymentMethodPreferenceRequestSchema, InvoiceResponseSchema, InvoiceSchema, InvoiceStatusSchema, InvoiceTemplateResponseSchema, InvoiceTemplateSchema, InvoiceTemplatesResponseSchema, InvoicesResponseSchema, ListCustomFieldOptionResponseSchema, ListCustomFieldResponseSchema, MembershipTypeSchema, MessageChannelCreateRequestSchema, MessageChannelResponseSchema, MessageChannelSchema, MessageChannelsResponseSchema, MessageResponseSchema, MessageSchema, MessagesResponseSchema, NoteCreateRequestSchema, NoteResponseSchema, NoteSchema, NoteUpdateRequestSchema, NotesResponseSchema, NotificationCreateRequestSchema, NotificationDeliveryTargetsSchema, NotificationResponseSchema, NotificationSchema, NotificationsResponseSchema, PaymentMethodPreferenceSchema, PaymentMethodTypeSchema, PaymentResponseSchema, PaymentSchema, PaymentsResponseSchema, PriceResponseSchema, PriceSchema, PricesResponseSchema, ProductResponseSchema, ProductSchema, ProductsResponseSchema, SendMessageRequestSchema, SubscriptionCreateRequestSchema, SubscriptionResponseSchema, SubscriptionSchema, SubscriptionTemplateResponseSchema, SubscriptionTemplateSchema, SubscriptionTemplatesResponseSchema, SubscriptionsResponseSchema, TaskCreateRequestSchema, TaskResponseSchema, TaskSchema, TaskStatusSchema, TaskTemplateResponseSchema, TaskTemplateSchema, TaskTemplatesResponseSchema, TaskUpdateRequestSchema, TasksResponseSchema, TokenPayloadSchema, WorkspaceResponseSchema, WorkspaceSchema };
@@ -0,0 +1,8 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/schemas/shared/hex-color.d.ts
4
+ type HexColor = string;
5
+ declare const HexColorSchema: z.ZodType<HexColor>;
6
+ //#endregion
7
+ export { HexColor, HexColorSchema };
8
+ //# sourceMappingURL=hex-color.d.mts.map
@@ -0,0 +1,7 @@
1
+ import { z } from "zod";
2
+ //#region src/schemas/shared/hex-color.ts
3
+ const HexColorSchema = z.string().refine((val) => /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(val), { message: "Invalid hex color code" });
4
+ //#endregion
5
+ export { HexColorSchema };
6
+
7
+ //# sourceMappingURL=hex-color.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hex-color.mjs","names":[],"sources":["../../../src/schemas/shared/hex-color.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport type HexColor = string;\n\nexport const HexColorSchema: z.ZodType<HexColor> = z\n .string()\n .refine((val) => /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(val), {\n message: \"Invalid hex color code\",\n });\n"],"mappings":";;AAIA,MAAa,iBAAsC,EAChD,QAAQ,CACR,QAAQ,QAAQ,qCAAqC,KAAK,IAAI,EAAE,EAC/D,SAAS,0BACV,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { MembershipType, MembershipTypeSchema } from "./membership-type.mjs";
2
+ import { HexColor, HexColorSchema } from "./hex-color.mjs";
3
+ import { TokenPayload, TokenPayloadSchema } from "./token.mjs";
@@ -0,0 +1,4 @@
1
+ import "./membership-type.mjs";
2
+ import "./hex-color.mjs";
3
+ import "./token.mjs";
4
+ export {};
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/schemas/shared/membership-type.d.ts
4
+ /** Membership type shared across message channels, file channels, and app connections. */
5
+ type MembershipType = "company" | "group" | "individual";
6
+ declare const MembershipTypeSchema: z.ZodType<MembershipType>;
7
+ //#endregion
8
+ export { MembershipType, MembershipTypeSchema };
9
+ //# sourceMappingURL=membership-type.d.mts.map
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+ //#region src/schemas/shared/membership-type.ts
3
+ const MembershipTypeSchema = z.enum([
4
+ "individual",
5
+ "group",
6
+ "company"
7
+ ]);
8
+ //#endregion
9
+ export { MembershipTypeSchema };
10
+
11
+ //# sourceMappingURL=membership-type.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"membership-type.mjs","names":[],"sources":["../../../src/schemas/shared/membership-type.ts"],"sourcesContent":["import { z } from \"zod\";\n\n/** Membership type shared across message channels, file channels, and app connections. */\nexport type MembershipType = \"company\" | \"group\" | \"individual\";\n\nexport const MembershipTypeSchema: z.ZodType<MembershipType> = z.enum([\n \"individual\",\n \"group\",\n \"company\",\n]);\n"],"mappings":";;AAKA,MAAa,uBAAkD,EAAE,KAAK;CACpE;CACA;CACA;CACD,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/schemas/shared/token.d.ts
4
+ interface TokenPayload {
5
+ baseUrl?: string;
6
+ clientId?: string;
7
+ companyId?: string;
8
+ internalUserId?: string;
9
+ notificationId?: string;
10
+ tokenId?: string;
11
+ workspaceId: string;
12
+ }
13
+ /**
14
+ * Schema for a decrypted Assembly token payload.
15
+ * Unknown fields are silently stripped for forward compatibility.
16
+ * Requires either `internalUserId` (team member) or `clientId` (portal user).
17
+ * `companyId` is always optional.
18
+ */
19
+ declare const TokenPayloadSchema: z.ZodType<TokenPayload>;
20
+ //#endregion
21
+ export { TokenPayload, TokenPayloadSchema };
22
+ //# sourceMappingURL=token.d.mts.map
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ //#region src/schemas/shared/token.ts
3
+ /**
4
+ * Schema for a decrypted Assembly token payload.
5
+ * Unknown fields are silently stripped for forward compatibility.
6
+ * Requires either `internalUserId` (team member) or `clientId` (portal user).
7
+ * `companyId` is always optional.
8
+ */
9
+ const TokenPayloadSchema = z.object({
10
+ baseUrl: z.string().optional(),
11
+ clientId: z.string().optional(),
12
+ companyId: z.string().optional(),
13
+ internalUserId: z.string().optional(),
14
+ notificationId: z.string().optional(),
15
+ tokenId: z.string().optional(),
16
+ workspaceId: z.string().min(1)
17
+ }).refine((val) => val.internalUserId !== void 0 || val.clientId !== void 0, { message: "Token must contain either internalUserId or clientId" });
18
+ //#endregion
19
+ export { TokenPayloadSchema };
20
+
21
+ //# sourceMappingURL=token.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.mjs","names":[],"sources":["../../../src/schemas/shared/token.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport interface TokenPayload {\n baseUrl?: string;\n clientId?: string;\n companyId?: string;\n internalUserId?: string;\n notificationId?: string;\n tokenId?: string;\n workspaceId: string;\n}\n\n/**\n * Schema for a decrypted Assembly token payload.\n * Unknown fields are silently stripped for forward compatibility.\n * Requires either `internalUserId` (team member) or `clientId` (portal user).\n * `companyId` is always optional.\n */\nexport const TokenPayloadSchema: z.ZodType<TokenPayload> = z\n .object({\n baseUrl: z.string().optional(),\n clientId: z.string().optional(),\n companyId: z.string().optional(),\n internalUserId: z.string().optional(),\n notificationId: z.string().optional(),\n tokenId: z.string().optional(),\n workspaceId: z.string().min(1),\n })\n .refine((val) => val.internalUserId !== undefined || val.clientId !== undefined, {\n message: \"Token must contain either internalUserId or clientId\",\n });\n"],"mappings":";;;;;;;;AAkBA,MAAa,qBAA8C,EACxD,OAAO;CACN,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,UAAU,EAAE,QAAQ,CAAC,UAAU;CAC/B,WAAW,EAAE,QAAQ,CAAC,UAAU;CAChC,gBAAgB,EAAE,QAAQ,CAAC,UAAU;CACrC,gBAAgB,EAAE,QAAQ,CAAC,UAAU;CACrC,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,aAAa,EAAE,QAAQ,CAAC,IAAI,EAAE;CAC/B,CAAC,CACD,QAAQ,QAAQ,IAAI,mBAAmB,KAAA,KAAa,IAAI,aAAa,KAAA,GAAW,EAC/E,SAAS,wDACV,CAAC"}
@@ -0,0 +1,96 @@
1
+ import { TokenPayload } from "../schemas/shared/token.mjs";
2
+
3
+ //#region src/token/assembly-token.d.ts
4
+ /** A token payload that identifies a client (portal) user. */
5
+ interface ClientTokenPayload extends TokenPayload {
6
+ clientId: string;
7
+ companyId?: string;
8
+ }
9
+ /** A token payload that identifies an internal (team member) user. */
10
+ interface InternalUserTokenPayload extends TokenPayload {
11
+ internalUserId: string;
12
+ }
13
+ /**
14
+ * Decrypts and validates an Assembly token, exposing the payload with
15
+ * convenience getters for identity checks and compound key building.
16
+ *
17
+ * Use `AssemblyToken.run()` to store a request-scoped instance via
18
+ * `AsyncLocalStorage`, then retrieve it anywhere with `AssemblyToken.current()`.
19
+ * This is safe for Vercel fluid compute — no shared state across requests.
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * // Request-scoped (recommended for serverless)
24
+ * const t = AssemblyToken.new({ token: encryptedHex, apiKey });
25
+ * const same = AssemblyToken.new({ token: encryptedHex, apiKey }); // returns the same instance
26
+ *
27
+ * // Direct instantiation (always creates a new instance)
28
+ * const token = new AssemblyToken({ token: encryptedHex, apiKey });
29
+ * ```
30
+ *
31
+ * @throws {AssemblyNoTokenError} If `token` is nullish or empty.
32
+ * @throws {AssemblyInvalidTokenError} If decryption, JSON parsing, or schema validation fails.
33
+ */
34
+ declare class AssemblyToken {
35
+ #private;
36
+ readonly currentToken: string;
37
+ readonly payload: TokenPayload;
38
+ constructor({
39
+ token,
40
+ apiKey
41
+ }: {
42
+ token: unknown;
43
+ apiKey: string;
44
+ });
45
+ /**
46
+ * Get or create a request-scoped `AssemblyToken` instance via `AsyncLocalStorage`.
47
+ * Returns the existing instance if one exists with the same token. If the token
48
+ * differs, a new instance is created and replaces the previous one.
49
+ *
50
+ * @returns The `AssemblyToken` instance for the current async context.
51
+ */
52
+ static new(options: {
53
+ token: unknown;
54
+ apiKey: string;
55
+ }): AssemblyToken;
56
+ /** The workspace ID embedded in the token. Always present. */
57
+ get workspaceId(): string;
58
+ /** The token ID, if present (used in marketplace compound keys). */
59
+ get tokenId(): string | undefined;
60
+ /** The API base URL override, if present. */
61
+ get baseUrl(): string | undefined;
62
+ /** The client (portal user) ID, if present. */
63
+ get clientId(): string | undefined;
64
+ /** The company ID associated with the client, if present. */
65
+ get companyId(): string | undefined;
66
+ /** The internal (team member) user ID, if present. */
67
+ get internalUserId(): string | undefined;
68
+ /** `true` when the token belongs to a client (portal) user. */
69
+ get isClientUser(): boolean;
70
+ /** `true` when the token belongs to an internal (team member) user. */
71
+ get isInternalUser(): boolean;
72
+ /**
73
+ * Assert that the token belongs to a client user and return the narrowed payload.
74
+ * @throws {AssemblyUnauthorizedError} If the token does not represent a client user.
75
+ */
76
+ ensureIsClient(): ClientTokenPayload;
77
+ /**
78
+ * Assert that the token belongs to an internal (team member) user and return the narrowed payload.
79
+ * @throws {AssemblyUnauthorizedError} If the token does not represent an internal user.
80
+ */
81
+ ensureIsInternalUser(): InternalUserTokenPayload;
82
+ /**
83
+ * Build the compound API key sent in the `X-API-Key` header.
84
+ *
85
+ * - With `tokenId`: `{workspaceId}/{apiKey}/{tokenId}`
86
+ * - Without `tokenId`: `{workspaceId}/{apiKey}`
87
+ */
88
+ buildCompoundKey({
89
+ apiKey
90
+ }: {
91
+ apiKey: string;
92
+ }): string;
93
+ }
94
+ //#endregion
95
+ export { AssemblyToken, ClientTokenPayload, InternalUserTokenPayload };
96
+ //# sourceMappingURL=assembly-token.d.mts.map
@@ -0,0 +1,117 @@
1
+ import { AssemblyNoTokenError } from "../errors/no-token.mjs";
2
+ import { AssemblyInvalidTokenError } from "../errors/invalid-token.mjs";
3
+ import { AssemblyUnauthorizedError } from "../errors/unauthorized.mjs";
4
+ import { decrypt, validatePayload } from "./parse.mjs";
5
+ import { AsyncLocalStorage } from "node:async_hooks";
6
+ //#region src/token/assembly-token.ts
7
+ /**
8
+ * Decrypts and validates an Assembly token, exposing the payload with
9
+ * convenience getters for identity checks and compound key building.
10
+ *
11
+ * Use `AssemblyToken.run()` to store a request-scoped instance via
12
+ * `AsyncLocalStorage`, then retrieve it anywhere with `AssemblyToken.current()`.
13
+ * This is safe for Vercel fluid compute — no shared state across requests.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * // Request-scoped (recommended for serverless)
18
+ * const t = AssemblyToken.new({ token: encryptedHex, apiKey });
19
+ * const same = AssemblyToken.new({ token: encryptedHex, apiKey }); // returns the same instance
20
+ *
21
+ * // Direct instantiation (always creates a new instance)
22
+ * const token = new AssemblyToken({ token: encryptedHex, apiKey });
23
+ * ```
24
+ *
25
+ * @throws {AssemblyNoTokenError} If `token` is nullish or empty.
26
+ * @throws {AssemblyInvalidTokenError} If decryption, JSON parsing, or schema validation fails.
27
+ */
28
+ var AssemblyToken = class AssemblyToken {
29
+ static #store = new AsyncLocalStorage();
30
+ currentToken;
31
+ payload;
32
+ constructor({ token, apiKey }) {
33
+ if (token === void 0 || token === null || token === "") throw new AssemblyNoTokenError();
34
+ if (typeof token !== "string") throw new AssemblyInvalidTokenError({ message: `Expected token to be a string, got ${typeof token}` });
35
+ this.currentToken = token;
36
+ this.payload = validatePayload(decrypt({
37
+ apiKey,
38
+ token
39
+ }));
40
+ }
41
+ /**
42
+ * Get or create a request-scoped `AssemblyToken` instance via `AsyncLocalStorage`.
43
+ * Returns the existing instance if one exists with the same token. If the token
44
+ * differs, a new instance is created and replaces the previous one.
45
+ *
46
+ * @returns The `AssemblyToken` instance for the current async context.
47
+ */
48
+ static new(options) {
49
+ const existing = AssemblyToken.#store.getStore();
50
+ if (existing && existing.currentToken === options.token) return existing;
51
+ const instance = new AssemblyToken(options);
52
+ AssemblyToken.#store.enterWith(instance);
53
+ return instance;
54
+ }
55
+ /** The workspace ID embedded in the token. Always present. */
56
+ get workspaceId() {
57
+ return this.payload.workspaceId;
58
+ }
59
+ /** The token ID, if present (used in marketplace compound keys). */
60
+ get tokenId() {
61
+ return this.payload.tokenId;
62
+ }
63
+ /** The API base URL override, if present. */
64
+ get baseUrl() {
65
+ return this.payload.baseUrl;
66
+ }
67
+ /** The client (portal user) ID, if present. */
68
+ get clientId() {
69
+ return this.payload.clientId;
70
+ }
71
+ /** The company ID associated with the client, if present. */
72
+ get companyId() {
73
+ return this.payload.companyId;
74
+ }
75
+ /** The internal (team member) user ID, if present. */
76
+ get internalUserId() {
77
+ return this.payload.internalUserId;
78
+ }
79
+ /** `true` when the token belongs to a client (portal) user. */
80
+ get isClientUser() {
81
+ return this.payload.clientId !== void 0;
82
+ }
83
+ /** `true` when the token belongs to an internal (team member) user. */
84
+ get isInternalUser() {
85
+ return this.payload.internalUserId !== void 0;
86
+ }
87
+ /**
88
+ * Assert that the token belongs to a client user and return the narrowed payload.
89
+ * @throws {AssemblyUnauthorizedError} If the token does not represent a client user.
90
+ */
91
+ ensureIsClient() {
92
+ if (!this.isClientUser) throw new AssemblyUnauthorizedError({ message: "This operation requires a client token (clientId), but the token does not contain a clientId" });
93
+ return this.payload;
94
+ }
95
+ /**
96
+ * Assert that the token belongs to an internal (team member) user and return the narrowed payload.
97
+ * @throws {AssemblyUnauthorizedError} If the token does not represent an internal user.
98
+ */
99
+ ensureIsInternalUser() {
100
+ if (!this.isInternalUser) throw new AssemblyUnauthorizedError({ message: "This operation requires an internal user token (internalUserId), but the token does not contain an internalUserId" });
101
+ return this.payload;
102
+ }
103
+ /**
104
+ * Build the compound API key sent in the `X-API-Key` header.
105
+ *
106
+ * - With `tokenId`: `{workspaceId}/{apiKey}/{tokenId}`
107
+ * - Without `tokenId`: `{workspaceId}/{apiKey}`
108
+ */
109
+ buildCompoundKey({ apiKey }) {
110
+ if (this.payload.tokenId) return `${this.payload.workspaceId}/${apiKey}/${this.payload.tokenId}`;
111
+ return `${this.payload.workspaceId}/${apiKey}`;
112
+ }
113
+ };
114
+ //#endregion
115
+ export { AssemblyToken };
116
+
117
+ //# sourceMappingURL=assembly-token.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assembly-token.mjs","names":["#store"],"sources":["../../src/token/assembly-token.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\n\nimport { AssemblyInvalidTokenError } from \"src/errors/invalid-token\";\nimport { AssemblyNoTokenError } from \"src/errors/no-token\";\nimport { AssemblyUnauthorizedError } from \"src/errors/unauthorized\";\nimport type { TokenPayload } from \"src/schemas/shared/token\";\n\nimport { decrypt, validatePayload } from \"./parse\";\n\n/** A token payload that identifies a client (portal) user. */\nexport interface ClientTokenPayload extends TokenPayload {\n clientId: string;\n companyId?: string;\n}\n\n/** A token payload that identifies an internal (team member) user. */\nexport interface InternalUserTokenPayload extends TokenPayload {\n internalUserId: string;\n}\n\n/**\n * Decrypts and validates an Assembly token, exposing the payload with\n * convenience getters for identity checks and compound key building.\n *\n * Use `AssemblyToken.run()` to store a request-scoped instance via\n * `AsyncLocalStorage`, then retrieve it anywhere with `AssemblyToken.current()`.\n * This is safe for Vercel fluid compute — no shared state across requests.\n *\n * @example\n * ```ts\n * // Request-scoped (recommended for serverless)\n * const t = AssemblyToken.new({ token: encryptedHex, apiKey });\n * const same = AssemblyToken.new({ token: encryptedHex, apiKey }); // returns the same instance\n *\n * // Direct instantiation (always creates a new instance)\n * const token = new AssemblyToken({ token: encryptedHex, apiKey });\n * ```\n *\n * @throws {AssemblyNoTokenError} If `token` is nullish or empty.\n * @throws {AssemblyInvalidTokenError} If decryption, JSON parsing, or schema validation fails.\n */\nexport class AssemblyToken {\n static readonly #store: AsyncLocalStorage<AssemblyToken> = new AsyncLocalStorage<AssemblyToken>();\n\n readonly currentToken: string;\n readonly payload: TokenPayload;\n\n constructor({ token, apiKey }: { token: unknown; apiKey: string }) {\n if (token === undefined || token === null || token === \"\") {\n throw new AssemblyNoTokenError();\n }\n\n if (typeof token !== \"string\") {\n throw new AssemblyInvalidTokenError({\n message: `Expected token to be a string, got ${typeof token}`,\n });\n }\n\n this.currentToken = token;\n this.payload = validatePayload(decrypt({ apiKey, token }));\n }\n\n /**\n * Get or create a request-scoped `AssemblyToken` instance via `AsyncLocalStorage`.\n * Returns the existing instance if one exists with the same token. If the token\n * differs, a new instance is created and replaces the previous one.\n *\n * @returns The `AssemblyToken` instance for the current async context.\n */\n static new(options: { token: unknown; apiKey: string }): AssemblyToken {\n const existing = AssemblyToken.#store.getStore();\n if (existing && existing.currentToken === options.token) {\n return existing;\n }\n const instance = new AssemblyToken(options);\n AssemblyToken.#store.enterWith(instance);\n return instance;\n }\n\n /** The workspace ID embedded in the token. Always present. */\n get workspaceId(): string {\n return this.payload.workspaceId;\n }\n\n /** The token ID, if present (used in marketplace compound keys). */\n get tokenId(): string | undefined {\n return this.payload.tokenId;\n }\n\n /** The API base URL override, if present. */\n get baseUrl(): string | undefined {\n return this.payload.baseUrl;\n }\n\n /** The client (portal user) ID, if present. */\n get clientId(): string | undefined {\n return this.payload.clientId;\n }\n\n /** The company ID associated with the client, if present. */\n get companyId(): string | undefined {\n return this.payload.companyId;\n }\n\n /** The internal (team member) user ID, if present. */\n get internalUserId(): string | undefined {\n return this.payload.internalUserId;\n }\n\n /** `true` when the token belongs to a client (portal) user. */\n get isClientUser(): boolean {\n return this.payload.clientId !== undefined;\n }\n\n /** `true` when the token belongs to an internal (team member) user. */\n get isInternalUser(): boolean {\n return this.payload.internalUserId !== undefined;\n }\n\n /**\n * Assert that the token belongs to a client user and return the narrowed payload.\n * @throws {AssemblyUnauthorizedError} If the token does not represent a client user.\n */\n ensureIsClient(): ClientTokenPayload {\n if (!this.isClientUser) {\n throw new AssemblyUnauthorizedError({\n message:\n \"This operation requires a client token (clientId), but the token does not contain a clientId\",\n });\n }\n return this.payload as ClientTokenPayload;\n }\n\n /**\n * Assert that the token belongs to an internal (team member) user and return the narrowed payload.\n * @throws {AssemblyUnauthorizedError} If the token does not represent an internal user.\n */\n ensureIsInternalUser(): InternalUserTokenPayload {\n if (!this.isInternalUser) {\n throw new AssemblyUnauthorizedError({\n message:\n \"This operation requires an internal user token (internalUserId), but the token does not contain an internalUserId\",\n });\n }\n return this.payload as InternalUserTokenPayload;\n }\n\n /**\n * Build the compound API key sent in the `X-API-Key` header.\n *\n * - With `tokenId`: `{workspaceId}/{apiKey}/{tokenId}`\n * - Without `tokenId`: `{workspaceId}/{apiKey}`\n */\n buildCompoundKey({ apiKey }: { apiKey: string }): string {\n if (this.payload.tokenId) {\n return `${this.payload.workspaceId}/${apiKey}/${this.payload.tokenId}`;\n }\n return `${this.payload.workspaceId}/${apiKey}`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,gBAAb,MAAa,cAAc;CACzB,QAAA,QAA2D,IAAI,mBAAkC;CAEjG;CACA;CAEA,YAAY,EAAE,OAAO,UAA8C;AACjE,MAAI,UAAU,KAAA,KAAa,UAAU,QAAQ,UAAU,GACrD,OAAM,IAAI,sBAAsB;AAGlC,MAAI,OAAO,UAAU,SACnB,OAAM,IAAI,0BAA0B,EAClC,SAAS,sCAAsC,OAAO,SACvD,CAAC;AAGJ,OAAK,eAAe;AACpB,OAAK,UAAU,gBAAgB,QAAQ;GAAE;GAAQ;GAAO,CAAC,CAAC;;;;;;;;;CAU5D,OAAO,IAAI,SAA4D;EACrE,MAAM,WAAW,eAAA,MAAqB,UAAU;AAChD,MAAI,YAAY,SAAS,iBAAiB,QAAQ,MAChD,QAAO;EAET,MAAM,WAAW,IAAI,cAAc,QAAQ;AAC3C,iBAAA,MAAqB,UAAU,SAAS;AACxC,SAAO;;;CAIT,IAAI,cAAsB;AACxB,SAAO,KAAK,QAAQ;;;CAItB,IAAI,UAA8B;AAChC,SAAO,KAAK,QAAQ;;;CAItB,IAAI,UAA8B;AAChC,SAAO,KAAK,QAAQ;;;CAItB,IAAI,WAA+B;AACjC,SAAO,KAAK,QAAQ;;;CAItB,IAAI,YAAgC;AAClC,SAAO,KAAK,QAAQ;;;CAItB,IAAI,iBAAqC;AACvC,SAAO,KAAK,QAAQ;;;CAItB,IAAI,eAAwB;AAC1B,SAAO,KAAK,QAAQ,aAAa,KAAA;;;CAInC,IAAI,iBAA0B;AAC5B,SAAO,KAAK,QAAQ,mBAAmB,KAAA;;;;;;CAOzC,iBAAqC;AACnC,MAAI,CAAC,KAAK,aACR,OAAM,IAAI,0BAA0B,EAClC,SACE,gGACH,CAAC;AAEJ,SAAO,KAAK;;;;;;CAOd,uBAAiD;AAC/C,MAAI,CAAC,KAAK,eACR,OAAM,IAAI,0BAA0B,EAClC,SACE,qHACH,CAAC;AAEJ,SAAO,KAAK;;;;;;;;CASd,iBAAiB,EAAE,UAAsC;AACvD,MAAI,KAAK,QAAQ,QACf,QAAO,GAAG,KAAK,QAAQ,YAAY,GAAG,OAAO,GAAG,KAAK,QAAQ;AAE/D,SAAO,GAAG,KAAK,QAAQ,YAAY,GAAG"}
@@ -0,0 +1,98 @@
1
+ import { createCipheriv, createDecipheriv, createHmac, randomBytes } from "node:crypto";
2
+ //#region src/token/crypto.ts
3
+ /**
4
+ * Derive a 128-bit AES key from the API key using HMAC-SHA256.
5
+ * Takes the first 32 hex characters (16 bytes) of the HMAC digest.
6
+ */
7
+ const deriveKey = (apiKey) => createHmac("sha256", apiKey).digest("hex").slice(0, 32);
8
+ /**
9
+ * Strip PKCS7 padding from raw decrypted bytes.
10
+ * Uses constant-time comparison to prevent timing side-channel attacks.
11
+ */
12
+ const stripPkcs7 = (raw) => {
13
+ const padLen = raw.at(-1);
14
+ if (padLen === void 0 || padLen < 1 || padLen > 16) throw new Error(`Invalid PKCS7 padding byte: ${padLen}`);
15
+ let mismatches = 0;
16
+ for (let i = raw.length - padLen; i < raw.length; i += 1) if (raw[i] !== padLen) mismatches += 1;
17
+ if (mismatches > 0) throw new Error("Invalid PKCS7 padding");
18
+ return raw.subarray(0, raw.length - padLen);
19
+ };
20
+ /** Parse the hex-encoded token into key buffer, IV, and ciphertext. */
21
+ const parseEncryptedToken = ({ apiKey, encryptedToken }) => {
22
+ const keyBuffer = Buffer.from(deriveKey(apiKey), "hex");
23
+ const blob = Buffer.from(encryptedToken, "hex");
24
+ return {
25
+ ciphertext: blob.subarray(16),
26
+ iv: blob.subarray(0, 16),
27
+ keyBuffer
28
+ };
29
+ };
30
+ /** Decrypt with native autoPadding (works on Node 18/22 and most Bun versions). */
31
+ const decryptNative = ({ ciphertext, iv, keyBuffer }) => {
32
+ const decipher = createDecipheriv("aes-128-cbc", keyBuffer, iv);
33
+ return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
34
+ };
35
+ /**
36
+ * Decrypt with manual PKCS7 strip (handles Node 24 OpenSSL 3.4/3.5 edge case).
37
+ * If the runtime ignores setAutoPadding(false) and strips padding anyway
38
+ * (some Bun versions), the result won't be block-aligned — return it as-is.
39
+ */
40
+ const decryptManual = ({ ciphertext, iv, keyBuffer }) => {
41
+ const decipher = createDecipheriv("aes-128-cbc", keyBuffer, iv);
42
+ decipher.setAutoPadding(false);
43
+ const raw = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
44
+ if (raw.length % 16 !== 0) return raw.toString("utf8");
45
+ return stripPkcs7(raw).toString("utf8");
46
+ };
47
+ /**
48
+ * Decrypt an AES-128-CBC encrypted token string using the API key.
49
+ *
50
+ * The encrypted token is a hex-encoded binary blob where:
51
+ * - First 16 bytes = IV (initialization vector)
52
+ * - Remaining bytes = ciphertext
53
+ *
54
+ * Strategy: try native autoPadding first (works on most runtimes), then
55
+ * fall back to manual PKCS7 strip with autoPadding disabled. This handles:
56
+ * - Node 24 (OpenSSL 3.4/3.5) where autoPadding fails on block-aligned payloads
57
+ * - Bun versions where setAutoPadding(false) may be silently ignored
58
+ *
59
+ * @throws {Error} If decryption fails on both paths
60
+ */
61
+ const decryptTokenString = ({ apiKey, encryptedToken }) => {
62
+ const parts = parseEncryptedToken({
63
+ apiKey,
64
+ encryptedToken
65
+ });
66
+ try {
67
+ return decryptNative(parts);
68
+ } catch (nativeError) {
69
+ try {
70
+ return decryptManual(parts);
71
+ } catch {
72
+ throw nativeError;
73
+ }
74
+ }
75
+ };
76
+ /**
77
+ * Encrypt a plaintext string into a hex-encoded AES-128-CBC token.
78
+ *
79
+ * Produces a hex blob where the first 16 bytes are a random IV followed
80
+ * by the PKCS7-padded ciphertext — the exact format that `decryptTokenString`
81
+ * expects.
82
+ *
83
+ * @param {object} options - Encryption options.
84
+ * @param {string} options.apiKey - The workspace/app API key used to derive the encryption key.
85
+ * @param {string} options.plaintext - The plaintext string to encrypt (typically JSON).
86
+ * @returns {string} The hex-encoded encrypted token.
87
+ */
88
+ const encryptTokenString = ({ apiKey, plaintext }) => {
89
+ const keyBuffer = Buffer.from(deriveKey(apiKey), "hex");
90
+ const iv = randomBytes(16);
91
+ const cipher = createCipheriv("aes-128-cbc", keyBuffer, iv);
92
+ const encrypted = Buffer.concat([cipher.update(plaintext, "utf8"), cipher.final()]);
93
+ return Buffer.concat([iv, encrypted]).toString("hex");
94
+ };
95
+ //#endregion
96
+ export { decryptTokenString, encryptTokenString };
97
+
98
+ //# sourceMappingURL=crypto.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.mjs","names":[],"sources":["../../src/token/crypto.ts"],"sourcesContent":["import { createCipheriv, createDecipheriv, createHmac, randomBytes } from \"node:crypto\";\n\n/**\n * Derive a 128-bit AES key from the API key using HMAC-SHA256.\n * Takes the first 32 hex characters (16 bytes) of the HMAC digest.\n */\nexport const deriveKey = (apiKey: string): string =>\n createHmac(\"sha256\", apiKey).digest(\"hex\").slice(0, 32);\n\n/**\n * Strip PKCS7 padding from raw decrypted bytes.\n * Uses constant-time comparison to prevent timing side-channel attacks.\n */\nconst stripPkcs7 = (raw: Buffer): Buffer => {\n const padLen = raw.at(-1);\n if (padLen === undefined || padLen < 1 || padLen > 16) {\n throw new Error(`Invalid PKCS7 padding byte: ${padLen}`);\n }\n\n // Always check every padding byte (no early exit) to avoid timing side-channels\n let mismatches = 0;\n for (let i = raw.length - padLen; i < raw.length; i += 1) {\n if (raw[i] !== padLen) {\n mismatches += 1;\n }\n }\n\n if (mismatches > 0) {\n throw new Error(\"Invalid PKCS7 padding\");\n }\n\n return raw.subarray(0, raw.length - padLen);\n};\n\ninterface CipherParts {\n keyBuffer: Buffer;\n iv: Buffer;\n ciphertext: Buffer;\n}\n\n/** Parse the hex-encoded token into key buffer, IV, and ciphertext. */\nconst parseEncryptedToken = ({\n apiKey,\n encryptedToken,\n}: {\n apiKey: string;\n encryptedToken: string;\n}): CipherParts => {\n const keyBuffer = Buffer.from(deriveKey(apiKey), \"hex\");\n const blob = Buffer.from(encryptedToken, \"hex\");\n return { ciphertext: blob.subarray(16), iv: blob.subarray(0, 16), keyBuffer };\n};\n\n/** Decrypt with native autoPadding (works on Node 18/22 and most Bun versions). */\nconst decryptNative = ({ ciphertext, iv, keyBuffer }: CipherParts): string => {\n const decipher = createDecipheriv(\"aes-128-cbc\", keyBuffer, iv);\n return Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString(\"utf8\");\n};\n\n/**\n * Decrypt with manual PKCS7 strip (handles Node 24 OpenSSL 3.4/3.5 edge case).\n * If the runtime ignores setAutoPadding(false) and strips padding anyway\n * (some Bun versions), the result won't be block-aligned — return it as-is.\n */\nconst decryptManual = ({ ciphertext, iv, keyBuffer }: CipherParts): string => {\n const decipher = createDecipheriv(\"aes-128-cbc\", keyBuffer, iv);\n decipher.setAutoPadding(false);\n const raw = Buffer.concat([decipher.update(ciphertext), decipher.final()]);\n\n // If length isn't a multiple of 16, the runtime already stripped padding\n if (raw.length % 16 !== 0) {\n return raw.toString(\"utf8\");\n }\n\n return stripPkcs7(raw).toString(\"utf8\");\n};\n\n/**\n * Decrypt an AES-128-CBC encrypted token string using the API key.\n *\n * The encrypted token is a hex-encoded binary blob where:\n * - First 16 bytes = IV (initialization vector)\n * - Remaining bytes = ciphertext\n *\n * Strategy: try native autoPadding first (works on most runtimes), then\n * fall back to manual PKCS7 strip with autoPadding disabled. This handles:\n * - Node 24 (OpenSSL 3.4/3.5) where autoPadding fails on block-aligned payloads\n * - Bun versions where setAutoPadding(false) may be silently ignored\n *\n * @throws {Error} If decryption fails on both paths\n */\nexport const decryptTokenString = ({\n apiKey,\n encryptedToken,\n}: {\n apiKey: string;\n encryptedToken: string;\n}): string => {\n const parts = parseEncryptedToken({ apiKey, encryptedToken });\n\n try {\n return decryptNative(parts);\n } catch (nativeError: unknown) {\n try {\n return decryptManual(parts);\n } catch {\n // Both paths failed — throw the native error as it's more informative\n throw nativeError;\n }\n }\n};\n\n/**\n * Encrypt a plaintext string into a hex-encoded AES-128-CBC token.\n *\n * Produces a hex blob where the first 16 bytes are a random IV followed\n * by the PKCS7-padded ciphertext — the exact format that `decryptTokenString`\n * expects.\n *\n * @param {object} options - Encryption options.\n * @param {string} options.apiKey - The workspace/app API key used to derive the encryption key.\n * @param {string} options.plaintext - The plaintext string to encrypt (typically JSON).\n * @returns {string} The hex-encoded encrypted token.\n */\nexport const encryptTokenString = ({\n apiKey,\n plaintext,\n}: {\n apiKey: string;\n plaintext: string;\n}): string => {\n const keyBuffer = Buffer.from(deriveKey(apiKey), \"hex\");\n const iv = randomBytes(16);\n const cipher = createCipheriv(\"aes-128-cbc\", keyBuffer, iv);\n const encrypted = Buffer.concat([cipher.update(plaintext, \"utf8\"), cipher.final()]);\n return Buffer.concat([iv, encrypted]).toString(\"hex\");\n};\n"],"mappings":";;;;;;AAMA,MAAa,aAAa,WACxB,WAAW,UAAU,OAAO,CAAC,OAAO,MAAM,CAAC,MAAM,GAAG,GAAG;;;;;AAMzD,MAAM,cAAc,QAAwB;CAC1C,MAAM,SAAS,IAAI,GAAG,GAAG;AACzB,KAAI,WAAW,KAAA,KAAa,SAAS,KAAK,SAAS,GACjD,OAAM,IAAI,MAAM,+BAA+B,SAAS;CAI1D,IAAI,aAAa;AACjB,MAAK,IAAI,IAAI,IAAI,SAAS,QAAQ,IAAI,IAAI,QAAQ,KAAK,EACrD,KAAI,IAAI,OAAO,OACb,eAAc;AAIlB,KAAI,aAAa,EACf,OAAM,IAAI,MAAM,wBAAwB;AAG1C,QAAO,IAAI,SAAS,GAAG,IAAI,SAAS,OAAO;;;AAU7C,MAAM,uBAAuB,EAC3B,QACA,qBAIiB;CACjB,MAAM,YAAY,OAAO,KAAK,UAAU,OAAO,EAAE,MAAM;CACvD,MAAM,OAAO,OAAO,KAAK,gBAAgB,MAAM;AAC/C,QAAO;EAAE,YAAY,KAAK,SAAS,GAAG;EAAE,IAAI,KAAK,SAAS,GAAG,GAAG;EAAE;EAAW;;;AAI/E,MAAM,iBAAiB,EAAE,YAAY,IAAI,gBAAqC;CAC5E,MAAM,WAAW,iBAAiB,eAAe,WAAW,GAAG;AAC/D,QAAO,OAAO,OAAO,CAAC,SAAS,OAAO,WAAW,EAAE,SAAS,OAAO,CAAC,CAAC,CAAC,SAAS,OAAO;;;;;;;AAQxF,MAAM,iBAAiB,EAAE,YAAY,IAAI,gBAAqC;CAC5E,MAAM,WAAW,iBAAiB,eAAe,WAAW,GAAG;AAC/D,UAAS,eAAe,MAAM;CAC9B,MAAM,MAAM,OAAO,OAAO,CAAC,SAAS,OAAO,WAAW,EAAE,SAAS,OAAO,CAAC,CAAC;AAG1E,KAAI,IAAI,SAAS,OAAO,EACtB,QAAO,IAAI,SAAS,OAAO;AAG7B,QAAO,WAAW,IAAI,CAAC,SAAS,OAAO;;;;;;;;;;;;;;;;AAiBzC,MAAa,sBAAsB,EACjC,QACA,qBAIY;CACZ,MAAM,QAAQ,oBAAoB;EAAE;EAAQ;EAAgB,CAAC;AAE7D,KAAI;AACF,SAAO,cAAc,MAAM;UACpB,aAAsB;AAC7B,MAAI;AACF,UAAO,cAAc,MAAM;UACrB;AAEN,SAAM;;;;;;;;;;;;;;;;AAiBZ,MAAa,sBAAsB,EACjC,QACA,gBAIY;CACZ,MAAM,YAAY,OAAO,KAAK,UAAU,OAAO,EAAE,MAAM;CACvD,MAAM,KAAK,YAAY,GAAG;CAC1B,MAAM,SAAS,eAAe,eAAe,WAAW,GAAG;CAC3D,MAAM,YAAY,OAAO,OAAO,CAAC,OAAO,OAAO,WAAW,OAAO,EAAE,OAAO,OAAO,CAAC,CAAC;AACnF,QAAO,OAAO,OAAO,CAAC,IAAI,UAAU,CAAC,CAAC,SAAS,MAAM"}
@@ -0,0 +1,3 @@
1
+ import { AssemblyToken, ClientTokenPayload, InternalUserTokenPayload } from "./assembly-token.mjs";
2
+ import { createToken } from "./parse.mjs";
3
+ export { AssemblyToken, type ClientTokenPayload, type InternalUserTokenPayload, createToken };
@@ -0,0 +1,3 @@
1
+ import { createToken } from "./parse.mjs";
2
+ import { AssemblyToken } from "./assembly-token.mjs";
3
+ export { AssemblyToken, createToken };
@@ -0,0 +1,24 @@
1
+ import { TokenPayload } from "../schemas/shared/token.mjs";
2
+
3
+ //#region src/token/parse.d.ts
4
+ /**
5
+ * Encrypt a token payload into a hex-encoded AES-128-CBC token string.
6
+ *
7
+ * The payload is validated against `TokenPayloadSchema`, serialized to JSON,
8
+ * and encrypted using the API key with HMAC-SHA256 key derivation and AES-128-CBC.
9
+ *
10
+ * @param options.payload - The token payload to encrypt.
11
+ * @param options.apiKey - The workspace/app API key used to derive the encryption key.
12
+ * @returns The hex-encoded encrypted token string.
13
+ * @throws {AssemblyInvalidTokenError} If the payload fails schema validation.
14
+ */
15
+ declare const createToken: ({
16
+ payload,
17
+ apiKey
18
+ }: {
19
+ payload: TokenPayload;
20
+ apiKey: string;
21
+ }) => string;
22
+ //#endregion
23
+ export { createToken };
24
+ //# sourceMappingURL=parse.d.mts.map
@@ -0,0 +1,62 @@
1
+ import { AssemblyInvalidTokenError } from "../errors/invalid-token.mjs";
2
+ import { TokenPayloadSchema } from "../schemas/shared/token.mjs";
3
+ import { decryptTokenString, encryptTokenString } from "./crypto.mjs";
4
+ //#region src/token/parse.ts
5
+ /** Decrypt the token string, wrapping errors as AssemblyInvalidTokenError. */
6
+ const decrypt = ({ apiKey, token }) => {
7
+ try {
8
+ return decryptTokenString({
9
+ apiKey,
10
+ encryptedToken: token
11
+ });
12
+ } catch (error) {
13
+ throw new AssemblyInvalidTokenError({
14
+ cause: error,
15
+ message: "Failed to decrypt token — verify the API key and token are correct"
16
+ });
17
+ }
18
+ };
19
+ /** Parse + validate decrypted JSON against TokenPayloadSchema. */
20
+ const validatePayload = (decrypted) => {
21
+ let parsed;
22
+ try {
23
+ parsed = JSON.parse(decrypted);
24
+ } catch (error) {
25
+ throw new AssemblyInvalidTokenError({
26
+ cause: error,
27
+ message: "Decrypted token is not valid JSON"
28
+ });
29
+ }
30
+ const result = TokenPayloadSchema.safeParse(parsed);
31
+ if (!result.success) throw new AssemblyInvalidTokenError({
32
+ cause: result.error,
33
+ message: "Token payload failed schema validation"
34
+ });
35
+ return result.data;
36
+ };
37
+ /**
38
+ * Encrypt a token payload into a hex-encoded AES-128-CBC token string.
39
+ *
40
+ * The payload is validated against `TokenPayloadSchema`, serialized to JSON,
41
+ * and encrypted using the API key with HMAC-SHA256 key derivation and AES-128-CBC.
42
+ *
43
+ * @param options.payload - The token payload to encrypt.
44
+ * @param options.apiKey - The workspace/app API key used to derive the encryption key.
45
+ * @returns The hex-encoded encrypted token string.
46
+ * @throws {AssemblyInvalidTokenError} If the payload fails schema validation.
47
+ */
48
+ const createToken = ({ payload, apiKey }) => {
49
+ const result = TokenPayloadSchema.safeParse(payload);
50
+ if (!result.success) throw new AssemblyInvalidTokenError({
51
+ cause: result.error,
52
+ message: "Token payload failed schema validation"
53
+ });
54
+ return encryptTokenString({
55
+ apiKey,
56
+ plaintext: JSON.stringify(result.data)
57
+ });
58
+ };
59
+ //#endregion
60
+ export { createToken, decrypt, validatePayload };
61
+
62
+ //# sourceMappingURL=parse.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.mjs","names":[],"sources":["../../src/token/parse.ts"],"sourcesContent":["import { AssemblyInvalidTokenError } from \"src/errors/invalid-token\";\nimport type { TokenPayload } from \"src/schemas/shared/token\";\nimport { TokenPayloadSchema } from \"src/schemas/shared/token\";\n\nimport { decryptTokenString, encryptTokenString } from \"./crypto\";\n\n/** Decrypt the token string, wrapping errors as AssemblyInvalidTokenError. */\nexport const decrypt = ({ apiKey, token }: { apiKey: string; token: string }): string => {\n try {\n return decryptTokenString({ apiKey, encryptedToken: token });\n } catch (error) {\n throw new AssemblyInvalidTokenError({\n cause: error,\n message: \"Failed to decrypt token — verify the API key and token are correct\",\n });\n }\n};\n\n/** Parse + validate decrypted JSON against TokenPayloadSchema. */\nexport const validatePayload = (decrypted: string): TokenPayload => {\n let parsed: unknown;\n try {\n parsed = JSON.parse(decrypted);\n } catch (error) {\n throw new AssemblyInvalidTokenError({\n cause: error,\n message: \"Decrypted token is not valid JSON\",\n });\n }\n\n const result = TokenPayloadSchema.safeParse(parsed);\n if (!result.success) {\n throw new AssemblyInvalidTokenError({\n cause: result.error,\n message: \"Token payload failed schema validation\",\n });\n }\n\n return result.data;\n};\n\n/**\n * Encrypt a token payload into a hex-encoded AES-128-CBC token string.\n *\n * The payload is validated against `TokenPayloadSchema`, serialized to JSON,\n * and encrypted using the API key with HMAC-SHA256 key derivation and AES-128-CBC.\n *\n * @param options.payload - The token payload to encrypt.\n * @param options.apiKey - The workspace/app API key used to derive the encryption key.\n * @returns The hex-encoded encrypted token string.\n * @throws {AssemblyInvalidTokenError} If the payload fails schema validation.\n */\nexport const createToken = ({\n payload,\n apiKey,\n}: {\n payload: TokenPayload;\n apiKey: string;\n}): string => {\n const result = TokenPayloadSchema.safeParse(payload);\n if (!result.success) {\n throw new AssemblyInvalidTokenError({\n cause: result.error,\n message: \"Token payload failed schema validation\",\n });\n }\n\n return encryptTokenString({\n apiKey,\n plaintext: JSON.stringify(result.data),\n });\n};\n"],"mappings":";;;;;AAOA,MAAa,WAAW,EAAE,QAAQ,YAAuD;AACvF,KAAI;AACF,SAAO,mBAAmB;GAAE;GAAQ,gBAAgB;GAAO,CAAC;UACrD,OAAO;AACd,QAAM,IAAI,0BAA0B;GAClC,OAAO;GACP,SAAS;GACV,CAAC;;;;AAKN,MAAa,mBAAmB,cAAoC;CAClE,IAAI;AACJ,KAAI;AACF,WAAS,KAAK,MAAM,UAAU;UACvB,OAAO;AACd,QAAM,IAAI,0BAA0B;GAClC,OAAO;GACP,SAAS;GACV,CAAC;;CAGJ,MAAM,SAAS,mBAAmB,UAAU,OAAO;AACnD,KAAI,CAAC,OAAO,QACV,OAAM,IAAI,0BAA0B;EAClC,OAAO,OAAO;EACd,SAAS;EACV,CAAC;AAGJ,QAAO,OAAO;;;;;;;;;;;;;AAchB,MAAa,eAAe,EAC1B,SACA,aAIY;CACZ,MAAM,SAAS,mBAAmB,UAAU,QAAQ;AACpD,KAAI,CAAC,OAAO,QACV,OAAM,IAAI,0BAA0B;EAClC,OAAO,OAAO;EACd,SAAS;EACV,CAAC;AAGJ,QAAO,mBAAmB;EACxB;EACA,WAAW,KAAK,UAAU,OAAO,KAAK;EACvC,CAAC"}
@@ -0,0 +1,16 @@
1
+ //#region src/transport/build-search-params.ts
2
+ /**
3
+ * Builds a search params record from an optional args object,
4
+ * filtering out `undefined` and `null` values and keeping only
5
+ * string, number, and boolean values.
6
+ */
7
+ const buildSearchParams = (args) => {
8
+ if (!args) return {};
9
+ const params = {};
10
+ for (const [key, value] of Object.entries(args)) if (value !== void 0 && value !== null && (typeof value === "string" || typeof value === "number" || typeof value === "boolean")) params[key] = value;
11
+ return params;
12
+ };
13
+ //#endregion
14
+ export { buildSearchParams };
15
+
16
+ //# sourceMappingURL=build-search-params.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-search-params.mjs","names":[],"sources":["../../src/transport/build-search-params.ts"],"sourcesContent":["/**\n * Builds a search params record from an optional args object,\n * filtering out `undefined` and `null` values and keeping only\n * string, number, and boolean values.\n */\n// eslint-disable-next-line typescript/no-explicit-any -- accepts any args object\nexport const buildSearchParams = (args?: any): Record<string, string | number | boolean> => {\n if (!args) return {};\n\n const params: Record<string, string | number | boolean> = {};\n for (const [key, value] of Object.entries(args)) {\n if (\n value !== undefined &&\n value !== null &&\n (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\")\n ) {\n params[key] = value;\n }\n }\n return params;\n};\n"],"mappings":";;;;;;AAMA,MAAa,qBAAqB,SAA0D;AAC1F,KAAI,CAAC,KAAM,QAAO,EAAE;CAEpB,MAAM,SAAoD,EAAE;AAC5D,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,CAC7C,KACE,UAAU,KAAA,KACV,UAAU,SACT,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,OAAO,UAAU,WAE5E,QAAO,OAAO;AAGlB,QAAO"}