@kevisual/auth 2.0.0 → 2.0.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/dist/app.d.ts +57 -0
- package/dist/app.js +1854 -0
- package/package.json +6 -2
- package/bun.config.ts +0 -20
- package/test/create.ts +0 -38
package/package.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/auth",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "bun run bun.config.ts"
|
|
7
7
|
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"src"
|
|
11
|
+
],
|
|
8
12
|
"keywords": [],
|
|
9
13
|
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
|
|
10
14
|
"license": "MIT",
|
|
11
|
-
"packageManager": "pnpm@10.
|
|
15
|
+
"packageManager": "pnpm@10.28.1",
|
|
12
16
|
"type": "module",
|
|
13
17
|
"dependencies": {},
|
|
14
18
|
"devDependencies": {
|
package/bun.config.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { resolvePath } from '@kevisual/use-config';
|
|
2
|
-
import { execSync } from 'node:child_process';
|
|
3
|
-
|
|
4
|
-
const entry = 'src/index.ts';
|
|
5
|
-
const naming = 'app';
|
|
6
|
-
const external = ['pm2'];
|
|
7
|
-
await Bun.build({
|
|
8
|
-
target: 'browser',
|
|
9
|
-
format: 'esm',
|
|
10
|
-
entrypoints: [resolvePath(entry, { meta: import.meta })],
|
|
11
|
-
outdir: resolvePath('./dist', { meta: import.meta }),
|
|
12
|
-
naming: {
|
|
13
|
-
entry: `${naming}.js`,
|
|
14
|
-
},
|
|
15
|
-
external,
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const cmd ='dts -i src/index.ts -o app.d.ts'
|
|
19
|
-
execSync(cmd, { stdio: 'inherit' });
|
|
20
|
-
console.log('Build completed.');
|
package/test/create.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import * as jose from 'jose';
|
|
2
|
-
import { signJWT, decodeJWT, verifyJWT } from '../src/auth.ts';
|
|
3
|
-
import { getValues } from '../src/jwks/get.ts';
|
|
4
|
-
|
|
5
|
-
const payload = {
|
|
6
|
-
iss: "https://convex.kevisual.cn",
|
|
7
|
-
sub: "user:123456",
|
|
8
|
-
aud: "convex-app",
|
|
9
|
-
name: "John Doe",
|
|
10
|
-
email: "john.doe@example.com",
|
|
11
|
-
// exp: Math.floor(Date.now() / 1000) - (2 * 60 * 60) // 2 hours from now
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const createToken = async () => {
|
|
15
|
-
const { privateJWK, privateKeyPEM } = getValues();
|
|
16
|
-
const token = await signJWT(payload, privateKeyPEM);
|
|
17
|
-
console.log('Generated JWT:', token);
|
|
18
|
-
|
|
19
|
-
// console.log('expited at:', new Date(payload.exp * 1000).toLocaleString());
|
|
20
|
-
return token;
|
|
21
|
-
}
|
|
22
|
-
const token = await createToken()
|
|
23
|
-
|
|
24
|
-
const decode = decodeJWT(token)
|
|
25
|
-
|
|
26
|
-
console.log('Decoded JWT:', decode);
|
|
27
|
-
|
|
28
|
-
const verify = async () => {
|
|
29
|
-
const { publicKeyPEM, privateJWK, jwks } = getValues();
|
|
30
|
-
try {
|
|
31
|
-
const verifiedPayload = await verifyJWT(token, publicKeyPEM);
|
|
32
|
-
console.log('Verified JWT payload:', verifiedPayload);
|
|
33
|
-
} catch (error) {
|
|
34
|
-
console.error('Verification failed:', error);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
await verify();
|