passkey-kit 0.5.4 → 0.5.5
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 +3 -3
- package/src/kit.ts +14 -12
- 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.5.
|
|
3
|
+
"version": "0.5.5",
|
|
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,9 +13,9 @@
|
|
|
13
13
|
"@stellar/stellar-sdk": "12.1.0",
|
|
14
14
|
"base64url": "^3.0.1",
|
|
15
15
|
"buffer": "^6.0.3",
|
|
16
|
+
"sac-sdk": "0.1.0",
|
|
16
17
|
"passkey-factory-sdk": "0.2.1",
|
|
17
|
-
"passkey-kit-sdk": "0.2.1"
|
|
18
|
-
"sac-sdk": "0.1.0"
|
|
18
|
+
"passkey-kit-sdk": "0.2.1"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@simplewebauthn/types": "^10.0.0",
|
package/src/kit.ts
CHANGED
|
@@ -29,7 +29,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
29
29
|
startAuthentication: typeof startAuthentication
|
|
30
30
|
}
|
|
31
31
|
}) {
|
|
32
|
-
const { rpcUrl, networkPassphrase, factoryContractId } = options
|
|
32
|
+
const { rpcUrl, networkPassphrase, factoryContractId, WebAuthn } = options
|
|
33
33
|
|
|
34
34
|
super(rpcUrl)
|
|
35
35
|
|
|
@@ -39,7 +39,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
39
39
|
networkPassphrase,
|
|
40
40
|
rpcUrl
|
|
41
41
|
})
|
|
42
|
-
this.WebAuthn =
|
|
42
|
+
this.WebAuthn = WebAuthn || { startRegistration, startAuthentication }
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
public async createWallet(app: string, user: string) {
|
|
@@ -66,13 +66,13 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
public async createKey(app: string, user: string) {
|
|
69
|
+
public async createKey(app: string, user: string, rpId?: string) {
|
|
70
70
|
const now = new Date()
|
|
71
71
|
const displayName = `${user} — ${now.toLocaleString()}`
|
|
72
72
|
const { id, response } = await this.WebAuthn.startRegistration({
|
|
73
73
|
challenge: base64url("stellaristhebetterblockchain"),
|
|
74
74
|
rp: {
|
|
75
|
-
|
|
75
|
+
id: rpId,
|
|
76
76
|
name: app,
|
|
77
77
|
},
|
|
78
78
|
user: {
|
|
@@ -81,9 +81,9 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
81
81
|
displayName
|
|
82
82
|
},
|
|
83
83
|
// authenticatorSelection: {
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
84
|
+
// requireResidentKey: false,
|
|
85
|
+
// residentKey: "preferred",
|
|
86
|
+
// userVerification: "discouraged",
|
|
87
87
|
// },
|
|
88
88
|
pubKeyCredParams: [{ alg: -7, type: "public-key" }],
|
|
89
89
|
// attestation: "none",
|
|
@@ -101,15 +101,16 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
101
101
|
|
|
102
102
|
public async connectWallet(opts?: {
|
|
103
103
|
keyId?: string | Uint8Array,
|
|
104
|
+
rpId?: string,
|
|
104
105
|
getContractId?: (keyId: string) => Promise<string | undefined>
|
|
105
106
|
}) {
|
|
106
|
-
let { keyId, getContractId } = opts || {}
|
|
107
|
+
let { keyId, rpId, getContractId } = opts || {}
|
|
107
108
|
let keyIdBuffer: Buffer
|
|
108
109
|
|
|
109
110
|
if (!keyId) {
|
|
110
111
|
const response = await this.WebAuthn.startAuthentication({
|
|
111
112
|
challenge: base64url("stellaristhebetterblockchain"),
|
|
112
|
-
|
|
113
|
+
rpId,
|
|
113
114
|
// userVerification: "discouraged",
|
|
114
115
|
// timeout: 120_000
|
|
115
116
|
});
|
|
@@ -169,10 +170,11 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
169
170
|
entry: xdr.SorobanAuthorizationEntry,
|
|
170
171
|
options?: {
|
|
171
172
|
keyId?: 'any' | string | Uint8Array
|
|
173
|
+
rpId?: string,
|
|
172
174
|
ledgersToLive?: number
|
|
173
175
|
}
|
|
174
176
|
) {
|
|
175
|
-
let { keyId, ledgersToLive = DEFAULT_TIMEOUT } = options || {}
|
|
177
|
+
let { keyId, rpId, ledgersToLive = DEFAULT_TIMEOUT } = options || {}
|
|
176
178
|
|
|
177
179
|
const lastLedger = await this.rpc.getLatestLedger().then(({ sequence }) => sequence)
|
|
178
180
|
const credentials = entry.credentials().address();
|
|
@@ -191,13 +193,13 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
191
193
|
|| (!keyId && !this.keyId)
|
|
192
194
|
? {
|
|
193
195
|
challenge: base64url(payload),
|
|
194
|
-
|
|
196
|
+
rpId,
|
|
195
197
|
// userVerification: "discouraged",
|
|
196
198
|
// timeout: 120_000
|
|
197
199
|
}
|
|
198
200
|
: {
|
|
199
201
|
challenge: base64url(payload),
|
|
200
|
-
|
|
202
|
+
rpId,
|
|
201
203
|
allowCredentials: [
|
|
202
204
|
{
|
|
203
205
|
id: keyId instanceof Uint8Array
|
package/types/kit.d.ts
CHANGED
|
@@ -29,12 +29,13 @@ export declare class PasskeyKit extends PasskeyBase {
|
|
|
29
29
|
contractId: string;
|
|
30
30
|
xdr: string | undefined;
|
|
31
31
|
}>;
|
|
32
|
-
createKey(app: string, user: string): Promise<{
|
|
32
|
+
createKey(app: string, user: string, rpId?: string): Promise<{
|
|
33
33
|
keyId: Buffer;
|
|
34
34
|
publicKey: Buffer;
|
|
35
35
|
}>;
|
|
36
36
|
connectWallet(opts?: {
|
|
37
37
|
keyId?: string | Uint8Array;
|
|
38
|
+
rpId?: string;
|
|
38
39
|
getContractId?: (keyId: string) => Promise<string | undefined>;
|
|
39
40
|
}): Promise<{
|
|
40
41
|
keyId: Buffer;
|
|
@@ -42,6 +43,7 @@ export declare class PasskeyKit extends PasskeyBase {
|
|
|
42
43
|
}>;
|
|
43
44
|
signAuthEntry(entry: xdr.SorobanAuthorizationEntry, options?: {
|
|
44
45
|
keyId?: 'any' | string | Uint8Array;
|
|
46
|
+
rpId?: string;
|
|
45
47
|
ledgersToLive?: number;
|
|
46
48
|
}): Promise<xdr.SorobanAuthorizationEntry>;
|
|
47
49
|
signAuthEntries(entries: xdr.SorobanAuthorizationEntry[], options?: {
|