passkey-kit 0.10.6 → 0.10.7

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.10.6",
3
+ "version": "0.10.7",
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.0.0",
13
13
  "base64url": "^3.0.1",
14
14
  "buffer": "^6.0.3",
15
- "passkey-kit-sdk": "0.6.2",
16
- "sac-sdk": "0.3.2"
15
+ "passkey-kit-sdk": "0.6.3",
16
+ "sac-sdk": "0.3.3"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@simplewebauthn/types": "^12.0.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.6.2",
2
+ "version": "0.6.3",
3
3
  "name": "passkey-kit-sdk",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
@@ -3,7 +3,6 @@ import {
3
3
  AssembledTransaction,
4
4
  Client as ContractClient,
5
5
  ClientOptions as ContractClientOptions,
6
- MethodOptions,
7
6
  Spec as ContractSpec,
8
7
  } from '@stellar/stellar-sdk/minimal/contract';
9
8
  import type {
@@ -18,30 +17,20 @@ if (typeof window !== 'undefined') {
18
17
 
19
18
  export const Errors = {
20
19
  1: { message: "NotFound" },
21
-
22
20
  2: { message: "AlreadyExists" },
23
-
24
21
  3: { message: "MissingContext" },
25
-
26
22
  4: { message: "SignerExpired" },
27
-
28
23
  5: { message: "FailedSignerLimits" },
29
-
30
24
  6: { message: "FailedPolicySignerLimits" },
31
-
32
25
  7: { message: "SignatureKeyValueMismatch" },
33
-
34
26
  8: { message: "ClientDataJsonChallengeIncorrect" },
35
-
36
27
  9: { message: "JsonParseError" }
37
28
  }
29
+
38
30
  export type SignerLimits = readonly [Map<string, Option<Array<SignerKey>>>];
39
31
  export type SignerKey = { tag: "Policy", values: readonly [string] } | { tag: "Ed25519", values: readonly [Buffer] } | { tag: "Secp256r1", values: readonly [Buffer] };
40
-
41
32
  export type SignerVal = { tag: "Policy", values: readonly [Option<u32>, SignerLimits] } | { tag: "Ed25519", values: readonly [Option<u32>, SignerLimits] } | { tag: "Secp256r1", values: readonly [Buffer, Option<u32>, SignerLimits] };
42
-
43
33
  export type SignerStorage = { tag: "Persistent", values: void } | { tag: "Temporary", values: void };
44
-
45
34
  export type Signer = { tag: "Policy", values: readonly [string, Option<u32>, SignerLimits, SignerStorage] } | { tag: "Ed25519", values: readonly [Buffer, Option<u32>, SignerLimits, SignerStorage] } | { tag: "Secp256r1", values: readonly [Buffer, Buffer, Option<u32>, SignerLimits, SignerStorage] };
46
35
 
47
36
  export interface Secp256r1Signature {
@@ -51,7 +40,6 @@ export interface Secp256r1Signature {
51
40
  }
52
41
 
53
42
  export type Signature = { tag: "Ed25519", values: readonly [Buffer] } | { tag: "Secp256r1", values: readonly [Secp256r1Signature] };
54
-
55
43
  export type Signatures = readonly [Map<SignerKey, Option<Signature>>];
56
44
 
57
45
  export interface Client {
@@ -134,25 +122,8 @@ export interface Client {
134
122
  */
135
123
  simulate?: boolean;
136
124
  }) => Promise<AssembledTransaction<null>>
137
-
138
125
  }
139
126
  export class Client extends ContractClient {
140
- static async deploy<T = Client>(
141
- /** Constructor/Initialization Args for the contract's `__constructor` method */
142
- { signer }: { signer: Option<Signer> },
143
- /** Options for initalizing a Client as well as for calling a method, with extras specific to deploying. */
144
- options: MethodOptions &
145
- Omit<ContractClientOptions, "contractId"> & {
146
- /** The hash of the Wasm blob, which must already be installed on-chain. */
147
- wasmHash: Buffer | string;
148
- /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
149
- salt?: Buffer | Uint8Array;
150
- /** The format used to decode `wasmHash`, if it's provided as a string. */
151
- format?: "hex" | "base64";
152
- }
153
- ): Promise<AssembledTransaction<T>> {
154
- return ContractClient.deploy({ signer }, options)
155
- }
156
127
  constructor(public readonly options: ContractClientOptions) {
157
128
  super(
158
129
  new ContractSpec(["AAAABAAAAAAAAAAAAAAABUVycm9yAAAAAAAACQAAAAAAAAAITm90Rm91bmQAAAABAAAAAAAAAA1BbHJlYWR5RXhpc3RzAAAAAAAAAgAAAAAAAAAOTWlzc2luZ0NvbnRleHQAAAAAAAMAAAAAAAAADVNpZ25lckV4cGlyZWQAAAAAAAAEAAAAAAAAABJGYWlsZWRTaWduZXJMaW1pdHMAAAAAAAUAAAAAAAAAGEZhaWxlZFBvbGljeVNpZ25lckxpbWl0cwAAAAYAAAAAAAAAGVNpZ25hdHVyZUtleVZhbHVlTWlzbWF0Y2gAAAAAAAAHAAAAAAAAACBDbGllbnREYXRhSnNvbkNoYWxsZW5nZUluY29ycmVjdAAAAAgAAAAAAAAADkpzb25QYXJzZUVycm9yAAAAAAAJ",
@@ -1,5 +1,5 @@
1
1
  import { Buffer } from "buffer";
2
- import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions, MethodOptions } from '@stellar/stellar-sdk/minimal/contract';
2
+ import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions } from '@stellar/stellar-sdk/minimal/contract';
3
3
  import type { u32, Option } from '@stellar/stellar-sdk/minimal/contract';
4
4
  export declare const Errors: {
5
5
  1: {
@@ -161,20 +161,6 @@ export interface Client {
161
161
  }
162
162
  export declare class Client extends ContractClient {
163
163
  readonly options: ContractClientOptions;
164
- static deploy<T = Client>(
165
- /** Constructor/Initialization Args for the contract's `__constructor` method */
166
- { signer }: {
167
- signer: Option<Signer>;
168
- },
169
- /** Options for initalizing a Client as well as for calling a method, with extras specific to deploying. */
170
- options: MethodOptions & Omit<ContractClientOptions, "contractId"> & {
171
- /** The hash of the Wasm blob, which must already be installed on-chain. */
172
- wasmHash: Buffer | string;
173
- /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
174
- salt?: Buffer | Uint8Array;
175
- /** The format used to decode `wasmHash`, if it's provided as a string. */
176
- format?: "hex" | "base64";
177
- }): Promise<AssembledTransaction<T>>;
178
164
  constructor(options: ContractClientOptions);
179
165
  readonly fromJSON: {
180
166
  add_signer: (json: string) => AssembledTransaction<null>;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.3.2",
2
+ "version": "0.3.3",
3
3
  "name": "sac-sdk",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
@@ -3,7 +3,6 @@ import {
3
3
  AssembledTransaction,
4
4
  Client as ContractClient,
5
5
  ClientOptions as ContractClientOptions,
6
- MethodOptions,
7
6
  Spec as ContractSpec,
8
7
  } from '@stellar/stellar-sdk/minimal/contract';
9
8
  import type {
@@ -16,13 +15,6 @@ if (typeof window !== 'undefined') {
16
15
  window.Buffer = window.Buffer || Buffer;
17
16
  }
18
17
 
19
- export const networks = {
20
- testnet: {
21
- networkPassphrase: "Test SDF Network ; September 2015",
22
- contractId: "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC",
23
- }
24
- } as const
25
-
26
18
  export const Errors = {
27
19
 
28
20
  }
@@ -530,23 +522,8 @@ export interface Client {
530
522
  */
531
523
  simulate?: boolean;
532
524
  }) => Promise<AssembledTransaction<null>>
533
-
534
525
  }
535
526
  export class Client extends ContractClient {
536
- static async deploy<T = Client>(
537
- /** Options for initalizing a Client as well as for calling a method, with extras specific to deploying. */
538
- options: MethodOptions &
539
- Omit<ContractClientOptions, "contractId"> & {
540
- /** The hash of the Wasm blob, which must already be installed on-chain. */
541
- wasmHash: Buffer | string;
542
- /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
543
- salt?: Buffer | Uint8Array;
544
- /** The format used to decode `wasmHash`, if it's provided as a string. */
545
- format?: "hex" | "base64";
546
- }
547
- ): Promise<AssembledTransaction<T>> {
548
- return ContractClient.deploy(null, options)
549
- }
550
527
  constructor(public readonly options: ContractClientOptions) {
551
528
  super(
552
529
  new ContractSpec(["AAAAAAAAAYpSZXR1cm5zIHRoZSBhbGxvd2FuY2UgZm9yIGBzcGVuZGVyYCB0byB0cmFuc2ZlciBmcm9tIGBmcm9tYC4KClRoZSBhbW91bnQgcmV0dXJuZWQgaXMgdGhlIGFtb3VudCB0aGF0IHNwZW5kZXIgaXMgYWxsb3dlZCB0byB0cmFuc2ZlcgpvdXQgb2YgZnJvbSdzIGJhbGFuY2UuIFdoZW4gdGhlIHNwZW5kZXIgdHJhbnNmZXJzIGFtb3VudHMsIHRoZSBhbGxvd2FuY2UKd2lsbCBiZSByZWR1Y2VkIGJ5IHRoZSBhbW91bnQgdHJhbnNmZXJyZWQuCgojIEFyZ3VtZW50cwoKKiBgZnJvbWAgLSBUaGUgYWRkcmVzcyBob2xkaW5nIHRoZSBiYWxhbmNlIG9mIHRva2VucyB0byBiZSBkcmF3biBmcm9tLgoqIGBzcGVuZGVyYCAtIFRoZSBhZGRyZXNzIHNwZW5kaW5nIHRoZSB0b2tlbnMgaGVsZCBieSBgZnJvbWAuAAAAAAAJYWxsb3dhbmNlAAAAAAAAAgAAAAAAAAAEZnJvbQAAABMAAAAAAAAAB3NwZW5kZXIAAAAAEwAAAAEAAAAL",
@@ -1,12 +1,5 @@
1
- import { Buffer } from "buffer";
2
- import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions, MethodOptions } from '@stellar/stellar-sdk/minimal/contract';
1
+ import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions } from '@stellar/stellar-sdk/minimal/contract';
3
2
  import type { u32, i128 } from '@stellar/stellar-sdk/minimal/contract';
4
- export declare const networks: {
5
- readonly testnet: {
6
- readonly networkPassphrase: "Test SDF Network ; September 2015";
7
- readonly contractId: "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC";
8
- };
9
- };
10
3
  export declare const Errors: {};
11
4
  export interface Client {
12
5
  /**
@@ -506,16 +499,6 @@ export interface Client {
506
499
  }
507
500
  export declare class Client extends ContractClient {
508
501
  readonly options: ContractClientOptions;
509
- static deploy<T = Client>(
510
- /** Options for initalizing a Client as well as for calling a method, with extras specific to deploying. */
511
- options: MethodOptions & Omit<ContractClientOptions, "contractId"> & {
512
- /** The hash of the Wasm blob, which must already be installed on-chain. */
513
- wasmHash: Buffer | string;
514
- /** Salt used to generate the contract's ID. Passed through to {@link Operation.createCustomContract}. Default: random. */
515
- salt?: Buffer | Uint8Array;
516
- /** The format used to decode `wasmHash`, if it's provided as a string. */
517
- format?: "hex" | "base64";
518
- }): Promise<AssembledTransaction<T>>;
519
502
  constructor(options: ContractClientOptions);
520
503
  readonly fromJSON: {
521
504
  allowance: (json: string) => AssembledTransaction<bigint>;
package/src/kit.ts CHANGED
@@ -13,14 +13,14 @@ export class PasskeyKit extends PasskeyBase {
13
13
  declare rpc: Server
14
14
  declare rpcUrl: string
15
15
 
16
- private walletKeypair = Keypair.fromRawEd25519Seed(Buffer.alloc(32))
17
- private walletPublicKey = this.walletKeypair.publicKey()
16
+ private walletKeypair: Keypair
17
+ private walletPublicKey: string
18
18
  private walletWasmHash: string
19
19
  private WebAuthn: {
20
20
  startRegistration: typeof startRegistration,
21
21
  startAuthentication: typeof startAuthentication
22
22
  }
23
-
23
+
24
24
  public keyId: string | undefined
25
25
  public networkPassphrase: string
26
26
  public wallet: PasskeyClient | undefined
@@ -39,12 +39,14 @@ export class PasskeyKit extends PasskeyBase {
39
39
  super(rpcUrl)
40
40
 
41
41
  this.networkPassphrase = networkPassphrase
42
+ this.walletKeypair = Keypair.fromRawEd25519Seed(hash(Buffer.from(this.networkPassphrase)))
43
+ this.walletPublicKey = this.walletKeypair.publicKey()
42
44
  this.walletWasmHash = walletWasmHash
43
45
  this.WebAuthn = WebAuthn || { startRegistration, startAuthentication }
44
46
  }
45
47
 
46
48
  public async createWallet(app: string, user: string) {
47
- const { keyId, keyId_base64, publicKey } = await this.createKey(app, user)
49
+ const { keyId, keyIdBase64, publicKey } = await this.createKey(app, user)
48
50
 
49
51
  const at = await PasskeyClient.deploy(
50
52
  {
@@ -82,9 +84,9 @@ export class PasskeyKit extends PasskeyBase {
82
84
 
83
85
  return {
84
86
  keyId,
85
- keyId_base64,
87
+ keyIdBase64,
86
88
  contractId,
87
- built: at.signed
89
+ signedTx: at.signed!
88
90
  }
89
91
  }
90
92
 
@@ -120,7 +122,7 @@ export class PasskeyKit extends PasskeyBase {
120
122
 
121
123
  return {
122
124
  keyId: base64url.toBuffer(id),
123
- keyId_base64: id,
125
+ keyIdBase64: id,
124
126
  publicKey: await this.getPublicKey(response),
125
127
  }
126
128
  }
@@ -189,7 +191,7 @@ export class PasskeyKit extends PasskeyBase {
189
191
 
190
192
  return {
191
193
  keyId: keyIdBuffer,
192
- keyId_base64: keyId,
194
+ keyIdBase64: keyId,
193
195
  contractId
194
196
  }
195
197
  }
package/types/kit.d.ts CHANGED
@@ -28,16 +28,16 @@ export declare class PasskeyKit extends PasskeyBase {
28
28
  });
29
29
  createWallet(app: string, user: string): Promise<{
30
30
  keyId: Buffer<ArrayBufferLike>;
31
- keyId_base64: string;
31
+ keyIdBase64: string;
32
32
  contractId: string;
33
- built: Tx | undefined;
33
+ signedTx: Tx;
34
34
  }>;
35
35
  createKey(app: string, user: string, settings?: {
36
36
  rpId?: string;
37
37
  authenticatorSelection?: AuthenticatorSelectionCriteria;
38
38
  }): Promise<{
39
39
  keyId: Buffer<ArrayBufferLike>;
40
- keyId_base64: string;
40
+ keyIdBase64: string;
41
41
  publicKey: Buffer<ArrayBufferLike>;
42
42
  }>;
43
43
  connectWallet(opts?: {
@@ -46,7 +46,7 @@ export declare class PasskeyKit extends PasskeyBase {
46
46
  getContractId?: (keyId: string) => Promise<string | undefined>;
47
47
  }): Promise<{
48
48
  keyId: Buffer<ArrayBufferLike>;
49
- keyId_base64: string;
49
+ keyIdBase64: string;
50
50
  contractId: string;
51
51
  }>;
52
52
  signAuthEntry(entry: xdr.SorobanAuthorizationEntry, options?: {