@agoric/orchestration 0.1.1-dev-585d68c.0.585d68c → 0.1.1-dev-f9b3d7d.0.f9b3d7d

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/orchestration",
3
- "version": "0.1.1-dev-585d68c.0.585d68c",
3
+ "version": "0.1.1-dev-f9b3d7d.0.f9b3d7d",
4
4
  "description": "Chain abstraction for Agoric's orchestration clients",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -35,18 +35,18 @@
35
35
  },
36
36
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
37
37
  "dependencies": {
38
- "@agoric/async-flow": "0.1.1-dev-585d68c.0.585d68c",
39
- "@agoric/cosmic-proto": "0.4.1-dev-585d68c.0.585d68c",
40
- "@agoric/ertp": "0.16.3-dev-585d68c.0.585d68c",
41
- "@agoric/internal": "0.3.3-dev-585d68c.0.585d68c",
42
- "@agoric/network": "0.1.1-dev-585d68c.0.585d68c",
43
- "@agoric/notifier": "0.6.3-dev-585d68c.0.585d68c",
44
- "@agoric/store": "0.9.3-dev-585d68c.0.585d68c",
45
- "@agoric/time": "0.3.3-dev-585d68c.0.585d68c",
46
- "@agoric/vat-data": "0.5.3-dev-585d68c.0.585d68c",
47
- "@agoric/vow": "0.1.1-dev-585d68c.0.585d68c",
48
- "@agoric/zoe": "0.26.3-dev-585d68c.0.585d68c",
49
- "@agoric/zone": "0.2.3-dev-585d68c.0.585d68c",
38
+ "@agoric/async-flow": "0.1.1-dev-f9b3d7d.0.f9b3d7d",
39
+ "@agoric/cosmic-proto": "0.4.1-dev-f9b3d7d.0.f9b3d7d",
40
+ "@agoric/ertp": "0.16.3-dev-f9b3d7d.0.f9b3d7d",
41
+ "@agoric/internal": "0.3.3-dev-f9b3d7d.0.f9b3d7d",
42
+ "@agoric/network": "0.1.1-dev-f9b3d7d.0.f9b3d7d",
43
+ "@agoric/notifier": "0.6.3-dev-f9b3d7d.0.f9b3d7d",
44
+ "@agoric/store": "0.9.3-dev-f9b3d7d.0.f9b3d7d",
45
+ "@agoric/time": "0.3.3-dev-f9b3d7d.0.f9b3d7d",
46
+ "@agoric/vat-data": "0.5.3-dev-f9b3d7d.0.f9b3d7d",
47
+ "@agoric/vow": "0.1.1-dev-f9b3d7d.0.f9b3d7d",
48
+ "@agoric/zoe": "0.26.3-dev-f9b3d7d.0.f9b3d7d",
49
+ "@agoric/zone": "0.2.3-dev-f9b3d7d.0.f9b3d7d",
50
50
  "@cosmjs/encoding": "^0.36.0",
51
51
  "@endo/base64": "^1.1.1",
52
52
  "@endo/common": "^1.4.0",
@@ -61,9 +61,9 @@
61
61
  "bs58": "^6.0.0"
62
62
  },
63
63
  "devDependencies": {
64
- "@agoric/swingset-liveslots": "0.10.3-dev-585d68c.0.585d68c",
65
- "@agoric/vats": "0.15.2-dev-585d68c.0.585d68c",
66
- "@agoric/xsnap": "0.14.3-dev-585d68c.0.585d68c",
64
+ "@agoric/swingset-liveslots": "0.10.3-dev-f9b3d7d.0.f9b3d7d",
65
+ "@agoric/vats": "0.15.2-dev-f9b3d7d.0.f9b3d7d",
66
+ "@agoric/xsnap": "0.14.3-dev-f9b3d7d.0.f9b3d7d",
67
67
  "@chain-registry/client": "^1.53.194",
68
68
  "@cosmjs/amino": "^0.36.0",
69
69
  "@cosmjs/proto-signing": "^0.36.0",
@@ -100,5 +100,5 @@
100
100
  "typeCoverage": {
101
101
  "atLeast": 96.68
102
102
  },
103
- "gitHead": "585d68c965886c9a0f64660cb9c21812694eeaa6"
103
+ "gitHead": "f9b3d7de3a57032939d0ad78a50a0dca8ad98f7a"
104
104
  }
@@ -224,6 +224,13 @@ export const ForwardOptsShape: CastedPattern<NonNullable<IBCMsgTransferOptions["
224
224
  * @internal
225
225
  */
226
226
  export const IBCTransferOptionsShape: CastedPattern<IBCMsgTransferOptions>;
227
+ export namespace SignedEIP712DataShape {
228
+ let domain: import("@endo/patterns").MatcherOf<"recordOf", any>;
229
+ let types: import("@endo/patterns").MatcherOf<"recordOf", any>;
230
+ let primaryType: import("@endo/patterns").MatcherOf<"string", string>;
231
+ let message: import("@endo/patterns").MatcherOf<"recordOf", any>;
232
+ let signature: import("@endo/patterns").MatcherOf<"or", [import("@endo/patterns").MatcherOf<"string", string>, import("@endo/patterns").MatcherOf<"recordOf", any>]>;
233
+ }
227
234
  import type { Caip10Record } from './types.js';
228
235
  import type { CastedPattern } from '@endo/patterns';
229
236
  import type { AccountIdArg } from './types.js';
@@ -1 +1 @@
1
- {"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["typeGuards.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AACH;;;GAQE;;;;;;AAYF,0CAA0C;AAC1C,gCADW,cAAc,YAAY,CAAC,CAKpC;;AAMF;;;;GAIG;AACH,gCAFU,cAAc,YAAY,CAAC,CAEsC;AAE3E,uCAAuC;AACvC,0BADW,cAAc,SAAS,CAAC,CACmC;AAGtE,gBAAgB;AAChB,qFAA4C;AAE5C,gBAAgB;AAChB;;;;;;;;eAQG;AAEH,gBAAgB;AAChB,wFAA+C;AAE/C,gBAAgB;AAChB;;;;;;;;;;;;;;;;;eASG;AAEH,6CAA6C;AAC7C,mCADW,cAAc,eAAe,CAAC,CAStC;AAWH,2CAA2C;AAC3C,iCADW,cAAc,aAAa,CAAC,CAIrC;AAGF,6CAA6C;AAC7C,mCADW,cAAc,eAAe,CAAC,CAevC;AAGF,uCAAuC;AACvC,6BADW,cAAc,SAAS,CAAC,CAC0C;AAG7E,8EAAqC;AAErC,kCAAkC;AAClC,wBADW,cAAc,IAAI,CAAC,CAK5B;AAGF,iDAAiD;AACjD,6BADW,cAAc,UAAU,GAAG,EAAE,GAAG,CAAC,CAAC,CAM3C;AAGF,yCAAyC;AACzC,+BADW,cAAc,WAAW,CAAC,CAInC;AAGF,yCAAyC;AACzC,+BADW,cAAc,WAAW,C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YAAY;0BAGpC,kDAAkD;+BAH1B,YAAY;iCAK7B,qBAAqB;iCALJ,YAAY;4BAMlC,cAAc;+BANQ,YAAY;4CAAZ,YAAY;+BAI/B,sBAAsB;0CAJH,YAAY;mCAAZ,YAAY;yCAAZ,YAAY;mDAAZ,YAAY;0CAAZ,YAAY;4BAElC,8CAA8C;yCAFxB,YAAY;iCAAZ,YAAY;2CAAZ,YAAY"}
package/src/typeGuards.js CHANGED
@@ -378,3 +378,23 @@ export const IBCTransferOptionsShape = M.and(
378
378
  ),
379
379
  CosmosActionOptionsShape,
380
380
  );
381
+
382
+ /**
383
+ * The fields of signed EIP-712 typed data, e.g. as relayed on behalf of its
384
+ * signer. Only the envelope is described: the typed data itself, and its
385
+ * signature, need to be validated separately.
386
+ *
387
+ * The signature may be in any passable form accepted by viem (see
388
+ * `WithSignature`): hex encoded, or structured (`{ r, s, v }` or
389
+ * `{ r, s, yParity }`).
390
+ *
391
+ * As a record of shapes, it can also be extended with other fields.
392
+ */
393
+ export const SignedEIP712DataShape = {
394
+ domain: M.record(),
395
+ types: M.record(),
396
+ primaryType: M.string(),
397
+ message: M.record(),
398
+ signature: M.or(M.string(), M.record()),
399
+ };
400
+ harden(SignedEIP712DataShape);
@@ -24,7 +24,8 @@ export type OperationDetails<S extends EIP712MessageSchema, T extends OperationN
24
24
  * drop) genuinely-signed fields this version doesn't recognize, `data`
25
25
  * can carry extra properties beyond `OperationType<S, P>` at runtime.
26
26
  * Consumers that must reject such fields (e.g. permission records)
27
- * need to validate that themselves against a closed shape.
27
+ * need to validate that themselves against a closed shape, unless the
28
+ * utils were made with `onUnknownSignedField: 'throw'`.
28
29
  */
29
30
  data: OperationType<S, P>;
30
31
  };
@@ -59,6 +60,23 @@ export type FullMessageDetails<S extends EIP712MessageSchema, T extends Operatio
59
60
  * Valid contract addresses, keyed by chain ID.
60
61
  */
61
62
  export type ContractAddresses = Partial<Record<number | string, Address>>;
63
+ /**
64
+ * What to do with a field that was genuinely signed, but is not part of the
65
+ * schema's types for the operation (e.g. added by a newer client version):
66
+ *
67
+ * - `'keep'`: return it as part of the operation `data`, for the consumer to
68
+ * validate (e.g. against a closed shape).
69
+ * - `'throw'`: reject the message.
70
+ *
71
+ * Silently dropping such a field is intentionally not an option: a dropped
72
+ * field the signer relied upon (e.g. an attenuation on a grant) would be
73
+ * treated as absent.
74
+ */
75
+ export type UnknownSignedFieldHandling = 'keep' | 'throw';
76
+ export type EIP712MessageHandlerOptions = {
77
+ /** @default 'keep' */
78
+ onUnknownSignedField?: UnknownSignedFieldHandling;
79
+ };
62
80
  export type EIP712ViemUtils = {
63
81
  isHex: typeof isHex;
64
82
  hashStruct: typeof hashStruct;
@@ -74,10 +92,12 @@ export type EIP712ViemUtils = {
74
92
  * @param viemUtils
75
93
  * @param schema describes the domain and operations of accepted messages.
76
94
  * Messages of any other domain or operation are rejected.
77
- * @throws {Error} if a viem util is missing, or if the schema is invalid
78
- * (see {@link makeEIP712MessageKit}).
95
+ * @param options
96
+ * @param options.onUnknownSignedField see {@link UnknownSignedFieldHandling}
97
+ * @throws {Error} if a viem util is missing, if the schema is invalid
98
+ * (see {@link makeEIP712MessageKit}), or if an option is invalid.
79
99
  */
80
- export declare const makeEIP712MessageHandlerUtils: <const S extends EIP712MessageSchema>(viemUtils: EIP712ViemUtils, schema: S) => {
100
+ export declare const makeEIP712MessageHandlerUtils: <const S extends EIP712MessageSchema>(viemUtils: EIP712ViemUtils, schema: S, { onUnknownSignedField }?: EIP712MessageHandlerOptions) => {
81
101
  extractOperationDetailsFromStandaloneData: <T extends OperationNames<S>>(data: Omit<StandaloneOperationData<S, T>, "domain"> & {
82
102
  domain: FullDomain<S>;
83
103
  }, validContractAddresses?: undefined) => OperationDetails<S, T>;
@@ -1 +1 @@
1
- {"version":3,"file":"eip712-message-handler.d.ts","sourceRoot":"","sources":["eip712-message-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAa,eAAe,EAA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,QAAQ,CAAC,GAAG;QACpC,MAAM,EAAE,aAAa,CAAC;KACvB,KACA,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC;;SAqCtB,CAAC,kCACM,IAAI,+CAAgB,QAAQ,CAAC,GAAG;YACpC,MAAM,EAAE,aAAa,CAAC;YACtB,OAAO,EAAE,OAAO,CAAC;YACjB,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC;SAC/C,GACA,aAAa;SACf,CAAC,kCACM,IAAI,+CAAgB,QAAQ,CAAC,GAAG;YACpC,MAAM,EAAE,aAAa,CAAC;SACvB,SACM,OAAO,aACH,aAAa,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,GAC5C,aAAa;;iDAmHkC,CAAC,sDAC7C,CAAC,aAAa,8CAAe,gCAAoB,CAAC,GAAG;QACzD,OAAO,EAAE,OAAO,CAAC;KAClB,sBACkB;QACjB,OAAO,CAAC,EAAE,iBAAiB,CAAC;QAC5B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;KACvC,KACA,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC;4CAiK0B,CAAC,4DACxC,aAAa,CAAC,4EAAiC,CAAC,GAAG;QAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,oCACiC,iBAAiB,KAClD,OAAO,CAAC,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CA0BrC,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,CAAC,SAAS,mBAAmB,IACjE,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -58,7 +58,8 @@ import {
58
58
 
59
59
 
60
60
 
61
-
61
+
62
+
62
63
 
63
64
 
64
65
 
@@ -101,6 +102,25 @@ import {
101
102
  */
102
103
  ;
103
104
 
105
+ /**
106
+ * What to do with a field that was genuinely signed, but is not part of the
107
+ * schema's types for the operation (e.g. added by a newer client version):
108
+ *
109
+ * - `'keep'`: return it as part of the operation `data`, for the consumer to
110
+ * validate (e.g. against a closed shape).
111
+ * - `'throw'`: reject the message.
112
+ *
113
+ * Silently dropping such a field is intentionally not an option: a dropped
114
+ * field the signer relied upon (e.g. an attenuation on a grant) would be
115
+ * treated as absent.
116
+ */
117
+ ;
118
+
119
+ ;
120
+
121
+
122
+
123
+
104
124
  ;
105
125
 
106
126
 
@@ -117,14 +137,17 @@ import {
117
137
  * @param viemUtils
118
138
  * @param schema describes the domain and operations of accepted messages.
119
139
  * Messages of any other domain or operation are rejected.
120
- * @throws {Error} if a viem util is missing, or if the schema is invalid
121
- * (see {@link makeEIP712MessageKit}).
140
+ * @param options
141
+ * @param options.onUnknownSignedField see {@link UnknownSignedFieldHandling}
142
+ * @throws {Error} if a viem util is missing, if the schema is invalid
143
+ * (see {@link makeEIP712MessageKit}), or if an option is invalid.
122
144
  */
123
145
  export const makeEIP712MessageHandlerUtils = (
124
146
 
125
147
 
126
148
  viemUtils ,
127
149
  schema ,
150
+ { onUnknownSignedField = 'keep' } = {},
128
151
  ) => {
129
152
 
130
153
 
@@ -169,6 +192,12 @@ export const makeEIP712MessageHandlerUtils = (
169
192
  }
170
193
  }
171
194
 
195
+ if (onUnknownSignedField !== 'keep' && onUnknownSignedField !== 'throw') {
196
+ throw new Error(
197
+ `Invalid onUnknownSignedField option: ${String(onUnknownSignedField)}`,
198
+ );
199
+ }
200
+
172
201
  // Explicitly typed, as required to call its assertion methods.
173
202
  const messageKit = makeEIP712MessageKit(schema);
174
203
  const { domainName } = schema;
@@ -186,9 +215,9 @@ export const makeEIP712MessageHandlerUtils = (
186
215
  * actually part of what was signed. This function normalizes it a second
187
216
  * time against the types this (possibly older) version of the code
188
217
  * expects for the operation, resolving any `optional` field based on
189
- * whether it's actually present in the message, but *keeps* rather than
190
- * drops fields the signer's client signed that this version doesn't know
191
- * about yet: dropping them would let a permissions-bearing field silently
218
+ * whether it's actually present in the message, but *keeps* (or, if so
219
+ * configured, rejects) rather than drops fields the signer's client signed
220
+ * that this version doesn't know about yet: dropping them would let a permissions-bearing field silently
192
221
  * disappear (e.g. a not-yet-understood attenuation on a grant), turning
193
222
  * an attenuated grant into an unconstrained one. The returned `data` can
194
223
  * therefore be a superset of the expected shape; it is guaranteed to
@@ -242,7 +271,7 @@ export const makeEIP712MessageHandlerUtils = (
242
271
  types: messageKit.getOperationTypes(operation),
243
272
  primaryType: operation,
244
273
  },
245
- { onExtraField: 'keep', onNonCanonicalValue: 'throw' },
274
+ { onExtraField: onUnknownSignedField, onNonCanonicalValue: 'throw' },
246
275
  );
247
276
  return {
248
277
  operation,
@@ -262,8 +291,8 @@ export const makeEIP712MessageHandlerUtils = (
262
291
  * normalizes it a second time against the types this (possibly older)
263
292
  * version of the code expects for the operation, resolving any `optional`
264
293
  * field based on whether it's actually present in the witness data, but
265
- * *keeps* rather than drops fields the signer's client signed that this
266
- * version doesn't know about yet (see
294
+ * *keeps* (or, if so configured, rejects) rather than drops fields the
295
+ * signer's client signed that this version doesn't know about yet (see
267
296
  * `extractOperationDetailsFromStandaloneData`).
268
297
  *
269
298
  * Assumes the message has already been validated against the types from the data.
@@ -302,7 +331,7 @@ export const makeEIP712MessageHandlerUtils = (
302
331
  types: messageKit.getOperationTypes(operation),
303
332
  primaryType: operation,
304
333
  },
305
- { onExtraField: 'keep', onNonCanonicalValue: 'throw' },
334
+ { onExtraField: onUnknownSignedField, onNonCanonicalValue: 'throw' },
306
335
  );
307
336
  const spender = permitData.message.spender;
308
337
  return {
@@ -425,9 +454,10 @@ export const makeEIP712MessageHandlerUtils = (
425
454
  * the same way, separately (its values live outside `message`).
426
455
  * A *different*, later normalize pass (in
427
456
  * `extractOperationDetailsFromStandaloneData` /
428
- * `extractOperationDetailsFromPermit2WitnessData`) keeps -- rather than
429
- * rejects -- fields that were genuinely signed but aren't supported by
430
- * this version's schema operation types: they were legitimately
457
+ * `extractOperationDetailsFromPermit2WitnessData`) by default keeps --
458
+ * rather than rejects -- fields that were genuinely signed but aren't
459
+ * supported by this version's schema operation types (see
460
+ * {@link UnknownSignedFieldHandling}): they were legitimately
431
461
  * signed, merely not (yet) understood by this version. They are not
432
462
  * dropped, because a permissions-bearing field this version doesn't
433
463
  * understand yet must not silently vanish and be treated as absent (that