passkey-kit 0.10.22 → 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 +4 -4
- package/src/kit.ts +13 -9
- 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",
|
|
@@ -12,12 +12,12 @@
|
|
|
12
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.15.
|
|
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,
|
|
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: {
|
|
@@ -115,7 +115,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
115
115
|
// In this case we should save the passkey info and retry uploading it async vs asking the user to create another passkey
|
|
116
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
|
|
117
117
|
|
|
118
|
-
const
|
|
118
|
+
const rawResponse = await this.WebAuthn.startRegistration({
|
|
119
119
|
optionsJSON: {
|
|
120
120
|
challenge: base64url("stellaristhebetterblockchain"),
|
|
121
121
|
rp: {
|
|
@@ -131,11 +131,13 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
131
131
|
pubKeyCredParams: [{ alg: -7, type: "public-key" }],
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
|
+
const { id, response } = rawResponse
|
|
134
135
|
|
|
135
136
|
if (!this.keyId)
|
|
136
137
|
this.keyId = id;
|
|
137
138
|
|
|
138
139
|
return {
|
|
140
|
+
rawResponse,
|
|
139
141
|
keyId: base64url.toBuffer(id),
|
|
140
142
|
keyIdBase64: id,
|
|
141
143
|
publicKey: await this.getPublicKey(response),
|
|
@@ -150,11 +152,12 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
150
152
|
// Consider putting this somewhere else??
|
|
151
153
|
walletPublicKey?: string
|
|
152
154
|
}) {
|
|
153
|
-
let {
|
|
155
|
+
let { rpId, keyId, getContractId, walletPublicKey } = opts || {}
|
|
154
156
|
let keyIdBuffer: Buffer
|
|
157
|
+
let rawResponse: AuthenticationResponseJSON | undefined;
|
|
155
158
|
|
|
156
159
|
if (!keyId) {
|
|
157
|
-
|
|
160
|
+
rawResponse = await this.WebAuthn.startAuthentication({
|
|
158
161
|
optionsJSON: {
|
|
159
162
|
challenge: base64url("stellaristhebetterblockchain"),
|
|
160
163
|
rpId,
|
|
@@ -162,7 +165,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
162
165
|
}
|
|
163
166
|
});
|
|
164
167
|
|
|
165
|
-
keyId =
|
|
168
|
+
keyId = rawResponse.id
|
|
166
169
|
}
|
|
167
170
|
|
|
168
171
|
if (keyId instanceof Uint8Array) {
|
|
@@ -212,6 +215,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
212
215
|
})
|
|
213
216
|
|
|
214
217
|
return {
|
|
218
|
+
rawResponse,
|
|
215
219
|
keyId: keyIdBuffer,
|
|
216
220
|
keyIdBase64: keyId,
|
|
217
221
|
contractId
|
|
@@ -427,7 +431,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
427
431
|
const operation = built.operations[0] as Operation.InvokeHostFunction;
|
|
428
432
|
|
|
429
433
|
txn = await AssembledTransaction.buildWithOp<T>(
|
|
430
|
-
Operation.invokeHostFunction({ func: operation.func }),
|
|
434
|
+
Operation.invokeHostFunction({ func: operation.func }),
|
|
431
435
|
this.wallet!.options as AssembledTransactionOptions<T>
|
|
432
436
|
);
|
|
433
437
|
}
|
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;
|