nworks-plus 1.4.4 → 1.4.5
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/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -733,17 +733,24 @@ var logoutCommand = new Command2("logout").description("Remove stored credential
|
|
|
733
733
|
|
|
734
734
|
// src/commands/whoami.ts
|
|
735
735
|
import { Command as Command3 } from "commander";
|
|
736
|
+
function describeToken(token) {
|
|
737
|
+
const expiresAt = token?.expiresAt;
|
|
738
|
+
if (typeof expiresAt !== "number" || isNaN(expiresAt) || expiresAt <= 0) {
|
|
739
|
+
return { valid: false, expiresAt: "(no token)" };
|
|
740
|
+
}
|
|
741
|
+
return {
|
|
742
|
+
valid: expiresAt > Date.now() / 1e3,
|
|
743
|
+
expiresAt: new Date(expiresAt * 1e3).toISOString()
|
|
744
|
+
};
|
|
745
|
+
}
|
|
736
746
|
var whoamiCommand = new Command3("whoami").description("Show current authentication status").option("--profile <name>", "Profile name", "default").option("--json", "JSON output").action(async (opts) => {
|
|
737
747
|
try {
|
|
738
748
|
const profile = opts.profile;
|
|
739
749
|
const creds = await loadCredentials(profile);
|
|
740
750
|
const token = await loadToken(profile);
|
|
741
|
-
const
|
|
742
|
-
const
|
|
743
|
-
|
|
744
|
-
if (typeof expiresAt === "number" && !isNaN(expiresAt) && expiresAt > 0) {
|
|
745
|
-
tokenExpiresAt = new Date(expiresAt * 1e3).toISOString();
|
|
746
|
-
}
|
|
751
|
+
const userToken = await loadUserToken(profile);
|
|
752
|
+
const service = describeToken(token);
|
|
753
|
+
const user = describeToken(userToken);
|
|
747
754
|
output(
|
|
748
755
|
{
|
|
749
756
|
profile,
|
|
@@ -751,8 +758,11 @@ var whoamiCommand = new Command3("whoami").description("Show current authenticat
|
|
|
751
758
|
clientId: creds.clientId,
|
|
752
759
|
botId: creds.botId ?? "(not set)",
|
|
753
760
|
domainId: creds.domainId ?? "(not set)",
|
|
754
|
-
tokenValid:
|
|
755
|
-
tokenExpiresAt
|
|
761
|
+
tokenValid: service.valid,
|
|
762
|
+
tokenExpiresAt: service.expiresAt,
|
|
763
|
+
userOAuthValid: user.valid,
|
|
764
|
+
userOAuthExpiresAt: user.expiresAt,
|
|
765
|
+
userOAuthScope: userToken?.scope ?? "(not set)"
|
|
756
766
|
},
|
|
757
767
|
opts
|
|
758
768
|
);
|