@authly/sdk 1.0.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
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Anvoria
|
|
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/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpClient = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* A class that provides a static method for making HTTP requests.
|
|
6
|
+
*/
|
|
7
|
+
class HttpClient {
|
|
8
|
+
constructor() { }
|
|
9
|
+
/**
|
|
10
|
+
* Makes an HTTP request to the specified URL.
|
|
11
|
+
* @param url - The URL to make the request to.
|
|
12
|
+
* @param options - The options for the request.
|
|
13
|
+
* @returns A promise that resolves to the response data.
|
|
14
|
+
*/
|
|
15
|
+
static async request(url, options) {
|
|
16
|
+
try {
|
|
17
|
+
const response = await fetch(url, {
|
|
18
|
+
...options,
|
|
19
|
+
headers: {
|
|
20
|
+
"Content-Type": "application/json",
|
|
21
|
+
Accept: "application/json",
|
|
22
|
+
...options.headers,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return (await response.json());
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return {
|
|
29
|
+
success: false,
|
|
30
|
+
error: {
|
|
31
|
+
code: "UNKNOWN_ERROR",
|
|
32
|
+
message: error instanceof Error ? error.message : "An unknown error occurred.",
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Makes a GET request to the specified URL.
|
|
39
|
+
* @param url - The URL to make the request to.
|
|
40
|
+
* @param options - The options for the request.
|
|
41
|
+
* @returns A promise that resolves to the response data.
|
|
42
|
+
*/
|
|
43
|
+
static async get(url, options) {
|
|
44
|
+
return this.request(url, {
|
|
45
|
+
...options,
|
|
46
|
+
method: "GET",
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Makes a POST request to the specified URL.
|
|
51
|
+
* @param url - The URL to make the request to.
|
|
52
|
+
* @param options - The options for the request.
|
|
53
|
+
* @returns A promise that resolves to the response data.
|
|
54
|
+
*/
|
|
55
|
+
static async post(url, options) {
|
|
56
|
+
return this.request(url, {
|
|
57
|
+
...options,
|
|
58
|
+
method: "POST",
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Makes a PUT request to the specified URL.
|
|
63
|
+
* @param url - The URL to make the request to.
|
|
64
|
+
* @param options - The options for the request.
|
|
65
|
+
* @returns A promise that resolves to the response data.
|
|
66
|
+
*/
|
|
67
|
+
static async put(url, options) {
|
|
68
|
+
return this.request(url, {
|
|
69
|
+
...options,
|
|
70
|
+
method: "PUT",
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Makes a PATCH request to the specified URL.
|
|
75
|
+
* @param url - The URL to make the request to.
|
|
76
|
+
* @param options - The options for the request.
|
|
77
|
+
* @returns A promise that resolves to the response data.
|
|
78
|
+
*/
|
|
79
|
+
static async patch(url, options) {
|
|
80
|
+
return this.request(url, {
|
|
81
|
+
...options,
|
|
82
|
+
method: "PATCH",
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Makes a DELETE request to the specified URL.
|
|
87
|
+
* @param url - The URL to make the request to.
|
|
88
|
+
* @param options - The options for the request.
|
|
89
|
+
* @returns A promise that resolves to the response data.
|
|
90
|
+
*/
|
|
91
|
+
static async delete(url, options) {
|
|
92
|
+
return this.request(url, {
|
|
93
|
+
...options,
|
|
94
|
+
method: "DELETE",
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.HttpClient = HttpClient;
|
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@authly/sdk",
|
|
3
|
+
"description": "A library for building authentication systems using Authly.",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Anvoria",
|
|
7
|
+
"url": "https://github.com/Anvoria"
|
|
8
|
+
},
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/Anvoria/authly-sdk-ts.git"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/Anvoria/authly-sdk-ts",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/Anvoria/authly-sdk-ts/issues"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"authentication",
|
|
20
|
+
"authorization",
|
|
21
|
+
"authentication-library",
|
|
22
|
+
"authly"
|
|
23
|
+
],
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18.0.0",
|
|
26
|
+
"bun": ">=1.0.0"
|
|
27
|
+
},
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"types": "dist/index.d.ts",
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"publishConfig": {
|
|
34
|
+
"access": "public"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc",
|
|
38
|
+
"format": "bunx prettier --write .",
|
|
39
|
+
"lint": "bunx eslint .",
|
|
40
|
+
"lint:fix": "bunx eslint --fix .",
|
|
41
|
+
"test": "tsx --test tests/**/*.test.ts",
|
|
42
|
+
"test:watch": "tsx --test --watch tests/**/*.test.ts",
|
|
43
|
+
"prepublishOnly": "bun run build",
|
|
44
|
+
"prepare": "bunx husky"
|
|
45
|
+
},
|
|
46
|
+
"lint-staged": {
|
|
47
|
+
"*.{ts,json,jsonc,md}": [
|
|
48
|
+
"eslint --fix",
|
|
49
|
+
"prettier --write"
|
|
50
|
+
],
|
|
51
|
+
"*,{yml,yaml}": [
|
|
52
|
+
"prettier --write"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@eslint/js": "^9.39.2",
|
|
57
|
+
"@eslint/json": "^0.14.0",
|
|
58
|
+
"@eslint/markdown": "^7.5.1",
|
|
59
|
+
"@types/bun": "^1.3.4",
|
|
60
|
+
"@types/node": "^25.0.3",
|
|
61
|
+
"eslint": "^9.39.2",
|
|
62
|
+
"globals": "^16.5.0",
|
|
63
|
+
"husky": "^9.1.7",
|
|
64
|
+
"jiti": "^2.6.1",
|
|
65
|
+
"lint-staged": "^16.2.7",
|
|
66
|
+
"prettier": "^3.7.4",
|
|
67
|
+
"tsx": "^4.21.0",
|
|
68
|
+
"typescript": "^5.9.3",
|
|
69
|
+
"typescript-eslint": "^8.50.0"
|
|
70
|
+
}
|
|
71
|
+
}
|