passkey-kit 0.10.21 → 0.10.23
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 +6 -6
- package/packages/passkey-kit-sdk/package.json +3 -3
- package/packages/sac-sdk/package.json +3 -3
- package/src/kit.ts +15 -13
- package/src/sac.ts +1 -1
- package/types/kit.d.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passkey-kit",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.23",
|
|
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",
|
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
"types": "types/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@simplewebauthn/browser": "^13.1.0",
|
|
12
|
-
"@stellar/stellar-sdk": "^13.
|
|
12
|
+
"@stellar/stellar-sdk": "^13.3.0",
|
|
13
13
|
"base64url": "^3.0.1",
|
|
14
14
|
"buffer": "^6.0.3",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"sac-sdk": "0.3.8",
|
|
16
|
+
"passkey-kit-sdk": "0.6.8"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@simplewebauthn/types": "^12.0.0",
|
|
20
|
-
"@types/node": "^22.
|
|
21
|
-
"typescript": "^5.8.
|
|
20
|
+
"@types/node": "^22.15.3",
|
|
21
|
+
"typescript": "^5.8.3"
|
|
22
22
|
},
|
|
23
23
|
"workspaces": [
|
|
24
24
|
"packages/*"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
2
|
+
"version": "0.6.8",
|
|
3
3
|
"name": "passkey-kit-sdk",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"build": "tsc"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@stellar/stellar-sdk": "^13.
|
|
12
|
+
"@stellar/stellar-sdk": "^13.3.0",
|
|
13
13
|
"buffer": "^6.0.3"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"typescript": "^5.8.
|
|
16
|
+
"typescript": "^5.8.3"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.3.
|
|
2
|
+
"version": "0.3.8",
|
|
3
3
|
"name": "sac-sdk",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"build": "tsc"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@stellar/stellar-sdk": "^13.
|
|
12
|
+
"@stellar/stellar-sdk": "^13.3.0",
|
|
13
13
|
"buffer": "^6.0.3"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"typescript": "^5.8.
|
|
16
|
+
"typescript": "^5.8.3"
|
|
17
17
|
}
|
|
18
18
|
}
|
package/src/kit.ts
CHANGED
|
@@ -1,22 +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,
|
|
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
|
-
// TODO default to 30 second timeouts
|
|
13
|
-
|
|
14
12
|
export class PasskeyKit extends PasskeyBase {
|
|
15
13
|
declare rpc: Server
|
|
16
14
|
declare rpcUrl: string
|
|
17
15
|
|
|
18
|
-
private walletKeypair: Keypair
|
|
19
|
-
private walletPublicKey: string
|
|
16
|
+
private walletKeypair: Keypair
|
|
17
|
+
private walletPublicKey: string
|
|
20
18
|
private walletWasmHash: string
|
|
21
19
|
private timeoutInSeconds: number
|
|
22
20
|
private WebAuthn: {
|
|
@@ -51,7 +49,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
51
49
|
this.walletKeypair = Keypair.fromRawEd25519Seed(hash(Buffer.from('kalepail')));
|
|
52
50
|
this.walletPublicKey = this.walletKeypair.publicKey()
|
|
53
51
|
this.walletWasmHash = walletWasmHash
|
|
54
|
-
this.timeoutInSeconds = options.timeoutInSeconds ||
|
|
52
|
+
this.timeoutInSeconds = options.timeoutInSeconds || 30 // Launchtube requires <= 30 second timeout so let's default to that
|
|
55
53
|
this.WebAuthn = WebAuthn || { startRegistration, startAuthentication }
|
|
56
54
|
}
|
|
57
55
|
|
|
@@ -117,7 +115,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
117
115
|
// In this case we should save the passkey info and retry uploading it async vs asking the user to create another passkey
|
|
118
116
|
// 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
|
|
119
117
|
|
|
120
|
-
const
|
|
118
|
+
const rawResponse = await this.WebAuthn.startRegistration({
|
|
121
119
|
optionsJSON: {
|
|
122
120
|
challenge: base64url("stellaristhebetterblockchain"),
|
|
123
121
|
rp: {
|
|
@@ -133,11 +131,13 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
133
131
|
pubKeyCredParams: [{ alg: -7, type: "public-key" }],
|
|
134
132
|
}
|
|
135
133
|
});
|
|
134
|
+
const { id, response } = rawResponse
|
|
136
135
|
|
|
137
136
|
if (!this.keyId)
|
|
138
137
|
this.keyId = id;
|
|
139
138
|
|
|
140
139
|
return {
|
|
140
|
+
rawResponse,
|
|
141
141
|
keyId: base64url.toBuffer(id),
|
|
142
142
|
keyIdBase64: id,
|
|
143
143
|
publicKey: await this.getPublicKey(response),
|
|
@@ -152,11 +152,12 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
152
152
|
// Consider putting this somewhere else??
|
|
153
153
|
walletPublicKey?: string
|
|
154
154
|
}) {
|
|
155
|
-
let {
|
|
155
|
+
let { rpId, keyId, getContractId, walletPublicKey } = opts || {}
|
|
156
156
|
let keyIdBuffer: Buffer
|
|
157
|
+
let rawResponse: AuthenticationResponseJSON | undefined;
|
|
157
158
|
|
|
158
159
|
if (!keyId) {
|
|
159
|
-
|
|
160
|
+
rawResponse = await this.WebAuthn.startAuthentication({
|
|
160
161
|
optionsJSON: {
|
|
161
162
|
challenge: base64url("stellaristhebetterblockchain"),
|
|
162
163
|
rpId,
|
|
@@ -164,7 +165,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
164
165
|
}
|
|
165
166
|
});
|
|
166
167
|
|
|
167
|
-
keyId =
|
|
168
|
+
keyId = rawResponse.id
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
if (keyId instanceof Uint8Array) {
|
|
@@ -214,6 +215,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
214
215
|
})
|
|
215
216
|
|
|
216
217
|
return {
|
|
218
|
+
rawResponse,
|
|
217
219
|
keyId: keyIdBuffer,
|
|
218
220
|
keyIdBase64: keyId,
|
|
219
221
|
contractId
|
|
@@ -242,7 +244,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
242
244
|
|
|
243
245
|
if (!expiration) {
|
|
244
246
|
const { sequence } = await this.rpc.getLatestLedger()
|
|
245
|
-
expiration = sequence +
|
|
247
|
+
expiration = sequence + this.timeoutInSeconds / 5; // assumes 5 second ledger time
|
|
246
248
|
}
|
|
247
249
|
}
|
|
248
250
|
|
|
@@ -429,7 +431,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
429
431
|
const operation = built.operations[0] as Operation.InvokeHostFunction;
|
|
430
432
|
|
|
431
433
|
txn = await AssembledTransaction.buildWithOp<T>(
|
|
432
|
-
Operation.invokeHostFunction({ func: operation.func }),
|
|
434
|
+
Operation.invokeHostFunction({ func: operation.func }),
|
|
433
435
|
this.wallet!.options as AssembledTransactionOptions<T>
|
|
434
436
|
);
|
|
435
437
|
}
|
package/src/sac.ts
CHANGED
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';
|
|
@@ -38,6 +38,7 @@ export declare class PasskeyKit extends PasskeyBase {
|
|
|
38
38
|
rpId?: string;
|
|
39
39
|
authenticatorSelection?: AuthenticatorSelectionCriteria;
|
|
40
40
|
}): Promise<{
|
|
41
|
+
rawResponse: import("@simplewebauthn/browser").RegistrationResponseJSON;
|
|
41
42
|
keyId: Buffer<ArrayBufferLike>;
|
|
42
43
|
keyIdBase64: string;
|
|
43
44
|
publicKey: Buffer<ArrayBufferLike>;
|
|
@@ -48,6 +49,7 @@ export declare class PasskeyKit extends PasskeyBase {
|
|
|
48
49
|
getContractId?: (keyId: string) => Promise<string | undefined>;
|
|
49
50
|
walletPublicKey?: string;
|
|
50
51
|
}): Promise<{
|
|
52
|
+
rawResponse: AuthenticationResponseJSON | undefined;
|
|
51
53
|
keyId: Buffer<ArrayBufferLike>;
|
|
52
54
|
keyIdBase64: string;
|
|
53
55
|
contractId: string;
|