@droplinked_inc/wallet-connection 0.4.1 → 0.6.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/CHANGELOG.md +26 -0
- package/README.md +51 -1
- package/THREAT_MODEL.md +49 -0
- package/dist/DropWeb3.d.ts +6 -2
- package/dist/DropWeb3.d.ts.map +1 -1
- package/dist/DropWeb3.js +6 -6
- package/dist/DropWeb3.js.map +1 -1
- package/dist/app-name.d.ts +28 -0
- package/dist/app-name.d.ts.map +1 -0
- package/dist/app-name.js +60 -0
- package/dist/app-name.js.map +1 -0
- package/dist/connectors/evm.d.ts +8 -1
- package/dist/connectors/evm.d.ts.map +1 -1
- package/dist/connectors/evm.js +11 -2
- package/dist/connectors/evm.js.map +1 -1
- package/dist/connectors/phantom.d.ts +26 -22
- package/dist/connectors/phantom.d.ts.map +1 -1
- package/dist/connectors/phantom.js +20 -4
- package/dist/connectors/phantom.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/session.d.ts +4 -18
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +4 -3
- package/dist/session.js.map +1 -1
- package/dist/signing.d.ts +23 -2
- package/dist/signing.d.ts.map +1 -1
- package/dist/signing.js +17 -5
- package/dist/signing.js.map +1 -1
- package/dist/types.d.ts +34 -135
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +11 -10
- package/dist/types.js.map +1 -1
- package/dist/zod-compat.d.ts +28 -0
- package/dist/zod-compat.d.ts.map +1 -0
- package/dist/zod-compat.js +44 -0
- package/dist/zod-compat.js.map +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @droplinked_inc/wallet-connection
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f90ab6f: Add an optional `appName` to `walletLogin()` so a white-label app can show its own product name in the wallet prompt.
|
|
8
|
+
|
|
9
|
+
`walletLogin({ appName: 'Acme' })` makes the wallet show "Sign in to Acme. This signature does not authorize any token transfer." on every connector that signs: `EvmConnector`, `PhantomConnector`, the `DropWeb3` login adapters and the `getNetworkProvider()` result. On EVM chains the name is also the EIP-712 domain `name`. Only the name can be set; the rest of the sentence is fixed. The name is trimmed and must be 1 to 64 code points with no control, line-break or invisible formatting characters; anything else throws `SignaturePayloadInvalidError` before the wallet is contacted and is never replaced by the default.
|
|
10
|
+
|
|
11
|
+
Unchanged: with no `appName`, the payload sent to the wallet and the value returned are byte-identical to 0.5.0 (pinned by `default-payload-pin.test.ts`, recorded from 0.5.0).
|
|
12
|
+
|
|
13
|
+
Verification: `verifyLoginSignature` and `verifySolanaLoginSignature` take an optional `expectedAppName`. Omitted, they check exactly what they checked before (EVM expects the domain name `droplinked`). Given, the EVM domain name must be that name and, on both chains, the statement must be its fixed sentence. An EVM signature made with a custom name fails verification unless the same `expectedAppName` is passed.
|
|
14
|
+
|
|
15
|
+
New exports: `WalletLoginOptions`, `SignLoginPayloadOptions`, `VerifyLoginArgs`, `VerifySolanaLoginArgs`, `DEFAULT_APP_NAME`, `APP_NAME_MAX_LENGTH`, `normalizeAppName`, `buildLoginStatement`. `signLoginPayload()` takes an optional third argument `{ appName }`.
|
|
16
|
+
|
|
17
|
+
## 0.5.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- d1970bb: **Breaking (0.x): move to zod 4 (`zod ^4.6.7`).** Clears GHSA-mrhx-c7xc-m3w5 (zod < 4.6.6).
|
|
22
|
+
|
|
23
|
+
Breaking because the package re-exports zod schemas (`LoginPayloadSchema`, `ChainPaymentSchema`, `ProofSchema`, `WalletSessionSchema`, `SolanaLoginPayloadSchema`, `EvmAddressSchema`, …): they are now zod 4 schema objects, and a `ZodError` thrown by `.parse()` is zod 4's (`.issues` as before; the zod 3 `.errors` alias is gone).
|
|
24
|
+
|
|
25
|
+
Unchanged: what every schema accepts and returns, the inferred types and the custom error messages. zod 4 narrowed `.int()` (safe integers only), `.datetime()` (seconds required) and `.url()` (trims its output); internal helpers keep the zod 3 behaviour, so amounts past `Number.MAX_SAFE_INTEGER`, minute-precision timestamps and untrimmed `uri` values parse exactly as before (`schema-behaviour.test.ts`, written against zod 3 and passing on both).
|
|
26
|
+
|
|
27
|
+
Changed: zod's default issue wording (e.g. inside `SignaturePayloadInvalidError` messages).
|
|
28
|
+
|
|
3
29
|
## 0.4.1
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ pnpm add @droplinked_inc/wallet-connection
|
|
|
21
21
|
Peer-ish runtime deps:
|
|
22
22
|
|
|
23
23
|
- `viem ^2.21`
|
|
24
|
-
- `zod ^
|
|
24
|
+
- `zod ^4.6.7`
|
|
25
25
|
|
|
26
26
|
Both are direct dependencies; you do not need to install them yourself.
|
|
27
27
|
|
|
@@ -74,6 +74,56 @@ const connector = new PhantomConnector(Network.MAINNET);
|
|
|
74
74
|
const { address, signature } = await connector.walletLogin();
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
## Product name in the wallet prompt
|
|
78
|
+
|
|
79
|
+
By default the wallet asks the user to sign
|
|
80
|
+
"Sign in to droplinked. This signature does not authorize any token
|
|
81
|
+
transfer." A white-label build can show its own product name instead:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
const { address, signature } = await connector.walletLogin({ appName: 'Acme' });
|
|
85
|
+
// Wallet shows: "Sign in to Acme. This signature does not authorize any token transfer."
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`appName` is accepted by every connector that signs (`EvmConnector`,
|
|
89
|
+
`PhantomConnector`, the `DropWeb3` login adapters and the
|
|
90
|
+
`getNetworkProvider()` result).
|
|
91
|
+
|
|
92
|
+
- It sets only the name. The rest of the sentence is fixed and cannot be
|
|
93
|
+
changed or removed through `walletLogin()`.
|
|
94
|
+
- On EVM chains it is also the EIP-712 domain `name`, so it is part of
|
|
95
|
+
what is signed.
|
|
96
|
+
- It is trimmed, then must be 1 to 64 characters (Unicode code points)
|
|
97
|
+
with no control characters, line breaks or invisible formatting
|
|
98
|
+
characters such as bidi overrides. Anything else throws
|
|
99
|
+
`SignaturePayloadInvalidError` before the wallet is contacted; an
|
|
100
|
+
invalid name is never replaced by the default.
|
|
101
|
+
- Omit it to sign exactly what earlier versions signed. `normalizeAppName()`
|
|
102
|
+
validates a name up front (for example at app start) and
|
|
103
|
+
`buildLoginStatement()` returns the sentence for a name.
|
|
104
|
+
|
|
105
|
+
A verifier must expect the same name:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
await verifyLoginSignature({
|
|
109
|
+
payload,
|
|
110
|
+
signature,
|
|
111
|
+
expectedAddress: address,
|
|
112
|
+
expectedChainId: 1,
|
|
113
|
+
expectedOrigin: window.location.origin,
|
|
114
|
+
expectedAppName: 'Acme',
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
| `expectedAppName` | `verifyLoginSignature` (EVM) | `verifySolanaLoginSignature` |
|
|
119
|
+
| ----------------- | ---------------------------------------------------------------------- | ------------------------------------------------ |
|
|
120
|
+
| omitted | domain name must be `droplinked`; statement not checked (as before) | statement not checked (as before) |
|
|
121
|
+
| given | domain name must be this name and the statement its fixed sentence | the statement must be this name's fixed sentence |
|
|
122
|
+
|
|
123
|
+
On EVM, a signature made with `appName: 'Acme'` fails verification
|
|
124
|
+
unless `expectedAppName: 'Acme'` is passed. On Solana the name is only in
|
|
125
|
+
the statement, so pass `expectedAppName` to enforce it.
|
|
126
|
+
|
|
77
127
|
## ERC-20 transfer
|
|
78
128
|
|
|
79
129
|
```ts
|
package/THREAT_MODEL.md
CHANGED
|
@@ -165,6 +165,55 @@ match them, so wallet errors silently slipped through to incorrect
|
|
|
165
165
|
**Test.** `errors.test.ts → 'errors propagate through try/catch
|
|
166
166
|
(regression: v1.0.1 did not extend Error)'`.
|
|
167
167
|
|
|
168
|
+
### T11 — Caller-controlled text in the sign-in prompt
|
|
169
|
+
|
|
170
|
+
**Scenario.** `walletLogin({ appName })` lets the calling app choose the
|
|
171
|
+
product name shown in the wallet prompt (for white-label builds). A
|
|
172
|
+
compromised or careless caller could try to use that input to rewrite
|
|
173
|
+
the prompt: drop or contradict "This signature does not authorize any
|
|
174
|
+
token transfer.", push it out of view with line breaks, or visually
|
|
175
|
+
reorder it with bidi control characters.
|
|
176
|
+
|
|
177
|
+
**Mitigation.** The public option is a name, not a statement. The
|
|
178
|
+
package builds the sentence itself as
|
|
179
|
+
`Sign in to <appName>. This signature does not authorize any token
|
|
180
|
+
transfer.`, so the safety sentence is always present and always last.
|
|
181
|
+
The name is trimmed and must be 1 to 64 code points with no characters
|
|
182
|
+
from Unicode categories Cc (controls, including line feed, carriage
|
|
183
|
+
return, tab and NEL), Cf (bidi overrides, zero-width characters, BOM),
|
|
184
|
+
Cs (lone surrogates), Zl or Zp (line and paragraph separators). Invalid
|
|
185
|
+
input throws `SignaturePayloadInvalidError` before the wallet is
|
|
186
|
+
contacted and is never replaced by the default. With no `appName`, the
|
|
187
|
+
payload is byte-identical to earlier versions.
|
|
188
|
+
|
|
189
|
+
**What this does not cover.**
|
|
190
|
+
- Within 64 characters the name is still free text: a caller can put a
|
|
191
|
+
misleading name or a lookalike (homoglyph) name in the slot. It cannot
|
|
192
|
+
remove or reorder the fixed sentence.
|
|
193
|
+
- The lower-level exports `buildLoginPayload({ statement })` and
|
|
194
|
+
`buildSolanaLoginPayload({ statement })` accepted a free-form statement
|
|
195
|
+
before this change and still do. Code that can call them, or that can
|
|
196
|
+
call the wallet directly, can already ask the user to sign any text.
|
|
197
|
+
- The name is not a replay boundary. Origin binding (T3), chain binding
|
|
198
|
+
(T2) and the nonce remain what stop replay.
|
|
199
|
+
|
|
200
|
+
**Changed assumption (T1).** The EIP-712 domain name is no longer always
|
|
201
|
+
`droplinked`: on EVM it is the caller's `appName`, and it is part of the
|
|
202
|
+
signed hash. A verifier must pass the same `expectedAppName` to
|
|
203
|
+
`verifyLoginSignature`; omitting it means the default name, exactly as
|
|
204
|
+
before, so existing verifiers keep passing for default logins and reject
|
|
205
|
+
custom-named ones. When `expectedAppName` is given, both verifiers also
|
|
206
|
+
require the statement to be the fixed sentence for that name. The Solana
|
|
207
|
+
verifier did not check the statement before and still does not when
|
|
208
|
+
`expectedAppName` is omitted.
|
|
209
|
+
|
|
210
|
+
**Test.** `app-name.test.ts` (validation, the fixed sentence, each
|
|
211
|
+
connector and adapter, and "signed for Acme: fails against the default
|
|
212
|
+
name, passes when Acme is expected" for EVM and Solana) and
|
|
213
|
+
`default-payload-pin.test.ts` (the default payload sent to the wallet
|
|
214
|
+
and the returned result, recorded from the code before this option
|
|
215
|
+
existed).
|
|
216
|
+
|
|
168
217
|
## Out of scope (tracked for follow-ups)
|
|
169
218
|
|
|
170
219
|
- WalletConnect v2 connector — placeholder factory exposed; needs a
|
package/dist/DropWeb3.d.ts
CHANGED
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
import { Chain, ChainWallet, Network } from './types.js';
|
|
43
43
|
import { Web3Actions } from './Web3Actions.js';
|
|
44
44
|
import { WalletConnectionError } from './errors.js';
|
|
45
|
+
import type { WalletLoginOptions } from './app-name.js';
|
|
45
46
|
/** Raised when a `Web3Actions` value has not been ported into this facade. */
|
|
46
47
|
export declare class Web3ActionNotImplementedError extends WalletConnectionError {
|
|
47
48
|
readonly name = "Web3ActionNotImplementedError";
|
|
@@ -69,8 +70,11 @@ export interface DropWeb3LoginResult {
|
|
|
69
70
|
* connector and re-exposes the slimmer hostile-package surface.
|
|
70
71
|
*/
|
|
71
72
|
export interface DropWeb3ChainInstance {
|
|
72
|
-
/**
|
|
73
|
-
|
|
73
|
+
/**
|
|
74
|
+
* EVM / Solana wallet login (EIP-712 / SIWS). `options.appName` sets the
|
|
75
|
+
* product name in the wallet prompt; see `WalletLoginOptions`.
|
|
76
|
+
*/
|
|
77
|
+
walletLogin(options?: WalletLoginOptions): Promise<DropWeb3LoginResult>;
|
|
74
78
|
/**
|
|
75
79
|
* Unstoppable Domains OAuth login. The caller passes the OAuth
|
|
76
80
|
* `clientId` and `redirectUri`; the implementation is delegated to a
|
package/dist/DropWeb3.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropWeb3.d.ts","sourceRoot":"","sources":["../src/DropWeb3.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAA2B,qBAAqB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"DropWeb3.d.ts","sourceRoot":"","sources":["../src/DropWeb3.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAA2B,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD,8EAA8E;AAC9E,qBAAa,6BAA8B,SAAQ,qBAAqB;IACtE,SAAkB,IAAI,mCAAmC;gBAC7C,MAAM,EAAE,WAAW,GAAG,MAAM;CAGzC;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,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EAAE,MAAM,EAAE,MAAM;IAO5C;;;;;;OAMG;IACG,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CA6D3E"}
|
package/dist/DropWeb3.js
CHANGED
|
@@ -86,7 +86,7 @@ export class DropWeb3 {
|
|
|
86
86
|
args.preferredWallet === ChainWallet.Phantom) {
|
|
87
87
|
const connector = new PhantomConnector(this.network);
|
|
88
88
|
return makeAdapter({
|
|
89
|
-
walletLogin: async () => phantomLoginToDropWeb3Result(connector),
|
|
89
|
+
walletLogin: async (options) => phantomLoginToDropWeb3Result(connector, options),
|
|
90
90
|
unstoppableLogin: rejectUnstoppableOnNonUd,
|
|
91
91
|
});
|
|
92
92
|
}
|
|
@@ -115,7 +115,7 @@ export class DropWeb3 {
|
|
|
115
115
|
wallet: args.preferredWallet,
|
|
116
116
|
});
|
|
117
117
|
return makeAdapter({
|
|
118
|
-
walletLogin: async () => evmLoginToDropWeb3Result(connector),
|
|
118
|
+
walletLogin: async (options) => evmLoginToDropWeb3Result(connector, options),
|
|
119
119
|
unstoppableLogin: rejectUnstoppableOnNonUd,
|
|
120
120
|
});
|
|
121
121
|
}
|
|
@@ -141,10 +141,10 @@ async function rejectUnstoppableOnNonUd() {
|
|
|
141
141
|
* holds the canonical payload, we replicate just enough of it here to
|
|
142
142
|
* capture issuedAt + nonce alongside the signature.
|
|
143
143
|
*/
|
|
144
|
-
async function evmLoginToDropWeb3Result(connector) {
|
|
144
|
+
async function evmLoginToDropWeb3Result(connector, options) {
|
|
145
145
|
// Reuse the connector's high-level walletLogin so all hardening
|
|
146
146
|
// (chain-id check, address parse, EIP-712 typed sign) is exercised.
|
|
147
|
-
const { address, signature } = await connector.walletLogin();
|
|
147
|
+
const { address, signature } = await connector.walletLogin(options);
|
|
148
148
|
// We don't have direct access to the payload's nonce/issuedAt from
|
|
149
149
|
// the public return type — but EvmConnector's signed payload is
|
|
150
150
|
// bound to issuedAt = ISO-now and a fresh CSPRNG nonce. For the
|
|
@@ -157,8 +157,8 @@ async function evmLoginToDropWeb3Result(connector) {
|
|
|
157
157
|
const nonce = generateClientNonce();
|
|
158
158
|
return { address, signature, date: issuedAt, nonce };
|
|
159
159
|
}
|
|
160
|
-
async function phantomLoginToDropWeb3Result(connector) {
|
|
161
|
-
const result = await connector.walletLogin();
|
|
160
|
+
async function phantomLoginToDropWeb3Result(connector, options) {
|
|
161
|
+
const result = await connector.walletLogin(options);
|
|
162
162
|
// PhantomConnector returns the canonical signed payload — surface its
|
|
163
163
|
// nonce + issuedAt rather than re-deriving so the diagnostic surface
|
|
164
164
|
// matches what was actually signed.
|
package/dist/DropWeb3.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropWeb3.js","sourceRoot":"","sources":["../src/DropWeb3.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAW,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"DropWeb3.js","sourceRoot":"","sources":["../src/DropWeb3.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAW,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAA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CAAC,GAAI,UAA4E,CAAC,MAAM,CAAC;IAC/F,IAAI,CAAC,KAAK,SAAS,IAAI,OAAO,CAAC,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;QAC/D,+DAA+D;QAC/D,kEAAkE;QAClE,6DAA6D;QAC7D,aAAa;QACb,OAAO,SAAS,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;IAC/B,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IACzB,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE;QAAE,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAW,CAAC,CAAC;IACtF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** The name used when the caller passes none. Equal to `TYPED_DATA_DOMAIN_NAME`. */
|
|
2
|
+
export declare const DEFAULT_APP_NAME: "droplinked";
|
|
3
|
+
/** Longest accepted app name, counted in Unicode code points after trimming. */
|
|
4
|
+
export declare const APP_NAME_MAX_LENGTH = 64;
|
|
5
|
+
/** Options accepted by every connector's `walletLogin()`. */
|
|
6
|
+
export interface WalletLoginOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Product name shown in the wallet prompt. Defaults to
|
|
9
|
+
* `DEFAULT_APP_NAME` ('droplinked'). Trimmed; must then be 1 to
|
|
10
|
+
* `APP_NAME_MAX_LENGTH` code points with no control, format or
|
|
11
|
+
* line-break characters. Invalid values throw
|
|
12
|
+
* `SignaturePayloadInvalidError`; they are never replaced by the default.
|
|
13
|
+
*/
|
|
14
|
+
readonly appName?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Returns the app name to sign with: `DEFAULT_APP_NAME` when `appName`
|
|
18
|
+
* is `undefined`, otherwise the trimmed, validated value. Throws
|
|
19
|
+
* `SignaturePayloadInvalidError` for anything else.
|
|
20
|
+
*/
|
|
21
|
+
export declare function normalizeAppName(appName: string | undefined): string;
|
|
22
|
+
/**
|
|
23
|
+
* The sign-in sentence for `appName`. With no name it returns exactly
|
|
24
|
+
* the sentence earlier versions signed:
|
|
25
|
+
* 'Sign in to droplinked. This signature does not authorize any token transfer.'
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildLoginStatement(appName?: string): string;
|
|
28
|
+
//# sourceMappingURL=app-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-name.d.ts","sourceRoot":"","sources":["../src/app-name.ts"],"names":[],"mappings":"AAcA,oFAAoF;AACpF,eAAO,MAAM,gBAAgB,EAAG,YAAqB,CAAC;AAEtD,gFAAgF;AAChF,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAatC,6DAA6D;AAC7D,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAsBpE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5D"}
|
package/dist/app-name.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The product name shown in the wallet's sign-in prompt.
|
|
3
|
+
*
|
|
4
|
+
* `walletLogin({ appName })` puts this name in two places: the EIP-712
|
|
5
|
+
* domain `name` (EVM) and the fixed sign-in sentence (EVM and Solana).
|
|
6
|
+
* The caller chooses only the name. The rest of the sentence, including
|
|
7
|
+
* "This signature does not authorize any token transfer.", is fixed here
|
|
8
|
+
* and cannot be changed or removed through `walletLogin()`.
|
|
9
|
+
*
|
|
10
|
+
* Kept in its own module, with no viem import, so the Solana connector
|
|
11
|
+
* can use it without pulling in the EVM signing code.
|
|
12
|
+
*/
|
|
13
|
+
import { SignaturePayloadInvalidError } from './errors.js';
|
|
14
|
+
/** The name used when the caller passes none. Equal to `TYPED_DATA_DOMAIN_NAME`. */
|
|
15
|
+
export const DEFAULT_APP_NAME = 'droplinked';
|
|
16
|
+
/** Longest accepted app name, counted in Unicode code points after trimming. */
|
|
17
|
+
export const APP_NAME_MAX_LENGTH = 64;
|
|
18
|
+
/**
|
|
19
|
+
* Characters refused anywhere in an app name:
|
|
20
|
+
* Cc control characters (includes \n, \r, \t, NUL, NEL)
|
|
21
|
+
* Cf format characters (bidi overrides such as U+202E, zero-width
|
|
22
|
+
* characters, BOM) which can reorder or hide text in a prompt
|
|
23
|
+
* Cs lone surrogates
|
|
24
|
+
* Zl line separator U+2028
|
|
25
|
+
* Zp paragraph separator U+2029
|
|
26
|
+
*/
|
|
27
|
+
const FORBIDDEN_APP_NAME_CHARS = /[\p{Cc}\p{Cf}\p{Cs}\p{Zl}\p{Zp}]/u;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the app name to sign with: `DEFAULT_APP_NAME` when `appName`
|
|
30
|
+
* is `undefined`, otherwise the trimmed, validated value. Throws
|
|
31
|
+
* `SignaturePayloadInvalidError` for anything else.
|
|
32
|
+
*/
|
|
33
|
+
export function normalizeAppName(appName) {
|
|
34
|
+
if (appName === undefined) {
|
|
35
|
+
return DEFAULT_APP_NAME;
|
|
36
|
+
}
|
|
37
|
+
if (typeof appName !== 'string') {
|
|
38
|
+
throw new SignaturePayloadInvalidError('appName must be a string');
|
|
39
|
+
}
|
|
40
|
+
const trimmed = appName.trim();
|
|
41
|
+
if (trimmed.length === 0) {
|
|
42
|
+
throw new SignaturePayloadInvalidError('appName must not be empty');
|
|
43
|
+
}
|
|
44
|
+
if ([...trimmed].length > APP_NAME_MAX_LENGTH) {
|
|
45
|
+
throw new SignaturePayloadInvalidError(`appName must be at most ${APP_NAME_MAX_LENGTH} characters`);
|
|
46
|
+
}
|
|
47
|
+
if (FORBIDDEN_APP_NAME_CHARS.test(trimmed)) {
|
|
48
|
+
throw new SignaturePayloadInvalidError('appName must not contain control, format or line-break characters');
|
|
49
|
+
}
|
|
50
|
+
return trimmed;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The sign-in sentence for `appName`. With no name it returns exactly
|
|
54
|
+
* the sentence earlier versions signed:
|
|
55
|
+
* 'Sign in to droplinked. This signature does not authorize any token transfer.'
|
|
56
|
+
*/
|
|
57
|
+
export function buildLoginStatement(appName) {
|
|
58
|
+
return `Sign in to ${normalizeAppName(appName)}. This signature does not authorize any token transfer.`;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=app-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-name.js","sourceRoot":"","sources":["../src/app-name.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAE3D,oFAAoF;AACpF,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAqB,CAAC;AAEtD,gFAAgF;AAChF,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAEtC;;;;;;;;GAQG;AACH,MAAM,wBAAwB,GAAG,mCAAmC,CAAC;AAcrE;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA2B;IAC1D,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,IAAI,4BAA4B,CAAC,0BAA0B,CAAC,CAAC;IACrE,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC/B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,4BAA4B,CAAC,2BAA2B,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,GAAG,mBAAmB,EAAE,CAAC;QAC9C,MAAM,IAAI,4BAA4B,CACpC,2BAA2B,mBAAmB,aAAa,CAC5D,CAAC;IACJ,CAAC;IACD,IAAI,wBAAwB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,MAAM,IAAI,4BAA4B,CACpC,mEAAmE,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,OAAO,cAAc,gBAAgB,CAAC,OAAO,CAAC,yDAAyD,CAAC;AAC1G,CAAC"}
|
package/dist/connectors/evm.d.ts
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { Chain, ChainWallet, Network, type ChainProvider, type EvmAddress, type IChainPayment } from '../types.js';
|
|
18
18
|
import { type Eip1193Provider } from '../provider.js';
|
|
19
|
+
import { type WalletLoginOptions } from '../app-name.js';
|
|
19
20
|
import type { Hex } from 'viem';
|
|
20
21
|
/** Minimal ABI fragments — kept inline rather than fetched remotely. */
|
|
21
22
|
declare const ERC20_TRANSFER_ABI: readonly [{
|
|
@@ -65,8 +66,14 @@ export declare class EvmConnector implements ChainProvider {
|
|
|
65
66
|
/**
|
|
66
67
|
* Connect + EIP-712 typed login. Returns the signature; the caller is
|
|
67
68
|
* expected to submit it to the droplinked auth API.
|
|
69
|
+
*
|
|
70
|
+
* `options.appName` sets the product name in the prompt: it becomes the
|
|
71
|
+
* EIP-712 domain name and the name in the fixed sentence
|
|
72
|
+
* "Sign in to <appName>. This signature does not authorize any token
|
|
73
|
+
* transfer." It is validated before the wallet is contacted. Omit it
|
|
74
|
+
* to sign exactly what earlier versions signed ('droplinked').
|
|
68
75
|
*/
|
|
69
|
-
walletLogin(): Promise<{
|
|
76
|
+
walletLogin(options?: WalletLoginOptions): Promise<{
|
|
70
77
|
address: EvmAddress;
|
|
71
78
|
signature: string;
|
|
72
79
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../src/connectors/evm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACL,KAAK,EAEL,WAAW,EAEX,OAAO,EACP,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAQrB,OAAO,EAOL,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhC,wEAAwE;AACxE,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;EAYd,CAAC;AAEX,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,2EAA2E;IAC3E,QAAQ,CAAC,uBAAuB,CAAC,EAAE,UAAU,CAAC;IAC9C,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,YAAa,YAAW,aAAa;IAChD,SAAgB,KAAK,EAAE,KAAK,CAAC;IAC7B,SAAgB,OAAO,EAAE,OAAO,CAAC;IAC1B,OAAO,EAAE,UAAU,CAAgD;IACnE,MAAM,EAAE,WAAW,CAAC;IAC3B,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAyB;IACjE,OAAO,CAAC,QAAQ,CAAC,MAAM,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AM,CAAC,CAOpE,CAAC;AAyCF,iEAAiE;AACjE,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,CASvE;AAGD,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/connectors/evm.js
CHANGED
|
@@ -19,6 +19,7 @@ import { AccountChangedException, ChainMismatchError, InvalidTransactionError, W
|
|
|
19
19
|
import { getChainMetadata } from '../chains.js';
|
|
20
20
|
import { getAccounts, getChainId, isWalletConnected, requestAccounts, selectCoinbaseProvider, selectMetaMaskProvider, } from '../provider.js';
|
|
21
21
|
import { buildLoginPayload, signLoginPayload, } from '../signing.js';
|
|
22
|
+
import { buildLoginStatement, normalizeAppName, } from '../app-name.js';
|
|
22
23
|
/** Minimal ABI fragments — kept inline rather than fetched remotely. */
|
|
23
24
|
const ERC20_TRANSFER_ABI = [
|
|
24
25
|
{
|
|
@@ -124,8 +125,15 @@ export class EvmConnector {
|
|
|
124
125
|
/**
|
|
125
126
|
* Connect + EIP-712 typed login. Returns the signature; the caller is
|
|
126
127
|
* expected to submit it to the droplinked auth API.
|
|
128
|
+
*
|
|
129
|
+
* `options.appName` sets the product name in the prompt: it becomes the
|
|
130
|
+
* EIP-712 domain name and the name in the fixed sentence
|
|
131
|
+
* "Sign in to <appName>. This signature does not authorize any token
|
|
132
|
+
* transfer." It is validated before the wallet is contacted. Omit it
|
|
133
|
+
* to sign exactly what earlier versions signed ('droplinked').
|
|
127
134
|
*/
|
|
128
|
-
async walletLogin() {
|
|
135
|
+
async walletLogin(options = {}) {
|
|
136
|
+
const appName = normalizeAppName(options.appName);
|
|
129
137
|
const provider = this.getWalletProvider();
|
|
130
138
|
const accountsBefore = await getAccounts(provider);
|
|
131
139
|
const accounts = accountsBefore.length > 0 ? accountsBefore : await requestAccounts(provider);
|
|
@@ -143,9 +151,10 @@ export class EvmConnector {
|
|
|
143
151
|
address,
|
|
144
152
|
chainId: meta.chainIdNumber,
|
|
145
153
|
origin: this.origin,
|
|
154
|
+
statement: buildLoginStatement(appName),
|
|
146
155
|
expiresInSeconds: 60 * 10, // 10 minutes
|
|
147
156
|
});
|
|
148
|
-
const signature = await signLoginPayload(provider, payload);
|
|
157
|
+
const signature = await signLoginPayload(provider, payload, { appName });
|
|
149
158
|
this.address = address;
|
|
150
159
|
return { address, signature };
|
|
151
160
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evm.js","sourceRoot":"","sources":["../../src/connectors/evm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAEL,kBAAkB,EAClB,WAAW,EACX,gBAAgB,GAKjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,GAEvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"evm.js","sourceRoot":"","sources":["../../src/connectors/evm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAEL,kBAAkB,EAClB,WAAW,EACX,gBAAgB,GAKjB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EACL,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,sBAAsB,EACtB,sBAAsB,GAEvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,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EAAkE;AAClE,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -22,9 +22,11 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import { z } from 'zod';
|
|
24
24
|
import { Chain, ChainWallet, Network, type ChainProvider, type IChainPayment } from '../types.js';
|
|
25
|
+
import { type WalletLoginOptions } from '../app-name.js';
|
|
25
26
|
/**
|
|
26
27
|
* Default human-readable statement embedded in the signed payload so
|
|
27
|
-
* Phantom's prompt explains *why* the user is signing.
|
|
28
|
+
* Phantom's prompt explains *why* the user is signing. Equal to
|
|
29
|
+
* `buildLoginStatement()`; `walletLogin({ appName })` swaps only the name.
|
|
28
30
|
*/
|
|
29
31
|
export declare const DEFAULT_SOLANA_LOGIN_STATEMENT = "Sign in to droplinked. This signature does not authorize any token transfer.";
|
|
30
32
|
/** Allowed Solana chain identifiers; `chain` is bound into the payload. */
|
|
@@ -37,28 +39,16 @@ export declare const SOLANA_LOGIN_DEFAULT_TTL_SECONDS: number;
|
|
|
37
39
|
export declare const SolanaLoginPayloadSchema: z.ZodObject<{
|
|
38
40
|
domain: z.ZodString;
|
|
39
41
|
address: z.ZodString;
|
|
40
|
-
chain: z.ZodEnum<
|
|
42
|
+
chain: z.ZodEnum<{
|
|
43
|
+
"solana-mainnet": "solana-mainnet";
|
|
44
|
+
"solana-devnet": "solana-devnet";
|
|
45
|
+
"solana-testnet": "solana-testnet";
|
|
46
|
+
}>;
|
|
41
47
|
nonce: z.ZodString;
|
|
42
|
-
issuedAt: z.
|
|
43
|
-
expirationTime: z.
|
|
48
|
+
issuedAt: z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODateTime]>;
|
|
49
|
+
expirationTime: z.ZodUnion<readonly [z.ZodISODateTime, z.ZodISODateTime]>;
|
|
44
50
|
statement: z.ZodString;
|
|
45
|
-
},
|
|
46
|
-
domain: string;
|
|
47
|
-
address: string;
|
|
48
|
-
statement: string;
|
|
49
|
-
nonce: string;
|
|
50
|
-
issuedAt: string;
|
|
51
|
-
expirationTime: string;
|
|
52
|
-
chain: "solana-mainnet" | "solana-devnet" | "solana-testnet";
|
|
53
|
-
}, {
|
|
54
|
-
domain: string;
|
|
55
|
-
address: string;
|
|
56
|
-
statement: string;
|
|
57
|
-
nonce: string;
|
|
58
|
-
issuedAt: string;
|
|
59
|
-
expirationTime: string;
|
|
60
|
-
chain: "solana-mainnet" | "solana-devnet" | "solana-testnet";
|
|
61
|
-
}>;
|
|
51
|
+
}, z.core.$strip>;
|
|
62
52
|
export type SolanaLoginPayload = z.infer<typeof SolanaLoginPayloadSchema>;
|
|
63
53
|
export interface BuildSolanaLoginPayloadArgs {
|
|
64
54
|
readonly address: string;
|
|
@@ -89,6 +79,13 @@ export interface VerifySolanaLoginArgs {
|
|
|
89
79
|
readonly expectedChain: SolanaChainId;
|
|
90
80
|
readonly expectedOrigin: string;
|
|
91
81
|
readonly nowMs?: number;
|
|
82
|
+
/**
|
|
83
|
+
* The app name the payload was signed with (`walletLogin({ appName })`).
|
|
84
|
+
* Omitted: the statement is not checked, exactly as before this option
|
|
85
|
+
* existed. Given: `payload.statement` must be the fixed sentence for
|
|
86
|
+
* this name (`buildLoginStatement(expectedAppName)`).
|
|
87
|
+
*/
|
|
88
|
+
readonly expectedAppName?: string;
|
|
92
89
|
}
|
|
93
90
|
/**
|
|
94
91
|
* Verify a Phantom (Solana) SIWS-style login signature.
|
|
@@ -99,6 +96,8 @@ export interface VerifySolanaLoginArgs {
|
|
|
99
96
|
* 3. `payload.domain === host(expectedOrigin)` (origin-spoofing refused).
|
|
100
97
|
* 4. `payload.address === expectedAddress`.
|
|
101
98
|
* 5. `now < expirationTime` AND `issuedAt <= now` (freshness).
|
|
99
|
+
* 5a. When `expectedAppName` is given, `payload.statement` is the fixed
|
|
100
|
+
* sentence for that name.
|
|
102
101
|
* 6. The base64 signature is a valid ed25519 signature over
|
|
103
102
|
* `utf8(canonicalizeSolanaLoginPayload(payload))` for the public
|
|
104
103
|
* key derived from `expectedAddress` (base58-decoded).
|
|
@@ -140,8 +139,13 @@ export declare class PhantomConnector implements ChainProvider {
|
|
|
140
139
|
*
|
|
141
140
|
* Replaces the v1.0.1 / pre-audit static-plaintext signMessage path,
|
|
142
141
|
* which was replayable across origins, chains, and sessions.
|
|
142
|
+
*
|
|
143
|
+
* `options.appName` sets the product name in the fixed sentence
|
|
144
|
+
* "Sign in to <appName>. This signature does not authorize any token
|
|
145
|
+
* transfer." It is validated before Phantom is contacted. Omit it to
|
|
146
|
+
* sign exactly what earlier versions signed ('droplinked').
|
|
143
147
|
*/
|
|
144
|
-
walletLogin(): Promise<{
|
|
148
|
+
walletLogin(options?: WalletLoginOptions): Promise<{
|
|
145
149
|
address: string;
|
|
146
150
|
signature: string;
|
|
147
151
|
payload: SolanaLoginPayload;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phantom.d.ts","sourceRoot":"","sources":["../../src/connectors/phantom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"phantom.d.ts","sourceRoot":"","sources":["../../src/connectors/phantom.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAOlG,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,gBAAgB,CAAC;AAoCxB;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,iFACqC,CAAC;AAEjF,2EAA2E;AAC3E,eAAO,MAAM,gBAAgB,gEAAiE,CAAC;AAC/F,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D,+DAA+D;AAC/D,eAAO,MAA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