passkey-kit 0.4.2 → 0.4.3

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,6 +1,6 @@
1
1
  {
2
2
  "name": "passkey-kit",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
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",
package/src/base.ts CHANGED
@@ -1,12 +1,9 @@
1
- import { Networks, SorobanRpc, xdr } from "@stellar/stellar-sdk"
2
- import { Client as FactoryClient } from 'passkey-factory-sdk'
1
+ import { SorobanRpc, xdr } from "@stellar/stellar-sdk"
3
2
  import base64url from "base64url"
4
3
 
5
4
  export class PasskeyBase {
6
5
  public rpc: SorobanRpc.Server
7
- public factory: FactoryClient
8
6
  public rpcUrl: string
9
- public networkPassphrase: Networks
10
7
  public launchtubeUrl: string | undefined
11
8
  public launchtubeJwt: string | undefined
12
9
  public mercuryUrl: string | undefined
@@ -27,8 +24,6 @@ export class PasskeyBase {
27
24
  }) {
28
25
  const {
29
26
  rpcUrl,
30
- networkPassphrase,
31
- factoryContractId,
32
27
  launchtubeUrl,
33
28
  launchtubeJwt,
34
29
  mercuryUrl,
@@ -55,17 +50,14 @@ export class PasskeyBase {
55
50
  if (mercuryPassword)
56
51
  this.mercuryPassword = mercuryPassword
57
52
 
53
+ if (!mercuryJwt && mercuryUrl && mercuryEmail && mercuryPassword)
54
+ this.setMercuryJwt()
55
+
58
56
  this.rpcUrl = rpcUrl
59
57
  this.rpc = new SorobanRpc.Server(rpcUrl)
60
- this.networkPassphrase = networkPassphrase as Networks
61
- this.factory = new FactoryClient({
62
- contractId: factoryContractId,
63
- networkPassphrase,
64
- rpcUrl
65
- })
66
58
  }
67
59
 
68
- public async getMercuryJwt() {
60
+ public async setMercuryJwt() {
69
61
  if (!this.mercuryEmail || !this.mercuryPassword)
70
62
  throw new Error('Mercury service not configured')
71
63
 
@@ -92,10 +84,11 @@ export class PasskeyBase {
92
84
  throw await res.json()
93
85
  })
94
86
 
87
+ this.mercuryJwt = jwtToken
95
88
  return jwtToken
96
89
  }
97
90
 
98
- public async getSigners(contractId: string = this.factory.options.contractId) {
91
+ public async getSigners(contractId: string) {
99
92
  if (!this.mercuryUrl || !this.mercuryJwt)
100
93
  throw new Error('Mercury service not configured')
101
94
 
package/src/kit.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Client as PasskeyClient } from 'passkey-kit-sdk'
2
-
2
+ import { Client as FactoryClient } from 'passkey-factory-sdk'
3
3
  import { Address, StrKey, hash, xdr, Transaction, SorobanRpc, Operation, TransactionBuilder } from '@stellar/stellar-sdk'
4
4
  import base64url from 'base64url'
5
5
  import { startRegistration, startAuthentication } from "@simplewebauthn/browser"
@@ -10,6 +10,8 @@ import { PasskeyBase } from './base'
10
10
 
11
11
  export class PasskeyKit extends PasskeyBase {
12
12
  public keyId: string | undefined
13
+ public networkPassphrase: string
14
+ public factory: FactoryClient
13
15
  public wallet: PasskeyClient | undefined
14
16
 
15
17
  constructor(options: {
@@ -23,7 +25,16 @@ export class PasskeyKit extends PasskeyBase {
23
25
  mercuryEmail?: string,
24
26
  mercuryPassword?: string
25
27
  }) {
28
+ const { rpcUrl, networkPassphrase, factoryContractId } = options
29
+
26
30
  super(options)
31
+
32
+ this.networkPassphrase = networkPassphrase
33
+ this.factory = new FactoryClient({
34
+ contractId: factoryContractId,
35
+ networkPassphrase,
36
+ rpcUrl
37
+ })
27
38
  }
28
39
 
29
40
  public async createWallet(app: string, user: string) {
package/types/base.d.ts CHANGED
@@ -1,10 +1,7 @@
1
- import { Networks, SorobanRpc } from "@stellar/stellar-sdk";
2
- import { Client as FactoryClient } from 'passkey-factory-sdk';
1
+ import { SorobanRpc } from "@stellar/stellar-sdk";
3
2
  export declare class PasskeyBase {
4
3
  rpc: SorobanRpc.Server;
5
- factory: FactoryClient;
6
4
  rpcUrl: string;
7
- networkPassphrase: Networks;
8
5
  launchtubeUrl: string | undefined;
9
6
  launchtubeJwt: string | undefined;
10
7
  mercuryUrl: string | undefined;
@@ -22,8 +19,8 @@ export declare class PasskeyBase {
22
19
  mercuryEmail?: string;
23
20
  mercuryPassword?: string;
24
21
  });
25
- getMercuryJwt(): Promise<any>;
26
- getSigners(contractId?: string): Promise<{
22
+ setMercuryJwt(): Promise<any>;
23
+ getSigners(contractId: string): Promise<{
27
24
  id: string;
28
25
  pk: string;
29
26
  admin: boolean;
package/types/kit.d.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  import { Client as PasskeyClient } from 'passkey-kit-sdk';
2
+ import { Client as FactoryClient } from 'passkey-factory-sdk';
2
3
  import { xdr, Transaction } from '@stellar/stellar-sdk';
3
4
  import { Buffer } from 'buffer';
4
5
  import { PasskeyBase } from './base';
5
6
  export declare class PasskeyKit extends PasskeyBase {
6
7
  keyId: string | undefined;
8
+ networkPassphrase: string;
9
+ factory: FactoryClient;
7
10
  wallet: PasskeyClient | undefined;
8
11
  constructor(options: {
9
12
  rpcUrl: string;