@tinycloud/sdk-core 2.0.0 → 2.0.2-beta.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 (188) hide show
  1. package/dist/index.cjs +3816 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +3867 -0
  4. package/dist/index.d.ts +3861 -21
  5. package/dist/index.js +3767 -61
  6. package/dist/index.js.map +1 -1
  7. package/package.json +6 -5
  8. package/dist/TinyCloud.d.ts +0 -271
  9. package/dist/TinyCloud.d.ts.map +0 -1
  10. package/dist/TinyCloud.js +0 -458
  11. package/dist/TinyCloud.js.map +0 -1
  12. package/dist/TinyCloud.schema.d.ts +0 -173
  13. package/dist/TinyCloud.schema.d.ts.map +0 -1
  14. package/dist/TinyCloud.schema.js +0 -136
  15. package/dist/TinyCloud.schema.js.map +0 -1
  16. package/dist/TinyCloud.schema.test.d.ts +0 -5
  17. package/dist/TinyCloud.schema.test.d.ts.map +0 -1
  18. package/dist/TinyCloud.schema.test.js +0 -286
  19. package/dist/TinyCloud.schema.test.js.map +0 -1
  20. package/dist/authorization/CapabilityKeyRegistry.d.ts +0 -317
  21. package/dist/authorization/CapabilityKeyRegistry.d.ts.map +0 -1
  22. package/dist/authorization/CapabilityKeyRegistry.js +0 -509
  23. package/dist/authorization/CapabilityKeyRegistry.js.map +0 -1
  24. package/dist/authorization/authorization.schema.d.ts +0 -233
  25. package/dist/authorization/authorization.schema.d.ts.map +0 -1
  26. package/dist/authorization/authorization.schema.js +0 -220
  27. package/dist/authorization/authorization.schema.js.map +0 -1
  28. package/dist/authorization/authorization.schema.test.d.ts +0 -5
  29. package/dist/authorization/authorization.schema.test.d.ts.map +0 -1
  30. package/dist/authorization/authorization.schema.test.js +0 -618
  31. package/dist/authorization/authorization.schema.test.js.map +0 -1
  32. package/dist/authorization/index.d.ts +0 -38
  33. package/dist/authorization/index.d.ts.map +0 -1
  34. package/dist/authorization/index.js +0 -52
  35. package/dist/authorization/index.js.map +0 -1
  36. package/dist/authorization/spaceCreation.d.ts +0 -96
  37. package/dist/authorization/spaceCreation.d.ts.map +0 -1
  38. package/dist/authorization/spaceCreation.js +0 -35
  39. package/dist/authorization/spaceCreation.js.map +0 -1
  40. package/dist/authorization/spaceCreation.schema.d.ts +0 -67
  41. package/dist/authorization/spaceCreation.schema.d.ts.map +0 -1
  42. package/dist/authorization/spaceCreation.schema.js +0 -95
  43. package/dist/authorization/spaceCreation.schema.js.map +0 -1
  44. package/dist/authorization/spaceCreation.schema.test.d.ts +0 -5
  45. package/dist/authorization/spaceCreation.schema.test.d.ts.map +0 -1
  46. package/dist/authorization/spaceCreation.schema.test.js +0 -168
  47. package/dist/authorization/spaceCreation.schema.test.js.map +0 -1
  48. package/dist/authorization/strategies.d.ts +0 -134
  49. package/dist/authorization/strategies.d.ts.map +0 -1
  50. package/dist/authorization/strategies.js +0 -15
  51. package/dist/authorization/strategies.js.map +0 -1
  52. package/dist/authorization/strategies.schema.d.ts +0 -185
  53. package/dist/authorization/strategies.schema.d.ts.map +0 -1
  54. package/dist/authorization/strategies.schema.js +0 -147
  55. package/dist/authorization/strategies.schema.js.map +0 -1
  56. package/dist/authorization/strategies.schema.test.d.ts +0 -5
  57. package/dist/authorization/strategies.schema.test.d.ts.map +0 -1
  58. package/dist/authorization/strategies.schema.test.js +0 -253
  59. package/dist/authorization/strategies.schema.test.js.map +0 -1
  60. package/dist/client-types.d.ts +0 -128
  61. package/dist/client-types.d.ts.map +0 -1
  62. package/dist/client-types.js +0 -40
  63. package/dist/client-types.js.map +0 -1
  64. package/dist/delegations/DelegationManager.d.ts +0 -164
  65. package/dist/delegations/DelegationManager.d.ts.map +0 -1
  66. package/dist/delegations/DelegationManager.js +0 -428
  67. package/dist/delegations/DelegationManager.js.map +0 -1
  68. package/dist/delegations/SharingService.d.ts +0 -341
  69. package/dist/delegations/SharingService.d.ts.map +0 -1
  70. package/dist/delegations/SharingService.js +0 -722
  71. package/dist/delegations/SharingService.js.map +0 -1
  72. package/dist/delegations/SharingService.schema.d.ts +0 -409
  73. package/dist/delegations/SharingService.schema.d.ts.map +0 -1
  74. package/dist/delegations/SharingService.schema.js +0 -222
  75. package/dist/delegations/SharingService.schema.js.map +0 -1
  76. package/dist/delegations/index.d.ts +0 -38
  77. package/dist/delegations/index.d.ts.map +0 -1
  78. package/dist/delegations/index.js +0 -42
  79. package/dist/delegations/index.js.map +0 -1
  80. package/dist/delegations/types.d.ts +0 -13
  81. package/dist/delegations/types.d.ts.map +0 -1
  82. package/dist/delegations/types.js +0 -42
  83. package/dist/delegations/types.js.map +0 -1
  84. package/dist/delegations/types.schema.d.ts +0 -1773
  85. package/dist/delegations/types.schema.d.ts.map +0 -1
  86. package/dist/delegations/types.schema.js +0 -535
  87. package/dist/delegations/types.schema.js.map +0 -1
  88. package/dist/delegations/types.schema.test.d.ts +0 -5
  89. package/dist/delegations/types.schema.test.d.ts.map +0 -1
  90. package/dist/delegations/types.schema.test.js +0 -627
  91. package/dist/delegations/types.schema.test.js.map +0 -1
  92. package/dist/ens.d.ts +0 -17
  93. package/dist/ens.d.ts.map +0 -1
  94. package/dist/ens.js +0 -10
  95. package/dist/ens.js.map +0 -1
  96. package/dist/index.d.ts.map +0 -1
  97. package/dist/json-schema.d.ts +0 -327
  98. package/dist/json-schema.d.ts.map +0 -1
  99. package/dist/json-schema.js +0 -703
  100. package/dist/json-schema.js.map +0 -1
  101. package/dist/json-schema.test.d.ts +0 -7
  102. package/dist/json-schema.test.d.ts.map +0 -1
  103. package/dist/json-schema.test.js +0 -365
  104. package/dist/json-schema.test.js.map +0 -1
  105. package/dist/notifications.d.ts +0 -33
  106. package/dist/notifications.d.ts.map +0 -1
  107. package/dist/notifications.js +0 -15
  108. package/dist/notifications.js.map +0 -1
  109. package/dist/signer.d.ts +0 -28
  110. package/dist/signer.d.ts.map +0 -1
  111. package/dist/signer.js +0 -2
  112. package/dist/signer.js.map +0 -1
  113. package/dist/space.d.ts +0 -57
  114. package/dist/space.d.ts.map +0 -1
  115. package/dist/space.js +0 -87
  116. package/dist/space.js.map +0 -1
  117. package/dist/space.schema.d.ts +0 -65
  118. package/dist/space.schema.d.ts.map +0 -1
  119. package/dist/space.schema.js +0 -65
  120. package/dist/space.schema.js.map +0 -1
  121. package/dist/space.schema.test.d.ts +0 -5
  122. package/dist/space.schema.test.d.ts.map +0 -1
  123. package/dist/space.schema.test.js +0 -148
  124. package/dist/space.schema.test.js.map +0 -1
  125. package/dist/space.test.d.ts +0 -5
  126. package/dist/space.test.d.ts.map +0 -1
  127. package/dist/space.test.js +0 -87
  128. package/dist/space.test.js.map +0 -1
  129. package/dist/spaces/Space.d.ts +0 -175
  130. package/dist/spaces/Space.d.ts.map +0 -1
  131. package/dist/spaces/Space.js +0 -84
  132. package/dist/spaces/Space.js.map +0 -1
  133. package/dist/spaces/SpaceService.d.ts +0 -291
  134. package/dist/spaces/SpaceService.d.ts.map +0 -1
  135. package/dist/spaces/SpaceService.js +0 -740
  136. package/dist/spaces/SpaceService.js.map +0 -1
  137. package/dist/spaces/index.d.ts +0 -11
  138. package/dist/spaces/index.d.ts.map +0 -1
  139. package/dist/spaces/index.js +0 -22
  140. package/dist/spaces/index.js.map +0 -1
  141. package/dist/spaces/spaces.schema.d.ts +0 -421
  142. package/dist/spaces/spaces.schema.d.ts.map +0 -1
  143. package/dist/spaces/spaces.schema.js +0 -342
  144. package/dist/spaces/spaces.schema.js.map +0 -1
  145. package/dist/spaces/spaces.schema.test.d.ts +0 -5
  146. package/dist/spaces/spaces.schema.test.d.ts.map +0 -1
  147. package/dist/spaces/spaces.schema.test.js +0 -471
  148. package/dist/spaces/spaces.schema.test.js.map +0 -1
  149. package/dist/storage.d.ts +0 -47
  150. package/dist/storage.d.ts.map +0 -1
  151. package/dist/storage.js +0 -14
  152. package/dist/storage.js.map +0 -1
  153. package/dist/storage.schema.d.ts +0 -291
  154. package/dist/storage.schema.d.ts.map +0 -1
  155. package/dist/storage.schema.js +0 -189
  156. package/dist/storage.schema.js.map +0 -1
  157. package/dist/storage.schema.test.d.ts +0 -5
  158. package/dist/storage.schema.test.d.ts.map +0 -1
  159. package/dist/storage.schema.test.js +0 -346
  160. package/dist/storage.schema.test.js.map +0 -1
  161. package/dist/userAuthorization.d.ts +0 -117
  162. package/dist/userAuthorization.d.ts.map +0 -1
  163. package/dist/userAuthorization.js +0 -3
  164. package/dist/userAuthorization.js.map +0 -1
  165. package/dist/userAuthorization.schema.d.ts +0 -260
  166. package/dist/userAuthorization.schema.d.ts.map +0 -1
  167. package/dist/userAuthorization.schema.js +0 -169
  168. package/dist/userAuthorization.schema.js.map +0 -1
  169. package/dist/userAuthorization.schema.test.d.ts +0 -5
  170. package/dist/userAuthorization.schema.test.d.ts.map +0 -1
  171. package/dist/userAuthorization.schema.test.js +0 -356
  172. package/dist/userAuthorization.schema.test.js.map +0 -1
  173. package/dist/version.d.ts +0 -32
  174. package/dist/version.d.ts.map +0 -1
  175. package/dist/version.js +0 -59
  176. package/dist/version.js.map +0 -1
  177. package/dist/wasm-validation.d.ts +0 -291
  178. package/dist/wasm-validation.d.ts.map +0 -1
  179. package/dist/wasm-validation.js +0 -221
  180. package/dist/wasm-validation.js.map +0 -1
  181. package/dist/wasm-validation.test.d.ts +0 -5
  182. package/dist/wasm-validation.test.d.ts.map +0 -1
  183. package/dist/wasm-validation.test.js +0 -233
  184. package/dist/wasm-validation.test.js.map +0 -1
  185. package/dist/wasm.d.ts +0 -66
  186. package/dist/wasm.d.ts.map +0 -1
  187. package/dist/wasm.js +0 -10
  188. package/dist/wasm.js.map +0 -1
@@ -1,175 +0,0 @@
1
- /**
2
- * Space - Represents a scoped access point to a TinyCloud space.
3
- *
4
- * The Space object provides scoped access to services within a specific space,
5
- * whether owned by the user or delegated from another user.
6
- *
7
- * @packageDocumentation
8
- */
9
- import type { IKVService, Result, ServiceError } from "@tinycloud/sdk-services";
10
- import type { SpaceInfo } from "../delegations/types";
11
- /**
12
- * Interface for space-scoped delegation operations.
13
- *
14
- * Provides delegation management scoped to a specific space.
15
- */
16
- export interface ISpaceScopedDelegations {
17
- /**
18
- * List delegations created by the user in this space (outgoing).
19
- */
20
- list(): Promise<Result<import("../delegations/types").Delegation[], ServiceError>>;
21
- /**
22
- * List delegations received by the user for this space (incoming).
23
- */
24
- listReceived(): Promise<Result<import("../delegations/types").Delegation[], ServiceError>>;
25
- /**
26
- * Create a delegation within this space.
27
- */
28
- create(params: Omit<import("../delegations/types").CreateDelegationParams, "spaceId">): Promise<Result<import("../delegations/types").Delegation, ServiceError>>;
29
- /**
30
- * Revoke a delegation within this space.
31
- */
32
- revoke(cid: string): Promise<Result<void, ServiceError>>;
33
- }
34
- /**
35
- * Interface for space-scoped sharing operations.
36
- *
37
- * Provides sharing link management scoped to a specific space.
38
- */
39
- export interface ISpaceScopedSharing {
40
- /**
41
- * Generate a sharing link for a resource in this space.
42
- */
43
- generate(params: Omit<import("../delegations/types").GenerateShareParams, "spaceId">): Promise<Result<import("../delegations/types").ShareLink, ServiceError>>;
44
- /**
45
- * List active sharing links in this space.
46
- */
47
- list(): Promise<Result<import("../delegations/types").ShareLink[], ServiceError>>;
48
- /**
49
- * Revoke a sharing link.
50
- */
51
- revoke(token: string): Promise<Result<void, ServiceError>>;
52
- }
53
- /**
54
- * Interface for a Space object.
55
- *
56
- * Provides scoped access to services within a specific space.
57
- */
58
- export interface ISpace {
59
- /**
60
- * The space identifier.
61
- */
62
- readonly id: string;
63
- /**
64
- * The short name of the space.
65
- */
66
- readonly name: string;
67
- /**
68
- * KV operations scoped to this space.
69
- */
70
- readonly kv: IKVService;
71
- /**
72
- * Delegation operations scoped to this space.
73
- */
74
- readonly delegations: ISpaceScopedDelegations;
75
- /**
76
- * Sharing operations scoped to this space.
77
- */
78
- readonly sharing: ISpaceScopedSharing;
79
- /**
80
- * Get space metadata.
81
- */
82
- info(): Promise<Result<SpaceInfo, ServiceError>>;
83
- }
84
- /**
85
- * Configuration for creating a Space object.
86
- */
87
- export interface SpaceConfig {
88
- /**
89
- * The space identifier (full URI).
90
- */
91
- id: string;
92
- /**
93
- * The short name of the space.
94
- */
95
- name: string;
96
- /**
97
- * Factory function to create a space-scoped KV service.
98
- */
99
- createKV: (spaceId: string) => IKVService;
100
- /**
101
- * Factory function to create space-scoped delegations.
102
- */
103
- createDelegations: (spaceId: string) => ISpaceScopedDelegations;
104
- /**
105
- * Factory function to create space-scoped sharing.
106
- */
107
- createSharing: (spaceId: string) => ISpaceScopedSharing;
108
- /**
109
- * Function to get space info.
110
- */
111
- getInfo: (spaceId: string) => Promise<Result<SpaceInfo, ServiceError>>;
112
- }
113
- /**
114
- * Space - Provides scoped access to services within a specific space.
115
- *
116
- * @example
117
- * ```typescript
118
- * const space = sdk.space('default');
119
- *
120
- * // KV operations scoped to this space
121
- * await space.kv.put('key', 'value');
122
- * const result = await space.kv.get('key');
123
- *
124
- * // Delegation operations scoped to this space
125
- * await space.delegations.create({
126
- * delegateDID: 'did:pkh:eip155:1:0x...',
127
- * path: '/shared/',
128
- * actions: ['tinycloud.kv/get']
129
- * });
130
- *
131
- * // Get space metadata
132
- * const info = await space.info();
133
- * ```
134
- */
135
- export declare class Space implements ISpace {
136
- private readonly _id;
137
- private readonly _name;
138
- private readonly _kv;
139
- private readonly _delegations;
140
- private readonly _sharing;
141
- private readonly _getInfo;
142
- /**
143
- * Create a new Space instance.
144
- *
145
- * @param config - Space configuration
146
- */
147
- constructor(config: SpaceConfig);
148
- /**
149
- * The space identifier (full URI).
150
- */
151
- get id(): string;
152
- /**
153
- * The short name of the space.
154
- */
155
- get name(): string;
156
- /**
157
- * KV operations scoped to this space.
158
- */
159
- get kv(): IKVService;
160
- /**
161
- * Delegation operations scoped to this space.
162
- */
163
- get delegations(): ISpaceScopedDelegations;
164
- /**
165
- * Sharing operations scoped to this space.
166
- */
167
- get sharing(): ISpaceScopedSharing;
168
- /**
169
- * Get space metadata.
170
- *
171
- * @returns Result containing space information
172
- */
173
- info(): Promise<Result<SpaceInfo, ServiceError>>;
174
- }
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A0B;IACvD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsB;IAC/C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgE;IAEzF;;;;OAIG;gBACS,MAAM,EAAE,WAAW;IAS/B;;OAEG;IACH,IAAI,EAAE,IAAI,MAAM,CAEf;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,EAAE,IAAI,UAAU,CAEnB;IAED;;OAEG;IACH,IAAI,WAAW,IAAI,uBAAuB,CAEzC;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,mBAAmB,CAEjC;IAED;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;CAGvD"}
@@ -1,84 +0,0 @@
1
- /**
2
- * Space - Represents a scoped access point to a TinyCloud space.
3
- *
4
- * The Space object provides scoped access to services within a specific space,
5
- * whether owned by the user or delegated from another user.
6
- *
7
- * @packageDocumentation
8
- */
9
- /**
10
- * Space - Provides scoped access to services within a specific space.
11
- *
12
- * @example
13
- * ```typescript
14
- * const space = sdk.space('default');
15
- *
16
- * // KV operations scoped to this space
17
- * await space.kv.put('key', 'value');
18
- * const result = await space.kv.get('key');
19
- *
20
- * // Delegation operations scoped to this space
21
- * await space.delegations.create({
22
- * delegateDID: 'did:pkh:eip155:1:0x...',
23
- * path: '/shared/',
24
- * actions: ['tinycloud.kv/get']
25
- * });
26
- *
27
- * // Get space metadata
28
- * const info = await space.info();
29
- * ```
30
- */
31
- export class Space {
32
- /**
33
- * Create a new Space instance.
34
- *
35
- * @param config - Space configuration
36
- */
37
- constructor(config) {
38
- this._id = config.id;
39
- this._name = config.name;
40
- this._kv = config.createKV(config.id);
41
- this._delegations = config.createDelegations(config.id);
42
- this._sharing = config.createSharing(config.id);
43
- this._getInfo = config.getInfo;
44
- }
45
- /**
46
- * The space identifier (full URI).
47
- */
48
- get id() {
49
- return this._id;
50
- }
51
- /**
52
- * The short name of the space.
53
- */
54
- get name() {
55
- return this._name;
56
- }
57
- /**
58
- * KV operations scoped to this space.
59
- */
60
- get kv() {
61
- return this._kv;
62
- }
63
- /**
64
- * Delegation operations scoped to this space.
65
- */
66
- get delegations() {
67
- return this._delegations;
68
- }
69
- /**
70
- * Sharing operations scoped to this space.
71
- */
72
- get sharing() {
73
- return this._sharing;
74
- }
75
- /**
76
- * Get space metadata.
77
- *
78
- * @returns Result containing space information
79
- */
80
- async info() {
81
- return this._getInfo(this._id);
82
- }
83
- }
84
- //# sourceMappingURL=Space.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Space.js","sourceRoot":"","sources":["../../src/spaces/Space.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkIH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,KAAK;IAQhB;;;;OAIG;IACH,YAAY,MAAmB;QAC7B,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;CACF"}
@@ -1,291 +0,0 @@
1
- /**
2
- * SpaceService - Global singleton for managing spaces (owned and delegated).
3
- *
4
- * SpaceService provides a unified interface for discovering, creating,
5
- * and accessing spaces. It handles both owned spaces (created by the user)
6
- * and delegated spaces (shared by other users).
7
- *
8
- * @packageDocumentation
9
- */
10
- import type { IKVService, Result, ServiceError, ServiceSession, FetchFunction, InvokeFunction } from "@tinycloud/sdk-services";
11
- import type { SpaceInfo, Delegation, CreateDelegationParams } from "../delegations/types";
12
- import type { ICapabilityKeyRegistry } from "../authorization/CapabilityKeyRegistry";
13
- import type { ISharingService } from "../delegations/SharingService";
14
- import { type ISpace } from "./Space";
15
- /**
16
- * Error codes for SpaceService operations.
17
- */
18
- export declare const SpaceErrorCodes: {
19
- /** Space not found */
20
- readonly NOT_FOUND: "SPACE_NOT_FOUND";
21
- /** Space already exists */
22
- readonly ALREADY_EXISTS: "SPACE_ALREADY_EXISTS";
23
- /** Creation failed */
24
- readonly CREATION_FAILED: "SPACE_CREATION_FAILED";
25
- /** Authentication required */
26
- readonly AUTH_REQUIRED: "AUTH_REQUIRED";
27
- /** Invalid space name or URI */
28
- readonly INVALID_NAME: "INVALID_SPACE_NAME";
29
- /** Network error */
30
- readonly NETWORK_ERROR: "NETWORK_ERROR";
31
- /** Not initialized */
32
- readonly NOT_INITIALIZED: "NOT_INITIALIZED";
33
- };
34
- export type SpaceErrorCode = (typeof SpaceErrorCodes)[keyof typeof SpaceErrorCodes];
35
- /**
36
- * Parameters for creating a space-scoped delegation.
37
- * Extends CreateDelegationParams with the spaceId.
38
- */
39
- export interface SpaceDelegationParams extends Omit<CreateDelegationParams, "spaceId"> {
40
- /** The space ID to create the delegation for */
41
- spaceId: string;
42
- }
43
- /**
44
- * Function type for creating delegations.
45
- * Platform SDKs provide this to handle SIWE-based delegation creation.
46
- */
47
- export type CreateDelegationFunction = (params: SpaceDelegationParams) => Promise<Result<Delegation, ServiceError>>;
48
- /**
49
- * Configuration for SpaceService.
50
- */
51
- export interface SpaceServiceConfig {
52
- /** TinyCloud host URLs */
53
- hosts: string[];
54
- /** Active session for authentication */
55
- session: ServiceSession;
56
- /** Platform-specific invoke function */
57
- invoke: InvokeFunction;
58
- /** Optional custom fetch implementation */
59
- fetch?: FetchFunction;
60
- /** Optional capability key registry for delegated space discovery */
61
- capabilityRegistry?: ICapabilityKeyRegistry;
62
- /** Factory function to create a space-scoped KV service */
63
- createKVService?: (spaceId: string) => IKVService;
64
- /** User's PKH DID (derived from address or provided explicitly) */
65
- userDid?: string;
66
- /** Optional SharingService for v2 sharing links (client-side) */
67
- sharingService?: ISharingService;
68
- /**
69
- * Factory function to create delegations using SIWE-based flow.
70
- * Platform SDKs (web-sdk, node-sdk) provide this using their WASM bindings.
71
- * Required for space.delegations.create() to work.
72
- */
73
- createDelegation?: CreateDelegationFunction;
74
- }
75
- /**
76
- * Interface for SpaceService.
77
- */
78
- export interface ISpaceService {
79
- /**
80
- * List all spaces the user has access to (owned + delegated).
81
- */
82
- list(): Promise<Result<SpaceInfo[], ServiceError>>;
83
- /**
84
- * Create a new space.
85
- *
86
- * @param name - The name for the new space
87
- */
88
- create(name: string): Promise<Result<SpaceInfo, ServiceError>>;
89
- /**
90
- * Get a Space object by name or full URI.
91
- *
92
- * For owned spaces, use the short name: `sdk.space('default')`
93
- * For delegated spaces, use the full URI: `sdk.space('tinycloud:pkh:eip155:1:0x...:photos')`
94
- *
95
- * @param nameOrUri - Short name or full URI
96
- */
97
- get(nameOrUri: string): ISpace;
98
- /**
99
- * Check if a space exists and the user has access.
100
- *
101
- * @param nameOrUri - Short name or full URI
102
- */
103
- exists(nameOrUri: string): Promise<Result<boolean, ServiceError>>;
104
- /**
105
- * Get the current user's primary space ID.
106
- */
107
- getCurrentSpaceId(): string | undefined;
108
- /**
109
- * Update the service configuration.
110
- */
111
- updateConfig(config: Partial<SpaceServiceConfig>): void;
112
- }
113
- /**
114
- * Construct the deterministic public space ID for a given address and chain ID.
115
- *
116
- * Public space IDs follow the format:
117
- * `tinycloud:pkh:eip155:{chainId}:{address}:public`
118
- *
119
- * Given an address and chain ID, any client can construct this ID
120
- * to discover and read a user's public data without prior interaction.
121
- *
122
- * @param address - Ethereum address (0x-prefixed)
123
- * @param chainId - Chain ID (e.g., 1 for mainnet)
124
- * @returns The full public space ID URI
125
- *
126
- * @example
127
- * ```typescript
128
- * const spaceId = makePublicSpaceId('0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045', 1);
129
- * // => "tinycloud:pkh:eip155:1:0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045:public"
130
- * ```
131
- */
132
- export declare function makePublicSpaceId(address: string, chainId: number): string;
133
- /**
134
- * Parse a space URI to extract components.
135
- *
136
- * Full URI format: `tinycloud:pkh:eip155:{chainId}:{address}:{name}`
137
- * Short name format: `{name}`
138
- *
139
- * @param uri - The space URI or short name
140
- * @returns Parsed components or null if invalid
141
- */
142
- export declare function parseSpaceUri(uri: string): {
143
- owner: string;
144
- name: string;
145
- chainId?: string;
146
- address?: string;
147
- } | null;
148
- /**
149
- * Build a full space URI from components.
150
- *
151
- * @param owner - Owner DID (did:pkh:eip155:{chainId}:{address})
152
- * @param name - Space name
153
- * @returns Full space URI
154
- */
155
- export declare function buildSpaceUri(owner: string, name: string): string;
156
- /**
157
- * SpaceService - Global singleton for managing spaces.
158
- *
159
- * @example
160
- * ```typescript
161
- * const spaceService = new SpaceService({
162
- * hosts: ['https://node.tinycloud.xyz'],
163
- * session,
164
- * invoke,
165
- * });
166
- *
167
- * // List all accessible spaces
168
- * const result = await spaceService.list();
169
- * if (result.ok) {
170
- * for (const space of result.data) {
171
- * console.log(`${space.name} (${space.type})`);
172
- * }
173
- * }
174
- *
175
- * // Create a new space
176
- * const createResult = await spaceService.create('photos');
177
- *
178
- * // Get a space object for operations
179
- * const space = spaceService.get('photos');
180
- * await space.kv.put('album/vacation', { photos: [...] });
181
- * ```
182
- */
183
- export declare class SpaceService implements ISpaceService {
184
- private hosts;
185
- private session;
186
- private invoke;
187
- private fetchFn;
188
- private capabilityRegistry?;
189
- private createKVServiceFn?;
190
- private _userDid?;
191
- private sharingService?;
192
- private createDelegationFn?;
193
- /** Cache of created Space objects */
194
- private spaceCache;
195
- /** Cache of space info */
196
- private infoCache;
197
- /** Cache TTL in milliseconds (5 minutes) */
198
- private readonly cacheTTL;
199
- /**
200
- * Create a new SpaceService instance.
201
- *
202
- * @param config - Service configuration
203
- */
204
- constructor(config: SpaceServiceConfig);
205
- /**
206
- * Update the service configuration.
207
- */
208
- updateConfig(config: Partial<SpaceServiceConfig>): void;
209
- /**
210
- * Get the current user's primary space ID.
211
- */
212
- getCurrentSpaceId(): string | undefined;
213
- /**
214
- * Get the primary host URL.
215
- */
216
- private get host();
217
- /**
218
- * Get the current user's PKH DID.
219
- */
220
- private get userDid();
221
- /**
222
- * List all spaces the user has access to.
223
- *
224
- * Combines owned spaces (from the server) with delegated spaces
225
- * (from the capability registry).
226
- */
227
- list(): Promise<Result<SpaceInfo[], ServiceError>>;
228
- /**
229
- * List owned spaces from the server.
230
- */
231
- private listOwnedSpaces;
232
- /**
233
- * Discover delegated spaces from the capability registry.
234
- */
235
- private discoverDelegatedSpaces;
236
- /**
237
- * Extract space name from a full space ID.
238
- */
239
- private extractNameFromId;
240
- /**
241
- * Deduplicate spaces, preferring owned over delegated.
242
- */
243
- private deduplicateSpaces;
244
- /**
245
- * Create a new space.
246
- *
247
- * @param name - The name for the new space
248
- */
249
- create(name: string): Promise<Result<SpaceInfo, ServiceError>>;
250
- /**
251
- * Get a Space object by name or full URI.
252
- *
253
- * @param nameOrUri - Short name or full URI
254
- */
255
- get(nameOrUri: string): ISpace;
256
- /**
257
- * Resolve a name or URI to a full space ID.
258
- */
259
- private resolveSpaceId;
260
- /**
261
- * Check if a space exists and the user has access.
262
- */
263
- exists(nameOrUri: string): Promise<Result<boolean, ServiceError>>;
264
- /**
265
- * Get space info from server or cache.
266
- */
267
- private getSpaceInfo;
268
- /**
269
- * Create a space-scoped KV service.
270
- */
271
- private createSpaceScopedKV;
272
- /**
273
- * Create space-scoped delegation operations.
274
- */
275
- private createSpaceScopedDelegations;
276
- /**
277
- * Create space-scoped sharing operations.
278
- *
279
- * When a SharingService is configured, delegates to client-side v2 sharing.
280
- * V2 sharing links are self-contained with embedded private keys - no server tracking.
281
- */
282
- private createSpaceScopedSharing;
283
- }
284
- /**
285
- * Create a new SpaceService instance.
286
- *
287
- * @param config - Service configuration
288
- * @returns A new SpaceService instance
289
- */
290
- export declare function createSpaceService(config: SpaceServiceConfig): ISpaceService;
291
- //# sourceMappingURL=SpaceService.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SpaceService.d.ts","sourceRoot":"","sources":["../../src/spaces/SpaceService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,MAAM,EACN,YAAY,EACZ,cAAc,EACd,aAAa,EACb,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EACV,SAAS,EAET,UAAU,EACV,sBAAsB,EAGvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AACrF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAEL,KAAK,MAAM,EAIZ,MAAM,SAAS,CAAC;AAejB;;GAEG;AACH,eAAO,MAAM,eAAe;IAC1B,sBAAsB;;IAEtB,2BAA2B;;IAE3B,sBAAsB;;IAEtB,8BAA8B;;IAE9B,gCAAgC;;IAEhC,oBAA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