beamsocial 0.10.1 → 0.11.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/lib/index.d.ts +1 -1
- package/lib/index.js +9 -19
- package/lib/models/posts.js +3 -9
- package/lib/models/types/inbox.d.ts +1 -5
- package/lib/models/types/profiles.d.ts +2 -0
- package/lib/models/users.js +5 -15
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -21,4 +21,4 @@ export declare class Client {
|
|
|
21
21
|
export { User } from './models/users.js';
|
|
22
22
|
export { Session } from './models/auth.js';
|
|
23
23
|
export { Post } from './models/posts.js';
|
|
24
|
-
export type { Notification,
|
|
24
|
+
export type { Notification, NotificationSingle, NotificationWarn, NotificationBan } from './models/types/inbox.js';
|
package/lib/index.js
CHANGED
|
@@ -20,7 +20,9 @@ export class Client {
|
|
|
20
20
|
login(username, password) {
|
|
21
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
try {
|
|
23
|
-
const res = yield axios.post(this.baseURL + '/auth/login', { username, password }
|
|
23
|
+
const res = yield axios.post(this.baseURL + '/auth/login', { username, password }, {
|
|
24
|
+
withCredentials: true,
|
|
25
|
+
});
|
|
24
26
|
yield this.refresh(res.data.token);
|
|
25
27
|
return this.session || null;
|
|
26
28
|
}
|
|
@@ -52,9 +54,7 @@ export class Client {
|
|
|
52
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
55
|
try {
|
|
54
56
|
const res = yield axios.get(this.baseURL + '/me', {
|
|
55
|
-
|
|
56
|
-
Authorization: this.token ? `Bearer ${this.token}` : undefined,
|
|
57
|
-
},
|
|
57
|
+
withCredentials: true,
|
|
58
58
|
});
|
|
59
59
|
let session;
|
|
60
60
|
session = new Session(res.data.id, this.token || null);
|
|
@@ -84,9 +84,7 @@ export class Client {
|
|
|
84
84
|
privacy: settings.privacy,
|
|
85
85
|
appearence: settings.appearance
|
|
86
86
|
}, {
|
|
87
|
-
|
|
88
|
-
Authorization: this.token ? `Bearer ${this.token}` : undefined,
|
|
89
|
-
},
|
|
87
|
+
withCredentials: true,
|
|
90
88
|
});
|
|
91
89
|
yield this.refresh();
|
|
92
90
|
return;
|
|
@@ -112,9 +110,7 @@ export class Client {
|
|
|
112
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
113
111
|
try {
|
|
114
112
|
const res = yield axios.get(this.baseURL + '/users/' + name, {
|
|
115
|
-
|
|
116
|
-
Authorization: this.token ? `Bearer ${this.token}` : undefined,
|
|
117
|
-
},
|
|
113
|
+
withCredentials: true,
|
|
118
114
|
});
|
|
119
115
|
let user;
|
|
120
116
|
user = new User(res.data.id);
|
|
@@ -149,9 +145,7 @@ export class Client {
|
|
|
149
145
|
visibility: visibility,
|
|
150
146
|
answers_to: answers_to || undefined
|
|
151
147
|
}, {
|
|
152
|
-
|
|
153
|
-
Authorization: this.token ? `Bearer ${this.token}` : undefined,
|
|
154
|
-
},
|
|
148
|
+
withCredentials: true,
|
|
155
149
|
});
|
|
156
150
|
const data = res.data;
|
|
157
151
|
const post = new Post(data.id);
|
|
@@ -181,9 +175,7 @@ export class Client {
|
|
|
181
175
|
return __awaiter(this, void 0, void 0, function* () {
|
|
182
176
|
try {
|
|
183
177
|
const res = yield axios.get(this.baseURL + '/posts/' + id, {
|
|
184
|
-
|
|
185
|
-
Authorization: this.token ? `Bearer ${this.token}` : undefined,
|
|
186
|
-
},
|
|
178
|
+
withCredentials: true,
|
|
187
179
|
});
|
|
188
180
|
const data = res.data;
|
|
189
181
|
const post = new Post(data.id);
|
|
@@ -216,9 +208,7 @@ export class Client {
|
|
|
216
208
|
return __awaiter(this, void 0, void 0, function* () {
|
|
217
209
|
try {
|
|
218
210
|
const res = yield axios.get(this.baseURL + '/users/' + name + `/posts`, {
|
|
219
|
-
|
|
220
|
-
Authorization: this.token ? `Bearer ${this.token}` : undefined,
|
|
221
|
-
},
|
|
211
|
+
withCredentials: true,
|
|
222
212
|
});
|
|
223
213
|
const data = res.data;
|
|
224
214
|
const posts = [];
|
package/lib/models/posts.js
CHANGED
|
@@ -44,9 +44,7 @@ export class Post {
|
|
|
44
44
|
var _a;
|
|
45
45
|
try {
|
|
46
46
|
const res = yield axios.post(this.__url + `/like`, {}, {
|
|
47
|
-
|
|
48
|
-
Authorization: this.__token ? `Bearer ${this.__token}` : undefined,
|
|
49
|
-
},
|
|
47
|
+
withCredentials: true,
|
|
50
48
|
});
|
|
51
49
|
this.likes += 1;
|
|
52
50
|
(_a = this.__session) === null || _a === void 0 ? void 0 : _a.tastes.likes.push(this.id);
|
|
@@ -78,9 +76,7 @@ export class Post {
|
|
|
78
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
77
|
try {
|
|
80
78
|
const res = yield axios.delete(this.__url + `/like`, {
|
|
81
|
-
|
|
82
|
-
Authorization: this.__token ? `Bearer ${this.__token}` : undefined,
|
|
83
|
-
},
|
|
79
|
+
withCredentials: true,
|
|
84
80
|
});
|
|
85
81
|
this.likes -= 1;
|
|
86
82
|
this.__session.tastes.likes = this.__session.tastes.likes.filter((id) => id !== this.id);
|
|
@@ -127,9 +123,7 @@ export class Post {
|
|
|
127
123
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
124
|
try {
|
|
129
125
|
const res = yield axios.delete(this.__url, {
|
|
130
|
-
|
|
131
|
-
Authorization: this.__token ? `Bearer ${this.__token}` : undefined,
|
|
132
|
-
},
|
|
126
|
+
withCredentials: true,
|
|
133
127
|
});
|
|
134
128
|
return;
|
|
135
129
|
}
|
|
@@ -5,10 +5,6 @@ export interface NotificationBase {
|
|
|
5
5
|
isGroupable: boolean;
|
|
6
6
|
read: boolean;
|
|
7
7
|
}
|
|
8
|
-
export interface NotificationGroup extends NotificationBase {
|
|
9
|
-
authors: string[];
|
|
10
|
-
target: string;
|
|
11
|
-
}
|
|
12
8
|
export interface NotificationSingle extends NotificationBase {
|
|
13
9
|
author: string;
|
|
14
10
|
}
|
|
@@ -20,7 +16,7 @@ export interface NotificationBan extends NotificationBase {
|
|
|
20
16
|
until: Date;
|
|
21
17
|
reason: string;
|
|
22
18
|
}
|
|
23
|
-
export type Notification =
|
|
19
|
+
export type Notification = NotificationSingle | NotificationWarn | NotificationBan;
|
|
24
20
|
export type Inbox = {
|
|
25
21
|
id: string;
|
|
26
22
|
requests: {
|
package/lib/models/users.js
CHANGED
|
@@ -48,9 +48,7 @@ export class User {
|
|
|
48
48
|
var _a;
|
|
49
49
|
try {
|
|
50
50
|
const res = yield axios.post(this.__url + `/follow`, {}, {
|
|
51
|
-
|
|
52
|
-
Authorization: this.__token ? `Bearer ${this.__token}` : undefined,
|
|
53
|
-
},
|
|
51
|
+
withCredentials: true,
|
|
54
52
|
});
|
|
55
53
|
if (res.status == 200) {
|
|
56
54
|
this.followers += 1;
|
|
@@ -86,9 +84,7 @@ export class User {
|
|
|
86
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
85
|
try {
|
|
88
86
|
const res = yield axios.post(this.__url + `/unfollow`, {}, {
|
|
89
|
-
|
|
90
|
-
Authorization: this.__token ? `Bearer ${this.__token}` : undefined,
|
|
91
|
-
},
|
|
87
|
+
withCredentials: true,
|
|
92
88
|
});
|
|
93
89
|
this.followers -= 1;
|
|
94
90
|
return;
|
|
@@ -120,9 +116,7 @@ export class User {
|
|
|
120
116
|
var _a;
|
|
121
117
|
try {
|
|
122
118
|
const res = yield axios.post(this.__url + `/accept/${request}`, {}, {
|
|
123
|
-
|
|
124
|
-
Authorization: this.__token ? `Bearer ${this.__token}` : undefined,
|
|
125
|
-
}
|
|
119
|
+
withCredentials: true,
|
|
126
120
|
});
|
|
127
121
|
if (res.status == 200) {
|
|
128
122
|
this.followers += 1;
|
|
@@ -159,9 +153,7 @@ export class User {
|
|
|
159
153
|
var _a;
|
|
160
154
|
try {
|
|
161
155
|
const res = yield axios.post(this.__url + `/block`, {}, {
|
|
162
|
-
|
|
163
|
-
Authorization: this.__token ? `Bearer ${this.__token}` : undefined,
|
|
164
|
-
},
|
|
156
|
+
withCredentials: true,
|
|
165
157
|
});
|
|
166
158
|
(_a = this.__session) === null || _a === void 0 ? void 0 : _a.relations.blocklist.push(this.id);
|
|
167
159
|
return;
|
|
@@ -189,9 +181,7 @@ export class User {
|
|
|
189
181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
190
182
|
try {
|
|
191
183
|
const res = yield axios.post(this.__url + `/unblock`, {}, {
|
|
192
|
-
|
|
193
|
-
Authorization: this.__token ? `Bearer ${this.__token}` : undefined,
|
|
194
|
-
},
|
|
184
|
+
withCredentials: true,
|
|
195
185
|
});
|
|
196
186
|
if (this.__session && this.__session.relations) {
|
|
197
187
|
this.__session.relations.blocklist = this.__session.relations.blocklist.filter((item) => item !== this.id);
|