passkey-kit 0.10.23 → 0.11.0

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/.cursorrules ADDED
@@ -0,0 +1,170 @@
1
+ # Passkey Kit – Cursor Workspace Rules (v2025-06-12)
2
+
3
+ These rules provide canonical guidance to AI assistants and contributors interacting with this repository. They supersede any previous `.cursorrules` file.
4
+ Their intent is to stay *future-proof*: they encode principles that should hold even as tooling evolves. When in doubt, prefer the spirit of the rule over its letter.
5
+
6
+ ---
7
+
8
+ ## 1 Repository Topology (overview)
9
+
10
+ • `src/` – Core **passkey-kit** TypeScript library (published to npm).
11
+ • `packages/passkey-kit-sdk/` – Stand-alone TS SDK used by the main package.
12
+ • `packages/sac-sdk/` – SAC (smart-account contract) SDK.
13
+ • `contracts/` – Soroban smart contracts written in Rust.
14
+ • `zephyr/` – Deterministic Zephyr program exposing HTTP endpoints.
15
+ • `demo/` – Svelte demo showcasing end-to-end usage.
16
+
17
+ This repo is a **pnpm workspace**; always use `pnpm` (≥ 8) for Node tasks.
18
+
19
+ ---
20
+
21
+ ## 2 Language & Toolchain Baselines
22
+
23
+ | Domain | Minimum Supported | Notes |
24
+ |--------|-------------------|-------|
25
+ | Node.js | 20 LTS | ESM by default, top-level `await` allowed |
26
+ | TypeScript | 5.4 | `strict`, `moduleResolution: node16` |
27
+ | Rust (contracts) | 1.79 | Follow the current stable Soroban toolchain |
28
+ | Soroban SDK | 22.x | Keep minor versions in lock-step across contracts |
29
+ | Bun (tests) | 1.x | Used for ultrafast unit tests (`bun test`) |
30
+ | pnpm | 8.x | Managed via **Corepack**; lockfile v5 enforced |
31
+
32
+ Upgrade the baselines on every **major** release of the kit.
33
+
34
+ ---
35
+
36
+ ## 3 General Coding Principles
37
+
38
+ 1. **Functional & immutable** – avoid shared mutable state; favour pure functions.
39
+ 2. **Fail loudly, fail early** – surface rich, actionable error messages.
40
+ 3. **Minimal dependencies** – prefer platform APIs or internal utils; justify every new dep.
41
+ 4. **Typed first** – all public surfaces must be *fully* typed; export `.d.ts` files.
42
+ 5. **Async-first** – use `async/await`; never chain raw `Promise` callbacks.
43
+ 6. **Workspace integrity** – after changes run `pnpm run build` at the repo root to guarantee type-safety across packages.
44
+
45
+ ---
46
+
47
+ ## 4 JavaScript / TypeScript Specifics
48
+
49
+ • Import Stellar via `@stellar/stellar-sdk/minimal` unless full bundle is strictly required.
50
+ • Base-64 URL encode/decode with `base64url`; avoid `Buffer.from(x, 'base64')`.
51
+ • Prefer **named exports**; avoid `export default` in new code.
52
+ • File extensions: `.ts` / `.tsx` (React) / `.svelte` (demo) only.
53
+ • Module import grouping: external → workspace → relative → style imports; blank line between groups.
54
+ • Leverage modern ECMAScript (`??`, `?.`, `Array#at`, `Intl`) – but avoid stage-3 proposals unless polyfilled.
55
+ • Publish ESM-first: every package must declare `"type": "module"` and expose an `exports` map with `import`, `require` (fallback), and `types` conditions.
56
+ • Mark packages `"sideEffects": false` when safe to enable aggressive tree-shaking.
57
+ • Ship first-party `.d.ts` bundles (either via `tsc --emitDeclarationOnly` or `api-extractor`). Do **not** rely on DefinitelyTyped for kit packages.
58
+ • Top-level entrypoints should be 100 % statically analyzable – avoid dynamic `require()` or `eval()`.
59
+
60
+ ---
61
+
62
+ ## 5 Rust / Soroban Contract Rules
63
+
64
+ 1. Contracts live in `contracts/*/src`.
65
+ 2. `#![no_std]` mandatory; rely on `soroban-sdk` helpers instead of `std`.
66
+ 3. Expose a top-level `Contract` struct marked with `#[contract]`.
67
+ 4. Model errors with `#[contracterror]`; surface via `panic_with_error!`.
68
+ 5. Tests belong under `contracts/*/src/tests` using `soroban_sdk::testutils`.
69
+ 6. New contracts must be registered in `contracts/Cargo.toml` workspace members.
70
+
71
+ ---
72
+
73
+ ## 6 Zephyr Program Rules
74
+
75
+ • Zephyr code resides in `zephyr/src` and **must remain deterministic** – avoid non-deterministic data sources (e.g. system time, randomness) unless explicitly mocked.
76
+ • Each externally exposed endpoint must be documented *above* its `#[no_mangle]` function.
77
+
78
+ ---
79
+
80
+ ## 7 Svelte / Demo Rules
81
+
82
+ • Demo code lives in `demo/src`.
83
+ • Follow existing component conventions: PascalCase filenames, `<script lang="ts">`, `<style scoped>`.
84
+ • Prefer lightweight stores over global state; mock network calls when possible.
85
+
86
+ ---
87
+
88
+ ## 8 Testing & CI
89
+
90
+ 1. Run `bun test` to execute JavaScript unit tests (`bun_tests/`).
91
+ 2. Rust contract tests live alongside contracts.
92
+ 3. All new public functions (TS) or contract interfaces (Rust) require unit tests.
93
+ 4. Use **Conventional Commits** in PR titles to automate semantic-release notes.
94
+ 5. CI (GitHub Actions) must run: `pnpm lint`, `pnpm run build`, `bun test`, and contract tests.
95
+
96
+ ---
97
+
98
+ ## 9 Versioning & Release
99
+
100
+ • Independent package versions, shared workspace lockfile.
101
+ • Semantic Versioning: breaking changes → major bump.
102
+ • Root `prepublishOnly` script builds **all** packages; never publish from a dirty tree.
103
+ • Tags follow `pkg-name@x.y.z` format.
104
+ • Adopt **Changesets** for automated changelog generation and version bumping across the workspace; release pipeline should consume the generated changelog artefacts.
105
+
106
+ ---
107
+
108
+ ## 10 Style, Linting & Formatting
109
+
110
+ • Indent: 2 spaces, trailing commas, single quotes.
111
+ • Code formatted with **Prettier** (`pnpm format`).
112
+ • Lint with **ESLint** + `@typescript-eslint`. Lint errors are CI blockers.
113
+ • Prefer `const`; use `let` only when reassignment is needed.
114
+
115
+ ---
116
+
117
+ ## 11 AI Usage Etiquette
118
+
119
+ • These rules are the *source of truth* for AI coding assistants.
120
+ • Assistants must **never** write secrets, API keys, or personal data into the codebase.
121
+ • When creating code, ensure it can run *immediately* and is fully typed.
122
+ • Before adding dependencies, verify they fit the "minimal deps" philosophy and update `package.json` accordingly.
123
+
124
+ ---
125
+
126
+ ## 12 Context Shortcuts
127
+
128
+ Use these aliases when referencing files in chat:
129
+
130
+ ```text
131
+ @kit.ts → src/kit.ts
132
+ @smart-wallet → contracts/smart-wallet/src/lib.rs
133
+ @passkey-sdk → packages/passkey-kit-sdk/src
134
+ ```
135
+
136
+ ---
137
+
138
+ ## 13 Performance & Build Optimisation
139
+
140
+ 1. Prefer **incremental builds** (e.g. `pnpm --filter`, `--recursive --workspace-concurrency`) to accelerate CI and local development.
141
+ 2. Enable intelligent cache layers (GitHub Actions cache / bun test cache) to avoid redundant compilation of unchanged packages.
142
+ 3. Leverage Bun's ultra-fast test runner; keep test suites granular to maximise parallelism.
143
+ 4. When introducing heavy tasks (e.g. Soroban WASM compilation), gate them behind conditional steps so that they execute only when relevant code changes.
144
+ 5. Monitor build & test times; aim for sub-5-minute end-to-end CI under normal load.
145
+
146
+ ---
147
+
148
+ ## 14 npm Package Publishing Principles
149
+
150
+ • Source of truth is **ESM**; if CJS support is required, publish it under `./cjs` and reference with the `require` condition – no transpiled dual-bundles in `dist/`.
151
+ • Generate a **size-snapshot** report (e.g. with `size-limit`) and block PRs that increase size over budget.
152
+ • `package.json` must include: `license`, `funding`, `homepage`, `repository`, `bugs`, and a short but descriptive `description`.
153
+ • Use the `files` whitelist (or `.npmignore`) to keep the published tarball lean (< 30 KiB ideally).
154
+ • Release via GitHub Actions with `npm publish --provenance` to attach Sigstore metadata; use **two-factor auth** on the npm org.
155
+ • After publish, run `npm view @scope/pkg dist.unpackedSize` in CI and fail if unexpectedly large.
156
+
157
+ ---
158
+
159
+ ## 15 Security & Supply Chain
160
+
161
+ 1. Enforce automated dependency scanning (GitHub Dependabot + `pnpm audit --recursive`).
162
+ 2. Run **OpenSSF Scorecard** weekly; block merges if score < 7.
163
+ 3. Sign commits & tags (Conventional Commits + `git config commit.gpgsign`); CI verifies signatures.
164
+ 4. Harden CI with minimal permissions (`GITHUB_TOKEN` → read-only except on `release/*` jobs).
165
+ 5. Adopt `.npmrc` with `ignore-scripts=true` for CI and `prefer-offline=true` for faster deterministic installs.
166
+ 6. All public APIs must have runtime assertions (zod or custom) to prevent type coercion exploits.
167
+
168
+ ---
169
+
170
+ End of rules.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  > [!WARNING]
4
4
  > Code in this repo is demo material only. It has not been audited. Do not use to hold, protect, or secure anything.
5
5
 
6
- Passkey kit is a basic TypeScript SDK for creating and managing Stellar smart wallets. It's intended to be used in tandem with [Launchtube](https://github.com/kalepail/launchtube) for submitting passkey signed transactions onchain however this is not a requirement. This is both a client and a server side library. `PasskeyKit` on the client and `PasskeyServer` on the server.
6
+ Passkey kit is a basic TypeScript SDK for creating and managing Stellar smart wallets. It's intended to be used in tandem with [Launchtube](https://github.com/stellar/launchtube) for submitting passkey signed transactions onchain however this is not a requirement. This is both a client and a server side library. `PasskeyKit` on the client and `PasskeyServer` on the server.
7
7
 
8
8
  Demo site: [passkey-kit-demo.pages.dev](https://passkey-kit-demo.pages.dev/)
9
9
 
package/cheatsheet.txt CHANGED
@@ -5,8 +5,8 @@ npm publish --workspaces
5
5
  pnpm publish --no-git-checks
6
6
 
7
7
  # Stellar commands
8
- stellar contract bindings rust --wasm target/wasm32-unknown-unknown/release/smart_wallet.wasm
9
- stellar contract deploy --wasm target/wasm32-unknown-unknown/release/sample_policy.wasm --network testnet --source default
8
+ stellar contract bindings rust --wasm target/wasm32v1-none/release/smart_wallet.wasm
9
+ stellar contract deploy --wasm target/wasm32v1-none/release/sample_policy.wasm --network testnet --source default
10
10
 
11
11
  # Mercury commands
12
12
  # https://test.mercurydata.app/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "passkey-kit",
3
- "version": "0.10.23",
3
+ "version": "0.11.0",
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",
@@ -9,11 +9,11 @@
9
9
  "types": "types/index.d.ts",
10
10
  "dependencies": {
11
11
  "@simplewebauthn/browser": "^13.1.0",
12
- "@stellar/stellar-sdk": "^13.3.0",
12
+ "@stellar/stellar-sdk": "14.0.0-rc.3",
13
13
  "base64url": "^3.0.1",
14
14
  "buffer": "^6.0.3",
15
- "sac-sdk": "0.3.8",
16
- "passkey-kit-sdk": "0.6.8"
15
+ "sac-sdk": "0.4.0",
16
+ "passkey-kit-sdk": "0.7.0"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@simplewebauthn/types": "^12.0.0",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.6.8",
2
+ "version": "0.7.0",
3
3
  "name": "passkey-kit-sdk",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
@@ -9,7 +9,7 @@
9
9
  "build": "tsc"
10
10
  },
11
11
  "dependencies": {
12
- "@stellar/stellar-sdk": "^13.3.0",
12
+ "@stellar/stellar-sdk": "14.0.0-rc.3",
13
13
  "buffer": "^6.0.3"
14
14
  },
15
15
  "devDependencies": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.3.8",
2
+ "version": "0.4.0",
3
3
  "name": "sac-sdk",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
@@ -9,7 +9,7 @@
9
9
  "build": "tsc"
10
10
  },
11
11
  "dependencies": {
12
- "@stellar/stellar-sdk": "^13.3.0",
12
+ "@stellar/stellar-sdk": "14.0.0-rc.3",
13
13
  "buffer": "^6.0.3"
14
14
  },
15
15
  "devDependencies": {
package/src/kit.ts CHANGED
@@ -54,7 +54,7 @@ export class PasskeyKit extends PasskeyBase {
54
54
  }
55
55
 
56
56
  public async createWallet(app: string, user: string) {
57
- const { keyId, keyIdBase64, publicKey } = await this.createKey(app, user)
57
+ const { rawResponse, keyId, keyIdBase64, publicKey } = await this.createKey(app, user)
58
58
 
59
59
  const at = await PasskeyClient.deploy(
60
60
  {
@@ -92,6 +92,7 @@ export class PasskeyKit extends PasskeyBase {
92
92
  })
93
93
 
94
94
  return {
95
+ rawResponse,
95
96
  keyId,
96
97
  keyIdBase64,
97
98
  contractId,
@@ -424,7 +425,7 @@ export class PasskeyKit extends PasskeyBase {
424
425
  ) {
425
426
  if (!(txn instanceof AssembledTransaction)) {
426
427
  try {
427
- txn = AssembledTransaction.fromXDR(this.wallet!.options, typeof txn === 'string' ? txn : txn.toXDR(), this.wallet!.spec)
428
+ txn = AssembledTransaction.fromXDR(this.wallet!.options, typeof txn === 'string' ? txn : txn.toXDR(), this.wallet!.spec);
428
429
  } catch {
429
430
  if (!(txn instanceof AssembledTransaction)) {
430
431
  const built = TransactionBuilder.fromXDR(typeof txn === 'string' ? txn : txn.toXDR(), this.networkPassphrase);
package/types/kit.d.ts CHANGED
@@ -29,6 +29,7 @@ export declare class PasskeyKit extends PasskeyBase {
29
29
  };
30
30
  });
31
31
  createWallet(app: string, user: string): Promise<{
32
+ rawResponse: import("@simplewebauthn/browser").RegistrationResponseJSON;
32
33
  keyId: Buffer<ArrayBufferLike>;
33
34
  keyIdBase64: string;
34
35
  contractId: string;