@zeltjs/auth-jwt 0.0.1 → 0.3.0
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/LICENSE +21 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +116 -0
- package/dist/index.js.map +1 -0
- package/package.json +42 -8
- package/README.md +0 -45
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 9wick / Kohei Kido
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Next, RequestContext, RequestContextSchema } from "@zeltjs/core";
|
|
2
|
+
import * as _$hono_utils_http_status0 from "hono/utils/http-status";
|
|
3
|
+
import * as _$hono_http_exception0 from "hono/http-exception";
|
|
4
|
+
|
|
5
|
+
//#region src/errors.d.ts
|
|
6
|
+
type JwtConfigErrorReason = 'missing_secret';
|
|
7
|
+
declare const ZeltJwtConfigError: new (context: {
|
|
8
|
+
reason: JwtConfigErrorReason;
|
|
9
|
+
}, cause?: unknown) => Error & {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly context: {
|
|
12
|
+
reason: JwtConfigErrorReason;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/exceptions.d.ts
|
|
17
|
+
type UnauthorizedReason = 'missing_token' | 'invalid_token' | 'expired';
|
|
18
|
+
declare const UnauthorizedException: new (context: {
|
|
19
|
+
reason: UnauthorizedReason;
|
|
20
|
+
}, options?: {
|
|
21
|
+
status?: _$hono_utils_http_status0.ContentfulStatusCode;
|
|
22
|
+
cause?: unknown;
|
|
23
|
+
}) => _$hono_http_exception0.HTTPException & {
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly context: {
|
|
26
|
+
reason: UnauthorizedReason;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/jwt.types.d.ts
|
|
31
|
+
interface JwtPayload {
|
|
32
|
+
sub?: string;
|
|
33
|
+
iat?: number;
|
|
34
|
+
exp?: number;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
type JwtDriver = 'header' | 'cookie';
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/jwt.config.d.ts
|
|
40
|
+
interface ResolveUserResult {
|
|
41
|
+
user: RequestContextSchema['user'];
|
|
42
|
+
roles: RequestContextSchema['authRoles'];
|
|
43
|
+
}
|
|
44
|
+
declare class JwtConfig {
|
|
45
|
+
/**
|
|
46
|
+
* @throws {ZeltJwtConfigError} When JWT_SECRET is not set
|
|
47
|
+
*/
|
|
48
|
+
get secret(): string;
|
|
49
|
+
get expiresIn(): string;
|
|
50
|
+
get driver(): JwtDriver;
|
|
51
|
+
get cookieName(): string;
|
|
52
|
+
get resolveUser(): (payload: JwtPayload) => Promise<ResolveUserResult>;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/jwt.service.d.ts
|
|
56
|
+
declare class JwtService {
|
|
57
|
+
private config;
|
|
58
|
+
constructor(config?: JwtConfig);
|
|
59
|
+
sign(payload: Record<string, unknown>): Promise<string>;
|
|
60
|
+
verify(token: string): Promise<JwtPayload>;
|
|
61
|
+
decode(token: string): JwtPayload | null;
|
|
62
|
+
private parseExpiresIn;
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/jwt.middleware.d.ts
|
|
66
|
+
declare class JwtMiddleware {
|
|
67
|
+
private readonly jwtService;
|
|
68
|
+
private readonly config;
|
|
69
|
+
constructor(jwtService?: JwtService, config?: JwtConfig);
|
|
70
|
+
/**
|
|
71
|
+
* @throws {UnauthorizedException} When token is missing (401)
|
|
72
|
+
* @throws {UnauthorizedException} When token is invalid or expired (401)
|
|
73
|
+
*/
|
|
74
|
+
use(c: RequestContext, next: Next): Promise<Response | undefined>;
|
|
75
|
+
private extractToken;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { JwtConfig, type JwtConfigErrorReason, type JwtDriver, JwtMiddleware, type JwtPayload, JwtService, type ResolveUserResult, UnauthorizedException, type UnauthorizedReason, ZeltJwtConfigError };
|
|
79
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/errors.ts","../src/exceptions.ts","../src/jwt.types.ts","../src/jwt.config.ts","../src/jwt.service.ts","../src/jwt.middleware.ts"],"mappings":";;;;;KAEY,oBAAA;AAAA,cAMC,kBAAA,OAAkB,OAAA;UAEb,oBAAA;AAAA;;;YAAA,oBAAA;EAAA;AAAA;;;KCRN,kBAAA;AAAA,cAQC,qBAAA,OAAqB,OAAA;UAGhB,kBAAA;AAAA;WAAkB,yBAAA,CASkgG,oBAAA;;MAAA,sBAAA,CAAA,aAAA;EAAA;;YATphG,kBAAA;EAAA;AAAA;;;UCbD,UAAA;EACf,GAAA;EACA,GAAA;EACA,GAAA;EAAA,CACC,GAAA;AAAA;AAAA,KAGS,SAAA;;;UCDK,iBAAA;EACf,IAAA,EAAM,oBAAA;EACN,KAAA,EAAO,oBAAA;AAAA;AAAA,cAII,SAAA;;;;MAIP,MAAA,CAAA;EAAA,IAQA,SAAA,CAAA;EAAA,IAIA,MAAA,CAAA,GAAU,SAAA;EAAA,IAIV,UAAA,CAAA;EAAA,IAIA,WAAA,CAAA,IAAgB,OAAA,EAAS,UAAA,KAAe,OAAA,CAAQ,iBAAA;AAAA;;;cC7BzC,UAAA;EAAA,QACS,MAAA;cAAA,MAAA,GAAM,SAAA;EAEpB,IAAA,CAAK,OAAA,EAAS,MAAA,oBAA0B,OAAA;EAaxC,MAAA,CAAO,KAAA,WAAgB,OAAA,CAAQ,UAAA;EAMrC,MAAA,CAAO,KAAA,WAAgB,UAAA;EAAA,QAQf,cAAA;AAAA;;;cC5BG,aAAA;EAAA,iBAEQ,UAAA;EAAA,iBACA,MAAA;cADA,UAAA,GAAU,UAAA,EACV,MAAA,GAAM,SAAA;;;;ALJ3B;EKWQ,GAAA,CAAI,CAAA,EAAG,cAAA,EAAgB,IAAA,EAAM,IAAA,GAAO,OAAA,CAAQ,QAAA;EAAA,QAsB1C,YAAA;AAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { defineError } from "@zeltjs/core/internal-bridge/errors";
|
|
2
|
+
import { Config, Injectable, Middleware, defineHttpException, inject, setUser } from "@zeltjs/core";
|
|
3
|
+
import { getCookie } from "hono/cookie";
|
|
4
|
+
import { SignJWT, decodeJwt, jwtVerify } from "jose";
|
|
5
|
+
//#region src/errors.ts
|
|
6
|
+
const messages$1 = { missing_secret: "JWT_SECRET environment variable is required" };
|
|
7
|
+
const ZeltJwtConfigError = defineError("ZeltJwtConfigError", (ctx) => messages$1[ctx.reason]);
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/exceptions.ts
|
|
10
|
+
const messages = {
|
|
11
|
+
missing_token: "Authorization token is required",
|
|
12
|
+
invalid_token: "Invalid authorization token",
|
|
13
|
+
expired: "Authorization token has expired"
|
|
14
|
+
};
|
|
15
|
+
const UnauthorizedException = defineHttpException("UnauthorizedException", 401, (ctx) => messages[ctx.reason], { buildResponse: (ctx, status, message) => Response.json({
|
|
16
|
+
code: "UNAUTHORIZED",
|
|
17
|
+
reason: ctx.reason,
|
|
18
|
+
message
|
|
19
|
+
}, {
|
|
20
|
+
status,
|
|
21
|
+
headers: { "WWW-Authenticate": "Bearer" }
|
|
22
|
+
}) });
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/jwt.config.ts
|
|
25
|
+
var JwtConfig = @Config class {
|
|
26
|
+
/**
|
|
27
|
+
* @throws {ZeltJwtConfigError} When JWT_SECRET is not set
|
|
28
|
+
*/
|
|
29
|
+
get secret() {
|
|
30
|
+
const secret = process.env["JWT_SECRET"];
|
|
31
|
+
if (!secret) throw new ZeltJwtConfigError({ reason: "missing_secret" });
|
|
32
|
+
return secret;
|
|
33
|
+
}
|
|
34
|
+
get expiresIn() {
|
|
35
|
+
return "1h";
|
|
36
|
+
}
|
|
37
|
+
get driver() {
|
|
38
|
+
return "header";
|
|
39
|
+
}
|
|
40
|
+
get cookieName() {
|
|
41
|
+
return "jwt";
|
|
42
|
+
}
|
|
43
|
+
get resolveUser() {
|
|
44
|
+
return async (payload) => ({
|
|
45
|
+
user: payload.sub,
|
|
46
|
+
roles: []
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/jwt.service.ts
|
|
52
|
+
var JwtService = @Injectable() class {
|
|
53
|
+
constructor(config = inject(JwtConfig)) {
|
|
54
|
+
this.config = config;
|
|
55
|
+
}
|
|
56
|
+
async sign(payload) {
|
|
57
|
+
const secret = new TextEncoder().encode(this.config.secret);
|
|
58
|
+
const expiresIn = this.parseExpiresIn(this.config.expiresIn);
|
|
59
|
+
return await new SignJWT(payload).setProtectedHeader({ alg: "HS256" }).setIssuedAt().setExpirationTime(expiresIn).sign(secret);
|
|
60
|
+
}
|
|
61
|
+
async verify(token) {
|
|
62
|
+
const { payload } = await jwtVerify(token, new TextEncoder().encode(this.config.secret));
|
|
63
|
+
return payload;
|
|
64
|
+
}
|
|
65
|
+
decode(token) {
|
|
66
|
+
try {
|
|
67
|
+
return decodeJwt(token);
|
|
68
|
+
} catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
parseExpiresIn(expiresIn) {
|
|
73
|
+
const match = /^(\d+)([smhd])$/.exec(expiresIn);
|
|
74
|
+
if (match) return `${parseInt(match[1] ?? "0", 10)} ${{
|
|
75
|
+
s: "seconds",
|
|
76
|
+
m: "minutes",
|
|
77
|
+
h: "hours",
|
|
78
|
+
d: "days"
|
|
79
|
+
}[match[2] ?? ""]}`;
|
|
80
|
+
return expiresIn;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/jwt.middleware.ts
|
|
85
|
+
var JwtMiddleware = @Middleware class {
|
|
86
|
+
constructor(jwtService = inject(JwtService), config = inject(JwtConfig)) {
|
|
87
|
+
this.jwtService = jwtService;
|
|
88
|
+
this.config = config;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* @throws {UnauthorizedException} When token is missing (401)
|
|
92
|
+
* @throws {UnauthorizedException} When token is invalid or expired (401)
|
|
93
|
+
*/
|
|
94
|
+
async use(c, next) {
|
|
95
|
+
const token = this.extractToken(c);
|
|
96
|
+
if (!token) throw new UnauthorizedException({ reason: "missing_token" });
|
|
97
|
+
const verified = await this.jwtService.verify(token).then((payload) => ({
|
|
98
|
+
ok: true,
|
|
99
|
+
payload
|
|
100
|
+
}), () => ({ ok: false }));
|
|
101
|
+
if (!verified.ok) throw new UnauthorizedException({ reason: "invalid_token" });
|
|
102
|
+
const { user, roles } = await this.config.resolveUser(verified.payload);
|
|
103
|
+
setUser(user, roles);
|
|
104
|
+
await next();
|
|
105
|
+
}
|
|
106
|
+
extractToken(c) {
|
|
107
|
+
if (this.config.driver === "cookie") return getCookie(c, this.config.cookieName) ?? null;
|
|
108
|
+
const authHeader = c.req.header("Authorization");
|
|
109
|
+
if (!authHeader?.startsWith("Bearer ")) return null;
|
|
110
|
+
return authHeader.slice(7);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
//#endregion
|
|
114
|
+
export { JwtConfig, JwtMiddleware, JwtService, UnauthorizedException, ZeltJwtConfigError };
|
|
115
|
+
|
|
116
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["messages"],"sources":["../src/errors.ts","../src/exceptions.ts","../src/jwt.config.ts","../src/jwt.service.ts","../src/jwt.middleware.ts"],"sourcesContent":["import { defineError } from '@zeltjs/core/internal-bridge/errors';\n\nexport type JwtConfigErrorReason = 'missing_secret';\n\nconst messages: Record<JwtConfigErrorReason, string> = {\n missing_secret: 'JWT_SECRET environment variable is required',\n};\n\nexport const ZeltJwtConfigError = defineError(\n 'ZeltJwtConfigError',\n (ctx: { reason: JwtConfigErrorReason }) => messages[ctx.reason],\n);\n","import { defineHttpException } from '@zeltjs/core';\n\nexport type UnauthorizedReason = 'missing_token' | 'invalid_token' | 'expired';\n\nconst messages: Record<UnauthorizedReason, string> = {\n missing_token: 'Authorization token is required',\n invalid_token: 'Invalid authorization token',\n expired: 'Authorization token has expired',\n};\n\nexport const UnauthorizedException = defineHttpException(\n 'UnauthorizedException',\n 401,\n (ctx: { reason: UnauthorizedReason }) => messages[ctx.reason],\n {\n buildResponse: (ctx, status, message) =>\n Response.json(\n { code: 'UNAUTHORIZED', reason: ctx.reason, message },\n { status, headers: { 'WWW-Authenticate': 'Bearer' } },\n ),\n },\n);\n","import type { RequestContextSchema } from '@zeltjs/core';\nimport { Config } from '@zeltjs/core';\n\nimport { ZeltJwtConfigError } from './errors';\nimport type { JwtDriver, JwtPayload } from './jwt.types';\n\nexport interface ResolveUserResult {\n user: RequestContextSchema['user'];\n roles: RequestContextSchema['authRoles'];\n}\n\n@Config\nexport class JwtConfig {\n /**\n * @throws {ZeltJwtConfigError} When JWT_SECRET is not set\n */\n get secret(): string {\n const secret = process.env['JWT_SECRET'];\n if (!secret) {\n throw new ZeltJwtConfigError({ reason: 'missing_secret' });\n }\n return secret;\n }\n\n get expiresIn(): string {\n return '1h';\n }\n\n get driver(): JwtDriver {\n return 'header';\n }\n\n get cookieName(): string {\n return 'jwt';\n }\n\n get resolveUser(): (payload: JwtPayload) => Promise<ResolveUserResult> {\n return async (payload) => ({\n user: payload.sub,\n roles: [],\n });\n }\n}\n","import { Injectable, inject } from '@zeltjs/core';\nimport { decodeJwt, jwtVerify, SignJWT } from 'jose';\n\nimport { JwtConfig } from './jwt.config';\nimport type { JwtPayload } from './jwt.types';\n\n@Injectable()\nexport class JwtService {\n constructor(private config = inject(JwtConfig)) {}\n\n async sign(payload: Record<string, unknown>): Promise<string> {\n const secret = new TextEncoder().encode(this.config.secret);\n const expiresIn = this.parseExpiresIn(this.config.expiresIn);\n\n const jwt = await new SignJWT(payload)\n .setProtectedHeader({ alg: 'HS256' })\n .setIssuedAt()\n .setExpirationTime(expiresIn)\n .sign(secret);\n\n return jwt;\n }\n\n async verify(token: string): Promise<JwtPayload> {\n const secret = new TextEncoder().encode(this.config.secret);\n const { payload } = await jwtVerify<JwtPayload>(token, secret);\n return payload;\n }\n\n decode(token: string): JwtPayload | null {\n try {\n return decodeJwt<JwtPayload>(token);\n } catch {\n return null;\n }\n }\n\n private parseExpiresIn(expiresIn: string): string | number {\n const match = /^(\\d+)([smhd])$/.exec(expiresIn);\n if (match) {\n const value = parseInt(match[1] ?? '0', 10);\n const unit = match[2] ?? '';\n const unitMap: Record<string, string> = {\n s: 'seconds',\n m: 'minutes',\n h: 'hours',\n d: 'days',\n };\n return `${value} ${unitMap[unit]}`;\n }\n return expiresIn;\n }\n}\n","import type { Next, RequestContext } from '@zeltjs/core';\nimport { inject, Middleware, setUser } from '@zeltjs/core';\nimport { getCookie } from 'hono/cookie';\n\nimport { UnauthorizedException } from './exceptions';\nimport { JwtConfig } from './jwt.config';\nimport { JwtService } from './jwt.service';\n\n@Middleware\nexport class JwtMiddleware {\n constructor(\n private readonly jwtService = inject(JwtService),\n private readonly config = inject(JwtConfig),\n ) {}\n\n /**\n * @throws {UnauthorizedException} When token is missing (401)\n * @throws {UnauthorizedException} When token is invalid or expired (401)\n */\n async use(c: RequestContext, next: Next): Promise<Response | undefined> {\n const token = this.extractToken(c);\n\n if (!token) {\n throw new UnauthorizedException({ reason: 'missing_token' });\n }\n\n const verified = await this.jwtService.verify(token).then(\n (payload) => ({ ok: true as const, payload }),\n () => ({ ok: false as const }),\n );\n\n if (!verified.ok) {\n throw new UnauthorizedException({ reason: 'invalid_token' });\n }\n\n const { user, roles } = await this.config.resolveUser(verified.payload);\n setUser(user, roles);\n await next();\n return undefined;\n }\n\n private extractToken(c: RequestContext): string | null {\n if (this.config.driver === 'cookie') {\n return getCookie(c, this.config.cookieName) ?? null;\n }\n\n const authHeader = c.req.header('Authorization');\n if (!authHeader?.startsWith('Bearer ')) {\n return null;\n }\n return authHeader.slice(7);\n }\n}\n"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeltjs/auth-jwt",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
}
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/zeltjs/zelt.git",
|
|
9
|
+
"directory": "packages/auth-jwt"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"hono": "^4.0.0",
|
|
25
|
+
"@zeltjs/core": "0.3.0"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"jose": "6.0.11"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "22.19.17",
|
|
32
|
+
"hono": "4.12.16",
|
|
33
|
+
"@zeltjs/core": "0.3.0",
|
|
34
|
+
"@zeltjs/testing": "0.3.0"
|
|
35
|
+
},
|
|
36
|
+
"volta": {
|
|
37
|
+
"extends": "../../package.json"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsdown",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"typecheck": "tsc -b"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/README.md
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# @zeltjs/auth-jwt
|
|
2
|
-
|
|
3
|
-
## ⚠️ IMPORTANT NOTICE ⚠️
|
|
4
|
-
|
|
5
|
-
**This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
|
|
6
|
-
|
|
7
|
-
This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
|
|
8
|
-
|
|
9
|
-
## Purpose
|
|
10
|
-
|
|
11
|
-
This package exists to:
|
|
12
|
-
1. Configure OIDC trusted publishing for the package name `@zeltjs/auth-jwt`
|
|
13
|
-
2. Enable secure, token-less publishing from CI/CD workflows
|
|
14
|
-
3. Establish provenance for packages published under this name
|
|
15
|
-
|
|
16
|
-
## What is OIDC Trusted Publishing?
|
|
17
|
-
|
|
18
|
-
OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
|
|
19
|
-
|
|
20
|
-
## Setup Instructions
|
|
21
|
-
|
|
22
|
-
To properly configure OIDC trusted publishing for this package:
|
|
23
|
-
|
|
24
|
-
1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
|
|
25
|
-
2. Configure the trusted publisher (e.g., GitHub Actions)
|
|
26
|
-
3. Specify the repository and workflow that should be allowed to publish
|
|
27
|
-
4. Use the configured workflow to publish your actual package
|
|
28
|
-
|
|
29
|
-
## DO NOT USE THIS PACKAGE
|
|
30
|
-
|
|
31
|
-
This package is a placeholder for OIDC configuration only. It:
|
|
32
|
-
- Contains no executable code
|
|
33
|
-
- Provides no functionality
|
|
34
|
-
- Should not be installed as a dependency
|
|
35
|
-
- Exists only for administrative purposes
|
|
36
|
-
|
|
37
|
-
## More Information
|
|
38
|
-
|
|
39
|
-
For more details about npm's trusted publishing feature, see:
|
|
40
|
-
- [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
|
|
41
|
-
- [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
|
|
42
|
-
|
|
43
|
-
---
|
|
44
|
-
|
|
45
|
-
**Maintained for OIDC setup purposes only**
|