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 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, NotificationGroup, NotificationSingle, NotificationWarn, NotificationBan } from './models/types/inbox.js';
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
- headers: {
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
- headers: {
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
- headers: {
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
- headers: {
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
- headers: {
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
- headers: {
220
- Authorization: this.token ? `Bearer ${this.token}` : undefined,
221
- },
211
+ withCredentials: true,
222
212
  });
223
213
  const data = res.data;
224
214
  const posts = [];
@@ -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
- headers: {
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
- headers: {
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
- headers: {
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 = NotificationGroup | NotificationSingle | NotificationWarn | NotificationBan;
19
+ export type Notification = NotificationSingle | NotificationWarn | NotificationBan;
24
20
  export type Inbox = {
25
21
  id: string;
26
22
  requests: {
@@ -23,6 +23,8 @@ export type Settings = {
23
23
  };
24
24
  appearance: {
25
25
  global_theme: string;
26
+ high_contrast: boolean;
27
+ color_blind_mode: boolean;
26
28
  };
27
29
  };
28
30
  export type Relations = {
@@ -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
- headers: {
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
- headers: {
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
- headers: {
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
- headers: {
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
- headers: {
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "beamsocial",
3
- "version": "0.10.1",
3
+ "version": "0.11.1",
4
4
  "type": "module",
5
5
  "description": "API-wrapper pour Beam",
6
6
  "main": "index.js",