passkey-kit 0.7.15 → 0.7.17
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 +1 -5
- package/clone-js-sdk.sh +0 -0
- package/package.json +23 -16
- package/packages/passkey-factory-sdk/package.json +1 -1
- package/packages/passkey-kit-sdk/package.json +1 -1
- package/packages/sac-sdk/package.json +1 -1
- package/src/index.ts +6 -5
- package/src/kit.ts +6 -31
- package/src/server.ts +11 -7
- package/src/types.ts +22 -0
- package/types/index.d.ts +6 -4
- package/types/kit.d.ts +5 -19
- package/types/server.d.ts +2 -0
- package/types/types.d.ts +13 -0
- package/wrangler.toml +20 -0
- package/pnpm-workspace.yaml +0 -4
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/
|
|
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/clone-js-sdk.sh
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passkey-kit",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"description": "A helper library for creating and using
|
|
3
|
+
"version": "0.7.17",
|
|
4
|
+
"description": "A helper library for creating and using smart wallet accounts on the Stellar blockchain.",
|
|
5
5
|
"author": "Tyler van der Hoeven",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "src/index.ts",
|
|
9
9
|
"types": "types/index.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build:demo": "cd demo && npm --workspaces=false install && npm run build",
|
|
12
|
+
"deploy:demo": "npx wrangler pages deploy",
|
|
13
|
+
"deploy:demo:prod": "npx wrangler pages deploy --env production",
|
|
14
|
+
"prepublishOnly": "npm run build",
|
|
15
|
+
"build:sac": "npm --workspace=sac-sdk run build",
|
|
16
|
+
"build:pfs": "npm --workspace=passkey-factory-sdk run build",
|
|
17
|
+
"build:pks": "npm --workspace=passkey-kit-sdk run build",
|
|
18
|
+
"build": "npm run build:sac && npm run build:pfs && npm run build:pks && tsc",
|
|
19
|
+
"ext:cp": "./clone-js-sdk.sh"
|
|
20
|
+
},
|
|
10
21
|
"dependencies": {
|
|
11
22
|
"@darkedges/capacitor-native-webauthn": "^0.0.4",
|
|
12
23
|
"@simplewebauthn/browser": "^10.0.0",
|
|
13
|
-
"@stellar/stellar-sdk": "
|
|
24
|
+
"@stellar/stellar-sdk": "github:stellar/js-stellar-sdk",
|
|
14
25
|
"base64url": "^3.0.1",
|
|
15
26
|
"buffer": "^6.0.3",
|
|
16
|
-
"passkey-factory-sdk": "
|
|
17
|
-
"passkey-kit-sdk": "
|
|
18
|
-
"sac-sdk": "
|
|
27
|
+
"passkey-factory-sdk": "workspace:*",
|
|
28
|
+
"passkey-kit-sdk": "workspace:*",
|
|
29
|
+
"sac-sdk": "workspace:*"
|
|
19
30
|
},
|
|
20
31
|
"devDependencies": {
|
|
21
32
|
"@simplewebauthn/types": "^10.0.0",
|
|
22
|
-
"@types/node": "^22.7.
|
|
33
|
+
"@types/node": "^22.7.4",
|
|
23
34
|
"typescript": "^5.6.2"
|
|
24
35
|
},
|
|
25
36
|
"workspaces": [
|
|
@@ -27,6 +38,9 @@
|
|
|
27
38
|
"packages/passkey-kit-sdk",
|
|
28
39
|
"packages/sac-sdk"
|
|
29
40
|
],
|
|
41
|
+
"overrides": {
|
|
42
|
+
"@stellar/stellar-sdk": "$@stellar/stellar-sdk"
|
|
43
|
+
},
|
|
30
44
|
"engine": {
|
|
31
45
|
"node": ">=20"
|
|
32
46
|
},
|
|
@@ -48,12 +62,5 @@
|
|
|
48
62
|
"url": "https://github.com/kalepail/passkey-kit/issues"
|
|
49
63
|
},
|
|
50
64
|
"homepage": "https://github.com/kalepail/passkey-kit/blob/main/README.md",
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
"build:sac": "pnpm --filter ./packages/sac-sdk run build",
|
|
54
|
-
"build:pfs": "pnpm --filter ./packages/passkey-factory-sdk run build",
|
|
55
|
-
"build:pks": "pnpm --filter ./packages/passkey-kit-sdk run build",
|
|
56
|
-
"build": "pnpm run build:sac && pnpm run build:pfs && pnpm run build:pks && tsc",
|
|
57
|
-
"ext:cp": "./clone-js-sdk.sh"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
65
|
+
"packageManager": "npm@10.5.2"
|
|
66
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export {
|
|
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
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export {
|
|
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 {
|
|
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;
|
package/types/types.d.ts
ADDED
|
@@ -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
|
+
}
|
package/wrangler.toml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Generated by Wrangler on Thu Oct 03 2024 15:40:55 GMT-0400 (Eastern Daylight Time)
|
|
2
|
+
name = "passkey-kit-demo"
|
|
3
|
+
pages_build_output_dir = "demo/dist"
|
|
4
|
+
compatibility_date = "2024-10-03"
|
|
5
|
+
|
|
6
|
+
[vars]
|
|
7
|
+
VITE_factoryContractId = "CCD7M4VVKELWL2RO4XJOZOGBDF3ESFIKG2EAU4ETVNAKMRRKE6YIQU5E"
|
|
8
|
+
VITE_launchtubeUrl = "https://launchtube.sdf-ecosystem.workers.dev"
|
|
9
|
+
VITE_mercuryUrl = "https://api.mercurydata.app"
|
|
10
|
+
VITE_nativeContractId = "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC"
|
|
11
|
+
VITE_networkPassphrase = "Test SDF Network ; September 2015"
|
|
12
|
+
VITE_rpcUrl = "https://soroban-testnet.stellar.org"
|
|
13
|
+
|
|
14
|
+
[env.production.vars]
|
|
15
|
+
VITE_factoryContractId = "CCPLERXCJZB7LX2VOSOCBNRN754FRLHI6Y2AVOQBA5L7C2ZJX5RFVVET"
|
|
16
|
+
VITE_launchtubeUrl = "https://launchtube.sdf-ecosystem.workers.dev"
|
|
17
|
+
VITE_mercuryUrl = "https://api.mercurydata.app"
|
|
18
|
+
VITE_nativeContractId = "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC"
|
|
19
|
+
VITE_networkPassphrase = "Test SDF Network ; September 2015"
|
|
20
|
+
VITE_rpcUrl = "https://soroban-testnet.stellar.org"
|
package/pnpm-workspace.yaml
DELETED