@im-more/dsh-matrix 0.0.0-stage → 0.1.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.
Files changed (86) hide show
  1. package/LICENSE +21 -0
  2. package/cordis.patch.yml +14 -0
  3. package/lib/index.js +2401 -0
  4. package/lib/index.js.map +1 -0
  5. package/lib/types/as.d.ts +33 -0
  6. package/lib/types/as.d.ts.map +1 -0
  7. package/lib/types/as.js +237 -0
  8. package/lib/types/as.js.map +1 -0
  9. package/lib/types/bot.d.ts +109 -0
  10. package/lib/types/bot.d.ts.map +1 -0
  11. package/lib/types/bot.js +234 -0
  12. package/lib/types/bot.js.map +1 -0
  13. package/lib/types/config.d.ts +59 -0
  14. package/lib/types/config.d.ts.map +1 -0
  15. package/lib/types/config.js +67 -0
  16. package/lib/types/config.js.map +1 -0
  17. package/lib/types/decode.d.ts +56 -0
  18. package/lib/types/decode.d.ts.map +1 -0
  19. package/lib/types/decode.js +298 -0
  20. package/lib/types/decode.js.map +1 -0
  21. package/lib/types/errors.d.ts +45 -0
  22. package/lib/types/errors.d.ts.map +1 -0
  23. package/lib/types/errors.js +120 -0
  24. package/lib/types/errors.js.map +1 -0
  25. package/lib/types/html.d.ts +44 -0
  26. package/lib/types/html.d.ts.map +1 -0
  27. package/lib/types/html.js +286 -0
  28. package/lib/types/html.js.map +1 -0
  29. package/lib/types/identity.d.ts +20 -0
  30. package/lib/types/identity.d.ts.map +1 -0
  31. package/lib/types/identity.js +136 -0
  32. package/lib/types/identity.js.map +1 -0
  33. package/lib/types/index.d.ts +5 -0
  34. package/lib/types/index.d.ts.map +1 -0
  35. package/lib/types/index.js +5 -0
  36. package/lib/types/index.js.map +1 -0
  37. package/lib/types/media.d.ts +54 -0
  38. package/lib/types/media.d.ts.map +1 -0
  39. package/lib/types/media.js +94 -0
  40. package/lib/types/media.js.map +1 -0
  41. package/lib/types/mentions.d.ts +58 -0
  42. package/lib/types/mentions.d.ts.map +1 -0
  43. package/lib/types/mentions.js +94 -0
  44. package/lib/types/mentions.js.map +1 -0
  45. package/lib/types/modes/html.d.ts +13 -0
  46. package/lib/types/modes/html.d.ts.map +1 -0
  47. package/lib/types/modes/html.js +242 -0
  48. package/lib/types/modes/html.js.map +1 -0
  49. package/lib/types/modes/shared.d.ts +164 -0
  50. package/lib/types/modes/shared.d.ts.map +1 -0
  51. package/lib/types/modes/shared.js +312 -0
  52. package/lib/types/modes/shared.js.map +1 -0
  53. package/lib/types/request.d.ts +82 -0
  54. package/lib/types/request.d.ts.map +1 -0
  55. package/lib/types/request.js +206 -0
  56. package/lib/types/request.js.map +1 -0
  57. package/lib/types/rooms.d.ts +83 -0
  58. package/lib/types/rooms.d.ts.map +1 -0
  59. package/lib/types/rooms.js +177 -0
  60. package/lib/types/rooms.js.map +1 -0
  61. package/lib/types/send.d.ts +76 -0
  62. package/lib/types/send.d.ts.map +1 -0
  63. package/lib/types/send.js +172 -0
  64. package/lib/types/send.js.map +1 -0
  65. package/lib/types/types.d.ts +418 -0
  66. package/lib/types/types.d.ts.map +1 -0
  67. package/lib/types/types.js +134 -0
  68. package/lib/types/types.js.map +1 -0
  69. package/package.json +65 -3
  70. package/src/as.ts +293 -0
  71. package/src/bot.ts +338 -0
  72. package/src/config.ts +100 -0
  73. package/src/decode.ts +392 -0
  74. package/src/errors.ts +149 -0
  75. package/src/html.ts +325 -0
  76. package/src/identity.ts +165 -0
  77. package/src/index.ts +14 -0
  78. package/src/media.ts +132 -0
  79. package/src/mentions.ts +134 -0
  80. package/src/modes/html.ts +346 -0
  81. package/src/modes/shared.ts +485 -0
  82. package/src/request.ts +295 -0
  83. package/src/rooms.ts +232 -0
  84. package/src/send.ts +275 -0
  85. package/src/types.ts +633 -0
  86. package/README.md +0 -3
package/src/types.ts ADDED
@@ -0,0 +1,633 @@
1
+ import imageSize from 'image-size'
2
+ import type { Dict } from '@deepseek-ai/cordis-plugin-im-core'
3
+ import type { MatrixBot } from './bot.ts'
4
+
5
+ export interface Transaction {
6
+ txnId: string
7
+ events: ClientEvent[]
8
+ }
9
+
10
+ export interface ClientEvent {
11
+ content: EventContent
12
+ event_id: string
13
+ origin_server_ts: number
14
+ redacts?: string
15
+ room_id: string
16
+ sender: string
17
+ state_key?: string
18
+ type: string
19
+ unsigned?: UnsignedData
20
+ }
21
+
22
+ export interface UnsignedData {
23
+ age?: number
24
+ prev_content?: EventContent
25
+ redacted_because?: ClientEvent
26
+ transaction_id?: string
27
+ }
28
+
29
+ export interface PreviousRoom {
30
+ event_id: string
31
+ room_id: string
32
+ }
33
+
34
+ export interface AllowCondition {
35
+ room_id?: string
36
+ type: 'm.room_membership'
37
+ }
38
+
39
+ export interface Invite {
40
+ display_name: string
41
+ signed: Signed
42
+ }
43
+
44
+ export interface Signed {
45
+ mxid: string
46
+ // signatures: Signatures
47
+ signatures: any
48
+ token: string
49
+ }
50
+
51
+ export interface Notifications {
52
+ room?: number
53
+ }
54
+
55
+ export interface ThumbnailInfo {
56
+ h?: number
57
+ mimetype?: string
58
+ size?: number
59
+ w?: number
60
+ }
61
+
62
+ export interface ImageInfo {
63
+ h?: number
64
+ mimetype?: string
65
+ size?: number
66
+ // thumbnail_file?: EncryptedFile // end to end only
67
+ thumbnail_file?: any
68
+ thumbnail_info?: ThumbnailInfo
69
+ thumbnail_url?: string
70
+ w?: number
71
+ }
72
+
73
+ export interface FileInfo {
74
+ mimetype?: string
75
+ size?: number
76
+ // thumbnail_file?: EncryptedFile // end to end only
77
+ thumbnail_file?: any
78
+ thumbnail_info?: ThumbnailInfo
79
+ thumbnail_url?: string
80
+ }
81
+
82
+ export interface AudioInfo {
83
+ duration?: number
84
+ mimetype?: string
85
+ size?: number
86
+ }
87
+
88
+ export interface LocationInfo {
89
+ // thumbnail_file?: EncryptedFile // end to end only
90
+ thumbnail_file?: any
91
+ thumbnail_info?: ThumbnailInfo
92
+ thumbnail_url?: string
93
+ }
94
+
95
+ export interface VideoInfo {
96
+ duration?: number
97
+ h?: number
98
+ mimetype?: string
99
+ size?: number
100
+ // thumbnail_file?: EncryptedFile // end to end only
101
+ thumbnail_file?: any
102
+ thumbnail_info?: ThumbnailInfo
103
+ thumbnail_url?: string
104
+ w?: number
105
+ }
106
+
107
+ export interface PublicKeys {
108
+ key_validity_url?: string
109
+ public_key: string
110
+ }
111
+
112
+ export interface Profile {
113
+ avatar_url?: string
114
+ displayname?: string
115
+ }
116
+
117
+ export interface User {
118
+ access_token?: string
119
+ device_id?: string
120
+ user_id?: string
121
+ }
122
+
123
+ export interface Sync {
124
+ account_data?: AccountData
125
+ // device_lists? // end to end
126
+ // device_one_time_keys_count? // end to end
127
+ next_batch: string
128
+ presence?: Presence
129
+ rooms?: Rooms
130
+ // to_device? // end to end
131
+ }
132
+
133
+ export interface AccountData {
134
+ events?: ClientEvent[]
135
+ }
136
+
137
+ export interface Presence {
138
+ events?: ClientEvent[]
139
+ }
140
+
141
+ export interface Rooms {
142
+ invite?: Dict<InvitedRoom>
143
+ join?: Dict<JoinedRoom>
144
+ knock?: Dict<KnockedRoom>
145
+ leave?: Dict<LeftRoom>
146
+ }
147
+
148
+ export interface InvitedRoom {
149
+ invite_state?: InviteState
150
+ }
151
+
152
+ export interface InviteState {
153
+ events?: ClientEvent[]
154
+ }
155
+
156
+ export interface JoinedRoom {
157
+ account_data?: AccountData
158
+ ephemeral?: Ephemeral
159
+ state?: State
160
+ summary?: RoomSummary
161
+ timeline?: Timeline
162
+ unread_notifications?: UnreadNotificationCounts
163
+ unread_thread_notifications?: Dict<ThreadNotificationCounts>
164
+ }
165
+
166
+ export interface Ephemeral {
167
+ events?: ClientEvent[]
168
+ }
169
+
170
+ export interface State {
171
+ events?: ClientEvent[]
172
+ }
173
+
174
+ export interface RoomSummary {
175
+ 'm.heroes'?: string[]
176
+ 'm.invited_member_count'?: number
177
+ 'm.joined_member_count'?: number
178
+ }
179
+
180
+ export interface Timeline {
181
+ events: ClientEvent[]
182
+ limited?: boolean
183
+ prev_batch?: string
184
+ }
185
+
186
+ export interface UnreadNotificationCounts {
187
+ highlight_count?: number
188
+ notification_count?: number
189
+ }
190
+
191
+ export interface ThreadNotificationCounts {
192
+ highlight_count?: number
193
+ notification_count?: number
194
+ }
195
+
196
+ export interface KnockedRoom {
197
+ knock_state?: KnockState
198
+ }
199
+
200
+ export interface KnockState {
201
+ events?: ClientEvent[]
202
+ }
203
+
204
+ export interface LeftRoom {
205
+ account_data?: AccountData
206
+ state?: State
207
+ timeline?: Timeline
208
+ }
209
+
210
+ export interface Invite3pid {
211
+ address: string
212
+ id_access_token: string
213
+ id_server: string
214
+ medium: string
215
+ }
216
+
217
+ export interface StateEvent {
218
+ content: EventContent
219
+ state_key?: string
220
+ type: string
221
+ }
222
+
223
+ export interface RoomCreation {
224
+ creation_content?: Partial<M_ROOM_CREATE>
225
+ initial_state?: StateEvent[]
226
+ invite?: string[]
227
+ invite_3pid?: Invite3pid
228
+ is_direct?: boolean
229
+ name: string
230
+ power_level_content_override?: M_ROOM_POWER_LEVELS
231
+ preset?: 'private_chat' | 'public_chat' | 'trusted_private_chat'
232
+ room_alias_name?: string
233
+ room_version?: string
234
+ topic?: string
235
+ visibility?: 'public' | 'private'
236
+ }
237
+
238
+ export interface EventContent {}
239
+
240
+ export interface Relation {
241
+ event_id?: string
242
+ rel_type?: string
243
+ 'm.in_reply_to'?: {
244
+ event_id: string
245
+ }
246
+ }
247
+
248
+ export interface M_ROOM_CANONICAL_ALIAS extends EventContent {
249
+ alias?: string
250
+ alt_aliases?: string[]
251
+ }
252
+
253
+ export interface M_ROOM_CREATE extends EventContent {
254
+ creator: string
255
+ 'm.federate'?: boolean
256
+ predecessor?: PreviousRoom
257
+ room_version?: string
258
+ type?: string
259
+ }
260
+
261
+ export interface M_ROOM_JOIN_RULES extends EventContent {
262
+ allow?: AllowCondition[]
263
+ join_rule?: 'public' | 'knock' | 'invite' | 'private' | 'restricted'
264
+ }
265
+
266
+ export interface M_ROOM_MEMBER extends EventContent {
267
+ avatar_url?: string
268
+ displayname?: string
269
+ is_direct?: boolean
270
+ join_authorised_via_users_server?: string
271
+ membership?: 'invite' | 'join' | 'knock' | 'leave' | 'ban'
272
+ reason?: string
273
+ third_party_invite?: Invite
274
+ }
275
+
276
+ export interface M_ROOM_POWER_LEVELS extends EventContent {
277
+ ban?: number
278
+ events?: Record<string, number>
279
+ events_default?: number
280
+ invite?: number
281
+ kick?: number
282
+ notifications?: Notifications
283
+ redact?: number
284
+ state_default?: number
285
+ users?: Record<string, number>
286
+ users_default?: number
287
+ }
288
+
289
+ export interface M_ROOM_REDACTION extends EventContent {
290
+ reason?: string
291
+ }
292
+
293
+ export interface M_ROOM_MESSAGE extends EventContent {
294
+ body: string
295
+ msgtype: string
296
+ 'm.relates_to'?: Relation
297
+ 'm.new_content'?: M_ROOM_MESSAGE
298
+ }
299
+
300
+ export interface M_ROOM_MESSAGE_FEEDBACK extends EventContent {
301
+ target_event_id: string
302
+ type: 'delivered' | 'read'
303
+ }
304
+
305
+ export interface M_ROOM_NAME extends EventContent {
306
+ name: string
307
+ }
308
+
309
+ export interface M_ROOM_TOPIC extends EventContent {
310
+ topic: string
311
+ }
312
+
313
+ export interface M_ROOM_AVATAR extends EventContent {
314
+ info?: ImageInfo
315
+ url: string
316
+ }
317
+
318
+ export interface M_ROOM_PINNED_EVENTS extends EventContent {
319
+ pinned: string[]
320
+ }
321
+
322
+ export interface M_TEXT extends M_ROOM_MESSAGE {
323
+ body: string
324
+ format?: 'org.matrix.custom.html'
325
+ formatted_body?: string
326
+ msgtype: 'm.text'
327
+ }
328
+
329
+ export interface M_EMOTE extends M_ROOM_MESSAGE {
330
+ body: string
331
+ format?: 'org.matrix.custom.html'
332
+ formatted_body?: string
333
+ msgtype: 'm.emote'
334
+ }
335
+
336
+ export interface M_NOTICE extends M_ROOM_MESSAGE {
337
+ body: string
338
+ format?: 'org.matrix.custom.html'
339
+ formatted_body?: string
340
+ msgtype: 'm.notice'
341
+ }
342
+
343
+ export interface M_IMAGE extends M_ROOM_MESSAGE {
344
+ body: string
345
+ // file?: EncryptedFile // end to end only
346
+ file?: any
347
+ info?: ImageInfo
348
+ msgtype: 'm.image'
349
+ url?: string
350
+ }
351
+
352
+ export interface M_FILE extends M_ROOM_MESSAGE {
353
+ body: string
354
+ // file?: EncryptedFile // end to end only
355
+ file?: any
356
+ filename?: string
357
+ info?: FileInfo
358
+ msgtype: 'm.file'
359
+ url?: string
360
+ }
361
+
362
+ export interface M_AUDIO extends M_ROOM_MESSAGE {
363
+ body: string
364
+ // file?: EncryptedFile // end to end only
365
+ file?: any
366
+ filename?: string
367
+ info?: AudioInfo
368
+ msgtype: 'm.audio'
369
+ url?: string
370
+ }
371
+
372
+ export interface M_LOCATION extends M_ROOM_MESSAGE {
373
+ body: string
374
+ geo_uri: string
375
+ info?: LocationInfo
376
+ msgtype: 'm.location'
377
+ }
378
+
379
+ export interface M_VIDEO extends M_ROOM_MESSAGE {
380
+ body: string
381
+ // file?: EncryptedFile // end to end only
382
+ file?: any
383
+ info?: VideoInfo
384
+ msgtype: 'm.video'
385
+ url?: string
386
+ }
387
+
388
+ export interface M_TYPING extends EventContent {
389
+ user_ids: string[]
390
+ }
391
+
392
+ export interface M_RECEIPT extends EventContent { }
393
+
394
+ export interface M_FULLY_READ extends EventContent {
395
+ event_id: string
396
+ }
397
+
398
+ export interface M_PRESENCE extends EventContent {
399
+ avatar_url?: string
400
+ currently_actice?: boolean
401
+ displayname?: string
402
+ last_active_ago?: number
403
+ presence?: 'online' | 'offline' | 'unavailable'
404
+ status_msg?: string
405
+ }
406
+
407
+ export interface M_ROOM_HISTORY_VISIBILITY extends EventContent {
408
+ history_visibility: 'invited' | 'joined' | 'shared' | 'world_readable'
409
+ }
410
+
411
+ export interface M_ROOM_THIRD_PATRY_INVITE extends EventContent {
412
+ display_name: string
413
+ key_validity_url: string
414
+ public_key: string
415
+ public_keys: PublicKeys[]
416
+ }
417
+
418
+ export interface M_ROOM_GUEST_ACCESS extends EventContent {
419
+ guest_access: 'can_join' | 'forbidden'
420
+ }
421
+
422
+ export interface M_IGNORED_USER_LIST extends EventContent {
423
+ ignored_users: Record<string, any>
424
+ }
425
+
426
+ export interface M_STICKER extends EventContent {
427
+ body: string
428
+ info: ImageInfo
429
+ url: string
430
+ }
431
+
432
+ export interface M_ROOM_SERVER_ACL extends EventContent {
433
+ allow?: string[]
434
+ allow_ip_literals?: boolean
435
+ deny?: string[]
436
+ }
437
+
438
+ export interface M_ROOM_TOMBSTONE extends EventContent {
439
+ body: string
440
+ replacement_room: string
441
+ }
442
+
443
+ export interface M_POLICY_RULE_USER extends EventContent {
444
+ entity: string
445
+ reason: string
446
+ recommendation: string
447
+ }
448
+
449
+ export interface M_POLICY_RULE_ROOM extends EventContent {
450
+ entity: string
451
+ reason: string
452
+ recommendation: string
453
+ }
454
+
455
+ export interface M_POLICY_RULE_SERVER extends EventContent {
456
+ entity: string
457
+ reason: string
458
+ recommendation: string
459
+ }
460
+
461
+ export interface M_SPACE_CHILD extends EventContent {
462
+ order?: string
463
+ suggested?: boolean
464
+ via?: string[]
465
+ }
466
+
467
+ export interface M_SPACE_PARENT extends EventContent {
468
+ canonical?: boolean
469
+ via?: string[]
470
+ }
471
+
472
+ export interface M_ANNOTATION extends Relation {
473
+ rel_type: 'm.annotation'
474
+ key: string
475
+ }
476
+
477
+ export interface M_REACTION extends EventContent {
478
+ 'm.relates_to'?: M_ANNOTATION
479
+ }
480
+
481
+ export class Internal {
482
+ private txnId = Math.round(Math.random() * 1000)
483
+
484
+ constructor(public bot: MatrixBot) {}
485
+
486
+ async uploadFile(filename: string, buffer: Buffer, mimetype?: string): Promise<string> {
487
+ const headers: Record<string, string> = {}
488
+ if (mimetype) headers['content-type'] = mimetype
489
+ return (await this.bot.http.post(`/media/v3/upload?filename=${filename}`, buffer, { headers })).content_uri
490
+ }
491
+
492
+ async sendTextMessage(roomId: string, content: string, reply?: string): Promise<string> {
493
+ const eventContent: M_TEXT = {
494
+ msgtype: 'm.text',
495
+ body: content,
496
+ }
497
+ if (reply) eventContent['m.relates_to'] = { 'm.in_reply_to': { 'event_id': reply } }
498
+ const response = await this.bot.http.put(
499
+ `/client/v3/rooms/${roomId}/send/m.room.message/${this.txnId++}`, eventContent)
500
+ return response.event_id
501
+ }
502
+
503
+ async sendMediaMessage(
504
+ roomId: string, type: 'file' | 'image' | 'video' | 'audio',
505
+ buffer: Buffer, reply?: string, mimetype?: string, filename: string = 'file',
506
+ ): Promise<string> {
507
+ const uri = await this.uploadFile(filename, buffer, mimetype)
508
+ let info: ImageInfo | undefined
509
+ if (type === 'image') {
510
+ const { width, height } = imageSize(buffer)
511
+ info = {
512
+ size: buffer.byteLength,
513
+ h: height,
514
+ w: width,
515
+ ...(mimetype === undefined ? {} : { mimetype }),
516
+ }
517
+ }
518
+ const eventContent: Record<string, unknown> = {
519
+ msgtype: `m.${type}`,
520
+ body: filename,
521
+ url: uri,
522
+ ...(info === undefined ? {} : { info }),
523
+ }
524
+ if (reply) eventContent['m.relates_to'] = { 'm.in_reply_to': { 'event_id': reply } }
525
+ const response = await this.bot.http.put(
526
+ `/client/v3/rooms/${roomId}/send/m.room.message/${this.txnId++}`, eventContent)
527
+ return response.event_id
528
+ }
529
+
530
+ async sendReaction(roomId: string, messageId: string, key: string): Promise<string> {
531
+ const eventContent: M_REACTION = {
532
+ 'm.relates_to': {
533
+ rel_type: 'm.annotation',
534
+ event_id: messageId,
535
+ key,
536
+ },
537
+ }
538
+ const response = await this.bot.http.put(
539
+ `/client/v3/rooms/${roomId}/send/m.reaction/${this.txnId++}`, eventContent)
540
+ return response.event_id
541
+ }
542
+
543
+ async getEvent(roomId: string, eventId: string): Promise<ClientEvent> {
544
+ return await this.bot.http.get(`/client/v3/rooms/${roomId}/event/${eventId}`)
545
+ }
546
+
547
+ async redactEvent(roomId: string, eventId: string, reason?: string): Promise<string> {
548
+ const event = await this.bot.http.put(`/client/v3/rooms/${roomId}/redact/${eventId}/${this.txnId++}`, { reason })
549
+ return event.event_id
550
+ }
551
+
552
+ async getProfile(userId: string): Promise<Profile> {
553
+ return await this.bot.http.get(`/client/v3/profile/${userId}`)
554
+ }
555
+
556
+ async setDisplayName(userId: string, displayname: string): Promise<void> {
557
+ await this.bot.http.put(`/client/v3/profile/${userId}/displayname`, { displayname })
558
+ }
559
+
560
+ async setAvatar(userId: string, buffer: Buffer, mimetype: string): Promise<void> {
561
+ const uri = await this.uploadFile('avatar', buffer, mimetype)
562
+ await this.bot.http.put(`/client/v3/profile/${userId}/avatar_url`, { avatar_url: uri })
563
+ }
564
+
565
+ async createRoom(creation: RoomCreation): Promise<string> {
566
+ const response = await this.bot.http.post('/client/v3/createRoom', creation)
567
+ return response.room_id
568
+ }
569
+
570
+ async joinRoom(roomId: string, reason?: string): Promise<string> {
571
+ const response = await this.bot.http.post(`/client/v3/join/${roomId}`, { reason })
572
+ return response.room_id
573
+ }
574
+
575
+ async leaveRoom(roomId: string, reason?: string): Promise<string> {
576
+ const response = await this.bot.http.post(`/client/v3/rooms/${roomId}/leave`, { reason })
577
+ return response.room_id
578
+ }
579
+
580
+ async invite(roomId: string, userId: string, reason?: string): Promise<void> {
581
+ await this.bot.http.post(`/client/v3/rooms/${roomId}/invite`, { user_id: userId, reason })
582
+ }
583
+
584
+ async sync(fullSstate: boolean = false): Promise<Sync> {
585
+ return await this.bot.http.get('/client/v3/sync', {
586
+ params: { full_state: fullSstate },
587
+ })
588
+ }
589
+
590
+ async getState(roomId: string): Promise<ClientEvent[]> {
591
+ return await this.bot.http.get(`/client/v3/rooms/${roomId}/state`)
592
+ }
593
+
594
+ async setState(roomId: string, eventType: string, event: EventContent, state?: string): Promise<string> {
595
+ const statePath = state ? `/${state}` : ''
596
+ const response = await this.bot.http.put(`/client/v3/rooms/${roomId}/state/${eventType}${statePath}`, event)
597
+ return response.event_id
598
+ }
599
+
600
+ async getJoinedRooms(): Promise<string[]> {
601
+ return await this.bot.http.get('/client/v3/joined_rooms')
602
+ }
603
+
604
+ async register(username: string, asToken: string): Promise<User> {
605
+ return await this.bot.ctx.http.post(this.bot.endpoint + '/client/v3/register', {
606
+ type: 'm.login.application_service',
607
+ username,
608
+ }, {
609
+ headers: {
610
+ 'Authorization': `Bearer ${asToken}`,
611
+ },
612
+ })
613
+ }
614
+
615
+ async login(username: string, asToken: string): Promise<User> {
616
+ return await this.bot.ctx.http.post(this.bot.endpoint + '/client/v3/login', {
617
+ type: 'm.login.application_service',
618
+ identifier: {
619
+ type: 'm.id.user',
620
+ user: username,
621
+ },
622
+ }, {
623
+ headers: {
624
+ 'Authorization': `Bearer ${asToken}`,
625
+ },
626
+ })
627
+ }
628
+
629
+ getAssetUrl(mxc: string) {
630
+ // mxc://
631
+ return `${this.bot.endpoint}/client/v1/media/download/${mxc.substring(6)}`
632
+ }
633
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.