passkey-kit 0.10.22 → 0.10.24

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "passkey-kit",
3
- "version": "0.10.22",
3
+ "version": "0.10.24",
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",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "@simplewebauthn/types": "^12.0.0",
20
- "@types/node": "^22.15.2",
20
+ "@types/node": "^22.15.3",
21
21
  "typescript": "^5.8.3"
22
22
  },
23
23
  "workspaces": [
package/src/kit.ts CHANGED
@@ -1,20 +1,20 @@
1
1
  import { Client as PasskeyClient, type Signature, type SignerKey as SDKSignerKey, type SignerLimits as SDKSignerLimits } from 'passkey-kit-sdk'
2
2
  import { StrKey, hash, xdr, Keypair, Address, TransactionBuilder, Operation } from '@stellar/stellar-sdk/minimal'
3
- import type { AuthenticatorAttestationResponseJSON, AuthenticatorSelectionCriteria } from "@simplewebauthn/types"
3
+ import type { AuthenticationResponseJSON, 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 AssembledTransactionOptions, type Tx } from '@stellar/stellar-sdk/minimal/contract'
9
+ import { AssembledTransaction, basicNodeSigner, 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 {
13
13
  declare rpc: Server
14
14
  declare rpcUrl: string
15
15
 
16
- private walletKeypair: Keypair
17
- private walletPublicKey: string
16
+ private walletKeypair: Keypair
17
+ private walletPublicKey: string
18
18
  private walletWasmHash: string
19
19
  private timeoutInSeconds: number
20
20
  private WebAuthn: {
@@ -54,7 +54,7 @@ export class PasskeyKit extends PasskeyBase {
54
54
  }
55
55
 
56
56
  public async createWallet(app: string, user: string) {
57
- const { keyId, keyIdBase64, publicKey } = await this.createKey(app, user)
57
+ const { rawResponse, keyId, keyIdBase64, publicKey } = await this.createKey(app, user)
58
58
 
59
59
  const at = await PasskeyClient.deploy(
60
60
  {
@@ -92,6 +92,7 @@ export class PasskeyKit extends PasskeyBase {
92
92
  })
93
93
 
94
94
  return {
95
+ rawResponse,
95
96
  keyId,
96
97
  keyIdBase64,
97
98
  contractId,
@@ -115,7 +116,7 @@ export class PasskeyKit extends PasskeyBase {
115
116
  // In this case we should save the passkey info and retry uploading it async vs asking the user to create another passkey
116
117
  // This does introduce a storage dependency though so it likely needs to be a function with some logic for choosing how to store the passkey data
117
118
 
118
- const { id, response } = await this.WebAuthn.startRegistration({
119
+ const rawResponse = await this.WebAuthn.startRegistration({
119
120
  optionsJSON: {
120
121
  challenge: base64url("stellaristhebetterblockchain"),
121
122
  rp: {
@@ -131,11 +132,13 @@ export class PasskeyKit extends PasskeyBase {
131
132
  pubKeyCredParams: [{ alg: -7, type: "public-key" }],
132
133
  }
133
134
  });
135
+ const { id, response } = rawResponse
134
136
 
135
137
  if (!this.keyId)
136
138
  this.keyId = id;
137
139
 
138
140
  return {
141
+ rawResponse,
139
142
  keyId: base64url.toBuffer(id),
140
143
  keyIdBase64: id,
141
144
  publicKey: await this.getPublicKey(response),
@@ -150,11 +153,12 @@ export class PasskeyKit extends PasskeyBase {
150
153
  // Consider putting this somewhere else??
151
154
  walletPublicKey?: string
152
155
  }) {
153
- let { keyId, rpId, getContractId, walletPublicKey } = opts || {}
156
+ let { rpId, keyId, getContractId, walletPublicKey } = opts || {}
154
157
  let keyIdBuffer: Buffer
158
+ let rawResponse: AuthenticationResponseJSON | undefined;
155
159
 
156
160
  if (!keyId) {
157
- const response = await this.WebAuthn.startAuthentication({
161
+ rawResponse = await this.WebAuthn.startAuthentication({
158
162
  optionsJSON: {
159
163
  challenge: base64url("stellaristhebetterblockchain"),
160
164
  rpId,
@@ -162,7 +166,7 @@ export class PasskeyKit extends PasskeyBase {
162
166
  }
163
167
  });
164
168
 
165
- keyId = response.id
169
+ keyId = rawResponse.id
166
170
  }
167
171
 
168
172
  if (keyId instanceof Uint8Array) {
@@ -212,6 +216,7 @@ export class PasskeyKit extends PasskeyBase {
212
216
  })
213
217
 
214
218
  return {
219
+ rawResponse,
215
220
  keyId: keyIdBuffer,
216
221
  keyIdBase64: keyId,
217
222
  contractId
@@ -427,7 +432,7 @@ export class PasskeyKit extends PasskeyBase {
427
432
  const operation = built.operations[0] as Operation.InvokeHostFunction;
428
433
 
429
434
  txn = await AssembledTransaction.buildWithOp<T>(
430
- Operation.invokeHostFunction({ func: operation.func }),
435
+ Operation.invokeHostFunction({ func: operation.func }),
431
436
  this.wallet!.options as AssembledTransactionOptions<T>
432
437
  );
433
438
  }
package/types/kit.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Client as PasskeyClient } from 'passkey-kit-sdk';
2
2
  import { xdr, Keypair } from '@stellar/stellar-sdk/minimal';
3
- import type { AuthenticatorSelectionCriteria } from "@simplewebauthn/types";
3
+ import type { AuthenticationResponseJSON, AuthenticatorSelectionCriteria } from "@simplewebauthn/types";
4
4
  import { startRegistration, startAuthentication } from "@simplewebauthn/browser";
5
5
  import { Buffer } from 'buffer';
6
6
  import type { SignerKey, SignerLimits, SignerStore } from './types';
@@ -29,6 +29,7 @@ export declare class PasskeyKit extends PasskeyBase {
29
29
  };
30
30
  });
31
31
  createWallet(app: string, user: string): Promise<{
32
+ rawResponse: import("@simplewebauthn/browser").RegistrationResponseJSON;
32
33
  keyId: Buffer<ArrayBufferLike>;
33
34
  keyIdBase64: string;
34
35
  contractId: string;
@@ -38,6 +39,7 @@ export declare class PasskeyKit extends PasskeyBase {
38
39
  rpId?: string;
39
40
  authenticatorSelection?: AuthenticatorSelectionCriteria;
40
41
  }): Promise<{
42
+ rawResponse: import("@simplewebauthn/browser").RegistrationResponseJSON;
41
43
  keyId: Buffer<ArrayBufferLike>;
42
44
  keyIdBase64: string;
43
45
  publicKey: Buffer<ArrayBufferLike>;
@@ -48,6 +50,7 @@ export declare class PasskeyKit extends PasskeyBase {
48
50
  getContractId?: (keyId: string) => Promise<string | undefined>;
49
51
  walletPublicKey?: string;
50
52
  }): Promise<{
53
+ rawResponse: AuthenticationResponseJSON | undefined;
51
54
  keyId: Buffer<ArrayBufferLike>;
52
55
  keyIdBase64: string;
53
56
  contractId: string;