passkey-kit 0.5.2 → 0.5.3
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 +15 -14
- package/package.json +3 -3
- package/src/kit.ts +6 -6
- package/tsconfig.json +4 -9
- package/types/kit.d.ts +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Passkey Kit
|
|
2
2
|
|
|
3
|
-
Passkey kit is a basic TypeScript SDK for creating and managing Stellar smart wallets. It's intended to be used in tandem with [Launchtube](https://github.com/kalepail/launchtube) for submitting passkey signed transactions onchain however this is not a requirement. This is both a client and a server side library. `PasskeyKit` on the client and `
|
|
3
|
+
Passkey kit is a basic TypeScript SDK for creating and managing Stellar smart wallets. It's intended to be used in tandem with [Launchtube](https://github.com/kalepail/launchtube) for submitting passkey signed transactions onchain however this is not a requirement. This is both a client and a server side library. `PasskeyKit` on the client and `PasskeyServer` on the server.
|
|
4
4
|
|
|
5
5
|
Demo site: [passkey-kit-demo.pages.dev](https://passkey-kit-demo.pages.dev/)
|
|
6
6
|
|
|
@@ -20,7 +20,7 @@ const account = new PasskeyKit({
|
|
|
20
20
|
|
|
21
21
|
On the server:
|
|
22
22
|
```ts
|
|
23
|
-
const account = new
|
|
23
|
+
const account = new PasskeyServer({
|
|
24
24
|
rpcUrl: env.PUBLIC_rpcUrl,
|
|
25
25
|
launchtubeUrl: env.PUBLIC_launchtubeUrl,
|
|
26
26
|
launchtubeJwt: env.PRIVATE_launchtubeJwt,
|
|
@@ -30,9 +30,15 @@ const account = new PasskeyBase({
|
|
|
30
30
|
});
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
This is a fully typed library so docs aren't provided, however there's a full example showcasing all the core public methods in the `./demo` directory. I also recommend reviewing the [Super Peach](https://github.com/kalepail/superpeach) repo for an example of how you could implement both the client and server side in a more real-world scenario.
|
|
34
|
+
|
|
35
|
+
Good luck, have fun, and change the world!
|
|
36
|
+
|
|
37
|
+
For any questions or to showcase your progress please join the `#passkeys` channel on our [Discord](https://discord.gg/stellardev).
|
|
38
|
+
|
|
39
|
+
## Deploy the event indexer
|
|
34
40
|
|
|
35
|
-
In order to utilize the
|
|
41
|
+
In order to utilize the Mercury Zephyr indexing service to track available signers and reverse lookup smart wallet contract addresses from passkey ids you'll need to deploy the Zephyr program from inside the `./zephyr` directory.
|
|
36
42
|
|
|
37
43
|
```bash
|
|
38
44
|
cd ./zephyr
|
|
@@ -43,13 +49,7 @@ export MERCURY_JWT="<YOUR.MERCURY.JWT>"
|
|
|
43
49
|
mercury-cli --jwt $MERCURY_JWT --local false --mainnet false deploy
|
|
44
50
|
```
|
|
45
51
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Good luck, have fun, and change the world!
|
|
49
|
-
|
|
50
|
-
For any questions or to showcase your progress please join the `#passkeys` channel on our [Discord](https://discord.gg/stellardev).
|
|
51
|
-
|
|
52
|
-
## Some Notes
|
|
52
|
+
## TypeScript gotchas
|
|
53
53
|
|
|
54
54
|
This is a TypeScript library and the npm package doesn't export a JavaScript version. The `@stellar/stellar-sdk` library is enormous and I really don't wan't folks bundling it up twice. Therefore you'll need to ensure you're transpiling this library into your project and that goes for either a TS project or a JS one. For many of you this will "just work" but for others you'll need to do some fiddling.
|
|
55
55
|
|
|
@@ -60,7 +60,8 @@ const nextConfig = {
|
|
|
60
60
|
transpilePackages: [
|
|
61
61
|
'passkey-kit',
|
|
62
62
|
'passkey-factory-sdk',
|
|
63
|
-
'passkey-kit-sdk'
|
|
63
|
+
'passkey-kit-sdk',
|
|
64
|
+
'sac-sdk',
|
|
64
65
|
]
|
|
65
66
|
};
|
|
66
67
|
|
|
@@ -71,10 +72,10 @@ If someone smarter than me knows how to include an optional JS build from a TS l
|
|
|
71
72
|
## Contributing
|
|
72
73
|
|
|
73
74
|
Passkey kit consists of three primary directories:
|
|
74
|
-
- `./contracts` - Contains the Rust Soroban smart contracts of the smart wallet implementation.
|
|
75
|
-
- `./zephyr` - Contains the [Zephyr](https://www.mercurydata.app/products/zephyr-vm) program for processing smart wallet events.
|
|
76
75
|
- `./src` - Contains the TypeScript files for the actual TS SDK library.
|
|
77
76
|
- `./demo` - Contains a basic demo of the SDK in action.
|
|
77
|
+
- `./contracts` - Contains the Rust Soroban smart contracts of the smart wallet implementation.
|
|
78
|
+
- `./zephyr` - Contains the [Zephyr](https://www.mercurydata.app/products/zephyr-vm) program for processing smart wallet events.
|
|
78
79
|
|
|
79
80
|
To install dependencies:
|
|
80
81
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passkey-kit",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
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-
|
|
17
|
-
"passkey-
|
|
16
|
+
"passkey-factory-sdk": "0.2.1",
|
|
17
|
+
"passkey-kit-sdk": "0.2.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@simplewebauthn/types": "^10.0.0",
|
package/src/kit.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { startRegistration, startAuthentication } from "@simplewebauthn/browser"
|
|
|
6
6
|
import type { AuthenticatorAttestationResponseJSON } from "@simplewebauthn/types"
|
|
7
7
|
import { Buffer } from 'buffer'
|
|
8
8
|
import { PasskeyBase } from './base'
|
|
9
|
+
import { DEFAULT_TIMEOUT } from '@stellar/stellar-sdk/contract'
|
|
9
10
|
|
|
10
11
|
export class PasskeyKit extends PasskeyBase {
|
|
11
12
|
declare public rpc: SorobanRpc.Server
|
|
@@ -41,7 +42,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
41
42
|
pk: publicKey
|
|
42
43
|
})
|
|
43
44
|
|
|
44
|
-
const contractId = result.unwrap()
|
|
45
|
+
const contractId = result.unwrap()
|
|
45
46
|
|
|
46
47
|
this.wallet = new PasskeyClient({
|
|
47
48
|
contractId,
|
|
@@ -52,7 +53,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
52
53
|
return {
|
|
53
54
|
keyId,
|
|
54
55
|
contractId,
|
|
55
|
-
xdr: built
|
|
56
|
+
xdr: built?.toXDR()
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
|
|
@@ -162,8 +163,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
162
163
|
ledgersToLive?: number
|
|
163
164
|
}
|
|
164
165
|
) {
|
|
165
|
-
|
|
166
|
-
let { keyId, ledgersToLive = 60 } = options || {}
|
|
166
|
+
let { keyId, ledgersToLive = DEFAULT_TIMEOUT } = options || {}
|
|
167
167
|
|
|
168
168
|
const lastLedger = await this.rpc.getLatestLedger().then(({ sequence }) => sequence)
|
|
169
169
|
const credentials = entry.credentials().address();
|
|
@@ -242,7 +242,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
242
242
|
&& auth.credentials().address().address().switch().name === 'scAddressTypeContract'
|
|
243
243
|
) {
|
|
244
244
|
// If auth entry matches our Smart Wallet move forward with the signature request
|
|
245
|
-
if (Address.contract(auth.credentials().address().address().contractId()).toString() === this.wallet
|
|
245
|
+
if (Address.contract(auth.credentials().address().address().contractId()).toString() === this.wallet?.options.contractId)
|
|
246
246
|
await this.signAuthEntry(auth, options)
|
|
247
247
|
}
|
|
248
248
|
}
|
|
@@ -309,7 +309,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
309
309
|
|
|
310
310
|
if (response.publicKey) {
|
|
311
311
|
publicKey = base64url.toBuffer(response.publicKey)
|
|
312
|
-
publicKey = publicKey
|
|
312
|
+
publicKey = publicKey?.slice(publicKey.length - 65)
|
|
313
313
|
}
|
|
314
314
|
|
|
315
315
|
if (
|
package/tsconfig.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"module": "ESNext",
|
|
7
7
|
"moduleDetection": "force",
|
|
8
8
|
// Bundler mode
|
|
9
|
-
"moduleResolution": "
|
|
9
|
+
"moduleResolution": "Bundler",
|
|
10
10
|
"allowImportingTsExtensions": true,
|
|
11
11
|
"verbatimModuleSyntax": true,
|
|
12
12
|
"declaration": true,
|
|
@@ -21,12 +21,7 @@
|
|
|
21
21
|
"noPropertyAccessFromIndexSignature": false,
|
|
22
22
|
"strictNullChecks": true,
|
|
23
23
|
},
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
"./demo",
|
|
28
|
-
"./packages",
|
|
29
|
-
"./types",
|
|
30
|
-
"./zephyr",
|
|
31
|
-
]
|
|
24
|
+
"include": [
|
|
25
|
+
"src/*",
|
|
26
|
+
],
|
|
32
27
|
}
|
package/types/kit.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class PasskeyKit extends PasskeyBase {
|
|
|
18
18
|
createWallet(app: string, user: string): Promise<{
|
|
19
19
|
keyId: Buffer;
|
|
20
20
|
contractId: string;
|
|
21
|
-
xdr: string;
|
|
21
|
+
xdr: string | undefined;
|
|
22
22
|
}>;
|
|
23
23
|
createKey(app: string, user: string): Promise<{
|
|
24
24
|
keyId: Buffer;
|