@xyo-network/xl1-rpc 1.6.4 → 1.6.6
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.
- package/dist/neutral/index.mjs +62 -262
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/node/index-node.mjs +62 -262
- package/dist/node/index-node.mjs.map +1 -1
- package/dist/types/engine/rpcMethodHandlersFromProvider.d.ts.map +1 -1
- package/dist/types/provider/index.d.ts +0 -1
- package/dist/types/provider/index.d.ts.map +1 -1
- package/dist/types/provider/provider/MemoryXyoProvider.d.ts +1 -4
- package/dist/types/provider/provider/MemoryXyoProvider.d.ts.map +1 -1
- package/dist/types/transport/post-message/PostMessageRpcTransport.d.ts.map +1 -1
- package/dist/types/transport/post-message/SessionEnvelope.d.ts +10 -0
- package/dist/types/transport/post-message/SessionEnvelope.d.ts.map +1 -0
- package/dist/types/transport/post-message/helpers.d.ts +1 -8
- package/dist/types/transport/post-message/helpers.d.ts.map +1 -1
- package/dist/types/transport/post-message/index.d.ts +1 -0
- package/dist/types/transport/post-message/index.d.ts.map +1 -1
- package/dist/types/types/XyoProviderRpc.d.ts +1 -2
- package/dist/types/types/XyoProviderRpc.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +0 -1
- package/dist/types/types/index.d.ts.map +1 -1
- package/dist/types/types/schema/AllRpcSchemas.d.ts.map +1 -1
- package/dist/types/types/schema/index.d.ts +0 -1
- package/dist/types/types/schema/index.d.ts.map +1 -1
- package/package.json +21 -21
- package/src/engine/rpcMethodHandlersFromProvider.ts +1 -3
- package/src/provider/index.ts +0 -1
- package/src/provider/provider/MemoryXyoProvider.ts +3 -11
- package/src/provider/runner/NodeXyoRunner.ts +1 -1
- package/src/transport/post-message/PostMessageRpcTransport.ts +3 -2
- package/src/transport/post-message/SessionEnvelope.ts +19 -0
- package/src/transport/post-message/helpers.ts +1 -18
- package/src/transport/post-message/index.ts +1 -0
- package/src/types/XyoProviderRpc.ts +0 -2
- package/src/types/index.ts +0 -1
- package/src/types/schema/AllRpcSchemas.ts +0 -2
- package/src/types/schema/index.ts +0 -1
- package/dist/types/engine/rpcMethodHandlersFromWallet.d.ts +0 -4
- package/dist/types/engine/rpcMethodHandlersFromWallet.d.ts.map +0 -1
- package/dist/types/provider/wallet/JsonRpcXyoWallet.d.ts +0 -17
- package/dist/types/provider/wallet/JsonRpcXyoWallet.d.ts.map +0 -1
- package/dist/types/provider/wallet/MemoryXyoWallet.d.ts +0 -18
- package/dist/types/provider/wallet/MemoryXyoWallet.d.ts.map +0 -1
- package/dist/types/provider/wallet/index.d.ts +0 -3
- package/dist/types/provider/wallet/index.d.ts.map +0 -1
- package/dist/types/types/XyoWalletRpc.d.ts +0 -7
- package/dist/types/types/XyoWalletRpc.d.ts.map +0 -1
- package/dist/types/types/schema/XyoWalletRpcSchemas.d.ts +0 -4
- package/dist/types/types/schema/XyoWalletRpcSchemas.d.ts.map +0 -1
- package/src/engine/rpcMethodHandlersFromWallet.ts +0 -16
- package/src/provider/wallet/JsonRpcXyoWallet.ts +0 -45
- package/src/provider/wallet/MemoryXyoWallet.ts +0 -52
- package/src/provider/wallet/index.ts +0 -2
- package/src/types/XyoWalletRpc.ts +0 -13
- package/src/types/schema/XyoWalletRpcSchemas.ts +0 -91
package/dist/neutral/index.mjs
CHANGED
|
@@ -37,23 +37,9 @@ var rpcMethodHandlersFromViewer = /* @__PURE__ */ __name((viewer) => {
|
|
|
37
37
|
};
|
|
38
38
|
}, "rpcMethodHandlersFromViewer");
|
|
39
39
|
|
|
40
|
-
// src/engine/rpcMethodHandlersFromWallet.ts
|
|
41
|
-
var rpcMethodHandlersFromWallet = /* @__PURE__ */ __name((wallet) => {
|
|
42
|
-
return {
|
|
43
|
-
xyoWallet_accounts: /* @__PURE__ */ __name((params) => wallet.accounts(...params ?? []), "xyoWallet_accounts"),
|
|
44
|
-
xyoWallet_addChain: /* @__PURE__ */ __name((params) => wallet.addChain(...params ?? []), "xyoWallet_addChain"),
|
|
45
|
-
xyoWallet_chain: /* @__PURE__ */ __name((params) => wallet.chain(...params ?? []), "xyoWallet_chain"),
|
|
46
|
-
xyoWallet_chains: /* @__PURE__ */ __name((params) => wallet.chains(...params ?? []), "xyoWallet_chains"),
|
|
47
|
-
xyoWallet_permissions: /* @__PURE__ */ __name((params) => wallet.permissions(...params ?? []), "xyoWallet_permissions"),
|
|
48
|
-
xyoWallet_requestPermissions: /* @__PURE__ */ __name((params) => wallet.requestPermissions(...params ?? []), "xyoWallet_requestPermissions"),
|
|
49
|
-
xyoWallet_revokePermissions: /* @__PURE__ */ __name((params) => wallet.revokePermissions(...params ?? []), "xyoWallet_revokePermissions"),
|
|
50
|
-
xyoWallet_switchChain: /* @__PURE__ */ __name((params) => wallet.switchChain(...params ?? []), "xyoWallet_switchChain")
|
|
51
|
-
};
|
|
52
|
-
}, "rpcMethodHandlersFromWallet");
|
|
53
|
-
|
|
54
40
|
// src/engine/rpcMethodHandlersFromProvider.ts
|
|
55
41
|
var rpcMethodHandlersFromProvider = /* @__PURE__ */ __name((provider) => {
|
|
56
|
-
const { runner, signer, viewer
|
|
42
|
+
const { runner, signer, viewer } = provider;
|
|
57
43
|
let result = {
|
|
58
44
|
xyoProvider_send: /* @__PURE__ */ __name((params) => provider.send(...params ?? []), "xyoProvider_send")
|
|
59
45
|
};
|
|
@@ -69,10 +55,6 @@ var rpcMethodHandlersFromProvider = /* @__PURE__ */ __name((provider) => {
|
|
|
69
55
|
...result,
|
|
70
56
|
...rpcMethodHandlersFromViewer(viewer)
|
|
71
57
|
};
|
|
72
|
-
if (wallet) result = {
|
|
73
|
-
...result,
|
|
74
|
-
...rpcMethodHandlersFromWallet(wallet)
|
|
75
|
-
};
|
|
76
58
|
return result;
|
|
77
59
|
}, "rpcMethodHandlersFromProvider");
|
|
78
60
|
|
|
@@ -186,13 +168,11 @@ var MemoryXyoProvider = class {
|
|
|
186
168
|
_runner;
|
|
187
169
|
_signer;
|
|
188
170
|
_viewer;
|
|
189
|
-
_wallet;
|
|
190
171
|
constructor(params) {
|
|
191
172
|
this._network = params?.network;
|
|
192
173
|
this._runner = params?.runner;
|
|
193
174
|
this._signer = params?.signer;
|
|
194
175
|
this._viewer = params?.viewer;
|
|
195
|
-
this._wallet = params?.wallet;
|
|
196
176
|
}
|
|
197
177
|
get network() {
|
|
198
178
|
return this._network;
|
|
@@ -206,19 +186,15 @@ var MemoryXyoProvider = class {
|
|
|
206
186
|
get viewer() {
|
|
207
187
|
return this._viewer;
|
|
208
188
|
}
|
|
209
|
-
get wallet() {
|
|
210
|
-
return this._wallet;
|
|
211
|
-
}
|
|
212
189
|
async send(elevatedPayloads, additionalPayloads, chain, nbf, exp, from, fees) {
|
|
213
|
-
|
|
214
|
-
if (chainValue === void 0) throw new Error("Failed to determine chain");
|
|
190
|
+
if (chain === void 0) throw new Error("Failed to determine chain");
|
|
215
191
|
const nbfValue = nbf === void 0 ? await this._viewer?.currentBlockNumber() : nbf;
|
|
216
192
|
if (nbfValue === void 0) throw new Error("Failed to determine nbf");
|
|
217
193
|
const expValue = exp === void 0 ? nbfValue + 1e3 : exp;
|
|
218
194
|
const feesValue = fees === void 0 ? defaultTransactionFees : fees;
|
|
219
195
|
const fromValue = from === void 0 ? await this._signer?.address() : from;
|
|
220
196
|
if (fromValue === void 0) throw new Error("Failed to determine from address");
|
|
221
|
-
const signedTransaction = assertEx(await this._signer?.createSignedTransaction(
|
|
197
|
+
const signedTransaction = assertEx(await this._signer?.createSignedTransaction(chain, elevatedPayloads, additionalPayloads, nbfValue, expValue, feesValue, fromValue), () => "Failed to create transaction");
|
|
222
198
|
assertEx(await this.runner?.broadcastTransaction([
|
|
223
199
|
await PayloadBuilder.addStorageMeta(signedTransaction),
|
|
224
200
|
await PayloadBuilder.addStorageMeta(elevatedPayloads)
|
|
@@ -305,7 +281,7 @@ var NodeXyoRunner = class {
|
|
|
305
281
|
getPendingArchivist = /* @__PURE__ */ __name(async () => {
|
|
306
282
|
if (this._pendingArchivist) return this._pendingArchivist;
|
|
307
283
|
this._pendingArchivist = await this.getArchivist(this.pendingArchivistPath);
|
|
308
|
-
return this._pendingArchivist;
|
|
284
|
+
return assertEx2(this._pendingArchivist, () => `Error: Could not resolve pending archivist at ${this.pendingArchivistPath}`);
|
|
309
285
|
}, "getPendingArchivist");
|
|
310
286
|
};
|
|
311
287
|
|
|
@@ -420,96 +396,6 @@ var JsonRpcXyoViewer = class {
|
|
|
420
396
|
}
|
|
421
397
|
};
|
|
422
398
|
|
|
423
|
-
// src/provider/wallet/JsonRpcXyoWallet.ts
|
|
424
|
-
var JsonRpcXyoWallet = class {
|
|
425
|
-
static {
|
|
426
|
-
__name(this, "JsonRpcXyoWallet");
|
|
427
|
-
}
|
|
428
|
-
transport;
|
|
429
|
-
constructor(transport) {
|
|
430
|
-
this.transport = transport;
|
|
431
|
-
}
|
|
432
|
-
async accounts() {
|
|
433
|
-
return await this.transport.sendRequest("xyoWallet_accounts");
|
|
434
|
-
}
|
|
435
|
-
async addChain(chain, name) {
|
|
436
|
-
return await this.transport.sendRequest("xyoWallet_addChain", [
|
|
437
|
-
chain,
|
|
438
|
-
name
|
|
439
|
-
]);
|
|
440
|
-
}
|
|
441
|
-
async chain() {
|
|
442
|
-
return await this.transport.sendRequest("xyoWallet_chain");
|
|
443
|
-
}
|
|
444
|
-
async chains() {
|
|
445
|
-
return await this.transport.sendRequest("xyoWallet_chains");
|
|
446
|
-
}
|
|
447
|
-
async permissions() {
|
|
448
|
-
return await this.transport.sendRequest("xyoWallet_permissions");
|
|
449
|
-
}
|
|
450
|
-
async requestPermissions(permissions) {
|
|
451
|
-
return await this.transport.sendRequest("xyoWallet_requestPermissions", [
|
|
452
|
-
permissions
|
|
453
|
-
]);
|
|
454
|
-
}
|
|
455
|
-
async revokePermissions(permissions) {
|
|
456
|
-
return await this.transport.sendRequest("xyoWallet_revokePermissions", [
|
|
457
|
-
permissions
|
|
458
|
-
]);
|
|
459
|
-
}
|
|
460
|
-
async switchChain(chain) {
|
|
461
|
-
return await this.transport.sendRequest("xyoWallet_switchChain", [
|
|
462
|
-
chain
|
|
463
|
-
]);
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
// src/provider/wallet/MemoryXyoWallet.ts
|
|
468
|
-
import { assertEx as assertEx3 } from "@xylabs/assert";
|
|
469
|
-
import { isDefined } from "@xylabs/typeof";
|
|
470
|
-
var MemoryXyoWallet = class {
|
|
471
|
-
static {
|
|
472
|
-
__name(this, "MemoryXyoWallet");
|
|
473
|
-
}
|
|
474
|
-
_account;
|
|
475
|
-
_chain;
|
|
476
|
-
_chains = {};
|
|
477
|
-
constructor(account) {
|
|
478
|
-
this._account = account;
|
|
479
|
-
}
|
|
480
|
-
accounts() {
|
|
481
|
-
return [
|
|
482
|
-
this._account.address
|
|
483
|
-
];
|
|
484
|
-
}
|
|
485
|
-
addChain(chain, name) {
|
|
486
|
-
this._chains[chain] = name;
|
|
487
|
-
return this.chains();
|
|
488
|
-
}
|
|
489
|
-
chain() {
|
|
490
|
-
return assertEx3(this._chain, () => "Chain not set");
|
|
491
|
-
}
|
|
492
|
-
chains() {
|
|
493
|
-
return this._chains;
|
|
494
|
-
}
|
|
495
|
-
permissions() {
|
|
496
|
-
throw new Error("Method not implemented.");
|
|
497
|
-
}
|
|
498
|
-
requestPermissions(_permissions) {
|
|
499
|
-
throw new Error("Method not implemented.");
|
|
500
|
-
}
|
|
501
|
-
revokePermissions(_permissions) {
|
|
502
|
-
throw new Error("Method not implemented.");
|
|
503
|
-
}
|
|
504
|
-
switchChain(chain) {
|
|
505
|
-
if (isDefined(this._chains[chain])) {
|
|
506
|
-
this._chain = chain;
|
|
507
|
-
} else {
|
|
508
|
-
throw new Error(`Chain ${chain} not found in wallet`);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
};
|
|
512
|
-
|
|
513
399
|
// src/transport/HttpRpcTransport.ts
|
|
514
400
|
import { AxiosJson } from "@xylabs/axios";
|
|
515
401
|
import { isUndefinedOrNull } from "@xylabs/typeof";
|
|
@@ -1026,208 +912,122 @@ var XyoViewerRpcSchemas = {
|
|
|
1026
912
|
}
|
|
1027
913
|
};
|
|
1028
914
|
|
|
1029
|
-
// src/types/schema/XyoWalletRpcSchemas.ts
|
|
1030
|
-
import { z as z18 } from "zod";
|
|
1031
|
-
var XyoWalletRpcSchemas = {
|
|
1032
|
-
xyoWallet_accounts: {
|
|
1033
|
-
params: {
|
|
1034
|
-
to: z18.array(z18.any()).length(0).optional(),
|
|
1035
|
-
from: z18.array(z18.any()).length(0).optional()
|
|
1036
|
-
},
|
|
1037
|
-
result: {
|
|
1038
|
-
to: z18.array(AddressToStringSchema),
|
|
1039
|
-
from: z18.array(AddressFromStringSchema)
|
|
1040
|
-
}
|
|
1041
|
-
},
|
|
1042
|
-
xyoWallet_addChain: {
|
|
1043
|
-
params: {
|
|
1044
|
-
to: z18.array(z18.any()).length(0).optional(),
|
|
1045
|
-
from: z18.array(z18.any()).length(0).optional()
|
|
1046
|
-
},
|
|
1047
|
-
result: {
|
|
1048
|
-
from: z18.any(),
|
|
1049
|
-
to: z18.any()
|
|
1050
|
-
}
|
|
1051
|
-
},
|
|
1052
|
-
xyoWallet_chain: {
|
|
1053
|
-
params: {
|
|
1054
|
-
to: z18.array(z18.any()).length(0).optional(),
|
|
1055
|
-
from: z18.array(z18.any()).length(0).optional()
|
|
1056
|
-
},
|
|
1057
|
-
result: {
|
|
1058
|
-
to: AddressToStringSchema,
|
|
1059
|
-
from: AddressFromStringSchema
|
|
1060
|
-
}
|
|
1061
|
-
},
|
|
1062
|
-
xyoWallet_chains: {
|
|
1063
|
-
params: {
|
|
1064
|
-
to: z18.array(z18.any()).length(0).optional(),
|
|
1065
|
-
from: z18.array(z18.any()).length(0).optional()
|
|
1066
|
-
},
|
|
1067
|
-
result: {
|
|
1068
|
-
from: z18.any(),
|
|
1069
|
-
to: z18.any()
|
|
1070
|
-
}
|
|
1071
|
-
},
|
|
1072
|
-
xyoWallet_permissions: {
|
|
1073
|
-
params: {
|
|
1074
|
-
to: z18.array(z18.any()).length(0).optional(),
|
|
1075
|
-
from: z18.array(z18.any()).length(0).optional()
|
|
1076
|
-
},
|
|
1077
|
-
result: {
|
|
1078
|
-
from: z18.any(),
|
|
1079
|
-
to: z18.any()
|
|
1080
|
-
}
|
|
1081
|
-
},
|
|
1082
|
-
xyoWallet_requestPermissions: {
|
|
1083
|
-
params: {
|
|
1084
|
-
to: z18.array(z18.any()).length(0).optional(),
|
|
1085
|
-
from: z18.array(z18.any()).length(0).optional()
|
|
1086
|
-
},
|
|
1087
|
-
result: {
|
|
1088
|
-
from: z18.any(),
|
|
1089
|
-
to: z18.any()
|
|
1090
|
-
}
|
|
1091
|
-
},
|
|
1092
|
-
xyoWallet_revokePermissions: {
|
|
1093
|
-
params: {
|
|
1094
|
-
to: z18.array(z18.any()).length(0).optional(),
|
|
1095
|
-
from: z18.array(z18.any()).length(0).optional()
|
|
1096
|
-
},
|
|
1097
|
-
result: {
|
|
1098
|
-
from: z18.any(),
|
|
1099
|
-
to: z18.any()
|
|
1100
|
-
}
|
|
1101
|
-
},
|
|
1102
|
-
xyoWallet_switchChain: {
|
|
1103
|
-
params: {
|
|
1104
|
-
to: z18.array(z18.any()).length(0).optional(),
|
|
1105
|
-
from: z18.array(z18.any()).length(0).optional()
|
|
1106
|
-
},
|
|
1107
|
-
result: {
|
|
1108
|
-
from: z18.any(),
|
|
1109
|
-
to: z18.any()
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
};
|
|
1113
|
-
|
|
1114
915
|
// src/types/schema/AllRpcSchemas.ts
|
|
1115
916
|
var AllRpcSchemas = {
|
|
1116
917
|
...XyoProviderRpcSchemas,
|
|
1117
918
|
...XyoRunnerRpcSchemas,
|
|
1118
919
|
...XyoSignerRpcSchemas,
|
|
1119
|
-
...XyoViewerRpcSchemas
|
|
1120
|
-
...XyoWalletRpcSchemas
|
|
920
|
+
...XyoViewerRpcSchemas
|
|
1121
921
|
};
|
|
1122
922
|
|
|
1123
923
|
// src/types/schema/createRequestSchema.ts
|
|
1124
|
-
import { z as
|
|
1125
|
-
var createRequestSchema = /* @__PURE__ */ __name((methodName, paramsSchema =
|
|
1126
|
-
id:
|
|
1127
|
-
|
|
1128
|
-
|
|
924
|
+
import { z as z18 } from "zod";
|
|
925
|
+
var createRequestSchema = /* @__PURE__ */ __name((methodName, paramsSchema = z18.undefined()) => z18.object({
|
|
926
|
+
id: z18.union([
|
|
927
|
+
z18.string(),
|
|
928
|
+
z18.number()
|
|
1129
929
|
]),
|
|
1130
|
-
jsonrpc:
|
|
1131
|
-
method:
|
|
930
|
+
jsonrpc: z18.literal(jsonrpc),
|
|
931
|
+
method: z18.literal(methodName),
|
|
1132
932
|
params: paramsSchema
|
|
1133
933
|
}), "createRequestSchema");
|
|
1134
934
|
|
|
1135
935
|
// src/types/schema/createResponseSchema.ts
|
|
1136
|
-
import { z as
|
|
1137
|
-
var createResponseSchema = /* @__PURE__ */ __name((resultSchema =
|
|
1138
|
-
id:
|
|
1139
|
-
|
|
1140
|
-
|
|
936
|
+
import { z as z19 } from "zod";
|
|
937
|
+
var createResponseSchema = /* @__PURE__ */ __name((resultSchema = z19.undefined()) => z19.object({
|
|
938
|
+
id: z19.union([
|
|
939
|
+
z19.string(),
|
|
940
|
+
z19.number()
|
|
1141
941
|
]),
|
|
1142
|
-
jsonrpc:
|
|
942
|
+
jsonrpc: z19.literal(jsonrpc),
|
|
1143
943
|
result: resultSchema
|
|
1144
944
|
}), "createResponseSchema");
|
|
1145
945
|
|
|
1146
946
|
// src/types/schema/XyoHostRpcSchemas.ts
|
|
1147
|
-
import { z as
|
|
1148
|
-
var ChainConnectionSchema =
|
|
1149
|
-
chainId:
|
|
1150
|
-
|
|
1151
|
-
|
|
947
|
+
import { z as z20 } from "zod";
|
|
948
|
+
var ChainConnectionSchema = z20.object({
|
|
949
|
+
chainId: z20.union([
|
|
950
|
+
z20.string(),
|
|
951
|
+
z20.custom()
|
|
1152
952
|
]).optional(),
|
|
1153
|
-
name:
|
|
1154
|
-
url:
|
|
953
|
+
name: z20.string(),
|
|
954
|
+
url: z20.string()
|
|
1155
955
|
});
|
|
1156
|
-
var CaveatTypesSchema =
|
|
956
|
+
var CaveatTypesSchema = z20.enum([
|
|
1157
957
|
"chain",
|
|
1158
958
|
"expiration",
|
|
1159
959
|
"filteredResponse",
|
|
1160
960
|
"rateLimit"
|
|
1161
961
|
]);
|
|
1162
|
-
var CaveatsSchema =
|
|
962
|
+
var CaveatsSchema = z20.object({
|
|
1163
963
|
type: CaveatTypesSchema,
|
|
1164
|
-
value:
|
|
964
|
+
value: z20.unknown()
|
|
1165
965
|
});
|
|
1166
|
-
var PermissionSchema =
|
|
1167
|
-
capability:
|
|
966
|
+
var PermissionSchema = z20.object({
|
|
967
|
+
capability: z20.string(),
|
|
1168
968
|
caveats: CaveatsSchema.array().optional(),
|
|
1169
|
-
invoker:
|
|
969
|
+
invoker: z20.string()
|
|
1170
970
|
});
|
|
1171
971
|
var InvokerPermissionSchema = PermissionSchema.extend({
|
|
1172
|
-
date:
|
|
972
|
+
date: z20.number().optional()
|
|
1173
973
|
});
|
|
1174
974
|
var XyoHostRpcSchemas = {
|
|
1175
975
|
xyoHost_addChain: {
|
|
1176
976
|
params: {
|
|
1177
|
-
to:
|
|
977
|
+
to: z20.tuple([
|
|
1178
978
|
ChainConnectionSchema
|
|
1179
979
|
]),
|
|
1180
|
-
from:
|
|
980
|
+
from: z20.tuple([
|
|
1181
981
|
ChainConnectionSchema
|
|
1182
982
|
])
|
|
1183
983
|
},
|
|
1184
984
|
result: {
|
|
1185
|
-
to:
|
|
1186
|
-
|
|
985
|
+
to: z20.tuple([
|
|
986
|
+
z20.boolean()
|
|
1187
987
|
]),
|
|
1188
|
-
from:
|
|
1189
|
-
|
|
988
|
+
from: z20.tuple([
|
|
989
|
+
z20.boolean()
|
|
1190
990
|
])
|
|
1191
991
|
}
|
|
1192
992
|
},
|
|
1193
993
|
xyoHost_chains: {
|
|
1194
994
|
params: {
|
|
1195
|
-
to:
|
|
1196
|
-
from:
|
|
995
|
+
to: z20.array(z20.any()).length(0).optional(),
|
|
996
|
+
from: z20.array(z20.any()).length(0).optional()
|
|
1197
997
|
},
|
|
1198
998
|
result: {
|
|
1199
|
-
to:
|
|
1200
|
-
from:
|
|
999
|
+
to: z20.array(ChainConnectionSchema),
|
|
1000
|
+
from: z20.array(ChainConnectionSchema)
|
|
1201
1001
|
}
|
|
1202
1002
|
},
|
|
1203
1003
|
xyoHost_getPermissions: {
|
|
1204
1004
|
params: {
|
|
1205
|
-
to:
|
|
1206
|
-
from:
|
|
1005
|
+
to: z20.array(z20.any()).length(0).optional(),
|
|
1006
|
+
from: z20.array(z20.any()).length(0).optional()
|
|
1207
1007
|
},
|
|
1208
1008
|
result: {
|
|
1209
|
-
to:
|
|
1210
|
-
from:
|
|
1009
|
+
to: z20.array(InvokerPermissionSchema),
|
|
1010
|
+
from: z20.array(InvokerPermissionSchema)
|
|
1211
1011
|
}
|
|
1212
1012
|
},
|
|
1213
1013
|
xyoHost_requestPermissions: {
|
|
1214
1014
|
params: {
|
|
1215
|
-
to:
|
|
1216
|
-
from:
|
|
1015
|
+
to: z20.array(PermissionSchema),
|
|
1016
|
+
from: z20.array(PermissionSchema)
|
|
1217
1017
|
},
|
|
1218
1018
|
result: {
|
|
1219
|
-
to:
|
|
1220
|
-
from:
|
|
1019
|
+
to: z20.boolean(),
|
|
1020
|
+
from: z20.boolean()
|
|
1221
1021
|
}
|
|
1222
1022
|
},
|
|
1223
1023
|
xyoHost_revokePermissions: {
|
|
1224
1024
|
params: {
|
|
1225
|
-
to:
|
|
1226
|
-
from:
|
|
1025
|
+
to: z20.array(PermissionSchema),
|
|
1026
|
+
from: z20.array(PermissionSchema)
|
|
1227
1027
|
},
|
|
1228
1028
|
result: {
|
|
1229
|
-
to:
|
|
1230
|
-
from:
|
|
1029
|
+
to: z20.boolean(),
|
|
1030
|
+
from: z20.boolean()
|
|
1231
1031
|
}
|
|
1232
1032
|
}
|
|
1233
1033
|
};
|
|
@@ -1305,21 +1105,23 @@ var MemoryRpcTransport = class {
|
|
|
1305
1105
|
};
|
|
1306
1106
|
|
|
1307
1107
|
// src/transport/post-message/PostMessageRpcTransport.ts
|
|
1308
|
-
import { isDefined
|
|
1108
|
+
import { isDefined } from "@xylabs/typeof";
|
|
1309
1109
|
import { v4 as v43 } from "uuid";
|
|
1310
1110
|
|
|
1311
1111
|
// src/transport/post-message/helpers.ts
|
|
1312
1112
|
var isRpcError = /* @__PURE__ */ __name((data) => {
|
|
1313
1113
|
return data && typeof data === "object" && "error" in data && data.error;
|
|
1314
1114
|
}, "isRpcError");
|
|
1315
|
-
|
|
1115
|
+
|
|
1116
|
+
// src/transport/post-message/SessionEnvelope.ts
|
|
1117
|
+
var buildSessionMessageRequest = /* @__PURE__ */ __name((data, destination) => {
|
|
1316
1118
|
const request = {
|
|
1317
1119
|
data,
|
|
1318
1120
|
destination,
|
|
1319
1121
|
sessionId: globalThis.xyo.walletExtensionId() ?? ""
|
|
1320
1122
|
};
|
|
1321
1123
|
return request;
|
|
1322
|
-
}, "
|
|
1124
|
+
}, "buildSessionMessageRequest");
|
|
1323
1125
|
|
|
1324
1126
|
// src/transport/post-message/PostMessageRpcTransport.ts
|
|
1325
1127
|
var PostMessageRpcTransport = class {
|
|
@@ -1342,7 +1144,7 @@ var PostMessageRpcTransport = class {
|
|
|
1342
1144
|
id,
|
|
1343
1145
|
method
|
|
1344
1146
|
};
|
|
1345
|
-
body.params =
|
|
1147
|
+
body.params = isDefined(params) && isDefined(schemas[method]) ? schemas[method].params.to.parse(params) : params;
|
|
1346
1148
|
return await new Promise((resolve, reject) => {
|
|
1347
1149
|
const id2 = body.id;
|
|
1348
1150
|
const handler = /* @__PURE__ */ __name((event) => {
|
|
@@ -1356,7 +1158,7 @@ var PostMessageRpcTransport = class {
|
|
|
1356
1158
|
}
|
|
1357
1159
|
}, "handler");
|
|
1358
1160
|
globalThis.addEventListener("message", handler);
|
|
1359
|
-
globalThis.postMessage(
|
|
1161
|
+
globalThis.postMessage(buildSessionMessageRequest(body, this.destination), globalThis.location.origin);
|
|
1360
1162
|
});
|
|
1361
1163
|
}
|
|
1362
1164
|
};
|
|
@@ -1372,13 +1174,11 @@ export {
|
|
|
1372
1174
|
JsonRpcXyoRunner,
|
|
1373
1175
|
JsonRpcXyoSigner,
|
|
1374
1176
|
JsonRpcXyoViewer,
|
|
1375
|
-
JsonRpcXyoWallet,
|
|
1376
1177
|
MemoryRpcTransport,
|
|
1377
1178
|
MemoryXyoNetwork,
|
|
1378
1179
|
MemoryXyoProvider,
|
|
1379
1180
|
MemoryXyoRunner,
|
|
1380
1181
|
MemoryXyoSigner,
|
|
1381
|
-
MemoryXyoWallet,
|
|
1382
1182
|
NodeXyoRunner,
|
|
1383
1183
|
PermissionSchema,
|
|
1384
1184
|
PostMessageRpcTransport,
|
|
@@ -1387,7 +1187,7 @@ export {
|
|
|
1387
1187
|
XyoRunnerRpcSchemas,
|
|
1388
1188
|
XyoSignerRpcSchemas,
|
|
1389
1189
|
XyoViewerRpcSchemas,
|
|
1390
|
-
|
|
1190
|
+
buildSessionMessageRequest,
|
|
1391
1191
|
createRequestSchema,
|
|
1392
1192
|
createResponseSchema,
|
|
1393
1193
|
jsonrpc,
|