passkey-kit 0.5.3 → 0.5.4
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 +2 -2
- package/cheatsheet +1 -1
- package/package.json +4 -3
- package/src/kit.ts +16 -7
- package/src/server.ts +1 -0
- package/types/kit.d.ts +9 -0
package/.vscode/settings.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"rust-analyzer.linkedProjects": [
|
|
3
3
|
"./zephyr/Cargo.toml",
|
|
4
4
|
"./contracts/Cargo.toml",
|
|
5
|
-
"./contracts/
|
|
6
|
-
"./contracts/
|
|
5
|
+
"./contracts/webauthn-factory/Cargo.toml",
|
|
6
|
+
"./contracts/webauthn-wallet/Cargo.toml",
|
|
7
7
|
]
|
|
8
8
|
}
|
package/cheatsheet
CHANGED
|
@@ -9,7 +9,7 @@ pnpm publish --no-git-checks
|
|
|
9
9
|
|
|
10
10
|
export MERCURY_JWT=???
|
|
11
11
|
mercury-cli --jwt $MERCURY_JWT --local false --mainnet false deploy
|
|
12
|
-
mercury-cli --jwt $MERCURY_JWT --local false --mainnet false catchup --contracts "
|
|
12
|
+
mercury-cli --jwt $MERCURY_JWT --local false --mainnet false catchup --contracts "CDOWBLFYFIWXVUW46QILLAIYIWWCZ63CIRQBG3DK5PDBUVVJ4QVJX2IX" # don't forget to subscribe to the contract first
|
|
13
13
|
curl -X GET https://api.mercurydata.app/catchups/4
|
|
14
14
|
curl -X POST https://api.mercurydata.app/zephyr/execute -H "Authorization: Bearer $MERCURY_JWT" -H 'Content-Type: application/json' -d '{"mode":{"Function": {"fname": "get_signers_by_address", "arguments": "{\"address\": \"CCXIUFR243N7QWKXY44LZO3DVUXHAVBEEJWFGNGNVVB44VJXIYWVGNTR\"}"}}}'
|
|
15
15
|
curl -X POST https://api.mercurydata.app/zephyr/execute -H "Authorization: Bearer $MERCURY_JWT" -H 'Content-Type: application/json' -d '{"mode":{"Function": {"fname": "get_address_by_signer", "arguments": "{\"id\": [78,127,30,69,248,174,95,168,47,59,161,168,51,120,117,135,112,133,232,92]}"}}}'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passkey-kit",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
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",
|
|
@@ -8,13 +8,14 @@
|
|
|
8
8
|
"main": "src/index.ts",
|
|
9
9
|
"types": "types/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"@darkedges/capacitor-native-webauthn": "^0.0.4",
|
|
11
12
|
"@simplewebauthn/browser": "^10.0.0",
|
|
12
13
|
"@stellar/stellar-sdk": "12.1.0",
|
|
13
14
|
"base64url": "^3.0.1",
|
|
14
15
|
"buffer": "^6.0.3",
|
|
15
|
-
"sac-sdk": "0.1.0",
|
|
16
16
|
"passkey-factory-sdk": "0.2.1",
|
|
17
|
-
"passkey-kit-sdk": "0.2.1"
|
|
17
|
+
"passkey-kit-sdk": "0.2.1",
|
|
18
|
+
"sac-sdk": "0.1.0"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@simplewebauthn/types": "^10.0.0",
|
package/src/kit.ts
CHANGED
|
@@ -15,11 +15,19 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
15
15
|
public networkPassphrase: string
|
|
16
16
|
public factory: FactoryClient
|
|
17
17
|
public wallet: PasskeyClient | undefined
|
|
18
|
+
public WebAuthn: {
|
|
19
|
+
startRegistration: typeof startRegistration,
|
|
20
|
+
startAuthentication: typeof startAuthentication
|
|
21
|
+
}
|
|
18
22
|
|
|
19
23
|
constructor(options: {
|
|
20
24
|
rpcUrl: string,
|
|
21
25
|
networkPassphrase: string,
|
|
22
26
|
factoryContractId: string,
|
|
27
|
+
WebAuthn?: {
|
|
28
|
+
startRegistration: typeof startRegistration,
|
|
29
|
+
startAuthentication: typeof startAuthentication
|
|
30
|
+
}
|
|
23
31
|
}) {
|
|
24
32
|
const { rpcUrl, networkPassphrase, factoryContractId } = options
|
|
25
33
|
|
|
@@ -31,6 +39,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
31
39
|
networkPassphrase,
|
|
32
40
|
rpcUrl
|
|
33
41
|
})
|
|
42
|
+
this.WebAuthn = options.WebAuthn || { startRegistration, startAuthentication }
|
|
34
43
|
}
|
|
35
44
|
|
|
36
45
|
public async createWallet(app: string, user: string) {
|
|
@@ -60,7 +69,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
60
69
|
public async createKey(app: string, user: string) {
|
|
61
70
|
const now = new Date()
|
|
62
71
|
const displayName = `${user} — ${now.toLocaleString()}`
|
|
63
|
-
const { id, response } = await startRegistration({
|
|
72
|
+
const { id, response } = await this.WebAuthn.startRegistration({
|
|
64
73
|
challenge: base64url("stellaristhebetterblockchain"),
|
|
65
74
|
rp: {
|
|
66
75
|
// id: undefined,
|
|
@@ -72,9 +81,9 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
72
81
|
displayName
|
|
73
82
|
},
|
|
74
83
|
// authenticatorSelection: {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
84
|
+
// requireResidentKey: false,
|
|
85
|
+
// residentKey: "preferred",
|
|
86
|
+
// userVerification: "discouraged",
|
|
78
87
|
// },
|
|
79
88
|
pubKeyCredParams: [{ alg: -7, type: "public-key" }],
|
|
80
89
|
// attestation: "none",
|
|
@@ -98,7 +107,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
98
107
|
let keyIdBuffer: Buffer
|
|
99
108
|
|
|
100
109
|
if (!keyId) {
|
|
101
|
-
const response = await startAuthentication({
|
|
110
|
+
const response = await this.WebAuthn.startAuthentication({
|
|
102
111
|
challenge: base64url("stellaristhebetterblockchain"),
|
|
103
112
|
// rpId: undefined,
|
|
104
113
|
// userVerification: "discouraged",
|
|
@@ -177,7 +186,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
177
186
|
)
|
|
178
187
|
const payload = hash(preimage.toXDR())
|
|
179
188
|
|
|
180
|
-
const authenticationResponse = await startAuthentication(
|
|
189
|
+
const authenticationResponse = await this.WebAuthn.startAuthentication(
|
|
181
190
|
keyId === 'any'
|
|
182
191
|
|| (!keyId && !this.keyId)
|
|
183
192
|
? {
|
|
@@ -331,7 +340,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
331
340
|
|
|
332
341
|
let publicKeykPrefixSlice = Buffer.from([0xa5, 0x01, 0x02, 0x03, 0x26, 0x20, 0x01, 0x21, 0x58, 0x20])
|
|
333
342
|
let startIndex = attestationObject.indexOf(publicKeykPrefixSlice)
|
|
334
|
-
|
|
343
|
+
startIndex = startIndex + publicKeykPrefixSlice.length
|
|
335
344
|
|
|
336
345
|
x = attestationObject.slice(startIndex, 32 + startIndex)
|
|
337
346
|
y = attestationObject.slice(35 + startIndex, 67 + startIndex)
|
package/src/server.ts
CHANGED
|
@@ -167,6 +167,7 @@ export class PasskeyServer extends PasskeyBase {
|
|
|
167
167
|
@Later
|
|
168
168
|
*/
|
|
169
169
|
|
|
170
|
+
// TODO maybe fee should default to something more dynamic since we have endpoints for getting fee information now
|
|
170
171
|
public async send(xdr: string, fee: number = 10_000) {
|
|
171
172
|
if (!this.launchtubeUrl || !this.launchtubeJwt)
|
|
172
173
|
throw new Error('Launchtube service not configured')
|
package/types/kit.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Client as PasskeyClient } from 'passkey-kit-sdk';
|
|
2
2
|
import { Client as FactoryClient } from 'passkey-factory-sdk';
|
|
3
3
|
import { xdr, Transaction, SorobanRpc } from '@stellar/stellar-sdk';
|
|
4
|
+
import { startRegistration, startAuthentication } from "@simplewebauthn/browser";
|
|
4
5
|
import { Buffer } from 'buffer';
|
|
5
6
|
import { PasskeyBase } from './base';
|
|
6
7
|
export declare class PasskeyKit extends PasskeyBase {
|
|
@@ -10,10 +11,18 @@ export declare class PasskeyKit extends PasskeyBase {
|
|
|
10
11
|
networkPassphrase: string;
|
|
11
12
|
factory: FactoryClient;
|
|
12
13
|
wallet: PasskeyClient | undefined;
|
|
14
|
+
WebAuthn: {
|
|
15
|
+
startRegistration: typeof startRegistration;
|
|
16
|
+
startAuthentication: typeof startAuthentication;
|
|
17
|
+
};
|
|
13
18
|
constructor(options: {
|
|
14
19
|
rpcUrl: string;
|
|
15
20
|
networkPassphrase: string;
|
|
16
21
|
factoryContractId: string;
|
|
22
|
+
WebAuthn?: {
|
|
23
|
+
startRegistration: typeof startRegistration;
|
|
24
|
+
startAuthentication: typeof startAuthentication;
|
|
25
|
+
};
|
|
17
26
|
});
|
|
18
27
|
createWallet(app: string, user: string): Promise<{
|
|
19
28
|
keyId: Buffer;
|