authly-me 0.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.
Files changed (2) hide show
  1. package/index.js +34 -0
  2. package/package.json +22 -0
package/index.js ADDED
@@ -0,0 +1,34 @@
1
+ const axios = require('axios');
2
+
3
+ class Authly {
4
+
5
+ constructor(key, options={}) {
6
+ if (!key) {
7
+ throw new Error('Key is required');
8
+ }
9
+ this.key = key;
10
+ this.server_url = options?.server_url ?? 'http://localhost:4000/api';
11
+ this.callback_url = options?.callback_url ?? null;
12
+ }
13
+
14
+ async generateAppAuthLink() {
15
+ const payload = {
16
+ key: this.key
17
+ };
18
+
19
+ if (this.callback_url) {
20
+ payload.callback_url = this.callback_url;
21
+ }
22
+
23
+ let response;
24
+ try {
25
+ response = await axios.post(`${this.server_url}/auth/app/generate-link`, payload);
26
+ return response.data;
27
+ } catch (error) {
28
+ return error.response.data;
29
+ }
30
+ }
31
+
32
+ }
33
+
34
+ module.exports = Authly;
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "authly-me",
3
+ "version": "0.0.1",
4
+ "main": "index.js",
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/massive-dynamics-in/authly-me.git"
11
+ },
12
+ "author": "massive-dynamics-in",
13
+ "license": "ISC",
14
+ "bugs": {
15
+ "url": "https://github.com/massive-dynamics-in/authly-me/issues"
16
+ },
17
+ "homepage": "https://github.com/massive-dynamics-in/authly-me#readme",
18
+ "description": "",
19
+ "dependencies": {
20
+ "axios": "^1.7.9"
21
+ }
22
+ }