MCPcopy
hub / github.com/spaceandtimefdn/SxT-NodeJS-SDK / CheckExistingSession

Function CheckExistingSession

examples/index.ts:16–40  ·  view source on GitHub ↗
(
    sessionFilePath: string,
    sxt: any
)

Source from the content-addressed store, hash-verified

14 * Check existing session
15 */
16const CheckExistingSession = async (
17 sessionFilePath: string,
18 sxt: any
19): Promise<Boolean> => {
20 const storage = sxt.Storage();
21 if (storage.ReadSession(sessionFilePath)?.error) {
22 return false;
23 }
24
25 const accessTokenObj = sxt.Authentication();
26 const validateResponse = await accessTokenObj.ValidateToken();
27 if (typeof validateResponse.error !== "undefined") {
28 return false;
29 }
30
31 const credentialsJson = storage.ReadCredentials(credentialsFilePath).data;
32 const authorization = sxt.Authorization();
33
34 const credentials =
35 authorization.GenerateKeyPairFromString(credentialsJson);
36
37 keypair = credentials;
38
39 return true;
40};
41
42/**
43 * Example

Callers 1

index.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected