Skip to content

Commit 5185a89

Browse files
authored
Merge 465c41d into e61b5ff
2 parents e61b5ff + 465c41d commit 5185a89

File tree

2 files changed

+41
-20
lines changed

2 files changed

+41
-20
lines changed

.github/workflows/lint.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,30 @@ jobs:
2121
- name: Install project dependencies
2222
run: yarn install
2323
- name: Lint
24+
id: lint
2425
run: yarn nx format:check --all
26+
continue-on-error: true # Continue even if the check fails
27+
28+
- name: Check Lint Results
29+
if: steps.lint.outcome == 'failure'
30+
run: echo "lint_failed=true" >> $GITHUB_OUTPUT
31+
32+
- name: Auto-format and commit changes if needed
33+
if: steps.lint.outcome == 'failure'
34+
run: |
35+
yarn nx format:write --all
36+
git config --global user.name "${{ github.actor }}"
37+
git config --global user.email "${{ github.actor }}@users.noreply.github.com"
38+
git add .
39+
git commit -m "auto fmt" || echo "No changes to commit"
40+
41+
# Get the current branch name
42+
BRANCH_NAME=$(git symbolic-ref --short HEAD || git rev-parse --abbrev-ref HEAD)
43+
44+
# If we're in detached HEAD state, use the GitHub event information
45+
if [ "$BRANCH_NAME" = "HEAD" ]; then
46+
BRANCH_NAME=${{ github.head_ref || github.ref_name }}
47+
fi
48+
49+
# Push changes
50+
git push origin HEAD:$BRANCH_NAME || echo "No changes to push"

packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ import type {
135135

136136
export class LitNodeClientNodeJs
137137
extends LitCore
138-
implements LitClientSessionManager, ILitNodeClient
139-
{
138+
implements LitClientSessionManager, ILitNodeClient {
140139
defaultAuthCallback?: (authSigParams: AuthCallbackParams) => Promise<AuthSig>;
141140

142141
// ========== Constructor ==========
@@ -1293,8 +1292,8 @@ export class LitNodeClientNodeJs
12931292
// -- optional params
12941293
...(params.authMethods &&
12951294
params.authMethods.length > 0 && {
1296-
authMethods: params.authMethods,
1297-
}),
1295+
authMethods: params.authMethods,
1296+
}),
12981297
};
12991298

13001299
logWithRequestId(requestId, 'reqBody:', reqBody);
@@ -2066,25 +2065,18 @@ export class LitNodeClientNodeJs
20662065
};
20672066

20682067
/**
2069-
*
2070-
* Retrieves or generates sessionSigs (think access token) for accessing Lit Network resources.
2068+
* Get session signatures for a set of [Lit resources](https://v6-api-doc-lit-js-sdk.vercel.app/interfaces/types_src.ILitResource.html#resource).
20712069
*
20722070
* How this function works on a high level:
20732071
* 1. Generate or retrieve [session keys](https://v6-api-doc-lit-js-sdk.vercel.app/interfaces/types_src.SessionKeyPair.html) (a public and private key pair)
20742072
* 2. Generate or retrieve the [`AuthSig`](https://v6-api-doc-lit-js-sdk.vercel.app/interfaces/types_src.AuthSig.html) that specifies the session [abilities](https://v6-api-doc-lit-js-sdk.vercel.app/enums/auth_helpers_src.LitAbility.html)
20752073
* 3. Sign the specific resources with the session key
20762074
*
2077-
* The process follows these steps:
2078-
* 1. Retrieves or generates a session key pair (Ed25519) for the user's device. The session key is either fetched from local storage or newly created if not found. The key does not expire.
2079-
* 2. Generates an authentication signature (`authSig`) by signing an ERC-5573 “Sign-in with Ethereum” message, which includes resource ability requests, capabilities, expiration, the user's device session public key, and a nonce. The `authSig` is retrieved from local storage, and if it has expired, the user will be prompted to re-sign.
2080-
* 3. Uses the session private key to sign the session public key along with the resource ability requests, capabilities, issuedAt, and expiration details. This creates a device-generated signature.
2081-
* 4. Constructs the session signatures (`sessionSigs`) by including the device-generated signature and the original message. The `sessionSigs` provide access to Lit Network features such as `executeJs` and `pkpSign`.
2082-
*
2083-
* See Sequence Diagram: https://www.plantuml.com/plantuml/uml/VPH1RnCn48Nl_XLFlT1Av00eGkm15QKLWY8K9K9SO-rEar4sjcLFalBl6NjJAuaMRl5utfjlPjQvJsAZx7UziQtuY5-9eWaQufQ3TOAR77cJy407Rka6zlNdHTRouUbIzSEtjiTIBUswg5v_NwMnuAVlA9KKFPN3I0x9qSSj7bqNF3iPykl9c4o9oUSJMuElv2XQ8IHAYRt3bluWM8wuVUpUJwVlFjsP8JUh5B_1DyV2AYdD6DjhLsTQTaYd3W3ad28SGWqM997fG5ZrB9DJqOaALuRwH1TMpik8tIYze-E8OrPKU5I6cMqtem2kCqOhr4vdaRAvtSjcoMkTo68scKu_Vi1EPMfrP_xVtj7sFMaHNg-6GVqk0MW0z18uKdVULTvDWtdqko28b7KktvUB2hKOBd1asU2QgDfTzrj7T4bLPdv6TR0zLwPQKkkZpIRTY4CTMbrBpg_VKuXyi49beUAHqIlirOUrL2zq9JPPdpRR5OMLVQGoGlLcjyRyQNv6MHz4W_fG42W--xWhUfNyOxiLL1USS6lRLeyAkYLNjrkVJuClm_qp5I8Lq0krUw7lwIt2DgY9oiozrjA_Yhy0
20842075
*
20852076
* Note: When generating session signatures for different PKPs or auth methods,
20862077
* be sure to call disconnectWeb3 to clear auth signatures stored in local storage
20872078
*
2079+
*
20882080
* @param { GetSessionSigsProps } params
20892081
*
20902082
* An example of how this function is used can be found in the Lit developer-guides-code repository [here](https://github.com/LIT-Protocol/developer-guides-code/tree/master/session-signatures/getSessionSigs).
@@ -2093,18 +2085,21 @@ export class LitNodeClientNodeJs
20932085
getSessionSigs = async (
20942086
params: GetSessionSigsProps
20952087
): Promise<SessionSigsMap> => {
2088+
20962089
// -- prepare
20972090
// Try to get it from local storage, if not generates one~
20982091
const sessionKey = params.sessionKey ?? this.getSessionKey();
20992092

21002093
const sessionKeyUri = this.getSessionKeyUri(sessionKey.publicKey);
21012094

21022095
// First get or generate the session capability object for the specified resources.
2103-
const sessionCapabilityObject = params.sessionCapabilityObject
2096+
const sessionCapabilityObject = params.sessionCapabilityObject
21042097
? params.sessionCapabilityObject
21052098
: await this.generateSessionCapabilityObjectWithWildcards(
2106-
params.resourceAbilityRequests.map((r) => r.resource)
2107-
);
2099+
params.resourceAbilityRequests.map((
2100+
r
2101+
) => r.resource)
2102+
);
21082103
const expiration = params.expiration || LitNodeClientNodeJs.getExpiration();
21092104

21102105
// -- (TRY) to get the wallet signature
@@ -2187,10 +2182,10 @@ export class LitNodeClientNodeJs
21872182

21882183
const capabilities = params.capacityDelegationAuthSig
21892184
? [
2190-
...(params.capabilityAuthSigs ?? []),
2191-
params.capacityDelegationAuthSig,
2192-
authSig,
2193-
]
2185+
...(params.capabilityAuthSigs ?? []),
2186+
params.capacityDelegationAuthSig,
2187+
authSig,
2188+
]
21942189
: [...(params.capabilityAuthSigs ?? []), authSig];
21952190

21962191
const signingTemplate = {

0 commit comments

Comments
 (0)