mtmsdk 0.0.52 → 0.0.53

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 (250) hide show
  1. package/dist/gomtmapi/@tanstack/react-query.gen.d.ts +21 -173
  2. package/dist/gomtmapi/@tanstack/react-query.gen.d.ts.map +1 -1
  3. package/dist/gomtmapi/@tanstack/react-query.gen.js +39 -179
  4. package/dist/gomtmapi/@tanstack/react-query.gen.js.map +1 -1
  5. package/dist/gomtmapi/index.d.ts +2 -2
  6. package/dist/gomtmapi/index.d.ts.map +1 -1
  7. package/dist/gomtmapi/index.js +1 -1
  8. package/dist/gomtmapi/index.js.map +1 -1
  9. package/dist/gomtmapi/schemas.gen.d.ts +67 -81
  10. package/dist/gomtmapi/schemas.gen.d.ts.map +1 -1
  11. package/dist/gomtmapi/schemas.gen.js +68 -82
  12. package/dist/gomtmapi/schemas.gen.js.map +1 -1
  13. package/dist/gomtmapi/sdk.gen.d.ts +15 -95
  14. package/dist/gomtmapi/sdk.gen.d.ts.map +1 -1
  15. package/dist/gomtmapi/sdk.gen.js +22 -102
  16. package/dist/gomtmapi/sdk.gen.js.map +1 -1
  17. package/dist/gomtmapi/types.gen.d.ts +66 -209
  18. package/dist/gomtmapi/types.gen.d.ts.map +1 -1
  19. package/dist/gomtmapi/zod.gen.d.ts +48 -121
  20. package/dist/gomtmapi/zod.gen.d.ts.map +1 -1
  21. package/dist/gomtmapi/zod.gen.js +36 -99
  22. package/dist/gomtmapi/zod.gen.js.map +1 -1
  23. package/dist/sbmng/@tanstack/react-query.gen.d.ts +146 -146
  24. package/dist/sbmng/@tanstack/react-query.gen.js +6 -6
  25. package/dist/sbmng/schemas.gen.d.ts +4 -4
  26. package/dist/sbmng/schemas.gen.js +4 -4
  27. package/dist/sbmng/schemas.gen.js.map +1 -1
  28. package/dist/sbmng/sdk.gen.d.ts +6 -6
  29. package/dist/sbmng/sdk.gen.js +6 -6
  30. package/dist/supabase/auth-provider.d.ts +8 -1
  31. package/dist/supabase/auth-provider.d.ts.map +1 -1
  32. package/dist/supabase/context.d.ts +3844 -1
  33. package/dist/supabase/context.d.ts.map +1 -1
  34. package/dist/supabase/cursor-pagination.d.ts +4 -4
  35. package/dist/supabase/cursor-pagination.js +4 -4
  36. package/dist/supabase/schema/index.d.ts +1 -11
  37. package/dist/supabase/schema/index.d.ts.map +1 -1
  38. package/dist/supabase/schema/index.js +1 -19
  39. package/dist/supabase/schema/index.js.map +1 -1
  40. package/dist/supabase/schema/system-config.d.ts +12 -0
  41. package/dist/supabase/schema/system-config.d.ts.map +1 -0
  42. package/dist/supabase/schema/system-config.js +22 -0
  43. package/dist/supabase/schema/system-config.js.map +1 -0
  44. package/dist/supabase/supabase-client.d.ts +1 -471
  45. package/dist/supabase/supabase-client.d.ts.map +1 -1
  46. package/dist/supabase/supabase.d.ts +44 -984
  47. package/dist/supabase/supabase.d.ts.map +1 -1
  48. package/dist/supabase/use-sb-query/use-rpc-mutation.d.ts +8 -8
  49. package/dist/supabase/use-sb-query/use-rpc-mutation.js +8 -8
  50. package/dist/types/contracts.d.ts +63 -0
  51. package/dist/types/contracts.d.ts.map +1 -0
  52. package/dist/types/contracts.js +17 -0
  53. package/dist/types/contracts.js.map +1 -0
  54. package/dist/types/database.schemas.d.ts +27 -626
  55. package/dist/types/database.schemas.d.ts.map +1 -1
  56. package/dist/types/database.schemas.js +0 -432
  57. package/dist/types/database.schemas.js.map +1 -1
  58. package/dist/types/database.types.d.ts +1 -476
  59. package/dist/types/database.types.d.ts.map +1 -1
  60. package/dist/types/database.types.js +0 -10
  61. package/dist/types/database.types.js.map +1 -1
  62. package/dist/types/index.d.ts +9 -25
  63. package/dist/types/index.d.ts.map +1 -1
  64. package/dist/types/index.js +3 -5
  65. package/dist/types/index.js.map +1 -1
  66. package/package.json +101 -105
  67. package/dist/cloud-account/platform-configs.d.ts +0 -64
  68. package/dist/cloud-account/platform-configs.d.ts.map +0 -1
  69. package/dist/cloud-account/platform-configs.js +0 -44
  70. package/dist/cloud-account/platform-configs.js.map +0 -1
  71. package/dist/lib/aisdk/types.d.ts +0 -3
  72. package/dist/lib/aisdk/types.d.ts.map +0 -1
  73. package/dist/lib/aisdk/types.js +0 -5
  74. package/dist/lib/aisdk/types.js.map +0 -1
  75. package/dist/lib/logger/index.d.ts +0 -22
  76. package/dist/lib/logger/index.d.ts.map +0 -1
  77. package/dist/lib/logger/index.js +0 -7
  78. package/dist/lib/logger/index.js.map +0 -1
  79. package/dist/lib/schema.d.ts +0 -43
  80. package/dist/lib/schema.d.ts.map +0 -1
  81. package/dist/lib/schema.js +0 -28
  82. package/dist/lib/schema.js.map +0 -1
  83. package/dist/mtgate_api/client/client.gen.d.ts +0 -3
  84. package/dist/mtgate_api/client/client.gen.d.ts.map +0 -1
  85. package/dist/mtgate_api/client/client.gen.js +0 -236
  86. package/dist/mtgate_api/client/client.gen.js.map +0 -1
  87. package/dist/mtgate_api/client/index.d.ts +0 -9
  88. package/dist/mtgate_api/client/index.d.ts.map +0 -1
  89. package/dist/mtgate_api/client/index.js +0 -7
  90. package/dist/mtgate_api/client/index.js.map +0 -1
  91. package/dist/mtgate_api/client/types.gen.d.ts +0 -118
  92. package/dist/mtgate_api/client/types.gen.d.ts.map +0 -1
  93. package/dist/mtgate_api/client/types.gen.js +0 -3
  94. package/dist/mtgate_api/client/types.gen.js.map +0 -1
  95. package/dist/mtgate_api/client/utils.gen.d.ts +0 -34
  96. package/dist/mtgate_api/client/utils.gen.d.ts.map +0 -1
  97. package/dist/mtgate_api/client/utils.gen.js +0 -232
  98. package/dist/mtgate_api/client/utils.gen.js.map +0 -1
  99. package/dist/mtgate_api/client.gen.d.ts +0 -13
  100. package/dist/mtgate_api/client.gen.d.ts.map +0 -1
  101. package/dist/mtgate_api/client.gen.js +0 -4
  102. package/dist/mtgate_api/client.gen.js.map +0 -1
  103. package/dist/mtgate_api/core/auth.gen.d.ts +0 -19
  104. package/dist/mtgate_api/core/auth.gen.d.ts.map +0 -1
  105. package/dist/mtgate_api/core/auth.gen.js +0 -15
  106. package/dist/mtgate_api/core/auth.gen.js.map +0 -1
  107. package/dist/mtgate_api/core/bodySerializer.gen.d.ts +0 -26
  108. package/dist/mtgate_api/core/bodySerializer.gen.d.ts.map +0 -1
  109. package/dist/mtgate_api/core/bodySerializer.gen.js +0 -58
  110. package/dist/mtgate_api/core/bodySerializer.gen.js.map +0 -1
  111. package/dist/mtgate_api/core/params.gen.d.ts +0 -44
  112. package/dist/mtgate_api/core/params.gen.d.ts.map +0 -1
  113. package/dist/mtgate_api/core/params.gen.js +0 -101
  114. package/dist/mtgate_api/core/params.gen.js.map +0 -1
  115. package/dist/mtgate_api/core/pathSerializer.gen.d.ts +0 -34
  116. package/dist/mtgate_api/core/pathSerializer.gen.d.ts.map +0 -1
  117. package/dist/mtgate_api/core/pathSerializer.gen.js +0 -115
  118. package/dist/mtgate_api/core/pathSerializer.gen.js.map +0 -1
  119. package/dist/mtgate_api/core/queryKeySerializer.gen.d.ts +0 -19
  120. package/dist/mtgate_api/core/queryKeySerializer.gen.d.ts.map +0 -1
  121. package/dist/mtgate_api/core/queryKeySerializer.gen.js +0 -100
  122. package/dist/mtgate_api/core/queryKeySerializer.gen.js.map +0 -1
  123. package/dist/mtgate_api/core/serverSentEvents.gen.d.ts +0 -72
  124. package/dist/mtgate_api/core/serverSentEvents.gen.d.ts.map +0 -1
  125. package/dist/mtgate_api/core/serverSentEvents.gen.js +0 -138
  126. package/dist/mtgate_api/core/serverSentEvents.gen.js.map +0 -1
  127. package/dist/mtgate_api/core/types.gen.d.ts +0 -79
  128. package/dist/mtgate_api/core/types.gen.d.ts.map +0 -1
  129. package/dist/mtgate_api/core/types.gen.js +0 -3
  130. package/dist/mtgate_api/core/types.gen.js.map +0 -1
  131. package/dist/mtgate_api/core/utils.gen.d.ts +0 -20
  132. package/dist/mtgate_api/core/utils.gen.d.ts.map +0 -1
  133. package/dist/mtgate_api/core/utils.gen.js +0 -88
  134. package/dist/mtgate_api/core/utils.gen.js.map +0 -1
  135. package/dist/mtgate_api/index.d.ts +0 -3
  136. package/dist/mtgate_api/index.d.ts.map +0 -1
  137. package/dist/mtgate_api/index.js +0 -3
  138. package/dist/mtgate_api/index.js.map +0 -1
  139. package/dist/mtgate_api/sdk.gen.d.ts +0 -15
  140. package/dist/mtgate_api/sdk.gen.d.ts.map +0 -1
  141. package/dist/mtgate_api/sdk.gen.js +0 -3
  142. package/dist/mtgate_api/sdk.gen.js.map +0 -1
  143. package/dist/mtgate_api/types.gen.d.ts +0 -4
  144. package/dist/mtgate_api/types.gen.d.ts.map +0 -1
  145. package/dist/mtgate_api/types.gen.js +0 -3
  146. package/dist/mtgate_api/types.gen.js.map +0 -1
  147. package/dist/openclaw/client-info.d.ts +0 -38
  148. package/dist/openclaw/client-info.d.ts.map +0 -1
  149. package/dist/openclaw/client-info.js +0 -38
  150. package/dist/openclaw/client-info.js.map +0 -1
  151. package/dist/openclaw/device-auth-utils.d.ts +0 -12
  152. package/dist/openclaw/device-auth-utils.d.ts.map +0 -1
  153. package/dist/openclaw/device-auth-utils.js +0 -16
  154. package/dist/openclaw/device-auth-utils.js.map +0 -1
  155. package/dist/openclaw/device-auth.d.ts +0 -21
  156. package/dist/openclaw/device-auth.d.ts.map +0 -1
  157. package/dist/openclaw/device-auth.js +0 -87
  158. package/dist/openclaw/device-auth.js.map +0 -1
  159. package/dist/openclaw/device-identity.d.ts +0 -8
  160. package/dist/openclaw/device-identity.d.ts.map +0 -1
  161. package/dist/openclaw/device-identity.js +0 -87
  162. package/dist/openclaw/device-identity.js.map +0 -1
  163. package/dist/openclaw/gateway.d.ts +0 -100
  164. package/dist/openclaw/gateway.d.ts.map +0 -1
  165. package/dist/openclaw/gateway.js +0 -302
  166. package/dist/openclaw/gateway.js.map +0 -1
  167. package/dist/openclaw/types.d.ts +0 -473
  168. package/dist/openclaw/types.d.ts.map +0 -1
  169. package/dist/openclaw/types.js +0 -2
  170. package/dist/openclaw/types.js.map +0 -1
  171. package/src/cloud-account/platform-configs.ts +0 -73
  172. package/src/gomtmapi/@tanstack/react-query.gen.ts +0 -537
  173. package/src/gomtmapi/client/client.gen.ts +0 -311
  174. package/src/gomtmapi/client/index.ts +0 -25
  175. package/src/gomtmapi/client/types.gen.ts +0 -241
  176. package/src/gomtmapi/client/utils.gen.ts +0 -332
  177. package/src/gomtmapi/client.gen.ts +0 -16
  178. package/src/gomtmapi/core/auth.gen.ts +0 -42
  179. package/src/gomtmapi/core/bodySerializer.gen.ts +0 -100
  180. package/src/gomtmapi/core/params.gen.ts +0 -176
  181. package/src/gomtmapi/core/pathSerializer.gen.ts +0 -181
  182. package/src/gomtmapi/core/queryKeySerializer.gen.ts +0 -136
  183. package/src/gomtmapi/core/serverSentEvents.gen.ts +0 -266
  184. package/src/gomtmapi/core/types.gen.ts +0 -118
  185. package/src/gomtmapi/core/utils.gen.ts +0 -143
  186. package/src/gomtmapi/index.ts +0 -4
  187. package/src/gomtmapi/schemas.gen.ts +0 -532
  188. package/src/gomtmapi/sdk.gen.ts +0 -371
  189. package/src/gomtmapi/types.gen.ts +0 -854
  190. package/src/gomtmapi/zod.gen.ts +0 -448
  191. package/src/index.ts +0 -4
  192. package/src/lib/aisdk/types.ts +0 -8
  193. package/src/lib/logger/index.ts +0 -8
  194. package/src/lib/schema.ts +0 -37
  195. package/src/mtgate_api/client/client.gen.ts +0 -311
  196. package/src/mtgate_api/client/index.ts +0 -25
  197. package/src/mtgate_api/client/types.gen.ts +0 -241
  198. package/src/mtgate_api/client/utils.gen.ts +0 -332
  199. package/src/mtgate_api/client.gen.ts +0 -16
  200. package/src/mtgate_api/core/auth.gen.ts +0 -42
  201. package/src/mtgate_api/core/bodySerializer.gen.ts +0 -100
  202. package/src/mtgate_api/core/params.gen.ts +0 -176
  203. package/src/mtgate_api/core/pathSerializer.gen.ts +0 -181
  204. package/src/mtgate_api/core/queryKeySerializer.gen.ts +0 -136
  205. package/src/mtgate_api/core/serverSentEvents.gen.ts +0 -266
  206. package/src/mtgate_api/core/types.gen.ts +0 -118
  207. package/src/mtgate_api/core/utils.gen.ts +0 -143
  208. package/src/mtgate_api/index.ts +0 -4
  209. package/src/mtgate_api/sdk.gen.ts +0 -17
  210. package/src/mtgate_api/types.gen.ts +0 -5
  211. package/src/openclaw/client-info.ts +0 -54
  212. package/src/openclaw/device-auth-utils.ts +0 -26
  213. package/src/openclaw/device-auth.ts +0 -99
  214. package/src/openclaw/device-identity.ts +0 -108
  215. package/src/openclaw/gateway.ts +0 -392
  216. package/src/openclaw/types.ts +0 -518
  217. package/src/sbmng/@tanstack/react-query.gen.ts +0 -2967
  218. package/src/sbmng/client/client.gen.ts +0 -311
  219. package/src/sbmng/client/index.ts +0 -25
  220. package/src/sbmng/client/types.gen.ts +0 -241
  221. package/src/sbmng/client/utils.gen.ts +0 -332
  222. package/src/sbmng/client.gen.ts +0 -16
  223. package/src/sbmng/core/auth.gen.ts +0 -42
  224. package/src/sbmng/core/bodySerializer.gen.ts +0 -100
  225. package/src/sbmng/core/params.gen.ts +0 -176
  226. package/src/sbmng/core/pathSerializer.gen.ts +0 -181
  227. package/src/sbmng/core/queryKeySerializer.gen.ts +0 -136
  228. package/src/sbmng/core/serverSentEvents.gen.ts +0 -266
  229. package/src/sbmng/core/types.gen.ts +0 -118
  230. package/src/sbmng/core/utils.gen.ts +0 -143
  231. package/src/sbmng/index.ts +0 -4
  232. package/src/sbmng/schemas.gen.ts +0 -9671
  233. package/src/sbmng/sdk.gen.ts +0 -1755
  234. package/src/sbmng/types.gen.ts +0 -7886
  235. package/src/supabase/auth-provider.tsx +0 -67
  236. package/src/supabase/context.tsx +0 -51
  237. package/src/supabase/cursor-pagination.ts +0 -155
  238. package/src/supabase/schema/browser.ts +0 -45
  239. package/src/supabase/schema/index.ts +0 -25
  240. package/src/supabase/supabase-client.ts +0 -30
  241. package/src/supabase/supabase.ts +0 -67
  242. package/src/supabase/use-sb-query/build-query-opts.ts +0 -68
  243. package/src/supabase/use-sb-query/key.ts +0 -57
  244. package/src/supabase/use-sb-query/use-query.ts +0 -352
  245. package/src/supabase/use-sb-query/use-rpc-mutation.ts +0 -83
  246. package/src/supabase/use-sb-query/use-rpc-query.ts +0 -267
  247. package/src/supabase/utils.ts +0 -75
  248. package/src/types/database.schemas.ts +0 -4359
  249. package/src/types/database.types.ts +0 -4182
  250. package/src/types/index.ts +0 -85
@@ -1,143 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- import type { BodySerializer, QuerySerializer } from './bodySerializer.gen';
4
- import {
5
- type ArraySeparatorStyle,
6
- serializeArrayParam,
7
- serializeObjectParam,
8
- serializePrimitiveParam,
9
- } from './pathSerializer.gen';
10
-
11
- export interface PathSerializer {
12
- path: Record<string, unknown>;
13
- url: string;
14
- }
15
-
16
- export const PATH_PARAM_RE = /\{[^{}]+\}/g;
17
-
18
- export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
19
- let url = _url;
20
- const matches = _url.match(PATH_PARAM_RE);
21
- if (matches) {
22
- for (const match of matches) {
23
- let explode = false;
24
- let name = match.substring(1, match.length - 1);
25
- let style: ArraySeparatorStyle = 'simple';
26
-
27
- if (name.endsWith('*')) {
28
- explode = true;
29
- name = name.substring(0, name.length - 1);
30
- }
31
-
32
- if (name.startsWith('.')) {
33
- name = name.substring(1);
34
- style = 'label';
35
- } else if (name.startsWith(';')) {
36
- name = name.substring(1);
37
- style = 'matrix';
38
- }
39
-
40
- const value = path[name];
41
-
42
- if (value === undefined || value === null) {
43
- continue;
44
- }
45
-
46
- if (Array.isArray(value)) {
47
- url = url.replace(
48
- match,
49
- serializeArrayParam({ explode, name, style, value }),
50
- );
51
- continue;
52
- }
53
-
54
- if (typeof value === 'object') {
55
- url = url.replace(
56
- match,
57
- serializeObjectParam({
58
- explode,
59
- name,
60
- style,
61
- value: value as Record<string, unknown>,
62
- valueOnly: true,
63
- }),
64
- );
65
- continue;
66
- }
67
-
68
- if (style === 'matrix') {
69
- url = url.replace(
70
- match,
71
- `;${serializePrimitiveParam({
72
- name,
73
- value: value as string,
74
- })}`,
75
- );
76
- continue;
77
- }
78
-
79
- const replaceValue = encodeURIComponent(
80
- style === 'label' ? `.${value as string}` : (value as string),
81
- );
82
- url = url.replace(match, replaceValue);
83
- }
84
- }
85
- return url;
86
- };
87
-
88
- export const getUrl = ({
89
- baseUrl,
90
- path,
91
- query,
92
- querySerializer,
93
- url: _url,
94
- }: {
95
- baseUrl?: string;
96
- path?: Record<string, unknown>;
97
- query?: Record<string, unknown>;
98
- querySerializer: QuerySerializer;
99
- url: string;
100
- }) => {
101
- const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
102
- let url = (baseUrl ?? '') + pathUrl;
103
- if (path) {
104
- url = defaultPathSerializer({ path, url });
105
- }
106
- let search = query ? querySerializer(query) : '';
107
- if (search.startsWith('?')) {
108
- search = search.substring(1);
109
- }
110
- if (search) {
111
- url += `?${search}`;
112
- }
113
- return url;
114
- };
115
-
116
- export function getValidRequestBody(options: {
117
- body?: unknown;
118
- bodySerializer?: BodySerializer | null;
119
- serializedBody?: unknown;
120
- }) {
121
- const hasBody = options.body !== undefined;
122
- const isSerializedBody = hasBody && options.bodySerializer;
123
-
124
- if (isSerializedBody) {
125
- if ('serializedBody' in options) {
126
- const hasSerializedBody =
127
- options.serializedBody !== undefined && options.serializedBody !== '';
128
-
129
- return hasSerializedBody ? options.serializedBody : null;
130
- }
131
-
132
- // not all clients implement a serializedBody property (i.e. client-axios)
133
- return options.body !== '' ? options.body : null;
134
- }
135
-
136
- // plain/text body
137
- if (hasBody) {
138
- return options.body;
139
- }
140
-
141
- // no body was provided
142
- return undefined;
143
- }
@@ -1,4 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- export type { Options } from './sdk.gen';
4
- export type { ClientOptions } from './types.gen';
@@ -1,17 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- import type { Client, Options as Options2, TDataShape } from './client';
4
-
5
- export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = Options2<TData, ThrowOnError> & {
6
- /**
7
- * You can provide a client instance returned by `createClient()` instead of
8
- * individual options. This might be also useful if you want to implement a
9
- * custom client.
10
- */
11
- client?: Client;
12
- /**
13
- * You can pass arbitrary values through the `meta` object. This can be
14
- * used to access values that aren't defined as part of the SDK function.
15
- */
16
- meta?: Record<string, unknown>;
17
- };
@@ -1,5 +0,0 @@
1
- // This file is auto-generated by @hey-api/openapi-ts
2
-
3
- export type ClientOptions = {
4
- baseUrl: `${string}://${string}` | (string & {});
5
- };
@@ -1,54 +0,0 @@
1
- export const GATEWAY_CLIENT_IDS = {
2
- WEBCHAT_UI: "webchat-ui",
3
- CONTROL_UI: "openclaw-control-ui",
4
- WEBCHAT: "webchat",
5
- CLI: "cli",
6
- GATEWAY_CLIENT: "gateway-client",
7
- MACOS_APP: "openclaw-macos",
8
- IOS_APP: "openclaw-ios",
9
- ANDROID_APP: "openclaw-android",
10
- NODE_HOST: "node-host",
11
- TEST: "test",
12
- FINGERPRINT: "fingerprint",
13
- PROBE: "openclaw-probe",
14
- } as const;
15
-
16
- export type GatewayClientId = (typeof GATEWAY_CLIENT_IDS)[keyof typeof GATEWAY_CLIENT_IDS];
17
-
18
- export const GATEWAY_CLIENT_MODES = {
19
- WEBCHAT: "webchat",
20
- CLI: "cli",
21
- UI: "ui",
22
- BACKEND: "backend",
23
- NODE: "node",
24
- PROBE: "probe",
25
- TEST: "test",
26
- } as const;
27
-
28
- export type GatewayClientMode = (typeof GATEWAY_CLIENT_MODES)[keyof typeof GATEWAY_CLIENT_MODES];
29
-
30
- export type GatewayClientInfo = {
31
- id: GatewayClientId;
32
- displayName?: string;
33
- version: string;
34
- platform: string;
35
- deviceFamily?: string;
36
- modelIdentifier?: string;
37
- mode: GatewayClientMode;
38
- instanceId?: string;
39
- };
40
-
41
- const GATEWAY_CLIENT_ID_SET = new Set<GatewayClientId>(Object.values(GATEWAY_CLIENT_IDS));
42
- const GATEWAY_CLIENT_MODE_SET = new Set<GatewayClientMode>(Object.values(GATEWAY_CLIENT_MODES));
43
-
44
- export function normalizeGatewayClientId(raw?: string | null): GatewayClientId | undefined {
45
- const normalized = raw?.trim().toLowerCase();
46
- if (!normalized) return undefined;
47
- return GATEWAY_CLIENT_ID_SET.has(normalized as GatewayClientId) ? (normalized as GatewayClientId) : undefined;
48
- }
49
-
50
- export function normalizeGatewayClientMode(raw?: string | null): GatewayClientMode | undefined {
51
- const normalized = raw?.trim().toLowerCase();
52
- if (!normalized) return undefined;
53
- return GATEWAY_CLIENT_MODE_SET.has(normalized as GatewayClientMode) ? (normalized as GatewayClientMode) : undefined;
54
- }
@@ -1,26 +0,0 @@
1
- export interface DeviceAuthPayloadParams {
2
- deviceId: string;
3
- clientId: string;
4
- clientMode: string;
5
- role: string;
6
- scopes: string[];
7
- signedAtMs: number;
8
- token?: string | null;
9
- nonce: string;
10
- }
11
-
12
- export function buildDeviceAuthPayload(params: DeviceAuthPayloadParams) {
13
- const scopes = params.scopes.join(",");
14
- const token = params.token ?? "";
15
- return [
16
- "v2",
17
- params.deviceId,
18
- params.clientId,
19
- params.clientMode,
20
- params.role,
21
- scopes,
22
- String(params.signedAtMs),
23
- token,
24
- params.nonce,
25
- ].join("|");
26
- }
@@ -1,99 +0,0 @@
1
- export type DeviceAuthEntry = {
2
- token: string;
3
- role: string;
4
- scopes: string[];
5
- updatedAtMs: number;
6
- };
7
-
8
- type DeviceAuthStore = {
9
- version: 1;
10
- deviceId: string;
11
- tokens: Record<string, DeviceAuthEntry>;
12
- };
13
-
14
- const STORAGE_KEY = "openclaw.device.auth.v1";
15
-
16
- function normalizeRole(role: string): string {
17
- return role.trim();
18
- }
19
-
20
- function normalizeScopes(scopes: string[] | undefined): string[] {
21
- if (!Array.isArray(scopes)) return [];
22
- const out = new Set<string>();
23
- for (const scope of scopes) {
24
- const trimmed = scope.trim();
25
- if (trimmed) out.add(trimmed);
26
- }
27
- return [...out].sort();
28
- }
29
-
30
- function readStore(): DeviceAuthStore | null {
31
- try {
32
- const raw = window.localStorage.getItem(STORAGE_KEY);
33
- if (!raw) return null;
34
- const parsed = JSON.parse(raw) as DeviceAuthStore;
35
- if (!parsed || parsed.version !== 1) return null;
36
- if (!parsed.deviceId || typeof parsed.deviceId !== "string") return null;
37
- if (!parsed.tokens || typeof parsed.tokens !== "object") return null;
38
- return parsed;
39
- } catch {
40
- return null;
41
- }
42
- }
43
-
44
- function writeStore(store: DeviceAuthStore) {
45
- try {
46
- window.localStorage.setItem(STORAGE_KEY, JSON.stringify(store));
47
- } catch {
48
- // best-effort
49
- }
50
- }
51
-
52
- export function loadDeviceAuthToken(params: { deviceId: string; role: string }): DeviceAuthEntry | null {
53
- const store = readStore();
54
- if (!store || store.deviceId !== params.deviceId) return null;
55
- const role = normalizeRole(params.role);
56
- const entry = store.tokens[role];
57
- if (!entry || typeof entry.token !== "string") return null;
58
- return entry;
59
- }
60
-
61
- export function storeDeviceAuthToken(params: {
62
- deviceId: string;
63
- role: string;
64
- token: string;
65
- scopes?: string[];
66
- }): DeviceAuthEntry {
67
- const role = normalizeRole(params.role);
68
- const next: DeviceAuthStore = {
69
- version: 1,
70
- deviceId: params.deviceId,
71
- tokens: {},
72
- };
73
- const existing = readStore();
74
- if (existing && existing.deviceId === params.deviceId) {
75
- next.tokens = { ...existing.tokens };
76
- }
77
- const entry: DeviceAuthEntry = {
78
- token: params.token,
79
- role,
80
- scopes: normalizeScopes(params.scopes),
81
- updatedAtMs: Date.now(),
82
- };
83
- next.tokens[role] = entry;
84
- writeStore(next);
85
- return entry;
86
- }
87
-
88
- export function clearDeviceAuthToken(params: { deviceId: string; role: string }) {
89
- const store = readStore();
90
- if (!store || store.deviceId !== params.deviceId) return;
91
- const role = normalizeRole(params.role);
92
- if (!store.tokens[role]) return;
93
- const next = {
94
- ...store,
95
- tokens: { ...store.tokens },
96
- };
97
- delete next.tokens[role];
98
- writeStore(next);
99
- }
@@ -1,108 +0,0 @@
1
- import { getPublicKeyAsync, signAsync, utils } from "@noble/ed25519";
2
-
3
- type StoredIdentity = {
4
- version: 1;
5
- deviceId: string;
6
- publicKey: string;
7
- privateKey: string;
8
- createdAtMs: number;
9
- };
10
-
11
- export type DeviceIdentity = {
12
- deviceId: string;
13
- publicKey: string;
14
- privateKey: string;
15
- };
16
-
17
- const STORAGE_KEY = "openclaw-device-identity-v1";
18
-
19
- function base64UrlEncode(bytes: Uint8Array): string {
20
- let binary = "";
21
- for (const byte of bytes) binary += String.fromCharCode(byte);
22
- return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/g, "");
23
- }
24
-
25
- function base64UrlDecode(input: string): Uint8Array {
26
- const normalized = input.replaceAll("-", "+").replaceAll("_", "/");
27
- const padded = normalized + "=".repeat((4 - (normalized.length % 4)) % 4);
28
- const binary = atob(padded);
29
- const out = new Uint8Array(binary.length);
30
- for (let i = 0; i < binary.length; i += 1) out[i] = binary.charCodeAt(i);
31
- return out;
32
- }
33
-
34
- function bytesToHex(bytes: Uint8Array): string {
35
- return Array.from(bytes)
36
- .map((b) => b.toString(16).padStart(2, "0"))
37
- .join("");
38
- }
39
-
40
- async function fingerprintPublicKey(publicKey: Uint8Array): Promise<string> {
41
- const hash = await crypto.subtle.digest("SHA-256", publicKey.slice().buffer);
42
- return bytesToHex(new Uint8Array(hash));
43
- }
44
-
45
- async function generateIdentity(): Promise<DeviceIdentity> {
46
- const privateKey = utils.randomSecretKey();
47
- const publicKey = await getPublicKeyAsync(privateKey);
48
- const deviceId = await fingerprintPublicKey(publicKey);
49
- return {
50
- deviceId,
51
- publicKey: base64UrlEncode(publicKey),
52
- privateKey: base64UrlEncode(privateKey),
53
- };
54
- }
55
-
56
- export async function loadOrCreateDeviceIdentity(): Promise<DeviceIdentity> {
57
- try {
58
- const raw = localStorage.getItem(STORAGE_KEY);
59
- if (raw) {
60
- const parsed = JSON.parse(raw) as StoredIdentity;
61
- if (
62
- parsed?.version === 1 &&
63
- typeof parsed.deviceId === "string" &&
64
- typeof parsed.publicKey === "string" &&
65
- typeof parsed.privateKey === "string"
66
- ) {
67
- const derivedId = await fingerprintPublicKey(base64UrlDecode(parsed.publicKey));
68
- if (derivedId !== parsed.deviceId) {
69
- const updated: StoredIdentity = {
70
- ...parsed,
71
- deviceId: derivedId,
72
- };
73
- localStorage.setItem(STORAGE_KEY, JSON.stringify(updated));
74
- return {
75
- deviceId: derivedId,
76
- publicKey: parsed.publicKey,
77
- privateKey: parsed.privateKey,
78
- };
79
- }
80
- return {
81
- deviceId: parsed.deviceId,
82
- publicKey: parsed.publicKey,
83
- privateKey: parsed.privateKey,
84
- };
85
- }
86
- }
87
- } catch {
88
- // fall through to regenerate
89
- }
90
-
91
- const identity = await generateIdentity();
92
- const stored: StoredIdentity = {
93
- version: 1,
94
- deviceId: identity.deviceId,
95
- publicKey: identity.publicKey,
96
- privateKey: identity.privateKey,
97
- createdAtMs: Date.now(),
98
- };
99
- localStorage.setItem(STORAGE_KEY, JSON.stringify(stored));
100
- return identity;
101
- }
102
-
103
- export async function signDevicePayload(privateKeyBase64Url: string, payload: string) {
104
- const key = base64UrlDecode(privateKeyBase64Url);
105
- const data = new TextEncoder().encode(payload);
106
- const sig = await signAsync(data, key);
107
- return base64UrlEncode(sig);
108
- }