| 14 | * Check existing session |
| 15 | */ |
| 16 | const 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 |