passkey-kit 0.0.26 → 0.0.27
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 +1 -1
- package/src/index.ts +16 -24
- package/types/index.d.ts +1 -2
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -121,7 +121,18 @@ export class PasskeyAccount {
|
|
|
121
121
|
this.sudoKeyId = startRegistrationResponse.id
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
const { publicKeyObject } = this.getPublicKeyObject(startRegistrationResponse.response.attestationObject);
|
|
125
|
+
|
|
126
|
+
const publicKey = Buffer.from([
|
|
127
|
+
4, // (0x04 prefix) https://en.bitcoin.it/wiki/Elliptic_Curve_Digital_Signature_Algorithm
|
|
128
|
+
...publicKeyObject.get('-2')!,
|
|
129
|
+
...publicKeyObject.get('-3')!
|
|
130
|
+
])
|
|
131
|
+
|
|
132
|
+
return {
|
|
133
|
+
keyId: base64url.toBuffer(startRegistrationResponse.id),
|
|
134
|
+
publicKey
|
|
135
|
+
}
|
|
125
136
|
}
|
|
126
137
|
|
|
127
138
|
public async connectWallet() {
|
|
@@ -134,7 +145,7 @@ export class PasskeyAccount {
|
|
|
134
145
|
if (!this.keyId)
|
|
135
146
|
this.keyId = startAuthenticationResponse.id
|
|
136
147
|
|
|
137
|
-
const
|
|
148
|
+
const keyIdBuffer = base64url.toBuffer(startAuthenticationResponse.id)
|
|
138
149
|
|
|
139
150
|
// NOTE might not need this for derivation as all signers are stored in the factory and we can use that lookup as both primary and secondary
|
|
140
151
|
let contractId = StrKey.encodeContract(hash(xdr.HashIdPreimage.envelopeTypeContractId(
|
|
@@ -143,7 +154,7 @@ export class PasskeyAccount {
|
|
|
143
154
|
contractIdPreimage: xdr.ContractIdPreimage.contractIdPreimageFromAddress(
|
|
144
155
|
new xdr.ContractIdPreimageFromAddress({
|
|
145
156
|
address: Address.fromString(this.factoryContractId).toScAddress(),
|
|
146
|
-
salt: hash(
|
|
157
|
+
salt: hash(keyIdBuffer),
|
|
147
158
|
})
|
|
148
159
|
)
|
|
149
160
|
})
|
|
@@ -155,7 +166,7 @@ export class PasskeyAccount {
|
|
|
155
166
|
}
|
|
156
167
|
// if that fails look up from the factory mapper
|
|
157
168
|
catch {
|
|
158
|
-
const { val } = await this.rpc.getContractData(this.factoryContractId, xdr.ScVal.scvBytes(
|
|
169
|
+
const { val } = await this.rpc.getContractData(this.factoryContractId, xdr.ScVal.scvBytes(keyIdBuffer))
|
|
159
170
|
contractId = scValToNative(val.contractData().val())
|
|
160
171
|
}
|
|
161
172
|
|
|
@@ -170,7 +181,7 @@ export class PasskeyAccount {
|
|
|
170
181
|
await this.getData()
|
|
171
182
|
|
|
172
183
|
return {
|
|
173
|
-
keyId,
|
|
184
|
+
keyId: keyIdBuffer,
|
|
174
185
|
contractId
|
|
175
186
|
}
|
|
176
187
|
}
|
|
@@ -324,25 +335,6 @@ export class PasskeyAccount {
|
|
|
324
335
|
@Later
|
|
325
336
|
*/
|
|
326
337
|
|
|
327
|
-
private async getKey(value: RegistrationResponseJSON | AuthenticationResponseJSON) {
|
|
328
|
-
let publicKey: Buffer | undefined
|
|
329
|
-
|
|
330
|
-
if (isAuthentication(value)) {
|
|
331
|
-
const { publicKeyObject } = this.getPublicKeyObject(value.response.attestationObject);
|
|
332
|
-
|
|
333
|
-
publicKey = Buffer.from([
|
|
334
|
-
4, // (0x04 prefix) https://en.bitcoin.it/wiki/Elliptic_Curve_Digital_Signature_Algorithm
|
|
335
|
-
...publicKeyObject.get('-2')!,
|
|
336
|
-
...publicKeyObject.get('-3')!
|
|
337
|
-
])
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return {
|
|
341
|
-
keyId: base64url.toBuffer(value.id),
|
|
342
|
-
publicKey
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
338
|
private getPublicKeyObject(attestationObject: string) {
|
|
347
339
|
const { authData } = decode(base64url.toBuffer(attestationObject));
|
|
348
340
|
const authDataUint8Array = new Uint8Array(authData);
|
package/types/index.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare class PasskeyAccount {
|
|
|
32
32
|
}>;
|
|
33
33
|
createKey(name: string, user: string): Promise<{
|
|
34
34
|
keyId: Buffer;
|
|
35
|
-
publicKey: Buffer
|
|
35
|
+
publicKey: Buffer;
|
|
36
36
|
}>;
|
|
37
37
|
connectWallet(): Promise<{
|
|
38
38
|
keyId: Buffer;
|
|
@@ -44,7 +44,6 @@ export declare class PasskeyAccount {
|
|
|
44
44
|
}): Promise<string>;
|
|
45
45
|
send(txn: Transaction, fee?: number): Promise<Horizon.HorizonApi.SubmitTransactionResponse>;
|
|
46
46
|
getData(): Promise<Map<string, any>>;
|
|
47
|
-
private getKey;
|
|
48
47
|
private getPublicKeyObject;
|
|
49
48
|
private convertEcdsaSignatureAsnToCompact;
|
|
50
49
|
}
|