@joeywallet/wallet-sdk 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +57 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +3 -0
- package/src/types.ts +64 -1
package/README.md
CHANGED
|
@@ -372,32 +372,91 @@ that screen. Both are unambiguous; only the pair "transaction 2 of 5" next to
|
|
|
372
372
|
|
|
373
373
|
## Sign in
|
|
374
374
|
|
|
375
|
-
`signIn` authenticates a user without a transaction.
|
|
376
|
-
[CAIP-122](https://namespaces.chainagnostic.org/xrpl/caip122) message
|
|
377
|
-
non-transaction domain separator, so the signature is cryptographically
|
|
375
|
+
`signIn` authenticates a user without a transaction. For a software account it
|
|
376
|
+
signs a [CAIP-122](https://namespaces.chainagnostic.org/xrpl/caip122) message
|
|
377
|
+
under a non-transaction domain separator, so the signature is cryptographically
|
|
378
378
|
incapable of being replayed as a transaction signature.
|
|
379
379
|
|
|
380
|
+
**It has two result shapes, and you must narrow before reading either.** Which
|
|
381
|
+
one you get is the wallet’s decision, not yours: it depends on the account the
|
|
382
|
+
user picks, and they pick it inside the wallet after your call has been made.
|
|
383
|
+
|
|
380
384
|
```ts
|
|
385
|
+
import { isChallengeSignIn } from '@joeywallet/wallet-sdk'
|
|
386
|
+
|
|
381
387
|
const result = await joey.signIn({
|
|
382
388
|
statement: 'Sign in to Example Exchange',
|
|
383
389
|
// nonce defaults to one the wallet generates; supply your own if your
|
|
384
390
|
// backend issues it.
|
|
385
391
|
})
|
|
386
392
|
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
393
|
+
if (isChallengeSignIn(result)) {
|
|
394
|
+
// A hardware account. Verify the signed transaction.
|
|
395
|
+
await fetch('/api/session/tx', {
|
|
396
|
+
method: 'POST',
|
|
397
|
+
headers: { 'content-type': 'application/json' },
|
|
398
|
+
body: JSON.stringify({ address: result.address, signedTx: result.signedTx }),
|
|
399
|
+
})
|
|
400
|
+
} else {
|
|
401
|
+
await fetch('/api/session', {
|
|
402
|
+
method: 'POST',
|
|
403
|
+
headers: { 'content-type': 'application/json' },
|
|
404
|
+
body: JSON.stringify({
|
|
405
|
+
address: result.address,
|
|
406
|
+
publicKey: result.publicKey,
|
|
407
|
+
message: result.message,
|
|
408
|
+
signature: result.signature,
|
|
409
|
+
}),
|
|
410
|
+
})
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
Verify the CAIP-122 signature server-side against `result.message` and check the
|
|
415
|
+
nonce, the domain and the issue time inside that message before trusting it.
|
|
416
|
+
|
|
417
|
+
### Hardware accounts sign a transaction instead
|
|
418
|
+
|
|
419
|
+
A Ledger cannot produce the result above. The XRP app signs transactions and has
|
|
420
|
+
no message primitive at all, so there is no command to ask it for a CAIP-122
|
|
421
|
+
signature. Rather than refuse the sign-in, the wallet proves ownership by having
|
|
422
|
+
the device sign a canonical 1-drop Payment and hands you the signed transaction
|
|
423
|
+
as `signedTx`.
|
|
424
|
+
|
|
425
|
+
That transaction is built entirely by the wallet and is unsubmittable twice
|
|
426
|
+
over: `Sequence` is `0`, which is never valid for a funded account, and the
|
|
427
|
+
destination is the signing account itself, which `rippled` refuses as
|
|
428
|
+
`temREDUNDANT`. Your challenge travels in a memo as
|
|
429
|
+
`{"wallet":"joey","challenge":"<nonce>"}`, hex-encoded.
|
|
430
|
+
|
|
431
|
+
`signedTx` is `JSON.stringify` of the **bare** decoded transaction — not wrapped
|
|
432
|
+
in `{ tx_json: … }` — so `JSON.parse` it and use the result as a transaction
|
|
433
|
+
object. To verify one, re-encode it and check the signature, then check the
|
|
434
|
+
signer is the address you are about to trust:
|
|
435
|
+
|
|
436
|
+
```ts
|
|
437
|
+
import { encode } from 'ripple-binary-codec'
|
|
438
|
+
import { verifySignature } from 'ripple-keypairs' // or your verifier of choice
|
|
439
|
+
|
|
440
|
+
const tx = JSON.parse(signedTx)
|
|
441
|
+
const ok = verifySignature(encode(tx)) // signatureValid, signedBy
|
|
442
|
+
// Bind the session to the address that actually signed, never to one the
|
|
443
|
+
// client claimed: without that check a valid signature made with any key can
|
|
444
|
+
// mint a session for any account.
|
|
397
445
|
```
|
|
398
446
|
|
|
399
|
-
|
|
400
|
-
|
|
447
|
+
This is byte-identical to what the Joey mobile wallet puts in a WalletConnect
|
|
448
|
+
session's `xrpl_signin_v1_signed_tx`, so a backend that already verifies mobile
|
|
449
|
+
Joey sign-ins verifies these unchanged.
|
|
450
|
+
|
|
451
|
+
Narrow with `isChallengeSignIn`, which tests for the `signedTx` field rather
|
|
452
|
+
than for `mode`. Wallets older than this shape send no `mode` at all, so a check
|
|
453
|
+
written the other way round misroutes every one of them.
|
|
454
|
+
|
|
455
|
+
> **If you skip the narrowing**, a verifier written for the CAIP-122 shape reads
|
|
456
|
+
> `publicKey`, `message` and `signature` as `undefined`, posts them, and reports
|
|
457
|
+
> "signature did not verify" — for a signature the user made correctly on their
|
|
458
|
+
> device, seconds earlier. The failure is silent on the wallet side and looks
|
|
459
|
+
> like a rejected login on yours.
|
|
401
460
|
|
|
402
461
|
Pass `resources` to name the scope you are asking for. It is shown on the
|
|
403
462
|
approval screen and written into the message's `Resources:` section, so it is
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ export { getJoey, isJoeyAvailable, requireJoey, resetJoeyDetection, waitForJoey,
|
|
|
8
8
|
export { createJoeyClient, readAccounts, readChain, readNetwork, type Joey, } from './client.js';
|
|
9
9
|
export { JOEY_ERROR_CODES, JoeyRpcError, isUserRejection, notInstalledError, userRejectedError, type JoeyErrorCode, } from './errors.js';
|
|
10
10
|
export { APPROVAL_TIMEOUT_MS, CAIP294_ANNOUNCE_EVENT, CAIP294_PROMPT_EVENT, JOEY_DAPP_FORBIDDEN_TRANSACTION_TYPES, JOEY_RDNS, JOEY_RPC_METHODS, JOEY_WALLET_NAME, MAX_BULK_TRANSACTIONS, REQUEST_TIMEOUT_MS, WALLET_STANDARD_APP_READY_EVENT, WALLET_STANDARD_REGISTER_EVENT, invoke, isJoeyInjectedProvider, subscribe, type JoeyInjectedProvider, type JoeyProviderEventName, type JoeyRequestArguments, type JoeyRpcMethod, } from './provider.js';
|
|
11
|
-
export { JOEY_CHAINS, chainForNetworkId, isJoeyChain, networkIdForChain, type Amount, type AnyTransaction, type ConnectParams, type ConnectResult, type IssuedCurrencyAmount, type JoeyAccount, type JoeyChain, type JoeyEventListener, type JoeyEventMap, type JoeyEventName, type JoeyNetwork, type Memo, type MPTAmount, type Path, type PathStep, type SignAndSubmitTransactionResult, type SigningContextParams, type SignInMode, type SignInParams, type SignInResult, type BulkEntryResult, type BulkEntryStatus, type SignTransactionBulkFailure, type SignTransactionBulkParams, type SignTransactionForParams, type SignTransactionParams, type SignTransactionResult, type Signer, type TransactionLike, } from './types.js';
|
|
11
|
+
export { JOEY_CHAINS, chainForNetworkId, isChallengeSignIn, isJoeyChain, networkIdForChain, type Amount, type AnyTransaction, type ConnectParams, type ConnectResult, type IssuedCurrencyAmount, type JoeyAccount, type JoeyChain, type JoeyEventListener, type JoeyEventMap, type JoeyEventName, type JoeyNetwork, type Memo, type MPTAmount, type Path, type PathStep, type SignAndSubmitTransactionResult, type SigningContextParams, type Caip122SignInResult, type ChallengeSignInResult, type SignInMode, type SignInParams, type SignInResult, type BulkEntryResult, type BulkEntryStatus, type SignTransactionBulkFailure, type SignTransactionBulkParams, type SignTransactionForParams, type SignTransactionParams, type SignTransactionResult, type Signer, type TransactionLike, } from './types.js';
|
|
12
12
|
export { initialMutationState, mutationReducer, toPublicState, type MutationAction, type MutationState, type MutationStatus, } from './mutation.js';
|
|
13
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,OAAO,EACP,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,WAAW,EACX,KAAK,IAAI,GACV,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,qCAAqC,EACrC,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,+BAA+B,EAC/B,8BAA8B,EAC9B,MAAM,EACN,sBAAsB,EACtB,SAAS,EACT,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAA;AAEtB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,QAAQ,EACb,KAAK,8BAA8B,EACnC,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,MAAM,EACX,KAAK,eAAe,GACrB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,OAAO,EACP,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,KAAK,kBAAkB,GACxB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,WAAW,EACX,KAAK,IAAI,GACV,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,aAAa,GACnB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,qCAAqC,EACrC,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,+BAA+B,EAC/B,8BAA8B,EAC9B,MAAM,EACN,sBAAsB,EACtB,SAAS,EACT,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAA;AAEtB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,IAAI,EACT,KAAK,QAAQ,EACb,KAAK,8BAA8B,EACnC,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,MAAM,EACX,KAAK,eAAe,GACrB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,6 @@ export { getJoey, isJoeyAvailable, requireJoey, resetJoeyDetection, waitForJoey,
|
|
|
8
8
|
export { createJoeyClient, readAccounts, readChain, readNetwork, } from './client.js';
|
|
9
9
|
export { JOEY_ERROR_CODES, JoeyRpcError, isUserRejection, notInstalledError, userRejectedError, } from './errors.js';
|
|
10
10
|
export { APPROVAL_TIMEOUT_MS, CAIP294_ANNOUNCE_EVENT, CAIP294_PROMPT_EVENT, JOEY_DAPP_FORBIDDEN_TRANSACTION_TYPES, JOEY_RDNS, JOEY_RPC_METHODS, JOEY_WALLET_NAME, MAX_BULK_TRANSACTIONS, REQUEST_TIMEOUT_MS, WALLET_STANDARD_APP_READY_EVENT, WALLET_STANDARD_REGISTER_EVENT, invoke, isJoeyInjectedProvider, subscribe, } from './provider.js';
|
|
11
|
-
export { JOEY_CHAINS, chainForNetworkId, isJoeyChain, networkIdForChain, } from './types.js';
|
|
11
|
+
export { JOEY_CHAINS, chainForNetworkId, isChallengeSignIn, isJoeyChain, networkIdForChain, } from './types.js';
|
|
12
12
|
export { initialMutationState, mutationReducer, toPublicState, } from './mutation.js';
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,OAAO,EACP,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,WAAW,GAEZ,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,WAAW,GAEZ,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAElB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,qCAAqC,EACrC,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,+BAA+B,EAC/B,8BAA8B,EAC9B,MAAM,EACN,sBAAsB,EACtB,SAAS,GAKV,MAAM,eAAe,CAAA;AAEtB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,OAAO,EACP,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,WAAW,GAEZ,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,WAAW,GAEZ,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,iBAAiB,GAElB,MAAM,aAAa,CAAA;AAEpB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,qCAAqC,EACrC,SAAS,EACT,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,+BAA+B,EAC/B,8BAA8B,EAC9B,MAAM,EACN,sBAAsB,EACtB,SAAS,GAKV,MAAM,eAAe,CAAA;AAEtB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,iBAAiB,GAgClB,MAAM,YAAY,CAAA;AAEnB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,aAAa,GAId,MAAM,eAAe,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -363,14 +363,70 @@ export interface SignInParams {
|
|
|
363
363
|
*/
|
|
364
364
|
resources?: string[];
|
|
365
365
|
}
|
|
366
|
-
|
|
366
|
+
/**
|
|
367
|
+
* What a software account answers with: a signature over a CAIP-122 message.
|
|
368
|
+
*
|
|
369
|
+
* `mode` is optional because wallets predating the second shape do not send
|
|
370
|
+
* it. Do not branch on it being `caip122` — branch on the *other* shape, with
|
|
371
|
+
* {@link isChallengeSignIn}, so an older wallet still takes this path.
|
|
372
|
+
*/
|
|
373
|
+
export interface Caip122SignInResult {
|
|
367
374
|
address: string;
|
|
368
375
|
publicKey: string;
|
|
369
376
|
/** Hex-encoded signature. */
|
|
370
377
|
signature: string;
|
|
371
378
|
/** The exact string that was signed. Rebuild it to verify the signature. */
|
|
372
379
|
message: string;
|
|
380
|
+
mode?: 'caip122';
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* What a hardware account answers with instead.
|
|
384
|
+
*
|
|
385
|
+
* A Ledger cannot produce the result above. The XRP app signs transactions and
|
|
386
|
+
* has no message primitive at all, so there is no command to ask it for a
|
|
387
|
+
* CAIP-122 signature — the wallet proves ownership by signing a canonical
|
|
388
|
+
* 1-drop Payment on the device instead, and hands you the signed transaction.
|
|
389
|
+
*
|
|
390
|
+
* The transaction is built entirely by the wallet and is unsubmittable twice
|
|
391
|
+
* over: `Sequence` is `0`, which is never valid for a funded account, and the
|
|
392
|
+
* destination is the signing account itself, which `rippled` refuses as
|
|
393
|
+
* `temREDUNDANT`. It carries your challenge in a memo, as
|
|
394
|
+
* `{"wallet":"joey","challenge":"<nonce>"}` hex-encoded.
|
|
395
|
+
*
|
|
396
|
+
* ## Verifying one
|
|
397
|
+
*
|
|
398
|
+
* `signedTx` is `JSON.stringify` of the *bare* decoded transaction — not
|
|
399
|
+
* wrapped in `{ tx_json: … }` — so `JSON.parse` it and use the result as a
|
|
400
|
+
* transaction object. Re-encode it with `ripple-binary-codec` and check the
|
|
401
|
+
* signature, then check the signer is the address you are about to trust.
|
|
402
|
+
*
|
|
403
|
+
* There is no `message` or `signature` field here, and that is the trap this
|
|
404
|
+
* type exists to close: a verifier written for the CAIP-122 shape reads three
|
|
405
|
+
* `undefined`s, sends them, and reports "signature did not verify" for a
|
|
406
|
+
* signature the user made correctly on their device.
|
|
407
|
+
*/
|
|
408
|
+
export interface ChallengeSignInResult {
|
|
409
|
+
address: string;
|
|
410
|
+
/** The bare signed transaction, JSON-encoded. */
|
|
411
|
+
signedTx: string;
|
|
412
|
+
mode: 'challenge-v1';
|
|
373
413
|
}
|
|
414
|
+
/**
|
|
415
|
+
* The result of {@link SignInParams}, in whichever form the account can make.
|
|
416
|
+
*
|
|
417
|
+
* Which one you get is the wallet’s decision and not yours: it depends on the
|
|
418
|
+
* account the user picks, and they pick it after your call has been made.
|
|
419
|
+
* Narrow with {@link isChallengeSignIn} before reading either shape.
|
|
420
|
+
*/
|
|
421
|
+
export type SignInResult = Caip122SignInResult | ChallengeSignInResult;
|
|
422
|
+
/**
|
|
423
|
+
* Whether a sign-in came back as a signed transaction rather than a message.
|
|
424
|
+
*
|
|
425
|
+
* Tests for the field rather than for `mode`, deliberately: wallets older than
|
|
426
|
+
* the second shape send no `mode` at all, and a check written the other way
|
|
427
|
+
* round would misroute every one of them.
|
|
428
|
+
*/
|
|
429
|
+
export declare function isChallengeSignIn(result: SignInResult): result is ChallengeSignInResult;
|
|
374
430
|
export interface JoeyEventMap {
|
|
375
431
|
/** The origin became authorised. */
|
|
376
432
|
connect: {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,iFAAiF;AACjF,eAAO,MAAM,WAAW,yCAA0C,CAAA;AAElE,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAA;AAEpD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,SAAS,CAAA;IAChB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAA;IACjB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAA;CACb;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAE9D;AAED,sEAAsE;AACtE,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAM9D;AAED,oFAAoF;AACpF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG9D;AAID,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC1B,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAID,MAAM,WAAW,oBAAoB;IACnC,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,SAAS;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,KA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ACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,6BAA6B;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAA;IACf,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,cAAc,CAAA;CACrB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,qBAAqB,CAAA;AAEtE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,YAAY,GACnB,MAAM,IAAI,qBAAqB,CAEjC;AAID,MAAM,WAAW,YAAY;IAC3B,oCAAoC;IACpC,OAAO,EAAE;QAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;QAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAA;KAAE,CAAA;IAC7D,2DAA2D;IAC3D,UAAU,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IAC/B,0EAA0E;IAC1E,eAAe,EAAE,WAAW,EAAE,CAAA;IAC9B,2EAA2E;IAC3E,cAAc,EAAE,WAAW,GAAG,IAAI,CAAA;CACnC;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,YAAY,CAAA;AAE9C,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,aAAa,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA"}
|
package/dist/types.js
CHANGED
|
@@ -35,4 +35,14 @@ export function networkIdForChain(chain) {
|
|
|
35
35
|
return null;
|
|
36
36
|
return Number(chain.slice('xrpl:'.length));
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Whether a sign-in came back as a signed transaction rather than a message.
|
|
40
|
+
*
|
|
41
|
+
* Tests for the field rather than for `mode`, deliberately: wallets older than
|
|
42
|
+
* the second shape send no `mode` at all, and a check written the other way
|
|
43
|
+
* round would misroute every one of them.
|
|
44
|
+
*/
|
|
45
|
+
export function isChallengeSignIn(result) {
|
|
46
|
+
return 'signedTx' in result;
|
|
47
|
+
}
|
|
38
48
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,gFAAgF;AAEhF,iFAAiF;AACjF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAA;AAYlE,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,WAAiC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACxF,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,MAAM,KAAK,GAAG,QAAQ,SAAS,EAAE,CAAA;IACjC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,UAAU,CAAC,iCAAiC,SAAS,EAAE,CAAC,CAAA;IACpE,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACpC,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;AAC5C,CAAC"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,gFAAgF;AAEhF,iFAAiF;AACjF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAU,CAAA;AAYlE,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAK,WAAiC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AACxF,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,iBAAiB,CAAC,SAAiB;IACjD,MAAM,KAAK,GAAG,QAAQ,SAAS,EAAE,CAAA;IACjC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,UAAU,CAAC,iCAAiC,SAAS,EAAE,CAAC,CAAA;IACpE,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IACpC,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;AAC5C,CAAC;AAwaD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAoB;IAEpB,OAAO,UAAU,IAAI,MAAM,CAAA;AAC7B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joeywallet/wallet-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Dependency-free TypeScript SDK for the Joey Wallet browser extension (XLS-72d / Wallet Standard).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/Joey-Wallet/joey-wallet-sdk#readme",
|
package/src/index.ts
CHANGED
|
@@ -54,6 +54,7 @@ export {
|
|
|
54
54
|
export {
|
|
55
55
|
JOEY_CHAINS,
|
|
56
56
|
chainForNetworkId,
|
|
57
|
+
isChallengeSignIn,
|
|
57
58
|
isJoeyChain,
|
|
58
59
|
networkIdForChain,
|
|
59
60
|
type Amount,
|
|
@@ -73,6 +74,8 @@ export {
|
|
|
73
74
|
type PathStep,
|
|
74
75
|
type SignAndSubmitTransactionResult,
|
|
75
76
|
type SigningContextParams,
|
|
77
|
+
type Caip122SignInResult,
|
|
78
|
+
type ChallengeSignInResult,
|
|
76
79
|
type SignInMode,
|
|
77
80
|
type SignInParams,
|
|
78
81
|
type SignInResult,
|
package/src/types.ts
CHANGED
|
@@ -413,13 +413,76 @@ export interface SignInParams {
|
|
|
413
413
|
resources?: string[]
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
-
|
|
416
|
+
/**
|
|
417
|
+
* What a software account answers with: a signature over a CAIP-122 message.
|
|
418
|
+
*
|
|
419
|
+
* `mode` is optional because wallets predating the second shape do not send
|
|
420
|
+
* it. Do not branch on it being `caip122` — branch on the *other* shape, with
|
|
421
|
+
* {@link isChallengeSignIn}, so an older wallet still takes this path.
|
|
422
|
+
*/
|
|
423
|
+
export interface Caip122SignInResult {
|
|
417
424
|
address: string
|
|
418
425
|
publicKey: string
|
|
419
426
|
/** Hex-encoded signature. */
|
|
420
427
|
signature: string
|
|
421
428
|
/** The exact string that was signed. Rebuild it to verify the signature. */
|
|
422
429
|
message: string
|
|
430
|
+
mode?: 'caip122'
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* What a hardware account answers with instead.
|
|
435
|
+
*
|
|
436
|
+
* A Ledger cannot produce the result above. The XRP app signs transactions and
|
|
437
|
+
* has no message primitive at all, so there is no command to ask it for a
|
|
438
|
+
* CAIP-122 signature — the wallet proves ownership by signing a canonical
|
|
439
|
+
* 1-drop Payment on the device instead, and hands you the signed transaction.
|
|
440
|
+
*
|
|
441
|
+
* The transaction is built entirely by the wallet and is unsubmittable twice
|
|
442
|
+
* over: `Sequence` is `0`, which is never valid for a funded account, and the
|
|
443
|
+
* destination is the signing account itself, which `rippled` refuses as
|
|
444
|
+
* `temREDUNDANT`. It carries your challenge in a memo, as
|
|
445
|
+
* `{"wallet":"joey","challenge":"<nonce>"}` hex-encoded.
|
|
446
|
+
*
|
|
447
|
+
* ## Verifying one
|
|
448
|
+
*
|
|
449
|
+
* `signedTx` is `JSON.stringify` of the *bare* decoded transaction — not
|
|
450
|
+
* wrapped in `{ tx_json: … }` — so `JSON.parse` it and use the result as a
|
|
451
|
+
* transaction object. Re-encode it with `ripple-binary-codec` and check the
|
|
452
|
+
* signature, then check the signer is the address you are about to trust.
|
|
453
|
+
*
|
|
454
|
+
* There is no `message` or `signature` field here, and that is the trap this
|
|
455
|
+
* type exists to close: a verifier written for the CAIP-122 shape reads three
|
|
456
|
+
* `undefined`s, sends them, and reports "signature did not verify" for a
|
|
457
|
+
* signature the user made correctly on their device.
|
|
458
|
+
*/
|
|
459
|
+
export interface ChallengeSignInResult {
|
|
460
|
+
address: string
|
|
461
|
+
/** The bare signed transaction, JSON-encoded. */
|
|
462
|
+
signedTx: string
|
|
463
|
+
mode: 'challenge-v1'
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* The result of {@link SignInParams}, in whichever form the account can make.
|
|
468
|
+
*
|
|
469
|
+
* Which one you get is the wallet’s decision and not yours: it depends on the
|
|
470
|
+
* account the user picks, and they pick it after your call has been made.
|
|
471
|
+
* Narrow with {@link isChallengeSignIn} before reading either shape.
|
|
472
|
+
*/
|
|
473
|
+
export type SignInResult = Caip122SignInResult | ChallengeSignInResult
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Whether a sign-in came back as a signed transaction rather than a message.
|
|
477
|
+
*
|
|
478
|
+
* Tests for the field rather than for `mode`, deliberately: wallets older than
|
|
479
|
+
* the second shape send no `mode` at all, and a check written the other way
|
|
480
|
+
* round would misroute every one of them.
|
|
481
|
+
*/
|
|
482
|
+
export function isChallengeSignIn(
|
|
483
|
+
result: SignInResult,
|
|
484
|
+
): result is ChallengeSignInResult {
|
|
485
|
+
return 'signedTx' in result
|
|
423
486
|
}
|
|
424
487
|
|
|
425
488
|
/* -------------------------------------------------------------------- events */
|