@xyo-network/xl1-rpc 1.15.2 → 1.15.3

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 (205) hide show
  1. package/README.md +11897 -1213
  2. package/dist/neutral/engine/index.d.ts +1 -0
  3. package/dist/neutral/engine/index.d.ts.map +1 -1
  4. package/dist/neutral/engine/rpcMethodHandlersFromPermissions.d.ts +4 -0
  5. package/dist/neutral/engine/rpcMethodHandlersFromPermissions.d.ts.map +1 -0
  6. package/dist/neutral/engine/rpcMethodHandlersFromViewer.d.ts.map +1 -1
  7. package/dist/neutral/index.mjs +853 -411
  8. package/dist/neutral/index.mjs.map +1 -1
  9. package/dist/neutral/provider/client/MemoryXyoClient.d.ts +2 -2
  10. package/dist/neutral/provider/client/MemoryXyoClient.d.ts.map +1 -1
  11. package/dist/neutral/provider/client/index.d.ts +0 -1
  12. package/dist/neutral/provider/client/index.d.ts.map +1 -1
  13. package/dist/neutral/provider/index.d.ts +1 -0
  14. package/dist/neutral/provider/index.d.ts.map +1 -1
  15. package/dist/neutral/provider/permissions/MemoryXyoPermissions.d.ts +17 -0
  16. package/dist/neutral/provider/permissions/MemoryXyoPermissions.d.ts.map +1 -0
  17. package/dist/neutral/provider/permissions/RpcXyoPermissions.d.ts +11 -0
  18. package/dist/neutral/provider/permissions/RpcXyoPermissions.d.ts.map +1 -0
  19. package/dist/neutral/provider/permissions/index.d.ts +4 -0
  20. package/dist/neutral/provider/permissions/index.d.ts.map +1 -0
  21. package/dist/neutral/provider/permissions/spec/MemoryXyoPermissions.spec.d.ts +2 -0
  22. package/dist/neutral/provider/permissions/spec/MemoryXyoPermissions.spec.d.ts.map +1 -0
  23. package/dist/neutral/provider/permissions/store/MemoryPermissions.d.ts +16 -0
  24. package/dist/neutral/provider/permissions/store/MemoryPermissions.d.ts.map +1 -0
  25. package/dist/neutral/provider/permissions/store/PermissionsStore.d.ts +12 -0
  26. package/dist/neutral/provider/permissions/store/PermissionsStore.d.ts.map +1 -0
  27. package/dist/neutral/provider/permissions/store/index.d.ts +3 -0
  28. package/dist/neutral/provider/permissions/store/index.d.ts.map +1 -0
  29. package/dist/neutral/provider/signer/JsonRpcXyoSigner.d.ts +2 -2
  30. package/dist/neutral/provider/signer/JsonRpcXyoSigner.d.ts.map +1 -1
  31. package/dist/neutral/provider/signer/MemoryXyoSigner.d.ts +2 -2
  32. package/dist/neutral/provider/signer/MemoryXyoSigner.d.ts.map +1 -1
  33. package/dist/neutral/provider/viewer/JsonRpcXyoViewer.d.ts +26 -9
  34. package/dist/neutral/provider/viewer/JsonRpcXyoViewer.d.ts.map +1 -1
  35. package/dist/neutral/transport/post-message/index.d.ts +0 -1
  36. package/dist/neutral/transport/post-message/index.d.ts.map +1 -1
  37. package/dist/neutral/types/XyoPermissions.d.ts +7 -0
  38. package/dist/neutral/types/XyoPermissions.d.ts.map +1 -0
  39. package/dist/neutral/types/index.d.ts +1 -2
  40. package/dist/neutral/types/index.d.ts.map +1 -1
  41. package/dist/neutral/types/schema/AllRpcSchemas.d.ts +914 -80
  42. package/dist/neutral/types/schema/AllRpcSchemas.d.ts.map +1 -1
  43. package/dist/neutral/types/schema/XyoPermissionsRpcSchemas.d.ts +74 -0
  44. package/dist/neutral/types/schema/XyoPermissionsRpcSchemas.d.ts.map +1 -0
  45. package/dist/neutral/types/schema/XyoProviderRpcSchemas.d.ts +4 -4
  46. package/dist/neutral/types/schema/XyoRunnerRpcSchemas.d.ts +4 -4
  47. package/dist/neutral/types/schema/XyoSignerRpcSchemas.d.ts +18 -18
  48. package/dist/neutral/types/schema/XyoViewerRpcSchemas.d.ts +828 -64
  49. package/dist/neutral/types/schema/XyoViewerRpcSchemas.d.ts.map +1 -1
  50. package/dist/neutral/types/schema/common/BlockBoundWitness.d.ts +4 -4
  51. package/dist/neutral/types/schema/common/Chain.d.ts +2 -2
  52. package/dist/neutral/types/schema/common/Chain.d.ts.map +1 -1
  53. package/dist/neutral/types/schema/common/HydratedBlock.d.ts +5 -5
  54. package/dist/neutral/types/schema/common/HydratedTransaction.d.ts +14 -14
  55. package/dist/neutral/types/schema/common/Permission.d.ts +7 -3
  56. package/dist/neutral/types/schema/common/Permission.d.ts.map +1 -1
  57. package/dist/neutral/types/schema/common/Stake.d.ts +11 -5
  58. package/dist/neutral/types/schema/common/Stake.d.ts.map +1 -1
  59. package/dist/neutral/types/schema/common/StepContext.d.ts +6 -0
  60. package/dist/neutral/types/schema/common/StepContext.d.ts.map +1 -0
  61. package/dist/neutral/types/schema/common/TransactionBoundWitness.d.ts +4 -4
  62. package/dist/neutral/types/schema/common/Transfer.d.ts +33 -0
  63. package/dist/neutral/types/schema/common/Transfer.d.ts.map +1 -0
  64. package/dist/neutral/types/schema/common/index.d.ts +2 -0
  65. package/dist/neutral/types/schema/common/index.d.ts.map +1 -1
  66. package/dist/neutral/types/schema/index.d.ts +1 -1
  67. package/dist/neutral/types/schema/index.d.ts.map +1 -1
  68. package/dist/node/engine/index.d.ts +1 -0
  69. package/dist/node/engine/index.d.ts.map +1 -1
  70. package/dist/node/engine/rpcMethodHandlersFromPermissions.d.ts +4 -0
  71. package/dist/node/engine/rpcMethodHandlersFromPermissions.d.ts.map +1 -0
  72. package/dist/node/engine/rpcMethodHandlersFromViewer.d.ts.map +1 -1
  73. package/dist/node/index-node.mjs +853 -411
  74. package/dist/node/index-node.mjs.map +1 -1
  75. package/dist/node/provider/client/MemoryXyoClient.d.ts +2 -2
  76. package/dist/node/provider/client/MemoryXyoClient.d.ts.map +1 -1
  77. package/dist/node/provider/client/index.d.ts +0 -1
  78. package/dist/node/provider/client/index.d.ts.map +1 -1
  79. package/dist/node/provider/index.d.ts +1 -0
  80. package/dist/node/provider/index.d.ts.map +1 -1
  81. package/dist/node/provider/permissions/MemoryXyoPermissions.d.ts +17 -0
  82. package/dist/node/provider/permissions/MemoryXyoPermissions.d.ts.map +1 -0
  83. package/dist/node/provider/permissions/RpcXyoPermissions.d.ts +11 -0
  84. package/dist/node/provider/permissions/RpcXyoPermissions.d.ts.map +1 -0
  85. package/dist/node/provider/permissions/index.d.ts +4 -0
  86. package/dist/node/provider/permissions/index.d.ts.map +1 -0
  87. package/dist/node/provider/permissions/spec/MemoryXyoPermissions.spec.d.ts +2 -0
  88. package/dist/node/provider/permissions/spec/MemoryXyoPermissions.spec.d.ts.map +1 -0
  89. package/dist/node/provider/permissions/store/MemoryPermissions.d.ts +16 -0
  90. package/dist/node/provider/permissions/store/MemoryPermissions.d.ts.map +1 -0
  91. package/dist/node/provider/permissions/store/PermissionsStore.d.ts +12 -0
  92. package/dist/node/provider/permissions/store/PermissionsStore.d.ts.map +1 -0
  93. package/dist/node/provider/permissions/store/index.d.ts +3 -0
  94. package/dist/node/provider/permissions/store/index.d.ts.map +1 -0
  95. package/dist/node/provider/signer/JsonRpcXyoSigner.d.ts +2 -2
  96. package/dist/node/provider/signer/JsonRpcXyoSigner.d.ts.map +1 -1
  97. package/dist/node/provider/signer/MemoryXyoSigner.d.ts +2 -2
  98. package/dist/node/provider/signer/MemoryXyoSigner.d.ts.map +1 -1
  99. package/dist/node/provider/viewer/JsonRpcXyoViewer.d.ts +26 -9
  100. package/dist/node/provider/viewer/JsonRpcXyoViewer.d.ts.map +1 -1
  101. package/dist/node/transport/post-message/index.d.ts +0 -1
  102. package/dist/node/transport/post-message/index.d.ts.map +1 -1
  103. package/dist/node/types/XyoPermissions.d.ts +7 -0
  104. package/dist/node/types/XyoPermissions.d.ts.map +1 -0
  105. package/dist/node/types/index.d.ts +1 -2
  106. package/dist/node/types/index.d.ts.map +1 -1
  107. package/dist/node/types/schema/AllRpcSchemas.d.ts +914 -80
  108. package/dist/node/types/schema/AllRpcSchemas.d.ts.map +1 -1
  109. package/dist/node/types/schema/XyoPermissionsRpcSchemas.d.ts +74 -0
  110. package/dist/node/types/schema/XyoPermissionsRpcSchemas.d.ts.map +1 -0
  111. package/dist/node/types/schema/XyoProviderRpcSchemas.d.ts +4 -4
  112. package/dist/node/types/schema/XyoRunnerRpcSchemas.d.ts +4 -4
  113. package/dist/node/types/schema/XyoSignerRpcSchemas.d.ts +18 -18
  114. package/dist/node/types/schema/XyoViewerRpcSchemas.d.ts +828 -64
  115. package/dist/node/types/schema/XyoViewerRpcSchemas.d.ts.map +1 -1
  116. package/dist/node/types/schema/common/BlockBoundWitness.d.ts +4 -4
  117. package/dist/node/types/schema/common/Chain.d.ts +2 -2
  118. package/dist/node/types/schema/common/Chain.d.ts.map +1 -1
  119. package/dist/node/types/schema/common/HydratedBlock.d.ts +5 -5
  120. package/dist/node/types/schema/common/HydratedTransaction.d.ts +14 -14
  121. package/dist/node/types/schema/common/Permission.d.ts +7 -3
  122. package/dist/node/types/schema/common/Permission.d.ts.map +1 -1
  123. package/dist/node/types/schema/common/Stake.d.ts +11 -5
  124. package/dist/node/types/schema/common/Stake.d.ts.map +1 -1
  125. package/dist/node/types/schema/common/StepContext.d.ts +6 -0
  126. package/dist/node/types/schema/common/StepContext.d.ts.map +1 -0
  127. package/dist/node/types/schema/common/TransactionBoundWitness.d.ts +4 -4
  128. package/dist/node/types/schema/common/Transfer.d.ts +33 -0
  129. package/dist/node/types/schema/common/Transfer.d.ts.map +1 -0
  130. package/dist/node/types/schema/common/index.d.ts +2 -0
  131. package/dist/node/types/schema/common/index.d.ts.map +1 -1
  132. package/dist/node/types/schema/index.d.ts +1 -1
  133. package/dist/node/types/schema/index.d.ts.map +1 -1
  134. package/package.json +34 -34
  135. package/src/engine/index.ts +1 -0
  136. package/src/engine/rpcMethodHandlersFromPermissions.ts +11 -0
  137. package/src/engine/rpcMethodHandlersFromViewer.ts +19 -1
  138. package/src/provider/client/MemoryXyoClient.ts +2 -1
  139. package/src/provider/client/index.ts +0 -1
  140. package/src/provider/client/spec/MemoryXyoClient.spec.ts +17 -31
  141. package/src/provider/index.ts +1 -0
  142. package/src/provider/permissions/MemoryXyoPermissions.ts +82 -0
  143. package/src/provider/permissions/RpcXyoPermissions.ts +30 -0
  144. package/src/provider/permissions/index.ts +3 -0
  145. package/src/provider/permissions/spec/MemoryXyoPermissions.spec.ts +93 -0
  146. package/src/provider/permissions/store/MemoryPermissions.ts +32 -0
  147. package/src/provider/permissions/store/PermissionsStore.ts +15 -0
  148. package/src/provider/permissions/store/index.ts +2 -0
  149. package/src/provider/signer/JsonRpcXyoSigner.ts +2 -2
  150. package/src/provider/signer/MemoryXyoSigner.ts +2 -2
  151. package/src/provider/signer/spec/RpcEngineXyoSigner.spec.ts +2 -2
  152. package/src/provider/viewer/JsonRpcXyoViewer.ts +105 -30
  153. package/src/transport/post-message/index.ts +0 -1
  154. package/src/types/XyoPermissions.ts +13 -0
  155. package/src/types/index.ts +1 -2
  156. package/src/types/schema/AllRpcSchemas.ts +2 -0
  157. package/src/types/schema/XyoPermissionsRpcSchemas.ts +40 -0
  158. package/src/types/schema/XyoViewerRpcSchemas.ts +261 -15
  159. package/src/types/schema/common/Chain.ts +2 -2
  160. package/src/types/schema/common/Permission.ts +3 -3
  161. package/src/types/schema/common/Stake.ts +3 -3
  162. package/src/types/schema/common/StepContext.ts +6 -0
  163. package/src/types/schema/common/Transfer.ts +14 -0
  164. package/src/types/schema/common/index.ts +2 -0
  165. package/src/types/schema/index.ts +1 -1
  166. package/dist/neutral/provider/client/PermissionsStore/MemoryPermissionsStore.d.ts +0 -11
  167. package/dist/neutral/provider/client/PermissionsStore/MemoryPermissionsStore.d.ts.map +0 -1
  168. package/dist/neutral/provider/client/PermissionsStore/PermissionsStore.d.ts +0 -8
  169. package/dist/neutral/provider/client/PermissionsStore/PermissionsStore.d.ts.map +0 -1
  170. package/dist/neutral/provider/client/PermissionsStore/getPermissionsStoreFromTransport.d.ts +0 -5
  171. package/dist/neutral/provider/client/PermissionsStore/getPermissionsStoreFromTransport.d.ts.map +0 -1
  172. package/dist/neutral/provider/client/PermissionsStore/index.d.ts +0 -4
  173. package/dist/neutral/provider/client/PermissionsStore/index.d.ts.map +0 -1
  174. package/dist/neutral/provider/client/PermissionsStore/spec/MemoryPermissionsStore.spec.d.ts +0 -2
  175. package/dist/neutral/provider/client/PermissionsStore/spec/MemoryPermissionsStore.spec.d.ts.map +0 -1
  176. package/dist/neutral/transport/post-message/LegacyPostMessageRpcTransport.d.ts +0 -15
  177. package/dist/neutral/transport/post-message/LegacyPostMessageRpcTransport.d.ts.map +0 -1
  178. package/dist/neutral/types/XyoGatewayRpc.d.ts +0 -8
  179. package/dist/neutral/types/XyoGatewayRpc.d.ts.map +0 -1
  180. package/dist/neutral/types/schema/XyoGatewayRpcSchemas.d.ts +0 -395
  181. package/dist/neutral/types/schema/XyoGatewayRpcSchemas.d.ts.map +0 -1
  182. package/dist/node/provider/client/PermissionsStore/MemoryPermissionsStore.d.ts +0 -11
  183. package/dist/node/provider/client/PermissionsStore/MemoryPermissionsStore.d.ts.map +0 -1
  184. package/dist/node/provider/client/PermissionsStore/PermissionsStore.d.ts +0 -8
  185. package/dist/node/provider/client/PermissionsStore/PermissionsStore.d.ts.map +0 -1
  186. package/dist/node/provider/client/PermissionsStore/getPermissionsStoreFromTransport.d.ts +0 -5
  187. package/dist/node/provider/client/PermissionsStore/getPermissionsStoreFromTransport.d.ts.map +0 -1
  188. package/dist/node/provider/client/PermissionsStore/index.d.ts +0 -4
  189. package/dist/node/provider/client/PermissionsStore/index.d.ts.map +0 -1
  190. package/dist/node/provider/client/PermissionsStore/spec/MemoryPermissionsStore.spec.d.ts +0 -2
  191. package/dist/node/provider/client/PermissionsStore/spec/MemoryPermissionsStore.spec.d.ts.map +0 -1
  192. package/dist/node/transport/post-message/LegacyPostMessageRpcTransport.d.ts +0 -15
  193. package/dist/node/transport/post-message/LegacyPostMessageRpcTransport.d.ts.map +0 -1
  194. package/dist/node/types/XyoGatewayRpc.d.ts +0 -8
  195. package/dist/node/types/XyoGatewayRpc.d.ts.map +0 -1
  196. package/dist/node/types/schema/XyoGatewayRpcSchemas.d.ts +0 -395
  197. package/dist/node/types/schema/XyoGatewayRpcSchemas.d.ts.map +0 -1
  198. package/src/provider/client/PermissionsStore/MemoryPermissionsStore.ts +0 -33
  199. package/src/provider/client/PermissionsStore/PermissionsStore.ts +0 -8
  200. package/src/provider/client/PermissionsStore/getPermissionsStoreFromTransport.ts +0 -12
  201. package/src/provider/client/PermissionsStore/index.ts +0 -3
  202. package/src/provider/client/PermissionsStore/spec/MemoryPermissionsStore.spec.ts +0 -78
  203. package/src/transport/post-message/LegacyPostMessageRpcTransport.ts +0 -120
  204. package/src/types/XyoGatewayRpc.ts +0 -15
  205. package/src/types/schema/XyoGatewayRpcSchemas.ts +0 -93
@@ -1,395 +0,0 @@
1
- import type { Chain } from '@xyo-network/xl1-protocol';
2
- import * as z from 'zod';
3
- export declare const ChainConnectionZod: z.ZodObject<{
4
- chainId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodCustom<Chain, Chain>]>>;
5
- name: z.ZodString;
6
- url: z.ZodString;
7
- }, z.core.$strip>;
8
- export type ChainConnection = z.infer<typeof ChainConnectionZod>;
9
- export declare const XyoGatewayRpcSchemas: {
10
- xyoGateway_submitTransaction: {
11
- params: {
12
- from: z.ZodArray<z.ZodTuple<[z.ZodObject<{
13
- schema: z.ZodLiteral<"network.xyo.boundwitness">;
14
- addresses: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
15
- readonly __hex: true;
16
- }>, {
17
- readonly __address: true;
18
- }>, string>>>;
19
- payload_hashes: z.ZodArray<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
20
- readonly __hex: true;
21
- }>, {
22
- readonly __hash: true;
23
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
24
- readonly __hex: true;
25
- }>, {
26
- readonly __hash: true;
27
- }>, unknown>>>;
28
- payload_schemas: z.ZodArray<z.ZodString>;
29
- previous_hashes: z.ZodArray<z.ZodNullable<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
30
- readonly __hex: true;
31
- }>, {
32
- readonly __hash: true;
33
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
34
- readonly __hex: true;
35
- }>, {
36
- readonly __hash: true;
37
- }>, unknown>>>>;
38
- $destination: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
39
- readonly __hex: true;
40
- }>, {
41
- readonly __address: true;
42
- }>, string>>>;
43
- $sourceQuery: z.ZodOptional<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
44
- readonly __hex: true;
45
- }>, {
46
- readonly __hash: true;
47
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
48
- readonly __hex: true;
49
- }>, {
50
- readonly __hash: true;
51
- }>, unknown>>>;
52
- $signatures: z.ZodArray<z.ZodUnion<readonly [z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
53
- readonly __hex: true;
54
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
55
- readonly __hex: true;
56
- }>, unknown>>, z.ZodNull]>>;
57
- _hash: z.ZodOptional<z.ZodPipe<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
58
- readonly __hex: true;
59
- }>, {
60
- readonly __hash: true;
61
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
62
- readonly __hex: true;
63
- }>, {
64
- readonly __hash: true;
65
- }>, unknown>>, z.ZodTransform<string, import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
66
- readonly __hex: true;
67
- }>, {
68
- readonly __hash: true;
69
- }>>>>;
70
- _dataHash: z.ZodOptional<z.ZodPipe<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
71
- readonly __hex: true;
72
- }>, {
73
- readonly __hash: true;
74
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
75
- readonly __hex: true;
76
- }>, {
77
- readonly __hash: true;
78
- }>, unknown>>, z.ZodTransform<string, import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
79
- readonly __hex: true;
80
- }>, {
81
- readonly __hash: true;
82
- }>>>>;
83
- _sequence: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
84
- nbf: z.ZodNumber;
85
- exp: z.ZodNumber;
86
- fees: z.ZodObject<{
87
- base: z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
88
- readonly __hex: true;
89
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
90
- readonly __hex: true;
91
- }>, unknown>>;
92
- gasLimit: z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
93
- readonly __hex: true;
94
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
95
- readonly __hex: true;
96
- }>, unknown>>;
97
- gasPrice: z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
98
- readonly __hex: true;
99
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
100
- readonly __hex: true;
101
- }>, unknown>>;
102
- priority: z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
103
- readonly __hex: true;
104
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
105
- readonly __hex: true;
106
- }>, unknown>>;
107
- }, z.core.$strip>;
108
- chain: z.ZodPipe<z.ZodString, z.ZodTransform<Chain, string>>;
109
- from: z.ZodPipe<z.ZodString, z.ZodTransform<Chain, string>>;
110
- script: z.ZodOptional<z.ZodArray<z.ZodString>>;
111
- }, z.core.$strip>, z.ZodArray<z.ZodObject<{
112
- schema: z.ZodString;
113
- }, z.core.$catchall<z.ZodAny>>>], null>>;
114
- to: z.ZodArray<z.ZodTuple<[z.ZodObject<{
115
- schema: z.ZodLiteral<"network.xyo.boundwitness">;
116
- addresses: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
117
- readonly __hex: true;
118
- }>, {
119
- readonly __address: true;
120
- }>, string>>>;
121
- payload_hashes: z.ZodArray<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
122
- readonly __hex: true;
123
- }>, {
124
- readonly __hash: true;
125
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
126
- readonly __hex: true;
127
- }>, {
128
- readonly __hash: true;
129
- }>, unknown>>>;
130
- payload_schemas: z.ZodArray<z.ZodString>;
131
- previous_hashes: z.ZodArray<z.ZodNullable<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
132
- readonly __hex: true;
133
- }>, {
134
- readonly __hash: true;
135
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
136
- readonly __hex: true;
137
- }>, {
138
- readonly __hash: true;
139
- }>, unknown>>>>;
140
- $destination: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
141
- readonly __hex: true;
142
- }>, {
143
- readonly __address: true;
144
- }>, string>>>;
145
- $sourceQuery: z.ZodOptional<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
146
- readonly __hex: true;
147
- }>, {
148
- readonly __hash: true;
149
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
150
- readonly __hex: true;
151
- }>, {
152
- readonly __hash: true;
153
- }>, unknown>>>;
154
- $signatures: z.ZodArray<z.ZodUnion<readonly [z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
155
- readonly __hex: true;
156
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
157
- readonly __hex: true;
158
- }>, unknown>>, z.ZodNull]>>;
159
- _hash: z.ZodOptional<z.ZodPipe<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
160
- readonly __hex: true;
161
- }>, {
162
- readonly __hash: true;
163
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
164
- readonly __hex: true;
165
- }>, {
166
- readonly __hash: true;
167
- }>, unknown>>, z.ZodTransform<string, import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
168
- readonly __hex: true;
169
- }>, {
170
- readonly __hash: true;
171
- }>>>>;
172
- _dataHash: z.ZodOptional<z.ZodPipe<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
173
- readonly __hex: true;
174
- }>, {
175
- readonly __hash: true;
176
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
177
- readonly __hex: true;
178
- }>, {
179
- readonly __hash: true;
180
- }>, unknown>>, z.ZodTransform<string, import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
181
- readonly __hex: true;
182
- }>, {
183
- readonly __hash: true;
184
- }>>>>;
185
- _sequence: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
186
- nbf: z.ZodNumber;
187
- exp: z.ZodNumber;
188
- fees: z.ZodObject<{
189
- base: z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
190
- readonly __hex: true;
191
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
192
- readonly __hex: true;
193
- }>, unknown>>;
194
- gasLimit: z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
195
- readonly __hex: true;
196
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
197
- readonly __hex: true;
198
- }>, unknown>>;
199
- gasPrice: z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
200
- readonly __hex: true;
201
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
202
- readonly __hex: true;
203
- }>, unknown>>;
204
- priority: z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
205
- readonly __hex: true;
206
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
207
- readonly __hex: true;
208
- }>, unknown>>;
209
- }, z.core.$strip>;
210
- chain: z.ZodPipe<z.ZodString, z.ZodTransform<Chain, string>>;
211
- from: z.ZodPipe<z.ZodString, z.ZodTransform<Chain, string>>;
212
- script: z.ZodOptional<z.ZodArray<z.ZodString>>;
213
- }, z.core.$strip>, z.ZodArray<z.ZodObject<{
214
- schema: z.ZodString;
215
- }, z.core.$catchall<z.ZodAny>>>], null>>;
216
- };
217
- result: {
218
- from: z.ZodObject<{
219
- schema: z.ZodLiteral<"network.xyo.boundwitness">;
220
- addresses: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
221
- readonly __hex: true;
222
- }>, {
223
- readonly __address: true;
224
- }>, string>>>;
225
- payload_hashes: z.ZodArray<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
226
- readonly __hex: true;
227
- }>, {
228
- readonly __hash: true;
229
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
230
- readonly __hex: true;
231
- }>, {
232
- readonly __hash: true;
233
- }>, unknown>>>;
234
- payload_schemas: z.ZodArray<z.ZodString>;
235
- previous_hashes: z.ZodArray<z.ZodNullable<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
236
- readonly __hex: true;
237
- }>, {
238
- readonly __hash: true;
239
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
240
- readonly __hex: true;
241
- }>, {
242
- readonly __hash: true;
243
- }>, unknown>>>>;
244
- $destination: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
245
- readonly __hex: true;
246
- }>, {
247
- readonly __address: true;
248
- }>, string>>>;
249
- $sourceQuery: z.ZodOptional<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
250
- readonly __hex: true;
251
- }>, {
252
- readonly __hash: true;
253
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
254
- readonly __hex: true;
255
- }>, {
256
- readonly __hash: true;
257
- }>, unknown>>>;
258
- $signatures: z.ZodArray<z.ZodUnion<readonly [z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
259
- readonly __hex: true;
260
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
261
- readonly __hex: true;
262
- }>, unknown>>, z.ZodNull]>>;
263
- _hash: z.ZodOptional<z.ZodPipe<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
264
- readonly __hex: true;
265
- }>, {
266
- readonly __hash: true;
267
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
268
- readonly __hex: true;
269
- }>, {
270
- readonly __hash: true;
271
- }>, unknown>>, z.ZodTransform<string, import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
272
- readonly __hex: true;
273
- }>, {
274
- readonly __hash: true;
275
- }>>>>;
276
- _dataHash: z.ZodOptional<z.ZodPipe<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
277
- readonly __hex: true;
278
- }>, {
279
- readonly __hash: true;
280
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
281
- readonly __hex: true;
282
- }>, {
283
- readonly __hash: true;
284
- }>, unknown>>, z.ZodTransform<string, import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
285
- readonly __hex: true;
286
- }>, {
287
- readonly __hash: true;
288
- }>>>>;
289
- _sequence: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
290
- block: z.ZodNumber;
291
- chain: z.ZodPipe<z.ZodString, z.ZodTransform<Chain, string>>;
292
- previous: z.ZodNullable<z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
293
- readonly __hex: true;
294
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
295
- readonly __hex: true;
296
- }>, unknown>>>;
297
- protocol: z.ZodOptional<z.ZodNumber>;
298
- step_hashes: z.ZodOptional<z.ZodArray<z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
299
- readonly __hex: true;
300
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
301
- readonly __hex: true;
302
- }>, unknown>>>>;
303
- $epoch: z.ZodNumber;
304
- }, z.core.$strip>;
305
- to: z.ZodObject<{
306
- schema: z.ZodLiteral<"network.xyo.boundwitness">;
307
- addresses: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
308
- readonly __hex: true;
309
- }>, {
310
- readonly __address: true;
311
- }>, string>>>;
312
- payload_hashes: z.ZodArray<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
313
- readonly __hex: true;
314
- }>, {
315
- readonly __hash: true;
316
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
317
- readonly __hex: true;
318
- }>, {
319
- readonly __hash: true;
320
- }>, unknown>>>;
321
- payload_schemas: z.ZodArray<z.ZodString>;
322
- previous_hashes: z.ZodArray<z.ZodNullable<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
323
- readonly __hex: true;
324
- }>, {
325
- readonly __hash: true;
326
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
327
- readonly __hex: true;
328
- }>, {
329
- readonly __hash: true;
330
- }>, unknown>>>>;
331
- $destination: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
332
- readonly __hex: true;
333
- }>, {
334
- readonly __address: true;
335
- }>, string>>>;
336
- $sourceQuery: z.ZodOptional<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
337
- readonly __hex: true;
338
- }>, {
339
- readonly __hash: true;
340
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
341
- readonly __hex: true;
342
- }>, {
343
- readonly __hash: true;
344
- }>, unknown>>>;
345
- $signatures: z.ZodArray<z.ZodUnion<readonly [z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
346
- readonly __hex: true;
347
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
348
- readonly __hex: true;
349
- }>, unknown>>, z.ZodNull]>>;
350
- _hash: z.ZodOptional<z.ZodPipe<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
351
- readonly __hex: true;
352
- }>, {
353
- readonly __hash: true;
354
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
355
- readonly __hex: true;
356
- }>, {
357
- readonly __hash: true;
358
- }>, unknown>>, z.ZodTransform<string, import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
359
- readonly __hex: true;
360
- }>, {
361
- readonly __hash: true;
362
- }>>>>;
363
- _dataHash: z.ZodOptional<z.ZodPipe<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
364
- readonly __hex: true;
365
- }>, {
366
- readonly __hash: true;
367
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
368
- readonly __hex: true;
369
- }>, {
370
- readonly __hash: true;
371
- }>, unknown>>, z.ZodTransform<string, import("@xylabs/typeof").Brand<import("@xylabs/typeof").Brand<Lowercase<string>, {
372
- readonly __hex: true;
373
- }>, {
374
- readonly __hash: true;
375
- }>>>>;
376
- _sequence: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodString]>>;
377
- block: z.ZodNumber;
378
- chain: z.ZodPipe<z.ZodString, z.ZodTransform<Chain, string>>;
379
- previous: z.ZodNullable<z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
380
- readonly __hex: true;
381
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
382
- readonly __hex: true;
383
- }>, unknown>>>;
384
- protocol: z.ZodOptional<z.ZodNumber>;
385
- step_hashes: z.ZodOptional<z.ZodArray<z.ZodType<import("@xylabs/typeof").Brand<Lowercase<string>, {
386
- readonly __hex: true;
387
- }>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<Lowercase<string>, {
388
- readonly __hex: true;
389
- }>, unknown>>>>;
390
- $epoch: z.ZodNumber;
391
- }, z.core.$strip>;
392
- };
393
- };
394
- };
395
- //# sourceMappingURL=XyoGatewayRpcSchemas.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"XyoGatewayRpcSchemas.d.ts","sourceRoot":"","sources":["../../../../src/types/schema/XyoGatewayRpcSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAMxB,eAAO,MAAM,kBAAkB;;;;iBAI7B,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEhE,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6EgB,CAAA"}
@@ -1,33 +0,0 @@
1
- import type { Promisable } from '@xylabs/promise'
2
- import type { InvokerPermission, Permission } from '@xyo-network/xl1-protocol'
3
-
4
- import type { PermissionsStore } from './PermissionsStore.ts'
5
-
6
- export class MemoryPermissionsStore implements PermissionsStore {
7
- private readonly _store: Map<string, InvokerPermission> = new Map()
8
-
9
- getPermissions(): Promisable<InvokerPermission[]> {
10
- return [...this._store.values()]
11
- }
12
-
13
- requestPermissions(permissions: Permission[]): Promisable<boolean> {
14
- const now = Date.now()
15
- for (const perm of permissions) {
16
- const key = this.getKey(perm)
17
- this._store.set(key, { ...perm, date: now })
18
- }
19
- return true
20
- }
21
-
22
- revokePermissions(permissions: Permission[]): Promisable<boolean> {
23
- for (const perm of permissions) {
24
- const key = this.getKey(perm)
25
- this._store.delete(key)
26
- }
27
- return true
28
- }
29
-
30
- private getKey(permission: Permission): string {
31
- return `${permission.invoker}::${permission.capability}`
32
- }
33
- }
@@ -1,8 +0,0 @@
1
- import type { Promisable } from '@xylabs/promise'
2
- import type { InvokerPermission, Permission } from '@xyo-network/xl1-protocol'
3
-
4
- export interface PermissionsStore {
5
- getPermissions(): Promisable<InvokerPermission[]>
6
- requestPermissions(permissions: Permission[]): Promisable<boolean>
7
- revokePermissions(permissions: Permission[]): Promisable<boolean>
8
- }
@@ -1,12 +0,0 @@
1
- import { type RpcTransport } from '../../../transport/index.ts'
2
- import type { XyoGatewayRpcSchemas } from '../../../types/index.ts'
3
- import type { PermissionsStore } from './PermissionsStore.ts'
4
-
5
- export const getPermissionsStoreFromTransport = (_transport: RpcTransport<typeof XyoGatewayRpcSchemas>): PermissionsStore => {
6
- throw new Error('Not implemented')
7
- // return {
8
- // getPermissions: () => transport.sendRequest('xyoGateway_getPermissions'),
9
- // requestPermissions: (permissions: Permission[]) => transport.sendRequest('xyoGateway_requestPermissions', permissions),
10
- // revokePermissions: (permissions: Permission[]) => transport.sendRequest('xyoGateway_revokePermissions', permissions),
11
- // }
12
- }
@@ -1,3 +0,0 @@
1
- export * from './getPermissionsStoreFromTransport.ts'
2
- export * from './MemoryPermissionsStore.ts'
3
- export * from './PermissionsStore.ts'
@@ -1,78 +0,0 @@
1
- import type { Permission } from '@xyo-network/xl1-protocol'
2
- import {
3
- beforeEach, describe, expect, it,
4
- } from 'vitest'
5
-
6
- import { MemoryPermissionsStore } from '../MemoryPermissionsStore.ts'
7
-
8
- describe('MemoryPermissionsStore', () => {
9
- const invoker = 'https://example.com'
10
- const capability = 'xyoViewer_chainId'
11
- let store: MemoryPermissionsStore
12
- const basePermission: Permission = { capability, invoker }
13
-
14
- beforeEach(() => {
15
- store = new MemoryPermissionsStore()
16
- })
17
-
18
- it('returns an empty list initially', async () => {
19
- const permissions = await store.getPermissions()
20
- expect(permissions).toEqual([])
21
- })
22
-
23
- it('adds and retrieves a permission', async () => {
24
- const result = await store.requestPermissions([basePermission])
25
- expect(result).toBe(true)
26
-
27
- const permissions = await store.getPermissions()
28
- expect(permissions.length).toBe(1)
29
- expect(permissions[0].capability).toBe(basePermission.capability)
30
- expect(permissions[0].invoker).toBe(basePermission.invoker)
31
- expect(typeof permissions[0].date).toBe('number')
32
- })
33
-
34
- it('replaces an existing permission with the same key', async () => {
35
- const original = { ...basePermission }
36
- const updated = { ...basePermission }
37
-
38
- await store.requestPermissions([original])
39
- const originalDate = (await store.getPermissions())[0].date
40
-
41
- await new Promise(r => setTimeout(r, 5)) // ensure timestamp difference
42
- await store.requestPermissions([updated])
43
- const updatedDate = (await store.getPermissions())[0].date
44
-
45
- expect(updatedDate).toBeGreaterThan(originalDate!)
46
- })
47
-
48
- it('revokes a previously granted permission', async () => {
49
- await store.requestPermissions([basePermission])
50
- expect((await store.getPermissions()).length).toBe(1)
51
-
52
- const result = await store.revokePermissions([basePermission])
53
- expect(result).toBe(true)
54
-
55
- const permissions = await store.getPermissions()
56
- expect(permissions).toEqual([])
57
- })
58
-
59
- it('revoking a non-existent permission does nothing and returns true', async () => {
60
- const result = await store.revokePermissions([basePermission])
61
- expect(result).toBe(true)
62
- expect(await store.getPermissions()).toEqual([])
63
- })
64
-
65
- it('can handle multiple permissions from different invokers', async () => {
66
- const perms: Permission[] = [
67
- { invoker: 'https://a.com', capability: 'xyo_1' },
68
- { invoker: 'https://b.com', capability: 'xyo_2' },
69
- { invoker: 'https://a.com', capability: 'xyo_3' },
70
- ]
71
-
72
- await store.requestPermissions(perms)
73
- const results = await store.getPermissions()
74
-
75
- expect(results.length).toBe(3)
76
- expect(results.map(p => p.capability).toSorted((a, b) => a.localeCompare(b))).toEqual(['xyo_1', 'xyo_2', 'xyo_3'])
77
- })
78
- })
@@ -1,120 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import type { JsonRpcRequest } from '@metamask/utils'
3
- import {
4
- isJsonRpcError,
5
- isJsonRpcSuccess,
6
- } from '@metamask/utils'
7
- import { isDefined } from '@xylabs/typeof'
8
- import { v4 } from 'uuid'
9
- import type * as z from 'zod'
10
-
11
- import type { RpcSchemaMap, XyoGatewayRpcMethodName } from '../../types/index.ts'
12
- import { jsonrpc, XyoGatewayRpcSchemas } from '../../types/index.ts'
13
- import type { RpcTransport } from '../RpcTransport.ts'
14
- // eslint-disable-next-line sonarjs/deprecation
15
- import { isRpcError } from './helpers.ts'
16
- import { resolvedEvent } from './resolveData.ts'
17
-
18
- const isValidBaseRpcEvent = (data: any) => {
19
- return !!(data && typeof data === 'object'
20
- && 'jsonrpc' in data && data.jsonrpc === '2.0'
21
- && 'method' in data && typeof data.method === 'string'
22
- && 'id' in data && typeof data.id === 'string')
23
- }
24
-
25
- const isRpcResponse = (data: any, targetId: string) => {
26
- return isValidBaseRpcEvent(data) && (isDefined(targetId) ? data.id === targetId : true) && 'result' in data && Array.isArray(data.result)
27
- }
28
-
29
- /** @deprecated - now part of a client gateway */
30
- export class LegacyPostMessageRpcTransport implements RpcTransport<RpcSchemaMap<XyoGatewayRpcMethodName>> {
31
- protected readonly destination?: string
32
- protected readonly schemas: RpcSchemaMap<XyoGatewayRpcMethodName>
33
- protected readonly sessionId?: string
34
-
35
- constructor(defaultDestination?: string, sessionId?: string) {
36
- this.schemas = XyoGatewayRpcSchemas
37
- this.destination = defaultDestination
38
- this.sessionId = sessionId
39
- }
40
-
41
- async sendRequest<
42
- TMethod extends keyof RpcSchemaMap<XyoGatewayRpcMethodName>,
43
- >(
44
- method: TMethod,
45
- params?: z.input<RpcSchemaMap<XyoGatewayRpcMethodName>[TMethod]['params']['to']>,
46
- ): Promise<z.output<RpcSchemaMap<XyoGatewayRpcMethodName>[TMethod]['result']['from']>> {
47
- const id = v4()
48
- return await this.callRpc(this.schemas, method, id, params)
49
- }
50
-
51
- private async callRpc<
52
- TSchemas extends RpcSchemaMap,
53
- TMethod extends keyof TSchemas,
54
- >(
55
- schemas: TSchemas,
56
- method: TMethod,
57
- id: string,
58
- params?: z.input<TSchemas[TMethod]['params']['to']>,
59
- ): Promise<z.output<TSchemas[TMethod]['result']['from']>> {
60
- const body: JsonRpcRequest = {
61
- jsonrpc,
62
- id,
63
- method: method as string,
64
- }
65
-
66
- body.params = ((isDefined(params) && isDefined(schemas[method])) ? schemas[method].params.to.parse(params) : params) as JsonRpcRequest
67
-
68
- return await new Promise((resolve, reject) => {
69
- const id = body.id
70
-
71
- const handler = (event: MessageEvent) => {
72
- if (event.origin !== globalThis.window.origin) return
73
- if (!isRpcResponse(event.data, id as string)) return
74
- const data = resolvedEvent(event, id as string)
75
- if (data === false) return
76
-
77
- globalThis.removeEventListener('message', handler)
78
-
79
- if (data.legacyEventData) {
80
- // Handle legacy event data
81
- // eslint-disable-next-line sonarjs/deprecation
82
- if (data.legacyEventData.result.some(isRpcError)) {
83
- reject(data.legacyEventData.result[0])
84
- } else {
85
- resolve(data.legacyEventData.result[0])
86
- }
87
- return
88
- }
89
-
90
- if (data.eventData) {
91
- // Handle new event data
92
- if (isJsonRpcError(data.eventData)) {
93
- reject(data.eventData)
94
- return
95
- }
96
- if (isJsonRpcSuccess(data.eventData)) {
97
- resolve(data.eventData as z.infer<TSchemas[TMethod]['result']['from']>)
98
- return
99
- }
100
- reject(new Error('Unexpected response format'))
101
- }
102
- }
103
-
104
- globalThis.addEventListener('message', handler)
105
-
106
- globalThis.postMessage(
107
- {
108
- data: body,
109
- destination: this.destination,
110
- sessionId: this.sessionId,
111
- },
112
- globalThis.location.origin,
113
- )
114
- })
115
- }
116
- }
117
-
118
- /** @deprecated - use LegacyPostMessageRpcTransport but rely on wallet release > 1.17.1 to handle the postMessage flow */
119
- // eslint-disable-next-line sonarjs/deprecation
120
- export const PostMessageRpcTransport = LegacyPostMessageRpcTransport