@wumx-labs/noxaeapi-sdk 0.4.2 → 0.5.1
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/README.md +12 -1
- package/dist/index.cjs +212 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +215 -33
- package/dist/index.d.ts +215 -33
- package/dist/index.js +212 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,10 +31,21 @@ const coins = await client.economy.getCurrencyBalance("coins", players[0].uuid);
|
|
|
31
31
|
const top = await client.leaderboards.getTop("mcmmo-power", 10);
|
|
32
32
|
const network = await client.network.statusAll();
|
|
33
33
|
|
|
34
|
-
//
|
|
34
|
+
// Cross-server network identity (deterministic identityUuid + local server status):
|
|
35
|
+
const identity = await client.identity.get("NoxlyDev");
|
|
36
|
+
|
|
37
|
+
// Resolve a name to a local UUID, then get their one-call profile (identity,
|
|
35
38
|
// ban/whitelist status, Vault balance, and every leaderboard entry at once):
|
|
36
39
|
const { uuid } = await client.players.resolve("NoxlyDev");
|
|
37
40
|
const profile = await client.leaderboards.getPlayerProfile(uuid);
|
|
41
|
+
|
|
42
|
+
// LuckPerms (requires the plugin to be loaded on the target server):
|
|
43
|
+
await client.luckperms.setPlayerGroup(uuid, "vip");
|
|
44
|
+
await client.luckperms.addPlayerPermission(uuid, "essentials.fly", { expiry: "2026-12-31T00:00:00Z" });
|
|
45
|
+
const { has } = await client.luckperms.checkPlayerPermission(uuid, "essentials.fly");
|
|
46
|
+
await client.luckperms.promotePlayer(uuid, "default"); // moves them up the "default" track
|
|
47
|
+
const group = await client.luckperms.getGroupInfo("vip");
|
|
48
|
+
await client.luckperms.setGroupPrefix("vip", "&b[VIP] ");
|
|
38
49
|
```
|
|
39
50
|
|
|
40
51
|
### From environment variables
|
package/dist/index.cjs
CHANGED
|
@@ -652,26 +652,44 @@ var LuckPermsModule = class {
|
|
|
652
652
|
this.http = http;
|
|
653
653
|
}
|
|
654
654
|
http;
|
|
655
|
-
|
|
655
|
+
// ---------------------------------------------------------------
|
|
656
|
+
// Player permissions & groups
|
|
657
|
+
// ---------------------------------------------------------------
|
|
658
|
+
/** Get the names of every group a player belongs to (via inheritance nodes). */
|
|
656
659
|
getPlayerGroups(uuid) {
|
|
657
660
|
return this.http.request("GET", `luckperms/player/${encodeURIComponent(uuid)}/groups`);
|
|
658
661
|
}
|
|
659
|
-
/** Get
|
|
662
|
+
/** Get every node (permissions, inheritance, prefix/suffix, meta, ...) held directly by a player. */
|
|
660
663
|
getPlayerPermissions(uuid) {
|
|
661
664
|
return this.http.request(
|
|
662
665
|
"GET",
|
|
663
666
|
`luckperms/player/${encodeURIComponent(uuid)}/permissions`
|
|
664
667
|
);
|
|
665
668
|
}
|
|
666
|
-
/** Add a permission node to a player. */
|
|
667
|
-
addPlayerPermission(uuid, permission,
|
|
669
|
+
/** Add a permission node to a player. Defaults to a permanent, global, `true`-valued node. */
|
|
670
|
+
addPlayerPermission(uuid, permission, options = {}) {
|
|
668
671
|
return this.http.request(
|
|
669
672
|
"POST",
|
|
670
673
|
`luckperms/player/${encodeURIComponent(uuid)}/permission`,
|
|
671
|
-
{ body: { permission,
|
|
674
|
+
{ body: { permission, ...options } }
|
|
672
675
|
);
|
|
673
676
|
}
|
|
674
|
-
/**
|
|
677
|
+
/**
|
|
678
|
+
* Remove a permission node from a player by key. Note this matches on
|
|
679
|
+
* the permission string only — it does not target a specific
|
|
680
|
+
* value/expiry/context combination.
|
|
681
|
+
*/
|
|
682
|
+
removePlayerPermission(uuid, permission) {
|
|
683
|
+
return this.http.request(
|
|
684
|
+
"DELETE",
|
|
685
|
+
`luckperms/player/${encodeURIComponent(uuid)}/permission`,
|
|
686
|
+
{ body: { permission } }
|
|
687
|
+
);
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* Check whether a player has a given permission, using LuckPerms'
|
|
691
|
+
* native resolution (inheritance, wildcards, contexts all apply).
|
|
692
|
+
*/
|
|
675
693
|
checkPlayerPermission(uuid, permission) {
|
|
676
694
|
return this.http.request(
|
|
677
695
|
"POST",
|
|
@@ -679,30 +697,105 @@ var LuckPermsModule = class {
|
|
|
679
697
|
{ body: { permission } }
|
|
680
698
|
);
|
|
681
699
|
}
|
|
682
|
-
/**
|
|
683
|
-
|
|
700
|
+
/** Get a player's primary group name. */
|
|
701
|
+
getPlayerPrimaryGroup(uuid) {
|
|
684
702
|
return this.http.request(
|
|
685
|
-
"
|
|
686
|
-
`luckperms/player/${encodeURIComponent(uuid)}/
|
|
687
|
-
{ body: { permission } }
|
|
703
|
+
"GET",
|
|
704
|
+
`luckperms/player/${encodeURIComponent(uuid)}/primary-group`
|
|
688
705
|
);
|
|
689
706
|
}
|
|
690
|
-
/**
|
|
691
|
-
|
|
707
|
+
/**
|
|
708
|
+
* Set a player's primary group. This both adds the corresponding
|
|
709
|
+
* inheritance node (so permissions actually resolve from the group) and
|
|
710
|
+
* updates the primary-group label — mirrors `/lp user <target> parent
|
|
711
|
+
* add <group>` plus `/lp user <target> setprimarygroup <group>`.
|
|
712
|
+
*/
|
|
713
|
+
setPlayerGroup(uuid, group, options = {}) {
|
|
692
714
|
return this.http.request(
|
|
693
715
|
"POST",
|
|
694
716
|
`luckperms/player/${encodeURIComponent(uuid)}/group`,
|
|
695
|
-
{ body: { group } }
|
|
717
|
+
{ body: { group, ...options } }
|
|
696
718
|
);
|
|
697
719
|
}
|
|
698
|
-
/**
|
|
720
|
+
/**
|
|
721
|
+
* Remove a group's inheritance node from a player. Does **not** change
|
|
722
|
+
* their primary group — call `setPlayerGroup()` with the new group
|
|
723
|
+
* afterward if you're reassigning rank rather than just removing one
|
|
724
|
+
* of several parents.
|
|
725
|
+
*/
|
|
699
726
|
removePlayerGroup(uuid, groupName) {
|
|
700
727
|
return this.http.request(
|
|
701
728
|
"DELETE",
|
|
702
729
|
`luckperms/player/${encodeURIComponent(uuid)}/group/${encodeURIComponent(groupName)}`
|
|
703
730
|
);
|
|
704
731
|
}
|
|
705
|
-
/**
|
|
732
|
+
/**
|
|
733
|
+
* Promote a player one step up a track. If the result isn't successful
|
|
734
|
+
* (e.g. `END_OF_TRACK`, `AMBIGUOUS_CALL`), the player's data is left
|
|
735
|
+
* untouched — check `.success`/`.status` on the result rather than
|
|
736
|
+
* assuming the call always moves them.
|
|
737
|
+
*/
|
|
738
|
+
promotePlayer(uuid, track, options = {}) {
|
|
739
|
+
return this.http.request(
|
|
740
|
+
"POST",
|
|
741
|
+
`luckperms/player/${encodeURIComponent(uuid)}/promote`,
|
|
742
|
+
{ body: { track, ...options } }
|
|
743
|
+
);
|
|
744
|
+
}
|
|
745
|
+
/** Demote a player one step down a track. See `promotePlayer()` for the result semantics. */
|
|
746
|
+
demotePlayer(uuid, track, options = {}) {
|
|
747
|
+
return this.http.request(
|
|
748
|
+
"POST",
|
|
749
|
+
`luckperms/player/${encodeURIComponent(uuid)}/demote`,
|
|
750
|
+
{ body: { track, ...options } }
|
|
751
|
+
);
|
|
752
|
+
}
|
|
753
|
+
// ---------------------------------------------------------------
|
|
754
|
+
// Player meta (prefix / suffix / custom meta)
|
|
755
|
+
// ---------------------------------------------------------------
|
|
756
|
+
/** Get a player's resolved prefix, suffix, and custom meta key-values. */
|
|
757
|
+
getPlayerMeta(uuid) {
|
|
758
|
+
return this.http.request("GET", `luckperms/player/${encodeURIComponent(uuid)}/meta`);
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Set a player's prefix. Behaves like a "set", not an "add" — any
|
|
762
|
+
* existing prefix node (in any context) is cleared first, so a player
|
|
763
|
+
* only ever has one active prefix from this call.
|
|
764
|
+
*/
|
|
765
|
+
setPlayerPrefix(uuid, prefix, options = {}) {
|
|
766
|
+
return this.http.request(
|
|
767
|
+
"POST",
|
|
768
|
+
`luckperms/player/${encodeURIComponent(uuid)}/meta/prefix`,
|
|
769
|
+
{ body: { prefix, ...options } }
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
/** Set a player's suffix. Same "set, not add" semantics as `setPlayerPrefix()`. */
|
|
773
|
+
setPlayerSuffix(uuid, suffix, options = {}) {
|
|
774
|
+
return this.http.request(
|
|
775
|
+
"POST",
|
|
776
|
+
`luckperms/player/${encodeURIComponent(uuid)}/meta/suffix`,
|
|
777
|
+
{ body: { suffix, ...options } }
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
/** Set a custom meta key-value pair on a player, replacing any existing value(s) for that key. */
|
|
781
|
+
setPlayerMeta(uuid, key, value, options = {}) {
|
|
782
|
+
return this.http.request(
|
|
783
|
+
"POST",
|
|
784
|
+
`luckperms/player/${encodeURIComponent(uuid)}/meta`,
|
|
785
|
+
{ body: { key, value, ...options } }
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
/** Remove a custom meta key from a player (all values/contexts for that key). */
|
|
789
|
+
removePlayerMeta(uuid, key) {
|
|
790
|
+
return this.http.request(
|
|
791
|
+
"DELETE",
|
|
792
|
+
`luckperms/player/${encodeURIComponent(uuid)}/meta/${encodeURIComponent(key)}`
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
// ---------------------------------------------------------------
|
|
796
|
+
// Groups
|
|
797
|
+
// ---------------------------------------------------------------
|
|
798
|
+
/** List the names of every group registered in LuckPerms. */
|
|
706
799
|
getGroups() {
|
|
707
800
|
return this.http.request("GET", "luckperms/groups");
|
|
708
801
|
}
|
|
@@ -721,10 +814,90 @@ var LuckPermsModule = class {
|
|
|
721
814
|
deleteGroup(name) {
|
|
722
815
|
return this.http.request("DELETE", `luckperms/group/${encodeURIComponent(name)}`);
|
|
723
816
|
}
|
|
724
|
-
/** Get
|
|
817
|
+
/** Get every node held directly by a group. */
|
|
725
818
|
getGroupPermissions(name) {
|
|
726
819
|
return this.http.request("GET", `luckperms/group/${encodeURIComponent(name)}/permissions`);
|
|
727
820
|
}
|
|
821
|
+
/** Add a permission node to a group. Same options/defaults as `addPlayerPermission()`. */
|
|
822
|
+
addGroupPermission(name, permission, options = {}) {
|
|
823
|
+
return this.http.request(
|
|
824
|
+
"POST",
|
|
825
|
+
`luckperms/group/${encodeURIComponent(name)}/permission`,
|
|
826
|
+
{ body: { permission, ...options } }
|
|
827
|
+
);
|
|
828
|
+
}
|
|
829
|
+
/** Remove a permission node from a group by key (matches on permission string only). */
|
|
830
|
+
removeGroupPermission(name, permission) {
|
|
831
|
+
return this.http.request(
|
|
832
|
+
"DELETE",
|
|
833
|
+
`luckperms/group/${encodeURIComponent(name)}/permission`,
|
|
834
|
+
{ body: { permission } }
|
|
835
|
+
);
|
|
836
|
+
}
|
|
837
|
+
/** Get full info for a group: name, display name, weight, and all its nodes. */
|
|
838
|
+
getGroupInfo(name) {
|
|
839
|
+
return this.http.request("GET", `luckperms/group/${encodeURIComponent(name)}`);
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* Update a group's weight and/or display name. Provide at least one of
|
|
843
|
+
* the two fields — the server 400s otherwise. Passing an empty/blank
|
|
844
|
+
* `displayName` resets it to the default rather than setting a blank one.
|
|
845
|
+
* Returns the group's full updated info.
|
|
846
|
+
*/
|
|
847
|
+
updateGroup(name, updates) {
|
|
848
|
+
return this.http.request("PUT", `luckperms/group/${encodeURIComponent(name)}`, {
|
|
849
|
+
body: updates
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
// ---------------------------------------------------------------
|
|
853
|
+
// Group meta (prefix / suffix / custom meta)
|
|
854
|
+
// ---------------------------------------------------------------
|
|
855
|
+
/** Get a group's resolved prefix, suffix, and custom meta key-values. */
|
|
856
|
+
getGroupMeta(name) {
|
|
857
|
+
return this.http.request("GET", `luckperms/group/${encodeURIComponent(name)}/meta`);
|
|
858
|
+
}
|
|
859
|
+
/** Set a group's prefix. Same "set, not add" semantics as `setPlayerPrefix()`. */
|
|
860
|
+
setGroupPrefix(name, prefix, options = {}) {
|
|
861
|
+
return this.http.request(
|
|
862
|
+
"POST",
|
|
863
|
+
`luckperms/group/${encodeURIComponent(name)}/meta/prefix`,
|
|
864
|
+
{ body: { prefix, ...options } }
|
|
865
|
+
);
|
|
866
|
+
}
|
|
867
|
+
/** Set a group's suffix. Same "set, not add" semantics as `setPlayerPrefix()`. */
|
|
868
|
+
setGroupSuffix(name, suffix, options = {}) {
|
|
869
|
+
return this.http.request(
|
|
870
|
+
"POST",
|
|
871
|
+
`luckperms/group/${encodeURIComponent(name)}/meta/suffix`,
|
|
872
|
+
{ body: { suffix, ...options } }
|
|
873
|
+
);
|
|
874
|
+
}
|
|
875
|
+
/** Set a custom meta key-value pair on a group, replacing any existing value(s) for that key. */
|
|
876
|
+
setGroupMeta(name, key, value, options = {}) {
|
|
877
|
+
return this.http.request(
|
|
878
|
+
"POST",
|
|
879
|
+
`luckperms/group/${encodeURIComponent(name)}/meta`,
|
|
880
|
+
{ body: { key, value, ...options } }
|
|
881
|
+
);
|
|
882
|
+
}
|
|
883
|
+
/** Remove a custom meta key from a group (all values/contexts for that key). */
|
|
884
|
+
removeGroupMeta(name, key) {
|
|
885
|
+
return this.http.request(
|
|
886
|
+
"DELETE",
|
|
887
|
+
`luckperms/group/${encodeURIComponent(name)}/meta/${encodeURIComponent(key)}`
|
|
888
|
+
);
|
|
889
|
+
}
|
|
890
|
+
// ---------------------------------------------------------------
|
|
891
|
+
// Tracks (rank ladders — promote/demote)
|
|
892
|
+
// ---------------------------------------------------------------
|
|
893
|
+
/** List the names of every track registered in LuckPerms. */
|
|
894
|
+
getTracks() {
|
|
895
|
+
return this.http.request("GET", "luckperms/tracks");
|
|
896
|
+
}
|
|
897
|
+
/** Get a track's name and its ordered list of groups (lowest to highest rank). */
|
|
898
|
+
getTrack(name) {
|
|
899
|
+
return this.http.request("GET", `luckperms/track/${encodeURIComponent(name)}`);
|
|
900
|
+
}
|
|
728
901
|
};
|
|
729
902
|
|
|
730
903
|
// src/modules/noxauth.ts
|
|
@@ -747,6 +920,25 @@ var NoxAuthModule = class {
|
|
|
747
920
|
}
|
|
748
921
|
};
|
|
749
922
|
|
|
923
|
+
// src/modules/identity.ts
|
|
924
|
+
var IdentityModule = class {
|
|
925
|
+
constructor(http) {
|
|
926
|
+
this.http = http;
|
|
927
|
+
}
|
|
928
|
+
http;
|
|
929
|
+
/**
|
|
930
|
+
* Resolves a player's network-wide identity and local UUID status.
|
|
931
|
+
*
|
|
932
|
+
* Unlike players.resolve(name), this does NOT throw 404 if the player
|
|
933
|
+
* has never joined this server. Instead, identityUuid is always computed
|
|
934
|
+
* deterministically from the username, and hasPlayedBefore will be false
|
|
935
|
+
* with localUuid: null.
|
|
936
|
+
*/
|
|
937
|
+
get(name) {
|
|
938
|
+
return this.http.request("GET", `identity/${encodeURIComponent(name)}`);
|
|
939
|
+
}
|
|
940
|
+
};
|
|
941
|
+
|
|
750
942
|
// src/modules/skills.ts
|
|
751
943
|
var SkillsModule = class {
|
|
752
944
|
constructor(http) {
|
|
@@ -1023,6 +1215,7 @@ function safeParse(text) {
|
|
|
1023
1215
|
// src/client.ts
|
|
1024
1216
|
var NoxAeApiClient = class _NoxAeApiClient {
|
|
1025
1217
|
players;
|
|
1218
|
+
identity;
|
|
1026
1219
|
economy;
|
|
1027
1220
|
server;
|
|
1028
1221
|
worlds;
|
|
@@ -1057,6 +1250,7 @@ var NoxAeApiClient = class _NoxAeApiClient {
|
|
|
1057
1250
|
this.baseUrl = options.baseUrl;
|
|
1058
1251
|
this.apiKey = options.apiKey;
|
|
1059
1252
|
this.players = new PlayersModule(this.http);
|
|
1253
|
+
this.identity = new IdentityModule(this.http);
|
|
1060
1254
|
this.economy = new EconomyModule(this.http);
|
|
1061
1255
|
this.server = new ServerModule(this.http);
|
|
1062
1256
|
this.worlds = new WorldsModule(this.http);
|
|
@@ -1126,6 +1320,7 @@ var NoxAeApiNetworkHubClient = class _NoxAeApiNetworkHubClient {
|
|
|
1126
1320
|
}
|
|
1127
1321
|
};
|
|
1128
1322
|
|
|
1323
|
+
exports.IdentityModule = IdentityModule;
|
|
1129
1324
|
exports.NoxAeApiClient = NoxAeApiClient;
|
|
1130
1325
|
exports.NoxAeApiError = NoxAeApiError;
|
|
1131
1326
|
exports.NoxAeApiForbiddenError = NoxAeApiForbiddenError;
|