Skip to content

Commit

Permalink
v7 Docs
Browse files Browse the repository at this point in the history
V7 Docs Updates
  • Loading branch information
awisniew207 authored Nov 6, 2024
2 parents d9b92db + e516d6f commit 0875232
Show file tree
Hide file tree
Showing 54 changed files with 1,302 additions and 746 deletions.
2 changes: 1 addition & 1 deletion docs/api-reference/latest.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import FeedbackComponent from "@site/src/pages/feedback.md";

# Latest SDK Version

The most recent version of the SDK i.e. v6.x.x (beta) API docs can be viewed [here](https://v6-api-doc-lit-js-sdk.vercel.app/).
The most recent version of the SDK (v7.x.x) API docs can be viewed [here](https://v7-api-doc-lit-js-sdk.vercel.app/).

<FeedbackComponent/>
9 changes: 9 additions & 0 deletions docs/api-reference/v6-sdk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

# SDK 6.x.x

The SDK v6.x.x API docs can be viewed [here](https://v6-api-doc-lit-js-sdk.vercel.app/).

:::warning
Please note that the latest API docs are [here](https://developer.litprotocol.com/api-reference/latest/).
:::
<FeedbackComponent/>
10 changes: 5 additions & 5 deletions docs/concepts/capacity-credits-concept.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ You can read more about Session Signatures [here](../sdk/authentication/session-


```javascript
import { LitNetwork } from "@lit-protocol/constants";
import { LIT_NETWORK, LIT_ABILITY } from "@lit-protocol/constants";

const litNodeClient = new LitNodeClient({
litNetwork: LitNetwork.DatilTest,
litNetwork: LIT_NETWORK.DatilTest,
checkNodeAttestation: true,
});

Expand All @@ -66,12 +66,12 @@ import { LitNetwork } from "@lit-protocol/constants";

recapObject.addCapabilityForResource(
litResource,
LitAbility.LitActionExecution
LIT_ABILITY.LitActionExecution
);

const verified = recapObject.verifyCapabilitiesForResource(
litResource,
LitAbility.LitActionExecution
LIT_ABILITY.LitActionExecution
);

if (!verified) {
Expand Down Expand Up @@ -110,7 +110,7 @@ import { LitNetwork } from "@lit-protocol/constants";
resourceAbilityRequests: [
{
resource: new LitActionResource('*'),
ability: LitAbility.LitActionExecution,
ability: LIT_ABILITY.LitActionExecution,
},
],
authNeededCallback,
Expand Down
6 changes: 3 additions & 3 deletions docs/connecting-to-a-lit-network/connecting.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Connecting to a Lit Network

After installing the Lit SDK, you can connect an instance of [LitNodeClient](https://v6-api-doc-lit-js-sdk.vercel.app/classes/lit_node_client_src.LitNodeClient.html) to a Lit network. This is done by setting the `litNetwork` property when instantiating an instance of `LitNodeClient`:
After installing the Lit SDK, you can connect an instance of [LitNodeClient](https://v7-api-doc-lit-js-sdk.vercel.app/classes/lit_node_client_src.LitNodeClient.html) to a Lit network. This is done by setting the `litNetwork` property when instantiating an instance of `LitNodeClient`:

```ts
import { LitNodeClient } from "@lit-protocol/lit-node-client";
import { LitNetwork } from "@lit-protocol/constants";
import { LIT_NETWORK } from "@lit-protocol/constants";

const litNodeClient = new LitNodeClient({
// Change this to the Lit SDK Network Identifier you want to connect to
litNetwork: LitNetwork.DatilDev,
litNetwork: LIT_NETWORK.DatilDev,
});
await litNodeClient.connect();
```
Expand Down
49 changes: 26 additions & 23 deletions docs/integrations/aa/candide.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,37 +49,31 @@ JSON_RPC_NODE_PROVIDER= // Get an RPC from a Node provider
#### Initialize the Lit Network Connection and GoogleProvider

- Connect to the Lit Network using LitNodeClient.
- Set up the LitAuthClient for authentication.
- Set up the LitRelay for authentication.
- Initialize a GoogleProvider for Google sign-in.

```jsx
import { LitNodeClient } from "@lit-protocol/lit-node-client";
import { LitAuthClient, GoogleProvider } from "@lit-protocol/lit-auth-client";
import { ProviderType, LitNetwork } from "@lit-protocol/constants";
import { LitRelay } from "@lit-protocol/lit-auth-client";
import { GoogleProvider } from "@lit-protocol/providers";
import { PROVIDER_TYPE, LIT_NETWORK } from "@lit-protocol/constants";

const initalizeClientsAndProvider = async () => {
const litNodeClient = new LitNodeClient({
litNetwork: LitNetwork.DatilDev,
litNetwork: LIT_NETWORK.DatilDev,
debug: true,
});
await litNodeClient.connect();

const litAuthClient = new LitAuthClient({
litRelayConfig: {
relayApiKey: process.env.LIT_API_KEY,
},
litNodeClient,
const litRelay = new LitRelay({
relayUrl: LitRelay.getRelayUrl(LIT_NETWORK.DatilDev),
relayApiKey: 'test-api-key',
});
console.log("Connected to Lit Nodes and Lit Relay ✔️");

console.log("Connected to Lit Node and Lit Auth Clients ✔️");
const provider = new GoogleProvider({ relay: litRelay, litNodeClient });

const provider = litAuthClient.initProvider<GoogleProvider>(
ProviderType.Google,
{
// redirectUri: The redirect URI Lit's login server should redirect to after a successful login
}
);
return { litNodeClient, litAuthClient, provider };
return { litNodeClient, litRelay, provider };
};
```

Expand Down Expand Up @@ -108,11 +102,20 @@ const authMethod = await generateAuthMethod();
if (!authMethod) {
return;
}
Mint PKP (Programmable Key Pair)
import { LitAuthClient } from "@lit-protocol/lit-auth-client";
```

#### Mint PKP (Programmable Key Pair)

```jsx
import { LitRelay } from "@lit-protocol/lit-auth-client";

const mintWithGoogle = async (authMethod) => {
const pkp = await litAuthClient.mintPKPWithAuthMethods([authMethod], {
const litRelay = new LitRelay({
relayUrl: LitRelay.getRelayUrl(LIT_NETWORK.DatilDev),
relayApiKey: 'test-api-key',
});

const pkp = await litRelay.mintPKPWithAuthMethods([authMethod], {
addPkpEthAddressAsPermittedAddress: true
});
console.log("Fetched PKP", pkp);
Expand All @@ -127,7 +130,7 @@ console.log("Minted PKP ✔️");

```jsx
import { PKPEthersWallet } from "@lit-protocol/pkp-ethers";
import { LitAbility, LitPKPResource } from "@lit-protocol/auth-helpers";
import { LIT_ABILITY, LitPKPResource } from "@lit-protocol/auth-helpers";
import { AuthCallbackParams } from "@lit-protocol/types";
import { LIT_RPC } from "@lit-protocol/constants";

Expand All @@ -139,7 +142,7 @@ const response = await litNodeClient.signSessionKey({
resourceAbilityRequests: [
{
resource: new LitPKPResource("*"),
ability: LitAbility.PKPSigning,
ability: LIT_ABILITY.PKPSigning,
},
],
expiration: params.expiration,
Expand All @@ -159,7 +162,7 @@ const guardianSigner = new PKPEthersWallet({
resourceAbilityRequests: [
{
resource: new LitPKPResource("*"),
ability: LitAbility.PKPSigning,
ability: LIT_ABILITY.PKPSigning,
},
],
authNeededCallback: authNeededCallback,
Expand Down
46 changes: 33 additions & 13 deletions docs/integrations/aa/pimlico.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,39 +152,45 @@ You can also ping the Lit developement team on [Discord](https://litgateway.com/
### 6. Mint a PKPs through Lit Protocol

```js
const litClient = new LitAuthClient({
litRelayConfig: {
relayApiKey: '<Your Lit Relay Server API Key>',
}
import { LIT_NETWORK } from "@lit-protocol/constants";
import { StytchOtpProvider } from "@lit-protocol/providers";
import { LitRelay } from "@lit-protocol/lit-auth-client";

const litRelay = new LitRelay({
relayUrl: LitRelay.getRelayUrl(LIT_NETWORK.DatilDev),
relayApiKey: 'test-api-key',
});
const session = litClient.initProvider(ProviderType.StytchOtp, {

const session = new StytchOtpProvider({ relay: litRelay, litNodeClient,
userId: sessionStatus.session.user_id,
appId: "project-test-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
})
});

const authMethod = await session.authenticate({
accessToken: sessionStatus.session_jwt
})
});

await session.mintPKPThroughRelayer(authMethod)
const pkps = await session.fetchPKPsThroughRelayer(authMethod)
await litRelay.mintPKPWithAuthMethods([authMethod], {});
const pkps = await session.fetchPKPs(authMethod);
```


### 7. Generate the Controller Session Signatures or its context to generate them on demand

```js
import { LitNodeClientNodeJs } from "@lit-protocol/lit-node-client-nodejs";
import { LIT_ABILITY, LIT_NETWORK } from "@lit-protocol/constants";

const litNodeClient = new LitNodeClientNodeJs({
litNetwork: "datil-dev",
litNetwork: LIT_NETWORK.DatilDev,
debug: false,
})
await litNodeClient.connect();

const resourceAbilities = [
{
resource: new LitActionResource("*"),
ability: LitAbility.PKPSigning,
ability: LIT_ABILITY.PKPSigning,
},
];

Expand Down Expand Up @@ -228,8 +234,22 @@ We will now generate a wallet that can act a regular Ethers.js wallet, but will
const pkpWallet = new PKPEthersWallet({
pkpPubKey: pkp[pkp.length - 1].publicKey,
rpc: "<standard RPC URL for the chain you are using>", // e.g. https://rpc.ankr.com/eth_goerli
litNodeClient,
authContext: {
getSessionSigsProps: {
chain: 'ethereum',
expiration: new Date(Date.now() + 60_000 * 60).toISOString(),
resourceAbilityRequests: resourceAbilities,
authNeededCallback,
},
},
// controllerSessionSigs: sesionSigs, // (deprecated) If you will be passing sessionSigs directly, do not pass authContext
});

const pkpWallet = new PKPEthersWallet({
pkpPubKey: pkp[pkp.length - 1].publicKey,
litNodeClient,
authContext: {
client: litNodeClient,
getSessionSigsProps: {
chain: 'ethereum',
expiration: new Date(Date.now() + 60_000 * 60).toISOString(),
Expand Down
19 changes: 9 additions & 10 deletions docs/integrations/storage/irys.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Connect to a Lit node on one of our [active networks](https://developer.litproto

```ts
import * as LitJsSdk from "@lit-protocol/lit-node-client-nodejs";
import { LitNetwork } from "@lit-protocol/constants";
import { LIT_NETWORK } from "@lit-protocol/constants";

let litNodeClientInstance: LitJsSdk.LitNodeClientNodeJs | null = null;

Expand All @@ -100,7 +100,7 @@ async function getLitNodeClient(): Promise<LitJsSdk.LitNodeClientNodeJs> {

litNodeClientInstance = new LitJsSdk.LitNodeClientNodeJs({
alertWhenUnauthorized: false,
litNetwork: LitNetwork.DatilDev, // DatilDev network for free usage
litNetwork: LIT_NETWORK.DatilDev, // DatilDev network for free usage
debug: false,
});

Expand Down Expand Up @@ -181,8 +181,6 @@ We provide multiple methods to encrypt data, including strings, files, zip files

- `encryptString():` Encrypts a string.
- `encryptToJson()`: Encrypts a string or file and serializes the result to JSON.
- `zipAndEncryptString()`: Encrypts and compresses a string into a zip file. Useful for bundling multiple pieces of data.
- `encryptFile()` and `zipAndEncryptFiles()`: Encrypt a single file or multiple files.

We will use `encryptString()` to encrypt a simple string:

Expand Down Expand Up @@ -291,7 +289,7 @@ async function decryptData(
resourceAbilityRequests: [
{
resource: new LitAccessControlConditionResource("*"),
ability: LitAbility.AccessControlConditionDecryption,
ability: LIT_ABILITY.AccessControlConditionDecryption,
},
],
authNeededCallback: async (params: any) => {
Expand Down Expand Up @@ -351,10 +349,13 @@ Connect to a Lit node on one of our [active networks](https://developer.litproto
```ts
import * as LitJsSdk from "@lit-protocol/lit-node-client";
import { LitNodeClient } from "@lit-protocol/lit-node-client";
import { LIT_NETWORK } from "@lit-protocol/constants";

const litClient = new LitNodeClient({
litNetwork: "datil-dev",
const litNodeClient = new LitNodeClient({
litNetwork: LIT_NETWORK.DatilDev,
});

await litNodeClient.connect();
```

### Setting Access Control Rules
Expand Down Expand Up @@ -427,8 +428,6 @@ We provide multiple methods to encrypt data, including strings, files, zip files

- `encryptString()`: Encrypts a string.
- `encryptToJson()`: Encrypts a string or file and serializes the result to JSON.
- `zipAndEncryptString()`: Encrypts and compresses a string into a zip file. Useful for bundling multiple pieces of data.
- `encryptFile()` and `zipAndEncryptFiles()`: Encrypt a single file or multiple files.

We will use `encryptString()` to encrypt a string:

Expand Down Expand Up @@ -569,7 +568,7 @@ export const decryptData = async (encryptedText: string, dataToEncryptHash: stri
resourceAbilityRequests: [
{
resource: litResource,
ability: LitAbility.AccessControlConditionDecryption,
ability: LIT_ABILITY.AccessControlConditionDecryption,
},
],
authNeededCallback,
Expand Down
16 changes: 8 additions & 8 deletions docs/intro/first-request/connecting-to-lit.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ When initializing a `LitNodeClient` instance, you must provide a `litNetwork`.

```tsx
import { LitNodeClient } from '@lit-protocol/lit-node-client';
import { LitNetwork } from '@lit-protocol/constants';
import { LIT_NETWORK } from '@lit-protocol/constants';

const litNodeClient = new LitNodeClient({
litNetwork: LitNetwork.DatilDev,
litNetwork: LIT_NETWORK.DatilDev,
debug: false,
});

await litNodeClient.connect();
```

### `LitNetwork` Constant
### `LIT_NETWORK` Constant

The `LitNetwork` constant contains the past and present Lit networks. The constant is imported from the `@lit-protocol/constants` package. The current networks in the constant can be found [here](https://v6-api-doc-lit-js-sdk.vercel.app/enums/constants_src.LitNetwork.html).
The `LIT_NETWORK` constant contains the past and present Lit networks. The constant is imported from the `@lit-protocol/constants` package. The current networks in the constant can be found [here](https://v7-api-doc-lit-js-sdk.vercel.app/variables/constants_src.LIT_NETWORK.html).

### `LitNodeClient` Flags

You have the option to pass flags to the `LitNodeClient` instance. These flags are used to configure the Lit network connection. You can find a complete list of flags in the [LitNodeClient Config](https://v6-api-doc-lit-js-sdk.vercel.app/interfaces/types_src.LitNodeClientConfig.html). In this guide we will cover the most common flags: `debug` and `storageProvider`.
You have the option to pass flags to the `LitNodeClient` instance. These flags are used to configure the Lit network connection. You can find a complete list of flags in the [LitNodeClient Config](https://v7-api-doc-lit-js-sdk.vercel.app/interfaces/types_src.LitNodeClientConfig.html). In this guide we will cover the most common flags: `debug` and `storageProvider`.

#### `debug`

Expand All @@ -38,13 +38,13 @@ In a browser environment, the `storageProvider` flag will be ignored, and the Se

```ts
import { LitNodeClient } from '@lit-protocol/lit-node-client';
import { LitNetwork } from '@lit-protocol/constants';
import { LIT_NETWORK } from '@lit-protocol/constants';
import { disconnectWeb3 } from "@lit-protocol/auth-browser";

let litNodeClient;
try {
litNodeClient = new LitNodeClient({
litNetwork: LitNetwork.DatilDev,
litNetwork: LIT_NETWORK.DatilDev,
debug: false,
});

Expand Down Expand Up @@ -90,7 +90,7 @@ The following is an example of a response to a request made using `LitNodeClient

### API Reference

To learn more about `LitNodeClient` properties and methods, visit the [API Reference Docs](https://v6-api-doc-lit-js-sdk.vercel.app/classes/core_src.LitCore.html).
To learn more about `LitNodeClient` properties and methods, visit the [API Reference Docs](https://v7-api-doc-lit-js-sdk.vercel.app/classes/core_src.LitCore.html).

### Code Example

Expand Down
Loading

0 comments on commit 0875232

Please sign in to comment.