@darco2903/auth-api 2.1.0 → 2.1.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/LICENSE +674 -674
- package/README.md +4 -3
- package/package.json +3 -3
- package/tools/generate-openapi.ts +25 -25
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ npm install @darco2903/auth-api
|
|
|
18
18
|
import { createClient } from "@darco2903/auth-api/client";
|
|
19
19
|
|
|
20
20
|
const SERVER_ORIGIN = "https://auth.example.com";
|
|
21
|
-
const authApi =
|
|
21
|
+
const authApi = createClient(SERVER_ORIGIN);
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
### Signing a JWT token
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
} from "@darco2903/auth-api/server";
|
|
32
32
|
import { Hour } from "@darco2903/secondthought";
|
|
33
33
|
|
|
34
|
-
const JWT_PRIVATE_KEY = "";
|
|
34
|
+
const JWT_PRIVATE_KEY = "..."; // Private key here
|
|
35
35
|
const tokenData: AccessTokenData = {
|
|
36
36
|
public_id: "user_public_id",
|
|
37
37
|
role: UserRole.User,
|
|
@@ -55,7 +55,8 @@ await JWTSign(tokenData, JWT_PRIVATE_KEY, expiresIn).match(
|
|
|
55
55
|
```ts
|
|
56
56
|
import { JWTVerify } from "@darco2903/auth-api/server";
|
|
57
57
|
|
|
58
|
-
const
|
|
58
|
+
const JWT_PUBLIC_KEY = "..."; // Public key here
|
|
59
|
+
const accessToken = "..."; // JWT token here
|
|
59
60
|
|
|
60
61
|
await JWTVerify(accessToken, JWT_PUBLIC_KEY).match(
|
|
61
62
|
(decodedToken) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darco2903/auth-api",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"repository": {
|
|
11
|
-
"url": "https://github.com/Darco2903/
|
|
11
|
+
"url": "https://github.com/Darco2903/auth-api.git"
|
|
12
12
|
},
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"./server": "./dist/server.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@darco2903/cdn-api": "^1.0
|
|
22
|
+
"@darco2903/cdn-api": "^1.1.0",
|
|
23
23
|
"@ts-rest/core": "^3.52.1",
|
|
24
24
|
"@ts-rest/open-api": "^3.52.1",
|
|
25
25
|
"jsonwebtoken": "^9.0.3",
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { generateOpenApi } from "@ts-rest/open-api";
|
|
3
|
-
import { contract } from "../src/";
|
|
4
|
-
|
|
5
|
-
import { version } from "../package.json";
|
|
6
|
-
|
|
7
|
-
console.log("Generating OpenAPI documentation...");
|
|
8
|
-
console.log(`API version: ${version}`);
|
|
9
|
-
|
|
10
|
-
const openApiDocument = generateOpenApi(contract, {
|
|
11
|
-
info: {
|
|
12
|
-
title: "Auth API",
|
|
13
|
-
version,
|
|
14
|
-
},
|
|
15
|
-
servers: [
|
|
16
|
-
{
|
|
17
|
-
url: "https://auth.darco2903.fr",
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
url: "https://dev-auth.darco2903.fr",
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
fs.writeFileSync("openapi.json", JSON.stringify(openApiDocument, null, 2));
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { generateOpenApi } from "@ts-rest/open-api";
|
|
3
|
+
import { contract } from "../src/";
|
|
4
|
+
|
|
5
|
+
import { version } from "../package.json";
|
|
6
|
+
|
|
7
|
+
console.log("Generating OpenAPI documentation...");
|
|
8
|
+
console.log(`API version: ${version}`);
|
|
9
|
+
|
|
10
|
+
const openApiDocument = generateOpenApi(contract, {
|
|
11
|
+
info: {
|
|
12
|
+
title: "Auth API",
|
|
13
|
+
version,
|
|
14
|
+
},
|
|
15
|
+
servers: [
|
|
16
|
+
{
|
|
17
|
+
url: "https://auth.darco2903.fr",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
url: "https://dev-auth.darco2903.fr",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
fs.writeFileSync("openapi.json", JSON.stringify(openApiDocument, null, 2));
|