passkey-kit 0.10.10 → 0.10.12

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/kit.ts +18 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "passkey-kit",
3
- "version": "0.10.10",
3
+ "version": "0.10.12",
4
4
  "description": "A helper library for creating and using smart wallet accounts on the Stellar blockchain.",
5
5
  "author": "Tyler van der Hoeven",
6
6
  "license": "MIT",
@@ -12,8 +12,8 @@
12
12
  "@stellar/stellar-sdk": "^13.1.0",
13
13
  "base64url": "^3.0.1",
14
14
  "buffer": "^6.0.3",
15
- "passkey-kit-sdk": "0.6.5",
16
- "sac-sdk": "0.3.5"
15
+ "sac-sdk": "0.3.5",
16
+ "passkey-kit-sdk": "0.6.5"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@simplewebauthn/types": "^12.0.0",
package/src/kit.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { Client as PasskeyClient, type Signature, type SignerKey as SDKSignerKey, type SignerLimits as SDKSignerLimits } from 'passkey-kit-sdk'
2
- import { StrKey, hash, xdr, Keypair, Address } from '@stellar/stellar-sdk/minimal'
2
+ import { StrKey, hash, xdr, Keypair, Address, TransactionBuilder, Operation } from '@stellar/stellar-sdk/minimal'
3
3
  import type { AuthenticatorAttestationResponseJSON, AuthenticatorSelectionCriteria } from "@simplewebauthn/types"
4
4
  import { startRegistration, startAuthentication } from "@simplewebauthn/browser"
5
5
  import { Buffer } from 'buffer'
6
6
  import base64url from 'base64url'
7
7
  import type { SignerKey, SignerLimits, SignerStore } from './types'
8
8
  import { PasskeyBase } from './base'
9
- import { AssembledTransaction, basicNodeSigner, DEFAULT_TIMEOUT, type Tx } from '@stellar/stellar-sdk/minimal/contract'
9
+ import { AssembledTransaction, basicNodeSigner, DEFAULT_TIMEOUT, type AssembledTransactionOptions, type Tx } from '@stellar/stellar-sdk/minimal/contract'
10
10
  import type { Server } from '@stellar/stellar-sdk/minimal/rpc'
11
11
 
12
12
  export class PasskeyKit extends PasskeyBase {
@@ -396,10 +396,22 @@ export class PasskeyKit extends PasskeyBase {
396
396
  expiration?: number
397
397
  }
398
398
  ) {
399
- if (typeof txn === 'string') {
400
- txn = AssembledTransaction.fromXDR(this.wallet!.options, txn, this.wallet!.spec)
401
- } else if (!(txn instanceof AssembledTransaction)) {
402
- txn = AssembledTransaction.fromXDR(this.wallet!.options, txn.toXDR(), this.wallet!.spec)
399
+ if (!(txn instanceof AssembledTransaction)) {
400
+ txn = typeof txn === 'string' ? txn : txn.toXDR()
401
+
402
+ try {
403
+ txn = AssembledTransaction.fromXDR(this.wallet!.options, txn, this.wallet!.spec)
404
+ } catch {
405
+ if (!(txn instanceof AssembledTransaction)) {
406
+ const built = TransactionBuilder.fromXDR(txn, this.networkPassphrase);
407
+ const operation = built.operations[0] as Operation.InvokeHostFunction;
408
+
409
+ txn = await AssembledTransaction.buildWithOp<T>(
410
+ Operation.invokeHostFunction({ func: operation.func }),
411
+ this.wallet!.options as AssembledTransactionOptions<T>
412
+ );
413
+ }
414
+ }
403
415
  }
404
416
 
405
417
  await txn.signAuthEntries({