@qlever-llc/trellis 0.5.1 → 0.6.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 (490) hide show
  1. package/README.md +16 -2
  2. package/esm/_dnt.polyfills.d.ts +11 -0
  3. package/esm/_dnt.polyfills.d.ts.map +1 -1
  4. package/esm/_dnt.polyfills.js +14 -0
  5. package/esm/_dnt.shims.d.ts +6 -0
  6. package/esm/_dnt.shims.d.ts.map +1 -0
  7. package/esm/_dnt.shims.js +61 -0
  8. package/esm/auth/browser/login.d.ts +27 -0
  9. package/esm/auth/browser/login.d.ts.map +1 -0
  10. package/esm/auth/browser/login.js +94 -0
  11. package/esm/auth/browser/portal.d.ts +11 -0
  12. package/esm/auth/browser/portal.d.ts.map +1 -0
  13. package/esm/auth/browser/portal.js +33 -0
  14. package/esm/auth/browser/session.d.ts +19 -0
  15. package/esm/auth/browser/session.d.ts.map +1 -0
  16. package/esm/auth/browser/session.js +65 -0
  17. package/esm/auth/browser/storage.d.ts +12 -0
  18. package/esm/auth/browser/storage.d.ts.map +1 -0
  19. package/esm/auth/browser/storage.js +61 -0
  20. package/esm/auth/browser.d.ts +13 -0
  21. package/esm/auth/browser.d.ts.map +1 -0
  22. package/esm/auth/browser.js +11 -0
  23. package/esm/auth/keys.d.ts +5 -0
  24. package/esm/auth/keys.d.ts.map +1 -0
  25. package/esm/auth/keys.js +50 -0
  26. package/esm/auth/mod.d.ts +18 -0
  27. package/esm/auth/mod.d.ts.map +1 -0
  28. package/esm/auth/mod.js +17 -0
  29. package/esm/auth/proof.d.ts +9 -0
  30. package/esm/auth/proof.d.ts.map +1 -0
  31. package/esm/auth/proof.js +43 -0
  32. package/esm/auth/protocol.d.ts +1212 -0
  33. package/esm/auth/protocol.d.ts.map +1 -0
  34. package/esm/auth/protocol.js +682 -0
  35. package/esm/auth/schemas.d.ts +93 -0
  36. package/esm/auth/schemas.d.ts.map +1 -0
  37. package/esm/auth/schemas.js +64 -0
  38. package/esm/auth/session_auth.d.ts +20 -0
  39. package/esm/auth/session_auth.d.ts.map +1 -0
  40. package/esm/auth/session_auth.js +42 -0
  41. package/esm/auth/trellis_id.d.ts +2 -0
  42. package/esm/auth/trellis_id.d.ts.map +1 -0
  43. package/esm/auth/trellis_id.js +5 -0
  44. package/esm/auth/types.d.ts +8 -0
  45. package/esm/auth/types.d.ts.map +1 -0
  46. package/esm/auth/types.js +1 -0
  47. package/esm/auth/utils.d.ts +11 -0
  48. package/esm/auth/utils.d.ts.map +1 -0
  49. package/esm/auth/utils.js +68 -0
  50. package/esm/auth/workload_activation.d.ts +192 -0
  51. package/esm/auth/workload_activation.d.ts.map +1 -0
  52. package/esm/auth/workload_activation.js +290 -0
  53. package/esm/contracts/canonical.d.ts +14 -0
  54. package/esm/contracts/canonical.d.ts.map +1 -0
  55. package/esm/contracts/canonical.js +135 -0
  56. package/esm/contracts/mod.d.ts +462 -0
  57. package/esm/contracts/mod.d.ts.map +1 -0
  58. package/esm/contracts/mod.js +532 -0
  59. package/esm/contracts/protocol.d.ts +301 -0
  60. package/esm/contracts/protocol.d.ts.map +1 -0
  61. package/esm/contracts/protocol.js +130 -0
  62. package/esm/contracts/runtime.d.ts +48 -0
  63. package/esm/contracts/runtime.d.ts.map +1 -0
  64. package/esm/contracts/runtime.js +9 -0
  65. package/esm/contracts/schema_pointers.d.ts +18 -0
  66. package/esm/contracts/schema_pointers.d.ts.map +1 -0
  67. package/esm/contracts/schema_pointers.js +59 -0
  68. package/esm/server/deno.d.ts +7 -0
  69. package/esm/server/deno.d.ts.map +1 -0
  70. package/esm/server/deno.js +16 -0
  71. package/esm/server/health.d.ts +92 -0
  72. package/esm/server/health.d.ts.map +1 -0
  73. package/esm/server/health.js +74 -0
  74. package/esm/server/health_rpc.d.ts +16 -0
  75. package/esm/server/health_rpc.d.ts.map +1 -0
  76. package/esm/server/health_rpc.js +23 -0
  77. package/esm/server/health_schemas.d.ts +20 -0
  78. package/esm/server/health_schemas.d.ts.map +1 -0
  79. package/esm/server/health_schemas.js +18 -0
  80. package/esm/server/mod.d.ts +17 -0
  81. package/esm/server/mod.d.ts.map +1 -0
  82. package/esm/server/mod.js +17 -0
  83. package/esm/server/node.d.ts +7 -0
  84. package/esm/server/node.d.ts.map +1 -0
  85. package/esm/server/node.js +16 -0
  86. package/esm/server/runtime.d.ts +16 -0
  87. package/esm/server/runtime.d.ts.map +1 -0
  88. package/esm/server/runtime.js +1 -0
  89. package/esm/server/service.d.ts +121 -0
  90. package/esm/server/service.d.ts.map +1 -0
  91. package/esm/server/service.js +256 -0
  92. package/esm/server/subscription.d.ts +99 -0
  93. package/esm/server/subscription.d.ts.map +1 -0
  94. package/esm/server/subscription.js +25 -0
  95. package/esm/telemetry/carrier.d.ts +9 -0
  96. package/esm/telemetry/carrier.d.ts.map +1 -0
  97. package/esm/telemetry/carrier.js +20 -0
  98. package/esm/telemetry/core.d.ts +8 -0
  99. package/esm/telemetry/core.d.ts.map +1 -0
  100. package/esm/telemetry/core.js +14 -0
  101. package/esm/telemetry/env.d.ts +2 -0
  102. package/esm/telemetry/env.d.ts.map +1 -0
  103. package/esm/telemetry/env.js +10 -0
  104. package/esm/telemetry/mod.d.ts +11 -0
  105. package/esm/telemetry/mod.d.ts.map +1 -0
  106. package/esm/telemetry/mod.js +7 -0
  107. package/esm/telemetry/nats.d.ts +7 -0
  108. package/esm/telemetry/nats.d.ts.map +1 -0
  109. package/esm/telemetry/nats.js +6 -0
  110. package/esm/telemetry/result.d.ts +2 -0
  111. package/esm/telemetry/result.d.ts.map +1 -0
  112. package/esm/telemetry/result.js +18 -0
  113. package/esm/telemetry/runtime.d.ts +2 -0
  114. package/esm/telemetry/runtime.d.ts.map +1 -0
  115. package/esm/telemetry/runtime.js +53 -0
  116. package/esm/telemetry/trace.d.ts +5 -0
  117. package/esm/telemetry/trace.d.ts.map +1 -0
  118. package/esm/telemetry/trace.js +26 -0
  119. package/esm/telemetry/trellis.d.ts +3 -0
  120. package/esm/telemetry/trellis.d.ts.map +1 -0
  121. package/esm/telemetry/trellis.js +7 -0
  122. package/esm/trellis/_sdk/activity/_dnt.polyfills.d.ts +12 -0
  123. package/esm/trellis/_sdk/activity/_dnt.polyfills.d.ts.map +1 -0
  124. package/esm/trellis/_sdk/activity/_dnt.polyfills.js +15 -0
  125. package/esm/trellis/_sdk/activity/api.d.ts +10 -0
  126. package/esm/trellis/_sdk/activity/api.d.ts.map +1 -0
  127. package/esm/trellis/_sdk/activity/api.js +43 -0
  128. package/esm/trellis/_sdk/activity/contract.d.ts +8 -0
  129. package/esm/trellis/_sdk/activity/contract.d.ts.map +1 -0
  130. package/esm/trellis/_sdk/activity/contract.js +59 -0
  131. package/esm/trellis/_sdk/activity/mod.d.ts +7 -0
  132. package/esm/trellis/_sdk/activity/mod.d.ts.map +1 -0
  133. package/esm/trellis/_sdk/activity/mod.js +5 -0
  134. package/esm/trellis/_sdk/activity/package.json +3 -0
  135. package/esm/trellis/_sdk/activity/schemas.d.ts +607 -0
  136. package/esm/trellis/_sdk/activity/schemas.d.ts.map +1 -0
  137. package/esm/trellis/_sdk/activity/schemas.js +33 -0
  138. package/esm/trellis/_sdk/activity/types.d.ts +96 -0
  139. package/esm/trellis/_sdk/activity/types.d.ts.map +1 -0
  140. package/esm/trellis/_sdk/activity/types.js +3 -0
  141. package/esm/trellis/_sdk/auth/_dnt.polyfills.d.ts +12 -0
  142. package/esm/trellis/_sdk/auth/_dnt.polyfills.d.ts.map +1 -0
  143. package/esm/trellis/_sdk/auth/_dnt.polyfills.js +15 -0
  144. package/esm/trellis/_sdk/auth/api.d.ts +10 -0
  145. package/esm/trellis/_sdk/auth/api.d.ts.map +1 -0
  146. package/esm/trellis/_sdk/auth/api.js +354 -0
  147. package/esm/trellis/_sdk/auth/contract.d.ts +28 -0
  148. package/esm/trellis/_sdk/auth/contract.d.ts.map +1 -0
  149. package/esm/trellis/_sdk/auth/contract.js +83 -0
  150. package/esm/trellis/_sdk/auth/mod.d.ts +7 -0
  151. package/esm/trellis/_sdk/auth/mod.d.ts.map +1 -0
  152. package/esm/trellis/_sdk/auth/mod.js +5 -0
  153. package/esm/trellis/_sdk/auth/package.json +3 -0
  154. package/esm/trellis/_sdk/auth/schemas.d.ts +8967 -0
  155. package/esm/trellis/_sdk/auth/schemas.d.ts.map +1 -0
  156. package/esm/trellis/_sdk/auth/schemas.js +306 -0
  157. package/esm/trellis/_sdk/auth/types.d.ts +1232 -0
  158. package/esm/trellis/_sdk/auth/types.d.ts.map +1 -0
  159. package/esm/trellis/_sdk/auth/types.js +3 -0
  160. package/esm/trellis/_sdk/core/_dnt.polyfills.d.ts +12 -0
  161. package/esm/trellis/_sdk/core/_dnt.polyfills.d.ts.map +1 -0
  162. package/esm/trellis/_sdk/core/_dnt.polyfills.js +15 -0
  163. package/esm/trellis/_sdk/core/api.d.ts +10 -0
  164. package/esm/trellis/_sdk/core/api.d.ts.map +1 -0
  165. package/esm/trellis/_sdk/core/api.js +36 -0
  166. package/esm/trellis/_sdk/core/contract.d.ts +8 -0
  167. package/esm/trellis/_sdk/core/contract.d.ts.map +1 -0
  168. package/esm/trellis/_sdk/core/contract.js +59 -0
  169. package/esm/trellis/_sdk/core/mod.d.ts +7 -0
  170. package/esm/trellis/_sdk/core/mod.d.ts.map +1 -0
  171. package/esm/trellis/_sdk/core/mod.js +5 -0
  172. package/esm/trellis/_sdk/core/package.json +3 -0
  173. package/esm/trellis/_sdk/core/schemas.d.ts +1144 -0
  174. package/esm/trellis/_sdk/core/schemas.d.ts.map +1 -0
  175. package/esm/trellis/_sdk/core/schemas.js +28 -0
  176. package/esm/trellis/_sdk/core/types.d.ts +176 -0
  177. package/esm/trellis/_sdk/core/types.d.ts.map +1 -0
  178. package/esm/trellis/_sdk/core/types.js +3 -0
  179. package/esm/trellis/auth/browser.d.ts +3 -0
  180. package/esm/trellis/auth/browser.d.ts.map +1 -0
  181. package/esm/trellis/auth/browser.js +2 -0
  182. package/esm/trellis/auth.d.ts +3 -0
  183. package/esm/trellis/auth.d.ts.map +1 -0
  184. package/esm/trellis/auth.js +2 -0
  185. package/esm/trellis/browser.d.ts +2 -7
  186. package/esm/trellis/browser.d.ts.map +1 -1
  187. package/esm/trellis/browser.js +2 -7
  188. package/esm/trellis/client.d.ts +6 -4
  189. package/esm/trellis/client.d.ts.map +1 -1
  190. package/esm/trellis/client.js +28 -1
  191. package/esm/trellis/codec.d.ts +4 -3
  192. package/esm/trellis/codec.d.ts.map +1 -1
  193. package/esm/trellis/codec.js +15 -2
  194. package/esm/trellis/contract.d.ts +11 -0
  195. package/esm/trellis/contract.d.ts.map +1 -0
  196. package/esm/trellis/contract.js +15 -0
  197. package/esm/trellis/contracts.d.ts +5 -0
  198. package/esm/trellis/contracts.d.ts.map +1 -0
  199. package/esm/trellis/contracts.js +3 -0
  200. package/esm/trellis/env.d.ts +1 -1
  201. package/esm/trellis/env.d.ts.map +1 -1
  202. package/esm/trellis/env.js +1 -1
  203. package/esm/trellis/errors/AuthError.d.ts +1 -1
  204. package/esm/trellis/errors/AuthError.d.ts.map +1 -1
  205. package/esm/trellis/errors/AuthError.js +11 -0
  206. package/esm/trellis/errors/RemoteError.d.ts +3 -3
  207. package/esm/trellis/errors/RemoteError.d.ts.map +1 -1
  208. package/esm/trellis/errors/RemoteError.js +3 -3
  209. package/esm/trellis/errors/TrellisError.d.ts +1 -1
  210. package/esm/trellis/errors/TrellisError.js +1 -1
  211. package/esm/trellis/errors/index.d.ts +2 -1
  212. package/esm/trellis/errors/index.d.ts.map +1 -1
  213. package/esm/trellis/errors/index.js +3 -2
  214. package/esm/trellis/globals.d.ts +9 -1
  215. package/esm/trellis/globals.d.ts.map +1 -1
  216. package/esm/trellis/globals.js +16 -8
  217. package/esm/trellis/helpers.d.ts +2 -1
  218. package/esm/trellis/helpers.d.ts.map +1 -1
  219. package/esm/trellis/helpers.js +1 -0
  220. package/esm/trellis/index.d.ts +13 -5
  221. package/esm/trellis/index.d.ts.map +1 -1
  222. package/esm/trellis/index.js +8 -3
  223. package/esm/trellis/kv.d.ts +10 -7
  224. package/esm/trellis/kv.d.ts.map +1 -1
  225. package/esm/trellis/kv.js +57 -34
  226. package/esm/trellis/models/trellis/TrellisError.d.ts +1 -1
  227. package/esm/trellis/models/trellis/TrellisError.js +1 -1
  228. package/esm/trellis/operations.d.ts +81 -0
  229. package/esm/trellis/operations.d.ts.map +1 -0
  230. package/esm/trellis/operations.js +206 -0
  231. package/esm/trellis/sdk/activity.d.ts +3 -0
  232. package/esm/trellis/sdk/activity.d.ts.map +1 -0
  233. package/esm/trellis/sdk/activity.js +2 -0
  234. package/esm/trellis/sdk/auth.d.ts +4 -0
  235. package/esm/trellis/sdk/auth.d.ts.map +1 -0
  236. package/esm/trellis/sdk/auth.js +3 -0
  237. package/esm/trellis/sdk/core.d.ts +4 -0
  238. package/esm/trellis/sdk/core.d.ts.map +1 -0
  239. package/esm/trellis/sdk/core.js +3 -0
  240. package/esm/trellis/server/deno.d.ts +3 -0
  241. package/esm/trellis/server/deno.d.ts.map +1 -0
  242. package/esm/trellis/server/deno.js +2 -0
  243. package/esm/trellis/server/health.d.ts +5 -0
  244. package/esm/trellis/server/health.d.ts.map +1 -0
  245. package/esm/trellis/server/health.js +3 -0
  246. package/esm/trellis/server/mod.d.ts +3 -0
  247. package/esm/trellis/server/mod.d.ts.map +1 -0
  248. package/esm/trellis/server/mod.js +2 -0
  249. package/esm/trellis/server/node.d.ts +3 -0
  250. package/esm/trellis/server/node.d.ts.map +1 -0
  251. package/esm/trellis/server/node.js +2 -0
  252. package/esm/trellis/server/runtime.d.ts +4 -0
  253. package/esm/trellis/server/runtime.d.ts.map +1 -0
  254. package/esm/trellis/server/runtime.js +2 -0
  255. package/esm/trellis/server.d.ts +21 -0
  256. package/esm/trellis/server.d.ts.map +1 -0
  257. package/esm/trellis/server.js +536 -0
  258. package/esm/trellis/server_logger.d.ts +3 -0
  259. package/esm/trellis/server_logger.d.ts.map +1 -0
  260. package/esm/trellis/server_logger.js +7 -0
  261. package/esm/trellis/tasks.d.ts +3 -3
  262. package/esm/trellis/tasks.d.ts.map +1 -1
  263. package/esm/trellis/tasks.js +1 -1
  264. package/esm/trellis/tracing.d.ts +2 -2
  265. package/esm/trellis/tracing.d.ts.map +1 -1
  266. package/esm/trellis/tracing.js +2 -2
  267. package/esm/trellis/trellis.d.ts +167 -78
  268. package/esm/trellis/trellis.d.ts.map +1 -1
  269. package/esm/trellis/trellis.js +281 -87
  270. package/esm/trellis/workload.d.ts +45 -0
  271. package/esm/trellis/workload.d.ts.map +1 -0
  272. package/esm/trellis/workload.js +144 -0
  273. package/package.json +63 -4
  274. package/script/auth/browser/login.d.ts +27 -0
  275. package/script/auth/browser/login.d.ts.map +1 -0
  276. package/script/auth/browser/login.js +100 -0
  277. package/script/auth/browser/portal.d.ts +11 -0
  278. package/script/auth/browser/portal.d.ts.map +1 -0
  279. package/script/auth/browser/portal.js +40 -0
  280. package/script/auth/browser/session.d.ts +19 -0
  281. package/script/auth/browser/session.d.ts.map +1 -0
  282. package/script/auth/browser/session.js +79 -0
  283. package/script/auth/browser/storage.d.ts +12 -0
  284. package/script/auth/browser/storage.d.ts.map +1 -0
  285. package/script/auth/browser/storage.js +67 -0
  286. package/script/auth/browser.d.ts +13 -0
  287. package/script/auth/browser.d.ts.map +1 -0
  288. package/script/auth/browser.js +46 -0
  289. package/script/auth/keys.d.ts +5 -0
  290. package/script/auth/keys.d.ts.map +1 -0
  291. package/script/auth/keys.js +56 -0
  292. package/script/auth/mod.d.ts +18 -0
  293. package/script/auth/mod.d.ts.map +1 -0
  294. package/script/auth/mod.js +172 -0
  295. package/script/auth/proof.d.ts +9 -0
  296. package/script/auth/proof.d.ts.map +1 -0
  297. package/script/auth/proof.js +48 -0
  298. package/script/auth/protocol.d.ts +1212 -0
  299. package/script/auth/protocol.d.ts.map +1 -0
  300. package/script/auth/protocol.js +687 -0
  301. package/script/auth/schemas.d.ts +93 -0
  302. package/script/auth/schemas.d.ts.map +1 -0
  303. package/script/auth/schemas.js +67 -0
  304. package/script/auth/session_auth.d.ts +20 -0
  305. package/script/auth/session_auth.d.ts.map +1 -0
  306. package/script/auth/session_auth.js +45 -0
  307. package/script/auth/trellis_id.d.ts +2 -0
  308. package/script/auth/trellis_id.d.ts.map +1 -0
  309. package/script/auth/trellis_id.js +8 -0
  310. package/script/auth/types.d.ts +8 -0
  311. package/script/auth/types.d.ts.map +1 -0
  312. package/script/auth/utils.d.ts +11 -0
  313. package/script/auth/utils.d.ts.map +1 -0
  314. package/script/auth/utils.js +77 -0
  315. package/script/auth/workload_activation.d.ts +192 -0
  316. package/script/auth/workload_activation.d.ts.map +1 -0
  317. package/script/auth/workload_activation.js +308 -0
  318. package/script/contracts/canonical.d.ts +14 -0
  319. package/script/contracts/canonical.d.ts.map +1 -0
  320. package/script/contracts/canonical.js +144 -0
  321. package/script/contracts/mod.d.ts +462 -0
  322. package/script/contracts/mod.d.ts.map +1 -0
  323. package/script/contracts/mod.js +555 -0
  324. package/script/contracts/protocol.d.ts +301 -0
  325. package/script/contracts/protocol.d.ts.map +1 -0
  326. package/script/contracts/protocol.js +136 -0
  327. package/script/contracts/runtime.d.ts +48 -0
  328. package/script/contracts/runtime.d.ts.map +1 -0
  329. package/script/contracts/runtime.js +13 -0
  330. package/script/contracts/schema_pointers.d.ts +18 -0
  331. package/script/contracts/schema_pointers.d.ts.map +1 -0
  332. package/script/contracts/schema_pointers.js +63 -0
  333. package/script/telemetry/carrier.d.ts +9 -0
  334. package/script/telemetry/carrier.d.ts.map +1 -0
  335. package/script/telemetry/carrier.js +25 -0
  336. package/script/telemetry/core.d.ts +8 -0
  337. package/script/telemetry/core.d.ts.map +1 -0
  338. package/script/telemetry/core.js +24 -0
  339. package/script/telemetry/env.d.ts +2 -0
  340. package/script/telemetry/env.d.ts.map +1 -0
  341. package/script/telemetry/env.js +12 -0
  342. package/script/telemetry/mod.d.ts +11 -0
  343. package/script/telemetry/mod.d.ts.map +1 -0
  344. package/script/telemetry/mod.js +29 -0
  345. package/script/telemetry/nats.d.ts +7 -0
  346. package/script/telemetry/nats.d.ts.map +1 -0
  347. package/script/telemetry/nats.js +9 -0
  348. package/script/telemetry/result.d.ts +2 -0
  349. package/script/telemetry/result.d.ts.map +1 -0
  350. package/script/telemetry/result.js +21 -0
  351. package/script/telemetry/runtime.d.ts +2 -0
  352. package/script/telemetry/runtime.d.ts.map +1 -0
  353. package/script/telemetry/runtime.js +79 -0
  354. package/script/telemetry/trace.d.ts +5 -0
  355. package/script/telemetry/trace.d.ts.map +1 -0
  356. package/script/telemetry/trace.js +31 -0
  357. package/script/telemetry/trellis.d.ts +3 -0
  358. package/script/telemetry/trellis.d.ts.map +1 -0
  359. package/script/telemetry/trellis.js +14 -0
  360. package/script/trellis/_sdk/activity/_dnt.polyfills.d.ts +12 -0
  361. package/script/trellis/_sdk/activity/_dnt.polyfills.d.ts.map +1 -0
  362. package/script/trellis/_sdk/activity/_dnt.polyfills.js +16 -0
  363. package/script/trellis/_sdk/activity/api.d.ts +10 -0
  364. package/script/trellis/_sdk/activity/api.d.ts.map +1 -0
  365. package/script/trellis/_sdk/activity/api.js +46 -0
  366. package/script/trellis/_sdk/activity/contract.d.ts +8 -0
  367. package/script/trellis/_sdk/activity/contract.d.ts.map +1 -0
  368. package/script/trellis/_sdk/activity/contract.js +62 -0
  369. package/script/trellis/_sdk/activity/mod.d.ts +7 -0
  370. package/script/trellis/_sdk/activity/mod.d.ts.map +1 -0
  371. package/script/trellis/_sdk/activity/mod.js +30 -0
  372. package/script/trellis/_sdk/activity/package.json +3 -0
  373. package/script/trellis/_sdk/activity/schemas.d.ts +607 -0
  374. package/script/trellis/_sdk/activity/schemas.d.ts.map +1 -0
  375. package/script/trellis/_sdk/activity/schemas.js +36 -0
  376. package/script/trellis/_sdk/activity/types.d.ts +96 -0
  377. package/script/trellis/_sdk/activity/types.d.ts.map +1 -0
  378. package/script/trellis/_sdk/activity/types.js +6 -0
  379. package/script/trellis/_sdk/auth/_dnt.polyfills.d.ts +12 -0
  380. package/script/trellis/_sdk/auth/_dnt.polyfills.d.ts.map +1 -0
  381. package/script/trellis/_sdk/auth/_dnt.polyfills.js +16 -0
  382. package/script/trellis/_sdk/auth/api.d.ts +10 -0
  383. package/script/trellis/_sdk/auth/api.d.ts.map +1 -0
  384. package/script/trellis/_sdk/auth/api.js +357 -0
  385. package/script/trellis/_sdk/auth/contract.d.ts +28 -0
  386. package/script/trellis/_sdk/auth/contract.d.ts.map +1 -0
  387. package/script/trellis/_sdk/auth/contract.js +86 -0
  388. package/script/trellis/_sdk/auth/mod.d.ts +7 -0
  389. package/script/trellis/_sdk/auth/mod.d.ts.map +1 -0
  390. package/script/trellis/_sdk/auth/mod.js +31 -0
  391. package/script/trellis/_sdk/auth/package.json +3 -0
  392. package/script/trellis/_sdk/auth/schemas.d.ts +8967 -0
  393. package/script/trellis/_sdk/auth/schemas.d.ts.map +1 -0
  394. package/script/trellis/_sdk/auth/schemas.js +309 -0
  395. package/script/trellis/_sdk/auth/types.d.ts +1232 -0
  396. package/script/trellis/_sdk/auth/types.d.ts.map +1 -0
  397. package/script/trellis/_sdk/auth/types.js +6 -0
  398. package/script/trellis/_sdk/core/_dnt.polyfills.d.ts +12 -0
  399. package/script/trellis/_sdk/core/_dnt.polyfills.d.ts.map +1 -0
  400. package/script/trellis/_sdk/core/_dnt.polyfills.js +16 -0
  401. package/script/trellis/_sdk/core/api.d.ts +10 -0
  402. package/script/trellis/_sdk/core/api.d.ts.map +1 -0
  403. package/script/trellis/_sdk/core/api.js +39 -0
  404. package/script/trellis/_sdk/core/contract.d.ts +8 -0
  405. package/script/trellis/_sdk/core/contract.d.ts.map +1 -0
  406. package/script/trellis/_sdk/core/contract.js +62 -0
  407. package/script/trellis/_sdk/core/mod.d.ts +7 -0
  408. package/script/trellis/_sdk/core/mod.d.ts.map +1 -0
  409. package/script/trellis/_sdk/core/mod.js +30 -0
  410. package/script/trellis/_sdk/core/package.json +3 -0
  411. package/script/trellis/_sdk/core/schemas.d.ts +1144 -0
  412. package/script/trellis/_sdk/core/schemas.d.ts.map +1 -0
  413. package/script/trellis/_sdk/core/schemas.js +31 -0
  414. package/script/trellis/_sdk/core/types.d.ts +176 -0
  415. package/script/trellis/_sdk/core/types.d.ts.map +1 -0
  416. package/script/trellis/_sdk/core/types.js +6 -0
  417. package/script/trellis/auth.d.ts +2 -0
  418. package/script/trellis/auth.d.ts.map +1 -0
  419. package/script/trellis/auth.js +17 -0
  420. package/script/trellis/client.d.ts +8 -6
  421. package/script/trellis/client.d.ts.map +1 -1
  422. package/script/trellis/client.js +54 -3
  423. package/script/trellis/codec.d.ts +5 -4
  424. package/script/trellis/codec.d.ts.map +1 -1
  425. package/script/trellis/codec.js +31 -17
  426. package/script/trellis/contract.d.ts +11 -0
  427. package/script/trellis/contract.d.ts.map +1 -0
  428. package/script/trellis/contract.js +18 -0
  429. package/script/trellis/contracts.d.ts +4 -0
  430. package/script/trellis/contracts.d.ts.map +1 -0
  431. package/script/trellis/contracts.js +20 -0
  432. package/script/trellis/errors/AuthError.d.ts +2 -2
  433. package/script/trellis/errors/AuthError.d.ts.map +1 -1
  434. package/script/trellis/errors/AuthError.js +13 -2
  435. package/script/trellis/errors/KVError.d.ts +1 -1
  436. package/script/trellis/errors/KVError.d.ts.map +1 -1
  437. package/script/trellis/errors/KVError.js +2 -2
  438. package/script/trellis/errors/RemoteError.d.ts +4 -4
  439. package/script/trellis/errors/RemoteError.d.ts.map +1 -1
  440. package/script/trellis/errors/RemoteError.js +11 -11
  441. package/script/trellis/errors/TrellisError.d.ts +1 -1
  442. package/script/trellis/errors/TrellisError.d.ts.map +1 -1
  443. package/script/trellis/errors/TrellisError.js +2 -2
  444. package/script/trellis/errors/ValidationError.d.ts +1 -1
  445. package/script/trellis/errors/ValidationError.d.ts.map +1 -1
  446. package/script/trellis/errors/ValidationError.js +2 -2
  447. package/script/trellis/errors/index.d.ts +14 -14
  448. package/script/trellis/errors/index.d.ts.map +1 -1
  449. package/script/trellis/errors/index.js +31 -31
  450. package/script/trellis/globals.d.ts +9 -1
  451. package/script/trellis/globals.d.ts.map +1 -1
  452. package/script/trellis/globals.js +16 -8
  453. package/script/trellis/helpers.d.ts +1 -1
  454. package/script/trellis/helpers.d.ts.map +1 -1
  455. package/script/trellis/index.d.ts +17 -10
  456. package/script/trellis/index.d.ts.map +1 -1
  457. package/script/trellis/index.js +57 -22
  458. package/script/trellis/kv.d.ts +11 -8
  459. package/script/trellis/kv.d.ts.map +1 -1
  460. package/script/trellis/kv.js +91 -68
  461. package/script/trellis/models/trellis/TrellisError.d.ts +1 -1
  462. package/script/trellis/models/trellis/TrellisError.d.ts.map +1 -1
  463. package/script/trellis/models/trellis/TrellisError.js +8 -8
  464. package/script/trellis/operations.d.ts +81 -0
  465. package/script/trellis/operations.d.ts.map +1 -0
  466. package/script/trellis/operations.js +212 -0
  467. package/script/trellis/sdk/core.d.ts +3 -0
  468. package/script/trellis/sdk/core.d.ts.map +1 -0
  469. package/script/trellis/sdk/core.js +20 -0
  470. package/script/trellis/tasks.d.ts +3 -3
  471. package/script/trellis/tasks.d.ts.map +1 -1
  472. package/script/trellis/tasks.js +5 -5
  473. package/script/trellis/tracing.d.ts +2 -3
  474. package/script/trellis/tracing.d.ts.map +1 -1
  475. package/script/trellis/tracing.js +17 -20
  476. package/script/trellis/trellis.d.ts +169 -80
  477. package/script/trellis/trellis.d.ts.map +1 -1
  478. package/script/trellis/trellis.js +379 -177
  479. package/script/trellis/workload.d.ts +45 -0
  480. package/script/trellis/workload.d.ts.map +1 -0
  481. package/script/trellis/workload.js +172 -0
  482. package/script/_dnt.polyfills.d.ts +0 -7
  483. package/script/_dnt.polyfills.d.ts.map +0 -1
  484. package/script/trellis/browser.d.ts +0 -11
  485. package/script/trellis/browser.d.ts.map +0 -1
  486. package/script/trellis/browser.js +0 -21
  487. package/script/trellis/env.d.ts +0 -2
  488. package/script/trellis/env.d.ts.map +0 -1
  489. package/script/trellis/env.js +0 -5
  490. /package/script/{_dnt.polyfills.js → auth/types.js} +0 -0
@@ -0,0 +1,290 @@
1
+ import { Type } from "typebox";
2
+ import { Value } from "typebox/value";
3
+ import { importEd25519PrivateKeyFromSeedBase64url, importEd25519PublicKeyFromBase64url, publicKeyBase64urlFromPrivateKey, } from "./keys.js";
4
+ import { AuthGetWorkloadConnectInfoResponseSchema, WaitForWorkloadActivationResponseSchema, } from "./protocol.js";
5
+ import { base64urlDecode, base64urlEncode, sha256, toArrayBuffer, utf8 } from "./utils.js";
6
+ const WORKLOAD_IDENTITY_HKDF_INFO = "trellis/workload-identity/v1";
7
+ const WORKLOAD_ACTIVATION_HKDF_INFO = "trellis/workload-activate/v1";
8
+ const WORKLOAD_QR_MAC_DOMAIN = "trellis-workload-qr/v1";
9
+ const WORKLOAD_CONFIRMATION_DOMAIN = "trellis-workload-confirm/v1";
10
+ const CROCKFORD_ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
11
+ const DEFAULT_WAIT_POLL_INTERVAL_MS = 1_000;
12
+ export const WorkloadActivationPayloadSchema = Type.Object({
13
+ v: Type.Literal(1),
14
+ publicIdentityKey: Type.String({ minLength: 1 }),
15
+ nonce: Type.String({ minLength: 1 }),
16
+ qrMac: Type.String({ minLength: 1 }),
17
+ }, { additionalProperties: false });
18
+ export const WorkloadActivationWaitRequestSchema = Type.Object({
19
+ publicIdentityKey: Type.String({ minLength: 1 }),
20
+ nonce: Type.String({ minLength: 1 }),
21
+ contractDigest: Type.Optional(Type.String({ minLength: 1 })),
22
+ iat: Type.Number(),
23
+ sig: Type.String({ minLength: 1 }),
24
+ }, { additionalProperties: false });
25
+ function concatBytes(parts) {
26
+ const size = parts.reduce((total, part) => total + part.length, 0);
27
+ const bytes = new Uint8Array(size);
28
+ let offset = 0;
29
+ for (const part of parts) {
30
+ bytes.set(part, offset);
31
+ offset += part.length;
32
+ }
33
+ return bytes;
34
+ }
35
+ function normalizeSecretBytes(value, name) {
36
+ if (typeof value === "string") {
37
+ const decoded = base64urlDecode(value);
38
+ if (decoded.length === 0)
39
+ throw new Error(`${name} must not be empty`);
40
+ return decoded;
41
+ }
42
+ if (value.length === 0)
43
+ throw new Error(`${name} must not be empty`);
44
+ return value;
45
+ }
46
+ async function hkdfSha256(inputKeyingMaterial, info, length) {
47
+ const key = await crypto.subtle.importKey("raw", toArrayBuffer(inputKeyingMaterial), "HKDF", false, ["deriveBits"]);
48
+ const derivedBits = await crypto.subtle.deriveBits({
49
+ name: "HKDF",
50
+ hash: "SHA-256",
51
+ salt: toArrayBuffer(new Uint8Array(0)),
52
+ info: toArrayBuffer(utf8(info)),
53
+ }, key, length * 8);
54
+ return new Uint8Array(derivedBits);
55
+ }
56
+ async function hmacSha256(keyBytes, data) {
57
+ const key = await crypto.subtle.importKey("raw", toArrayBuffer(keyBytes), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
58
+ return new Uint8Array(await crypto.subtle.sign("HMAC", key, toArrayBuffer(data)));
59
+ }
60
+ function crockfordEncode(bytes) {
61
+ let value = 0;
62
+ let bits = 0;
63
+ let output = "";
64
+ for (const byte of bytes) {
65
+ value = (value << 8) | byte;
66
+ bits += 8;
67
+ while (bits >= 5) {
68
+ bits -= 5;
69
+ output += CROCKFORD_ALPHABET[(value >>> bits) & 31] ?? "0";
70
+ }
71
+ }
72
+ if (bits > 0) {
73
+ output += CROCKFORD_ALPHABET[(value << (5 - bits)) & 31] ?? "0";
74
+ }
75
+ return output;
76
+ }
77
+ function normalizeCrockford(value) {
78
+ return value.trim().toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1");
79
+ }
80
+ async function sleep(ms, signal) {
81
+ if (signal?.aborted)
82
+ throw signal.reason ?? new DOMException("Aborted", "AbortError");
83
+ await new Promise((resolve, reject) => {
84
+ const timer = setTimeout(() => {
85
+ signal?.removeEventListener("abort", onAbort);
86
+ resolve();
87
+ }, ms);
88
+ function onAbort() {
89
+ clearTimeout(timer);
90
+ reject(signal?.reason ?? new DOMException("Aborted", "AbortError"));
91
+ }
92
+ signal?.addEventListener("abort", onAbort, { once: true });
93
+ });
94
+ }
95
+ export async function deriveWorkloadIdentity(workloadRootSecret) {
96
+ if (workloadRootSecret.length !== 32) {
97
+ throw new Error(`Invalid workload root secret length: ${workloadRootSecret.length} (expected 32)`);
98
+ }
99
+ const identitySeed = await hkdfSha256(workloadRootSecret, WORKLOAD_IDENTITY_HKDF_INFO, 32);
100
+ const activationKey = await hkdfSha256(workloadRootSecret, WORKLOAD_ACTIVATION_HKDF_INFO, 32);
101
+ const identitySeedBase64url = base64urlEncode(identitySeed);
102
+ const identityPrivateKey = await importEd25519PrivateKeyFromSeedBase64url(identitySeedBase64url);
103
+ const publicIdentityKey = await publicKeyBase64urlFromPrivateKey(identityPrivateKey);
104
+ return {
105
+ identitySeed,
106
+ identitySeedBase64url,
107
+ publicIdentityKey,
108
+ activationKey,
109
+ activationKeyBase64url: base64urlEncode(activationKey),
110
+ };
111
+ }
112
+ export async function deriveWorkloadQrMac(input) {
113
+ const activationKey = normalizeSecretBytes(input.activationKey, "activationKey");
114
+ const mac = await hmacSha256(activationKey, concatBytes([
115
+ utf8(WORKLOAD_QR_MAC_DOMAIN),
116
+ utf8(input.publicIdentityKey),
117
+ utf8(input.nonce),
118
+ ]));
119
+ return base64urlEncode(mac.slice(0, 8));
120
+ }
121
+ export async function buildWorkloadActivationPayload(input) {
122
+ const qrMac = await deriveWorkloadQrMac(input);
123
+ return {
124
+ v: 1,
125
+ publicIdentityKey: input.publicIdentityKey,
126
+ nonce: input.nonce,
127
+ qrMac,
128
+ };
129
+ }
130
+ export function encodeWorkloadActivationPayload(payload) {
131
+ return base64urlEncode(utf8(JSON.stringify(payload)));
132
+ }
133
+ export function parseWorkloadActivationPayload(value) {
134
+ const decoded = new TextDecoder().decode(base64urlDecode(value));
135
+ const parsed = JSON.parse(decoded);
136
+ if (!Value.Check(WorkloadActivationPayloadSchema, parsed)) {
137
+ throw new Error("Invalid workload activation payload");
138
+ }
139
+ return parsed;
140
+ }
141
+ export function buildWorkloadActivationUrl(args) {
142
+ const baseUrl = new URL(args.trellisUrl);
143
+ baseUrl.pathname = "/auth/workloads/activate";
144
+ baseUrl.searchParams.set("payload", typeof args.payload === "string" ? args.payload : encodeWorkloadActivationPayload(args.payload));
145
+ return baseUrl.toString();
146
+ }
147
+ export async function deriveWorkloadConfirmationCode(input) {
148
+ const activationKey = normalizeSecretBytes(input.activationKey, "activationKey");
149
+ const mac = await hmacSha256(activationKey, concatBytes([
150
+ utf8(WORKLOAD_CONFIRMATION_DOMAIN),
151
+ utf8(input.publicIdentityKey),
152
+ utf8(input.nonce),
153
+ ]));
154
+ return crockfordEncode(mac.slice(0, 5)).slice(0, 8);
155
+ }
156
+ export async function verifyWorkloadConfirmationCode(input) {
157
+ const expected = await deriveWorkloadConfirmationCode(input);
158
+ return normalizeCrockford(expected) === normalizeCrockford(input.confirmationCode);
159
+ }
160
+ export function buildWorkloadWaitProofInput(publicIdentityKey, nonce, iat) {
161
+ const enc = new TextEncoder();
162
+ const publicIdentityKeyBytes = enc.encode(publicIdentityKey);
163
+ const nonceBytes = enc.encode(nonce);
164
+ const iatBytes = enc.encode(String(iat));
165
+ const buf = new Uint8Array(4 + publicIdentityKeyBytes.length +
166
+ 4 + nonceBytes.length +
167
+ 4 + iatBytes.length);
168
+ const view = new DataView(buf.buffer);
169
+ let offset = 0;
170
+ view.setUint32(offset, publicIdentityKeyBytes.length);
171
+ offset += 4;
172
+ buf.set(publicIdentityKeyBytes, offset);
173
+ offset += publicIdentityKeyBytes.length;
174
+ view.setUint32(offset, nonceBytes.length);
175
+ offset += 4;
176
+ buf.set(nonceBytes, offset);
177
+ offset += nonceBytes.length;
178
+ view.setUint32(offset, iatBytes.length);
179
+ offset += 4;
180
+ buf.set(iatBytes, offset);
181
+ return buf;
182
+ }
183
+ export async function signWorkloadWaitRequest(args) {
184
+ const identitySeed = normalizeSecretBytes(args.identitySeed, "identitySeed");
185
+ const identityPrivateKey = await importEd25519PrivateKeyFromSeedBase64url(base64urlEncode(identitySeed));
186
+ const iat = args.iat ?? Math.floor(Date.now() / 1_000);
187
+ const proofInput = buildWorkloadWaitProofInput(args.publicIdentityKey, args.nonce, iat);
188
+ const proofHash = await sha256(proofInput);
189
+ const signature = new Uint8Array(await crypto.subtle.sign("Ed25519", identityPrivateKey, toArrayBuffer(proofHash)));
190
+ return {
191
+ publicIdentityKey: args.publicIdentityKey,
192
+ nonce: args.nonce,
193
+ ...(args.contractDigest ? { contractDigest: args.contractDigest } : {}),
194
+ iat,
195
+ sig: base64urlEncode(signature),
196
+ };
197
+ }
198
+ export async function createWorkloadNatsAuthToken(args) {
199
+ const identitySeed = normalizeSecretBytes(args.identitySeed, "identitySeed");
200
+ const identityPrivateKey = await importEd25519PrivateKeyFromSeedBase64url(base64urlEncode(identitySeed));
201
+ const iat = args.iat ?? Math.floor(Date.now() / 1_000);
202
+ const digest = await crypto.subtle.digest("SHA-256", toArrayBuffer(utf8(`nats-connect:${iat}`)));
203
+ const signature = new Uint8Array(await crypto.subtle.sign("Ed25519", identityPrivateKey, digest));
204
+ return {
205
+ v: 1,
206
+ sessionKey: args.publicIdentityKey,
207
+ iat,
208
+ sig: base64urlEncode(signature),
209
+ contractDigest: args.contractDigest,
210
+ };
211
+ }
212
+ export async function waitForWorkloadActivation(args) {
213
+ const pollIntervalMs = args.pollIntervalMs ?? DEFAULT_WAIT_POLL_INTERVAL_MS;
214
+ while (true) {
215
+ const request = await signWorkloadWaitRequest(args);
216
+ const response = await fetch(new URL("/auth/workloads/activate/wait", args.trellisUrl), {
217
+ method: "POST",
218
+ headers: { "Content-Type": "application/json" },
219
+ body: JSON.stringify(request),
220
+ signal: args.signal,
221
+ });
222
+ if (!response.ok) {
223
+ throw new Error(`workload activation wait failed: ${response.status}`);
224
+ }
225
+ const body = await response.json();
226
+ if (!Value.Check(WaitForWorkloadActivationResponseSchema, body)) {
227
+ throw new Error("Invalid workload activation wait response");
228
+ }
229
+ if (body.status === "pending") {
230
+ await sleep(pollIntervalMs, args.signal);
231
+ continue;
232
+ }
233
+ if (body.status === "rejected") {
234
+ throw new Error(`workload activation rejected: ${body.reason ?? "unknown_reason"}`);
235
+ }
236
+ return body;
237
+ }
238
+ }
239
+ export async function getWorkloadConnectInfo(args) {
240
+ const request = await signWorkloadWaitRequest({
241
+ publicIdentityKey: args.publicIdentityKey,
242
+ identitySeed: args.identitySeed,
243
+ contractDigest: args.contractDigest,
244
+ nonce: "connect-info",
245
+ iat: args.iat,
246
+ });
247
+ const payload = {
248
+ publicIdentityKey: request.publicIdentityKey,
249
+ contractDigest: args.contractDigest,
250
+ iat: request.iat,
251
+ sig: request.sig,
252
+ };
253
+ const response = await fetch(new URL("/auth/workloads/connect-info", args.trellisUrl), {
254
+ method: "POST",
255
+ headers: { "Content-Type": "application/json" },
256
+ body: JSON.stringify(payload),
257
+ });
258
+ if (!response.ok) {
259
+ throw new Error(`workload connect info failed: ${response.status}`);
260
+ }
261
+ const body = await response.json();
262
+ if (!Value.Check(AuthGetWorkloadConnectInfoResponseSchema, body)) {
263
+ throw new Error("Invalid workload connect info response");
264
+ }
265
+ return body;
266
+ }
267
+ export function createWorkloadActivationClient(client) {
268
+ return {
269
+ activateWorkload(input) {
270
+ return client.requestOrThrow("Auth.ActivateWorkload", input);
271
+ },
272
+ getWorkloadActivationStatus(input) {
273
+ return client.requestOrThrow("Auth.GetWorkloadActivationStatus", input);
274
+ },
275
+ listWorkloadActivations(input = {}) {
276
+ return client.requestOrThrow("Auth.ListWorkloadActivations", input);
277
+ },
278
+ revokeWorkloadActivation(input) {
279
+ return client.requestOrThrow("Auth.RevokeWorkloadActivation", input);
280
+ },
281
+ getWorkloadConnectInfo(input) {
282
+ return client.requestOrThrow("Auth.GetWorkloadConnectInfo", input);
283
+ },
284
+ };
285
+ }
286
+ export async function verifyWorkloadWaitSignature(input) {
287
+ const publicKey = await importEd25519PublicKeyFromBase64url(input.publicIdentityKey);
288
+ const proofHash = await sha256(buildWorkloadWaitProofInput(input.publicIdentityKey, input.nonce, input.iat));
289
+ return await crypto.subtle.verify("Ed25519", publicKey, toArrayBuffer(base64urlDecode(input.sig)), toArrayBuffer(proofHash));
290
+ }
@@ -0,0 +1,14 @@
1
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
2
+ [k: string]: JsonValue;
3
+ };
4
+ export declare function isJsonValue(value: unknown): value is JsonValue;
5
+ export declare function canonicalizeJson(value: JsonValue): string;
6
+ export declare function base64url(bytes: Uint8Array): string;
7
+ export declare function sha256Bytes(data: Uint8Array): Uint8Array;
8
+ export declare function sha256Base64urlSync(text: string): string;
9
+ export declare function sha256Base64url(text: string): Promise<string>;
10
+ export declare function digestJson(value: JsonValue): Promise<{
11
+ canonical: string;
12
+ digest: string;
13
+ }>;
14
+ //# sourceMappingURL=canonical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../src/contracts/canonical.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,IAAI,GACJ,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,EAAE,GACX;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAE/B,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAiB9D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAoBzD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAKnD;AAMD,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CA+ExD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAOnE;AAED,wBAAsB,UAAU,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAID"}
@@ -0,0 +1,135 @@
1
+ export function isJsonValue(value) {
2
+ if (value === null ||
3
+ typeof value === "string" ||
4
+ typeof value === "boolean")
5
+ return true;
6
+ if (typeof value === "number") {
7
+ return Number.isFinite(value) && !Object.is(value, -0);
8
+ }
9
+ if (Array.isArray(value))
10
+ return value.every(isJsonValue);
11
+ if (typeof value === "object") {
12
+ return Object.values(value).every(isJsonValue);
13
+ }
14
+ return false;
15
+ }
16
+ export function canonicalizeJson(value) {
17
+ if (value === null)
18
+ return "null";
19
+ if (typeof value === "boolean")
20
+ return value ? "true" : "false";
21
+ if (typeof value === "string")
22
+ return JSON.stringify(value);
23
+ if (typeof value === "number") {
24
+ if (!Number.isFinite(value) || Object.is(value, -0)) {
25
+ throw new Error(`Non-canonical number in manifest: ${value}`);
26
+ }
27
+ return JSON.stringify(value);
28
+ }
29
+ if (Array.isArray(value)) {
30
+ return `[${value.map(canonicalizeJson).join(",")}]`;
31
+ }
32
+ const keys = Object.keys(value).sort();
33
+ const entries = keys.map((k) => `${JSON.stringify(k)}:${canonicalizeJson(value[k])}`);
34
+ return `{${entries.join(",")}}`;
35
+ }
36
+ export function base64url(bytes) {
37
+ let bin = "";
38
+ for (const b of bytes)
39
+ bin += String.fromCharCode(b);
40
+ const b64 = btoa(bin);
41
+ return b64.replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
42
+ }
43
+ function rotr(value, bits) {
44
+ return (value >>> bits) | (value << (32 - bits));
45
+ }
46
+ export function sha256Bytes(data) {
47
+ const K = new Uint32Array([
48
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4,
49
+ 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe,
50
+ 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f,
51
+ 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
52
+ 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc,
53
+ 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
54
+ 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116,
55
+ 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
56
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7,
57
+ 0xc67178f2,
58
+ ]);
59
+ const H = new Uint32Array([
60
+ 0x6a09e667,
61
+ 0xbb67ae85,
62
+ 0x3c6ef372,
63
+ 0xa54ff53a,
64
+ 0x510e527f,
65
+ 0x9b05688c,
66
+ 0x1f83d9ab,
67
+ 0x5be0cd19,
68
+ ]);
69
+ const bitLength = data.length * 8;
70
+ const paddedLength = Math.ceil((data.length + 9) / 64) * 64;
71
+ const padded = new Uint8Array(paddedLength);
72
+ padded.set(data);
73
+ padded[data.length] = 0x80;
74
+ const view = new DataView(padded.buffer);
75
+ view.setUint32(paddedLength - 4, bitLength >>> 0, false);
76
+ view.setUint32(paddedLength - 8, Math.floor(bitLength / 2 ** 32), false);
77
+ const w = new Uint32Array(64);
78
+ for (let offset = 0; offset < padded.length; offset += 64) {
79
+ for (let i = 0; i < 16; i++) {
80
+ w[i] = view.getUint32(offset + i * 4, false);
81
+ }
82
+ for (let i = 16; i < 64; i++) {
83
+ const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ (w[i - 15] >>> 3);
84
+ const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ (w[i - 2] >>> 10);
85
+ w[i] = (((w[i - 16] + s0) | 0) + w[i - 7] + s1) >>> 0;
86
+ }
87
+ let [a, b, c, d, e, f, g, h] = H;
88
+ for (let i = 0; i < 64; i++) {
89
+ const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
90
+ const ch = (e & f) ^ (~e & g);
91
+ const temp1 = (((((h + s1) | 0) + ch) | 0) + K[i] + w[i]) >>> 0;
92
+ const s0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
93
+ const maj = (a & b) ^ (a & c) ^ (b & c);
94
+ const temp2 = (s0 + maj) >>> 0;
95
+ h = g;
96
+ g = f;
97
+ f = e;
98
+ e = (d + temp1) >>> 0;
99
+ d = c;
100
+ c = b;
101
+ b = a;
102
+ a = (temp1 + temp2) >>> 0;
103
+ }
104
+ H[0] = (H[0] + a) >>> 0;
105
+ H[1] = (H[1] + b) >>> 0;
106
+ H[2] = (H[2] + c) >>> 0;
107
+ H[3] = (H[3] + d) >>> 0;
108
+ H[4] = (H[4] + e) >>> 0;
109
+ H[5] = (H[5] + f) >>> 0;
110
+ H[6] = (H[6] + g) >>> 0;
111
+ H[7] = (H[7] + h) >>> 0;
112
+ }
113
+ const out = new Uint8Array(32);
114
+ const outView = new DataView(out.buffer);
115
+ for (let i = 0; i < H.length; i++) {
116
+ outView.setUint32(i * 4, H[i], false);
117
+ }
118
+ return out;
119
+ }
120
+ export function sha256Base64urlSync(text) {
121
+ return base64url(sha256Bytes(new TextEncoder().encode(text)));
122
+ }
123
+ export async function sha256Base64url(text) {
124
+ if (typeof crypto !== "undefined" && crypto.subtle) {
125
+ const data = new TextEncoder().encode(text);
126
+ const digest = await crypto.subtle.digest("SHA-256", data);
127
+ return base64url(new Uint8Array(digest));
128
+ }
129
+ return sha256Base64urlSync(text);
130
+ }
131
+ export async function digestJson(value) {
132
+ const canonical = canonicalizeJson(value);
133
+ const digest = await sha256Base64url(canonical);
134
+ return { canonical, digest };
135
+ }