passkey-kit 0.4.6 → 0.5.1

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/README.md CHANGED
@@ -12,28 +12,62 @@ pnpm i passkey-kit
12
12
  On the client:
13
13
  ```ts
14
14
  const account = new PasskeyKit({
15
- rpcUrl: env.RPC_URL,
16
- networkPassphrase: env.NETWORK_PASSPHRASE,
17
- factoryContractId: env.FACTORY_CONTRACT_ID,
15
+ rpcUrl: env.PUBLIC_rpcUrl,
16
+ networkPassphrase: env.PUBLIC_networkPassphrase,
17
+ factoryContractId: env.PUBLIC_factoryContractId,
18
18
  });
19
19
  ```
20
20
 
21
21
  On the server:
22
22
  ```ts
23
23
  const account = new PasskeyBase({
24
- launchtubeUrl: env.LAUNCHTUBE_URL,
25
- launchtubeJwt: env.LAUNCHTUBE_JWT,
24
+ rpcUrl: env.PUBLIC_rpcUrl,
25
+ launchtubeUrl: env.PUBLIC_launchtubeUrl,
26
+ launchtubeJwt: env.PRIVATE_launchtubeJwt,
27
+ mercuryUrl: env.PUBLIC_mercuryUrl,
28
+ mercuryEmail: env.PRIVATE_mercuryEmail,
29
+ mercuryPassword: env.PRIVATE_mercuryPassword,
26
30
  });
27
31
  ```
28
32
 
29
33
  Note that while I don't recommend it you can use the server-intended `send` method on the client side by passing in the `launchtubeUrl` and `launchtubeJwt` values to the `PasskeyKit` constructor. We do this in the `./demo` site to ease demonstration, development and experimentation, however in a production environment you'll want to keep your secrets safe on the server.
30
34
 
35
+ In order to utilize the zephyr indexing service to track available signers and reverse lookup smart wallet contract addresses from passkey ids you'll need to deploy the Zephyr program from inside the `./zephyr` directory.
36
+
37
+ ```bash
38
+ cd ./zephyr
39
+ cargo install mercury-cli
40
+ # Get a JWT from Mercury https://test.mercurydata.app
41
+ export MERCURY_JWT="<YOUR.MERCURY.JWT>"
42
+ # Make sure you're on Rust version 1.79.0 or newer
43
+ mercury-cli --jwt $MERCURY_JWT --local false --mainnet false deploy
44
+ ```
45
+
31
46
  This is a fully typed library so docs aren't provided, however there's a full example showcasing all the core public methods in the `./demo` directory. I also recommend reviewing the [Super Peach](https://github.com/kalepail/superpeach) repo for an example of how you could implement both the client and server side in a more real-world scenario.
32
47
 
33
48
  Good luck, have fun, and change the world!
34
49
 
35
50
  For any questions or to showcase your progress please join the `#passkeys` channel on our [Discord](https://discord.gg/stellardev).
36
51
 
52
+ ## Some Notes
53
+
54
+ This is a TypeScript library and the npm package doesn't export a JavaScript version. The `@stellar/stellar-sdk` library is enormous and I really don't wan't folks bundling it up twice. Therefore you'll need to ensure you're transpiling this library into your project and that goes for either a TS project or a JS one. For many of you this will "just work" but for others you'll need to do some fiddling.
55
+
56
+ For example if you're using NextJS this will mean modifying your `next.config.mjs` file to include the following packages in the `transpilePackages` key:
57
+ ```mjs
58
+ /** @type {import('next').NextConfig} */
59
+ const nextConfig = {
60
+ transpilePackages: [
61
+ 'passkey-kit',
62
+ 'passkey-factory-sdk',
63
+ 'passkey-kit-sdk'
64
+ ]
65
+ };
66
+
67
+ export default nextConfig;
68
+ ```
69
+ If someone smarter than me knows how to include an optional JS build from a TS library please submit a PR. I just don't want to deploy a compiled version of this and wind up having folks doubling up on an already gargantuan dependency.
70
+
37
71
  ## Contributing
38
72
 
39
73
  Passkey kit consists of three primary directories:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "passkey-kit",
3
- "version": "0.4.6",
3
+ "version": "0.5.1",
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",
@@ -12,8 +12,9 @@
12
12
  "@stellar/stellar-sdk": "12.1.0",
13
13
  "base64url": "^3.0.1",
14
14
  "buffer": "^6.0.3",
15
- "passkey-kit-sdk": "0.2.1",
16
- "passkey-factory-sdk": "0.2.1"
15
+ "sac-sdk": "0.1.0",
16
+ "passkey-factory-sdk": "0.2.1",
17
+ "passkey-kit-sdk": "0.2.1"
17
18
  },
18
19
  "devDependencies": {
19
20
  "@simplewebauthn/types": "^10.0.0",
@@ -45,8 +46,9 @@
45
46
  "homepage": "https://github.com/kalepail/passkey-kit/blob/main/README.md",
46
47
  "scripts": {
47
48
  "build:demo": "cd demo && pnpm --ignore-workspace install && pnpm run build",
49
+ "build:sac": "pnpm --filter ./packages/sac-sdk run build",
48
50
  "build:pfs": "pnpm --filter ./packages/passkey-factory-sdk run build",
49
51
  "build:pks": "pnpm --filter ./packages/passkey-kit-sdk run build",
50
- "build": "pnpm run build:pfs && pnpm run build:pks && tsc"
52
+ "build": "pnpm run build:sac && pnpm run build:pfs && pnpm run build:pks && tsc"
51
53
  }
52
54
  }
@@ -0,0 +1,54 @@
1
+ # sac-sdk JS
2
+
3
+ JS library for interacting with [Soroban](https://soroban.stellar.org/) smart contract `sac-sdk` via Soroban RPC.
4
+
5
+ This library was automatically generated by Soroban CLI using a command similar to:
6
+
7
+ ```bash
8
+ soroban contract bindings ts \
9
+ --rpc-url https://soroban-testnet.stellar.org \
10
+ --network-passphrase "Test SDF Network ; September 2015" \
11
+ --contract-id CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC \
12
+ --output-dir ./path/to/sac-sdk
13
+ ```
14
+
15
+ The network passphrase and contract ID are exported from [index.ts](./src/index.ts) in the `networks` constant. If you are the one who generated this library and you know that this contract is also deployed to other networks, feel free to update `networks` with other valid options. This will help your contract consumers use this library more easily.
16
+
17
+ # To publish or not to publish
18
+
19
+ This library is suitable for publishing to NPM. You can publish it to NPM using the `npm publish` command.
20
+
21
+ But you don't need to publish this library to NPM to use it. You can add it to your project's `package.json` using a file path:
22
+
23
+ ```json
24
+ "dependencies": {
25
+ "sac-sdk": "./path/to/this/folder"
26
+ }
27
+ ```
28
+
29
+ However, we've actually encountered [frustration](https://github.com/stellar/soroban-example-dapp/pull/117#discussion_r1232873560) using local libraries with NPM in this way. Though it seems a bit messy, we suggest generating the library directly to your `node_modules` folder automatically after each install by using a `postinstall` script. We've had the least trouble with this approach. NPM will automatically remove what it sees as erroneous directories during the `install` step, and then regenerate them when it gets to your `postinstall` step, which will keep the library up-to-date with your contract.
30
+
31
+ ```json
32
+ "scripts": {
33
+ "postinstall": "soroban contract bindings ts --rpc-url https://soroban-testnet.stellar.org --network-passphrase \"Test SDF Network ; September 2015\" --id CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC --name sac-sdk"
34
+ }
35
+ ```
36
+
37
+ Obviously you need to adjust the above command based on the actual command you used to generate the library.
38
+
39
+ # Use it
40
+
41
+ Now that you have your library up-to-date and added to your project, you can import it in a file and see inline documentation for all of its exported methods:
42
+
43
+ ```js
44
+ import { Contract, networks } from "sac-sdk"
45
+
46
+ const contract = new Contract({
47
+ ...networks.futurenet, // for example; check which networks this library exports
48
+ rpcUrl: '...', // use your own, or find one for testing at https://soroban.stellar.org/docs/reference/rpc#public-rpc-providers
49
+ })
50
+
51
+ contract.|
52
+ ```
53
+
54
+ As long as your editor is configured to show JavaScript/TypeScript documentation, you can pause your typing at that `|` to get a list of all exports and inline-documentation for each. It exports a separate [async](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function) function for each method in the smart contract, with documentation for each generated from the comments the contract's author included in the original source code.
@@ -0,0 +1,18 @@
1
+ {
2
+ "version": "0.1.0",
3
+ "name": "sac-sdk",
4
+ "type": "module",
5
+ "main": "src/index.ts",
6
+ "types": "types/index.d.ts",
7
+ "scripts": {
8
+ "prepublishOnly": "pnpm run build",
9
+ "build": "tsc"
10
+ },
11
+ "dependencies": {
12
+ "buffer": "6.0.3",
13
+ "@stellar/stellar-sdk": "12.1.0"
14
+ },
15
+ "devDependencies": {
16
+ "typescript": "5.5.3"
17
+ }
18
+ }