@amadeus-protocol/wallet-sdk 0.1.4 → 0.1.6
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 +17 -0
- package/dist/binary.d.ts +0 -2
- package/dist/binary.d.ts.map +1 -1
- package/dist/binary.js +1 -2
- package/dist/bytes.d.ts +0 -2
- package/dist/bytes.d.ts.map +1 -1
- package/dist/bytes.js +1 -2
- package/dist/client/injected.d.ts +0 -2
- package/dist/client/injected.d.ts.map +1 -1
- package/dist/client/injected.js +1 -2
- package/dist/constants.d.ts +0 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -2
- package/dist/crypto/apikey.d.ts +0 -2
- package/dist/crypto/apikey.d.ts.map +1 -1
- package/dist/crypto/apikey.js +5 -3
- package/dist/crypto/apikey.js.map +1 -1
- package/dist/crypto/bls.d.ts +0 -2
- package/dist/crypto/bls.d.ts.map +1 -1
- package/dist/crypto/bls.js +1 -2
- package/dist/crypto/box.d.ts +0 -2
- package/dist/crypto/box.d.ts.map +1 -1
- package/dist/crypto/box.js +3 -3
- package/dist/crypto/box.js.map +1 -1
- package/dist/crypto/connect.d.ts +0 -2
- package/dist/crypto/connect.d.ts.map +1 -1
- package/dist/crypto/connect.js +3 -3
- package/dist/crypto/connect.js.map +1 -1
- package/dist/crypto/message.d.ts +0 -2
- package/dist/crypto/message.d.ts.map +1 -1
- package/dist/crypto/message.js +3 -3
- package/dist/crypto/message.js.map +1 -1
- package/dist/errors.d.ts +0 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +1 -2
- package/dist/react/index.d.ts +0 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +1 -2
- package/dist/schema.d.ts +0 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +1 -2
- package/dist/transport/bridge.d.ts +0 -2
- package/dist/transport/bridge.d.ts.map +1 -1
- package/dist/transport/bridge.js +2 -3
- package/dist/transport/bridge.js.map +1 -1
- package/dist/transport/envelope.d.ts +0 -2
- package/dist/transport/envelope.d.ts.map +1 -1
- package/dist/transport/envelope.js +1 -2
- package/dist/transport/session.d.ts +0 -2
- package/dist/transport/session.d.ts.map +1 -1
- package/dist/transport/session.js +11 -11
- package/dist/transport/session.js.map +1 -1
- package/dist/transport/uri.d.ts +0 -2
- package/dist/transport/uri.d.ts.map +1 -1
- package/dist/transport/uri.js +1 -2
- package/dist/tx.d.ts +3 -11
- package/dist/tx.d.ts.map +1 -1
- package/dist/tx.js +13 -10
- package/dist/tx.js.map +1 -1
- package/dist/types.d.ts +0 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -2
- package/dist/wallet/handler.d.ts +6 -2
- package/dist/wallet/handler.d.ts.map +1 -1
- package/dist/wallet/handler.js +3 -13
- package/dist/wallet/handler.js.map +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -41,6 +41,23 @@ const result = verifyApiKey(apiKey, { aud: 'amadeus' })
|
|
|
41
41
|
if (result.valid) console.log(result.address)
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
+
> **The token's address is the public key of the `seed` you pass in.** A recovery
|
|
45
|
+
> phrase can open two different addresses (the standard `eip2333` derivation, and
|
|
46
|
+
> the `legacy` raw-BIP39 seed used by wallets created with older extension and app
|
|
47
|
+
> builds), so don't assume one. Resolve the seed with `resolveCandidateForAddress`
|
|
48
|
+
> (sdk ≥ 1.6.0), which returns the candidate whose `publicKey` equals the user's
|
|
49
|
+
> wallet address, or `null` if neither derivation opens it (it throws on an
|
|
50
|
+
> invalid phrase). Otherwise the token silently belongs to a different account.
|
|
51
|
+
>
|
|
52
|
+
> ```ts
|
|
53
|
+
> import { resolveCandidateForAddress } from '@amadeus-protocol/sdk'
|
|
54
|
+
> import { generateApiKey } from '@amadeus-protocol/wallet-sdk'
|
|
55
|
+
>
|
|
56
|
+
> const candidate = resolveCandidateForAddress(phrase, walletAddress)
|
|
57
|
+
> if (!candidate) throw new Error('This phrase does not open that address')
|
|
58
|
+
> const { apiKey } = generateApiKey({ seed: candidate.seed, aud: 'amadeus', expIn: 3600 })
|
|
59
|
+
> ```
|
|
60
|
+
|
|
44
61
|
## Security notes
|
|
45
62
|
|
|
46
63
|
- **Distinct DSTs** (`_TX_`, `_APIKEY_`, `_CONNECT_`) make a signature from one
|
package/dist/binary.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/binary.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* JSON-safe encoding for binary values (typed arrays) that cross a text
|
|
4
3
|
* transport. Transaction args can contain raw bytes (e.g. a recipient pubkey);
|
|
@@ -25,6 +24,5 @@ declare function encodeBinaryValues(value: unknown): unknown;
|
|
|
25
24
|
declare function decodeBinaryValues(value: unknown): unknown;
|
|
26
25
|
/** Human-readable stand-in for tagged bytes when displaying args in an approval UI. */
|
|
27
26
|
declare function describeBinaryValues(value: unknown): unknown;
|
|
28
|
-
//#endregion
|
|
29
27
|
export { BYTES_TAG, TaggedBytes, decodeBinaryValues, describeBinaryValues, encodeBinaryValues, isTaggedBytes };
|
|
30
28
|
//# sourceMappingURL=binary.d.ts.map
|
package/dist/binary.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binary.d.ts","names":[],"sources":["../src/binary.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"binary.d.ts","names":[],"sources":["../src/binary.ts"],"mappings":";;;;;;;;;;;;cAea;KAED;GAAiB;;iBAab,cAAc,iBAAiB,SAAS;;;;;iBAcxC,mBAAmB;;iBAkBnB,mBAAmB;;iBAgBnB,qBAAqB"}
|
package/dist/binary.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { base64ToUint8Array, uint8ArrayToBase64 } from "@amadeus-protocol/sdk";
|
|
2
|
-
|
|
2
|
+
// src/binary.ts
|
|
3
3
|
/**
|
|
4
4
|
* JSON-safe encoding for binary values (typed arrays) that cross a text
|
|
5
5
|
* transport. Transaction args can contain raw bytes (e.g. a recipient pubkey);
|
|
@@ -50,7 +50,6 @@ function describeBinaryValues(value) {
|
|
|
50
50
|
if (typeof value === "object" && value !== null) return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, describeBinaryValues(entry)]));
|
|
51
51
|
return value;
|
|
52
52
|
}
|
|
53
|
-
//#endregion
|
|
54
53
|
export { BYTES_TAG, decodeBinaryValues, describeBinaryValues, encodeBinaryValues, isTaggedBytes };
|
|
55
54
|
|
|
56
55
|
//# sourceMappingURL=binary.js.map
|
package/dist/bytes.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { concatBytes, randomBytes } from "@noble/hashes/utils";
|
|
2
|
-
//#region src/bytes.d.ts
|
|
3
2
|
declare const concatBytes$1: typeof concatBytes;
|
|
4
3
|
declare const randomBytes$1: typeof randomBytes;
|
|
5
4
|
/** A random hex id (default 16 bytes → 32 hex chars). Used for request ids. */
|
|
@@ -15,6 +14,5 @@ declare function u32be(n: number): Uint8Array;
|
|
|
15
14
|
* (`box.open`) and BLS verification both rely on noble's constant-time primitives.
|
|
16
15
|
*/
|
|
17
16
|
declare function equalBytes(a: Uint8Array, b: Uint8Array): boolean;
|
|
18
|
-
//#endregion
|
|
19
17
|
export { bytesToUtf8, concatBytes$1 as concatBytes, equalBytes, randomBytes$1 as randomBytes, randomId, u32be, utf8ToBytes };
|
|
20
18
|
//# sourceMappingURL=bytes.d.ts.map
|
package/dist/bytes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bytes.d.ts","names":[],"sources":["../src/bytes.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","names":["concatBytes","nobleConcat","randomBytes","nobleRandom"],"sources":["../src/bytes.ts"],"mappings":";cAeaA,sBAAWC;cACXC,sBAAWC;;iBAGR,SAAS;iBAIT,YAAY,gBAAgB;iBAI5B,YAAY,OAAO;;iBAKnB,MAAM,YAAY;;;;;;;iBAkBlB,WAAW,GAAG,YAAY,GAAG"}
|
package/dist/bytes.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { bytesToHex, concatBytes, randomBytes } from "@noble/hashes/utils";
|
|
2
|
-
|
|
2
|
+
// src/bytes.ts
|
|
3
3
|
/**
|
|
4
4
|
* Small byte helpers, kept isomorphic (Node, browser, React Native/Hermes).
|
|
5
5
|
*
|
|
@@ -42,7 +42,6 @@ function equalBytes(a, b) {
|
|
|
42
42
|
for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i];
|
|
43
43
|
return diff === 0;
|
|
44
44
|
}
|
|
45
|
-
//#endregion
|
|
46
45
|
export { bytesToUtf8, concatBytes$1 as concatBytes, equalBytes, randomBytes$1 as randomBytes, randomId, u32be, utf8ToBytes };
|
|
47
46
|
|
|
48
47
|
//# sourceMappingURL=bytes.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AmadeusEventPayloadMap, AmadeusProvider, AmadeusProviderEvent, SignTransactionRequest, SignTransactionResponse } from "../types.js";
|
|
2
|
-
//#region src/client/injected.d.ts
|
|
3
2
|
/** Where a cached api-key lives. Default is in-memory; dApps can pass localStorage-backed. */
|
|
4
3
|
interface ApiKeyStore {
|
|
5
4
|
get(): string | null;
|
|
@@ -36,6 +35,5 @@ interface WalletClient {
|
|
|
36
35
|
* inject a provider (e.g. in tests); otherwise it reads `window.amadeus`.
|
|
37
36
|
*/
|
|
38
37
|
declare function createInjectedWalletClient(providerOverride?: AmadeusProvider): WalletClient;
|
|
39
|
-
//#endregion
|
|
40
38
|
export { ApiKeyStore, WalletClient, createInjectedWalletClient };
|
|
41
39
|
//# sourceMappingURL=injected.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injected.d.ts","names":[],"sources":["../../src/client/injected.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"injected.d.ts","names":[],"sources":["../../src/client/injected.ts"],"mappings":";;UAyBiB;EAChB;EACA,IAAI;;UAiBY;EAChB;EACA,eAAe;;EAEf,WAAW;EACX,cAAc;EACd,cAAc;EACd,gBAAgB,SAAS,yBAAyB,QAAQ;;EAE1D,cACC,SAAS,wBACT;IAAW;IAAiB;MAC1B;IAAU;IAAgB;;;EAE7B,aAAa;IACZ;IACA;IACA,QAAQ;IACR;MACG;EACJ,GAAG,UAAU,sBACZ,OAAO,GACP,KAAK,MAAM,uBAAuB;EAEnC,IAAI,UAAU,sBACb,OAAO,GACP,KAAK,MAAM,uBAAuB;;;;;;iBAQpB,2BAA2B,mBAAmB,kBAAkB"}
|
package/dist/client/injected.js
CHANGED
|
@@ -2,7 +2,7 @@ import { WalletSdkError } from "../errors.js";
|
|
|
2
2
|
import { submitTransaction } from "../tx.js";
|
|
3
3
|
import { getAmadeusProvider } from "../types.js";
|
|
4
4
|
import { decodeApiKey } from "../crypto/apikey.js";
|
|
5
|
-
|
|
5
|
+
// src/client/injected.ts
|
|
6
6
|
/**
|
|
7
7
|
* A framework-agnostic dApp client over the injected `window.amadeus` provider
|
|
8
8
|
* (the browser extension). It wraps the raw provider with the ergonomics every
|
|
@@ -81,7 +81,6 @@ function createInjectedWalletClient(providerOverride) {
|
|
|
81
81
|
off: (event, cb) => requireProvider().off(event, cb)
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
//#endregion
|
|
85
84
|
export { createInjectedWalletClient };
|
|
86
85
|
|
|
87
86
|
//# sourceMappingURL=injected.js.map
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/constants.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Protocol constants for the Amadeus dApp <-> wallet connection layer.
|
|
4
3
|
*
|
|
@@ -85,6 +84,5 @@ declare const NETWORKS: readonly ["mainnet", "testnet", "custom"];
|
|
|
85
84
|
* wallet rejects non-https bridge URLs via `assertAllowedBridgeUrl`).
|
|
86
85
|
*/
|
|
87
86
|
declare const DEFAULT_BRIDGE_URL = "https://bridge.ama.one";
|
|
88
|
-
//#endregion
|
|
89
87
|
export { API_KEY_DST, CONNECT_DST, CONNECT_TRANSCRIPT_LABEL, DEFAULT_BRIDGE_URL, MAX_API_KEY_STRING_LENGTH, MAX_MESSAGE_LENGTH, MESSAGE_DST, NETWORKS, PROTOCOL_VERSION, PROVIDER_EVENTS, PROVIDER_GLOBAL, PUBLIC_KEY_BYTE_LENGTH, SEED_BYTE_LENGTH, SESSION_NONCE_BYTE_LENGTH, SESSION_PUBLIC_KEY_BYTE_LENGTH, SESSION_SECRET_KEY_BYTE_LENGTH, SIGNATURE_BYTE_LENGTH, TX_DST, WALLET_INITIALIZED_EVENT, WALLET_WINDOW_EVENTS };
|
|
90
88
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../src/constants.ts"],"mappings":";;;;;;;;;;;;cAaa;;;;;;;cAQA;;;;;;cAOA;;;;;;;;cASA;;cAGA;cACA;cACA;;;;;;;cAQA;;;;;;cAOA;;cAGA;cACA;cACA;;cAGA;;cAGA;;cAGA;;;;;;cAOA;;cAGA;;;;;;;;;cAUA;;cAUA;;;;;;cAOA"}
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/constants.ts
|
|
2
2
|
/**
|
|
3
3
|
* Protocol constants for the Amadeus dApp <-> wallet connection layer.
|
|
4
4
|
*
|
|
@@ -96,7 +96,6 @@ const NETWORKS = [
|
|
|
96
96
|
* wallet rejects non-https bridge URLs via `assertAllowedBridgeUrl`).
|
|
97
97
|
*/
|
|
98
98
|
const DEFAULT_BRIDGE_URL = "https://bridge.ama.one";
|
|
99
|
-
//#endregion
|
|
100
99
|
export { API_KEY_DST, CONNECT_DST, CONNECT_TRANSCRIPT_LABEL, DEFAULT_BRIDGE_URL, MAX_API_KEY_STRING_LENGTH, MAX_MESSAGE_LENGTH, MESSAGE_DST, NETWORKS, PROTOCOL_VERSION, PROVIDER_EVENTS, PROVIDER_GLOBAL, PUBLIC_KEY_BYTE_LENGTH, SEED_BYTE_LENGTH, SESSION_NONCE_BYTE_LENGTH, SESSION_PUBLIC_KEY_BYTE_LENGTH, SESSION_SECRET_KEY_BYTE_LENGTH, SIGNATURE_BYTE_LENGTH, TX_DST, WALLET_INITIALIZED_EVENT, WALLET_WINDOW_EVENTS };
|
|
101
100
|
|
|
102
101
|
//# sourceMappingURL=constants.js.map
|
package/dist/crypto/apikey.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/crypto/apikey.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* BLS12-381 API-key bearer tokens — the ONE audited implementation, replacing
|
|
4
3
|
* the byte-identical copies currently hand-rolled in the wallet extension
|
|
@@ -67,6 +66,5 @@ type VerifyApiKeyResult = {
|
|
|
67
66
|
* result rather than throwing on the common "invalid" paths.
|
|
68
67
|
*/
|
|
69
68
|
declare function verifyApiKey(apiKey: string, options?: VerifyApiKeyOptions): VerifyApiKeyResult;
|
|
70
|
-
//#endregion
|
|
71
69
|
export { ApiKeyPayload, DecodedApiKey, GenerateApiKeyParams, GenerateApiKeyResult, VerifyApiKeyOptions, VerifyApiKeyResult, decodeApiKey, generateApiKey, verifyApiKey };
|
|
72
70
|
//# sourceMappingURL=apikey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apikey.d.ts","names":[],"sources":["../../src/crypto/apikey.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"apikey.d.ts","names":[],"sources":["../../src/crypto/apikey.ts"],"mappings":";;;;;;;;;;;;;;;;UA6BiB;EAChB;EACA;;UAGgB;;EAEhB;;EAEA;;EAEA;;EAEA;;UAGgB;EAChB;EACA,SAAS;;iBAGM,eAAe,QAAQ,uBAAuB;UAqB7C;EAChB,SAAS;EACT,WAAW;EACX,WAAW;;EAEX,WAAW;;EAEX;;;iBAIe,aAAa,iBAAiB;UAmD7B;;EAEhB;;EAEA;;EAEA;;KAGW;EACP;EAAa,SAAS;EAAe;;EACrC;EAAc;;;;;;;iBAOH,aACf,gBACA,UAAS,sBACP"}
|
package/dist/crypto/apikey.js
CHANGED
|
@@ -3,7 +3,7 @@ import { WalletSdkError } from "../errors.js";
|
|
|
3
3
|
import { bytesToUtf8, concatBytes, utf8ToBytes } from "../bytes.js";
|
|
4
4
|
import { deriveSigner, signHashed, verifyHashed } from "./bls.js";
|
|
5
5
|
import { fromBase58, toBase58 } from "@amadeus-protocol/sdk";
|
|
6
|
-
|
|
6
|
+
// src/crypto/apikey.ts
|
|
7
7
|
/**
|
|
8
8
|
* BLS12-381 API-key bearer tokens — the ONE audited implementation, replacing
|
|
9
9
|
* the byte-identical copies currently hand-rolled in the wallet extension
|
|
@@ -30,8 +30,11 @@ function generateApiKey(params) {
|
|
|
30
30
|
aud: params.aud,
|
|
31
31
|
exp
|
|
32
32
|
}));
|
|
33
|
+
const signed = concatBytes(jsonBytes, pk);
|
|
34
|
+
const signature = signHashed(signed, sk, API_KEY_DST);
|
|
35
|
+
const token = concatBytes(jsonBytes, pk, signature);
|
|
33
36
|
return {
|
|
34
|
-
apiKey: toBase58(
|
|
37
|
+
apiKey: toBase58(token),
|
|
35
38
|
payload: {
|
|
36
39
|
aud: params.aud,
|
|
37
40
|
exp
|
|
@@ -103,7 +106,6 @@ function verifyApiKey(apiKey, options = {}) {
|
|
|
103
106
|
address: decoded.address
|
|
104
107
|
};
|
|
105
108
|
}
|
|
106
|
-
//#endregion
|
|
107
109
|
export { decodeApiKey, generateApiKey, verifyApiKey };
|
|
108
110
|
|
|
109
111
|
//# sourceMappingURL=apikey.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apikey.js","names":[],"sources":["../../src/crypto/apikey.ts"],"sourcesContent":["/**\n * BLS12-381 API-key bearer tokens — the ONE audited implementation, replacing\n * the byte-identical copies currently hand-rolled in the wallet extension\n * (`background/handlers/api-key.ts`) and hub/prime-hub (`utils/blsWallet.ts`).\n *\n * Token layout (concatenated, then Base58-encoded):\n * [ jsonBytes (variable) | pubkey (48) | signature (96) ]\n *\n * jsonBytes = utf8(JSON.stringify({ aud, exp })) // key order: aud THEN exp\n * exp = floor(now/1000) + expIn // unix seconds\n * signature = BLS.sign(sha256(jsonBytes || pubkey), sk, { DST: API_KEY_DST })\n *\n * Folding the pubkey into the signed hash blocks rogue-key attacks. `kbs.ama.one`\n * verifies against exactly this construction — do not alter the field order,\n * concatenation, or DST.\n */\n\nimport { fromBase58, toBase58 } from '@amadeus-protocol/sdk'\n\nimport {\n\tAPI_KEY_DST,\n\tMAX_API_KEY_STRING_LENGTH,\n\tPUBLIC_KEY_BYTE_LENGTH,\n\tSIGNATURE_BYTE_LENGTH\n} from '../constants'\nimport { WalletSdkError } from '../errors'\nimport { bytesToUtf8, concatBytes, utf8ToBytes } from '../bytes'\nimport { deriveSigner, signHashed, verifyHashed } from './bls'\n\nexport interface ApiKeyPayload {\n\taud: string\n\texp: number\n}\n\nexport interface GenerateApiKeyParams {\n\t/** Base58 wallet seed (private key). */\n\tseed: string\n\t/** Audience claim the bearer will present to. */\n\taud: string\n\t/** Lifetime in seconds from now. */\n\texpIn: number\n\t/** Override \"now\" (ms since epoch) — for deterministic tests. */\n\tnow?: number\n}\n\nexport interface GenerateApiKeyResult {\n\tapiKey: string\n\tpayload: ApiKeyPayload\n}\n\nexport function generateApiKey(params: GenerateApiKeyParams): GenerateApiKeyResult {\n\tif (!params.aud || params.aud.length === 0) {\n\t\tthrow new WalletSdkError('INVALID_ARGUMENT', 'aud is required')\n\t}\n\tif (!Number.isInteger(params.expIn) || params.expIn <= 0) {\n\t\tthrow new WalletSdkError('INVALID_ARGUMENT', 'expIn must be a positive integer (seconds)')\n\t}\n\n\tconst { sk, pk } = deriveSigner(params.seed)\n\tconst nowMs = params.now ?? Date.now()\n\tconst exp = Math.floor(nowMs / 1000) + params.expIn\n\n\t// IMPORTANT: object literal order (aud, then exp) fixes the JSON byte layout.\n\tconst jsonBytes = utf8ToBytes(JSON.stringify({ aud: params.aud, exp }))\n\tconst signed = concatBytes(jsonBytes, pk)\n\tconst signature = signHashed(signed, sk, API_KEY_DST)\n\tconst token = concatBytes(jsonBytes, pk, signature)\n\n\treturn { apiKey: toBase58(token), payload: { aud: params.aud, exp } }\n}\n\nexport interface DecodedApiKey {\n\tpayload: ApiKeyPayload\n\tpublicKey: Uint8Array\n\tsignature: Uint8Array\n\t/** The raw JSON bytes that were signed — needed to re-verify exactly. */\n\tjsonBytes: Uint8Array\n\t/** The signing address (Base58 of `publicKey`). */\n\taddress: string\n}\n\n/** Parse a token into its parts. Throws `WalletSdkError('INVALID_API_KEY')` on malformed input. */\nexport function decodeApiKey(apiKey: string): DecodedApiKey {\n\t// Bound untrusted input BEFORE the quadratic Base58 decode so an oversized\n\t// string can't stall the verifier (event-loop DoS).\n\tif (\n\t\ttypeof apiKey !== 'string' ||\n\t\tapiKey.length === 0 ||\n\t\tapiKey.length > MAX_API_KEY_STRING_LENGTH\n\t) {\n\t\tthrow new WalletSdkError('INVALID_API_KEY', 'api key length is out of range')\n\t}\n\n\tlet raw: Uint8Array\n\ttry {\n\t\traw = fromBase58(apiKey)\n\t} catch {\n\t\tthrow new WalletSdkError('INVALID_API_KEY', 'api key is not valid Base58')\n\t}\n\n\tconst jsonEnd = raw.length - PUBLIC_KEY_BYTE_LENGTH - SIGNATURE_BYTE_LENGTH\n\tif (jsonEnd <= 0) {\n\t\tthrow new WalletSdkError('INVALID_API_KEY', 'api key is too short to contain a payload')\n\t}\n\n\tconst jsonBytes = raw.slice(0, jsonEnd)\n\tconst publicKey = raw.slice(jsonEnd, jsonEnd + PUBLIC_KEY_BYTE_LENGTH)\n\tconst signature = raw.slice(jsonEnd + PUBLIC_KEY_BYTE_LENGTH)\n\n\tlet parsed: unknown\n\ttry {\n\t\tparsed = JSON.parse(bytesToUtf8(jsonBytes))\n\t} catch {\n\t\tthrow new WalletSdkError('INVALID_API_KEY', 'api key payload is not valid JSON')\n\t}\n\n\tif (\n\t\ttypeof parsed !== 'object' ||\n\t\tparsed === null ||\n\t\ttypeof (parsed as ApiKeyPayload).aud !== 'string' ||\n\t\ttypeof (parsed as ApiKeyPayload).exp !== 'number' ||\n\t\t!Number.isFinite((parsed as ApiKeyPayload).exp)\n\t) {\n\t\tthrow new WalletSdkError(\n\t\t\t'INVALID_API_KEY',\n\t\t\t'api key payload must be { aud: string, exp: number }'\n\t\t)\n\t}\n\n\tconst payload = parsed as ApiKeyPayload\n\treturn { payload, publicKey, signature, jsonBytes, address: toBase58(publicKey) }\n}\n\nexport interface VerifyApiKeyOptions {\n\t/** If provided, the token's `aud` must equal this. */\n\taud?: string\n\t/** Override \"now\" (ms since epoch) — for deterministic tests. */\n\tnow?: number\n\t/** Treat the token as expired this many seconds early (clock-skew guard). Default 0. */\n\tleewaySeconds?: number\n}\n\nexport type VerifyApiKeyResult =\n\t| { valid: true; payload: ApiKeyPayload; address: string }\n\t| { valid: false; reason: 'malformed' | 'bad_signature' | 'expired' | 'aud_mismatch' }\n\n/**\n * Full verification: structure -> BLS signature (under the API-key DST, with the\n * pubkey folded in) -> expiry -> optional audience. Returns a discriminated\n * result rather than throwing on the common \"invalid\" paths.\n */\nexport function verifyApiKey(\n\tapiKey: string,\n\toptions: VerifyApiKeyOptions = {}\n): VerifyApiKeyResult {\n\tlet decoded: DecodedApiKey\n\ttry {\n\t\tdecoded = decodeApiKey(apiKey)\n\t} catch {\n\t\treturn { valid: false, reason: 'malformed' }\n\t}\n\n\tconst signed = concatBytes(decoded.jsonBytes, decoded.publicKey)\n\tif (!verifyHashed(decoded.signature, signed, decoded.publicKey, API_KEY_DST)) {\n\t\treturn { valid: false, reason: 'bad_signature' }\n\t}\n\n\tconst nowSec = Math.floor((options.now ?? Date.now()) / 1000)\n\tconst leeway = options.leewaySeconds ?? 0\n\tif (decoded.payload.exp <= nowSec + leeway) {\n\t\treturn { valid: false, reason: 'expired' }\n\t}\n\n\tif (options.aud !== undefined && decoded.payload.aud !== options.aud) {\n\t\treturn { valid: false, reason: 'aud_mismatch' }\n\t}\n\n\treturn { valid: true, payload: decoded.payload, address: decoded.address }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,eAAe,QAAoD;CAClF,IAAI,CAAC,OAAO,OAAO,OAAO,IAAI,WAAW,GACxC,MAAM,IAAI,eAAe,oBAAoB,iBAAiB;CAE/D,IAAI,CAAC,OAAO,UAAU,OAAO,KAAK,KAAK,OAAO,SAAS,GACtD,MAAM,IAAI,eAAe,oBAAoB,4CAA4C;CAG1F,MAAM,EAAE,IAAI,OAAO,aAAa,OAAO,IAAI;CAC3C,MAAM,QAAQ,OAAO,OAAO,KAAK,IAAI;CACrC,MAAM,MAAM,KAAK,MAAM,QAAQ,GAAI,IAAI,OAAO;CAG9C,MAAM,YAAY,YAAY,KAAK,UAAU;EAAE,KAAK,OAAO;EAAK;CAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"apikey.js","names":[],"sources":["../../src/crypto/apikey.ts"],"sourcesContent":["/**\n * BLS12-381 API-key bearer tokens — the ONE audited implementation, replacing\n * the byte-identical copies currently hand-rolled in the wallet extension\n * (`background/handlers/api-key.ts`) and hub/prime-hub (`utils/blsWallet.ts`).\n *\n * Token layout (concatenated, then Base58-encoded):\n * [ jsonBytes (variable) | pubkey (48) | signature (96) ]\n *\n * jsonBytes = utf8(JSON.stringify({ aud, exp })) // key order: aud THEN exp\n * exp = floor(now/1000) + expIn // unix seconds\n * signature = BLS.sign(sha256(jsonBytes || pubkey), sk, { DST: API_KEY_DST })\n *\n * Folding the pubkey into the signed hash blocks rogue-key attacks. `kbs.ama.one`\n * verifies against exactly this construction — do not alter the field order,\n * concatenation, or DST.\n */\n\nimport { fromBase58, toBase58 } from '@amadeus-protocol/sdk'\n\nimport {\n\tAPI_KEY_DST,\n\tMAX_API_KEY_STRING_LENGTH,\n\tPUBLIC_KEY_BYTE_LENGTH,\n\tSIGNATURE_BYTE_LENGTH\n} from '../constants'\nimport { WalletSdkError } from '../errors'\nimport { bytesToUtf8, concatBytes, utf8ToBytes } from '../bytes'\nimport { deriveSigner, signHashed, verifyHashed } from './bls'\n\nexport interface ApiKeyPayload {\n\taud: string\n\texp: number\n}\n\nexport interface GenerateApiKeyParams {\n\t/** Base58 wallet seed (private key). */\n\tseed: string\n\t/** Audience claim the bearer will present to. */\n\taud: string\n\t/** Lifetime in seconds from now. */\n\texpIn: number\n\t/** Override \"now\" (ms since epoch) — for deterministic tests. */\n\tnow?: number\n}\n\nexport interface GenerateApiKeyResult {\n\tapiKey: string\n\tpayload: ApiKeyPayload\n}\n\nexport function generateApiKey(params: GenerateApiKeyParams): GenerateApiKeyResult {\n\tif (!params.aud || params.aud.length === 0) {\n\t\tthrow new WalletSdkError('INVALID_ARGUMENT', 'aud is required')\n\t}\n\tif (!Number.isInteger(params.expIn) || params.expIn <= 0) {\n\t\tthrow new WalletSdkError('INVALID_ARGUMENT', 'expIn must be a positive integer (seconds)')\n\t}\n\n\tconst { sk, pk } = deriveSigner(params.seed)\n\tconst nowMs = params.now ?? Date.now()\n\tconst exp = Math.floor(nowMs / 1000) + params.expIn\n\n\t// IMPORTANT: object literal order (aud, then exp) fixes the JSON byte layout.\n\tconst jsonBytes = utf8ToBytes(JSON.stringify({ aud: params.aud, exp }))\n\tconst signed = concatBytes(jsonBytes, pk)\n\tconst signature = signHashed(signed, sk, API_KEY_DST)\n\tconst token = concatBytes(jsonBytes, pk, signature)\n\n\treturn { apiKey: toBase58(token), payload: { aud: params.aud, exp } }\n}\n\nexport interface DecodedApiKey {\n\tpayload: ApiKeyPayload\n\tpublicKey: Uint8Array\n\tsignature: Uint8Array\n\t/** The raw JSON bytes that were signed — needed to re-verify exactly. */\n\tjsonBytes: Uint8Array\n\t/** The signing address (Base58 of `publicKey`). */\n\taddress: string\n}\n\n/** Parse a token into its parts. Throws `WalletSdkError('INVALID_API_KEY')` on malformed input. */\nexport function decodeApiKey(apiKey: string): DecodedApiKey {\n\t// Bound untrusted input BEFORE the quadratic Base58 decode so an oversized\n\t// string can't stall the verifier (event-loop DoS).\n\tif (\n\t\ttypeof apiKey !== 'string' ||\n\t\tapiKey.length === 0 ||\n\t\tapiKey.length > MAX_API_KEY_STRING_LENGTH\n\t) {\n\t\tthrow new WalletSdkError('INVALID_API_KEY', 'api key length is out of range')\n\t}\n\n\tlet raw: Uint8Array\n\ttry {\n\t\traw = fromBase58(apiKey)\n\t} catch {\n\t\tthrow new WalletSdkError('INVALID_API_KEY', 'api key is not valid Base58')\n\t}\n\n\tconst jsonEnd = raw.length - PUBLIC_KEY_BYTE_LENGTH - SIGNATURE_BYTE_LENGTH\n\tif (jsonEnd <= 0) {\n\t\tthrow new WalletSdkError('INVALID_API_KEY', 'api key is too short to contain a payload')\n\t}\n\n\tconst jsonBytes = raw.slice(0, jsonEnd)\n\tconst publicKey = raw.slice(jsonEnd, jsonEnd + PUBLIC_KEY_BYTE_LENGTH)\n\tconst signature = raw.slice(jsonEnd + PUBLIC_KEY_BYTE_LENGTH)\n\n\tlet parsed: unknown\n\ttry {\n\t\tparsed = JSON.parse(bytesToUtf8(jsonBytes))\n\t} catch {\n\t\tthrow new WalletSdkError('INVALID_API_KEY', 'api key payload is not valid JSON')\n\t}\n\n\tif (\n\t\ttypeof parsed !== 'object' ||\n\t\tparsed === null ||\n\t\ttypeof (parsed as ApiKeyPayload).aud !== 'string' ||\n\t\ttypeof (parsed as ApiKeyPayload).exp !== 'number' ||\n\t\t!Number.isFinite((parsed as ApiKeyPayload).exp)\n\t) {\n\t\tthrow new WalletSdkError(\n\t\t\t'INVALID_API_KEY',\n\t\t\t'api key payload must be { aud: string, exp: number }'\n\t\t)\n\t}\n\n\tconst payload = parsed as ApiKeyPayload\n\treturn { payload, publicKey, signature, jsonBytes, address: toBase58(publicKey) }\n}\n\nexport interface VerifyApiKeyOptions {\n\t/** If provided, the token's `aud` must equal this. */\n\taud?: string\n\t/** Override \"now\" (ms since epoch) — for deterministic tests. */\n\tnow?: number\n\t/** Treat the token as expired this many seconds early (clock-skew guard). Default 0. */\n\tleewaySeconds?: number\n}\n\nexport type VerifyApiKeyResult =\n\t| { valid: true; payload: ApiKeyPayload; address: string }\n\t| { valid: false; reason: 'malformed' | 'bad_signature' | 'expired' | 'aud_mismatch' }\n\n/**\n * Full verification: structure -> BLS signature (under the API-key DST, with the\n * pubkey folded in) -> expiry -> optional audience. Returns a discriminated\n * result rather than throwing on the common \"invalid\" paths.\n */\nexport function verifyApiKey(\n\tapiKey: string,\n\toptions: VerifyApiKeyOptions = {}\n): VerifyApiKeyResult {\n\tlet decoded: DecodedApiKey\n\ttry {\n\t\tdecoded = decodeApiKey(apiKey)\n\t} catch {\n\t\treturn { valid: false, reason: 'malformed' }\n\t}\n\n\tconst signed = concatBytes(decoded.jsonBytes, decoded.publicKey)\n\tif (!verifyHashed(decoded.signature, signed, decoded.publicKey, API_KEY_DST)) {\n\t\treturn { valid: false, reason: 'bad_signature' }\n\t}\n\n\tconst nowSec = Math.floor((options.now ?? Date.now()) / 1000)\n\tconst leeway = options.leewaySeconds ?? 0\n\tif (decoded.payload.exp <= nowSec + leeway) {\n\t\treturn { valid: false, reason: 'expired' }\n\t}\n\n\tif (options.aud !== undefined && decoded.payload.aud !== options.aud) {\n\t\treturn { valid: false, reason: 'aud_mismatch' }\n\t}\n\n\treturn { valid: true, payload: decoded.payload, address: decoded.address }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAgB,eAAe,QAAoD;CAClF,IAAI,CAAC,OAAO,OAAO,OAAO,IAAI,WAAW,GACxC,MAAM,IAAI,eAAe,oBAAoB,iBAAiB;CAE/D,IAAI,CAAC,OAAO,UAAU,OAAO,KAAK,KAAK,OAAO,SAAS,GACtD,MAAM,IAAI,eAAe,oBAAoB,4CAA4C;CAG1F,MAAM,EAAE,IAAI,OAAO,aAAa,OAAO,IAAI;CAC3C,MAAM,QAAQ,OAAO,OAAO,KAAK,IAAI;CACrC,MAAM,MAAM,KAAK,MAAM,QAAQ,GAAI,IAAI,OAAO;CAG9C,MAAM,YAAY,YAAY,KAAK,UAAU;EAAE,KAAK,OAAO;EAAK;CAAI,CAAC,CAAC;CACtE,MAAM,SAAS,YAAY,WAAW,EAAE;CACxC,MAAM,YAAY,WAAW,QAAQ,IAAI,WAAW;CACpD,MAAM,QAAQ,YAAY,WAAW,IAAI,SAAS;CAElD,OAAO;EAAE,QAAQ,SAAS,KAAK;EAAG,SAAS;GAAE,KAAK,OAAO;GAAK;EAAI;CAAE;AACrE;;AAaA,SAAgB,aAAa,QAA+B;CAG3D,IACC,OAAO,WAAW,YAClB,OAAO,WAAW,KAClB,OAAO,SAAA,MAEP,MAAM,IAAI,eAAe,mBAAmB,gCAAgC;CAG7E,IAAI;CACJ,IAAI;EACH,MAAM,WAAW,MAAM;CACxB,QAAQ;EACP,MAAM,IAAI,eAAe,mBAAmB,6BAA6B;CAC1E;CAEA,MAAM,UAAU,IAAI,SAAA,KAAA;CACpB,IAAI,WAAW,GACd,MAAM,IAAI,eAAe,mBAAmB,2CAA2C;CAGxF,MAAM,YAAY,IAAI,MAAM,GAAG,OAAO;CACtC,MAAM,YAAY,IAAI,MAAM,SAAS,UAAA,EAAgC;CACrE,MAAM,YAAY,IAAI,MAAM,UAAA,EAAgC;CAE5D,IAAI;CACJ,IAAI;EACH,SAAS,KAAK,MAAM,YAAY,SAAS,CAAC;CAC3C,QAAQ;EACP,MAAM,IAAI,eAAe,mBAAmB,mCAAmC;CAChF;CAEA,IACC,OAAO,WAAW,YAClB,WAAW,QACX,OAAQ,OAAyB,QAAQ,YACzC,OAAQ,OAAyB,QAAQ,YACzC,CAAC,OAAO,SAAU,OAAyB,GAAG,GAE9C,MAAM,IAAI,eACT,mBACA,sDACD;CAID,OAAO;EAAE,SAAA;EAAS;EAAW;EAAW;EAAW,SAAS,SAAS,SAAS;CAAE;AACjF;;;;;;AAoBA,SAAgB,aACf,QACA,UAA+B,CAAC,GACX;CACrB,IAAI;CACJ,IAAI;EACH,UAAU,aAAa,MAAM;CAC9B,QAAQ;EACP,OAAO;GAAE,OAAO;GAAO,QAAQ;EAAY;CAC5C;CAEA,MAAM,SAAS,YAAY,QAAQ,WAAW,QAAQ,SAAS;CAC/D,IAAI,CAAC,aAAa,QAAQ,WAAW,QAAQ,QAAQ,WAAA,oDAAsB,GAC1E,OAAO;EAAE,OAAO;EAAO,QAAQ;CAAgB;CAGhD,MAAM,SAAS,KAAK,OAAO,QAAQ,OAAO,KAAK,IAAI,KAAK,GAAI;CAC5D,MAAM,SAAS,QAAQ,iBAAiB;CACxC,IAAI,QAAQ,QAAQ,OAAO,SAAS,QACnC,OAAO;EAAE,OAAO;EAAO,QAAQ;CAAU;CAG1C,IAAI,QAAQ,QAAQ,KAAA,KAAa,QAAQ,QAAQ,QAAQ,QAAQ,KAChE,OAAO;EAAE,OAAO;EAAO,QAAQ;CAAe;CAG/C,OAAO;EAAE,OAAO;EAAM,SAAS,QAAQ;EAAS,SAAS,QAAQ;CAAQ;AAC1E"}
|
package/dist/crypto/bls.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/crypto/bls.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Low-level BLS12-381 signing primitives, mirroring the exact recipe used by
|
|
4
3
|
* `@amadeus-protocol/sdk` (`signing.ts`) and the wallet extension: hash the
|
|
@@ -26,6 +25,5 @@ declare function verifyHashed(signature: Uint8Array, payload: Uint8Array, public
|
|
|
26
25
|
declare function publicKeyFromAddress(address: string): Uint8Array;
|
|
27
26
|
/** Decode a Base58 signature into its 96 raw bytes, validating length. */
|
|
28
27
|
declare function signatureFromBase58(signature: string): Uint8Array;
|
|
29
|
-
//#endregion
|
|
30
28
|
export { SignerKeys, deriveSigner, publicKeyFromAddress, signHashed, signatureFromBase58, verifyHashed };
|
|
31
29
|
//# sourceMappingURL=bls.d.ts.map
|
package/dist/crypto/bls.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bls.d.ts","names":[],"sources":["../../src/crypto/bls.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"bls.d.ts","names":[],"sources":["../../src/crypto/bls.ts"],"mappings":";;;;;;;;UAgBiB;;EAEhB,IAAI;;EAEJ,IAAI;;;iBAIW,aAAa,qBAAqB;;;;;iBAUlC,WAAW,SAAS,YAAY,IAAI,YAAY,cAAc;;iBAM9D,aACf,WAAW,YACX,SAAS,YACT,WAAW,YACX;;iBAWe,qBAAqB,kBAAkB;;iBAiBvC,oBAAoB,oBAAoB"}
|
package/dist/crypto/bls.js
CHANGED
|
@@ -3,7 +3,7 @@ import { WalletSdkError } from "../errors.js";
|
|
|
3
3
|
import { deriveSkAndSeed64FromBase58Seed, fromBase58, getPublicKey } from "@amadeus-protocol/sdk";
|
|
4
4
|
import { bls12_381 } from "@noble/curves/bls12-381";
|
|
5
5
|
import { sha256 } from "@noble/hashes/sha2";
|
|
6
|
-
|
|
6
|
+
// src/crypto/bls.ts
|
|
7
7
|
/**
|
|
8
8
|
* Low-level BLS12-381 signing primitives, mirroring the exact recipe used by
|
|
9
9
|
* `@amadeus-protocol/sdk` (`signing.ts`) and the wallet extension: hash the
|
|
@@ -59,7 +59,6 @@ function signatureFromBase58(signature) {
|
|
|
59
59
|
if (sig.length !== 96) throw new WalletSdkError("INVALID_SIGNATURE", `signature must be 96 bytes, got ${sig.length}`);
|
|
60
60
|
return sig;
|
|
61
61
|
}
|
|
62
|
-
//#endregion
|
|
63
62
|
export { deriveSigner, publicKeyFromAddress, signHashed, signatureFromBase58, verifyHashed };
|
|
64
63
|
|
|
65
64
|
//# sourceMappingURL=bls.js.map
|
package/dist/crypto/box.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/crypto/box.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* End-to-end encrypted session channel for cross-device transports (QR / bridge).
|
|
4
3
|
*
|
|
@@ -38,6 +37,5 @@ declare function seal(sharedKey: Uint8Array, plaintext: Uint8Array, aad?: Uint8A
|
|
|
38
37
|
* i.e. it fails closed.
|
|
39
38
|
*/
|
|
40
39
|
declare function open(sharedKey: Uint8Array, envelope: SealedEnvelope, aad?: Uint8Array): Uint8Array;
|
|
41
|
-
//#endregion
|
|
42
40
|
export { SealedEnvelope, SessionKeypair, deriveSharedKey, generateSessionKeypair, open, seal };
|
|
43
41
|
//# sourceMappingURL=box.d.ts.map
|
package/dist/crypto/box.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box.d.ts","names":[],"sources":["../../src/crypto/box.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"box.d.ts","names":[],"sources":["../../src/crypto/box.ts"],"mappings":";;;;;;;;;;;;UA0BiB;;EAEhB;;EAEA,WAAW;;;iBAII,0BAA0B;;;;;iBAU1B,gBAAgB,8BAA8B,aAAa,aAAa;UAyBvE;;EAEhB;;EAEA;;;iBAIe,KACf,WAAW,YACX,WAAW,YACX,MAAM,aACJ;;;;;;iBAWa,KACf,WAAW,YACX,UAAU,gBACV,MAAM,aACJ"}
|
package/dist/crypto/box.js
CHANGED
|
@@ -5,7 +5,7 @@ import { fromBase58, toBase58 } from "@amadeus-protocol/sdk";
|
|
|
5
5
|
import { sha256 } from "@noble/hashes/sha2";
|
|
6
6
|
import { xchacha20poly1305 } from "@noble/ciphers/chacha.js";
|
|
7
7
|
import { x25519 } from "@noble/curves/ed25519";
|
|
8
|
-
|
|
8
|
+
// src/crypto/box.ts
|
|
9
9
|
/**
|
|
10
10
|
* End-to-end encrypted session channel for cross-device transports (QR / bridge).
|
|
11
11
|
*
|
|
@@ -21,8 +21,9 @@ import { x25519 } from "@noble/curves/ed25519";
|
|
|
21
21
|
/** Generate a fresh ephemeral x25519 session keypair. */
|
|
22
22
|
function generateSessionKeypair() {
|
|
23
23
|
const secretKey = randomBytes(32);
|
|
24
|
+
const publicKey = x25519.getPublicKey(secretKey);
|
|
24
25
|
return {
|
|
25
|
-
publicKey: toBase58(
|
|
26
|
+
publicKey: toBase58(publicKey),
|
|
26
27
|
secretKey
|
|
27
28
|
};
|
|
28
29
|
}
|
|
@@ -76,7 +77,6 @@ function open(sharedKey, envelope, aad) {
|
|
|
76
77
|
throw new WalletSdkError("DECRYPT_FAILED", "authentication failed (wrong key or tampered)");
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
|
-
//#endregion
|
|
80
80
|
export { deriveSharedKey, generateSessionKeypair, open, seal };
|
|
81
81
|
|
|
82
82
|
//# sourceMappingURL=box.js.map
|
package/dist/crypto/box.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box.js","names":[],"sources":["../../src/crypto/box.ts"],"sourcesContent":["/**\n * End-to-end encrypted session channel for cross-device transports (QR / bridge).\n *\n * Each side holds an ephemeral x25519 keypair; the shared secret is derived via\n * ECDH and run through SHA-256 into a 32-byte symmetric key, then messages are\n * sealed with XChaCha20-Poly1305 (24-byte random nonce per message, AEAD auth\n * tag). This stack is Hermes-safe — it reuses the same `@noble` crypto the mobile\n * app already ships, and the CSPRNG is the platform `crypto.getRandomValues`.\n *\n * The x25519 keypair here is ONLY for transport encryption. It is completely\n * separate from the wallet's BLS signing key — never conflate them.\n */\n\nimport { fromBase58, toBase58 } from '@amadeus-protocol/sdk'\nimport { xchacha20poly1305 } from '@noble/ciphers/chacha.js'\nimport { x25519 } from '@noble/curves/ed25519'\nimport { sha256 } from '@noble/hashes/sha2'\n\nimport {\n\tSESSION_NONCE_BYTE_LENGTH,\n\tSESSION_PUBLIC_KEY_BYTE_LENGTH,\n\tSESSION_SECRET_KEY_BYTE_LENGTH\n} from '../constants'\nimport { randomBytes } from '../bytes'\nimport { WalletSdkError } from '../errors'\n\nexport interface SessionKeypair {\n\t/** x25519 public key (Base58) — safe to send in the clear (in the QR / link). */\n\tpublicKey: string\n\t/** x25519 secret key (32 raw bytes) — keep in memory only, never persist. */\n\tsecretKey: Uint8Array\n}\n\n/** Generate a fresh ephemeral x25519 session keypair. */\nexport function generateSessionKeypair(): SessionKeypair {\n\tconst secretKey = randomBytes(SESSION_SECRET_KEY_BYTE_LENGTH)\n\tconst publicKey = x25519.getPublicKey(secretKey)\n\treturn { publicKey: toBase58(publicKey), secretKey }\n}\n\n/**\n * Derive the 32-byte symmetric key shared with a peer. Both sides call this with\n * (their own secret, the other's public) and get the same key.\n */\nexport function deriveSharedKey(theirPublicKeyBase58: string, mySecretKey: Uint8Array): Uint8Array {\n\tlet theirPublicKey: Uint8Array\n\ttry {\n\t\ttheirPublicKey = fromBase58(theirPublicKeyBase58)\n\t} catch {\n\t\tthrow new WalletSdkError('DECRYPT_FAILED', 'peer public key is not valid Base58')\n\t}\n\tif (theirPublicKey.length !== SESSION_PUBLIC_KEY_BYTE_LENGTH) {\n\t\tthrow new WalletSdkError('DECRYPT_FAILED', 'peer public key has the wrong length')\n\t}\n\t// noble rejects low-order / all-zero points by throwing — normalize that (and\n\t// any other malformed-key throw) to the module's fail-closed error type so the\n\t// whole path fails closed on a hostile peer key rather than leaking a raw Error.\n\tlet shared: Uint8Array\n\ttry {\n\t\tshared = x25519.getSharedSecret(mySecretKey, theirPublicKey)\n\t} catch {\n\t\tthrow new WalletSdkError(\n\t\t\t'DECRYPT_FAILED',\n\t\t\t'invalid peer public key (low-order or malformed)'\n\t\t)\n\t}\n\treturn sha256(shared)\n}\n\nexport interface SealedEnvelope {\n\t/** Base58 24-byte nonce. */\n\tnonce: string\n\t/** Base58 ciphertext (includes the Poly1305 auth tag). */\n\tciphertext: string\n}\n\n/** Seal plaintext with the shared key. Optional `aad` is authenticated but not encrypted. */\nexport function seal(\n\tsharedKey: Uint8Array,\n\tplaintext: Uint8Array,\n\taad?: Uint8Array\n): SealedEnvelope {\n\tconst nonce = randomBytes(SESSION_NONCE_BYTE_LENGTH)\n\tconst ciphertext = xchacha20poly1305(sharedKey, nonce, aad).encrypt(plaintext)\n\treturn { nonce: toBase58(nonce), ciphertext: toBase58(ciphertext) }\n}\n\n/**\n * Open a sealed envelope. Throws `WalletSdkError('DECRYPT_FAILED')` if the key is\n * wrong, the ciphertext/aad was tampered with, or the envelope is malformed —\n * i.e. it fails closed.\n */\nexport function open(\n\tsharedKey: Uint8Array,\n\tenvelope: SealedEnvelope,\n\taad?: Uint8Array\n): Uint8Array {\n\tlet nonce: Uint8Array\n\tlet ciphertext: Uint8Array\n\ttry {\n\t\tnonce = fromBase58(envelope.nonce)\n\t\tciphertext = fromBase58(envelope.ciphertext)\n\t} catch {\n\t\tthrow new WalletSdkError('DECRYPT_FAILED', 'sealed envelope is not valid Base58')\n\t}\n\tif (nonce.length !== SESSION_NONCE_BYTE_LENGTH) {\n\t\tthrow new WalletSdkError('DECRYPT_FAILED', 'nonce has the wrong length')\n\t}\n\ttry {\n\t\treturn xchacha20poly1305(sharedKey, nonce, aad).decrypt(ciphertext)\n\t} catch {\n\t\tthrow new WalletSdkError('DECRYPT_FAILED', 'authentication failed (wrong key or tampered)')\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,yBAAyC;CACxD,MAAM,YAAY,YAAA,EAA0C;
|
|
1
|
+
{"version":3,"file":"box.js","names":[],"sources":["../../src/crypto/box.ts"],"sourcesContent":["/**\n * End-to-end encrypted session channel for cross-device transports (QR / bridge).\n *\n * Each side holds an ephemeral x25519 keypair; the shared secret is derived via\n * ECDH and run through SHA-256 into a 32-byte symmetric key, then messages are\n * sealed with XChaCha20-Poly1305 (24-byte random nonce per message, AEAD auth\n * tag). This stack is Hermes-safe — it reuses the same `@noble` crypto the mobile\n * app already ships, and the CSPRNG is the platform `crypto.getRandomValues`.\n *\n * The x25519 keypair here is ONLY for transport encryption. It is completely\n * separate from the wallet's BLS signing key — never conflate them.\n */\n\nimport { fromBase58, toBase58 } from '@amadeus-protocol/sdk'\nimport { xchacha20poly1305 } from '@noble/ciphers/chacha.js'\nimport { x25519 } from '@noble/curves/ed25519'\nimport { sha256 } from '@noble/hashes/sha2'\n\nimport {\n\tSESSION_NONCE_BYTE_LENGTH,\n\tSESSION_PUBLIC_KEY_BYTE_LENGTH,\n\tSESSION_SECRET_KEY_BYTE_LENGTH\n} from '../constants'\nimport { randomBytes } from '../bytes'\nimport { WalletSdkError } from '../errors'\n\nexport interface SessionKeypair {\n\t/** x25519 public key (Base58) — safe to send in the clear (in the QR / link). */\n\tpublicKey: string\n\t/** x25519 secret key (32 raw bytes) — keep in memory only, never persist. */\n\tsecretKey: Uint8Array\n}\n\n/** Generate a fresh ephemeral x25519 session keypair. */\nexport function generateSessionKeypair(): SessionKeypair {\n\tconst secretKey = randomBytes(SESSION_SECRET_KEY_BYTE_LENGTH)\n\tconst publicKey = x25519.getPublicKey(secretKey)\n\treturn { publicKey: toBase58(publicKey), secretKey }\n}\n\n/**\n * Derive the 32-byte symmetric key shared with a peer. Both sides call this with\n * (their own secret, the other's public) and get the same key.\n */\nexport function deriveSharedKey(theirPublicKeyBase58: string, mySecretKey: Uint8Array): Uint8Array {\n\tlet theirPublicKey: Uint8Array\n\ttry {\n\t\ttheirPublicKey = fromBase58(theirPublicKeyBase58)\n\t} catch {\n\t\tthrow new WalletSdkError('DECRYPT_FAILED', 'peer public key is not valid Base58')\n\t}\n\tif (theirPublicKey.length !== SESSION_PUBLIC_KEY_BYTE_LENGTH) {\n\t\tthrow new WalletSdkError('DECRYPT_FAILED', 'peer public key has the wrong length')\n\t}\n\t// noble rejects low-order / all-zero points by throwing — normalize that (and\n\t// any other malformed-key throw) to the module's fail-closed error type so the\n\t// whole path fails closed on a hostile peer key rather than leaking a raw Error.\n\tlet shared: Uint8Array\n\ttry {\n\t\tshared = x25519.getSharedSecret(mySecretKey, theirPublicKey)\n\t} catch {\n\t\tthrow new WalletSdkError(\n\t\t\t'DECRYPT_FAILED',\n\t\t\t'invalid peer public key (low-order or malformed)'\n\t\t)\n\t}\n\treturn sha256(shared)\n}\n\nexport interface SealedEnvelope {\n\t/** Base58 24-byte nonce. */\n\tnonce: string\n\t/** Base58 ciphertext (includes the Poly1305 auth tag). */\n\tciphertext: string\n}\n\n/** Seal plaintext with the shared key. Optional `aad` is authenticated but not encrypted. */\nexport function seal(\n\tsharedKey: Uint8Array,\n\tplaintext: Uint8Array,\n\taad?: Uint8Array\n): SealedEnvelope {\n\tconst nonce = randomBytes(SESSION_NONCE_BYTE_LENGTH)\n\tconst ciphertext = xchacha20poly1305(sharedKey, nonce, aad).encrypt(plaintext)\n\treturn { nonce: toBase58(nonce), ciphertext: toBase58(ciphertext) }\n}\n\n/**\n * Open a sealed envelope. Throws `WalletSdkError('DECRYPT_FAILED')` if the key is\n * wrong, the ciphertext/aad was tampered with, or the envelope is malformed —\n * i.e. it fails closed.\n */\nexport function open(\n\tsharedKey: Uint8Array,\n\tenvelope: SealedEnvelope,\n\taad?: Uint8Array\n): Uint8Array {\n\tlet nonce: Uint8Array\n\tlet ciphertext: Uint8Array\n\ttry {\n\t\tnonce = fromBase58(envelope.nonce)\n\t\tciphertext = fromBase58(envelope.ciphertext)\n\t} catch {\n\t\tthrow new WalletSdkError('DECRYPT_FAILED', 'sealed envelope is not valid Base58')\n\t}\n\tif (nonce.length !== SESSION_NONCE_BYTE_LENGTH) {\n\t\tthrow new WalletSdkError('DECRYPT_FAILED', 'nonce has the wrong length')\n\t}\n\ttry {\n\t\treturn xchacha20poly1305(sharedKey, nonce, aad).decrypt(ciphertext)\n\t} catch {\n\t\tthrow new WalletSdkError('DECRYPT_FAILED', 'authentication failed (wrong key or tampered)')\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,SAAgB,yBAAyC;CACxD,MAAM,YAAY,YAAA,EAA0C;CAC5D,MAAM,YAAY,OAAO,aAAa,SAAS;CAC/C,OAAO;EAAE,WAAW,SAAS,SAAS;EAAG;CAAU;AACpD;;;;;AAMA,SAAgB,gBAAgB,sBAA8B,aAAqC;CAClG,IAAI;CACJ,IAAI;EACH,iBAAiB,WAAW,oBAAoB;CACjD,QAAQ;EACP,MAAM,IAAI,eAAe,kBAAkB,qCAAqC;CACjF;CACA,IAAI,eAAe,WAAA,IAClB,MAAM,IAAI,eAAe,kBAAkB,sCAAsC;CAKlF,IAAI;CACJ,IAAI;EACH,SAAS,OAAO,gBAAgB,aAAa,cAAc;CAC5D,QAAQ;EACP,MAAM,IAAI,eACT,kBACA,kDACD;CACD;CACA,OAAO,OAAO,MAAM;AACrB;;AAUA,SAAgB,KACf,WACA,WACA,KACiB;CACjB,MAAM,QAAQ,YAAA,EAAqC;CACnD,MAAM,aAAa,kBAAkB,WAAW,OAAO,GAAG,CAAC,CAAC,QAAQ,SAAS;CAC7E,OAAO;EAAE,OAAO,SAAS,KAAK;EAAG,YAAY,SAAS,UAAU;CAAE;AACnE;;;;;;AAOA,SAAgB,KACf,WACA,UACA,KACa;CACb,IAAI;CACJ,IAAI;CACJ,IAAI;EACH,QAAQ,WAAW,SAAS,KAAK;EACjC,aAAa,WAAW,SAAS,UAAU;CAC5C,QAAQ;EACP,MAAM,IAAI,eAAe,kBAAkB,qCAAqC;CACjF;CACA,IAAI,MAAM,WAAA,IACT,MAAM,IAAI,eAAe,kBAAkB,4BAA4B;CAExE,IAAI;EACH,OAAO,kBAAkB,WAAW,OAAO,GAAG,CAAC,CAAC,QAAQ,UAAU;CACnE,QAAQ;EACP,MAAM,IAAI,eAAe,kBAAkB,+CAA+C;CAC3F;AACD"}
|
package/dist/crypto/connect.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/crypto/connect.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Connection-auth signatures. When a dApp asks the wallet to connect, it must
|
|
4
3
|
* prove control of its address. The wallet signs a TRANSCRIPT that binds the
|
|
@@ -54,6 +53,5 @@ interface VerifyConnectParams {
|
|
|
54
53
|
* Never throws — returns false on any malformed input or verification failure.
|
|
55
54
|
*/
|
|
56
55
|
declare function verifyConnect(params: VerifyConnectParams): boolean;
|
|
57
|
-
//#endregion
|
|
58
56
|
export { ConnectTranscript, SignConnectParams, VerifyConnectParams, buildConnectTranscript, signConnect, verifyConnect };
|
|
59
57
|
//# sourceMappingURL=connect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","names":[],"sources":["../../src/crypto/connect.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.d.ts","names":[],"sources":["../../src/crypto/connect.ts"],"mappings":";;;;;;;;;;;;;;;UA4BiB;;EAEhB;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;;iBAWe,uBAAuB,YAAY,oBAAoB;UAiBtD;;EAEhB;EACA,YAAY;;;iBAIG,YAAY,QAAQ;UAMnB;;EAEhB;EACA,YAAY;;EAEZ;;;;;;iBAOe,cAAc,QAAQ"}
|
package/dist/crypto/connect.js
CHANGED
|
@@ -2,7 +2,7 @@ import { CONNECT_DST, CONNECT_TRANSCRIPT_LABEL } from "../constants.js";
|
|
|
2
2
|
import { concatBytes, u32be, utf8ToBytes } from "../bytes.js";
|
|
3
3
|
import { deriveSigner, publicKeyFromAddress, signHashed, signatureFromBase58, verifyHashed } from "./bls.js";
|
|
4
4
|
import { toBase58 } from "@amadeus-protocol/sdk";
|
|
5
|
-
|
|
5
|
+
// src/crypto/connect.ts
|
|
6
6
|
/**
|
|
7
7
|
* Connection-auth signatures. When a dApp asks the wallet to connect, it must
|
|
8
8
|
* prove control of its address. The wallet signs a TRANSCRIPT that binds the
|
|
@@ -49,7 +49,8 @@ function buildConnectTranscript(transcript) {
|
|
|
49
49
|
/** Wallet side: sign the transcript, returning a Base58 signature. */
|
|
50
50
|
function signConnect(params) {
|
|
51
51
|
const { sk } = deriveSigner(params.seed);
|
|
52
|
-
|
|
52
|
+
const signature = signHashed(buildConnectTranscript(params.transcript), sk, CONNECT_DST);
|
|
53
|
+
return toBase58(signature);
|
|
53
54
|
}
|
|
54
55
|
/**
|
|
55
56
|
* dApp side: verify the wallet controls `address` for this exact transcript.
|
|
@@ -66,7 +67,6 @@ function verifyConnect(params) {
|
|
|
66
67
|
}
|
|
67
68
|
return verifyHashed(signature, buildConnectTranscript(params.transcript), publicKey, CONNECT_DST);
|
|
68
69
|
}
|
|
69
|
-
//#endregion
|
|
70
70
|
export { buildConnectTranscript, signConnect, verifyConnect };
|
|
71
71
|
|
|
72
72
|
//# sourceMappingURL=connect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","names":[],"sources":["../../src/crypto/connect.ts"],"sourcesContent":["/**\n * Connection-auth signatures. When a dApp asks the wallet to connect, it must\n * prove control of its address. The wallet signs a TRANSCRIPT that binds the\n * whole handshake — origin, both x25519 session public keys, the dApp's\n * challenge, and the request id — NOT just the raw challenge nonce.\n *\n * Signing only the nonce is a key-substitution MITM: an attacker replays a\n * harvested `sig(challenge)` under their own session keys and ends up with a\n * fully-authenticated session. Binding the session keys + origin into the signed\n * bytes closes that, the same property SIWE / CAIP-122 rely on.\n *\n * The transcript is length-prefixed and label-tagged so its bytes are\n * unambiguous, and signed under `CONNECT_DST` so a connect proof can never be\n * reused as a transaction, api-key, or any other signature.\n */\n\nimport { toBase58 } from '@amadeus-protocol/sdk'\n\nimport { CONNECT_DST, CONNECT_TRANSCRIPT_LABEL } from '../constants'\nimport { concatBytes, u32be, utf8ToBytes } from '../bytes'\nimport {\n\tderiveSigner,\n\tpublicKeyFromAddress,\n\tsignatureFromBase58,\n\tsignHashed,\n\tverifyHashed\n} from './bls'\n\nexport interface ConnectTranscript {\n\t/** The dApp's origin, e.g. \"https://app.amadeus.xyz\". */\n\torigin: string\n\t/** The dApp's ephemeral x25519 session public key (Base58). */\n\tdappPublicKey: string\n\t/** The wallet's ephemeral x25519 session public key (Base58). */\n\twalletPublicKey: string\n\t/** Random challenge nonce chosen by the dApp. */\n\tchallenge: string\n\t/** Unique id for this connect request. */\n\trequestId: string\n}\n\n/**\n * Deterministic canonical bytes for a transcript. Identical inputs -> identical\n * bytes on both wallet and dApp (that's the whole point of a shared package).\n * Every element is length-prefixed (including the label) so field boundaries are\n * unambiguous — no concatenation/canonicalization ambiguity even if the label is\n * ever made dynamic. Layout: u32(labelLen) ++ label ++ u32(fieldCount) ++\n * for each field: u32(len) ++ utf8(field).\n */\nexport function buildConnectTranscript(transcript: ConnectTranscript): Uint8Array {\n\tconst fields = [\n\t\ttranscript.origin,\n\t\ttranscript.dappPublicKey,\n\t\ttranscript.walletPublicKey,\n\t\ttranscript.challenge,\n\t\ttranscript.requestId\n\t]\n\tconst label = utf8ToBytes(CONNECT_TRANSCRIPT_LABEL)\n\tconst parts: Uint8Array[] = [u32be(label.length), label, u32be(fields.length)]\n\tfor (const field of fields) {\n\t\tconst bytes = utf8ToBytes(field)\n\t\tparts.push(u32be(bytes.length), bytes)\n\t}\n\treturn concatBytes(...parts)\n}\n\nexport interface SignConnectParams {\n\t/** Base58 wallet seed (private key). */\n\tseed: string\n\ttranscript: ConnectTranscript\n}\n\n/** Wallet side: sign the transcript, returning a Base58 signature. */\nexport function signConnect(params: SignConnectParams): string {\n\tconst { sk } = deriveSigner(params.seed)\n\tconst signature = signHashed(buildConnectTranscript(params.transcript), sk, CONNECT_DST)\n\treturn toBase58(signature)\n}\n\nexport interface VerifyConnectParams {\n\t/** The address (Base58 public key) that claims to have signed. */\n\taddress: string\n\ttranscript: ConnectTranscript\n\t/** The Base58 signature returned by the wallet. */\n\tsignature: string\n}\n\n/**\n * dApp side: verify the wallet controls `address` for this exact transcript.\n * Never throws — returns false on any malformed input or verification failure.\n */\nexport function verifyConnect(params: VerifyConnectParams): boolean {\n\tlet publicKey: Uint8Array\n\tlet signature: Uint8Array\n\ttry {\n\t\tpublicKey = publicKeyFromAddress(params.address)\n\t\tsignature = signatureFromBase58(params.signature)\n\t} catch {\n\t\treturn false\n\t}\n\treturn verifyHashed(\n\t\tsignature,\n\t\tbuildConnectTranscript(params.transcript),\n\t\tpublicKey,\n\t\tCONNECT_DST\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,uBAAuB,YAA2C;CACjF,MAAM,SAAS;EACd,WAAW;EACX,WAAW;EACX,WAAW;EACX,WAAW;EACX,WAAW;CACZ;CACA,MAAM,QAAQ,YAAY,wBAAwB;CAClD,MAAM,QAAsB;EAAC,MAAM,MAAM,MAAM;EAAG;EAAO,MAAM,OAAO,MAAM;CAAC;CAC7E,KAAK,MAAM,SAAS,QAAQ;EAC3B,MAAM,QAAQ,YAAY,KAAK;EAC/B,MAAM,KAAK,MAAM,MAAM,MAAM,GAAG,KAAK;CACtC;CACA,OAAO,YAAY,GAAG,KAAK;AAC5B;;AASA,SAAgB,YAAY,QAAmC;CAC9D,MAAM,EAAE,OAAO,aAAa,OAAO,IAAI;
|
|
1
|
+
{"version":3,"file":"connect.js","names":[],"sources":["../../src/crypto/connect.ts"],"sourcesContent":["/**\n * Connection-auth signatures. When a dApp asks the wallet to connect, it must\n * prove control of its address. The wallet signs a TRANSCRIPT that binds the\n * whole handshake — origin, both x25519 session public keys, the dApp's\n * challenge, and the request id — NOT just the raw challenge nonce.\n *\n * Signing only the nonce is a key-substitution MITM: an attacker replays a\n * harvested `sig(challenge)` under their own session keys and ends up with a\n * fully-authenticated session. Binding the session keys + origin into the signed\n * bytes closes that, the same property SIWE / CAIP-122 rely on.\n *\n * The transcript is length-prefixed and label-tagged so its bytes are\n * unambiguous, and signed under `CONNECT_DST` so a connect proof can never be\n * reused as a transaction, api-key, or any other signature.\n */\n\nimport { toBase58 } from '@amadeus-protocol/sdk'\n\nimport { CONNECT_DST, CONNECT_TRANSCRIPT_LABEL } from '../constants'\nimport { concatBytes, u32be, utf8ToBytes } from '../bytes'\nimport {\n\tderiveSigner,\n\tpublicKeyFromAddress,\n\tsignatureFromBase58,\n\tsignHashed,\n\tverifyHashed\n} from './bls'\n\nexport interface ConnectTranscript {\n\t/** The dApp's origin, e.g. \"https://app.amadeus.xyz\". */\n\torigin: string\n\t/** The dApp's ephemeral x25519 session public key (Base58). */\n\tdappPublicKey: string\n\t/** The wallet's ephemeral x25519 session public key (Base58). */\n\twalletPublicKey: string\n\t/** Random challenge nonce chosen by the dApp. */\n\tchallenge: string\n\t/** Unique id for this connect request. */\n\trequestId: string\n}\n\n/**\n * Deterministic canonical bytes for a transcript. Identical inputs -> identical\n * bytes on both wallet and dApp (that's the whole point of a shared package).\n * Every element is length-prefixed (including the label) so field boundaries are\n * unambiguous — no concatenation/canonicalization ambiguity even if the label is\n * ever made dynamic. Layout: u32(labelLen) ++ label ++ u32(fieldCount) ++\n * for each field: u32(len) ++ utf8(field).\n */\nexport function buildConnectTranscript(transcript: ConnectTranscript): Uint8Array {\n\tconst fields = [\n\t\ttranscript.origin,\n\t\ttranscript.dappPublicKey,\n\t\ttranscript.walletPublicKey,\n\t\ttranscript.challenge,\n\t\ttranscript.requestId\n\t]\n\tconst label = utf8ToBytes(CONNECT_TRANSCRIPT_LABEL)\n\tconst parts: Uint8Array[] = [u32be(label.length), label, u32be(fields.length)]\n\tfor (const field of fields) {\n\t\tconst bytes = utf8ToBytes(field)\n\t\tparts.push(u32be(bytes.length), bytes)\n\t}\n\treturn concatBytes(...parts)\n}\n\nexport interface SignConnectParams {\n\t/** Base58 wallet seed (private key). */\n\tseed: string\n\ttranscript: ConnectTranscript\n}\n\n/** Wallet side: sign the transcript, returning a Base58 signature. */\nexport function signConnect(params: SignConnectParams): string {\n\tconst { sk } = deriveSigner(params.seed)\n\tconst signature = signHashed(buildConnectTranscript(params.transcript), sk, CONNECT_DST)\n\treturn toBase58(signature)\n}\n\nexport interface VerifyConnectParams {\n\t/** The address (Base58 public key) that claims to have signed. */\n\taddress: string\n\ttranscript: ConnectTranscript\n\t/** The Base58 signature returned by the wallet. */\n\tsignature: string\n}\n\n/**\n * dApp side: verify the wallet controls `address` for this exact transcript.\n * Never throws — returns false on any malformed input or verification failure.\n */\nexport function verifyConnect(params: VerifyConnectParams): boolean {\n\tlet publicKey: Uint8Array\n\tlet signature: Uint8Array\n\ttry {\n\t\tpublicKey = publicKeyFromAddress(params.address)\n\t\tsignature = signatureFromBase58(params.signature)\n\t} catch {\n\t\treturn false\n\t}\n\treturn verifyHashed(\n\t\tsignature,\n\t\tbuildConnectTranscript(params.transcript),\n\t\tpublicKey,\n\t\tCONNECT_DST\n\t)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,SAAgB,uBAAuB,YAA2C;CACjF,MAAM,SAAS;EACd,WAAW;EACX,WAAW;EACX,WAAW;EACX,WAAW;EACX,WAAW;CACZ;CACA,MAAM,QAAQ,YAAY,wBAAwB;CAClD,MAAM,QAAsB;EAAC,MAAM,MAAM,MAAM;EAAG;EAAO,MAAM,OAAO,MAAM;CAAC;CAC7E,KAAK,MAAM,SAAS,QAAQ;EAC3B,MAAM,QAAQ,YAAY,KAAK;EAC/B,MAAM,KAAK,MAAM,MAAM,MAAM,GAAG,KAAK;CACtC;CACA,OAAO,YAAY,GAAG,KAAK;AAC5B;;AASA,SAAgB,YAAY,QAAmC;CAC9D,MAAM,EAAE,OAAO,aAAa,OAAO,IAAI;CACvC,MAAM,YAAY,WAAW,uBAAuB,OAAO,UAAU,GAAG,IAAI,WAAW;CACvF,OAAO,SAAS,SAAS;AAC1B;;;;;AAcA,SAAgB,cAAc,QAAsC;CACnE,IAAI;CACJ,IAAI;CACJ,IAAI;EACH,YAAY,qBAAqB,OAAO,OAAO;EAC/C,YAAY,oBAAoB,OAAO,SAAS;CACjD,QAAQ;EACP,OAAO;CACR;CACA,OAAO,aACN,WACA,uBAAuB,OAAO,UAAU,GACxC,WACA,WACD;AACD"}
|
package/dist/crypto/message.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/crypto/message.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Arbitrary-message signing ("personal sign") — the wallet proves control of an
|
|
4
3
|
* account over a human-readable string (a login challenge, a terms acceptance, a
|
|
@@ -42,6 +41,5 @@ interface VerifyMessageParams {
|
|
|
42
41
|
* input (bad Base58, wrong length, over-long message) returns `false`.
|
|
43
42
|
*/
|
|
44
43
|
declare function verifyMessage(params: VerifyMessageParams): boolean;
|
|
45
|
-
//#endregion
|
|
46
44
|
export { SignMessageParams, SignMessageResult, VerifyMessageParams, signMessage, verifyMessage };
|
|
47
45
|
//# sourceMappingURL=message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","names":[],"sources":["../../src/crypto/message.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"message.d.ts","names":[],"sources":["../../src/crypto/message.ts"],"mappings":";;;;;;;;;;;;;;UAsBiB;;EAEhB;;EAEA;;UAGgB;;EAEhB;;EAEA;;EAEA;;;iBAiBe,YAAY,QAAQ,oBAAoB;UAOvC;;EAEhB;;EAEA;;EAEA;;;;;;iBAOe,cAAc,QAAQ"}
|
package/dist/crypto/message.js
CHANGED
|
@@ -3,7 +3,7 @@ import { WalletSdkError } from "../errors.js";
|
|
|
3
3
|
import { utf8ToBytes } from "../bytes.js";
|
|
4
4
|
import { deriveSigner, publicKeyFromAddress, signHashed, signatureFromBase58, verifyHashed } from "./bls.js";
|
|
5
5
|
import { toBase58 } from "@amadeus-protocol/sdk";
|
|
6
|
-
|
|
6
|
+
// src/crypto/message.ts
|
|
7
7
|
/**
|
|
8
8
|
* Arbitrary-message signing ("personal sign") — the wallet proves control of an
|
|
9
9
|
* account over a human-readable string (a login challenge, a terms acceptance, a
|
|
@@ -42,12 +42,12 @@ function verifyMessage(params) {
|
|
|
42
42
|
try {
|
|
43
43
|
assertMessage(params.message);
|
|
44
44
|
const publicKey = publicKeyFromAddress(params.address);
|
|
45
|
-
|
|
45
|
+
const signature = signatureFromBase58(params.signature);
|
|
46
|
+
return verifyHashed(signature, utf8ToBytes(params.message), publicKey, MESSAGE_DST);
|
|
46
47
|
} catch {
|
|
47
48
|
return false;
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
|
-
//#endregion
|
|
51
51
|
export { signMessage, verifyMessage };
|
|
52
52
|
|
|
53
53
|
//# sourceMappingURL=message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","names":[],"sources":["../../src/crypto/message.ts"],"sourcesContent":["/**\n * Arbitrary-message signing (\"personal sign\") — the wallet proves control of an\n * account over a human-readable string (a login challenge, a terms acceptance, a\n * nonce). Unlike a transaction it never touches the chain; unlike an API key it\n * carries no audience/expiry — it is just a signature the dApp (or its backend)\n * can verify with `verifyMessage`.\n *\n * Recipe: signature = BLS.sign(sha256(utf8(message)), sk, { DST: MESSAGE_DST }).\n * The dedicated `MESSAGE_DST` is what makes this safe to expose: BLS mixes the\n * DST into the curve point, so a message signature can never be replayed as a\n * transaction or API-key signature (and vice-versa). No pubkey is folded in — a\n * single signature is already bound to its signer through verification against a\n * known address, so there is no rogue-key surface here.\n */\n\nimport { toBase58 } from '@amadeus-protocol/sdk'\n\nimport { MAX_MESSAGE_LENGTH, MESSAGE_DST } from '../constants'\nimport { WalletSdkError } from '../errors'\nimport { utf8ToBytes } from '../bytes'\nimport { deriveSigner, publicKeyFromAddress, signatureFromBase58, signHashed, verifyHashed } from './bls'\n\nexport interface SignMessageParams {\n\t/** Base58 wallet seed (private key). */\n\tseed: string\n\t/** The UTF-8 message to sign. */\n\tmessage: string\n}\n\nexport interface SignMessageResult {\n\t/** The message that was signed, echoed back for display/verification. */\n\tmessage: string\n\t/** Base58 BLS signature (96 bytes). */\n\tsignature: string\n\t/** The signing address (Base58 public key). */\n\taddress: string\n}\n\n/** Assert a message is a non-empty string within the length bound. */\nfunction assertMessage(message: string): void {\n\tif (typeof message !== 'string' || message.length === 0) {\n\t\tthrow new WalletSdkError('INVALID_ARGUMENT', 'message is required')\n\t}\n\tif (message.length > MAX_MESSAGE_LENGTH) {\n\t\tthrow new WalletSdkError(\n\t\t\t'INVALID_ARGUMENT',\n\t\t\t`message exceeds ${MAX_MESSAGE_LENGTH} characters`\n\t\t)\n\t}\n}\n\n/** Sign a UTF-8 message under `MESSAGE_DST`. */\nexport function signMessage(params: SignMessageParams): SignMessageResult {\n\tassertMessage(params.message)\n\tconst { sk, pk } = deriveSigner(params.seed)\n\tconst signature = signHashed(utf8ToBytes(params.message), sk, MESSAGE_DST)\n\treturn { message: params.message, signature: toBase58(signature), address: toBase58(pk) }\n}\n\nexport interface VerifyMessageParams {\n\t/** The UTF-8 message that was signed. */\n\tmessage: string\n\t/** Base58 BLS signature returned by `signMessage`. */\n\tsignature: string\n\t/** The Base58 address (public key) that should have signed it. */\n\taddress: string\n}\n\n/**\n * Verify a message signature against a claimed address. Never throws — malformed\n * input (bad Base58, wrong length, over-long message) returns `false`.\n */\nexport function verifyMessage(params: VerifyMessageParams): boolean {\n\ttry {\n\t\tassertMessage(params.message)\n\t\tconst publicKey = publicKeyFromAddress(params.address)\n\t\tconst signature = signatureFromBase58(params.signature)\n\t\treturn verifyHashed(signature, utf8ToBytes(params.message), publicKey, MESSAGE_DST)\n\t} catch {\n\t\treturn false\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,SAAS,cAAc,SAAuB;CAC7C,IAAI,OAAO,YAAY,YAAY,QAAQ,WAAW,GACrD,MAAM,IAAI,eAAe,oBAAoB,qBAAqB;CAEnE,IAAI,QAAQ,SAAA,MACX,MAAM,IAAI,eACT,oBACA,mBAAmB,mBAAmB,YACvC;AAEF;;AAGA,SAAgB,YAAY,QAA8C;CACzE,cAAc,OAAO,OAAO;CAC5B,MAAM,EAAE,IAAI,OAAO,aAAa,OAAO,IAAI;CAC3C,MAAM,YAAY,WAAW,YAAY,OAAO,OAAO,GAAG,IAAI,WAAW;CACzE,OAAO;EAAE,SAAS,OAAO;EAAS,WAAW,SAAS,SAAS;EAAG,SAAS,SAAS,EAAE;CAAE;AACzF;;;;;AAeA,SAAgB,cAAc,QAAsC;CACnE,IAAI;EACH,cAAc,OAAO,OAAO;EAC5B,MAAM,YAAY,qBAAqB,OAAO,OAAO;
|
|
1
|
+
{"version":3,"file":"message.js","names":[],"sources":["../../src/crypto/message.ts"],"sourcesContent":["/**\n * Arbitrary-message signing (\"personal sign\") — the wallet proves control of an\n * account over a human-readable string (a login challenge, a terms acceptance, a\n * nonce). Unlike a transaction it never touches the chain; unlike an API key it\n * carries no audience/expiry — it is just a signature the dApp (or its backend)\n * can verify with `verifyMessage`.\n *\n * Recipe: signature = BLS.sign(sha256(utf8(message)), sk, { DST: MESSAGE_DST }).\n * The dedicated `MESSAGE_DST` is what makes this safe to expose: BLS mixes the\n * DST into the curve point, so a message signature can never be replayed as a\n * transaction or API-key signature (and vice-versa). No pubkey is folded in — a\n * single signature is already bound to its signer through verification against a\n * known address, so there is no rogue-key surface here.\n */\n\nimport { toBase58 } from '@amadeus-protocol/sdk'\n\nimport { MAX_MESSAGE_LENGTH, MESSAGE_DST } from '../constants'\nimport { WalletSdkError } from '../errors'\nimport { utf8ToBytes } from '../bytes'\nimport { deriveSigner, publicKeyFromAddress, signatureFromBase58, signHashed, verifyHashed } from './bls'\n\nexport interface SignMessageParams {\n\t/** Base58 wallet seed (private key). */\n\tseed: string\n\t/** The UTF-8 message to sign. */\n\tmessage: string\n}\n\nexport interface SignMessageResult {\n\t/** The message that was signed, echoed back for display/verification. */\n\tmessage: string\n\t/** Base58 BLS signature (96 bytes). */\n\tsignature: string\n\t/** The signing address (Base58 public key). */\n\taddress: string\n}\n\n/** Assert a message is a non-empty string within the length bound. */\nfunction assertMessage(message: string): void {\n\tif (typeof message !== 'string' || message.length === 0) {\n\t\tthrow new WalletSdkError('INVALID_ARGUMENT', 'message is required')\n\t}\n\tif (message.length > MAX_MESSAGE_LENGTH) {\n\t\tthrow new WalletSdkError(\n\t\t\t'INVALID_ARGUMENT',\n\t\t\t`message exceeds ${MAX_MESSAGE_LENGTH} characters`\n\t\t)\n\t}\n}\n\n/** Sign a UTF-8 message under `MESSAGE_DST`. */\nexport function signMessage(params: SignMessageParams): SignMessageResult {\n\tassertMessage(params.message)\n\tconst { sk, pk } = deriveSigner(params.seed)\n\tconst signature = signHashed(utf8ToBytes(params.message), sk, MESSAGE_DST)\n\treturn { message: params.message, signature: toBase58(signature), address: toBase58(pk) }\n}\n\nexport interface VerifyMessageParams {\n\t/** The UTF-8 message that was signed. */\n\tmessage: string\n\t/** Base58 BLS signature returned by `signMessage`. */\n\tsignature: string\n\t/** The Base58 address (public key) that should have signed it. */\n\taddress: string\n}\n\n/**\n * Verify a message signature against a claimed address. Never throws — malformed\n * input (bad Base58, wrong length, over-long message) returns `false`.\n */\nexport function verifyMessage(params: VerifyMessageParams): boolean {\n\ttry {\n\t\tassertMessage(params.message)\n\t\tconst publicKey = publicKeyFromAddress(params.address)\n\t\tconst signature = signatureFromBase58(params.signature)\n\t\treturn verifyHashed(signature, utf8ToBytes(params.message), publicKey, MESSAGE_DST)\n\t} catch {\n\t\treturn false\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuCA,SAAS,cAAc,SAAuB;CAC7C,IAAI,OAAO,YAAY,YAAY,QAAQ,WAAW,GACrD,MAAM,IAAI,eAAe,oBAAoB,qBAAqB;CAEnE,IAAI,QAAQ,SAAA,MACX,MAAM,IAAI,eACT,oBACA,mBAAmB,mBAAmB,YACvC;AAEF;;AAGA,SAAgB,YAAY,QAA8C;CACzE,cAAc,OAAO,OAAO;CAC5B,MAAM,EAAE,IAAI,OAAO,aAAa,OAAO,IAAI;CAC3C,MAAM,YAAY,WAAW,YAAY,OAAO,OAAO,GAAG,IAAI,WAAW;CACzE,OAAO;EAAE,SAAS,OAAO;EAAS,WAAW,SAAS,SAAS;EAAG,SAAS,SAAS,EAAE;CAAE;AACzF;;;;;AAeA,SAAgB,cAAc,QAAsC;CACnE,IAAI;EACH,cAAc,OAAO,OAAO;EAC5B,MAAM,YAAY,qBAAqB,OAAO,OAAO;EACrD,MAAM,YAAY,oBAAoB,OAAO,SAAS;EACtD,OAAO,aAAa,WAAW,YAAY,OAAO,OAAO,GAAG,WAAW,WAAW;CACnF,QAAQ;EACP,OAAO;CACR;AACD"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
//#region src/errors.d.ts
|
|
2
1
|
/** Stable error codes so callers can branch without string-matching messages. */
|
|
3
2
|
type WalletSdkErrorCode = 'INVALID_API_KEY' | 'BAD_SIGNATURE' | 'EXPIRED' | 'AUD_MISMATCH' | 'INVALID_ADDRESS' | 'INVALID_SIGNATURE' | 'INVALID_ARGUMENT' | 'SUBMIT_FAILED' | 'DECRYPT_FAILED';
|
|
4
3
|
declare class WalletSdkError extends Error {
|
|
5
4
|
readonly code: WalletSdkErrorCode;
|
|
6
5
|
constructor(code: WalletSdkErrorCode, message: string);
|
|
7
6
|
}
|
|
8
|
-
//#endregion
|
|
9
7
|
export { WalletSdkError, WalletSdkErrorCode };
|
|
10
8
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":";KACY;cAWC,uBAAuB;WAC1B,MAAM;EAEH,YAAA,MAAM,oBAAoB"}
|
package/dist/errors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/errors.ts
|
|
2
2
|
var WalletSdkError = class WalletSdkError extends Error {
|
|
3
3
|
code;
|
|
4
4
|
constructor(code, message) {
|
|
@@ -8,7 +8,6 @@ var WalletSdkError = class WalletSdkError extends Error {
|
|
|
8
8
|
Object.setPrototypeOf(this, WalletSdkError.prototype);
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
-
//#endregion
|
|
12
11
|
export { WalletSdkError };
|
|
13
12
|
|
|
14
13
|
//# sourceMappingURL=errors.js.map
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SignTransactionRequest, SignTransactionResponse } from "../types.js";
|
|
2
2
|
import { WalletClient } from "../client/injected.js";
|
|
3
|
-
//#region src/react/index.d.ts
|
|
4
3
|
type WalletStatus = 'unavailable' | 'disconnected' | 'connecting' | 'connected';
|
|
5
4
|
interface UseWalletResult {
|
|
6
5
|
client: WalletClient;
|
|
@@ -15,6 +14,5 @@ interface UseWalletResult {
|
|
|
15
14
|
ensureApiKey: WalletClient['ensureApiKey'];
|
|
16
15
|
}
|
|
17
16
|
declare function useWallet(): UseWalletResult;
|
|
18
|
-
//#endregion
|
|
19
17
|
export { UseWalletResult, WalletStatus, useWallet };
|
|
20
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/react/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/react/index.ts"],"mappings":";;KAoBY;UAEK;EAChB,QAAQ;EACR,QAAQ;EACR;EACA;EACA;EACA,eAAe;EACf;EACA,kBAAkB,SAAS,2BAA2B,QAAQ;EAC9D,eAAe;EACf,cAAc;;iBAGC,aAAa"}
|
package/dist/react/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WALLET_INITIALIZED_EVENT } from "../constants.js";
|
|
2
2
|
import { createInjectedWalletClient } from "../client/injected.js";
|
|
3
3
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
4
|
-
|
|
4
|
+
// src/react/index.ts
|
|
5
5
|
/**
|
|
6
6
|
* React ergonomics for dApps: a single `useWallet()` hook over the injected
|
|
7
7
|
* provider client. It fixes the `amadeus#initialized` vs `amadeus-wallet#initialized`
|
|
@@ -89,7 +89,6 @@ function useWallet() {
|
|
|
89
89
|
ensureApiKey: client.ensureApiKey
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
//#endregion
|
|
93
92
|
export { useWallet };
|
|
94
93
|
|
|
95
94
|
//# sourceMappingURL=index.js.map
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
//#region src/schema.d.ts
|
|
3
2
|
/** http(s) origin, matching the extension's `originSchema`. */
|
|
4
3
|
declare const originSchema: z.ZodEffects<z.ZodString, string, string>;
|
|
5
4
|
/** A Base58 string that decodes to a 48-byte Amadeus public key / address. */
|
|
@@ -67,6 +66,5 @@ type SignTransactionRequestInput = z.infer<typeof signTransactionRequestSchema>;
|
|
|
67
66
|
type GenerateApiKeyRequestInput = z.infer<typeof generateApiKeyRequestSchema>;
|
|
68
67
|
type SignMessageRequestInput = z.infer<typeof signMessageRequestSchema>;
|
|
69
68
|
type ConnectTranscriptInput = z.infer<typeof connectTranscriptSchema>;
|
|
70
|
-
//#endregion
|
|
71
69
|
export { ConnectTranscriptInput, GenerateApiKeyRequestInput, SignMessageRequestInput, SignTransactionRequestInput, addressSchema, connectTranscriptSchema, generateApiKeyRequestSchema, networkSchema, originSchema, sessionPublicKeySchema, signMessageRequestSchema, signTransactionRequestSchema };
|
|
72
70
|
//# sourceMappingURL=schema.d.ts.map
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","names":[],"sources":["../src/schema.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","names":[],"sources":["../src/schema.ts"],"mappings":";;cAiCa,cAAY,EAAA,WAAA,EAAA;;cAKZ,eAAa,EAAA,WAAA,EAAA;;cAGb,wBAAsB,EAAA,WAAA,EAAA;cAKtB,eAAa,EAAA;;cAGb,8BAA4B,EAAA;;;;;;;;;;;;;;;;;cAQ5B,6BAA2B,EAAA;;;;;;;;;;;cAM3B,0BAAwB,EAAA;;;;;;;;cAKxB,yBAAuB,EAAA;;;;;;;;;;;;;;;;;;;KAQxB,8BAA8B,EAAE,aAAa;KAC7C,6BAA6B,EAAE,aAAa;KAC5C,0BAA0B,EAAE,aAAa;KACzC,yBAAyB,EAAE,aAAa"}
|
package/dist/schema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MAX_MESSAGE_LENGTH, NETWORKS } from "./constants.js";
|
|
2
2
|
import { fromBase58 } from "@amadeus-protocol/sdk";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
|
|
4
|
+
// src/schema.ts
|
|
5
5
|
/**
|
|
6
6
|
* Runtime validation for untrusted wire input (deep links, QR payloads, bridge
|
|
7
7
|
* frames, cross-origin messages). Validate BEFORE any request is shown for
|
|
@@ -48,7 +48,6 @@ const connectTranscriptSchema = z.object({
|
|
|
48
48
|
challenge: z.string().min(1),
|
|
49
49
|
requestId: z.string().min(1)
|
|
50
50
|
});
|
|
51
|
-
//#endregion
|
|
52
51
|
export { addressSchema, connectTranscriptSchema, generateApiKeyRequestSchema, networkSchema, originSchema, sessionPublicKeySchema, signMessageRequestSchema, signTransactionRequestSchema };
|
|
53
52
|
|
|
54
53
|
//# sourceMappingURL=schema.js.map
|