passkey-kit 0.4.3 → 0.4.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/package.json +1 -1
- package/src/base.ts +8 -8
- package/src/kit.ts +9 -3
- package/types/base.d.ts +3 -5
package/package.json
CHANGED
package/src/base.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { SorobanRpc, xdr } from "@stellar/stellar-sdk"
|
|
|
2
2
|
import base64url from "base64url"
|
|
3
3
|
|
|
4
4
|
export class PasskeyBase {
|
|
5
|
-
public rpc: SorobanRpc.Server
|
|
6
|
-
public rpcUrl: string
|
|
5
|
+
public rpc: SorobanRpc.Server | undefined
|
|
6
|
+
public rpcUrl: string | undefined
|
|
7
7
|
public launchtubeUrl: string | undefined
|
|
8
8
|
public launchtubeJwt: string | undefined
|
|
9
9
|
public mercuryUrl: string | undefined
|
|
@@ -12,9 +12,7 @@ export class PasskeyBase {
|
|
|
12
12
|
public mercuryPassword: string | undefined
|
|
13
13
|
|
|
14
14
|
constructor(options: {
|
|
15
|
-
rpcUrl
|
|
16
|
-
networkPassphrase: string,
|
|
17
|
-
factoryContractId: string,
|
|
15
|
+
rpcUrl?: string,
|
|
18
16
|
launchtubeUrl?: string,
|
|
19
17
|
launchtubeJwt?: string,
|
|
20
18
|
mercuryUrl?: string,
|
|
@@ -53,8 +51,10 @@ export class PasskeyBase {
|
|
|
53
51
|
if (!mercuryJwt && mercuryUrl && mercuryEmail && mercuryPassword)
|
|
54
52
|
this.setMercuryJwt()
|
|
55
53
|
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
if (rpcUrl) {
|
|
55
|
+
this.rpcUrl = rpcUrl
|
|
56
|
+
this.rpc = new SorobanRpc.Server(rpcUrl)
|
|
57
|
+
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
public async setMercuryJwt() {
|
|
@@ -89,7 +89,7 @@ export class PasskeyBase {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
public async getSigners(contractId: string) {
|
|
92
|
-
if (!this.mercuryUrl || !this.mercuryJwt)
|
|
92
|
+
if (!this.rpc || !this.mercuryUrl || !this.mercuryJwt)
|
|
93
93
|
throw new Error('Mercury service not configured')
|
|
94
94
|
|
|
95
95
|
const signers = await fetch(`${this.mercuryUrl}/zephyr/execute`, {
|
package/src/kit.ts
CHANGED
|
@@ -29,6 +29,12 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
29
29
|
|
|
30
30
|
super(options)
|
|
31
31
|
|
|
32
|
+
if (!this.rpcUrl)
|
|
33
|
+
this.rpcUrl = rpcUrl
|
|
34
|
+
|
|
35
|
+
if (!this.rpc)
|
|
36
|
+
this.rpc = new SorobanRpc.Server(rpcUrl)
|
|
37
|
+
|
|
32
38
|
this.networkPassphrase = networkPassphrase
|
|
33
39
|
this.factory = new FactoryClient({
|
|
34
40
|
contractId: factoryContractId,
|
|
@@ -140,7 +146,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
140
146
|
// attempt passkey id derivation
|
|
141
147
|
try {
|
|
142
148
|
// TODO what is the error if the entry exists but is archived?
|
|
143
|
-
await this.rpc
|
|
149
|
+
await this.rpc!.getContractData(contractId, xdr.ScVal.scvLedgerKeyContractInstance())
|
|
144
150
|
}
|
|
145
151
|
// if that fails look up from the `getContractId` function
|
|
146
152
|
catch {
|
|
@@ -172,7 +178,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
172
178
|
// Default mirrors DEFAULT_TIMEOUT (currently 5 minutes) https://github.com/stellar/js-stellar-sdk/blob/master/src/contract/utils.ts#L7
|
|
173
179
|
let { keyId, ledgersToLive = 60 } = options || {}
|
|
174
180
|
|
|
175
|
-
const lastLedger = await this.rpc
|
|
181
|
+
const lastLedger = await this.rpc!.getLatestLedger().then(({ sequence }) => sequence)
|
|
176
182
|
const credentials = entry.credentials().address();
|
|
177
183
|
const preimage = xdr.HashIdPreimage.envelopeTypeSorobanAuthorization(
|
|
178
184
|
new xdr.HashIdPreimageSorobanAuthorization({
|
|
@@ -295,7 +301,7 @@ export class PasskeyKit extends PasskeyBase {
|
|
|
295
301
|
await this.signAuthEntries(entries, options)
|
|
296
302
|
}
|
|
297
303
|
|
|
298
|
-
const sim = await this.rpc
|
|
304
|
+
const sim = await this.rpc!.simulateTransaction(txn)
|
|
299
305
|
|
|
300
306
|
if (
|
|
301
307
|
SorobanRpc.Api.isSimulationError(sim)
|
package/types/base.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SorobanRpc } from "@stellar/stellar-sdk";
|
|
2
2
|
export declare class PasskeyBase {
|
|
3
|
-
rpc: SorobanRpc.Server;
|
|
4
|
-
rpcUrl: string;
|
|
3
|
+
rpc: SorobanRpc.Server | undefined;
|
|
4
|
+
rpcUrl: string | undefined;
|
|
5
5
|
launchtubeUrl: string | undefined;
|
|
6
6
|
launchtubeJwt: string | undefined;
|
|
7
7
|
mercuryUrl: string | undefined;
|
|
@@ -9,9 +9,7 @@ export declare class PasskeyBase {
|
|
|
9
9
|
mercuryEmail: string | undefined;
|
|
10
10
|
mercuryPassword: string | undefined;
|
|
11
11
|
constructor(options: {
|
|
12
|
-
rpcUrl
|
|
13
|
-
networkPassphrase: string;
|
|
14
|
-
factoryContractId: string;
|
|
12
|
+
rpcUrl?: string;
|
|
15
13
|
launchtubeUrl?: string;
|
|
16
14
|
launchtubeJwt?: string;
|
|
17
15
|
mercuryUrl?: string;
|