passkey-kit 0.5.1 → 0.5.2

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.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "A helper library for creating and using passkey accounts on the Stellar blockchain.",
5
5
  "author": "Tyler van der Hoeven",
6
6
  "license": "MIT",
@@ -13,8 +13,8 @@
13
13
  "base64url": "^3.0.1",
14
14
  "buffer": "^6.0.3",
15
15
  "sac-sdk": "0.1.0",
16
- "passkey-factory-sdk": "0.2.1",
17
- "passkey-kit-sdk": "0.2.1"
16
+ "passkey-kit-sdk": "0.2.1",
17
+ "passkey-factory-sdk": "0.2.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@simplewebauthn/types": "^10.0.0",
package/src/kit.ts CHANGED
@@ -70,14 +70,14 @@ export class PasskeyKit extends PasskeyBase {
70
70
  name: displayName,
71
71
  displayName
72
72
  },
73
- authenticatorSelection: {
74
- requireResidentKey: false,
75
- residentKey: "preferred",
76
- userVerification: "discouraged",
77
- },
73
+ // authenticatorSelection: {
74
+ // requireResidentKey: false,
75
+ // residentKey: "preferred",
76
+ // userVerification: "discouraged",
77
+ // },
78
78
  pubKeyCredParams: [{ alg: -7, type: "public-key" }],
79
- attestation: "none",
80
- timeout: 120_000,
79
+ // attestation: "none",
80
+ // timeout: 120_000,
81
81
  });
82
82
 
83
83
  if (!this.keyId)
@@ -100,8 +100,8 @@ export class PasskeyKit extends PasskeyBase {
100
100
  const response = await startAuthentication({
101
101
  challenge: base64url("stellaristhebetterblockchain"),
102
102
  // rpId: undefined,
103
- userVerification: "discouraged",
104
- timeout: 120_000
103
+ // userVerification: "discouraged",
104
+ // timeout: 120_000
105
105
  });
106
106
 
107
107
  keyId = response.id
@@ -183,8 +183,8 @@ export class PasskeyKit extends PasskeyBase {
183
183
  ? {
184
184
  challenge: base64url(payload),
185
185
  // rpId: undefined,
186
- userVerification: "discouraged",
187
- timeout: 120_000
186
+ // userVerification: "discouraged",
187
+ // timeout: 120_000
188
188
  }
189
189
  : {
190
190
  challenge: base64url(payload),
@@ -197,8 +197,8 @@ export class PasskeyKit extends PasskeyBase {
197
197
  type: "public-key",
198
198
  },
199
199
  ],
200
- userVerification: "discouraged",
201
- timeout: 120_000
200
+ // userVerification: "discouraged",
201
+ // timeout: 120_000
202
202
  }
203
203
  );
204
204
 
@@ -327,13 +327,14 @@ export class PasskeyKit extends PasskeyBase {
327
327
  x = authenticatorData.slice(65 + credentialIdLength, 97 + credentialIdLength)
328
328
  y = authenticatorData.slice(100 + credentialIdLength, 132 + credentialIdLength)
329
329
  } else {
330
- const attestationData = base64url.toBuffer(response.attestationObject)
331
-
332
- let startIndex = attestationData.indexOf(0xa5, 0x01, 0x02, 0x03, 0x26, 0x20, 0x01, 0x21, 0x58, 0x20)
333
- startIndex = startIndex + startIndex.length
330
+ const attestationObject = base64url.toBuffer(response.attestationObject)
331
+
332
+ let publicKeykPrefixSlice = Buffer.from([0xa5, 0x01, 0x02, 0x03, 0x26, 0x20, 0x01, 0x21, 0x58, 0x20])
333
+ let startIndex = attestationObject.indexOf(publicKeykPrefixSlice)
334
+ startIndex = startIndex + publicKeykPrefixSlice.length
334
335
 
335
- x = attestationData.slice(startIndex, 32 + startIndex)
336
- y = attestationData.slice(35 + startIndex, 67 + startIndex)
336
+ x = attestationObject.slice(startIndex, 32 + startIndex)
337
+ y = attestationObject.slice(35 + startIndex, 67 + startIndex)
337
338
  }
338
339
 
339
340
  publicKey = Buffer.from([
package/src/sac.ts CHANGED
@@ -1,10 +1,11 @@
1
- import { SorobanRpc } from "@stellar/stellar-sdk"
2
1
  import { Client as SacClient } from 'sac-sdk'
2
+ import { PasskeyBase } from "./base"
3
+ import type { SorobanRpc } from '@stellar/stellar-sdk'
3
4
 
4
- export class SACClient {
5
+ export class SACClient extends PasskeyBase {
6
+ declare public rpc: SorobanRpc.Server
7
+ declare public rpcUrl: string
5
8
  public networkPassphrase: string
6
- public rpcUrl: string
7
- public rpc: SorobanRpc.Server
8
9
 
9
10
  constructor(options: {
10
11
  networkPassphrase: string,
@@ -12,9 +13,9 @@ export class SACClient {
12
13
  }) {
13
14
  const { networkPassphrase, rpcUrl } = options
14
15
 
16
+ super(rpcUrl)
17
+
15
18
  this.networkPassphrase = networkPassphrase
16
- this.rpcUrl = rpcUrl
17
- this.rpc = new SorobanRpc.Server(rpcUrl)
18
19
  }
19
20
 
20
21
  public getSACClient(SACContractId: string) {
@@ -23,72 +24,5 @@ export class SACClient {
23
24
  networkPassphrase: this.networkPassphrase,
24
25
  rpcUrl: this.rpcUrl
25
26
  })
26
-
27
- // switch (command) {
28
- // case SacCommands.Allowance:
29
- // return sac.allowance(args)
30
- // case SacCommands.Authorized:
31
- // return sac.authorized(args)
32
- // case SacCommands.Approve:
33
- // return sac.approve(args)
34
- // case SacCommands.Balance:
35
- // return sac.balance(args)
36
- // case SacCommands.Burn:
37
- // return sac.burn(args)
38
- // case SacCommands.BurnFrom:
39
- // return sac.burn_from(args)
40
- // case SacCommands.Clawback:
41
- // return sac.clawback(args)
42
- // case SacCommands.Decimals:
43
- // return sac.decimals(args)
44
- // case SacCommands.Mint:
45
- // return sac.mint(args)
46
- // case SacCommands.Name:
47
- // return sac.name(args)
48
- // case SacCommands.SetAdmin:
49
- // return sac.set_admin(args)
50
- // case SacCommands.Admin:
51
- // return sac.admin(args)
52
- // case SacCommands.SetAuthorized:
53
- // return sac.set_authorized(args)
54
- // case SacCommands.Symbol:
55
- // return sac.symbol(args)
56
- // case SacCommands.Transfer:
57
- // return sac.transfer(args)
58
- // case SacCommands.TransferFrom:
59
- // return sac.transfer_from(args)
60
- // default:
61
- // throw new Error('Invalid command')
62
- // }
63
-
64
- // const { SAC, from, to, amount, fee = 0 } = args
65
- // const txn = new TransactionBuilder(mockSource, {
66
- // fee: fee.toString(),
67
- // networkPassphrase: import.meta.env.VITE_networkPassphrase
68
- // })
69
- // .addOperation(Operation.invokeContractFunction({
70
- // contract: SAC,
71
- // function: 'transfer',
72
- // args: [
73
- // nativeToScVal(from, { type: 'address' }),
74
- // nativeToScVal(to, { type: 'address' }),
75
- // nativeToScVal(amount, { type: 'i128' })
76
- // ],
77
- // }))
78
- // .setTimeout(5 * 60)
79
- // .build()
80
-
81
- // const sim = await rpc.simulateTransaction(txn)
82
-
83
- // if (
84
- // SorobanRpc.Api.isSimulationError(sim)
85
- // || SorobanRpc.Api.isSimulationRestore(sim)
86
- // ) throw sim
87
-
88
- // return {
89
- // txn,
90
- // sim,
91
- // built: SorobanRpc.assembleTransaction(txn, sim).build()
92
- // }
93
27
  }
94
28
  }
package/tsconfig.json CHANGED
@@ -23,10 +23,10 @@
23
23
  },
24
24
  "exclude": [
25
25
  "./bun_tests",
26
- "./contracts",
27
- "./demo",
26
+ "./contracts",
27
+ "./demo",
28
28
  "./packages",
29
- "./types",
30
- "./zephyr",
29
+ "./types",
30
+ "./zephyr",
31
31
  ]
32
32
  }
package/types/sac.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import { SorobanRpc } from "@stellar/stellar-sdk";
2
1
  import { Client as SacClient } from 'sac-sdk';
3
- export declare class SACClient {
4
- networkPassphrase: string;
5
- rpcUrl: string;
2
+ import { PasskeyBase } from "./base";
3
+ import type { SorobanRpc } from '@stellar/stellar-sdk';
4
+ export declare class SACClient extends PasskeyBase {
6
5
  rpc: SorobanRpc.Server;
6
+ rpcUrl: string;
7
+ networkPassphrase: string;
7
8
  constructor(options: {
8
9
  networkPassphrase: string;
9
10
  rpcUrl: string;