@opys/authliberty 0.1.2
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.cjs +149 -0
- package/dist/index.d.cts +117 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +117 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +147 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +36 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _opys_dev = require("@opys/dev");
|
|
3
|
+
let _opys_core = require("@opys/core");
|
|
4
|
+
|
|
5
|
+
//#region lib/resolver.ts
|
|
6
|
+
/**
|
|
7
|
+
* Resolver for AuthLiberty releases on a GitLab generic package registry.
|
|
8
|
+
*
|
|
9
|
+
* AuthLiberty's CI publishes the agent jar to two channels:
|
|
10
|
+
* - `latest` — auto-updated from `main`, filename `authliberty-latest.jar`
|
|
11
|
+
* - `<version>` — tagged releases, filename `authliberty-<version>.jar`
|
|
12
|
+
*
|
|
13
|
+
* Both ship as a single `.jar` in a generic package named `authliberty`.
|
|
14
|
+
* GitLab exposes the file's sha256 via the `package_files` API, which we
|
|
15
|
+
* use for integrity verification. The `latest` channel's sha256 changes
|
|
16
|
+
* whenever a new build replaces it — that's resolved at template-build
|
|
17
|
+
* time and frozen into the opys manifest.
|
|
18
|
+
*
|
|
19
|
+
* Accepted version forms:
|
|
20
|
+
* - Exact version: `'0.3'`
|
|
21
|
+
* - `'latest'` — the auto-updating `latest` package version
|
|
22
|
+
*/
|
|
23
|
+
const DEFAULT_PROJECT = "harmoniya/authliberty";
|
|
24
|
+
const DEFAULT_GITLAB = "https://gitlab.com";
|
|
25
|
+
const PACKAGE_NAME = "authliberty";
|
|
26
|
+
function authHeaders(token) {
|
|
27
|
+
return token ? { "PRIVATE-TOKEN": token } : {};
|
|
28
|
+
}
|
|
29
|
+
async function fetchPackages(base, projectPath, token) {
|
|
30
|
+
const res = await (0, _opys_core.fetchWithRetry)(`${base}/api/v4/projects/${encodeURIComponent(projectPath)}/packages?package_type=generic&package_name=${PACKAGE_NAME}&per_page=100`, { headers: authHeaders(token) });
|
|
31
|
+
if (!res.ok) throw new Error(`GitLab API ${res.status} ${res.statusText} listing packages for ${projectPath}`);
|
|
32
|
+
return (await res.json()).filter((p) => p.name === PACKAGE_NAME && p.package_type === "generic" && p.status === "default");
|
|
33
|
+
}
|
|
34
|
+
async function fetchPackageFiles(base, projectPath, packageId, token) {
|
|
35
|
+
const res = await (0, _opys_core.fetchWithRetry)(`${base}/api/v4/projects/${encodeURIComponent(projectPath)}/packages/${packageId}/package_files?per_page=100`, { headers: authHeaders(token) });
|
|
36
|
+
if (!res.ok) throw new Error(`GitLab API ${res.status} ${res.statusText} listing files for package ${packageId}`);
|
|
37
|
+
return await res.json();
|
|
38
|
+
}
|
|
39
|
+
/** Pick the .jar file. If multiple, prefer the most recently created one. */
|
|
40
|
+
function findJar(files) {
|
|
41
|
+
const jars = files.filter((f) => f.file_name.endsWith(".jar"));
|
|
42
|
+
if (jars.length === 0) return null;
|
|
43
|
+
return jars.reduce((latest, f) => f.created_at > latest.created_at ? f : latest);
|
|
44
|
+
}
|
|
45
|
+
async function resolveAuthLibertyVersion(input, options = {}) {
|
|
46
|
+
const project = options.project ?? DEFAULT_PROJECT;
|
|
47
|
+
const base = (options.gitlab ?? DEFAULT_GITLAB).replace(/\/+$/, "");
|
|
48
|
+
const packages = await fetchPackages(base, project, options.token);
|
|
49
|
+
const candidates = packages.filter((p) => p.version === input);
|
|
50
|
+
if (candidates.length === 0) {
|
|
51
|
+
const available = [...new Set(packages.map((p) => p.version))].slice(0, 8).join(", ");
|
|
52
|
+
throw new Error(`AuthLiberty version '${input}' not found in ${project}. Available: ${available || "(none)"}`);
|
|
53
|
+
}
|
|
54
|
+
const pkg = candidates.reduce((latest, p) => p.created_at > latest.created_at ? p : latest);
|
|
55
|
+
const jar = findJar(await fetchPackageFiles(base, project, pkg.id, options.token));
|
|
56
|
+
if (!jar) throw new Error(`AuthLiberty package ${project}@${pkg.version} has no .jar file`);
|
|
57
|
+
const downloadUrl = `${base}/api/v4/projects/${encodeURIComponent(project)}/packages/generic/${PACKAGE_NAME}/${encodeURIComponent(pkg.version)}/${encodeURIComponent(jar.file_name)}`;
|
|
58
|
+
return {
|
|
59
|
+
version: pkg.version,
|
|
60
|
+
filename: jar.file_name,
|
|
61
|
+
url: downloadUrl,
|
|
62
|
+
size: jar.size,
|
|
63
|
+
sha256: jar.file_sha256 ?? void 0,
|
|
64
|
+
createdAt: pkg.created_at
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region lib/template.ts
|
|
70
|
+
const HOST_PROPS = {
|
|
71
|
+
auth: "minecraft.api.auth.host",
|
|
72
|
+
account: "minecraft.api.account.host",
|
|
73
|
+
session: "minecraft.api.session.host",
|
|
74
|
+
services: "minecraft.api.services.host"
|
|
75
|
+
};
|
|
76
|
+
const SERVERS = Object.keys(HOST_PROPS);
|
|
77
|
+
function resolveHost(hosts, server) {
|
|
78
|
+
if (!hosts) return void 0;
|
|
79
|
+
const raw = typeof hosts === "function" ? hosts(server) : hosts[server];
|
|
80
|
+
return raw ? raw : void 0;
|
|
81
|
+
}
|
|
82
|
+
function val(value) {
|
|
83
|
+
return {
|
|
84
|
+
rules: [],
|
|
85
|
+
value: [value]
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Build a opys template fragment that loads AuthLiberty as a `-javaagent`
|
|
90
|
+
* and points Mojang's auth/account/session/services hosts at the configured
|
|
91
|
+
* replacements.
|
|
92
|
+
*
|
|
93
|
+
* The agent jar lands at `${library_directory}/net/harmoniya/authliberty/<v>/authliberty-<v>.jar`
|
|
94
|
+
* (a maven-ish path mirroring how Forge/Cleanroom organize bootstrap jars).
|
|
95
|
+
* The `jvmArgs` Valset is meant to be spread into a loader template's
|
|
96
|
+
* `command.args` — AuthLiberty has no main class, no classpath needs, and
|
|
97
|
+
* doesn't interact with any loader's bootstrap, so it composes cleanly with
|
|
98
|
+
* any of `@opys/{minecraft,forge,cleanroom,lwjgl3ify}`.
|
|
99
|
+
*/
|
|
100
|
+
async function resolveAuthliberty(options) {
|
|
101
|
+
const release = await resolveAuthLibertyVersion(options.version, {
|
|
102
|
+
project: options.project,
|
|
103
|
+
gitlab: options.gitlab,
|
|
104
|
+
token: options.token
|
|
105
|
+
});
|
|
106
|
+
const path = `\${library_directory}/net/harmoniya/authliberty/${release.version}/${release.filename}`;
|
|
107
|
+
const artifact = {
|
|
108
|
+
path,
|
|
109
|
+
source: (0, _opys_core.sourceUrl)(release.url),
|
|
110
|
+
size: release.size,
|
|
111
|
+
rules: [],
|
|
112
|
+
...release.sha256 ? { integrity: { sha256: release.sha256 } } : {}
|
|
113
|
+
};
|
|
114
|
+
const args = [val(`-javaagent:${path}`)];
|
|
115
|
+
for (const server of SERVERS) {
|
|
116
|
+
const url = resolveHost(options.hosts, server);
|
|
117
|
+
if (url) args.push(val(`-D${HOST_PROPS[server]}=${url}`));
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
artifacts: [artifact],
|
|
121
|
+
jvmArgs: args,
|
|
122
|
+
release
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//#endregion
|
|
127
|
+
//#region lib/plugin.ts
|
|
128
|
+
/** AuthLiberty — an authlib-injector `-javaagent` auth redirector. */
|
|
129
|
+
function authliberty(version, opts = {}) {
|
|
130
|
+
return (0, _opys_dev.definePlugin)({
|
|
131
|
+
name: "authliberty",
|
|
132
|
+
async build(ctx) {
|
|
133
|
+
const t = await resolveAuthliberty({
|
|
134
|
+
version,
|
|
135
|
+
...opts
|
|
136
|
+
});
|
|
137
|
+
ctx.log("authliberty", `resolved ${version}`);
|
|
138
|
+
return {
|
|
139
|
+
artifacts: t.artifacts,
|
|
140
|
+
launch: { jvmArgs: t.jvmArgs }
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
//#endregion
|
|
147
|
+
exports.authliberty = authliberty;
|
|
148
|
+
exports.resolveAuthLibertyVersion = resolveAuthLibertyVersion;
|
|
149
|
+
exports.resolveAuthliberty = resolveAuthliberty;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { OpysPlugin } from "@opys/dev";
|
|
2
|
+
import { Artifact, Valset } from "@opys/core";
|
|
3
|
+
|
|
4
|
+
//#region lib/resolver.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolver for AuthLiberty releases on a GitLab generic package registry.
|
|
7
|
+
*
|
|
8
|
+
* AuthLiberty's CI publishes the agent jar to two channels:
|
|
9
|
+
* - `latest` — auto-updated from `main`, filename `authliberty-latest.jar`
|
|
10
|
+
* - `<version>` — tagged releases, filename `authliberty-<version>.jar`
|
|
11
|
+
*
|
|
12
|
+
* Both ship as a single `.jar` in a generic package named `authliberty`.
|
|
13
|
+
* GitLab exposes the file's sha256 via the `package_files` API, which we
|
|
14
|
+
* use for integrity verification. The `latest` channel's sha256 changes
|
|
15
|
+
* whenever a new build replaces it — that's resolved at template-build
|
|
16
|
+
* time and frozen into the opys manifest.
|
|
17
|
+
*
|
|
18
|
+
* Accepted version forms:
|
|
19
|
+
* - Exact version: `'0.3'`
|
|
20
|
+
* - `'latest'` — the auto-updating `latest` package version
|
|
21
|
+
*/
|
|
22
|
+
interface AuthLibertyRelease {
|
|
23
|
+
/** Package version, e.g. `0.3` or `latest`. */
|
|
24
|
+
readonly version: string;
|
|
25
|
+
/** Asset filename, e.g. `authliberty-0.3.jar`. */
|
|
26
|
+
readonly filename: string;
|
|
27
|
+
/** Direct download URL for the agent jar. */
|
|
28
|
+
readonly url: string;
|
|
29
|
+
/** Asset size in bytes. */
|
|
30
|
+
readonly size: number;
|
|
31
|
+
/** sha256 of the asset (hex), as reported by GitLab. */
|
|
32
|
+
readonly sha256?: string;
|
|
33
|
+
/** ISO timestamp the package was created. */
|
|
34
|
+
readonly createdAt: string;
|
|
35
|
+
}
|
|
36
|
+
interface ResolveAuthLibertyOptions {
|
|
37
|
+
/** GitLab project path `group/name`. Default: `harmoniya/authliberty`. */
|
|
38
|
+
project?: string;
|
|
39
|
+
/** GitLab instance URL. Default: `https://gitlab.com`. */
|
|
40
|
+
gitlab?: string;
|
|
41
|
+
/** Optional GitLab token for private projects / higher rate limits. */
|
|
42
|
+
token?: string;
|
|
43
|
+
}
|
|
44
|
+
declare function resolveAuthLibertyVersion(input: string, options?: ResolveAuthLibertyOptions): Promise<AuthLibertyRelease>;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region lib/template.d.ts
|
|
47
|
+
/** Mojang server kind AuthLiberty's bytecode transformer can retarget. */
|
|
48
|
+
type AuthLibertyServer = 'auth' | 'account' | 'session' | 'services';
|
|
49
|
+
/**
|
|
50
|
+
* Per-server host overrides. Either:
|
|
51
|
+
* - an object — only the keys you set become `-D` flags; unset ones fall
|
|
52
|
+
* back to the original Mojang host at runtime, OR
|
|
53
|
+
* - a function — called once per server kind. Return a URL to override,
|
|
54
|
+
* or `undefined` / empty string to leave that server on its Mojang
|
|
55
|
+
* default.
|
|
56
|
+
*/
|
|
57
|
+
type AuthLibertyHosts = AuthLibertyHostMap | ((server: AuthLibertyServer) => string | undefined);
|
|
58
|
+
interface AuthLibertyHostMap {
|
|
59
|
+
/** `-Dminecraft.api.auth.host` — Yggdrasil auth server (default `https://authserver.mojang.com`). */
|
|
60
|
+
auth?: string;
|
|
61
|
+
/** `-Dminecraft.api.account.host` — account services (default `https://account.mojang.com`). */
|
|
62
|
+
account?: string;
|
|
63
|
+
/** `-Dminecraft.api.session.host` — session/profile server (default `https://sessionserver.mojang.com`). */
|
|
64
|
+
session?: string;
|
|
65
|
+
/** `-Dminecraft.api.services.host` — Minecraft Services API (default `https://api.minecraftservices.com`). */
|
|
66
|
+
services?: string;
|
|
67
|
+
}
|
|
68
|
+
interface AuthLibertyOptions {
|
|
69
|
+
/**
|
|
70
|
+
* AuthLiberty version. Accepts:
|
|
71
|
+
* - Exact version: `'0.3'`
|
|
72
|
+
* - `'latest'` — auto-updating `main` build (sha256 frozen at template-build time)
|
|
73
|
+
*/
|
|
74
|
+
version: string;
|
|
75
|
+
/** GitLab project path. Default: `harmoniya/authliberty`. */
|
|
76
|
+
project?: string;
|
|
77
|
+
/** GitLab instance URL. Default: `https://gitlab.com`. */
|
|
78
|
+
gitlab?: string;
|
|
79
|
+
/** Optional GitLab token for private projects / higher rate limits. */
|
|
80
|
+
token?: string;
|
|
81
|
+
/** Replacement host overrides. Each maps to a `-Dminecraft.api.*.host` system property. */
|
|
82
|
+
hosts?: AuthLibertyHosts;
|
|
83
|
+
}
|
|
84
|
+
interface AuthLibertyTemplate {
|
|
85
|
+
/** The agent jar artifact. */
|
|
86
|
+
artifacts: Artifact[];
|
|
87
|
+
/**
|
|
88
|
+
* JVM args to add to the launch command — `-javaagent:<path>` plus a
|
|
89
|
+
* `-D` for each configured host. Spread these into your loader
|
|
90
|
+
* template's `command.args` (typically *before* the loader's own
|
|
91
|
+
* `-javaagent:` and main-class args, so the redirector is in place
|
|
92
|
+
* before any auth code runs).
|
|
93
|
+
*/
|
|
94
|
+
jvmArgs: Valset;
|
|
95
|
+
/** Resolved release metadata, useful for logging / pinning. */
|
|
96
|
+
release: AuthLibertyRelease;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Build a opys template fragment that loads AuthLiberty as a `-javaagent`
|
|
100
|
+
* and points Mojang's auth/account/session/services hosts at the configured
|
|
101
|
+
* replacements.
|
|
102
|
+
*
|
|
103
|
+
* The agent jar lands at `${library_directory}/net/harmoniya/authliberty/<v>/authliberty-<v>.jar`
|
|
104
|
+
* (a maven-ish path mirroring how Forge/Cleanroom organize bootstrap jars).
|
|
105
|
+
* The `jvmArgs` Valset is meant to be spread into a loader template's
|
|
106
|
+
* `command.args` — AuthLiberty has no main class, no classpath needs, and
|
|
107
|
+
* doesn't interact with any loader's bootstrap, so it composes cleanly with
|
|
108
|
+
* any of `@opys/{minecraft,forge,cleanroom,lwjgl3ify}`.
|
|
109
|
+
*/
|
|
110
|
+
declare function resolveAuthliberty(options: AuthLibertyOptions): Promise<AuthLibertyTemplate>;
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region lib/plugin.d.ts
|
|
113
|
+
/** AuthLiberty — an authlib-injector `-javaagent` auth redirector. */
|
|
114
|
+
declare function authliberty(version: string, opts?: Omit<AuthLibertyOptions, 'version'>): OpysPlugin;
|
|
115
|
+
//#endregion
|
|
116
|
+
export { type AuthLibertyHostMap, type AuthLibertyHosts, type AuthLibertyOptions, type AuthLibertyRelease, type AuthLibertyServer, type AuthLibertyTemplate, type ResolveAuthLibertyOptions, authliberty, resolveAuthLibertyVersion, resolveAuthliberty };
|
|
117
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../lib/resolver.ts","../lib/template.ts","../lib/plugin.ts"],"mappings":";;;;;;;;AAwBA;;;;;;;;;;;;AAeA;UAfiB,kBAAA;;WAEN,OAAA;EAeT;EAAA,SAbS,QAAA;EAiBT;EAAA,SAfS,GAAA;EAeJ;EAAA,SAbI,IAAA;EAwFoC;EAAA,SAtFpC,MAAA;EAwFA;EAAA,SAtFA,SAAA;AAAA;AAAA,UAGM,yBAAA;EAoFP;EAlFR,OAAA;EAiFS;EA/ET,MAAA;EAgFC;EA9ED,KAAA;AAAA;AAAA,iBA2EoB,yBAAA,CACpB,KAAA,UACA,OAAA,GAAS,yBAAA,GACR,OAAA,CAAQ,kBAAA;;;;KClHC,iBAAA;;;;;;;;;KAUA,gBAAA,GACR,kBAAA,KACE,MAAA,EAAQ,iBAAA;AAAA,UAEG,kBAAA;EDaG;ECXlB,IAAA;EDcwC;ECZxC,OAAA;EDYwC;ECVxC,OAAA;EDcA;ECZA,QAAA;AAAA;AAAA,UAGe,kBAAA;EDsFK;;;;;EChFpB,OAAA;EDmFQ;ECjFR,OAAA;ED+EA;EC7EA,MAAA;ED8EA;EC5EA,KAAA;ED6ES;EC3ET,KAAA,GAAQ,gBAAA;AAAA;AAAA,UAGO,mBAAA;;EAEf,SAAA,EAAW,QAAA;EA5CD;;;;;AAUZ;;EA0CE,OAAA,EAAS,MAAA;EAxCoB;EA0C7B,OAAA,EAAS,kBAAA;AAAA;;;;AAxCX;;;;;;;;;iBA6EsB,kBAAA,CACpB,OAAA,EAAS,kBAAA,GACR,OAAA,CAAQ,mBAAA;;;;iBClGK,WAAA,CACd,OAAA,UACA,IAAA,GAAM,IAAA,CAAK,kBAAA,eACV,UAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { OpysPlugin } from "@opys/dev";
|
|
2
|
+
import { Artifact, Valset } from "@opys/core";
|
|
3
|
+
|
|
4
|
+
//#region lib/resolver.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolver for AuthLiberty releases on a GitLab generic package registry.
|
|
7
|
+
*
|
|
8
|
+
* AuthLiberty's CI publishes the agent jar to two channels:
|
|
9
|
+
* - `latest` — auto-updated from `main`, filename `authliberty-latest.jar`
|
|
10
|
+
* - `<version>` — tagged releases, filename `authliberty-<version>.jar`
|
|
11
|
+
*
|
|
12
|
+
* Both ship as a single `.jar` in a generic package named `authliberty`.
|
|
13
|
+
* GitLab exposes the file's sha256 via the `package_files` API, which we
|
|
14
|
+
* use for integrity verification. The `latest` channel's sha256 changes
|
|
15
|
+
* whenever a new build replaces it — that's resolved at template-build
|
|
16
|
+
* time and frozen into the opys manifest.
|
|
17
|
+
*
|
|
18
|
+
* Accepted version forms:
|
|
19
|
+
* - Exact version: `'0.3'`
|
|
20
|
+
* - `'latest'` — the auto-updating `latest` package version
|
|
21
|
+
*/
|
|
22
|
+
interface AuthLibertyRelease {
|
|
23
|
+
/** Package version, e.g. `0.3` or `latest`. */
|
|
24
|
+
readonly version: string;
|
|
25
|
+
/** Asset filename, e.g. `authliberty-0.3.jar`. */
|
|
26
|
+
readonly filename: string;
|
|
27
|
+
/** Direct download URL for the agent jar. */
|
|
28
|
+
readonly url: string;
|
|
29
|
+
/** Asset size in bytes. */
|
|
30
|
+
readonly size: number;
|
|
31
|
+
/** sha256 of the asset (hex), as reported by GitLab. */
|
|
32
|
+
readonly sha256?: string;
|
|
33
|
+
/** ISO timestamp the package was created. */
|
|
34
|
+
readonly createdAt: string;
|
|
35
|
+
}
|
|
36
|
+
interface ResolveAuthLibertyOptions {
|
|
37
|
+
/** GitLab project path `group/name`. Default: `harmoniya/authliberty`. */
|
|
38
|
+
project?: string;
|
|
39
|
+
/** GitLab instance URL. Default: `https://gitlab.com`. */
|
|
40
|
+
gitlab?: string;
|
|
41
|
+
/** Optional GitLab token for private projects / higher rate limits. */
|
|
42
|
+
token?: string;
|
|
43
|
+
}
|
|
44
|
+
declare function resolveAuthLibertyVersion(input: string, options?: ResolveAuthLibertyOptions): Promise<AuthLibertyRelease>;
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region lib/template.d.ts
|
|
47
|
+
/** Mojang server kind AuthLiberty's bytecode transformer can retarget. */
|
|
48
|
+
type AuthLibertyServer = 'auth' | 'account' | 'session' | 'services';
|
|
49
|
+
/**
|
|
50
|
+
* Per-server host overrides. Either:
|
|
51
|
+
* - an object — only the keys you set become `-D` flags; unset ones fall
|
|
52
|
+
* back to the original Mojang host at runtime, OR
|
|
53
|
+
* - a function — called once per server kind. Return a URL to override,
|
|
54
|
+
* or `undefined` / empty string to leave that server on its Mojang
|
|
55
|
+
* default.
|
|
56
|
+
*/
|
|
57
|
+
type AuthLibertyHosts = AuthLibertyHostMap | ((server: AuthLibertyServer) => string | undefined);
|
|
58
|
+
interface AuthLibertyHostMap {
|
|
59
|
+
/** `-Dminecraft.api.auth.host` — Yggdrasil auth server (default `https://authserver.mojang.com`). */
|
|
60
|
+
auth?: string;
|
|
61
|
+
/** `-Dminecraft.api.account.host` — account services (default `https://account.mojang.com`). */
|
|
62
|
+
account?: string;
|
|
63
|
+
/** `-Dminecraft.api.session.host` — session/profile server (default `https://sessionserver.mojang.com`). */
|
|
64
|
+
session?: string;
|
|
65
|
+
/** `-Dminecraft.api.services.host` — Minecraft Services API (default `https://api.minecraftservices.com`). */
|
|
66
|
+
services?: string;
|
|
67
|
+
}
|
|
68
|
+
interface AuthLibertyOptions {
|
|
69
|
+
/**
|
|
70
|
+
* AuthLiberty version. Accepts:
|
|
71
|
+
* - Exact version: `'0.3'`
|
|
72
|
+
* - `'latest'` — auto-updating `main` build (sha256 frozen at template-build time)
|
|
73
|
+
*/
|
|
74
|
+
version: string;
|
|
75
|
+
/** GitLab project path. Default: `harmoniya/authliberty`. */
|
|
76
|
+
project?: string;
|
|
77
|
+
/** GitLab instance URL. Default: `https://gitlab.com`. */
|
|
78
|
+
gitlab?: string;
|
|
79
|
+
/** Optional GitLab token for private projects / higher rate limits. */
|
|
80
|
+
token?: string;
|
|
81
|
+
/** Replacement host overrides. Each maps to a `-Dminecraft.api.*.host` system property. */
|
|
82
|
+
hosts?: AuthLibertyHosts;
|
|
83
|
+
}
|
|
84
|
+
interface AuthLibertyTemplate {
|
|
85
|
+
/** The agent jar artifact. */
|
|
86
|
+
artifacts: Artifact[];
|
|
87
|
+
/**
|
|
88
|
+
* JVM args to add to the launch command — `-javaagent:<path>` plus a
|
|
89
|
+
* `-D` for each configured host. Spread these into your loader
|
|
90
|
+
* template's `command.args` (typically *before* the loader's own
|
|
91
|
+
* `-javaagent:` and main-class args, so the redirector is in place
|
|
92
|
+
* before any auth code runs).
|
|
93
|
+
*/
|
|
94
|
+
jvmArgs: Valset;
|
|
95
|
+
/** Resolved release metadata, useful for logging / pinning. */
|
|
96
|
+
release: AuthLibertyRelease;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Build a opys template fragment that loads AuthLiberty as a `-javaagent`
|
|
100
|
+
* and points Mojang's auth/account/session/services hosts at the configured
|
|
101
|
+
* replacements.
|
|
102
|
+
*
|
|
103
|
+
* The agent jar lands at `${library_directory}/net/harmoniya/authliberty/<v>/authliberty-<v>.jar`
|
|
104
|
+
* (a maven-ish path mirroring how Forge/Cleanroom organize bootstrap jars).
|
|
105
|
+
* The `jvmArgs` Valset is meant to be spread into a loader template's
|
|
106
|
+
* `command.args` — AuthLiberty has no main class, no classpath needs, and
|
|
107
|
+
* doesn't interact with any loader's bootstrap, so it composes cleanly with
|
|
108
|
+
* any of `@opys/{minecraft,forge,cleanroom,lwjgl3ify}`.
|
|
109
|
+
*/
|
|
110
|
+
declare function resolveAuthliberty(options: AuthLibertyOptions): Promise<AuthLibertyTemplate>;
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region lib/plugin.d.ts
|
|
113
|
+
/** AuthLiberty — an authlib-injector `-javaagent` auth redirector. */
|
|
114
|
+
declare function authliberty(version: string, opts?: Omit<AuthLibertyOptions, 'version'>): OpysPlugin;
|
|
115
|
+
//#endregion
|
|
116
|
+
export { type AuthLibertyHostMap, type AuthLibertyHosts, type AuthLibertyOptions, type AuthLibertyRelease, type AuthLibertyServer, type AuthLibertyTemplate, type ResolveAuthLibertyOptions, authliberty, resolveAuthLibertyVersion, resolveAuthliberty };
|
|
117
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../lib/resolver.ts","../lib/template.ts","../lib/plugin.ts"],"mappings":";;;;;;;;AAwBA;;;;;;;;;;;;AAeA;UAfiB,kBAAA;;WAEN,OAAA;EAeT;EAAA,SAbS,QAAA;EAiBT;EAAA,SAfS,GAAA;EAeJ;EAAA,SAbI,IAAA;EAwFoC;EAAA,SAtFpC,MAAA;EAwFA;EAAA,SAtFA,SAAA;AAAA;AAAA,UAGM,yBAAA;EAoFP;EAlFR,OAAA;EAiFS;EA/ET,MAAA;EAgFC;EA9ED,KAAA;AAAA;AAAA,iBA2EoB,yBAAA,CACpB,KAAA,UACA,OAAA,GAAS,yBAAA,GACR,OAAA,CAAQ,kBAAA;;;;KClHC,iBAAA;;;;;;;;;KAUA,gBAAA,GACR,kBAAA,KACE,MAAA,EAAQ,iBAAA;AAAA,UAEG,kBAAA;EDaG;ECXlB,IAAA;EDcwC;ECZxC,OAAA;EDYwC;ECVxC,OAAA;EDcA;ECZA,QAAA;AAAA;AAAA,UAGe,kBAAA;EDsFK;;;;;EChFpB,OAAA;EDmFQ;ECjFR,OAAA;ED+EA;EC7EA,MAAA;ED8EA;EC5EA,KAAA;ED6ES;EC3ET,KAAA,GAAQ,gBAAA;AAAA;AAAA,UAGO,mBAAA;;EAEf,SAAA,EAAW,QAAA;EA5CD;;;;;AAUZ;;EA0CE,OAAA,EAAS,MAAA;EAxCoB;EA0C7B,OAAA,EAAS,kBAAA;AAAA;;;;AAxCX;;;;;;;;;iBA6EsB,kBAAA,CACpB,OAAA,EAAS,kBAAA,GACR,OAAA,CAAQ,mBAAA;;;;iBClGK,WAAA,CACd,OAAA,UACA,IAAA,GAAM,IAAA,CAAK,kBAAA,eACV,UAAA"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { definePlugin } from "@opys/dev";
|
|
2
|
+
import { fetchWithRetry, sourceUrl } from "@opys/core";
|
|
3
|
+
|
|
4
|
+
//#region lib/resolver.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolver for AuthLiberty releases on a GitLab generic package registry.
|
|
7
|
+
*
|
|
8
|
+
* AuthLiberty's CI publishes the agent jar to two channels:
|
|
9
|
+
* - `latest` — auto-updated from `main`, filename `authliberty-latest.jar`
|
|
10
|
+
* - `<version>` — tagged releases, filename `authliberty-<version>.jar`
|
|
11
|
+
*
|
|
12
|
+
* Both ship as a single `.jar` in a generic package named `authliberty`.
|
|
13
|
+
* GitLab exposes the file's sha256 via the `package_files` API, which we
|
|
14
|
+
* use for integrity verification. The `latest` channel's sha256 changes
|
|
15
|
+
* whenever a new build replaces it — that's resolved at template-build
|
|
16
|
+
* time and frozen into the opys manifest.
|
|
17
|
+
*
|
|
18
|
+
* Accepted version forms:
|
|
19
|
+
* - Exact version: `'0.3'`
|
|
20
|
+
* - `'latest'` — the auto-updating `latest` package version
|
|
21
|
+
*/
|
|
22
|
+
const DEFAULT_PROJECT = "harmoniya/authliberty";
|
|
23
|
+
const DEFAULT_GITLAB = "https://gitlab.com";
|
|
24
|
+
const PACKAGE_NAME = "authliberty";
|
|
25
|
+
function authHeaders(token) {
|
|
26
|
+
return token ? { "PRIVATE-TOKEN": token } : {};
|
|
27
|
+
}
|
|
28
|
+
async function fetchPackages(base, projectPath, token) {
|
|
29
|
+
const res = await fetchWithRetry(`${base}/api/v4/projects/${encodeURIComponent(projectPath)}/packages?package_type=generic&package_name=${PACKAGE_NAME}&per_page=100`, { headers: authHeaders(token) });
|
|
30
|
+
if (!res.ok) throw new Error(`GitLab API ${res.status} ${res.statusText} listing packages for ${projectPath}`);
|
|
31
|
+
return (await res.json()).filter((p) => p.name === PACKAGE_NAME && p.package_type === "generic" && p.status === "default");
|
|
32
|
+
}
|
|
33
|
+
async function fetchPackageFiles(base, projectPath, packageId, token) {
|
|
34
|
+
const res = await fetchWithRetry(`${base}/api/v4/projects/${encodeURIComponent(projectPath)}/packages/${packageId}/package_files?per_page=100`, { headers: authHeaders(token) });
|
|
35
|
+
if (!res.ok) throw new Error(`GitLab API ${res.status} ${res.statusText} listing files for package ${packageId}`);
|
|
36
|
+
return await res.json();
|
|
37
|
+
}
|
|
38
|
+
/** Pick the .jar file. If multiple, prefer the most recently created one. */
|
|
39
|
+
function findJar(files) {
|
|
40
|
+
const jars = files.filter((f) => f.file_name.endsWith(".jar"));
|
|
41
|
+
if (jars.length === 0) return null;
|
|
42
|
+
return jars.reduce((latest, f) => f.created_at > latest.created_at ? f : latest);
|
|
43
|
+
}
|
|
44
|
+
async function resolveAuthLibertyVersion(input, options = {}) {
|
|
45
|
+
const project = options.project ?? DEFAULT_PROJECT;
|
|
46
|
+
const base = (options.gitlab ?? DEFAULT_GITLAB).replace(/\/+$/, "");
|
|
47
|
+
const packages = await fetchPackages(base, project, options.token);
|
|
48
|
+
const candidates = packages.filter((p) => p.version === input);
|
|
49
|
+
if (candidates.length === 0) {
|
|
50
|
+
const available = [...new Set(packages.map((p) => p.version))].slice(0, 8).join(", ");
|
|
51
|
+
throw new Error(`AuthLiberty version '${input}' not found in ${project}. Available: ${available || "(none)"}`);
|
|
52
|
+
}
|
|
53
|
+
const pkg = candidates.reduce((latest, p) => p.created_at > latest.created_at ? p : latest);
|
|
54
|
+
const jar = findJar(await fetchPackageFiles(base, project, pkg.id, options.token));
|
|
55
|
+
if (!jar) throw new Error(`AuthLiberty package ${project}@${pkg.version} has no .jar file`);
|
|
56
|
+
const downloadUrl = `${base}/api/v4/projects/${encodeURIComponent(project)}/packages/generic/${PACKAGE_NAME}/${encodeURIComponent(pkg.version)}/${encodeURIComponent(jar.file_name)}`;
|
|
57
|
+
return {
|
|
58
|
+
version: pkg.version,
|
|
59
|
+
filename: jar.file_name,
|
|
60
|
+
url: downloadUrl,
|
|
61
|
+
size: jar.size,
|
|
62
|
+
sha256: jar.file_sha256 ?? void 0,
|
|
63
|
+
createdAt: pkg.created_at
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region lib/template.ts
|
|
69
|
+
const HOST_PROPS = {
|
|
70
|
+
auth: "minecraft.api.auth.host",
|
|
71
|
+
account: "minecraft.api.account.host",
|
|
72
|
+
session: "minecraft.api.session.host",
|
|
73
|
+
services: "minecraft.api.services.host"
|
|
74
|
+
};
|
|
75
|
+
const SERVERS = Object.keys(HOST_PROPS);
|
|
76
|
+
function resolveHost(hosts, server) {
|
|
77
|
+
if (!hosts) return void 0;
|
|
78
|
+
const raw = typeof hosts === "function" ? hosts(server) : hosts[server];
|
|
79
|
+
return raw ? raw : void 0;
|
|
80
|
+
}
|
|
81
|
+
function val(value) {
|
|
82
|
+
return {
|
|
83
|
+
rules: [],
|
|
84
|
+
value: [value]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Build a opys template fragment that loads AuthLiberty as a `-javaagent`
|
|
89
|
+
* and points Mojang's auth/account/session/services hosts at the configured
|
|
90
|
+
* replacements.
|
|
91
|
+
*
|
|
92
|
+
* The agent jar lands at `${library_directory}/net/harmoniya/authliberty/<v>/authliberty-<v>.jar`
|
|
93
|
+
* (a maven-ish path mirroring how Forge/Cleanroom organize bootstrap jars).
|
|
94
|
+
* The `jvmArgs` Valset is meant to be spread into a loader template's
|
|
95
|
+
* `command.args` — AuthLiberty has no main class, no classpath needs, and
|
|
96
|
+
* doesn't interact with any loader's bootstrap, so it composes cleanly with
|
|
97
|
+
* any of `@opys/{minecraft,forge,cleanroom,lwjgl3ify}`.
|
|
98
|
+
*/
|
|
99
|
+
async function resolveAuthliberty(options) {
|
|
100
|
+
const release = await resolveAuthLibertyVersion(options.version, {
|
|
101
|
+
project: options.project,
|
|
102
|
+
gitlab: options.gitlab,
|
|
103
|
+
token: options.token
|
|
104
|
+
});
|
|
105
|
+
const path = `\${library_directory}/net/harmoniya/authliberty/${release.version}/${release.filename}`;
|
|
106
|
+
const artifact = {
|
|
107
|
+
path,
|
|
108
|
+
source: sourceUrl(release.url),
|
|
109
|
+
size: release.size,
|
|
110
|
+
rules: [],
|
|
111
|
+
...release.sha256 ? { integrity: { sha256: release.sha256 } } : {}
|
|
112
|
+
};
|
|
113
|
+
const args = [val(`-javaagent:${path}`)];
|
|
114
|
+
for (const server of SERVERS) {
|
|
115
|
+
const url = resolveHost(options.hosts, server);
|
|
116
|
+
if (url) args.push(val(`-D${HOST_PROPS[server]}=${url}`));
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
artifacts: [artifact],
|
|
120
|
+
jvmArgs: args,
|
|
121
|
+
release
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region lib/plugin.ts
|
|
127
|
+
/** AuthLiberty — an authlib-injector `-javaagent` auth redirector. */
|
|
128
|
+
function authliberty(version, opts = {}) {
|
|
129
|
+
return definePlugin({
|
|
130
|
+
name: "authliberty",
|
|
131
|
+
async build(ctx) {
|
|
132
|
+
const t = await resolveAuthliberty({
|
|
133
|
+
version,
|
|
134
|
+
...opts
|
|
135
|
+
});
|
|
136
|
+
ctx.log("authliberty", `resolved ${version}`);
|
|
137
|
+
return {
|
|
138
|
+
artifacts: t.artifacts,
|
|
139
|
+
launch: { jvmArgs: t.jvmArgs }
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
146
|
+
export { authliberty, resolveAuthLibertyVersion, resolveAuthliberty };
|
|
147
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../lib/resolver.ts","../lib/template.ts","../lib/plugin.ts"],"sourcesContent":["/**\n * Resolver for AuthLiberty releases on a GitLab generic package registry.\n *\n * AuthLiberty's CI publishes the agent jar to two channels:\n * - `latest` — auto-updated from `main`, filename `authliberty-latest.jar`\n * - `<version>` — tagged releases, filename `authliberty-<version>.jar`\n *\n * Both ship as a single `.jar` in a generic package named `authliberty`.\n * GitLab exposes the file's sha256 via the `package_files` API, which we\n * use for integrity verification. The `latest` channel's sha256 changes\n * whenever a new build replaces it — that's resolved at template-build\n * time and frozen into the opys manifest.\n *\n * Accepted version forms:\n * - Exact version: `'0.3'`\n * - `'latest'` — the auto-updating `latest` package version\n */\n\nimport { fetchWithRetry } from '@opys/core';\n\nconst DEFAULT_PROJECT = 'harmoniya/authliberty';\nconst DEFAULT_GITLAB = 'https://gitlab.com';\nconst PACKAGE_NAME = 'authliberty';\n\nexport interface AuthLibertyRelease {\n /** Package version, e.g. `0.3` or `latest`. */\n readonly version: string;\n /** Asset filename, e.g. `authliberty-0.3.jar`. */\n readonly filename: string;\n /** Direct download URL for the agent jar. */\n readonly url: string;\n /** Asset size in bytes. */\n readonly size: number;\n /** sha256 of the asset (hex), as reported by GitLab. */\n readonly sha256?: string;\n /** ISO timestamp the package was created. */\n readonly createdAt: string;\n}\n\nexport interface ResolveAuthLibertyOptions {\n /** GitLab project path `group/name`. Default: `harmoniya/authliberty`. */\n project?: string;\n /** GitLab instance URL. Default: `https://gitlab.com`. */\n gitlab?: string;\n /** Optional GitLab token for private projects / higher rate limits. */\n token?: string;\n}\n\ninterface RawPackage {\n id: number;\n name: string;\n version: string;\n package_type: string;\n status: string;\n created_at: string;\n}\n\ninterface RawPackageFile {\n id: number;\n package_id: number;\n file_name: string;\n size: number;\n file_sha256: string | null;\n created_at: string;\n}\n\nfunction authHeaders(token: string | undefined): Record<string, string> {\n return token ? { 'PRIVATE-TOKEN': token } : {};\n}\n\nasync function fetchPackages(\n base: string,\n projectPath: string,\n token: string | undefined,\n): Promise<RawPackage[]> {\n const projectEnc = encodeURIComponent(projectPath);\n const url = `${base}/api/v4/projects/${projectEnc}/packages?package_type=generic&package_name=${PACKAGE_NAME}&per_page=100`;\n const res = await fetchWithRetry(url, { headers: authHeaders(token) });\n if (!res.ok) {\n throw new Error(\n `GitLab API ${res.status} ${res.statusText} listing packages for ${projectPath}`,\n );\n }\n const all = (await res.json()) as RawPackage[];\n // GitLab's `package_name` filter is a fuzzy match — narrow to exact name\n // and the generic registry, drop any non-default (broken/processing).\n return all.filter(\n (p) =>\n p.name === PACKAGE_NAME &&\n p.package_type === 'generic' &&\n p.status === 'default',\n );\n}\n\nasync function fetchPackageFiles(\n base: string,\n projectPath: string,\n packageId: number,\n token: string | undefined,\n): Promise<RawPackageFile[]> {\n const projectEnc = encodeURIComponent(projectPath);\n const url = `${base}/api/v4/projects/${projectEnc}/packages/${packageId}/package_files?per_page=100`;\n const res = await fetchWithRetry(url, { headers: authHeaders(token) });\n if (!res.ok) {\n throw new Error(\n `GitLab API ${res.status} ${res.statusText} listing files for package ${packageId}`,\n );\n }\n return (await res.json()) as RawPackageFile[];\n}\n\n/** Pick the .jar file. If multiple, prefer the most recently created one. */\nfunction findJar(files: RawPackageFile[]): RawPackageFile | null {\n const jars = files.filter((f) => f.file_name.endsWith('.jar'));\n if (jars.length === 0) return null;\n return jars.reduce((latest, f) =>\n f.created_at > latest.created_at ? f : latest,\n );\n}\n\nexport async function resolveAuthLibertyVersion(\n input: string,\n options: ResolveAuthLibertyOptions = {},\n): Promise<AuthLibertyRelease> {\n const project = options.project ?? DEFAULT_PROJECT;\n const base = (options.gitlab ?? DEFAULT_GITLAB).replace(/\\/+$/, '');\n const packages = await fetchPackages(base, project, options.token);\n\n const candidates = packages.filter((p) => p.version === input);\n if (candidates.length === 0) {\n const available = [...new Set(packages.map((p) => p.version))]\n .slice(0, 8)\n .join(', ');\n throw new Error(\n `AuthLiberty version '${input}' not found in ${project}. Available: ${available || '(none)'}`,\n );\n }\n // Same version can be re-published; the most recent package wins.\n const pkg = candidates.reduce((latest, p) =>\n p.created_at > latest.created_at ? p : latest,\n );\n\n const files = await fetchPackageFiles(base, project, pkg.id, options.token);\n const jar = findJar(files);\n if (!jar) {\n throw new Error(\n `AuthLiberty package ${project}@${pkg.version} has no .jar file`,\n );\n }\n\n const projectEnc = encodeURIComponent(project);\n const downloadUrl = `${base}/api/v4/projects/${projectEnc}/packages/generic/${PACKAGE_NAME}/${encodeURIComponent(pkg.version)}/${encodeURIComponent(jar.file_name)}`;\n\n return {\n version: pkg.version,\n filename: jar.file_name,\n url: downloadUrl,\n size: jar.size,\n sha256: jar.file_sha256 ?? undefined,\n createdAt: pkg.created_at,\n };\n}\n","import { type Artifact, sourceUrl } from '@opys/core';\nimport type { Val, Valset } from '@opys/core';\nimport {\n resolveAuthLibertyVersion,\n type AuthLibertyRelease,\n type ResolveAuthLibertyOptions,\n} from './resolver';\n\n/** Mojang server kind AuthLiberty's bytecode transformer can retarget. */\nexport type AuthLibertyServer = 'auth' | 'account' | 'session' | 'services';\n\n/**\n * Per-server host overrides. Either:\n * - an object — only the keys you set become `-D` flags; unset ones fall\n * back to the original Mojang host at runtime, OR\n * - a function — called once per server kind. Return a URL to override,\n * or `undefined` / empty string to leave that server on its Mojang\n * default.\n */\nexport type AuthLibertyHosts =\n | AuthLibertyHostMap\n | ((server: AuthLibertyServer) => string | undefined);\n\nexport interface AuthLibertyHostMap {\n /** `-Dminecraft.api.auth.host` — Yggdrasil auth server (default `https://authserver.mojang.com`). */\n auth?: string;\n /** `-Dminecraft.api.account.host` — account services (default `https://account.mojang.com`). */\n account?: string;\n /** `-Dminecraft.api.session.host` — session/profile server (default `https://sessionserver.mojang.com`). */\n session?: string;\n /** `-Dminecraft.api.services.host` — Minecraft Services API (default `https://api.minecraftservices.com`). */\n services?: string;\n}\n\nexport interface AuthLibertyOptions {\n /**\n * AuthLiberty version. Accepts:\n * - Exact version: `'0.3'`\n * - `'latest'` — auto-updating `main` build (sha256 frozen at template-build time)\n */\n version: string;\n /** GitLab project path. Default: `harmoniya/authliberty`. */\n project?: string;\n /** GitLab instance URL. Default: `https://gitlab.com`. */\n gitlab?: string;\n /** Optional GitLab token for private projects / higher rate limits. */\n token?: string;\n /** Replacement host overrides. Each maps to a `-Dminecraft.api.*.host` system property. */\n hosts?: AuthLibertyHosts;\n}\n\nexport interface AuthLibertyTemplate {\n /** The agent jar artifact. */\n artifacts: Artifact[];\n /**\n * JVM args to add to the launch command — `-javaagent:<path>` plus a\n * `-D` for each configured host. Spread these into your loader\n * template's `command.args` (typically *before* the loader's own\n * `-javaagent:` and main-class args, so the redirector is in place\n * before any auth code runs).\n */\n jvmArgs: Valset;\n /** Resolved release metadata, useful for logging / pinning. */\n release: AuthLibertyRelease;\n}\n\nconst HOST_PROPS = {\n auth: 'minecraft.api.auth.host',\n account: 'minecraft.api.account.host',\n session: 'minecraft.api.session.host',\n services: 'minecraft.api.services.host',\n} as const satisfies Record<AuthLibertyServer, string>;\n\nconst SERVERS = Object.keys(HOST_PROPS) as AuthLibertyServer[];\n\nfunction resolveHost(\n hosts: AuthLibertyHosts | undefined,\n server: AuthLibertyServer,\n): string | undefined {\n if (!hosts) return undefined;\n const raw = typeof hosts === 'function' ? hosts(server) : hosts[server];\n return raw ? raw : undefined;\n}\n\nfunction val(value: string): Val {\n return { rules: [], value: [value] };\n}\n\n/**\n * Build a opys template fragment that loads AuthLiberty as a `-javaagent`\n * and points Mojang's auth/account/session/services hosts at the configured\n * replacements.\n *\n * The agent jar lands at `${library_directory}/net/harmoniya/authliberty/<v>/authliberty-<v>.jar`\n * (a maven-ish path mirroring how Forge/Cleanroom organize bootstrap jars).\n * The `jvmArgs` Valset is meant to be spread into a loader template's\n * `command.args` — AuthLiberty has no main class, no classpath needs, and\n * doesn't interact with any loader's bootstrap, so it composes cleanly with\n * any of `@opys/{minecraft,forge,cleanroom,lwjgl3ify}`.\n */\nexport async function resolveAuthliberty(\n options: AuthLibertyOptions,\n): Promise<AuthLibertyTemplate> {\n const release = await resolveAuthLibertyVersion(options.version, {\n project: options.project,\n gitlab: options.gitlab,\n token: options.token,\n } satisfies ResolveAuthLibertyOptions);\n\n const path = `\\${library_directory}/net/harmoniya/authliberty/${release.version}/${release.filename}`;\n\n const artifact: Artifact = {\n path,\n source: sourceUrl(release.url),\n size: release.size,\n rules: [],\n ...(release.sha256 ? { integrity: { sha256: release.sha256 } } : {}),\n };\n\n const args: Val[] = [val(`-javaagent:${path}`)];\n for (const server of SERVERS) {\n const url = resolveHost(options.hosts, server);\n if (url) args.push(val(`-D${HOST_PROPS[server]}=${url}`));\n }\n\n return {\n artifacts: [artifact],\n jvmArgs: args,\n release,\n };\n}\n","import { definePlugin, type OpysPlugin } from '@opys/dev';\nimport { resolveAuthliberty, type AuthLibertyOptions } from './template';\n\n/** AuthLiberty — an authlib-injector `-javaagent` auth redirector. */\nexport function authliberty(\n version: string,\n opts: Omit<AuthLibertyOptions, 'version'> = {},\n): OpysPlugin {\n return definePlugin({\n name: 'authliberty',\n async build(ctx) {\n const t = await resolveAuthliberty({ version, ...opts });\n ctx.log('authliberty', `resolved ${version}`);\n return { artifacts: t.artifacts, launch: { jvmArgs: t.jvmArgs } };\n },\n });\n}\n"],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opys/authliberty",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.mjs",
|
|
9
|
+
"require": "./dist/index.cjs"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsdown lib/index.ts --format esm,cjs --dts --clean",
|
|
14
|
+
"typecheck": "tsc --noEmit -p tsconfig.json",
|
|
15
|
+
"test": "vitest run tests/unit --passWithNoTests"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@opys/core": "^0.1.2",
|
|
19
|
+
"@opys/dev": "^0.1.2"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"tsdown": "*",
|
|
23
|
+
"vitest": "*"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=20"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/harmoniya-net/opys.git",
|
|
34
|
+
"directory": "packages/authliberty"
|
|
35
|
+
}
|
|
36
|
+
}
|