@tier0/sdk-v2 0.9.10 → 0.10.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 (238) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/LICENSE +21 -21
  3. package/README.md +162 -24
  4. package/dist/cjs/client.d.ts +83 -3
  5. package/dist/cjs/client.js +4 -6
  6. package/dist/cjs/client.js.map +1 -1
  7. package/dist/cjs/cloud-server.d.ts +33 -26
  8. package/dist/cjs/cloud-server.js +102 -100
  9. package/dist/cjs/cloud-server.js.map +1 -1
  10. package/dist/cjs/cloud-transport.d.ts +15 -20
  11. package/dist/cjs/cloud-transport.js +87 -68
  12. package/dist/cjs/cloud-transport.js.map +1 -1
  13. package/dist/cjs/data/bootstrap.js +3 -4
  14. package/dist/cjs/data/bootstrap.js.map +1 -1
  15. package/dist/cjs/data/call.d.ts +1 -3
  16. package/dist/cjs/data/call.js +8 -12
  17. package/dist/cjs/data/call.js.map +1 -1
  18. package/dist/cjs/data/client.d.ts +8 -7
  19. package/dist/cjs/data/client.js +24 -11
  20. package/dist/cjs/data/client.js.map +1 -1
  21. package/dist/cjs/data/collection.d.ts +3 -5
  22. package/dist/cjs/data/collection.js +3 -4
  23. package/dist/cjs/data/collection.js.map +1 -1
  24. package/dist/cjs/data/context.d.ts +5 -11
  25. package/dist/cjs/data/context.js +21 -36
  26. package/dist/cjs/data/context.js.map +1 -1
  27. package/dist/cjs/data/error.js +1 -1
  28. package/dist/cjs/data/error.js.map +1 -1
  29. package/dist/cjs/data/index.d.ts +5 -3
  30. package/dist/cjs/data/index.js +5 -5
  31. package/dist/cjs/data/index.js.map +1 -1
  32. package/dist/cjs/data/relay.d.ts +51 -0
  33. package/dist/cjs/data/relay.js +371 -0
  34. package/dist/cjs/data/relay.js.map +1 -0
  35. package/dist/cjs/data/subscribe.d.ts +22 -38
  36. package/dist/cjs/data/subscribe.js +22 -28
  37. package/dist/cjs/data/subscribe.js.map +1 -1
  38. package/dist/cjs/event-stream.d.ts +28 -0
  39. package/dist/cjs/event-stream.js +222 -0
  40. package/dist/cjs/event-stream.js.map +1 -0
  41. package/dist/cjs/mq/client.d.ts +32 -1
  42. package/dist/cjs/mq/client.js +404 -69
  43. package/dist/cjs/mq/client.js.map +1 -1
  44. package/dist/cjs/mq/index.d.ts +1 -0
  45. package/dist/cjs/mq/index.js +3 -1
  46. package/dist/cjs/mq/index.js.map +1 -1
  47. package/dist/cjs/mq/topic.d.ts +29 -0
  48. package/dist/cjs/mq/topic.js +48 -0
  49. package/dist/cjs/mq/topic.js.map +1 -0
  50. package/dist/cjs/mq/types.d.ts +21 -1
  51. package/dist/cjs/mq/types.js.map +1 -1
  52. package/dist/cjs/openapi/api.generated.d.ts +21 -0
  53. package/dist/cjs/openapi/api.generated.js +11 -0
  54. package/dist/cjs/openapi/api.generated.js.map +1 -1
  55. package/dist/cjs/openapi/client.d.ts +46 -0
  56. package/dist/cjs/openapi/client.js +158 -10
  57. package/dist/cjs/openapi/client.js.map +1 -1
  58. package/dist/cjs/openapi/codecs.generated.d.ts +75 -0
  59. package/dist/cjs/openapi/codecs.generated.js +1 -1
  60. package/dist/cjs/openapi/codecs.generated.js.map +1 -1
  61. package/dist/cjs/openapi/types.generated.d.ts +206 -1
  62. package/dist/cjs/openapi/types.generated.js.map +1 -1
  63. package/dist/cjs/page-runtime.d.ts +48 -0
  64. package/dist/cjs/page-runtime.js +74 -0
  65. package/dist/cjs/page-runtime.js.map +1 -0
  66. package/dist/cjs/platform-proxy.d.ts +17 -0
  67. package/dist/cjs/platform-proxy.js +52 -0
  68. package/dist/cjs/platform-proxy.js.map +1 -0
  69. package/dist/cjs/runtime-context.d.ts +2 -1
  70. package/dist/cjs/runtime-context.js +6 -2
  71. package/dist/cjs/runtime-context.js.map +1 -1
  72. package/dist/cjs/runtime-env.js.map +1 -1
  73. package/dist/cjs/source.d.ts +19 -1
  74. package/dist/cjs/source.js +9 -3
  75. package/dist/cjs/source.js.map +1 -1
  76. package/dist/cjs/stream.js +3 -2
  77. package/dist/cjs/stream.js.map +1 -1
  78. package/dist/cjs/streams/contract.generated.d.ts +7 -1
  79. package/dist/cjs/streams/contract.generated.js.map +1 -1
  80. package/dist/cjs/streams/messages.js +1 -10
  81. package/dist/cjs/streams/messages.js.map +1 -1
  82. package/dist/cjs/streams/requests.d.ts +3 -0
  83. package/dist/cjs/streams/requests.js +5 -2
  84. package/dist/cjs/streams/requests.js.map +1 -1
  85. package/dist/cjs/streams/transport.d.ts +1 -13
  86. package/dist/cjs/streams/transport.js +2 -18
  87. package/dist/cjs/streams/transport.js.map +1 -1
  88. package/dist/cjs/uns-v2/client.d.ts +1 -6
  89. package/dist/cjs/uns-v2/client.js +30 -6
  90. package/dist/cjs/uns-v2/client.js.map +1 -1
  91. package/dist/cjs/uns-v2/data-client.d.ts +5 -2
  92. package/dist/cjs/uns-v2/data-client.js +7 -4
  93. package/dist/cjs/uns-v2/data-client.js.map +1 -1
  94. package/dist/cjs/uns-v2/generated.d.ts +6783 -4655
  95. package/dist/cjs/uns-v2/generated.js +221 -65
  96. package/dist/cjs/uns-v2/generated.js.map +1 -1
  97. package/dist/cjs/uns-v2/sse.d.ts +7 -1
  98. package/dist/cjs/uns-v2/sse.js +12 -2
  99. package/dist/cjs/uns-v2/sse.js.map +1 -1
  100. package/dist/esm/client.d.ts +83 -3
  101. package/dist/esm/client.js +5 -7
  102. package/dist/esm/client.js.map +1 -1
  103. package/dist/esm/cloud-server.d.ts +33 -26
  104. package/dist/esm/cloud-server.js +99 -97
  105. package/dist/esm/cloud-server.js.map +1 -1
  106. package/dist/esm/cloud-transport.d.ts +15 -20
  107. package/dist/esm/cloud-transport.js +86 -67
  108. package/dist/esm/cloud-transport.js.map +1 -1
  109. package/dist/esm/data/bootstrap.js +3 -4
  110. package/dist/esm/data/bootstrap.js.map +1 -1
  111. package/dist/esm/data/call.d.ts +1 -3
  112. package/dist/esm/data/call.js +9 -13
  113. package/dist/esm/data/call.js.map +1 -1
  114. package/dist/esm/data/client.d.ts +8 -7
  115. package/dist/esm/data/client.js +22 -9
  116. package/dist/esm/data/client.js.map +1 -1
  117. package/dist/esm/data/collection.d.ts +3 -5
  118. package/dist/esm/data/collection.js +3 -4
  119. package/dist/esm/data/collection.js.map +1 -1
  120. package/dist/esm/data/context.d.ts +5 -11
  121. package/dist/esm/data/context.js +19 -33
  122. package/dist/esm/data/context.js.map +1 -1
  123. package/dist/esm/data/error.js +1 -1
  124. package/dist/esm/data/error.js.map +1 -1
  125. package/dist/esm/data/index.d.ts +5 -3
  126. package/dist/esm/data/index.js +3 -2
  127. package/dist/esm/data/index.js.map +1 -1
  128. package/dist/esm/data/relay.d.ts +51 -0
  129. package/dist/esm/data/relay.js +368 -0
  130. package/dist/esm/data/relay.js.map +1 -0
  131. package/dist/esm/data/subscribe.d.ts +22 -38
  132. package/dist/esm/data/subscribe.js +22 -27
  133. package/dist/esm/data/subscribe.js.map +1 -1
  134. package/dist/esm/event-stream.d.ts +28 -0
  135. package/dist/esm/event-stream.js +217 -0
  136. package/dist/esm/event-stream.js.map +1 -0
  137. package/dist/esm/mq/client.d.ts +32 -1
  138. package/dist/esm/mq/client.js +404 -69
  139. package/dist/esm/mq/client.js.map +1 -1
  140. package/dist/esm/mq/index.d.ts +1 -0
  141. package/dist/esm/mq/index.js +1 -0
  142. package/dist/esm/mq/index.js.map +1 -1
  143. package/dist/esm/mq/topic.d.ts +29 -0
  144. package/dist/esm/mq/topic.js +44 -0
  145. package/dist/esm/mq/topic.js.map +1 -0
  146. package/dist/esm/mq/types.d.ts +21 -1
  147. package/dist/esm/mq/types.js.map +1 -1
  148. package/dist/esm/openapi/api.generated.d.ts +21 -0
  149. package/dist/esm/openapi/api.generated.js +11 -0
  150. package/dist/esm/openapi/api.generated.js.map +1 -1
  151. package/dist/esm/openapi/client.d.ts +46 -0
  152. package/dist/esm/openapi/client.js +157 -10
  153. package/dist/esm/openapi/client.js.map +1 -1
  154. package/dist/esm/openapi/codecs.generated.d.ts +75 -0
  155. package/dist/esm/openapi/codecs.generated.js +1 -1
  156. package/dist/esm/openapi/codecs.generated.js.map +1 -1
  157. package/dist/esm/openapi/types.generated.d.ts +206 -1
  158. package/dist/esm/openapi/types.generated.js.map +1 -1
  159. package/dist/esm/page-runtime.d.ts +48 -0
  160. package/dist/esm/page-runtime.js +65 -0
  161. package/dist/esm/page-runtime.js.map +1 -0
  162. package/dist/esm/platform-proxy.d.ts +17 -0
  163. package/dist/esm/platform-proxy.js +47 -0
  164. package/dist/esm/platform-proxy.js.map +1 -0
  165. package/dist/esm/runtime-context.d.ts +2 -1
  166. package/dist/esm/runtime-context.js +6 -2
  167. package/dist/esm/runtime-context.js.map +1 -1
  168. package/dist/esm/runtime-env.js.map +1 -1
  169. package/dist/esm/source.d.ts +19 -1
  170. package/dist/esm/source.js +10 -4
  171. package/dist/esm/source.js.map +1 -1
  172. package/dist/esm/stream.js +4 -3
  173. package/dist/esm/stream.js.map +1 -1
  174. package/dist/esm/streams/contract.generated.d.ts +7 -1
  175. package/dist/esm/streams/contract.generated.js.map +1 -1
  176. package/dist/esm/streams/messages.js +1 -10
  177. package/dist/esm/streams/messages.js.map +1 -1
  178. package/dist/esm/streams/requests.d.ts +3 -0
  179. package/dist/esm/streams/requests.js +5 -2
  180. package/dist/esm/streams/requests.js.map +1 -1
  181. package/dist/esm/streams/transport.d.ts +1 -13
  182. package/dist/esm/streams/transport.js +1 -17
  183. package/dist/esm/streams/transport.js.map +1 -1
  184. package/dist/esm/uns-v2/client.d.ts +1 -6
  185. package/dist/esm/uns-v2/client.js +30 -6
  186. package/dist/esm/uns-v2/client.js.map +1 -1
  187. package/dist/esm/uns-v2/data-client.d.ts +5 -2
  188. package/dist/esm/uns-v2/data-client.js +8 -5
  189. package/dist/esm/uns-v2/data-client.js.map +1 -1
  190. package/dist/esm/uns-v2/generated.d.ts +6783 -4655
  191. package/dist/esm/uns-v2/generated.js +221 -65
  192. package/dist/esm/uns-v2/generated.js.map +1 -1
  193. package/dist/esm/uns-v2/sse.d.ts +7 -1
  194. package/dist/esm/uns-v2/sse.js +12 -2
  195. package/dist/esm/uns-v2/sse.js.map +1 -1
  196. package/package.json +25 -12
  197. package/skills/tier0-sdk-v2/SKILL.md +11 -5
  198. package/skills/tier0-sdk-v2/references/integration.md +14 -24
  199. package/skills/tier0-sdk-v2/tier0-sdk-v2-data/SKILL.md +11 -5
  200. package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/consistency.md +6 -10
  201. package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/errors.md +20 -3
  202. package/skills/tier0-sdk-v2/tier0-sdk-v2-data/references/read-write.md +46 -13
  203. package/skills/tier0-sdk-v2/tier0-sdk-v2-members/SKILL.md +2 -2
  204. package/skills/tier0-sdk-v2/tier0-sdk-v2-members/references/app-members.md +5 -1
  205. package/skills/tier0-sdk-v2/tier0-sdk-v2-mq/SKILL.md +25 -0
  206. package/skills/tier0-sdk-v2/tier0-sdk-v2-mq/references/quickstart.md +1 -1
  207. package/skills/tier0-sdk-v2/tier0-sdk-v2-notifications/SKILL.md +3 -3
  208. package/skills/tier0-sdk-v2/tier0-sdk-v2-notifications/references/send.md +6 -6
  209. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/SKILL.md +4 -4
  210. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/changes.md +2 -2
  211. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/create.md +26 -36
  212. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/delete.md +9 -23
  213. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/protocols.md +12 -29
  214. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/read.md +4 -5
  215. package/skills/tier0-sdk-v2/tier0-sdk-v2-source/references/update.md +5 -5
  216. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/SKILL.md +3 -3
  217. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/create.md +23 -9
  218. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/deploy.md +14 -12
  219. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/http-server.md +4 -4
  220. package/skills/tier0-sdk-v2/tier0-sdk-v2-stream/references/read.md +4 -3
  221. package/skills/tier0-sdk-v2/tier0-sdk-v2-streams/SKILL.md +14 -12
  222. package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/SKILL.md +3 -1
  223. package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/create.md +2 -2
  224. package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/delete.md +22 -1
  225. package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/read.md +5 -6
  226. package/skills/tier0-sdk-v2/tier0-sdk-v2-uns/references/update.md +11 -0
  227. package/dist/cjs/app-identity-contract.generated.d.ts +0 -22
  228. package/dist/cjs/app-identity-contract.generated.js +0 -51
  229. package/dist/cjs/app-identity-contract.generated.js.map +0 -1
  230. package/dist/cjs/runtime.d.ts +0 -13
  231. package/dist/cjs/runtime.js +0 -51
  232. package/dist/cjs/runtime.js.map +0 -1
  233. package/dist/esm/app-identity-contract.generated.d.ts +0 -22
  234. package/dist/esm/app-identity-contract.generated.js +0 -48
  235. package/dist/esm/app-identity-contract.generated.js.map +0 -1
  236. package/dist/esm/runtime.d.ts +0 -13
  237. package/dist/esm/runtime.js +0 -46
  238. package/dist/esm/runtime.js.map +0 -1
@@ -8,7 +8,7 @@ import type { CloudTransportConfig } from './cloud-transport.js';
8
8
  export interface Tier0ClientConfig extends ClientConfig, CloudTransportConfig {
9
9
  }
10
10
  export type Tier0Client = ReturnType<typeof createClient>;
11
- /** 现役服务端和数据客户端保留独立配置;浏览器交互仅使用受信宿主。 */
11
+ /** 每个实例持有独立配置;带 Key 的客户端只在服务端使用。 */
12
12
  export declare function createClient(config?: Tier0ClientConfig): Readonly<{
13
13
  streams: {
14
14
  requests: StreamRequestsClient;
@@ -28,6 +28,7 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
28
28
  email: string;
29
29
  keyPrefix: string;
30
30
  keyType: string;
31
+ permission?: string;
31
32
  permissions: string[];
32
33
  roles: string[];
33
34
  userID: number | bigint;
@@ -59,6 +60,8 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
59
60
  send: (body: import("./index.js").components["schemas"]["SdknotificationsSendRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
60
61
  createdAt: string;
61
62
  messageId: string;
63
+ recipientName?: string;
64
+ recipientUserId: string;
62
65
  status: string;
63
66
  }>;
64
67
  get: (body: import("./index.js").components["schemas"]["SdknotificationsGetRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -68,9 +71,17 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
68
71
  errorCode?: string;
69
72
  message?: string;
70
73
  messageId: string;
74
+ recipientName?: string;
75
+ recipientUserId: string;
71
76
  status: string;
72
77
  type: string;
73
78
  }>;
79
+ list: (body?: import("./index.js").components["schemas"]["SdknotificationsListRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
80
+ list: import("./index.js").components["schemas"]["NotificationListItem"][];
81
+ page: number | bigint;
82
+ size: number | bigint;
83
+ total: number | bigint;
84
+ }>;
74
85
  };
75
86
  mqttAuth: {
76
87
  create: (body: import("./index.js").components["schemas"]["SdkmqttAuthCreateRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -210,7 +221,6 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
210
221
  files: FilesClient;
211
222
  capabilities: CapabilitiesClient;
212
223
  source: Readonly<{
213
- delete: (request: import("./index.js").CloudSourceDeleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDeleteResponse>;
214
224
  validate: (request: import("./index.js").UnsV2SourceValidateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceValidateResponse>;
215
225
  probe: (request: import("./index.js").UnsV2SourceProbeReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceProbeResponse>;
216
226
  discover: (request: import("./index.js").CloudSourceDiscoverReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDiscoverResponse>;
@@ -225,11 +235,30 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
225
235
  observations: Readonly<{
226
236
  get: (request: import("./index.js").CloudSourceObservationsGetReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceObservationsGetResponse>;
227
237
  }>;
238
+ resources: Readonly<{
239
+ catalog: (request: import("./index.js").CloudSourceResourceCatalogReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceCatalogResponse>;
240
+ preview: (request: import("./index.js").CloudSourceResourceReadReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceReadResponse>;
241
+ scan: (request: import("./index.js").CloudSourceResourceScanReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceScanResponse>;
242
+ }>;
243
+ devices: Readonly<{
244
+ list: (request: import("./index.js").CloudSourceDevicesListReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDevicesListResponse>;
245
+ }>;
228
246
  documents: Readonly<{
229
247
  list: (request: import("./index.js").CloudSourceDocumentListReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentListResponse>;
230
248
  get: (request: import("./index.js").CloudSourceDocumentGetReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentGetResponse>;
231
249
  create: (request: import("./index.js").CloudSourceDocumentCreateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentCreateResponse>;
232
250
  update: (request: import("./index.js").CloudSourceDocumentUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentUpdateResponse>;
251
+ delete: (request: import("./index.js").UnsV2SourceDocumentDeleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceDocumentDeleteResponse>;
252
+ credentials: Readonly<{
253
+ update: (request: import("./index.js").UnsV2SourceNativeCredentialsUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeCredentialsUpdateResponse>;
254
+ }>;
255
+ state: Readonly<{
256
+ update: (request: import("./index.js").CloudEdgeSourceStateUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudEdgeSourceStateUpdateResponse>;
257
+ }>;
258
+ oauth: Readonly<{
259
+ start: (request: import("./index.js").UnsV2SourceNativeOAuthStartReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeOAuthStartResponse>;
260
+ complete: (request: import("./index.js").UnsV2SourceNativeOAuthCompleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeOAuthCompleteResponse>;
261
+ }>;
233
262
  }>;
234
263
  }>;
235
264
  stream: Readonly<{
@@ -271,6 +300,7 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
271
300
  email: string;
272
301
  keyPrefix: string;
273
302
  keyType: string;
303
+ permission?: string;
274
304
  permissions: string[];
275
305
  roles: string[];
276
306
  userID: number | bigint;
@@ -335,6 +365,8 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
335
365
  send: (body: import("./index.js").components["schemas"]["SdknotificationsSendRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
336
366
  createdAt: string;
337
367
  messageId: string;
368
+ recipientName?: string;
369
+ recipientUserId: string;
338
370
  status: string;
339
371
  }>;
340
372
  get: (body: import("./index.js").components["schemas"]["SdknotificationsGetRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -344,9 +376,17 @@ export declare function createClient(config?: Tier0ClientConfig): Readonly<{
344
376
  errorCode?: string;
345
377
  message?: string;
346
378
  messageId: string;
379
+ recipientName?: string;
380
+ recipientUserId: string;
347
381
  status: string;
348
382
  type: string;
349
383
  }>;
384
+ list: (body?: import("./index.js").components["schemas"]["SdknotificationsListRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
385
+ list: import("./index.js").components["schemas"]["NotificationListItem"][];
386
+ page: number | bigint;
387
+ size: number | bigint;
388
+ total: number | bigint;
389
+ }>;
350
390
  };
351
391
  members: {
352
392
  listWorkspace: (body?: import("./index.js").components["schemas"]["SdkmembersListWorkspaceRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -539,6 +579,7 @@ export declare const client: Readonly<{
539
579
  email: string;
540
580
  keyPrefix: string;
541
581
  keyType: string;
582
+ permission?: string;
542
583
  permissions: string[];
543
584
  roles: string[];
544
585
  userID: number | bigint;
@@ -570,6 +611,8 @@ export declare const client: Readonly<{
570
611
  send: (body: import("./index.js").components["schemas"]["SdknotificationsSendRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
571
612
  createdAt: string;
572
613
  messageId: string;
614
+ recipientName?: string;
615
+ recipientUserId: string;
573
616
  status: string;
574
617
  }>;
575
618
  get: (body: import("./index.js").components["schemas"]["SdknotificationsGetRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -579,9 +622,17 @@ export declare const client: Readonly<{
579
622
  errorCode?: string;
580
623
  message?: string;
581
624
  messageId: string;
625
+ recipientName?: string;
626
+ recipientUserId: string;
582
627
  status: string;
583
628
  type: string;
584
629
  }>;
630
+ list: (body?: import("./index.js").components["schemas"]["SdknotificationsListRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
631
+ list: import("./index.js").components["schemas"]["NotificationListItem"][];
632
+ page: number | bigint;
633
+ size: number | bigint;
634
+ total: number | bigint;
635
+ }>;
585
636
  };
586
637
  mqttAuth: {
587
638
  create: (body: import("./index.js").components["schemas"]["SdkmqttAuthCreateRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -721,7 +772,6 @@ export declare const client: Readonly<{
721
772
  files: FilesClient;
722
773
  capabilities: CapabilitiesClient;
723
774
  source: Readonly<{
724
- delete: (request: import("./index.js").CloudSourceDeleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDeleteResponse>;
725
775
  validate: (request: import("./index.js").UnsV2SourceValidateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceValidateResponse>;
726
776
  probe: (request: import("./index.js").UnsV2SourceProbeReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceProbeResponse>;
727
777
  discover: (request: import("./index.js").CloudSourceDiscoverReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDiscoverResponse>;
@@ -736,11 +786,30 @@ export declare const client: Readonly<{
736
786
  observations: Readonly<{
737
787
  get: (request: import("./index.js").CloudSourceObservationsGetReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceObservationsGetResponse>;
738
788
  }>;
789
+ resources: Readonly<{
790
+ catalog: (request: import("./index.js").CloudSourceResourceCatalogReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceCatalogResponse>;
791
+ preview: (request: import("./index.js").CloudSourceResourceReadReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceReadResponse>;
792
+ scan: (request: import("./index.js").CloudSourceResourceScanReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceResourceScanResponse>;
793
+ }>;
794
+ devices: Readonly<{
795
+ list: (request: import("./index.js").CloudSourceDevicesListReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDevicesListResponse>;
796
+ }>;
739
797
  documents: Readonly<{
740
798
  list: (request: import("./index.js").CloudSourceDocumentListReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentListResponse>;
741
799
  get: (request: import("./index.js").CloudSourceDocumentGetReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentGetResponse>;
742
800
  create: (request: import("./index.js").CloudSourceDocumentCreateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentCreateResponse>;
743
801
  update: (request: import("./index.js").CloudSourceDocumentUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudSourceDocumentUpdateResponse>;
802
+ delete: (request: import("./index.js").UnsV2SourceDocumentDeleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceDocumentDeleteResponse>;
803
+ credentials: Readonly<{
804
+ update: (request: import("./index.js").UnsV2SourceNativeCredentialsUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeCredentialsUpdateResponse>;
805
+ }>;
806
+ state: Readonly<{
807
+ update: (request: import("./index.js").CloudEdgeSourceStateUpdateReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").CloudEdgeSourceStateUpdateResponse>;
808
+ }>;
809
+ oauth: Readonly<{
810
+ start: (request: import("./index.js").UnsV2SourceNativeOAuthStartReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeOAuthStartResponse>;
811
+ complete: (request: import("./index.js").UnsV2SourceNativeOAuthCompleteReq, options?: import("./openapi/client.js").RequestOptions) => Promise<import("./index.js").UnsV2SourceNativeOAuthCompleteResponse>;
812
+ }>;
744
813
  }>;
745
814
  }>;
746
815
  stream: Readonly<{
@@ -782,6 +851,7 @@ export declare const client: Readonly<{
782
851
  email: string;
783
852
  keyPrefix: string;
784
853
  keyType: string;
854
+ permission?: string;
785
855
  permissions: string[];
786
856
  roles: string[];
787
857
  userID: number | bigint;
@@ -846,6 +916,8 @@ export declare const client: Readonly<{
846
916
  send: (body: import("./index.js").components["schemas"]["SdknotificationsSendRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
847
917
  createdAt: string;
848
918
  messageId: string;
919
+ recipientName?: string;
920
+ recipientUserId: string;
849
921
  status: string;
850
922
  }>;
851
923
  get: (body: import("./index.js").components["schemas"]["SdknotificationsGetRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -855,9 +927,17 @@ export declare const client: Readonly<{
855
927
  errorCode?: string;
856
928
  message?: string;
857
929
  messageId: string;
930
+ recipientName?: string;
931
+ recipientUserId: string;
858
932
  status: string;
859
933
  type: string;
860
934
  }>;
935
+ list: (body?: import("./index.js").components["schemas"]["SdknotificationsListRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
936
+ list: import("./index.js").components["schemas"]["NotificationListItem"][];
937
+ page: number | bigint;
938
+ size: number | bigint;
939
+ total: number | bigint;
940
+ }>;
861
941
  };
862
942
  members: {
863
943
  listWorkspace: (body?: import("./index.js").components["schemas"]["SdkmembersListWorkspaceRequest"], options?: import("./openapi/client.js").RequestOptions) => Promise<{
@@ -14,9 +14,7 @@ const source_js_1 = require("./source.js");
14
14
  const stream_js_1 = require("./stream.js");
15
15
  const capabilities_js_2 = require("./capabilities.js");
16
16
  const files_js_1 = require("./files.js");
17
- /** Use a fresh instance per incoming request when supplying employee data delegation. */
18
- function assemble(resolve, snapshot) {
19
- const http = resolve();
17
+ function assemble(resolve, snapshot, http = resolve()) {
20
18
  const api = (0, api_generated_js_1.createOpenAPI)(http);
21
19
  const transport = new transport_js_1.StreamTransport(resolve, snapshot);
22
20
  const messages = new messages_js_1.StreamMessagesClient(transport);
@@ -37,9 +35,9 @@ function assemble(resolve, snapshot) {
37
35
  api,
38
36
  });
39
37
  }
40
- /** 现役服务端和数据客户端保留独立配置;浏览器交互仅使用受信宿主。 */
38
+ /** 每个实例持有独立配置;带 Key 的客户端只在服务端使用。 */
41
39
  function createClient(config = {}) {
42
- const snapshot = Object.freeze({ ...config });
40
+ const snapshot = Object.freeze((0, client_js_1.snapshotClientConfig)(config));
43
41
  const http = new client_js_1.HttpClient(snapshot);
44
42
  return assemble(() => http, snapshot);
45
43
  }
@@ -52,5 +50,5 @@ const defaultHttp = new Proxy(new client_js_1.HttpClient(), {
52
50
  },
53
51
  });
54
52
  /** App 默认交互客户端在调用时解析宿主,无需在浏览器配置密钥。 */
55
- exports.client = assemble(() => defaultHttp, {});
53
+ exports.client = assemble(client_js_1.getClient, {}, defaultHttp);
56
54
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAyCA,oCAIC;AA7CD,uDAA6D;AAC7D,uDAA6D;AAC7D,yDAAyD;AACzD,+DAAqE;AACrE,mDAA+E;AAC/E,iEAA2D;AAC3D,kDAAuD;AACvD,4DAA4D;AAC5D,2CAA+C;AAC/C,2CAA+C;AAC/C,uDAAuD;AACvD,yCAAyC;AAIzC,yFAAyF;AACzF,SAAS,QAAQ,CAAC,OAAyB,EAAE,QAA2B;IACtE,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC;IACvB,MAAM,GAAG,GAAG,IAAA,gCAAa,EAAC,IAAI,CAAC,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,8BAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,IAAI,kCAAoB,CAAC,SAAS,CAAC,CAAC;IACrD,MAAM,GAAG,GAAG,IAAA,6BAAiB,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACjD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,kCAAoB,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,0CAAwB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;QACnI,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE;QACjC,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,KAAK,EAAE,IAAI,sBAAW,CAAC,IAAI,CAAC;QAC5B,YAAY,EAAE,IAAI,oCAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC;QACvD,MAAM,EAAE,IAAA,4BAAgB,EAAC,GAAG,CAAC;QAC7B,MAAM,EAAE,IAAA,4BAAgB,EAAC,GAAG,CAAC;QAC7B,GAAG,EAAE,IAAA,kCAAiB,EAAC,GAAG,CAAC;QAC3B,GAAG;KACJ,CAAC,CAAC;AACL,CAAC;AAGD,sCAAsC;AACtC,SAAgB,YAAY,CAAC,SAA4B,EAAE;IACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG,IAAI,sBAAU,CAAC,QAAQ,CAAC,CAAC;IACtC,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED,6CAA6C;AAC7C,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,IAAI,sBAAU,EAAE,EAAE;IAC9C,GAAG,CAAC,OAAO,EAAE,GAAG;QACd,MAAM,OAAO,GAAG,IAAA,qBAAS,GAAE,CAAC;QAC5B,MAAM,KAAK,GAAY,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACjD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,CAAC;CACF,CAAC,CAAC;AACH,sCAAsC;AACzB,QAAA,MAAM,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC","sourcesContent":["import { StreamRequestsClient } from './streams/requests.js';\nimport { StreamMessagesClient } from './streams/messages.js';\nimport { StreamTransport } from './streams/transport.js';\nimport { StreamCapabilitiesClient } from './streams/capabilities.js';\nimport { getClient, HttpClient, type ClientConfig } from './openapi/client.js';\nimport { createOpenAPI } from './openapi/api.generated.js';\nimport { createUnsV2Client } from './uns-v2/client.js';\nimport { bindUnsDataClient } from './uns-v2/data-client.js';\nimport { bindSourceClient } from './source.js';\nimport { bindStreamClient } from './stream.js';\nimport { CapabilitiesClient } from './capabilities.js';\nimport { FilesClient } from './files.js';\nimport type { CloudTransportConfig } from './cloud-transport.js';\n\nexport interface Tier0ClientConfig extends ClientConfig, CloudTransportConfig {}\n/** Use a fresh instance per incoming request when supplying employee data delegation. */\nfunction assemble(resolve: () => HttpClient, snapshot: Tier0ClientConfig) {\n const http = resolve();\n const api = createOpenAPI(http);\n const transport = new StreamTransport(resolve, snapshot);\n const messages = new StreamMessagesClient(transport);\n const raw = createUnsV2Client(resolve, snapshot);\n return Object.freeze({\n streams: { requests: new StreamRequestsClient(transport), messages, capabilities: new StreamCapabilitiesClient(resolve, snapshot) },\n dispose: () => messages.dispose(),\n system: api.system,\n members: api.members,\n notifications: api.notifications,\n mqttAuth: api.mqttAuth,\n agent: api.agent,\n files: new FilesClient(http),\n capabilities: new CapabilitiesClient(resolve, snapshot),\n source: bindSourceClient(raw),\n stream: bindStreamClient(raw),\n uns: bindUnsDataClient(raw),\n api,\n });\n}\nexport type Tier0Client = ReturnType<typeof createClient>;\n\n/** 现役服务端和数据客户端保留独立配置;浏览器交互仅使用受信宿主。 */\nexport function createClient(config: Tier0ClientConfig = {}) {\n const snapshot = Object.freeze({ ...config });\n const http = new HttpClient(snapshot);\n return assemble(() => http, snapshot);\n}\n\n// 全局兼容入口也在调用时读取 configureClient,不固化模块导入时的配置。\nconst defaultHttp = new Proxy(new HttpClient(), {\n get(_target, key) {\n const current = getClient();\n const value: unknown = Reflect.get(current, key);\n return typeof value === 'function' ? value.bind(current) : value;\n },\n});\n/** App 默认交互客户端在调用时解析宿主,无需在浏览器配置密钥。 */\nexport const client = assemble(() => defaultHttp, {});\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAuCA,oCAIC;AA3CD,uDAA6D;AAC7D,uDAA6D;AAC7D,yDAAyD;AACzD,+DAAqE;AACrE,mDAAqG;AACrG,iEAA2D;AAC3D,kDAAuD;AACvD,4DAA4D;AAC5D,2CAA+C;AAC/C,2CAA+C;AAC/C,uDAAuD;AACvD,yCAAyC;AAIzC,SAAS,QAAQ,CAAC,OAAyB,EAAE,QAA2B,EAAE,IAAI,GAAG,OAAO,EAAE;IACxF,MAAM,GAAG,GAAG,IAAA,gCAAa,EAAC,IAAI,CAAC,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,8BAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,IAAI,kCAAoB,CAAC,SAAS,CAAC,CAAC;IACrD,MAAM,GAAG,GAAG,IAAA,6BAAiB,EAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACjD,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,kCAAoB,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,0CAAwB,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE;QACnI,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE;QACjC,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,KAAK,EAAE,IAAI,sBAAW,CAAC,IAAI,CAAC;QAC5B,YAAY,EAAE,IAAI,oCAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC;QACvD,MAAM,EAAE,IAAA,4BAAgB,EAAC,GAAG,CAAC;QAC7B,MAAM,EAAE,IAAA,4BAAgB,EAAC,GAAG,CAAC;QAC7B,GAAG,EAAE,IAAA,kCAAiB,EAAC,GAAG,CAAC;QAC3B,GAAG;KACJ,CAAC,CAAC;AACL,CAAC;AAGD,oCAAoC;AACpC,SAAgB,YAAY,CAAC,SAA4B,EAAE;IACzD,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAA,gCAAoB,EAAC,MAAM,CAAC,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,IAAI,sBAAU,CAAC,QAAQ,CAAC,CAAC;IACtC,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED,6CAA6C;AAC7C,MAAM,WAAW,GAAG,IAAI,KAAK,CAAC,IAAI,sBAAU,EAAE,EAAE;IAC9C,GAAG,CAAC,OAAO,EAAE,GAAG;QACd,MAAM,OAAO,GAAG,IAAA,qBAAS,GAAE,CAAC;QAC5B,MAAM,KAAK,GAAY,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACjD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,CAAC;CACF,CAAC,CAAC;AACH,sCAAsC;AACzB,QAAA,MAAM,GAAG,QAAQ,CAAC,qBAAS,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { StreamRequestsClient } from './streams/requests.js';\nimport { StreamMessagesClient } from './streams/messages.js';\nimport { StreamTransport } from './streams/transport.js';\nimport { StreamCapabilitiesClient } from './streams/capabilities.js';\nimport { getClient, HttpClient, snapshotClientConfig, type ClientConfig } from './openapi/client.js';\nimport { createOpenAPI } from './openapi/api.generated.js';\nimport { createUnsV2Client } from './uns-v2/client.js';\nimport { bindUnsDataClient } from './uns-v2/data-client.js';\nimport { bindSourceClient } from './source.js';\nimport { bindStreamClient } from './stream.js';\nimport { CapabilitiesClient } from './capabilities.js';\nimport { FilesClient } from './files.js';\nimport type { CloudTransportConfig } from './cloud-transport.js';\n\nexport interface Tier0ClientConfig extends ClientConfig, CloudTransportConfig {}\nfunction assemble(resolve: () => HttpClient, snapshot: Tier0ClientConfig, http = resolve()) {\n const api = createOpenAPI(http);\n const transport = new StreamTransport(resolve, snapshot);\n const messages = new StreamMessagesClient(transport);\n const raw = createUnsV2Client(resolve, snapshot);\n return Object.freeze({\n streams: { requests: new StreamRequestsClient(transport), messages, capabilities: new StreamCapabilitiesClient(resolve, snapshot) },\n dispose: () => messages.dispose(),\n system: api.system,\n members: api.members,\n notifications: api.notifications,\n mqttAuth: api.mqttAuth,\n agent: api.agent,\n files: new FilesClient(http),\n capabilities: new CapabilitiesClient(resolve, snapshot),\n source: bindSourceClient(raw),\n stream: bindStreamClient(raw),\n uns: bindUnsDataClient(raw),\n api,\n });\n}\nexport type Tier0Client = ReturnType<typeof createClient>;\n\n/** 每个实例持有独立配置;带 Key 的客户端只在服务端使用。 */\nexport function createClient(config: Tier0ClientConfig = {}) {\n const snapshot = Object.freeze(snapshotClientConfig(config));\n const http = new HttpClient(snapshot);\n return assemble(() => http, snapshot);\n}\n\n// 全局兼容入口也在调用时读取 configureClient,不固化模块导入时的配置。\nconst defaultHttp = new Proxy(new HttpClient(), {\n get(_target, key) {\n const current = getClient();\n const value: unknown = Reflect.get(current, key);\n return typeof value === 'function' ? value.bind(current) : value;\n },\n});\n/** App 默认交互客户端在调用时解析宿主,无需在浏览器配置密钥。 */\nexport const client = assemble(getClient, {}, defaultHttp);\n"]}
@@ -1,31 +1,38 @@
1
- export declare const APP_REQUEST_IDENTITY_HEADER: "X-Tier0-App-Identity";
2
- export declare class AppRequestIdentityError extends Error {
3
- readonly code: 'APP_IDENTITY_INVALID' | 'APP_IDENTITY_CONFIGURATION_INVALID';
4
- constructor(code: 'APP_IDENTITY_INVALID' | 'APP_IDENTITY_CONFIGURATION_INVALID');
1
+ /** Set by the front door on every request it forwards to the App, after stripping any `X-Tier0-*` the client sent. */
2
+ export declare const VISITOR_HEADER = "X-Tier0-Visitor";
3
+ export type VisitorErrorCode = 'VISITOR_HEADER_INVALID' | 'VISITOR_CONFIGURATION_INVALID';
4
+ export declare class VisitorError extends Error {
5
+ readonly code: VisitorErrorCode;
6
+ constructor(code: VisitorErrorCode);
5
7
  }
6
- export interface VerifiedCloudAppUser {
7
- readonly kind: 'gateway-user';
8
- readonly userID: string;
8
+ /** The visitor of a request, from `X-Tier0-Visitor`. */
9
+ export interface Visitor {
10
+ readonly subType: 'employee' | 'machine';
11
+ /** Employee user ID, or the call token ID of a machine visitor. */
12
+ readonly subject: string;
13
+ /** Grant of an employee's access; empty for a machine visitor. */
14
+ readonly grant: string;
9
15
  readonly workspaceID: string;
10
16
  readonly appID: string;
11
- readonly roleKeys: readonly string[];
12
- readonly requestID: string;
13
- readonly issuedAt: number;
14
- readonly expiresAt: number;
15
- readonly verificationKeyID: string;
17
+ readonly runtime: 'deployed' | 'preview';
18
+ /** Roles of this visitor in the App; in Preview, the roles selected in "view as". */
19
+ readonly appRoles: readonly string[];
20
+ /** Only in Preview's "view as". */
21
+ readonly activeRole?: string;
16
22
  }
17
- export interface CloudAppIdentityAuthority {
18
- appID: string;
19
- workspaceID: string;
20
- /** Pinned server configuration, never a key or URL taken from the request. */
21
- publicKeys: unknown;
23
+ export interface ParseVisitorOptions {
24
+ /** The App the header must name. Defaults to `TIER0_APP_ID`. */
25
+ appID?: string;
22
26
  }
23
- export interface CloudAppIdentityRequest {
24
- assertion: string | undefined;
25
- method: string;
26
- requestURI: string;
27
- /** Exact bytes received from the gateway, before JSON parsing or normalization. */
28
- body: Uint8Array;
29
- }
30
- /** Verifies request provenance, not business authorization or delegated UNS permissions. */
31
- export declare function createCloudAppRequestVerifier(authority: CloudAppIdentityAuthority): (request: CloudAppIdentityRequest) => VerifiedCloudAppUser;
27
+ /**
28
+ * Parses `X-Tier0-Visitor`: the unpadded base64url (RFC 4648 §5) of a UTF-8
29
+ * JSON object of at most 8192 bytes. The header is not signed; the front door
30
+ * is the only way into the App and replaces whatever the client sent. Parsing
31
+ * is strict: a byte order mark, a duplicate key, a lone UTF-16 surrogate
32
+ * (e.g. `"\ud800"`), an unknown or missing field, a wrong type or length, a `ws` that
33
+ * is not a positive decimal ID without sign or leading zero, an employee
34
+ * without a grant or a machine visitor with one, or an `app` other than this
35
+ * App's throws `VISITOR_HEADER_INVALID`. Without an App ID
36
+ * (`TIER0_APP_ID` unset) it throws `VISITOR_CONFIGURATION_INVALID`.
37
+ */
38
+ export declare function parseVisitorHeader(value: string | null | undefined, options?: ParseVisitorOptions): Visitor;
@@ -1,114 +1,116 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppRequestIdentityError = exports.APP_REQUEST_IDENTITY_HEADER = void 0;
4
- exports.createCloudAppRequestVerifier = createCloudAppRequestVerifier;
5
- // Server-only entry point. Browser HTTP clients remain independent of node:crypto.
6
- const node_crypto_1 = require("node:crypto");
7
- const app_identity_contract_generated_js_1 = require("./app-identity-contract.generated.js");
8
- exports.APP_REQUEST_IDENTITY_HEADER = app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.header;
9
- class AppRequestIdentityError extends Error {
3
+ exports.VisitorError = exports.VISITOR_HEADER = void 0;
4
+ exports.parseVisitorHeader = parseVisitorHeader;
5
+ // Server-only entry point: the App's view of the request it is serving.
6
+ const runtime_env_js_1 = require("./runtime-env.js");
7
+ const maxID = BigInt('9223372036854775807');
8
+ /** A positive decimal int64 without sign or leading zero. */
9
+ const validID = (value) => typeof value === 'string' && /^[1-9]\d{0,18}$/.test(value) && BigInt(value) <= maxID;
10
+ const isObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
11
+ /** Set by the front door on every request it forwards to the App, after stripping any `X-Tier0-*` the client sent. */
12
+ exports.VISITOR_HEADER = 'X-Tier0-Visitor';
13
+ /** Limit of the JSON before encoding. */
14
+ const VISITOR_MAX_JSON_BYTES = 8192;
15
+ /** Unpadded base64url of `VISITOR_MAX_JSON_BYTES`. */
16
+ const VISITOR_MAX_HEADER_LENGTH = Math.ceil((VISITOR_MAX_JSON_BYTES * 4) / 3);
17
+ const VISITOR_MAX_STRING_BYTES = 128;
18
+ const VISITOR_FIELDS = new Set(['ws', 'app', 'runtime', 'sub_type', 'sub', 'grant', 'app_roles', 'active_role']);
19
+ class VisitorError extends Error {
10
20
  code;
11
21
  constructor(code) {
12
22
  super(code);
13
23
  this.code = code;
14
- this.name = 'AppRequestIdentityError';
24
+ this.name = 'VisitorError';
15
25
  }
16
26
  }
17
- exports.AppRequestIdentityError = AppRequestIdentityError;
18
- const invalid = () => new AppRequestIdentityError('APP_IDENTITY_INVALID');
19
- const invalidConfig = () => new AppRequestIdentityError('APP_IDENTITY_CONFIGURATION_INVALID');
20
- const appPattern = new RegExp(app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.appIDPattern);
21
- const kidPattern = new RegExp(app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.keyIDPattern);
22
- const methodPattern = new RegExp(app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.methodPattern);
23
- const maxID = BigInt('9223372036854775807');
24
- const validID = (value) => typeof value === 'string' && /^[1-9]\d{0,18}$/.test(value) && BigInt(value) <= maxID;
25
- const isObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
26
- const exactKeys = (value, keys) => Object.keys(value).length === keys.length && Object.keys(value).every((key) => keys.includes(key));
27
- const validString = (value, maxBytes) => typeof value === 'string' && value.length > 0 && Buffer.byteLength(value) <= maxBytes &&
28
- Buffer.from(value).toString('utf8') === value && !/[\u0000-\u001f\u007f-\u009f]/.test(value);
29
- const decode = (value) => {
30
- if (!/^[A-Za-z0-9_-]+$/.test(value))
31
- throw invalid();
32
- const bytes = Buffer.from(value, 'base64url');
33
- if (bytes.toString('base64url') !== value)
34
- throw invalid();
35
- return bytes;
36
- };
37
- /** Verifies request provenance, not business authorization or delegated UNS permissions. */
38
- function createCloudAppRequestVerifier(authority) {
39
- if (!isObject(authority) || typeof authority.appID !== 'string' || !appPattern.test(authority.appID) || !validID(authority.workspaceID))
40
- throw invalidConfig();
41
- const appID = authority.appID;
42
- const workspaceID = authority.workspaceID;
43
- const keys = new Map();
44
- try {
45
- let raw = authority.publicKeys;
46
- if (typeof raw === 'string') {
47
- if (Buffer.byteLength(raw) > app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.maxTokenBytes * app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.maxKeys)
48
- throw invalidConfig();
49
- raw = JSON.parse(raw);
50
- }
51
- if (!isObject(raw) || !exactKeys(raw, ['keys']) || !Array.isArray(raw.keys) ||
52
- raw.keys.length === 0 || raw.keys.length > app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.maxKeys)
53
- throw invalidConfig();
54
- for (const key of raw.keys) {
55
- if (!isObject(key) || !exactKeys(key, app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.publicKeyFields) || key.kty !== 'OKP' ||
56
- key.crv !== 'Ed25519' || typeof key.kid !== 'string' || !kidPattern.test(key.kid) ||
57
- keys.has(key.kid) || typeof key.x !== 'string' || decode(key.x).length !== 32)
58
- throw invalidConfig();
59
- keys.set(key.kid, (0, node_crypto_1.createPublicKey)({ key: { kty: 'OKP', crv: 'Ed25519', x: key.x }, format: 'jwk' }));
27
+ exports.VisitorError = VisitorError;
28
+ /** A UTF-16 surrogate without its pair, as JSON escapes like "\ud800" can produce. */
29
+ const LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
30
+ /**
31
+ * Raw key tokens of the top-level object, for spotting duplicates
32
+ * (`JSON.parse` keeps the last silently). Values of the visitor are strings
33
+ * and arrays of strings, so only depth 1 holds keys.
34
+ */
35
+ function topLevelKeys(json) {
36
+ const keys = [];
37
+ let depth = 0;
38
+ for (let i = 0; i < json.length; i += 1) {
39
+ const char = json[i];
40
+ if (char === '{' || char === '[')
41
+ depth += 1;
42
+ else if (char === '}' || char === ']')
43
+ depth -= 1;
44
+ else if (char === '"') {
45
+ const start = i;
46
+ for (i += 1; i < json.length && json[i] !== '"'; i += 1)
47
+ if (json[i] === '\\')
48
+ i += 1;
49
+ let next = i + 1;
50
+ while (next < json.length && /\s/.test(json[next]))
51
+ next += 1;
52
+ if (depth === 1 && json[next] === ':')
53
+ keys.push(json.slice(start, i + 1));
60
54
  }
61
55
  }
56
+ return keys;
57
+ }
58
+ const bytes = (value) => Buffer.byteLength(value, 'utf8');
59
+ const sized = (value, min, max) => typeof value === 'string' && !LONE_SURROGATE.test(value) && bytes(value) >= min && bytes(value) <= max;
60
+ /**
61
+ * Parses `X-Tier0-Visitor`: the unpadded base64url (RFC 4648 §5) of a UTF-8
62
+ * JSON object of at most 8192 bytes. The header is not signed; the front door
63
+ * is the only way into the App and replaces whatever the client sent. Parsing
64
+ * is strict: a byte order mark, a duplicate key, a lone UTF-16 surrogate
65
+ * (e.g. `"\ud800"`), an unknown or missing field, a wrong type or length, a `ws` that
66
+ * is not a positive decimal ID without sign or leading zero, an employee
67
+ * without a grant or a machine visitor with one, or an `app` other than this
68
+ * App's throws `VISITOR_HEADER_INVALID`. Without an App ID
69
+ * (`TIER0_APP_ID` unset) it throws `VISITOR_CONFIGURATION_INVALID`.
70
+ */
71
+ function parseVisitorHeader(value, options = {}) {
72
+ const appID = options.appID ?? (0, runtime_env_js_1.getEnvVar)('TIER0_APP_ID')?.trim();
73
+ if (!appID)
74
+ throw new VisitorError('VISITOR_CONFIGURATION_INVALID');
75
+ const fail = () => new VisitorError('VISITOR_HEADER_INVALID');
76
+ if (typeof value !== 'string' || value.length === 0 || value.length > VISITOR_MAX_HEADER_LENGTH || !/^[A-Za-z0-9_-]+$/.test(value))
77
+ throw fail();
78
+ const raw = Buffer.from(value, 'base64url');
79
+ // Only the canonical encoding: no padding, no stray trailing bits.
80
+ if (raw.length > VISITOR_MAX_JSON_BYTES || raw.toString('base64url') !== value)
81
+ throw fail();
82
+ // A UTF-8 byte order mark is not part of the contract (TextDecoder would drop it silently).
83
+ if (raw[0] === 0xef && raw[1] === 0xbb && raw[2] === 0xbf)
84
+ throw fail();
85
+ let claims;
86
+ let json;
87
+ try {
88
+ json = new TextDecoder('utf-8', { fatal: true }).decode(raw);
89
+ claims = JSON.parse(json);
90
+ }
62
91
  catch {
63
- throw invalidConfig();
92
+ throw fail();
64
93
  }
65
- return (request) => {
66
- try {
67
- if (typeof request.assertion !== 'string' || Buffer.byteLength(request.assertion) > app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.maxTokenBytes ||
68
- !(request.body instanceof Uint8Array) || request.body.byteLength > app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.maxBodyBytes ||
69
- !methodPattern.test(request.method) || !validString(request.requestURI, app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.maxURIBytes) ||
70
- !request.requestURI.startsWith('/') || request.requestURI.startsWith('//'))
71
- throw invalid();
72
- const parts = request.assertion.split('.');
73
- if (parts.length !== 3)
74
- throw invalid();
75
- const header = JSON.parse(decode(parts[0]).toString('utf8'));
76
- if (!isObject(header) || !exactKeys(header, app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.requiredHeaderFields) ||
77
- header.alg !== app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.algorithm || header.typ !== app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.type ||
78
- typeof header.kid !== 'string' || !kidPattern.test(header.kid))
79
- throw invalid();
80
- const key = keys.get(header.kid);
81
- const signature = decode(parts[2]);
82
- if (!key || signature.length !== 64 ||
83
- !(0, node_crypto_1.verify)(null, Buffer.from(parts[0] + '.' + parts[1], 'ascii'), key, signature))
84
- throw invalid();
85
- const claims = JSON.parse(decode(parts[1]).toString('utf8'));
86
- if (!isObject(claims) || !exactKeys(claims, app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.requiredClaims) ||
87
- claims.ver !== app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.version || claims.iss !== app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.issuer || claims.aud !== app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.audience ||
88
- !validID(claims.sub) || claims.workspaceID !== workspaceID || claims.appID !== appID ||
89
- claims.method !== request.method || claims.requestURI !== request.requestURI ||
90
- typeof claims.bodySHA256 !== 'string' || !/^[a-f0-9]{64}$/.test(claims.bodySHA256) ||
91
- claims.bodySHA256 !== (0, node_crypto_1.createHash)('sha256').update(request.body).digest('hex') ||
92
- typeof claims.iat !== 'number' || !Number.isSafeInteger(claims.iat) || claims.iat <= 0 ||
93
- typeof claims.exp !== 'number' || !Number.isSafeInteger(claims.exp) || claims.exp <= claims.iat ||
94
- claims.exp - claims.iat > app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.maxTTLSeconds ||
95
- typeof claims.jti !== 'string' || !/^[a-f0-9]{32}$/.test(claims.jti) ||
96
- !Array.isArray(claims.roles) || claims.roles.length > app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.maxRoles ||
97
- claims.roles.some((role) => !validString(role, app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.maxRoleBytes) || role.trim() !== role) ||
98
- new Set(claims.roles).size !== claims.roles.length)
99
- throw invalid();
100
- const now = Math.floor(Date.now() / 1000);
101
- if (claims.iat > now + app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.clockSkewSeconds || now >= claims.exp + app_identity_contract_generated_js_1.APP_REQUEST_IDENTITY_CONTRACT.clockSkewSeconds)
102
- throw invalid();
103
- return Object.freeze({
104
- kind: 'gateway-user', userID: claims.sub, workspaceID, appID,
105
- roleKeys: Object.freeze([...claims.roles]), requestID: claims.jti,
106
- issuedAt: claims.iat, expiresAt: claims.exp, verificationKeyID: header.kid,
107
- });
108
- }
109
- catch {
110
- throw invalid();
111
- }
112
- };
94
+ if (!isObject(claims) || Object.keys(claims).some((key) => !VISITOR_FIELDS.has(key)))
95
+ throw fail();
96
+ // Every key at most once, each spelling decoded ("\u0077s" is "ws").
97
+ const keys = topLevelKeys(json).map((token) => JSON.parse(token));
98
+ if (new Set(keys).size !== keys.length)
99
+ throw fail();
100
+ const { ws, app, runtime, sub_type: subType, sub, grant, app_roles: appRoles, active_role: activeRole } = claims;
101
+ if (!validID(ws) || app !== appID ||
102
+ (runtime !== 'deployed' && runtime !== 'preview') ||
103
+ (subType !== 'employee' && subType !== 'machine') ||
104
+ !sized(sub, 1, VISITOR_MAX_STRING_BYTES) ||
105
+ // An employee's access always has a grant; a machine visitor has none.
106
+ typeof grant !== 'string' || (subType === 'employee' ? !sized(grant, 1, VISITOR_MAX_STRING_BYTES) : grant !== '') ||
107
+ !Array.isArray(appRoles) || appRoles.some((role) => !sized(role, 1, VISITOR_MAX_STRING_BYTES)) ||
108
+ (activeRole !== undefined && !sized(activeRole, 1, VISITOR_MAX_STRING_BYTES)))
109
+ throw fail();
110
+ return Object.freeze({
111
+ subType, subject: sub, grant, workspaceID: ws, appID, runtime,
112
+ appRoles: Object.freeze([...new Set(appRoles)]),
113
+ ...(activeRole === undefined ? {} : { activeRole }),
114
+ });
113
115
  }
114
116
  //# sourceMappingURL=cloud-server.js.map