passkey-kit 0.0.30 → 0.1.1
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/.vscode/settings.json +6 -0
- package/README.md +9 -1
- package/package.json +7 -5
- package/src/index.ts +26 -11
- package/tsconfig.json +1 -1
- package/types/index.d.ts +4 -4
- package/types/src/index.d.ts +49 -0
package/README.md
CHANGED
|
@@ -10,4 +10,12 @@ To build:
|
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
pnpm run build
|
|
13
|
-
```
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
If you fiddle with contracts in `./contracts` you'll need to run the make commands. Just remember to update the `WEBAUTHN_FACTORY` and `WEBAUTHN_WASM` values from the `make deploy` command before running `make init`. Once you run `make init` you'll need to update all the `.env` site files with the new `PUBLIC_factoryContractId`.
|
|
16
|
+
|
|
17
|
+
Keep in mind the bindings here in `./packages` have been _heavily_ modified. Be careful when rebuilding and updating. Likely you'll only want to update the `src/index.ts` files in each respective package.
|
|
18
|
+
|
|
19
|
+
## TODO
|
|
20
|
+
- [ ] Signer list should be paginated
|
|
21
|
+
- [ ] Attach some meaningful metadata to signers so you know which one belongs to which domain
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passkey-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
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",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"bigint-conversion": "^2.4.3",
|
|
16
16
|
"buffer": "^6.0.3",
|
|
17
17
|
"cbor-x": "^1.5.9",
|
|
18
|
-
"passkey-
|
|
19
|
-
"passkey-
|
|
18
|
+
"passkey-factory-sdk": "0.0.7",
|
|
19
|
+
"passkey-kit-sdk": "0.0.7"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"typescript": "^5.4.5"
|
|
@@ -34,10 +34,12 @@
|
|
|
34
34
|
"keywords": [
|
|
35
35
|
"smart wallet",
|
|
36
36
|
"passkey",
|
|
37
|
-
"
|
|
37
|
+
"webauthn",
|
|
38
38
|
"blockchain",
|
|
39
39
|
"stellar",
|
|
40
|
-
"web3"
|
|
40
|
+
"web3",
|
|
41
|
+
"account abstraction",
|
|
42
|
+
"secp256r1"
|
|
41
43
|
],
|
|
42
44
|
"bugs": {
|
|
43
45
|
"url": "https://github.com/kalepail/passkey-kit/issues"
|
package/src/index.ts
CHANGED
|
@@ -11,6 +11,8 @@ import { Buffer } from 'buffer'
|
|
|
11
11
|
/* TODO
|
|
12
12
|
- Clean up these params and the interface as a whole
|
|
13
13
|
Might put wallet activities and maybe factory as well into the root of the class vs buried inside this.wallet and this.factory
|
|
14
|
+
@Later
|
|
15
|
+
|
|
14
16
|
- Right now publicKey can mean a Stellar public key or a passkey public key, there should be a noted difference
|
|
15
17
|
*/
|
|
16
18
|
|
|
@@ -25,23 +27,30 @@ export class PasskeyAccount {
|
|
|
25
27
|
public horizon: Horizon.Server
|
|
26
28
|
public rpcUrl: string
|
|
27
29
|
public rpc: SorobanRpc.Server
|
|
28
|
-
public feeBumpUrl: string
|
|
29
|
-
public feeBumpJwt: string
|
|
30
|
+
public feeBumpUrl: string | undefined
|
|
31
|
+
public feeBumpJwt: string | undefined
|
|
30
32
|
public factoryContractId: string = networks.testnet.contractId
|
|
31
33
|
|
|
32
34
|
/* TODO
|
|
33
35
|
- Consider adding the ability to pass in a keyId and maybe even a contractId in order to preconnect to a wallet
|
|
34
|
-
If just a keyId call connectWallet in order to get the contractId
|
|
36
|
+
If just a keyId call `connectWallet` in order to get the contractId
|
|
35
37
|
If both keyId and contractId are passed in then we can skip the connectWallet call (though we won't get the sudoKeyId in that case)
|
|
38
|
+
We don't stictly _need_ this as a dev can just call `connectWallet` after class instantiation but it might be a nice convenience
|
|
39
|
+
@Later
|
|
36
40
|
*/
|
|
37
41
|
constructor(options: {
|
|
38
42
|
sequencePublicKey: string,
|
|
39
43
|
networkPassphrase: Networks,
|
|
40
44
|
horizonUrl: string,
|
|
41
45
|
rpcUrl: string,
|
|
42
|
-
feeBumpUrl
|
|
43
|
-
feeBumpJwt
|
|
44
|
-
|
|
46
|
+
feeBumpUrl?: string,
|
|
47
|
+
feeBumpJwt?: string,
|
|
48
|
+
/* TODO
|
|
49
|
+
- Maybe remove this? The factory should likely be baked in a bit more tightly
|
|
50
|
+
On the other hand once we have a standard interface the factory interface only uses the `deploy` method right now inside the interface
|
|
51
|
+
@Later
|
|
52
|
+
*/
|
|
53
|
+
factoryContractId?: string,
|
|
45
54
|
}) {
|
|
46
55
|
const {
|
|
47
56
|
sequencePublicKey,
|
|
@@ -59,8 +68,12 @@ export class PasskeyAccount {
|
|
|
59
68
|
this.horizon = new Horizon.Server(horizonUrl)
|
|
60
69
|
this.rpcUrl = rpcUrl
|
|
61
70
|
this.rpc = new SorobanRpc.Server(rpcUrl)
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
|
|
72
|
+
if (feeBumpUrl)
|
|
73
|
+
this.feeBumpUrl = feeBumpUrl
|
|
74
|
+
|
|
75
|
+
if (feeBumpJwt)
|
|
76
|
+
this.feeBumpJwt = feeBumpJwt
|
|
64
77
|
|
|
65
78
|
if (factoryContractId)
|
|
66
79
|
this.factoryContractId = factoryContractId
|
|
@@ -99,7 +112,7 @@ export class PasskeyAccount {
|
|
|
99
112
|
|
|
100
113
|
public async createKey(name: string, user: string) {
|
|
101
114
|
const startRegistrationResponse = await startRegistration({
|
|
102
|
-
challenge: base64url("
|
|
115
|
+
challenge: base64url("stellaristhebetterblockchain"),
|
|
103
116
|
rp: {
|
|
104
117
|
// id: undefined,
|
|
105
118
|
name,
|
|
@@ -145,6 +158,7 @@ export class PasskeyAccount {
|
|
|
145
158
|
- Support passing in a contractId as well as a keyId
|
|
146
159
|
Maybe not as we wouldn't have a keyId which could have interesting consequences
|
|
147
160
|
Also not sure what the use case would be for this where keyId wouldn't also be possible and better
|
|
161
|
+
@No
|
|
148
162
|
*/
|
|
149
163
|
|
|
150
164
|
// @ts-ignore
|
|
@@ -158,7 +172,7 @@ export class PasskeyAccount {
|
|
|
158
172
|
const startAuthenticationResponse = id
|
|
159
173
|
? { id }
|
|
160
174
|
: await startAuthentication({
|
|
161
|
-
challenge: base64url("
|
|
175
|
+
challenge: base64url("stellaristhebetterblockchain"),
|
|
162
176
|
// rpId: undefined,
|
|
163
177
|
userVerification: "discouraged",
|
|
164
178
|
});
|
|
@@ -226,6 +240,7 @@ export class PasskeyAccount {
|
|
|
226
240
|
), { fee: '0' }).build()
|
|
227
241
|
|
|
228
242
|
// NOTE hard coded to sign only Soroban transactions and only and always the first auth
|
|
243
|
+
// TODO switch to support signing multiple and specific auth entries. Possibly pass in auth entry vs the entire txn
|
|
229
244
|
const op = txn.operations[0] as Operation.InvokeHostFunction
|
|
230
245
|
const auth = op.auth![0]
|
|
231
246
|
const lastLedger = await this.rpc.getLatestLedger().then(({ sequence }) => sequence)
|
|
@@ -311,7 +326,7 @@ export class PasskeyAccount {
|
|
|
311
326
|
data.set('xdr', txn.toXDR());
|
|
312
327
|
data.set('fee', fee.toString());
|
|
313
328
|
|
|
314
|
-
const bumptxn = await fetch(this.feeBumpUrl
|
|
329
|
+
const bumptxn = await fetch(this.feeBumpUrl!, {
|
|
315
330
|
method: 'POST',
|
|
316
331
|
headers: {
|
|
317
332
|
authorization: `Bearer ${this.feeBumpJwt}`,
|
package/tsconfig.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -13,16 +13,16 @@ export declare class PasskeyAccount {
|
|
|
13
13
|
horizon: Horizon.Server;
|
|
14
14
|
rpcUrl: string;
|
|
15
15
|
rpc: SorobanRpc.Server;
|
|
16
|
-
feeBumpUrl: string;
|
|
17
|
-
feeBumpJwt: string;
|
|
16
|
+
feeBumpUrl: string | undefined;
|
|
17
|
+
feeBumpJwt: string | undefined;
|
|
18
18
|
factoryContractId: string;
|
|
19
19
|
constructor(options: {
|
|
20
20
|
sequencePublicKey: string;
|
|
21
21
|
networkPassphrase: Networks;
|
|
22
22
|
horizonUrl: string;
|
|
23
23
|
rpcUrl: string;
|
|
24
|
-
feeBumpUrl
|
|
25
|
-
feeBumpJwt
|
|
24
|
+
feeBumpUrl?: string;
|
|
25
|
+
feeBumpJwt?: string;
|
|
26
26
|
factoryContractId?: string;
|
|
27
27
|
});
|
|
28
28
|
createWallet(name: string, user: string): Promise<{
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Client as PasskeyClient } from 'passkey-kit-sdk';
|
|
2
|
+
import { Client as FactoryClient } from 'passkey-factory-sdk';
|
|
3
|
+
import { Networks, Transaction, Horizon, SorobanRpc } from '@stellar/stellar-sdk';
|
|
4
|
+
import { Buffer } from 'buffer';
|
|
5
|
+
export declare class PasskeyAccount {
|
|
6
|
+
keyId: string | undefined;
|
|
7
|
+
sudoKeyId: string | undefined;
|
|
8
|
+
wallet: PasskeyClient | undefined;
|
|
9
|
+
factory: FactoryClient;
|
|
10
|
+
sequencePublicKey: string;
|
|
11
|
+
networkPassphrase: Networks;
|
|
12
|
+
horizonUrl: string;
|
|
13
|
+
horizon: Horizon.Server;
|
|
14
|
+
rpcUrl: string;
|
|
15
|
+
rpc: SorobanRpc.Server;
|
|
16
|
+
feeBumpUrl: string | undefined;
|
|
17
|
+
feeBumpJwt: string | undefined;
|
|
18
|
+
factoryContractId: string;
|
|
19
|
+
constructor(options: {
|
|
20
|
+
sequencePublicKey: string;
|
|
21
|
+
networkPassphrase: Networks;
|
|
22
|
+
horizonUrl: string;
|
|
23
|
+
rpcUrl: string;
|
|
24
|
+
feeBumpUrl?: string;
|
|
25
|
+
feeBumpJwt?: string;
|
|
26
|
+
factoryContractId?: string;
|
|
27
|
+
});
|
|
28
|
+
createWallet(name: string, user: string): Promise<{
|
|
29
|
+
keyId: Buffer;
|
|
30
|
+
contractId: string;
|
|
31
|
+
xdr: string;
|
|
32
|
+
}>;
|
|
33
|
+
createKey(name: string, user: string): Promise<{
|
|
34
|
+
keyId: Buffer;
|
|
35
|
+
publicKey: Buffer;
|
|
36
|
+
}>;
|
|
37
|
+
connectWallet(id?: string): Promise<{
|
|
38
|
+
keyId: Buffer;
|
|
39
|
+
contractId: string;
|
|
40
|
+
}>;
|
|
41
|
+
sign(txn: Transaction | string, options?: {
|
|
42
|
+
keyId?: 'any' | 'sudo' | string | Uint8Array;
|
|
43
|
+
ledgersToLive?: number;
|
|
44
|
+
}): Promise<string>;
|
|
45
|
+
send(txn: Transaction, fee?: number): Promise<Horizon.HorizonApi.SubmitTransactionResponse>;
|
|
46
|
+
getData(): Promise<Map<string, any>>;
|
|
47
|
+
private getPublicKeyObject;
|
|
48
|
+
private convertEcdsaSignatureAsnToCompact;
|
|
49
|
+
}
|