@1shotapi/ows-clear-signing 0.0.0-stage → 0.2.0
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/README.md +54 -2
- package/dist/ClearSigningError.d.ts +10 -0
- package/dist/ClearSigningError.d.ts.map +1 -0
- package/dist/ClearSigningError.js +13 -0
- package/dist/ClearSigningError.js.map +1 -0
- package/dist/ClearSigningFormatter.d.ts +26 -0
- package/dist/ClearSigningFormatter.d.ts.map +1 -0
- package/dist/ClearSigningFormatter.js +606 -0
- package/dist/ClearSigningFormatter.js.map +1 -0
- package/dist/ClearSigningPath.d.ts +48 -0
- package/dist/ClearSigningPath.d.ts.map +1 -0
- package/dist/ClearSigningPath.js +178 -0
- package/dist/ClearSigningPath.js.map +1 -0
- package/dist/ClearSigningUtils.d.ts +31 -0
- package/dist/ClearSigningUtils.d.ts.map +1 -0
- package/dist/ClearSigningUtils.js +110 -0
- package/dist/ClearSigningUtils.js.map +1 -0
- package/dist/ClearSigningValue.d.ts +49 -0
- package/dist/ClearSigningValue.d.ts.map +1 -0
- package/dist/ClearSigningValue.js +231 -0
- package/dist/ClearSigningValue.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces.d.ts +83 -0
- package/dist/interfaces.d.ts.map +1 -0
- package/dist/interfaces.js +12 -0
- package/dist/interfaces.js.map +1 -0
- package/package.json +49 -4
package/README.md
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @1shotapi/ows-clear-signing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ERC-7730 clear signing for OWS Branding Layers.
|
|
4
|
+
|
|
5
|
+
The 1Shot Relayer keeps a synced copy of the
|
|
6
|
+
[ERC-7730 registry](https://github.com/ethereum/clear-signing-erc7730-registry) and serves one
|
|
7
|
+
**resolved** descriptor per request (`includes` merged, definitions inlined, trimmed to the matching
|
|
8
|
+
format). This package does everything wallet-side:
|
|
9
|
+
|
|
10
|
+
- `ClearSigningUtils.calldataLookupKey(chainId, to, data)`: `{ chainId, address, selector }` for `GET /clear-signing/calldata`
|
|
11
|
+
- `ClearSigningUtils.eip712LookupKey(typedData)`: `{ chainId, verifyingContract, primaryType, encodeTypeHash }` for `GET /clear-signing/eip712`
|
|
12
|
+
- `ClearSigningFormatter`: renders a resolved descriptor into an `IClearSigningDisplay` (intent, interpolated intent, labeled fields)
|
|
13
|
+
|
|
14
|
+
Validate Relayer responses with `ClearSigningLookupResultSchema` from `@1shotapi/ows-types`.
|
|
15
|
+
|
|
16
|
+
## Trust model
|
|
17
|
+
|
|
18
|
+
The formatter re-verifies everything it can locally, so a compromised resolver can only change
|
|
19
|
+
labels. It can never change the decoded values shown to the user.
|
|
20
|
+
|
|
21
|
+
- **Calldata:** `context.contract.deployments` must contain `(chainId, to)`. The selector of `format.key` must equal `data[0:4]`. Arguments are decoded by the wallet from `format.key`.
|
|
22
|
+
- **EIP-712:** the domain must have `chainId` and `verifyingContract`. The `context.eip712` deployments, domain and `domainSeparator` constraints must hold. `format.key` must equal `encodeType(primaryType)`.
|
|
23
|
+
|
|
24
|
+
Any failure throws `ClearSigningError`. Callers MUST then fall back to their generic signing UI.
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { ClearSigningFormatter, ClearSigningUtils } from "@1shotapi/ows-clear-signing";
|
|
30
|
+
import { ClearSigningLookupResultSchema } from "@1shotapi/ows-types";
|
|
31
|
+
|
|
32
|
+
const key = ClearSigningUtils.calldataLookupKey(chainId, to, data);
|
|
33
|
+
const result = ClearSigningLookupResultSchema.parse(await (await fetch(url)).json());
|
|
34
|
+
if (result.found) {
|
|
35
|
+
const formatter = new ClearSigningFormatter(environment); // IClearSigningEnvironment
|
|
36
|
+
const display = await formatter.formatCalldata(result.descriptor, { chainId, from, to, data, value });
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`IClearSigningEnvironment` supplies the following, each returning `null` when unknown:
|
|
41
|
+
|
|
42
|
+
- token metadata
|
|
43
|
+
- the native currency
|
|
44
|
+
- chain names
|
|
45
|
+
- address names
|
|
46
|
+
|
|
47
|
+
The formatter does no network I/O of its own.
|
|
48
|
+
|
|
49
|
+
## Supported formats
|
|
50
|
+
|
|
51
|
+
- Fully supported: `raw`, `amount`, `tokenAmount` (threshold/message, `nativeCurrencyAddress`, `chainId`), `addressName` ("You" for the signer, `senderAddress`), `tokenTicker`, `nftName`, `date` (timestamp, blockheight), `duration`, `unit` (with SI prefixes), `enum`, `chainId`.
|
|
52
|
+
- `calldata`: rendered as "Embedded call to …" without recursive decoding.
|
|
53
|
+
- `interoperableAddressName`: rendered raw.
|
|
54
|
+
|
|
55
|
+
Paths support the `#.`, `@.` and `$.` roots, as well as relative paths, indices, negative indices, byte and array slices, `[]` iteration, groups (`sequential` / `bundled`), array-indexed params, `metadata.maps` references, and `visible` rules (`never` / `optional` / `ifNotIn` / `mustMatch`).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OwsError } from "@1shotapi/ows-types";
|
|
2
|
+
/**
|
|
3
|
+
* A descriptor cannot be applied to this transaction / message: binding mismatch, selector
|
|
4
|
+
* or type-hash mismatch, unresolvable path, invalid map reference, failed `mustMatch`, etc.
|
|
5
|
+
* Callers MUST fall back to their generic (non clear-signed) display.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ClearSigningError extends OwsError {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ClearSigningError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClearSigningError.d.ts","sourceRoot":"","sources":["../src/ClearSigningError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OwsError } from "@1shotapi/ows-types";
|
|
2
|
+
/**
|
|
3
|
+
* A descriptor cannot be applied to this transaction / message: binding mismatch, selector
|
|
4
|
+
* or type-hash mismatch, unresolvable path, invalid map reference, failed `mustMatch`, etc.
|
|
5
|
+
* Callers MUST fall back to their generic (non clear-signed) display.
|
|
6
|
+
*/
|
|
7
|
+
export class ClearSigningError extends OwsError {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "ClearSigningError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=ClearSigningError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClearSigningError.js","sourceRoot":"","sources":["../src/ClearSigningError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,OAAO,iBAAkB,SAAQ,QAAQ;IAC7C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { EVMAccountAddress, type IClearSigningDescriptor } from "@1shotapi/ows-types";
|
|
2
|
+
import { type IClearSigningDisplay, type IClearSigningEnvironment, type IClearSigningTransaction, type IClearSigningTypedData } from "./interfaces.js";
|
|
3
|
+
/**
|
|
4
|
+
* Renders an ERC-7730 descriptor (as resolved by the Relayer) against a transaction or EIP-712
|
|
5
|
+
* message. Every binding the wallet can check locally is re-verified here, so a compromised
|
|
6
|
+
* resolver can at worst mislabel fields — never change decoded values:
|
|
7
|
+
*
|
|
8
|
+
* - calldata: `context.contract.deployments` contains (chainId, to); the format key's selector
|
|
9
|
+
* equals `data[0:4]`; arguments are decoded by the wallet from the format key.
|
|
10
|
+
* - EIP-712: `context.eip712` deployments / domain / domainSeparator constraints hold; the
|
|
11
|
+
* format key equals `encodeType(primaryType)` of the message being signed.
|
|
12
|
+
*
|
|
13
|
+
* Throws {@link ClearSigningError} when the descriptor cannot be applied; callers fall back to
|
|
14
|
+
* their generic display.
|
|
15
|
+
*/
|
|
16
|
+
export declare class ClearSigningFormatter {
|
|
17
|
+
private readonly environment;
|
|
18
|
+
constructor(environment: IClearSigningEnvironment);
|
|
19
|
+
formatCalldata(descriptor: IClearSigningDescriptor, transaction: IClearSigningTransaction): Promise<IClearSigningDisplay>;
|
|
20
|
+
formatTypedData(descriptor: IClearSigningDescriptor, typedData: IClearSigningTypedData, signer: EVMAccountAddress): Promise<IClearSigningDisplay>;
|
|
21
|
+
private verifyEip712Binding;
|
|
22
|
+
private domainValueEquals;
|
|
23
|
+
private matchesDeployment;
|
|
24
|
+
private container;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ClearSigningFormatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClearSigningFormatter.d.ts","sourceRoot":"","sources":["../src/ClearSigningFormatter.ts"],"names":[],"mappings":"AAOA,OAAO,EAML,iBAAiB,EAKjB,KAAK,uBAAuB,EAE7B,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAEL,KAAK,oBAAoB,EAEzB,KAAK,wBAAwB,EAE7B,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,EAC5B,MAAM,iBAAiB,CAAC;AAYzB;;;;;;;;;;;;GAYG;AACH,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,wBAAwB;IAE5D,cAAc,CAClB,UAAU,EAAE,uBAAuB,EACnC,WAAW,EAAE,wBAAwB,GACpC,OAAO,CAAC,oBAAoB,CAAC;IA+B1B,eAAe,CACnB,UAAU,EAAE,uBAAuB,EACnC,SAAS,EAAE,sBAAsB,EACjC,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,oBAAoB,CAAC;IAsBhC,OAAO,CAAC,mBAAmB;IAyC3B,OAAO,CAAC,iBAAiB;IAUzB,OAAO,CAAC,iBAAiB;IAWzB,OAAO,CAAC,SAAS;CAalB"}
|