@solana/offchain-messages 0.0.0 → 5.1.0-canary-20251203213248

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 (63) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +14 -0
  3. package/dist/index.browser.cjs +828 -0
  4. package/dist/index.browser.cjs.map +1 -0
  5. package/dist/index.browser.mjs +788 -0
  6. package/dist/index.browser.mjs.map +1 -0
  7. package/dist/index.native.mjs +788 -0
  8. package/dist/index.native.mjs.map +1 -0
  9. package/dist/index.node.cjs +828 -0
  10. package/dist/index.node.cjs.map +1 -0
  11. package/dist/index.node.mjs +788 -0
  12. package/dist/index.node.mjs.map +1 -0
  13. package/dist/types/application-domain.d.ts +93 -0
  14. package/dist/types/application-domain.d.ts.map +1 -0
  15. package/dist/types/codecs/application-domain.d.ts +54 -0
  16. package/dist/types/codecs/application-domain.d.ts.map +1 -0
  17. package/dist/types/codecs/content.d.ts +6 -0
  18. package/dist/types/codecs/content.d.ts.map +1 -0
  19. package/dist/types/codecs/envelope.d.ts +31 -0
  20. package/dist/types/codecs/envelope.d.ts.map +1 -0
  21. package/dist/types/codecs/message-v0.d.ts +33 -0
  22. package/dist/types/codecs/message-v0.d.ts.map +1 -0
  23. package/dist/types/codecs/message-v1.d.ts +33 -0
  24. package/dist/types/codecs/message-v1.d.ts.map +1 -0
  25. package/dist/types/codecs/message.d.ts +43 -0
  26. package/dist/types/codecs/message.d.ts.map +1 -0
  27. package/dist/types/codecs/preamble-common.d.ts +12 -0
  28. package/dist/types/codecs/preamble-common.d.ts.map +1 -0
  29. package/dist/types/codecs/preamble-v0.d.ts +6 -0
  30. package/dist/types/codecs/preamble-v0.d.ts.map +1 -0
  31. package/dist/types/codecs/preamble-v1.d.ts +6 -0
  32. package/dist/types/codecs/preamble-v1.d.ts.map +1 -0
  33. package/dist/types/codecs/signatures.d.ts +4 -0
  34. package/dist/types/codecs/signatures.d.ts.map +1 -0
  35. package/dist/types/codecs/signing-domain.d.ts +5 -0
  36. package/dist/types/codecs/signing-domain.d.ts.map +1 -0
  37. package/dist/types/content.d.ts +234 -0
  38. package/dist/types/content.d.ts.map +1 -0
  39. package/dist/types/envelope-common.d.ts +9 -0
  40. package/dist/types/envelope-common.d.ts.map +1 -0
  41. package/dist/types/envelope-v0.d.ts +11 -0
  42. package/dist/types/envelope-v0.d.ts.map +1 -0
  43. package/dist/types/envelope-v1.d.ts +11 -0
  44. package/dist/types/envelope-v1.d.ts.map +1 -0
  45. package/dist/types/envelope.d.ts +29 -0
  46. package/dist/types/envelope.d.ts.map +1 -0
  47. package/dist/types/index.d.ts +23 -0
  48. package/dist/types/index.d.ts.map +1 -0
  49. package/dist/types/message-v0.d.ts +75 -0
  50. package/dist/types/message-v0.d.ts.map +1 -0
  51. package/dist/types/message-v1.d.ts +7 -0
  52. package/dist/types/message-v1.d.ts.map +1 -0
  53. package/dist/types/message.d.ts +7 -0
  54. package/dist/types/message.d.ts.map +1 -0
  55. package/dist/types/preamble-v0.d.ts +10 -0
  56. package/dist/types/preamble-v0.d.ts.map +1 -0
  57. package/dist/types/preamble-v1.d.ts +5 -0
  58. package/dist/types/preamble-v1.d.ts.map +1 -0
  59. package/dist/types/signatures.d.ts +138 -0
  60. package/dist/types/signatures.d.ts.map +1 -0
  61. package/dist/types/version.d.ts +2 -0
  62. package/dist/types/version.d.ts.map +1 -0
  63. package/package.json +85 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preamble-v1.d.ts","sourceRoot":"","sources":["../../../src/codecs/preamble-v1.ts"],"names":[],"mappings":"AACA,OAAO,EAMH,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAO3D,wBAAgB,mCAAmC,IAAI,mBAAmB,CAAC,yBAAyB,CAAC,CA2BpG;AAED,wBAAgB,mCAAmC,IAAI,mBAAmB,CAAC,yBAAyB,CAAC,CA0BpG;AAED,wBAAgB,iCAAiC,IAAI,iBAAiB,CAAC,yBAAyB,CAAC,CAEhG"}
@@ -0,0 +1,4 @@
1
+ import { VariableSizeEncoder } from '@solana/codecs-core';
2
+ import { OffchainMessageEnvelope } from '../envelope';
3
+ export declare function getSignaturesEncoder(): VariableSizeEncoder<OffchainMessageEnvelope['signatures']>;
4
+ //# sourceMappingURL=signatures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signatures.d.ts","sourceRoot":"","sources":["../../../src/codecs/signatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAM5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAgBtD,wBAAgB,oBAAoB,IAAI,mBAAmB,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC,CAKjG"}
@@ -0,0 +1,5 @@
1
+ import { FixedSizeCodec, FixedSizeDecoder, FixedSizeEncoder } from '@solana/codecs-core';
2
+ export declare function getOffchainMessageSigningDomainDecoder(): FixedSizeDecoder<void, 16>;
3
+ export declare function getOffchainMessageSigningDomainEncoder(): FixedSizeEncoder<void, 16>;
4
+ export declare function getOffchainMessageSigningDomainCodec(): FixedSizeCodec<void, void, 16>;
5
+ //# sourceMappingURL=signing-domain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signing-domain.d.ts","sourceRoot":"","sources":["../../../src/codecs/signing-domain.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAEnB,MAAM,qBAAqB,CAAC;AAQ7B,wBAAgB,sCAAsC,IAAI,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,CAEnF;AAED,wBAAgB,sCAAsC,IAAI,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,CAEnF;AAED,wBAAgB,oCAAoC,IAAI,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAErF"}
@@ -0,0 +1,234 @@
1
+ import { Brand } from '@solana/nominal-types';
2
+ /**
3
+ * A restriction on what characters the message text can contain and how long it can be.
4
+ *
5
+ * The aim of this restriction is to make a message more likely to be signable by a hardware wallet
6
+ * that imposes limits on message size. In the case of wanting a message to be clear-signable,
7
+ * restricting the character set to ASCII may ensure that certain models of hardware wallet without
8
+ * extended character sets can display it onscreen.
9
+ *
10
+ * @remarks This only applies to v0 messages.
11
+ */
12
+ export declare enum OffchainMessageContentFormat {
13
+ RESTRICTED_ASCII_1232_BYTES_MAX = 0,
14
+ UTF8_1232_BYTES_MAX = 1,
15
+ UTF8_65535_BYTES_MAX = 2
16
+ }
17
+ /**
18
+ * Describes message text that is no more than 1232 bytes long and made up of characters with ASCII
19
+ * character codes in the range [0x20, 0x7e].
20
+ *
21
+ * @remarks This type aims to restrict text to that which can be clear-signed by hardware wallets
22
+ * that can only display ASCII characters onscreen.
23
+ */
24
+ export type OffchainMessageContentRestrictedAsciiOf1232BytesMax<TContent extends string = string> = Readonly<{
25
+ format: OffchainMessageContentFormat.RESTRICTED_ASCII_1232_BYTES_MAX;
26
+ text: Brand<TContent, 'offchainMessageContentRestrictedAsciiOf1232BytesMax'>;
27
+ }>;
28
+ /**
29
+ * Describes message text that is no more than 1232 bytes long and mdae up of any UTF-8 characters.
30
+ */
31
+ export type OffchainMessageContentUtf8Of1232BytesMax<TContent extends string = string> = Readonly<{
32
+ format: OffchainMessageContentFormat.UTF8_1232_BYTES_MAX;
33
+ text: Brand<TContent, 'offchainMessageContentUtf8Of1232BytesMax'>;
34
+ }>;
35
+ /**
36
+ * Describes message text that is no more than 65535 bytes long and mdae up of any UTF-8 characters.
37
+ */
38
+ export type OffchainMessageContentUtf8Of65535BytesMax<TContent extends string = string> = Readonly<{
39
+ format: OffchainMessageContentFormat.UTF8_65535_BYTES_MAX;
40
+ text: Brand<TContent, 'offchainMessageContentUtf8Of65535BytesMax'>;
41
+ }>;
42
+ export type OffchainMessageContent = OffchainMessageContentRestrictedAsciiOf1232BytesMax | OffchainMessageContentUtf8Of1232BytesMax | OffchainMessageContentUtf8Of65535BytesMax;
43
+ /**
44
+ * In the event that you receive content of a v0 offchain message from an untrusted source, use this
45
+ * function to assert that it conforms to the
46
+ * {@link OffchainMessageContentRestrictedAsciiOf1232BytesMax} type.
47
+ *
48
+ * @see {@link OffchainMessageContentRestrictedAsciiOf1232BytesMax} for more detail.
49
+ */
50
+ export declare function assertIsOffchainMessageContentRestrictedAsciiOf1232BytesMax(putativeContent: {
51
+ format: OffchainMessageContentFormat;
52
+ text: string;
53
+ }): asserts putativeContent is OffchainMessageContentRestrictedAsciiOf1232BytesMax;
54
+ /**
55
+ * A type guard that returns `true` when supplied content of a v0 offchain message that conforms to
56
+ * the {@link OffchainMessageContentRestrictedAsciiOf1232BytesMax} type, and refines its type for use in your
57
+ * program.
58
+ *
59
+ * @see {@link OffchainMessageContentRestrictedAsciiOf1232BytesMax} for more detail.
60
+ */
61
+ export declare function isOffchainMessageContentRestrictedAsciiOf1232BytesMax(putativeContent: {
62
+ format: OffchainMessageContentFormat;
63
+ text: string;
64
+ }): putativeContent is OffchainMessageContentRestrictedAsciiOf1232BytesMax;
65
+ /**
66
+ * Combines _asserting_ that the content of a v0 offchain message is restricted ASCII with
67
+ * _coercing_ it to the {@link OffchainMessageContentRestrictedAsciiOf1232BytesMax} type. It's most
68
+ * useful with untrusted input.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * import { offchainMessageContentRestrictedAsciiOf1232BytesMax, OffchainMessageV0 } from '@solana/offchain-messages';
73
+ *
74
+ * function handleSubmit() {
75
+ * // We know only that what the user typed conforms to the `string` type.
76
+ * const text: string = textInput.value;
77
+ * try {
78
+ * const offchainMessage: OffchainMessageV0 = {
79
+ * content: offchainMessageContentRestrictedAsciiOf1232BytesMax(text),
80
+ * // ...
81
+ * };
82
+ * } catch (e) {
83
+ * // `text` turned out not to conform to
84
+ * // `OffchainMessageContentRestrictedAsciiOf1232BytesMax`
85
+ * }
86
+ * }
87
+ * ```
88
+ *
89
+ * > [!TIP]
90
+ * > When starting from known-good ASCII content as a string, it's more efficient to typecast it
91
+ * > rather than to use the {@link offchainMessageContentRestrictedAsciiOf1232BytesMax} helper,
92
+ * > because the helper unconditionally performs validation on its input.
93
+ * >
94
+ * > ```ts
95
+ * > import { OffchainMessageContentFormat, OffchainMessageV0 } from '@solana/offchain-messages';
96
+ * >
97
+ * > const offchainMessage: OffchainMessageV0 = {
98
+ * > /* ... *\/
99
+ * > content: Object.freeze({
100
+ * > format: OffchainMessageContentFormat.RESTRICTED_ASCII_1232_BYTES_MAX,
101
+ * > text: 'Hello world',
102
+ * > } as OffchainMessageContentRestrictedAsciiOf1232BytesMax<'Hello world'>),
103
+ * > };
104
+ * > ```
105
+ */
106
+ export declare function offchainMessageContentRestrictedAsciiOf1232BytesMax<TText extends string>(text: TText): OffchainMessageContentRestrictedAsciiOf1232BytesMax<TText>;
107
+ /**
108
+ * In the event that you receive content of a v0 offchain message from an untrusted source, use this
109
+ * function to assert that it conforms to the {@link OffchainMessageContentUtf8Of1232BytesMax} type.
110
+ *
111
+ * @see {@link OffchainMessageContentUtf8Of1232BytesMax} for more detail.
112
+ */
113
+ export declare function assertIsOffchainMessageContentUtf8Of1232BytesMax(putativeContent: {
114
+ format: OffchainMessageContentFormat;
115
+ text: string;
116
+ }): asserts putativeContent is OffchainMessageContentUtf8Of1232BytesMax;
117
+ /**
118
+ * A type guard that returns `true` when supplied content of a v0 offchain message that conforms to
119
+ * the {@link OffchainMessageContentUtf8Of1232BytesMax} type, and refines its type for use in your
120
+ * program.
121
+ *
122
+ * @see {@link OffchainMessageContentUtf8Of1232BytesMax} for more detail.
123
+ */
124
+ export declare function isOffchainMessageContentUtf8Of1232BytesMax(putativeContent: {
125
+ format: OffchainMessageContentFormat;
126
+ text: string;
127
+ }): putativeContent is OffchainMessageContentUtf8Of1232BytesMax;
128
+ /**
129
+ * Combines _asserting_ that the content of a v0 offchain message is UTF-8 of up to 1232 characters
130
+ * with _coercing_ it to the {@link OffchainMessageContentUtf8Of1232BytesMax} type. It's most useful
131
+ * with untrusted input.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * import { OffchainMessageContentUtf8Of1232BytesMax, OffchainMessageV0 } from '@solana/offchain-messages';
136
+ *
137
+ * function handleSubmit() {
138
+ * // We know only that what the user typed conforms to the `string` type.
139
+ * const text: string = textInput.value;
140
+ * try {
141
+ * const offchainMessage: OffchainMessageV0 = {
142
+ * content: OffchainMessageContentUtf8Of1232BytesMax(text),
143
+ * // ...
144
+ * };
145
+ * } catch (e) {
146
+ * // `text` turned out not to conform to
147
+ * // `OffchainMessageContentUtf8Of1232BytesMax`
148
+ * }
149
+ * }
150
+ * ```
151
+ *
152
+ * > [!TIP]
153
+ * > When starting from known-good UTF-8 content as a string up to 1232 bytes, it's more efficient
154
+ * > to typecast it rather than to use the {@link offchainMessageContentUtf8Of1232BytesMax} helper,
155
+ * > because the helper unconditionally performs validation on its input.
156
+ * >
157
+ * > ```ts
158
+ * > import { OffchainMessageContentFormat, OffchainMessageV0 } from '@solana/offchain-messages';
159
+ * >
160
+ * > const offchainMessage: OffchainMessageV0 = {
161
+ * > /* ... *\/
162
+ * > content: Object.freeze({
163
+ * > format: OffchainMessageContentFormat.UTF8_1232_BYTES_MAX,
164
+ * > text: '✌🏿cool',
165
+ * > } as OffchainMessageContentUtf8Of1232BytesMax<'✌🏿cool'>),
166
+ * > };
167
+ * > ```
168
+ */
169
+ export declare function offchainMessageContentUtf8Of1232BytesMax<TText extends string>(text: TText): OffchainMessageContentUtf8Of1232BytesMax<TText>;
170
+ /**
171
+ * In the event that you receive content of a v0 offchain message from an untrusted source, use this
172
+ * function to assert that it conforms to the {@link OffchainMessageContentUtf8Of65535BytesMax}
173
+ * type.
174
+ *
175
+ * @see {@link OffchainMessageContentUtf8Of65535BytesMax} for more detail.
176
+ */
177
+ export declare function assertIsOffchainMessageContentUtf8Of65535BytesMax(putativeContent: {
178
+ format: OffchainMessageContentFormat;
179
+ text: string;
180
+ }): asserts putativeContent is OffchainMessageContentUtf8Of65535BytesMax;
181
+ /**
182
+ * A type guard that returns `true` when supplied content of a v0 offchain message that conforms to
183
+ * the {@link OffchainMessageContentUtf8Of65535BytesMax} type, and refines its type for use in your
184
+ * program.
185
+ *
186
+ * @see {@link OffchainMessageContentUtf8Of65535BytesMax} for more detail.
187
+ */
188
+ export declare function isOffchainMessageContentUtf8Of65535BytesMax(putativeContent: {
189
+ format: OffchainMessageContentFormat;
190
+ text: string;
191
+ }): putativeContent is OffchainMessageContentUtf8Of65535BytesMax;
192
+ /**
193
+ * Combines _asserting_ that the content of a v0 offchain message is UTF-8 of up to 65535 characters
194
+ * with _coercing_ it to the {@link OffchainMessageContentUtf8Of65535BytesMax} type. It's most useful
195
+ * with untrusted input.
196
+ *
197
+ * @example
198
+ * ```ts
199
+ * import { OffchainMessageContentUtf8Of65535BytesMax, OffchainMessageV0 } from '@solana/offchain-messages';
200
+ *
201
+ * function handleSubmit() {
202
+ * // We know only that what the user typed conforms to the `string` type.
203
+ * const text: string = textInput.value;
204
+ * try {
205
+ * const offchainMessage: OffchainMessageV0 = {
206
+ * content: OffchainMessageContentUtf8Of65535BytesMax(text),
207
+ * // ...
208
+ * };
209
+ * } catch (e) {
210
+ * // `text` turned out not to conform to
211
+ * // `OffchainMessageContentUtf8Of65535BytesMax`
212
+ * }
213
+ * }
214
+ * ```
215
+ *
216
+ * > [!TIP]
217
+ * > When starting from known-good UTF-8 content as a string up to 65535 bytes, it's more efficient
218
+ * > to typecast it rather than to use the {@link OffchainMessageContentUtf8Of65535BytesMax} helper,
219
+ * > because the helper unconditionally performs validation on its input.
220
+ * >
221
+ * > ```ts
222
+ * > import { OffchainMessageContentFormat, OffchainMessageV0 } from '@solana/offchain-messages';
223
+ * >
224
+ * > const offchainMessage: OffchainMessageV0 = {
225
+ * > /* ... *\/
226
+ * > content: Object.freeze({
227
+ * > format: OffchainMessageContentFormat.UTF8_65535_BYTES_MAX,
228
+ * > text: '✌🏿cool',
229
+ * > } as OffchainMessageContentUtf8Of65535BytesMax<'✌🏿cool'>),
230
+ * > };
231
+ * > ```
232
+ */
233
+ export declare function offchainMessageContentUtf8Of65535BytesMax<TText extends string>(text: TText): OffchainMessageContentUtf8Of65535BytesMax<TText>;
234
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/content.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,9 @@
1
+ import { VariableSizeEncoder } from '@solana/codecs-core';
2
+ import { OffchainMessage, OffchainMessageBytes } from './message';
3
+ export declare function compileOffchainMessageEnvelopeUsingEncoder<T extends OffchainMessage>(offchainMessage: T, encoder: VariableSizeEncoder<T>): Readonly<{
4
+ content: OffchainMessageBytes;
5
+ signatures: Readonly<{
6
+ [x: import("@solana/nominal-types").NominalType<"brand", "Address"> & import("@solana/nominal-types").NominalType<"stringEncoding", "base58"> & string]: import("@solana/keys").SignatureBytes | null;
7
+ }>;
8
+ }>;
9
+ //# sourceMappingURL=envelope-common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope-common.d.ts","sourceRoot":"","sources":["../../src/envelope-common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAElE,wBAAgB,0CAA0C,CAAC,CAAC,SAAS,eAAe,EAChF,eAAe,EAAE,CAAC,EAClB,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC;;;;;GAWlC"}
@@ -0,0 +1,11 @@
1
+ import { OffchainMessageEnvelope } from './envelope';
2
+ import { OffchainMessageV0 } from './message-v0';
3
+ /**
4
+ * Returns an {@link OffchainMessageEnvelope} object for a given {@link OffchainMessageV0}.
5
+ *
6
+ * This includes the compiled bytes of the offchain message, and a map of signatures. This map will
7
+ * have a key for each address that is required to sign the message. The message envelope will not
8
+ * yet have signatures for any of these signatories.
9
+ */
10
+ export declare function compileOffchainMessageV0Envelope(offchainMessage: OffchainMessageV0): OffchainMessageEnvelope;
11
+ //# sourceMappingURL=envelope-v0.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope-v0.d.ts","sourceRoot":"","sources":["../../src/envelope-v0.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,eAAe,EAAE,iBAAiB,GAAG,uBAAuB,CAE5G"}
@@ -0,0 +1,11 @@
1
+ import { OffchainMessageEnvelope } from './envelope';
2
+ import { OffchainMessageV1 } from './message-v1';
3
+ /**
4
+ * Returns an {@link OffchainMessageEnvelope} object for a given {@link OffchainMessageV1}.
5
+ *
6
+ * This includes the compiled bytes of the offchain message, and a map of signatures. This map will
7
+ * have a key for each address that is required to sign the message. The message envelope will not
8
+ * yet have signatures for any of these signatories.
9
+ */
10
+ export declare function compileOffchainMessageV1Envelope(offchainMessage: OffchainMessageV1): OffchainMessageEnvelope;
11
+ //# sourceMappingURL=envelope-v1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope-v1.d.ts","sourceRoot":"","sources":["../../src/envelope-v1.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,eAAe,EAAE,iBAAiB,GAAG,uBAAuB,CAE5G"}
@@ -0,0 +1,29 @@
1
+ import { Address } from '@solana/addresses';
2
+ import { SignatureBytes } from '@solana/keys';
3
+ import { OffchainMessage, OffchainMessageBytes } from './message';
4
+ type OrderedMap<K extends string, V> = Record<K, V>;
5
+ type OffchainMessageSignaturesMap = OrderedMap<Address, SignatureBytes | null>;
6
+ export interface OffchainMessageEnvelope {
7
+ /** The bytes of the combined offchain message preamble and content */
8
+ readonly content: OffchainMessageBytes;
9
+ /**
10
+ * A map between the addresses of an offchain message's signers, and the 64-byte Ed25519
11
+ * signature of the combined message preamble and message content by the private key associated
12
+ * with each.
13
+ */
14
+ readonly signatures: OffchainMessageSignaturesMap;
15
+ }
16
+ /**
17
+ * Returns an {@link OffchainMessageEnvelope} object for a given {@link OffchainMessage}.
18
+ *
19
+ * This includes the compiled bytes of the offchain message, and a map of signatures. This map will
20
+ * have a key for each address that is required to sign the message. The message envelope will not
21
+ * yet have signatures for any of these signatories.
22
+ *
23
+ * @remarks
24
+ * If the offchain message version is known ahead of time, use one of the compile functions
25
+ * specific to that version so as not to bundle more code than you need.
26
+ */
27
+ export declare function compileOffchainMessageEnvelope(offchainMessage: OffchainMessage): OffchainMessageEnvelope;
28
+ export {};
29
+ //# sourceMappingURL=envelope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../src/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI9C,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAElE,KAAK,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACpD,KAAK,4BAA4B,GAAG,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC,CAAC;AAE/E,MAAM,WAAW,uBAAuB;IACpC,sEAAsE;IACtE,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,4BAA4B,CAAC;CACrD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAAC,eAAe,EAAE,eAAe,GAAG,uBAAuB,CAYxG"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * This package contains utilities for encoding and decoding messages according to the offchain
3
+ * message [specification](https://github.com/solana-foundation/SRFCs/discussions/3).
4
+ * It can be used standalone, but it is also exported as part of Kit [`@solana/kit`](https://github.com/anza-xyz/kit/tree/main/packages/kit).
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ export * from './application-domain';
9
+ export * from './codecs/application-domain';
10
+ export * from './codecs/envelope';
11
+ export * from './codecs/message';
12
+ export * from './codecs/message-v0';
13
+ export * from './codecs/message-v1';
14
+ export * from './content';
15
+ export * from './envelope';
16
+ export * from './envelope-v0';
17
+ export * from './envelope-v1';
18
+ export * from './message';
19
+ export * from './message-v0';
20
+ export * from './message-v1';
21
+ export * from './signatures';
22
+ export * from './version';
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { OffchainMessageContentFormat, OffchainMessageContentRestrictedAsciiOf1232BytesMax, OffchainMessageContentUtf8Of1232BytesMax, OffchainMessageContentUtf8Of65535BytesMax } from './content';
2
+ import { OffchainMessagePreambleV0 } from './preamble-v0';
3
+ import { OffchainMessageWithRequiredSignatories } from './signatures';
4
+ export type BaseOffchainMessageV0 = Omit<OffchainMessagePreambleV0, 'messageFormat' | 'messageLength' | 'requiredSignatories'>;
5
+ /**
6
+ * An offchain message whose content conforms to
7
+ * {@link OffchainMessageContentRestrictedAsciiOf1232BytesMax}
8
+ */
9
+ export interface OffchainMessageWithRestrictedAsciiOf1232BytesMaxContent {
10
+ readonly content: OffchainMessageContentRestrictedAsciiOf1232BytesMax;
11
+ }
12
+ /**
13
+ * An offchain message whose content conforms to
14
+ * {@link offchainMessageContentUtf8Of1232BytesMax}
15
+ */
16
+ export interface OffchainMessageWithUtf8Of1232BytesMaxContent {
17
+ readonly content: OffchainMessageContentUtf8Of1232BytesMax;
18
+ }
19
+ /**
20
+ * An offchain message whose content conforms to
21
+ * {@link OffchainMessageContentUtf8Of65535BytesMax}
22
+ */
23
+ export interface OffchainMessageWithUtf8Of65535BytesMaxContent {
24
+ readonly content: OffchainMessageContentUtf8Of65535BytesMax;
25
+ }
26
+ /**
27
+ * A union of the formats a v0 message's contents can take.
28
+ *
29
+ * @remarks From v1 and onward, an offchain message has only one format: UTF-8 text of arbitrary
30
+ * length.
31
+ */
32
+ export type OffchainMessageWithContent = OffchainMessageWithRestrictedAsciiOf1232BytesMaxContent | OffchainMessageWithUtf8Of1232BytesMaxContent | OffchainMessageWithUtf8Of65535BytesMaxContent;
33
+ export type OffchainMessageV0 = BaseOffchainMessageV0 & OffchainMessageWithContent & OffchainMessageWithRequiredSignatories;
34
+ /**
35
+ * In the event that you receive a v0 offchain message from an untrusted source, use this function
36
+ * to assert that it is one whose content conforms to the
37
+ * {@link OffchainMessageContentRestrictedAsciiOf1232BytesMax} type.
38
+ *
39
+ * @see {@link OffchainMessageContentRestrictedAsciiOf1232BytesMax} for more detail.
40
+ */
41
+ export declare function assertIsOffchainMessageRestrictedAsciiOf1232BytesMax<TMessage extends OffchainMessageV0>(putativeMessage: Omit<TMessage, 'content'> & Readonly<{
42
+ content: {
43
+ format: OffchainMessageContentFormat;
44
+ text: string;
45
+ };
46
+ }>): asserts putativeMessage is OffchainMessageWithRestrictedAsciiOf1232BytesMaxContent & Omit<TMessage, 'content'>;
47
+ /**
48
+ * In the event that you receive a v0 offchain message from an untrusted source, use this function
49
+ * to assert that it is one whose content conforms to the
50
+ * {@link offchainMessageContentUtf8Of1232BytesMax} type.
51
+ *
52
+ * @see {@link offchainMessageContentUtf8Of1232BytesMax} for more detail.
53
+ */
54
+ export declare function assertIsOffchainMessageUtf8Of1232BytesMax<TMessage extends OffchainMessageV0>(putativeMessage: Omit<TMessage, 'content'> & Readonly<{
55
+ content: {
56
+ format: OffchainMessageContentFormat;
57
+ text: string;
58
+ };
59
+ version: number;
60
+ }>): asserts putativeMessage is OffchainMessageWithUtf8Of1232BytesMaxContent & Omit<TMessage, 'content'>;
61
+ /**
62
+ * In the event that you receive a v0 offchain message from an untrusted source, use this function
63
+ * to assert that it is one whose content conforms to the
64
+ * {@link OffchainMessageContentUtf8Of65535BytesMax} type.
65
+ *
66
+ * @see {@link OffchainMessageContentUtf8Of65535BytesMax} for more detail.
67
+ */
68
+ export declare function assertIsOffchainMessageUtf8Of65535BytesMax<TMessage extends OffchainMessageV0>(putativeMessage: Omit<TMessage, 'content'> & Readonly<{
69
+ content: {
70
+ format: OffchainMessageContentFormat;
71
+ text: string;
72
+ };
73
+ version: number;
74
+ }>): asserts putativeMessage is OffchainMessageWithUtf8Of65535BytesMaxContent & Omit<TMessage, 'content'>;
75
+ //# sourceMappingURL=message-v0.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-v0.d.ts","sourceRoot":"","sources":["../../src/message-v0.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,4BAA4B,EAC5B,mDAAmD,EACnD,wCAAwC,EACxC,yCAAyC,EAC5C,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,sCAAsC,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACpC,yBAAyB,EACzB,eAAe,GAAG,eAAe,GAAG,qBAAqB,CAC5D,CAAC;AAEF;;;GAGG;AACH,MAAM,WAAW,uDAAuD;IACpE,QAAQ,CAAC,OAAO,EAAE,mDAAmD,CAAC;CACzE;AAED;;;GAGG;AACH,MAAM,WAAW,4CAA4C;IACzD,QAAQ,CAAC,OAAO,EAAE,wCAAwC,CAAC;CAC9D;AAED;;;GAGG;AACH,MAAM,WAAW,6CAA6C;IAC1D,QAAQ,CAAC,OAAO,EAAE,yCAAyC,CAAC;CAC/D;AAED;;;;;GAKG;AACH,MAAM,MAAM,0BAA0B,GAChC,uDAAuD,GACvD,4CAA4C,GAC5C,6CAA6C,CAAC;AAEpD,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GACjD,0BAA0B,GAC1B,sCAAsC,CAAC;AAE3C;;;;;;GAMG;AACH,wBAAgB,oDAAoD,CAAC,QAAQ,SAAS,iBAAiB,EACnG,eAAe,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,GACtC,QAAQ,CAAC;IACL,OAAO,EAAE;QACL,MAAM,EAAE,4BAA4B,CAAC;QACrC,IAAI,EAAE,MAAM,CAAC;KAChB,CAAC;CACL,CAAC,GACP,OAAO,CAAC,eAAe,IAAI,uDAAuD,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAEhH;AAED;;;;;;GAMG;AACH,wBAAgB,yCAAyC,CAAC,QAAQ,SAAS,iBAAiB,EACxF,eAAe,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,GACtC,QAAQ,CAAC;IACL,OAAO,EAAE;QACL,MAAM,EAAE,4BAA4B,CAAC;QACrC,IAAI,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC,GACP,OAAO,CAAC,eAAe,IAAI,4CAA4C,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAErG;AAED;;;;;;GAMG;AACH,wBAAgB,0CAA0C,CAAC,QAAQ,SAAS,iBAAiB,EACzF,eAAe,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,GACtC,QAAQ,CAAC;IACL,OAAO,EAAE;QACL,MAAM,EAAE,4BAA4B,CAAC;QACrC,IAAI,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC,GACP,OAAO,CAAC,eAAe,IAAI,6CAA6C,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAEtG"}
@@ -0,0 +1,7 @@
1
+ import { OffchainMessagePreambleV1 } from './preamble-v1';
2
+ import { OffchainMessageWithRequiredSignatories } from './signatures';
3
+ export type BaseOffchainMessageV1 = Omit<OffchainMessagePreambleV1, 'requiredSignatories'>;
4
+ export type OffchainMessageV1 = BaseOffchainMessageV1 & OffchainMessageWithRequiredSignatories & Readonly<{
5
+ content: string;
6
+ }>;
7
+ //# sourceMappingURL=message-v1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message-v1.d.ts","sourceRoot":"","sources":["../../src/message-v1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,sCAAsC,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,yBAAyB,EAAE,qBAAqB,CAAC,CAAC;AAE3F,MAAM,MAAM,iBAAiB,GAAG,qBAAqB,GACjD,sCAAsC,GACtC,QAAQ,CAAC;IACL,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { ReadonlyUint8Array } from '@solana/codecs-core';
2
+ import { Brand } from '@solana/nominal-types';
3
+ import { OffchainMessageV0 } from './message-v0';
4
+ import { OffchainMessageV1 } from './message-v1';
5
+ export type OffchainMessage = OffchainMessageV0 | OffchainMessageV1;
6
+ export type OffchainMessageBytes = Brand<ReadonlyUint8Array, 'OffchainMessageBytes'>;
7
+ //# sourceMappingURL=message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../src/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,MAAM,eAAe,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AACpE,MAAM,MAAM,oBAAoB,GAAG,KAAK,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { OffchainMessageApplicationDomain } from './application-domain';
2
+ import { OffchainMessageContentFormat } from './content';
3
+ import { OffchainMessageWithRequiredSignatories } from './signatures';
4
+ export interface OffchainMessagePreambleV0 extends OffchainMessageWithRequiredSignatories {
5
+ applicationDomain: OffchainMessageApplicationDomain;
6
+ messageFormat: OffchainMessageContentFormat;
7
+ messageLength: number;
8
+ version: 0;
9
+ }
10
+ //# sourceMappingURL=preamble-v0.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preamble-v0.d.ts","sourceRoot":"","sources":["../../src/preamble-v0.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,sCAAsC,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,WAAW,yBAA0B,SAAQ,sCAAsC;IACrF,iBAAiB,EAAE,gCAAgC,CAAC;IACpD,aAAa,EAAE,4BAA4B,CAAC;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,CAAC,CAAC;CACd"}
@@ -0,0 +1,5 @@
1
+ import { OffchainMessageWithRequiredSignatories } from './signatures';
2
+ export interface OffchainMessagePreambleV1 extends OffchainMessageWithRequiredSignatories {
3
+ version: 1;
4
+ }
5
+ //# sourceMappingURL=preamble-v1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preamble-v1.d.ts","sourceRoot":"","sources":["../../src/preamble-v1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sCAAsC,EAAE,MAAM,cAAc,CAAC;AAEtE,MAAM,WAAW,yBAA0B,SAAQ,sCAAsC;IACrF,OAAO,EAAE,CAAC,CAAC;CACd"}
@@ -0,0 +1,138 @@
1
+ import { Address } from '@solana/addresses';
2
+ import { NominalType } from '@solana/nominal-types';
3
+ import { OffchainMessageEnvelope } from './envelope';
4
+ /**
5
+ * Represents an offchain message envelope that is signed by all of its required signers.
6
+ */
7
+ export type FullySignedOffchainMessageEnvelope = NominalType<'offchainMessageEnvelopeSignedness', 'fullySigned'>;
8
+ /**
9
+ * Represents an address that is required to sign an offchain message for it to be valid.
10
+ */
11
+ export type OffchainMessageSignatory<TAddress extends string = string> = Readonly<{
12
+ address: Address<TAddress>;
13
+ }>;
14
+ /**
15
+ * An offchain message having a list of accounts that must sign it in order for it to be valid.
16
+ */
17
+ export interface OffchainMessageWithRequiredSignatories<TSignatory extends OffchainMessageSignatory = OffchainMessageSignatory> {
18
+ requiredSignatories: readonly TSignatory[];
19
+ }
20
+ /**
21
+ * Given an array of `CryptoKey` objects which are private keys pertaining to addresses that are
22
+ * required to sign an offchain message, this method will return a new signed offchain message
23
+ * envelope of type {@link OffchainMessageEnvelope}.
24
+ *
25
+ * Though the resulting message might be signed by all required signers, this function will not
26
+ * assert that it is. A partially signed message is not complete, but can be serialized and
27
+ * deserialized.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { generateKeyPair } from '@solana/keys';
32
+ * import { partiallySignOffchainMessageEnvelope } from '@solana/offchain-messages';
33
+ *
34
+ * const partiallySignedOffchainMessage = await partiallySignOffchainMessageEnvelope(
35
+ * [myPrivateKey],
36
+ * offchainMessageEnvelope,
37
+ * );
38
+ * ```
39
+ *
40
+ * @see {@link signOffchainMessageEnvelope} if you want to assert that the message is signed by all
41
+ * its required signers after signing.
42
+ */
43
+ export declare function partiallySignOffchainMessageEnvelope<TOffchainMessageEnvelope extends OffchainMessageEnvelope>(keyPairs: CryptoKeyPair[], offchainMessageEnvelope: TOffchainMessageEnvelope): Promise<TOffchainMessageEnvelope>;
44
+ /**
45
+ * Given an array of `CryptoKey` objects which are private keys pertaining to addresses that are
46
+ * required to sign an offchain message envelope, this method will return a new signed envelope of
47
+ * type {@link FullySignedOffchainMessageEnvelope}.
48
+ *
49
+ * This function will throw unless the resulting message is fully signed.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * import { generateKeyPair } from '@solana/keys';
54
+ * import { signOffchainMessageEnvelope } from '@solana/offchain-messages';
55
+ *
56
+ * const signedOffchainMessage = await signOffchainMessageEnvelope(
57
+ * [myPrivateKey],
58
+ * offchainMessageEnvelope,
59
+ * );
60
+ * ```
61
+ *
62
+ * @see {@link partiallySignOffchainMessageEnvelope} if you want to sign the message without
63
+ * asserting that the resulting message envelope is fully signed.
64
+ */
65
+ export declare function signOffchainMessageEnvelope<TOffchainMessageEnvelope extends OffchainMessageEnvelope>(keyPairs: CryptoKeyPair[], offchainMessageEnvelope: TOffchainMessageEnvelope): Promise<FullySignedOffchainMessageEnvelope & TOffchainMessageEnvelope>;
66
+ /**
67
+ * A type guard that returns `true` if the input {@link OffchainMessageEnvelope} is fully signed,
68
+ * and refines its type for use in your program, adding the
69
+ * {@link FullySignedOffchainMessageEnvelope} type.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * import { isFullySignedOffchainMessageEnvelope } from '@solana/offchain-messages';
74
+ *
75
+ * const offchainMessageEnvelope = getOffchainMessageDecoder().decode(offchainMessageBytes);
76
+ * if (isFullySignedOffchainMessageEnvelope(offchainMessageEnvelope)) {
77
+ * // At this point we know that the offchain message is fully signed.
78
+ * }
79
+ * ```
80
+ */
81
+ export declare function isFullySignedOffchainMessageEnvelope<TEnvelope extends OffchainMessageEnvelope>(offchainMessage: TEnvelope): offchainMessage is FullySignedOffchainMessageEnvelope & TEnvelope;
82
+ /**
83
+ * From time to time you might acquire a {@link OffchainMessageEnvelope}, that you expect to be
84
+ * fully signed, from an untrusted network API or user input. Use this function to assert that such
85
+ * an offchain message is fully signed.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * import { assertIsFullySignedOffchainMessage } from '@solana/offchain-messages';
90
+ *
91
+ * const offchainMessageEnvelope = getOffchainMessageDecoder().decode(offchainMessageBytes);
92
+ * try {
93
+ * // If this type assertion function doesn't throw, then Typescript will upcast
94
+ * // `offchainMessageEnvelope` to `FullySignedOffchainMessageEnvelope`.
95
+ * assertIsFullySignedOffchainMessageEnvelope(offchainMessage);
96
+ * // At this point we know that the offchain message is signed by all required signers.
97
+ * } catch(e) {
98
+ * if (isSolanaError(e, SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURES_MISSING)) {
99
+ * setError(`Missing signatures for ${e.context.addresses.join(', ')}`);
100
+ * } else {
101
+ * throw e;
102
+ * }
103
+ * }
104
+ * ```
105
+ */
106
+ export declare function assertIsFullySignedOffchainMessageEnvelope<TEnvelope extends OffchainMessageEnvelope>(offchainMessage: TEnvelope): asserts offchainMessage is FullySignedOffchainMessageEnvelope & TEnvelope;
107
+ /**
108
+ * Asserts that there are signatures present for all of an offchain message's required signatories,
109
+ * and that those signatures are valid given the message.
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * import { isSolanaError, SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE } from '@solana/errors';
114
+ * import { verifyOffchainMessageEnvelope } from '@solana/offchain-messages';
115
+ *
116
+ * try {
117
+ * await verifyOffchainMessageEnvelope(offchainMessageEnvelope);
118
+ * // At this point the message is valid and signed by all of the required signatories.
119
+ * } catch (e) {
120
+ * if (isSolanaError(e, SOLANA_ERROR__OFFCHAIN_MESSAGE__SIGNATURE_VERIFICATION_FAILURE)) {
121
+ * if (e.context.signatoriesWithMissingSignatures.length) {
122
+ * console.error(
123
+ * 'Missing signatures for the following addresses',
124
+ * e.context.signatoriesWithMissingSignatures,
125
+ * );
126
+ * }
127
+ * if (e.context.signatoriesWithInvalidSignatures.length) {
128
+ * console.error(
129
+ * 'Signatures for the following addresses are invalid',
130
+ * e.context.signatoriesWithInvalidSignatures,
131
+ * );
132
+ * }
133
+ * }
134
+ * throw e;
135
+ * }
136
+ */
137
+ export declare function verifyOffchainMessageEnvelope(offchainMessageEnvelope: OffchainMessageEnvelope): Promise<void>;
138
+ //# sourceMappingURL=signatures.d.ts.map