passkey-kit 0.10.16 → 0.10.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/package.json +3 -3
- package/src/server.ts +7 -3
- package/types/src/base.d.ts +6 -0
- package/types/src/index.d.ts +5 -0
- package/types/src/kit.d.ts +82 -0
- package/types/src/sac.d.ts +13 -0
- package/types/src/server.d.ts +28 -0
- package/types/src/types.d.ts +22 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passkey-kit",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.17",
|
|
4
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",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"@stellar/stellar-sdk": "^13.1.0",
|
|
13
13
|
"base64url": "^3.0.1",
|
|
14
14
|
"buffer": "^6.0.3",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"passkey-kit-sdk": "0.6.5",
|
|
16
|
+
"sac-sdk": "0.3.5"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@simplewebauthn/types": "^12.0.0",
|
package/src/server.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { xdr } from "@stellar/stellar-sdk/minimal"
|
|
2
2
|
import { PasskeyBase } from "./base"
|
|
3
3
|
import base64url from "base64url"
|
|
4
4
|
import type { Tx } from "@stellar/stellar-sdk/minimal/contract"
|
|
5
5
|
import type { Signer } from "./types"
|
|
6
6
|
import { AssembledTransaction } from "@stellar/stellar-sdk/minimal/contract"
|
|
7
7
|
import { Durability } from "@stellar/stellar-sdk/minimal/rpc"
|
|
8
|
+
import { version } from '../package.json'
|
|
8
9
|
|
|
9
10
|
export class PasskeyServer extends PasskeyBase {
|
|
10
11
|
private launchtubeJwt: string | undefined
|
|
@@ -149,7 +150,7 @@ export class PasskeyServer extends PasskeyBase {
|
|
|
149
150
|
- Add a method for getting a paginated or filtered list of all a wallet's events
|
|
150
151
|
*/
|
|
151
152
|
|
|
152
|
-
public async send<T>(txn: AssembledTransaction<T> | Tx | string, fee?: number) {
|
|
153
|
+
public async send<T>(txn: AssembledTransaction<T> | Tx | string, fee?: number, headers?: Record<string, string>) {
|
|
153
154
|
if (!this.launchtubeUrl || !this.launchtubeJwt)
|
|
154
155
|
throw new Error('Launchtube service not configured')
|
|
155
156
|
|
|
@@ -170,11 +171,14 @@ export class PasskeyServer extends PasskeyBase {
|
|
|
170
171
|
method: 'POST',
|
|
171
172
|
headers: {
|
|
172
173
|
authorization: `Bearer ${this.launchtubeJwt}`,
|
|
174
|
+
'X-Client-Name': 'passkey-kit',
|
|
175
|
+
'X-Client-Version': version,
|
|
176
|
+
...headers
|
|
173
177
|
},
|
|
174
178
|
body: data
|
|
175
179
|
}).then(async (res) => {
|
|
176
180
|
if (res.ok)
|
|
177
|
-
|
|
181
|
+
return res.json()
|
|
178
182
|
else throw await res.json()
|
|
179
183
|
})
|
|
180
184
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Client as PasskeyClient } from 'passkey-kit-sdk';
|
|
2
|
+
import { xdr, Keypair } from '@stellar/stellar-sdk/minimal';
|
|
3
|
+
import type { AuthenticatorSelectionCriteria } from "@simplewebauthn/types";
|
|
4
|
+
import { startRegistration, startAuthentication } from "@simplewebauthn/browser";
|
|
5
|
+
import { Buffer } from 'buffer';
|
|
6
|
+
import type { SignerKey, SignerLimits, SignerStore } from './types';
|
|
7
|
+
import { PasskeyBase } from './base';
|
|
8
|
+
import { AssembledTransaction, type Tx } from '@stellar/stellar-sdk/minimal/contract';
|
|
9
|
+
import type { Server } from '@stellar/stellar-sdk/minimal/rpc';
|
|
10
|
+
export declare class PasskeyKit extends PasskeyBase {
|
|
11
|
+
rpc: Server;
|
|
12
|
+
rpcUrl: string;
|
|
13
|
+
private walletKeypair;
|
|
14
|
+
private walletPublicKey;
|
|
15
|
+
private walletWasmHash;
|
|
16
|
+
private WebAuthn;
|
|
17
|
+
keyId: string | undefined;
|
|
18
|
+
networkPassphrase: string;
|
|
19
|
+
wallet: PasskeyClient | undefined;
|
|
20
|
+
constructor(options: {
|
|
21
|
+
rpcUrl: string;
|
|
22
|
+
networkPassphrase: string;
|
|
23
|
+
walletWasmHash: string;
|
|
24
|
+
WebAuthn?: {
|
|
25
|
+
startRegistration: typeof startRegistration;
|
|
26
|
+
startAuthentication: typeof startAuthentication;
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
createWallet(app: string, user: string): Promise<{
|
|
30
|
+
keyId: Buffer<ArrayBufferLike>;
|
|
31
|
+
keyIdBase64: string;
|
|
32
|
+
contractId: string;
|
|
33
|
+
signedTx: Tx;
|
|
34
|
+
}>;
|
|
35
|
+
createKey(app: string, user: string, settings?: {
|
|
36
|
+
rpId?: string;
|
|
37
|
+
authenticatorSelection?: AuthenticatorSelectionCriteria;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
keyId: Buffer<ArrayBufferLike>;
|
|
40
|
+
keyIdBase64: string;
|
|
41
|
+
publicKey: Buffer<ArrayBufferLike>;
|
|
42
|
+
}>;
|
|
43
|
+
connectWallet(opts?: {
|
|
44
|
+
rpId?: string;
|
|
45
|
+
keyId?: string | Uint8Array;
|
|
46
|
+
getContractId?: (keyId: string) => Promise<string | undefined>;
|
|
47
|
+
walletPublicKey?: string;
|
|
48
|
+
}): Promise<{
|
|
49
|
+
keyId: Buffer<ArrayBufferLike>;
|
|
50
|
+
keyIdBase64: string;
|
|
51
|
+
contractId: string;
|
|
52
|
+
}>;
|
|
53
|
+
signAuthEntry(entry: xdr.SorobanAuthorizationEntry, options?: {
|
|
54
|
+
rpId?: string;
|
|
55
|
+
keyId?: 'any' | string | Uint8Array;
|
|
56
|
+
keypair?: Keypair;
|
|
57
|
+
policy?: string;
|
|
58
|
+
expiration?: number;
|
|
59
|
+
}): Promise<xdr.SorobanAuthorizationEntry>;
|
|
60
|
+
sign<T>(txn: AssembledTransaction<T> | Tx | string, options?: {
|
|
61
|
+
rpId?: string;
|
|
62
|
+
keyId?: 'any' | string | Uint8Array;
|
|
63
|
+
keypair?: Keypair;
|
|
64
|
+
policy?: string;
|
|
65
|
+
expiration?: number;
|
|
66
|
+
}): Promise<AssembledTransaction<T>>;
|
|
67
|
+
addSecp256r1(keyId: string | Uint8Array, publicKey: string | Uint8Array, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<AssembledTransaction<null>>;
|
|
68
|
+
addEd25519(publicKey: string, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<AssembledTransaction<null>>;
|
|
69
|
+
addPolicy(policy: string, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<AssembledTransaction<null>>;
|
|
70
|
+
updateSecp256r1(keyId: string | Uint8Array, publicKey: string | Uint8Array, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<AssembledTransaction<null>>;
|
|
71
|
+
updateEd25519(publicKey: string, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<AssembledTransaction<null>>;
|
|
72
|
+
updatePolicy(policy: string, limits: SignerLimits, store: SignerStore, expiration?: number): Promise<AssembledTransaction<null>>;
|
|
73
|
+
remove(signer: SignerKey): Promise<AssembledTransaction<null>>;
|
|
74
|
+
private secp256r1;
|
|
75
|
+
private ed25519;
|
|
76
|
+
private policy;
|
|
77
|
+
private getSignerLimits;
|
|
78
|
+
private getSignerKey;
|
|
79
|
+
private encodeContract;
|
|
80
|
+
private getPublicKey;
|
|
81
|
+
private compactSignature;
|
|
82
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Client as SacClient } from 'sac-sdk';
|
|
2
|
+
import { PasskeyBase } from "./base";
|
|
3
|
+
import type { Server } from '@stellar/stellar-sdk/minimal/rpc';
|
|
4
|
+
export declare class SACClient extends PasskeyBase {
|
|
5
|
+
rpc: Server;
|
|
6
|
+
rpcUrl: string;
|
|
7
|
+
networkPassphrase: string;
|
|
8
|
+
constructor(options: {
|
|
9
|
+
networkPassphrase: string;
|
|
10
|
+
rpcUrl: string;
|
|
11
|
+
});
|
|
12
|
+
getSACClient(SACContractId: string): SacClient;
|
|
13
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PasskeyBase } from "./base";
|
|
2
|
+
import type { Tx } from "@stellar/stellar-sdk/minimal/contract";
|
|
3
|
+
import type { Signer } from "./types";
|
|
4
|
+
import { AssembledTransaction } from "@stellar/stellar-sdk/minimal/contract";
|
|
5
|
+
export declare class PasskeyServer extends PasskeyBase {
|
|
6
|
+
private launchtubeJwt;
|
|
7
|
+
private mercuryJwt;
|
|
8
|
+
private mercuryKey;
|
|
9
|
+
launchtubeUrl: string | undefined;
|
|
10
|
+
mercuryProjectName: string | undefined;
|
|
11
|
+
mercuryUrl: string | undefined;
|
|
12
|
+
constructor(options: {
|
|
13
|
+
rpcUrl?: string;
|
|
14
|
+
launchtubeUrl?: string;
|
|
15
|
+
launchtubeJwt?: string;
|
|
16
|
+
mercuryProjectName?: string;
|
|
17
|
+
mercuryUrl?: string;
|
|
18
|
+
mercuryJwt?: string;
|
|
19
|
+
mercuryKey?: string;
|
|
20
|
+
});
|
|
21
|
+
getSigners(contractId: string): Promise<Signer[]>;
|
|
22
|
+
getContractId(options: {
|
|
23
|
+
keyId?: string;
|
|
24
|
+
publicKey?: string;
|
|
25
|
+
policy?: string;
|
|
26
|
+
}, index?: number): Promise<string>;
|
|
27
|
+
send<T>(txn: AssembledTransaction<T> | Tx | string, fee?: number, headers?: Record<string, string>): Promise<any>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type Signer = {
|
|
2
|
+
kind: string;
|
|
3
|
+
key: string;
|
|
4
|
+
val: string;
|
|
5
|
+
expiration: number | null;
|
|
6
|
+
storage: "Persistent" | "Temporary";
|
|
7
|
+
limits: string;
|
|
8
|
+
evicted?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare class SignerKey {
|
|
11
|
+
key: "Policy" | "Ed25519" | "Secp256r1";
|
|
12
|
+
value: string;
|
|
13
|
+
private constructor();
|
|
14
|
+
static Policy(policy: string): SignerKey;
|
|
15
|
+
static Ed25519(publicKey: string): SignerKey;
|
|
16
|
+
static Secp256r1(id: string): SignerKey;
|
|
17
|
+
}
|
|
18
|
+
export type SignerLimits = Map<string, SignerKey[] | undefined> | undefined;
|
|
19
|
+
export declare enum SignerStore {
|
|
20
|
+
Persistent = "Persistent",
|
|
21
|
+
Temporary = "Temporary"
|
|
22
|
+
}
|