@mysten/zksend 0.12.25 → 0.12.27

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 (44) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/wallet/channel/index.js +2 -2
  3. package/dist/cjs/wallet/channel/index.js.map +2 -2
  4. package/dist/esm/wallet/channel/index.js +2 -2
  5. package/dist/esm/wallet/channel/index.js.map +2 -2
  6. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  7. package/dist/tsconfig.tsbuildinfo +1 -1
  8. package/package.json +5 -3
  9. package/dist/cjs/experimental/index.d.ts +0 -2
  10. package/dist/cjs/experimental/index.js +0 -30
  11. package/dist/cjs/experimental/index.js.map +0 -7
  12. package/dist/cjs/experimental/utils/withResolvers.d.ts +0 -6
  13. package/dist/cjs/experimental/utils/withResolvers.js +0 -33
  14. package/dist/cjs/experimental/utils/withResolvers.js.map +0 -7
  15. package/dist/cjs/experimental/wallet/channel/events.d.ts +0 -144
  16. package/dist/cjs/experimental/wallet/channel/events.js +0 -108
  17. package/dist/cjs/experimental/wallet/channel/events.js.map +0 -7
  18. package/dist/cjs/experimental/wallet/channel/index.d.ts +0 -56
  19. package/dist/cjs/experimental/wallet/channel/index.js +0 -198
  20. package/dist/cjs/experimental/wallet/channel/index.js.map +0 -7
  21. package/dist/cjs/experimental/wallet/index.d.ts +0 -36
  22. package/dist/cjs/experimental/wallet/index.js +0 -344
  23. package/dist/cjs/experimental/wallet/index.js.map +0 -7
  24. package/dist/cjs/utils/withResolvers.d.ts +0 -6
  25. package/dist/cjs/utils/withResolvers.js +0 -33
  26. package/dist/cjs/utils/withResolvers.js.map +0 -7
  27. package/dist/esm/experimental/index.d.ts +0 -2
  28. package/dist/esm/experimental/index.js +0 -10
  29. package/dist/esm/experimental/index.js.map +0 -7
  30. package/dist/esm/experimental/utils/withResolvers.d.ts +0 -6
  31. package/dist/esm/experimental/utils/withResolvers.js +0 -13
  32. package/dist/esm/experimental/utils/withResolvers.js.map +0 -7
  33. package/dist/esm/experimental/wallet/channel/events.d.ts +0 -144
  34. package/dist/esm/experimental/wallet/channel/events.js +0 -100
  35. package/dist/esm/experimental/wallet/channel/events.js.map +0 -7
  36. package/dist/esm/experimental/wallet/channel/index.d.ts +0 -56
  37. package/dist/esm/experimental/wallet/channel/index.js +0 -178
  38. package/dist/esm/experimental/wallet/channel/index.js.map +0 -7
  39. package/dist/esm/experimental/wallet/index.d.ts +0 -36
  40. package/dist/esm/experimental/wallet/index.js +0 -319
  41. package/dist/esm/experimental/wallet/index.js.map +0 -7
  42. package/dist/esm/utils/withResolvers.d.ts +0 -6
  43. package/dist/esm/utils/withResolvers.js +0 -13
  44. package/dist/esm/utils/withResolvers.js.map +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten/zksend",
3
- "version": "0.12.25",
3
+ "version": "0.12.27",
4
4
  "description": "TODO: Write Description",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Mysten Labs <build@mystenlabs.com>",
@@ -42,8 +42,10 @@
42
42
  "mitt": "^3.0.1",
43
43
  "nanostores": "^0.10.3",
44
44
  "valibot": "^0.36.0",
45
- "@mysten/sui": "1.27.1",
46
- "@mysten/wallet-standard": "0.14.4"
45
+ "@mysten/sui": "1.28.1",
46
+ "@mysten/utils": "0.0.0",
47
+ "@mysten/wallet-standard": "0.14.6",
48
+ "@mysten/window-wallet-core": "0.0.2"
47
49
  },
48
50
  "scripts": {
49
51
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
@@ -1,2 +0,0 @@
1
- export { registerStashedWallet, StashedWallet, STASHED_WALLET_NAME } from './wallet/index.js';
2
- export { StashedHost, StashedRequest } from './wallet/channel/index.js';
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var experimental_exports = {};
20
- __export(experimental_exports, {
21
- STASHED_WALLET_NAME: () => import_wallet.STASHED_WALLET_NAME,
22
- StashedHost: () => import_channel.StashedHost,
23
- StashedRequest: () => import_channel.StashedRequest,
24
- StashedWallet: () => import_wallet.StashedWallet,
25
- registerStashedWallet: () => import_wallet.registerStashedWallet
26
- });
27
- module.exports = __toCommonJS(experimental_exports);
28
- var import_wallet = require("./wallet/index.js");
29
- var import_channel = require("./wallet/channel/index.js");
30
- //# sourceMappingURL=index.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/experimental/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { registerStashedWallet, StashedWallet, STASHED_WALLET_NAME } from './wallet/index.js';\nexport { StashedHost, StashedRequest } from './wallet/channel/index.js';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAA0E;AAC1E,qBAA4C;",
6
- "names": []
7
- }
@@ -1,6 +0,0 @@
1
- export interface Resolvers<T = any> {
2
- promise: Promise<T>;
3
- reject: (error: Error) => void;
4
- resolve: (value: T) => void;
5
- }
6
- export declare function withResolvers<T = any>(): Resolvers<T>;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var withResolvers_exports = {};
20
- __export(withResolvers_exports, {
21
- withResolvers: () => withResolvers
22
- });
23
- module.exports = __toCommonJS(withResolvers_exports);
24
- function withResolvers() {
25
- let resolve;
26
- let reject;
27
- const promise = new Promise((res, rej) => {
28
- resolve = res;
29
- reject = rej;
30
- });
31
- return { promise, reject, resolve };
32
- }
33
- //# sourceMappingURL=withResolvers.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/experimental/utils/withResolvers.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport interface Resolvers<T = any> {\n\tpromise: Promise<T>;\n\treject: (error: Error) => void;\n\tresolve: (value: T) => void;\n}\n\nexport function withResolvers<T = any>(): Resolvers<T> {\n\tlet resolve: (value: T) => void;\n\tlet reject: (error: Error) => void;\n\n\tconst promise = new Promise<T>((res, rej) => {\n\t\tresolve = res;\n\t\treject = rej;\n\t});\n\n\treturn { promise, reject: reject!, resolve: resolve! };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASO,SAAS,gBAAuC;AACtD,MAAI;AACJ,MAAI;AAEJ,QAAM,UAAU,IAAI,QAAW,CAAC,KAAK,QAAQ;AAC5C,cAAU;AACV,aAAS;AAAA,EACV,CAAC;AAED,SAAO,EAAE,SAAS,QAAiB,QAAkB;AACtD;",
6
- "names": []
7
- }
@@ -1,144 +0,0 @@
1
- import type { InferOutput } from 'valibot';
2
- export declare const StashedRequestData: import("valibot").VariantSchema<"type", [import("valibot").ObjectSchema<{
3
- readonly type: import("valibot").LiteralSchema<"connect", undefined>;
4
- }, undefined>, import("valibot").ObjectSchema<{
5
- readonly type: import("valibot").LiteralSchema<"sign-transaction", undefined>;
6
- readonly transaction: import("valibot").StringSchema<"`transaction` is required">;
7
- readonly address: import("valibot").StringSchema<"`address` is required">;
8
- readonly chain: import("valibot").StringSchema<"`chain` is required">;
9
- readonly session: import("valibot").StringSchema<"`session` is required">;
10
- }, undefined>, import("valibot").ObjectSchema<{
11
- readonly type: import("valibot").LiteralSchema<"sign-and-execute-transaction", undefined>;
12
- readonly transaction: import("valibot").StringSchema<"`transaction` is required">;
13
- readonly address: import("valibot").StringSchema<"`address` is required">;
14
- readonly chain: import("valibot").StringSchema<"`chain` is required">;
15
- readonly session: import("valibot").StringSchema<"`session` is required">;
16
- }, undefined>, import("valibot").ObjectSchema<{
17
- readonly type: import("valibot").LiteralSchema<"sign-personal-message", undefined>;
18
- readonly chain: import("valibot").OptionalSchema<import("valibot").StringSchema<"`chain` is required">, never>;
19
- readonly message: import("valibot").StringSchema<"`message` is required">;
20
- readonly address: import("valibot").StringSchema<"`address` is required">;
21
- readonly session: import("valibot").StringSchema<"`session` is required">;
22
- }, undefined>], undefined>;
23
- export type StashedRequestData = InferOutput<typeof StashedRequestData>;
24
- export declare const StashedRequest: import("valibot").ObjectSchema<{
25
- readonly version: import("valibot").LiteralSchema<"v1", undefined>;
26
- readonly requestId: import("valibot").SchemaWithPipe<[import("valibot").StringSchema<"`requestId` is required">, import("valibot").UuidAction<string, undefined>]>;
27
- readonly appUrl: import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").UrlAction<string, "`appUrl` must be a valid URL">]>;
28
- readonly appName: import("valibot").StringSchema<"`appName` is required">;
29
- readonly payload: import("valibot").VariantSchema<"type", [import("valibot").ObjectSchema<{
30
- readonly type: import("valibot").LiteralSchema<"connect", undefined>;
31
- }, undefined>, import("valibot").ObjectSchema<{
32
- readonly type: import("valibot").LiteralSchema<"sign-transaction", undefined>;
33
- readonly transaction: import("valibot").StringSchema<"`transaction` is required">;
34
- readonly address: import("valibot").StringSchema<"`address` is required">;
35
- readonly chain: import("valibot").StringSchema<"`chain` is required">;
36
- readonly session: import("valibot").StringSchema<"`session` is required">;
37
- }, undefined>, import("valibot").ObjectSchema<{
38
- readonly type: import("valibot").LiteralSchema<"sign-and-execute-transaction", undefined>;
39
- readonly transaction: import("valibot").StringSchema<"`transaction` is required">;
40
- readonly address: import("valibot").StringSchema<"`address` is required">;
41
- readonly chain: import("valibot").StringSchema<"`chain` is required">;
42
- readonly session: import("valibot").StringSchema<"`session` is required">;
43
- }, undefined>, import("valibot").ObjectSchema<{
44
- readonly type: import("valibot").LiteralSchema<"sign-personal-message", undefined>;
45
- readonly chain: import("valibot").OptionalSchema<import("valibot").StringSchema<"`chain` is required">, never>;
46
- readonly message: import("valibot").StringSchema<"`message` is required">;
47
- readonly address: import("valibot").StringSchema<"`address` is required">;
48
- readonly session: import("valibot").StringSchema<"`session` is required">;
49
- }, undefined>], undefined>;
50
- readonly metadata: import("valibot").OptionalSchema<import("valibot").RecordSchema<import("valibot").StringSchema<undefined>, import("valibot").AnySchema, undefined>, never>;
51
- }, undefined>;
52
- export type StashedRequest = InferOutput<typeof StashedRequest>;
53
- export declare const StashedResponseData: import("valibot").VariantSchema<"type", [import("valibot").ObjectSchema<{
54
- readonly type: import("valibot").LiteralSchema<"connect", undefined>;
55
- readonly accounts: import("valibot").ArraySchema<import("valibot").ObjectSchema<{
56
- readonly address: import("valibot").StringSchema<"`address` is required">;
57
- readonly publicKey: import("valibot").OptionalSchema<import("valibot").StringSchema<"`publicKey` must be a string">, never>;
58
- }, undefined>, undefined>;
59
- readonly session: import("valibot").StringSchema<"`session` is required">;
60
- }, undefined>, import("valibot").ObjectSchema<{
61
- readonly type: import("valibot").LiteralSchema<"sign-transaction", undefined>;
62
- readonly bytes: import("valibot").StringSchema<undefined>;
63
- readonly signature: import("valibot").StringSchema<undefined>;
64
- }, undefined>, import("valibot").ObjectSchema<{
65
- readonly type: import("valibot").LiteralSchema<"sign-and-execute-transaction", undefined>;
66
- readonly bytes: import("valibot").StringSchema<undefined>;
67
- readonly signature: import("valibot").StringSchema<undefined>;
68
- readonly digest: import("valibot").StringSchema<undefined>;
69
- readonly effects: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
70
- }, undefined>, import("valibot").ObjectSchema<{
71
- readonly type: import("valibot").LiteralSchema<"sign-personal-message", undefined>;
72
- readonly bytes: import("valibot").StringSchema<undefined>;
73
- readonly signature: import("valibot").StringSchema<undefined>;
74
- }, undefined>], undefined>;
75
- export type StashedResponseData = InferOutput<typeof StashedResponseData>;
76
- export declare const StashedResponsePayload: import("valibot").VariantSchema<"type", [import("valibot").ObjectSchema<{
77
- readonly type: import("valibot").LiteralSchema<"reject", undefined>;
78
- readonly reason: import("valibot").OptionalSchema<import("valibot").StringSchema<"`reason` must be a string">, never>;
79
- }, undefined>, import("valibot").ObjectSchema<{
80
- readonly type: import("valibot").LiteralSchema<"resolve", undefined>;
81
- readonly data: import("valibot").VariantSchema<"type", [import("valibot").ObjectSchema<{
82
- readonly type: import("valibot").LiteralSchema<"connect", undefined>;
83
- readonly accounts: import("valibot").ArraySchema<import("valibot").ObjectSchema<{
84
- readonly address: import("valibot").StringSchema<"`address` is required">;
85
- readonly publicKey: import("valibot").OptionalSchema<import("valibot").StringSchema<"`publicKey` must be a string">, never>;
86
- }, undefined>, undefined>;
87
- readonly session: import("valibot").StringSchema<"`session` is required">;
88
- }, undefined>, import("valibot").ObjectSchema<{
89
- readonly type: import("valibot").LiteralSchema<"sign-transaction", undefined>;
90
- readonly bytes: import("valibot").StringSchema<undefined>;
91
- readonly signature: import("valibot").StringSchema<undefined>;
92
- }, undefined>, import("valibot").ObjectSchema<{
93
- readonly type: import("valibot").LiteralSchema<"sign-and-execute-transaction", undefined>;
94
- readonly bytes: import("valibot").StringSchema<undefined>;
95
- readonly signature: import("valibot").StringSchema<undefined>;
96
- readonly digest: import("valibot").StringSchema<undefined>;
97
- readonly effects: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
98
- }, undefined>, import("valibot").ObjectSchema<{
99
- readonly type: import("valibot").LiteralSchema<"sign-personal-message", undefined>;
100
- readonly bytes: import("valibot").StringSchema<undefined>;
101
- readonly signature: import("valibot").StringSchema<undefined>;
102
- }, undefined>], undefined>;
103
- }, undefined>], undefined>;
104
- export type StashedResponsePayload = InferOutput<typeof StashedResponsePayload>;
105
- export declare const StashedResponse: import("valibot").ObjectSchema<{
106
- readonly id: import("valibot").SchemaWithPipe<[import("valibot").StringSchema<undefined>, import("valibot").UuidAction<string, undefined>]>;
107
- readonly source: import("valibot").LiteralSchema<"stashed-channel", undefined>;
108
- readonly payload: import("valibot").VariantSchema<"type", [import("valibot").ObjectSchema<{
109
- readonly type: import("valibot").LiteralSchema<"reject", undefined>;
110
- readonly reason: import("valibot").OptionalSchema<import("valibot").StringSchema<"`reason` must be a string">, never>;
111
- }, undefined>, import("valibot").ObjectSchema<{
112
- readonly type: import("valibot").LiteralSchema<"resolve", undefined>;
113
- readonly data: import("valibot").VariantSchema<"type", [import("valibot").ObjectSchema<{
114
- readonly type: import("valibot").LiteralSchema<"connect", undefined>;
115
- readonly accounts: import("valibot").ArraySchema<import("valibot").ObjectSchema<{
116
- readonly address: import("valibot").StringSchema<"`address` is required">;
117
- readonly publicKey: import("valibot").OptionalSchema<import("valibot").StringSchema<"`publicKey` must be a string">, never>;
118
- }, undefined>, undefined>;
119
- readonly session: import("valibot").StringSchema<"`session` is required">;
120
- }, undefined>, import("valibot").ObjectSchema<{
121
- readonly type: import("valibot").LiteralSchema<"sign-transaction", undefined>;
122
- readonly bytes: import("valibot").StringSchema<undefined>;
123
- readonly signature: import("valibot").StringSchema<undefined>;
124
- }, undefined>, import("valibot").ObjectSchema<{
125
- readonly type: import("valibot").LiteralSchema<"sign-and-execute-transaction", undefined>;
126
- readonly bytes: import("valibot").StringSchema<undefined>;
127
- readonly signature: import("valibot").StringSchema<undefined>;
128
- readonly digest: import("valibot").StringSchema<undefined>;
129
- readonly effects: import("valibot").OptionalSchema<import("valibot").StringSchema<undefined>, never>;
130
- }, undefined>, import("valibot").ObjectSchema<{
131
- readonly type: import("valibot").LiteralSchema<"sign-personal-message", undefined>;
132
- readonly bytes: import("valibot").StringSchema<undefined>;
133
- readonly signature: import("valibot").StringSchema<undefined>;
134
- }, undefined>], undefined>;
135
- }, undefined>], undefined>;
136
- readonly version: import("valibot").LiteralSchema<"v1", undefined>;
137
- }, undefined>;
138
- export type StashedResponse = InferOutput<typeof StashedResponse>;
139
- export type StashedRequestTypes = Record<string, any> & {
140
- [P in StashedRequestData as P['type']]: P;
141
- };
142
- export type StashedResponseTypes = {
143
- [P in StashedResponseData as P['type']]: P;
144
- };
@@ -1,108 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var events_exports = {};
20
- __export(events_exports, {
21
- StashedRequest: () => StashedRequest,
22
- StashedRequestData: () => StashedRequestData,
23
- StashedResponse: () => StashedResponse,
24
- StashedResponseData: () => StashedResponseData,
25
- StashedResponsePayload: () => StashedResponsePayload
26
- });
27
- module.exports = __toCommonJS(events_exports);
28
- var import_valibot = require("valibot");
29
- const StashedRequestData = (0, import_valibot.variant)("type", [
30
- (0, import_valibot.object)({
31
- type: (0, import_valibot.literal)("connect")
32
- }),
33
- (0, import_valibot.object)({
34
- type: (0, import_valibot.literal)("sign-transaction"),
35
- transaction: (0, import_valibot.string)("`transaction` is required"),
36
- address: (0, import_valibot.string)("`address` is required"),
37
- chain: (0, import_valibot.string)("`chain` is required"),
38
- session: (0, import_valibot.string)("`session` is required")
39
- }),
40
- (0, import_valibot.object)({
41
- type: (0, import_valibot.literal)("sign-and-execute-transaction"),
42
- transaction: (0, import_valibot.string)("`transaction` is required"),
43
- address: (0, import_valibot.string)("`address` is required"),
44
- chain: (0, import_valibot.string)("`chain` is required"),
45
- session: (0, import_valibot.string)("`session` is required")
46
- }),
47
- (0, import_valibot.object)({
48
- type: (0, import_valibot.literal)("sign-personal-message"),
49
- chain: (0, import_valibot.optional)((0, import_valibot.string)("`chain` is required")),
50
- message: (0, import_valibot.string)("`message` is required"),
51
- address: (0, import_valibot.string)("`address` is required"),
52
- session: (0, import_valibot.string)("`session` is required")
53
- })
54
- ]);
55
- const StashedRequest = (0, import_valibot.object)({
56
- version: (0, import_valibot.literal)("v1"),
57
- requestId: (0, import_valibot.pipe)((0, import_valibot.string)("`requestId` is required"), (0, import_valibot.uuid)()),
58
- appUrl: (0, import_valibot.pipe)((0, import_valibot.string)(), (0, import_valibot.url)("`appUrl` must be a valid URL")),
59
- appName: (0, import_valibot.string)("`appName` is required"),
60
- payload: StashedRequestData,
61
- metadata: (0, import_valibot.optional)((0, import_valibot.record)((0, import_valibot.string)(), (0, import_valibot.any)()))
62
- });
63
- const StashedResponseData = (0, import_valibot.variant)("type", [
64
- (0, import_valibot.object)({
65
- type: (0, import_valibot.literal)("connect"),
66
- accounts: (0, import_valibot.array)(
67
- (0, import_valibot.object)({
68
- address: (0, import_valibot.string)("`address` is required"),
69
- publicKey: (0, import_valibot.optional)((0, import_valibot.string)("`publicKey` must be a string"))
70
- })
71
- ),
72
- session: (0, import_valibot.string)("`session` is required")
73
- }),
74
- (0, import_valibot.object)({
75
- type: (0, import_valibot.literal)("sign-transaction"),
76
- bytes: (0, import_valibot.string)(),
77
- signature: (0, import_valibot.string)()
78
- }),
79
- (0, import_valibot.object)({
80
- type: (0, import_valibot.literal)("sign-and-execute-transaction"),
81
- bytes: (0, import_valibot.string)(),
82
- signature: (0, import_valibot.string)(),
83
- digest: (0, import_valibot.string)(),
84
- effects: (0, import_valibot.optional)((0, import_valibot.string)())
85
- }),
86
- (0, import_valibot.object)({
87
- type: (0, import_valibot.literal)("sign-personal-message"),
88
- bytes: (0, import_valibot.string)(),
89
- signature: (0, import_valibot.string)()
90
- })
91
- ]);
92
- const StashedResponsePayload = (0, import_valibot.variant)("type", [
93
- (0, import_valibot.object)({
94
- type: (0, import_valibot.literal)("reject"),
95
- reason: (0, import_valibot.optional)((0, import_valibot.string)("`reason` must be a string"))
96
- }),
97
- (0, import_valibot.object)({
98
- type: (0, import_valibot.literal)("resolve"),
99
- data: StashedResponseData
100
- })
101
- ]);
102
- const StashedResponse = (0, import_valibot.object)({
103
- id: (0, import_valibot.pipe)((0, import_valibot.string)(), (0, import_valibot.uuid)()),
104
- source: (0, import_valibot.literal)("stashed-channel"),
105
- payload: StashedResponsePayload,
106
- version: (0, import_valibot.literal)("v1")
107
- });
108
- //# sourceMappingURL=events.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/experimental/wallet/channel/events.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { InferOutput } from 'valibot';\nimport {\n\tany,\n\tarray,\n\tliteral,\n\tobject,\n\toptional,\n\tpipe,\n\trecord,\n\tstring,\n\turl,\n\tuuid,\n\tvariant,\n} from 'valibot';\n\nexport const StashedRequestData = variant('type', [\n\tobject({\n\t\ttype: literal('connect'),\n\t}),\n\tobject({\n\t\ttype: literal('sign-transaction'),\n\t\ttransaction: string('`transaction` is required'),\n\t\taddress: string('`address` is required'),\n\t\tchain: string('`chain` is required'),\n\t\tsession: string('`session` is required'),\n\t}),\n\tobject({\n\t\ttype: literal('sign-and-execute-transaction'),\n\t\ttransaction: string('`transaction` is required'),\n\t\taddress: string('`address` is required'),\n\t\tchain: string('`chain` is required'),\n\t\tsession: string('`session` is required'),\n\t}),\n\tobject({\n\t\ttype: literal('sign-personal-message'),\n\t\tchain: optional(string('`chain` is required')),\n\t\tmessage: string('`message` is required'),\n\t\taddress: string('`address` is required'),\n\t\tsession: string('`session` is required'),\n\t}),\n]);\nexport type StashedRequestData = InferOutput<typeof StashedRequestData>;\n\nexport const StashedRequest = object({\n\tversion: literal('v1'),\n\trequestId: pipe(string('`requestId` is required'), uuid()),\n\tappUrl: pipe(string(), url('`appUrl` must be a valid URL')),\n\tappName: string('`appName` is required'),\n\tpayload: StashedRequestData,\n\tmetadata: optional(record(string(), any())),\n});\n\nexport type StashedRequest = InferOutput<typeof StashedRequest>;\n\nexport const StashedResponseData = variant('type', [\n\tobject({\n\t\ttype: literal('connect'),\n\t\taccounts: array(\n\t\t\tobject({\n\t\t\t\taddress: string('`address` is required'),\n\t\t\t\tpublicKey: optional(string('`publicKey` must be a string')),\n\t\t\t}),\n\t\t),\n\t\tsession: string('`session` is required'),\n\t}),\n\tobject({\n\t\ttype: literal('sign-transaction'),\n\t\tbytes: string(),\n\t\tsignature: string(),\n\t}),\n\tobject({\n\t\ttype: literal('sign-and-execute-transaction'),\n\t\tbytes: string(),\n\t\tsignature: string(),\n\t\tdigest: string(),\n\t\teffects: optional(string()),\n\t}),\n\tobject({\n\t\ttype: literal('sign-personal-message'),\n\t\tbytes: string(),\n\t\tsignature: string(),\n\t}),\n]);\nexport type StashedResponseData = InferOutput<typeof StashedResponseData>;\n\nexport const StashedResponsePayload = variant('type', [\n\tobject({\n\t\ttype: literal('reject'),\n\t\treason: optional(string('`reason` must be a string')),\n\t}),\n\tobject({\n\t\ttype: literal('resolve'),\n\t\tdata: StashedResponseData,\n\t}),\n]);\nexport type StashedResponsePayload = InferOutput<typeof StashedResponsePayload>;\n\nexport const StashedResponse = object({\n\tid: pipe(string(), uuid()),\n\tsource: literal('stashed-channel'),\n\tpayload: StashedResponsePayload,\n\tversion: literal('v1'),\n});\nexport type StashedResponse = InferOutput<typeof StashedResponse>;\n\nexport type StashedRequestTypes = Record<string, any> & {\n\t[P in StashedRequestData as P['type']]: P;\n};\n\nexport type StashedResponseTypes = {\n\t[P in StashedResponseData as P['type']]: P;\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,qBAYO;AAEA,MAAM,yBAAqB,wBAAQ,QAAQ;AAAA,MACjD,uBAAO;AAAA,IACN,UAAM,wBAAQ,SAAS;AAAA,EACxB,CAAC;AAAA,MACD,uBAAO;AAAA,IACN,UAAM,wBAAQ,kBAAkB;AAAA,IAChC,iBAAa,uBAAO,2BAA2B;AAAA,IAC/C,aAAS,uBAAO,uBAAuB;AAAA,IACvC,WAAO,uBAAO,qBAAqB;AAAA,IACnC,aAAS,uBAAO,uBAAuB;AAAA,EACxC,CAAC;AAAA,MACD,uBAAO;AAAA,IACN,UAAM,wBAAQ,8BAA8B;AAAA,IAC5C,iBAAa,uBAAO,2BAA2B;AAAA,IAC/C,aAAS,uBAAO,uBAAuB;AAAA,IACvC,WAAO,uBAAO,qBAAqB;AAAA,IACnC,aAAS,uBAAO,uBAAuB;AAAA,EACxC,CAAC;AAAA,MACD,uBAAO;AAAA,IACN,UAAM,wBAAQ,uBAAuB;AAAA,IACrC,WAAO,6BAAS,uBAAO,qBAAqB,CAAC;AAAA,IAC7C,aAAS,uBAAO,uBAAuB;AAAA,IACvC,aAAS,uBAAO,uBAAuB;AAAA,IACvC,aAAS,uBAAO,uBAAuB;AAAA,EACxC,CAAC;AACF,CAAC;AAGM,MAAM,qBAAiB,uBAAO;AAAA,EACpC,aAAS,wBAAQ,IAAI;AAAA,EACrB,eAAW,yBAAK,uBAAO,yBAAyB,OAAG,qBAAK,CAAC;AAAA,EACzD,YAAQ,yBAAK,uBAAO,OAAG,oBAAI,8BAA8B,CAAC;AAAA,EAC1D,aAAS,uBAAO,uBAAuB;AAAA,EACvC,SAAS;AAAA,EACT,cAAU,6BAAS,2BAAO,uBAAO,OAAG,oBAAI,CAAC,CAAC;AAC3C,CAAC;AAIM,MAAM,0BAAsB,wBAAQ,QAAQ;AAAA,MAClD,uBAAO;AAAA,IACN,UAAM,wBAAQ,SAAS;AAAA,IACvB,cAAU;AAAA,UACT,uBAAO;AAAA,QACN,aAAS,uBAAO,uBAAuB;AAAA,QACvC,eAAW,6BAAS,uBAAO,8BAA8B,CAAC;AAAA,MAC3D,CAAC;AAAA,IACF;AAAA,IACA,aAAS,uBAAO,uBAAuB;AAAA,EACxC,CAAC;AAAA,MACD,uBAAO;AAAA,IACN,UAAM,wBAAQ,kBAAkB;AAAA,IAChC,WAAO,uBAAO;AAAA,IACd,eAAW,uBAAO;AAAA,EACnB,CAAC;AAAA,MACD,uBAAO;AAAA,IACN,UAAM,wBAAQ,8BAA8B;AAAA,IAC5C,WAAO,uBAAO;AAAA,IACd,eAAW,uBAAO;AAAA,IAClB,YAAQ,uBAAO;AAAA,IACf,aAAS,6BAAS,uBAAO,CAAC;AAAA,EAC3B,CAAC;AAAA,MACD,uBAAO;AAAA,IACN,UAAM,wBAAQ,uBAAuB;AAAA,IACrC,WAAO,uBAAO;AAAA,IACd,eAAW,uBAAO;AAAA,EACnB,CAAC;AACF,CAAC;AAGM,MAAM,6BAAyB,wBAAQ,QAAQ;AAAA,MACrD,uBAAO;AAAA,IACN,UAAM,wBAAQ,QAAQ;AAAA,IACtB,YAAQ,6BAAS,uBAAO,2BAA2B,CAAC;AAAA,EACrD,CAAC;AAAA,MACD,uBAAO;AAAA,IACN,UAAM,wBAAQ,SAAS;AAAA,IACvB,MAAM;AAAA,EACP,CAAC;AACF,CAAC;AAGM,MAAM,sBAAkB,uBAAO;AAAA,EACrC,QAAI,yBAAK,uBAAO,OAAG,qBAAK,CAAC;AAAA,EACzB,YAAQ,wBAAQ,iBAAiB;AAAA,EACjC,SAAS;AAAA,EACT,aAAS,wBAAQ,IAAI;AACtB,CAAC;",
6
- "names": []
7
- }
@@ -1,56 +0,0 @@
1
- import type { InferOutput } from 'valibot';
2
- import type { StashedRequestData, StashedResponsePayload, StashedResponseTypes } from './events.js';
3
- import { StashedRequest, StashedResponse } from './events.js';
4
- export declare const DEFAULT_STASHED_ORIGIN = "https://getstashed.com";
5
- export { StashedRequest, StashedResponse };
6
- export declare class StashedPopup {
7
- #private;
8
- constructor({ name, origin, chain, }: {
9
- name: string;
10
- origin?: string;
11
- chain?: string;
12
- });
13
- send<T extends StashedRequestData['type']>({ type, ...data }: {
14
- type: T;
15
- } & Extract<StashedRequestData, {
16
- type: T;
17
- }>): Promise<StashedResponseTypes[T]>;
18
- close(): void;
19
- }
20
- export declare class StashedHost {
21
- #private;
22
- constructor(request: InferOutput<typeof StashedRequest>);
23
- static fromPayload(payload: StashedRequest): StashedHost;
24
- getRequestData(): {
25
- version: "v1";
26
- payload: {
27
- type: "connect";
28
- } | {
29
- type: "sign-transaction";
30
- address: string;
31
- transaction: string;
32
- chain: string;
33
- session: string;
34
- } | {
35
- type: "sign-and-execute-transaction";
36
- address: string;
37
- transaction: string;
38
- chain: string;
39
- session: string;
40
- } | {
41
- type: "sign-personal-message";
42
- message: string;
43
- address: string;
44
- session: string;
45
- chain?: string | undefined;
46
- };
47
- requestId: string;
48
- appUrl: string;
49
- appName: string;
50
- metadata?: {
51
- [x: string]: any;
52
- } | undefined;
53
- };
54
- sendMessage(payload: StashedResponsePayload): void;
55
- close(payload?: StashedResponsePayload): void;
56
- }
@@ -1,198 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __typeError = (msg) => {
7
- throw TypeError(msg);
8
- };
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
23
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
24
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
25
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
26
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
27
- var channel_exports = {};
28
- __export(channel_exports, {
29
- DEFAULT_STASHED_ORIGIN: () => DEFAULT_STASHED_ORIGIN,
30
- StashedHost: () => StashedHost,
31
- StashedPopup: () => StashedPopup,
32
- StashedRequest: () => import_events.StashedRequest,
33
- StashedResponse: () => import_events.StashedResponse
34
- });
35
- module.exports = __toCommonJS(channel_exports);
36
- var import_valibot = require("valibot");
37
- var import_withResolvers = require("../../utils/withResolvers.js");
38
- var import_events = require("./events.js");
39
- var _popup, _version, _id, _origin, _name, _chain, _promise, _resolve, _reject, _interval, _listener, _StashedPopup_instances, cleanup_fn, _request;
40
- const DEFAULT_STASHED_ORIGIN = "https://getstashed.com";
41
- const getClientMetadata = () => {
42
- return {
43
- version: "v1",
44
- originUrl: window.location.href,
45
- userAgent: navigator.userAgent,
46
- screenResolution: `${window.screen.width}x${window.screen.height}`,
47
- language: navigator.language,
48
- platform: navigator.platform,
49
- timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
50
- timestamp: Date.now()
51
- };
52
- };
53
- class StashedPopup {
54
- constructor({
55
- name,
56
- origin = DEFAULT_STASHED_ORIGIN,
57
- chain
58
- }) {
59
- __privateAdd(this, _StashedPopup_instances);
60
- __privateAdd(this, _popup);
61
- __privateAdd(this, _version);
62
- __privateAdd(this, _id);
63
- __privateAdd(this, _origin);
64
- __privateAdd(this, _name);
65
- __privateAdd(this, _chain);
66
- __privateAdd(this, _promise);
67
- __privateAdd(this, _resolve);
68
- __privateAdd(this, _reject);
69
- __privateAdd(this, _interval, null);
70
- __privateAdd(this, _listener, (event) => {
71
- if (event.origin !== __privateGet(this, _origin)) {
72
- return;
73
- }
74
- const { success, output } = (0, import_valibot.safeParse)(import_events.StashedResponse, event.data);
75
- if (!success || output.id !== __privateGet(this, _id)) return;
76
- __privateMethod(this, _StashedPopup_instances, cleanup_fn).call(this);
77
- if (output.payload.type === "reject") {
78
- __privateGet(this, _reject).call(this, new Error("User rejected the request"));
79
- } else if (output.payload.type === "resolve") {
80
- __privateGet(this, _resolve).call(this, output.payload.data);
81
- }
82
- });
83
- const popup = window.open("about:blank", "_blank");
84
- if (!popup) {
85
- throw new Error("Failed to open new window");
86
- }
87
- __privateSet(this, _popup, popup);
88
- __privateSet(this, _id, crypto.randomUUID());
89
- __privateSet(this, _origin, origin);
90
- __privateSet(this, _name, name);
91
- __privateSet(this, _version, "v1");
92
- __privateSet(this, _chain, chain);
93
- const { promise, resolve, reject } = (0, import_withResolvers.withResolvers)();
94
- __privateSet(this, _promise, promise);
95
- __privateSet(this, _resolve, resolve);
96
- __privateSet(this, _reject, reject);
97
- __privateSet(this, _interval, setInterval(() => {
98
- try {
99
- if (__privateGet(this, _popup).closed) {
100
- __privateMethod(this, _StashedPopup_instances, cleanup_fn).call(this);
101
- reject(new Error("User closed the Stashed window"));
102
- }
103
- } catch {
104
- }
105
- }, 1e3));
106
- }
107
- send({
108
- type,
109
- ...data
110
- }) {
111
- window.addEventListener("message", __privateGet(this, _listener));
112
- const requestData = {
113
- version: __privateGet(this, _version),
114
- requestId: __privateGet(this, _id),
115
- appUrl: window.location.href.split("#")[0],
116
- appName: __privateGet(this, _name),
117
- payload: {
118
- type,
119
- chain: __privateGet(this, _chain),
120
- ...data
121
- },
122
- metadata: getClientMetadata()
123
- };
124
- const encodedRequestData = btoa(JSON.stringify(requestData));
125
- __privateGet(this, _popup).location.assign(
126
- `${__privateGet(this, _origin)}/dapp-request${data ? `#${encodedRequestData}` : ""}`
127
- );
128
- return __privateGet(this, _promise);
129
- }
130
- close() {
131
- __privateMethod(this, _StashedPopup_instances, cleanup_fn).call(this);
132
- __privateGet(this, _popup).close();
133
- }
134
- }
135
- _popup = new WeakMap();
136
- _version = new WeakMap();
137
- _id = new WeakMap();
138
- _origin = new WeakMap();
139
- _name = new WeakMap();
140
- _chain = new WeakMap();
141
- _promise = new WeakMap();
142
- _resolve = new WeakMap();
143
- _reject = new WeakMap();
144
- _interval = new WeakMap();
145
- _listener = new WeakMap();
146
- _StashedPopup_instances = new WeakSet();
147
- cleanup_fn = function() {
148
- if (__privateGet(this, _interval)) {
149
- clearInterval(__privateGet(this, _interval));
150
- __privateSet(this, _interval, null);
151
- }
152
- window.removeEventListener("message", __privateGet(this, _listener));
153
- };
154
- const _StashedHost = class _StashedHost {
155
- constructor(request) {
156
- __privateAdd(this, _request);
157
- if (typeof window === "undefined" || !window.opener) {
158
- throw new Error(
159
- "StashedHost can only be used in a window opened through `window.open`. `window.opener` is not available."
160
- );
161
- }
162
- __privateSet(this, _request, request);
163
- }
164
- static fromPayload(payload) {
165
- const { requestId, appUrl, appName, version, ...rest } = payload;
166
- const request = (0, import_valibot.parse)(import_events.StashedRequest, {
167
- version,
168
- requestId,
169
- appUrl,
170
- appName,
171
- ...rest
172
- });
173
- return new _StashedHost(request);
174
- }
175
- getRequestData() {
176
- return __privateGet(this, _request);
177
- }
178
- sendMessage(payload) {
179
- window.opener.postMessage(
180
- {
181
- id: __privateGet(this, _request).requestId,
182
- source: "stashed-channel",
183
- payload,
184
- version: __privateGet(this, _request).version
185
- },
186
- __privateGet(this, _request).appUrl
187
- );
188
- }
189
- close(payload) {
190
- if (payload) {
191
- this.sendMessage(payload);
192
- }
193
- window.close();
194
- }
195
- };
196
- _request = new WeakMap();
197
- let StashedHost = _StashedHost;
198
- //# sourceMappingURL=index.js.map