passkey-kit 0.0.27 → 0.0.29
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,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passkey-kit",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@simplewebauthn/browser": "^10.0.0",
|
|
9
9
|
"@simplewebauthn/types": "^10.0.0",
|
|
10
|
-
"@stellar/stellar-sdk": "12.0.
|
|
10
|
+
"@stellar/stellar-sdk": "12.0.1",
|
|
11
11
|
"base64url": "^3.0.1",
|
|
12
12
|
"bigint-conversion": "^2.4.3",
|
|
13
13
|
"buffer": "^6.0.3",
|
|
14
14
|
"cbor-x": "^1.5.9",
|
|
15
|
-
"passkey-factory-sdk": "0.0.
|
|
16
|
-
"passkey-kit-sdk": "0.0.
|
|
15
|
+
"passkey-factory-sdk": "0.0.7",
|
|
16
|
+
"passkey-kit-sdk": "0.0.7"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"typescript": "^5.4.5"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.7",
|
|
3
3
|
"name": "passkey-factory-sdk",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"buffer": "6.0.3",
|
|
13
|
-
"@stellar/stellar-sdk": "12.0.
|
|
13
|
+
"@stellar/stellar-sdk": "12.0.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"typescript": "5.4.5"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.7",
|
|
3
3
|
"name": "passkey-kit-sdk",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "src/index.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"buffer": "6.0.3",
|
|
13
|
-
"@stellar/stellar-sdk": "12.0.
|
|
13
|
+
"@stellar/stellar-sdk": "12.0.1"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"typescript": "5.4.5"
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { bufToBigint, bigintToBuf } from 'bigint-conversion'
|
|
|
5
5
|
import base64url from 'base64url'
|
|
6
6
|
import { startRegistration, startAuthentication } from "@simplewebauthn/browser"
|
|
7
7
|
import { decode } from 'cbor-x/decode'
|
|
8
|
-
import type {
|
|
8
|
+
import type { RegistrationResponseJSON } from '@simplewebauthn/types';
|
|
9
9
|
import { Buffer } from 'buffer'
|
|
10
10
|
|
|
11
11
|
/* TODO
|
|
@@ -29,6 +29,11 @@ export class PasskeyAccount {
|
|
|
29
29
|
public feeBumpJwt: string
|
|
30
30
|
public factoryContractId: string = networks.testnet.contractId
|
|
31
31
|
|
|
32
|
+
/* TODO
|
|
33
|
+
- 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
|
|
35
|
+
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)
|
|
36
|
+
*/
|
|
32
37
|
constructor(options: {
|
|
33
38
|
sequencePublicKey: string,
|
|
34
39
|
networkPassphrase: Networks,
|
|
@@ -135,12 +140,28 @@ export class PasskeyAccount {
|
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
142
|
|
|
138
|
-
public async connectWallet() {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
public async connectWallet(id?: string) {
|
|
144
|
+
/* TODO
|
|
145
|
+
- Support passing in a contractId as well as a keyId
|
|
146
|
+
Maybe not as we wouldn't have a keyId which could have interesting consequences
|
|
147
|
+
Also not sure what the use case would be for this where keyId wouldn't also be possible and better
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
// @ts-ignore
|
|
151
|
+
// https://github.com/stellar/js-stellar-base/issues/750
|
|
152
|
+
// if (id && StrKey.isValidContract(id)) {
|
|
153
|
+
|
|
154
|
+
// } else {
|
|
155
|
+
|
|
156
|
+
// }
|
|
157
|
+
|
|
158
|
+
const startAuthenticationResponse = id
|
|
159
|
+
? { id }
|
|
160
|
+
: await startAuthentication({
|
|
161
|
+
challenge: base64url("sorobanisbest"),
|
|
162
|
+
// rpId: undefined,
|
|
163
|
+
userVerification: "discouraged",
|
|
164
|
+
});
|
|
144
165
|
|
|
145
166
|
if (!this.keyId)
|
|
146
167
|
this.keyId = startAuthenticationResponse.id
|
|
@@ -220,7 +241,7 @@ export class PasskeyAccount {
|
|
|
220
241
|
)
|
|
221
242
|
|
|
222
243
|
const authenticationResponse = await startAuthentication(
|
|
223
|
-
keyId === 'any' || (keyId === 'sudo' && !this.sudoKeyId)
|
|
244
|
+
keyId === 'any' || (keyId === 'sudo' && !this.sudoKeyId) || (!keyId && !this.keyId)
|
|
224
245
|
? {
|
|
225
246
|
challenge: base64url(authHash),
|
|
226
247
|
// rpId: undefined,
|
|
@@ -247,7 +268,7 @@ export class PasskeyAccount {
|
|
|
247
268
|
if (keyId === 'sudo')
|
|
248
269
|
this.sudoKeyId = authenticationResponse.id
|
|
249
270
|
|
|
250
|
-
// reset this.
|
|
271
|
+
// reset this.keyId to be the most recently used passkey
|
|
251
272
|
this.keyId = authenticationResponse.id
|
|
252
273
|
|
|
253
274
|
const signatureRaw = base64url.toBuffer(authenticationResponse.response.signature);
|