passkey-kit 0.7.15 → 0.7.16

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/cheatsheet CHANGED
@@ -15,8 +15,4 @@ export JWT=???
15
15
  mercury-cli --jwt $JWT --local false --mainnet false deploy
16
16
  mercury-cli --jwt $JWT --local false --mainnet false catchup --project-name "smart-wallets-data-multi-signer-multi-sig" --contracts CC3TMW7O43G3WJBZ2RVWMBBKL3B5KIO275D2LHQ43KJQF4TUOHFEYVOR
17
17
  curl -X GET https://api.mercurydata.app/catchups/4
18
- 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\": \"CA4G3X75IGGNXNLXFIVFNYIGC6YAVLA7KSIFFDBSR7RQ7KEZMZWLXQBH\"}"}}}'
19
- 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]}"}}}'
20
- curl -X POST https://api.mercurydata.app/zephyr/execute -H "Authorization: Bearer $MERCURY_JWT" -H 'Content-Type: application/json' -d '{"mode":{"Function": {"fname": "get_events_by_address", "arguments": "{\"address\": \"CA4G3X75IGGNXNLXFIVFNYIGC6YAVLA7KSIFFDBSR7RQ7KEZMZWLXQBH\"}"}}}'
21
-
22
- cp -R ext/js-stellar-sdk/lib/. ext/@stellar/stellar-sdk/
18
+ curl -X POST https://api.mercurydata.app/v2/key -H "Authorization: Bearer $JWT"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "passkey-kit",
3
- "version": "0.7.15",
3
+ "version": "0.7.16",
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/index.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { PasskeyServer } from "./server"
2
- import { PasskeyKit, PasskeyClient, FactoryClient, SignerStore, SignerKey, type SignerLimits } from "./kit"
3
- import { SACClient } from "./sac"
4
-
5
- export { PasskeyKit, PasskeyClient, FactoryClient, PasskeyServer, SACClient, SignerStore, SignerKey, type SignerLimits }
1
+ export { SignerStore, SignerKey, type SignerLimits } from './types'
2
+ export { PasskeyKit } from "./kit"
3
+ export { PasskeyServer } from "./server"
4
+ export { SACClient } from "./sac"
5
+ export { Client as PasskeyClient } from 'passkey-kit-sdk'
6
+ export { Client as FactoryClient } from 'passkey-factory-sdk'
package/src/kit.ts CHANGED
@@ -1,38 +1,13 @@
1
- import { Client as PasskeyClient, type Signature, type SignerKey as SDKSignerKey, type SignerLimits as SDKSignerLimits } from 'passkey-kit-sdk'
2
1
  import { Client as FactoryClient } from 'passkey-factory-sdk'
2
+ import { Client as PasskeyClient, type Signature, type SignerKey as SDKSignerKey, type SignerLimits as SDKSignerLimits } from 'passkey-kit-sdk'
3
3
  import { StrKey, hash, xdr, SorobanRpc, Keypair, Address } from '@stellar/stellar-sdk'
4
- import base64url from 'base64url'
5
- import { startRegistration, startAuthentication } from "@simplewebauthn/browser"
4
+ import { AssembledTransaction, DEFAULT_TIMEOUT, type Tx } from '@stellar/stellar-sdk/contract'
6
5
  import type { AuthenticatorAttestationResponseJSON, AuthenticatorSelectionCriteria } from "@simplewebauthn/types"
6
+ import { startRegistration, startAuthentication } from "@simplewebauthn/browser"
7
7
  import { Buffer } from 'buffer'
8
+ import base64url from 'base64url'
9
+ import type { SignerKey, SignerLimits, SignerStore } from './types'
8
10
  import { PasskeyBase } from './base'
9
- import { AssembledTransaction, DEFAULT_TIMEOUT, type Tx } from '@stellar/stellar-sdk/contract'
10
-
11
- export { Client as PasskeyClient } from 'passkey-kit-sdk'
12
- export { Client as FactoryClient } from 'passkey-factory-sdk'
13
-
14
- export class SignerKey {
15
- private constructor(public key: "Policy" | "Ed25519" | "Secp256r1", public value: string) { }
16
-
17
- static Policy(policy: string): SignerKey {
18
- return new SignerKey("Policy", policy);
19
- }
20
-
21
- static Ed25519(publicKey: string): SignerKey {
22
- return new SignerKey("Ed25519", publicKey);
23
- }
24
-
25
- static Secp256r1(id: string): SignerKey {
26
- return new SignerKey("Secp256r1", id);
27
- }
28
- }
29
-
30
- export type SignerLimits = Map<string, SignerKey[] | undefined>
31
-
32
- export enum SignerStore {
33
- Persistent = 'Persistent',
34
- Temporary = 'Temporary',
35
- }
36
11
 
37
12
  export class PasskeyKit extends PasskeyBase {
38
13
  declare public rpc: SorobanRpc.Server
@@ -139,8 +114,8 @@ export class PasskeyKit extends PasskeyBase {
139
114
  }
140
115
 
141
116
  public async connectWallet(opts?: {
142
- keyId?: string | Uint8Array,
143
117
  rpId?: string,
118
+ keyId?: string | Uint8Array,
144
119
  getContractId?: (keyId: string) => Promise<string | undefined>
145
120
  }) {
146
121
  let { keyId, rpId, getContractId } = opts || {}
package/src/server.ts CHANGED
@@ -8,6 +8,7 @@ export class PasskeyServer extends PasskeyBase {
8
8
  public launchtubeJwt: string | undefined
9
9
  public mercuryUrl: string | undefined
10
10
  public mercuryJwt: string | undefined
11
+ public mercuryKey: string | undefined
11
12
 
12
13
  constructor(options: {
13
14
  rpcUrl?: string,
@@ -15,6 +16,7 @@ export class PasskeyServer extends PasskeyBase {
15
16
  launchtubeJwt?: string,
16
17
  mercuryUrl?: string,
17
18
  mercuryJwt?: string,
19
+ mercuryKey?: string,
18
20
  }) {
19
21
  const {
20
22
  rpcUrl,
@@ -22,6 +24,7 @@ export class PasskeyServer extends PasskeyBase {
22
24
  launchtubeJwt,
23
25
  mercuryUrl,
24
26
  mercuryJwt,
27
+ mercuryKey,
25
28
  } = options
26
29
 
27
30
  super(rpcUrl)
@@ -37,17 +40,20 @@ export class PasskeyServer extends PasskeyBase {
37
40
 
38
41
  if (mercuryJwt)
39
42
  this.mercuryJwt = mercuryJwt
43
+
44
+ if (mercuryKey)
45
+ this.mercuryKey = mercuryKey
40
46
  }
41
47
 
42
48
  public async getSigners(contractId: string) {
43
- if (!this.rpc || !this.mercuryUrl || !this.mercuryJwt)
49
+ if (!this.rpc || !this.mercuryUrl || (!this.mercuryJwt && !this.mercuryKey))
44
50
  throw new Error('Mercury service not configured')
45
51
 
46
52
  const signers = await fetch(`${this.mercuryUrl}/zephyr/execute`, {
47
53
  method: 'POST',
48
54
  headers: {
49
55
  'Content-Type': 'application/json',
50
- Authorization: `Bearer ${this.mercuryJwt}`
56
+ Authorization: this.mercuryJwt ? `Bearer ${this.mercuryJwt}` : this.mercuryKey!
51
57
  },
52
58
  body: JSON.stringify({
53
59
  project_name: 'smart-wallets-data-multi-signer-multi-sig',
@@ -92,7 +98,7 @@ export class PasskeyServer extends PasskeyBase {
92
98
  publicKey?: string,
93
99
  policy?: string,
94
100
  }, index = 0) {
95
- if (!this.mercuryUrl || !this.mercuryJwt)
101
+ if (!this.mercuryUrl || (!this.mercuryJwt && !this.mercuryKey))
96
102
  throw new Error('Mercury service not configured')
97
103
 
98
104
  let { keyId, publicKey, policy } = options || {}
@@ -108,21 +114,19 @@ export class PasskeyServer extends PasskeyBase {
108
114
  args = { key: publicKey, kind: 'Ed25519' }
109
115
  else if (policy)
110
116
  args = { key: policy, kind: 'Policy' }
111
- else
112
- throw new Error('Exactly one of `options.keyId`, `options.publicKey`, or `options.policy` must be provided.');
113
117
 
114
118
  const res = await fetch(`${this.mercuryUrl}/zephyr/execute`, {
115
119
  method: 'POST',
116
120
  headers: {
117
121
  'Content-Type': 'application/json',
118
- Authorization: `Bearer ${this.mercuryJwt}`
122
+ Authorization: this.mercuryJwt ? `Bearer ${this.mercuryJwt}` : this.mercuryKey!
119
123
  },
120
124
  body: JSON.stringify({
121
125
  project_name: 'smart-wallets-data-multi-signer-multi-sig',
122
126
  mode: {
123
127
  Function: {
124
128
  fname: "get_addresses_by_signer",
125
- arguments: JSON.stringify(args)
129
+ arguments: JSON.stringify(args!)
126
130
  }
127
131
  }
128
132
  })
package/src/types.ts ADDED
@@ -0,0 +1,22 @@
1
+ export class SignerKey {
2
+ private constructor(public key: "Policy" | "Ed25519" | "Secp256r1", public value: string) { }
3
+
4
+ static Policy(policy: string): SignerKey {
5
+ return new SignerKey("Policy", policy);
6
+ }
7
+
8
+ static Ed25519(publicKey: string): SignerKey {
9
+ return new SignerKey("Ed25519", publicKey);
10
+ }
11
+
12
+ static Secp256r1(id: string): SignerKey {
13
+ return new SignerKey("Secp256r1", id);
14
+ }
15
+ }
16
+
17
+ export type SignerLimits = Map<string, SignerKey[] | undefined>
18
+
19
+ export enum SignerStore {
20
+ Persistent = 'Persistent',
21
+ Temporary = 'Temporary',
22
+ }
package/types/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import { PasskeyServer } from "./server";
2
- import { PasskeyKit, PasskeyClient, FactoryClient, SignerStore, SignerKey, type SignerLimits } from "./kit";
3
- import { SACClient } from "./sac";
4
- export { PasskeyKit, PasskeyClient, FactoryClient, PasskeyServer, SACClient, SignerStore, SignerKey, type SignerLimits };
1
+ export { SignerStore, SignerKey, type SignerLimits } from './types';
2
+ export { PasskeyKit } from "./kit";
3
+ export { PasskeyServer } from "./server";
4
+ export { SACClient } from "./sac";
5
+ export { Client as PasskeyClient } from 'passkey-kit-sdk';
6
+ export { Client as FactoryClient } from 'passkey-factory-sdk';
package/types/kit.d.ts CHANGED
@@ -1,26 +1,12 @@
1
- import { Client as PasskeyClient } from 'passkey-kit-sdk';
2
1
  import { Client as FactoryClient } from 'passkey-factory-sdk';
2
+ import { Client as PasskeyClient } from 'passkey-kit-sdk';
3
3
  import { xdr, SorobanRpc, Keypair } from '@stellar/stellar-sdk';
4
- import { startRegistration, startAuthentication } from "@simplewebauthn/browser";
4
+ import { AssembledTransaction, type Tx } from '@stellar/stellar-sdk/contract';
5
5
  import type { AuthenticatorSelectionCriteria } from "@simplewebauthn/types";
6
+ import { startRegistration, startAuthentication } from "@simplewebauthn/browser";
6
7
  import { Buffer } from 'buffer';
8
+ import type { SignerKey, SignerLimits, SignerStore } from './types';
7
9
  import { PasskeyBase } from './base';
8
- import { AssembledTransaction, type Tx } from '@stellar/stellar-sdk/contract';
9
- export { Client as PasskeyClient } from 'passkey-kit-sdk';
10
- export { Client as FactoryClient } from 'passkey-factory-sdk';
11
- export declare class SignerKey {
12
- key: "Policy" | "Ed25519" | "Secp256r1";
13
- value: string;
14
- private constructor();
15
- static Policy(policy: string): SignerKey;
16
- static Ed25519(publicKey: string): SignerKey;
17
- static Secp256r1(id: string): SignerKey;
18
- }
19
- export type SignerLimits = Map<string, SignerKey[] | undefined>;
20
- export declare enum SignerStore {
21
- Persistent = "Persistent",
22
- Temporary = "Temporary"
23
- }
24
10
  export declare class PasskeyKit extends PasskeyBase {
25
11
  rpc: SorobanRpc.Server;
26
12
  rpcUrl: string;
@@ -54,8 +40,8 @@ export declare class PasskeyKit extends PasskeyBase {
54
40
  publicKey: Buffer;
55
41
  }>;
56
42
  connectWallet(opts?: {
57
- keyId?: string | Uint8Array;
58
43
  rpId?: string;
44
+ keyId?: string | Uint8Array;
59
45
  getContractId?: (keyId: string) => Promise<string | undefined>;
60
46
  }): Promise<{
61
47
  keyId: Buffer;
package/types/server.d.ts CHANGED
@@ -5,12 +5,14 @@ export declare class PasskeyServer extends PasskeyBase {
5
5
  launchtubeJwt: string | undefined;
6
6
  mercuryUrl: string | undefined;
7
7
  mercuryJwt: string | undefined;
8
+ mercuryKey: string | undefined;
8
9
  constructor(options: {
9
10
  rpcUrl?: string;
10
11
  launchtubeUrl?: string;
11
12
  launchtubeJwt?: string;
12
13
  mercuryUrl?: string;
13
14
  mercuryJwt?: string;
15
+ mercuryKey?: string;
14
16
  });
15
17
  getSigners(contractId: string): Promise<{
16
18
  kind: string;
@@ -0,0 +1,13 @@
1
+ export declare class SignerKey {
2
+ key: "Policy" | "Ed25519" | "Secp256r1";
3
+ value: string;
4
+ private constructor();
5
+ static Policy(policy: string): SignerKey;
6
+ static Ed25519(publicKey: string): SignerKey;
7
+ static Secp256r1(id: string): SignerKey;
8
+ }
9
+ export type SignerLimits = Map<string, SignerKey[] | undefined>;
10
+ export declare enum SignerStore {
11
+ Persistent = "Persistent",
12
+ Temporary = "Temporary"
13
+ }