attlaz-client 1.22.4 → 1.23.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.
@@ -0,0 +1,13 @@
1
+ import { State } from '../State.js';
2
+ import { StateAware } from '../StateAware.js';
3
+ export declare class UserNotificationSession implements StateAware {
4
+ id: string;
5
+ session: string;
6
+ subscription: unknown;
7
+ createdAt: Date;
8
+ updatedAt: Date;
9
+ expiresAt: Date;
10
+ state: State;
11
+ os: string;
12
+ browser: string;
13
+ }
@@ -0,0 +1,11 @@
1
+ export class UserNotificationSession {
2
+ id;
3
+ session;
4
+ subscription;
5
+ createdAt;
6
+ updatedAt;
7
+ expiresAt;
8
+ state;
9
+ os;
10
+ browser;
11
+ }
@@ -2,6 +2,8 @@ import { UserAuthProvider } from '../Model/User/UserAuthProvider.js';
2
2
  import { User } from '../Model/User/User.js';
3
3
  import { CollectionResult } from '../Model/Result/CollectionResult.js';
4
4
  import { Endpoint } from './Endpoint.js';
5
+ import { UserNotificationSession } from '../Model/User/UserNotificationSession.js';
6
+ import { CursorPagination } from '../Model/Pagination/CursorPagination.js';
5
7
  export declare class UserEndpoint extends Endpoint {
6
8
  getUser(): Promise<User | null>;
7
9
  removeAuthProvider(providerId: string): Promise<boolean>;
@@ -14,5 +16,6 @@ export declare class UserEndpoint extends Endpoint {
14
16
  create(user: User, password: string, invitationCode?: string | null): Promise<User>;
15
17
  requestResetPassword(email: string): Promise<boolean>;
16
18
  resetPassword(code: string, password: string): Promise<boolean>;
17
- createWebPush(subscription: any, session: string): Promise<boolean>;
19
+ createWebPush(session: UserNotificationSession): Promise<boolean>;
20
+ getSessions(pagination: CursorPagination): Promise<CollectionResult<UserNotificationSession>>;
18
21
  }
@@ -1,6 +1,9 @@
1
1
  import { UserAuthProvider } from '../Model/User/UserAuthProvider.js';
2
2
  import { User } from '../Model/User/User.js';
3
3
  import { Endpoint } from './Endpoint.js';
4
+ import { UserNotificationSession } from '../Model/User/UserNotificationSession.js';
5
+ import { QueryString } from '../Http/Data/QueryString.js';
6
+ import { State } from '../Model/State.js';
4
7
  export class UserEndpoint extends Endpoint {
5
8
  async getUser() {
6
9
  const cmd = '/users';
@@ -111,11 +114,18 @@ export class UserEndpoint extends Endpoint {
111
114
  throw e;
112
115
  }
113
116
  }
114
- async createWebPush(subscription, session) {
117
+ async createWebPush(session) {
115
118
  try {
116
119
  const url = '/webpush';
120
+ const data = {
121
+ session: session.session,
122
+ subscription: session.subscription,
123
+ expires_at: session.expiresAt,
124
+ os: session.os,
125
+ browser: session.browser,
126
+ };
117
127
  const parser = (raw) => ({ created: raw.created });
118
- const result = await this.requestObject(url, { subscription, session }, parser, 'POST', true);
128
+ const result = await this.requestObject(url, data, parser, 'POST', true);
119
129
  const re = result.getData();
120
130
  if (re === null) {
121
131
  console.log('created web push wrong data', { result, parsed: re });
@@ -130,4 +140,22 @@ export class UserEndpoint extends Endpoint {
130
140
  throw e;
131
141
  }
132
142
  }
143
+ async getSessions(pagination) {
144
+ const queryString = new QueryString('/webpush');
145
+ queryString.addPagination(pagination);
146
+ const parser = (raw) => {
147
+ const session = new UserNotificationSession();
148
+ session.id = raw.id;
149
+ session.session = raw.session;
150
+ session.state = State.fromString(raw.state);
151
+ session.createdAt = raw.created_at;
152
+ session.updatedAt = raw.updated_at;
153
+ session.expiresAt = raw.expires_at;
154
+ session.os = raw.os;
155
+ session.browser = raw.browser;
156
+ return session;
157
+ };
158
+ const rawTriggers = await this.requestCollection(queryString, parser);
159
+ return rawTriggers;
160
+ }
133
161
  }
package/dist/index.d.ts CHANGED
@@ -28,6 +28,7 @@ export { AdapterCategory } from './Model/Adapter/AdapterCategory.js';
28
28
  export { AdapterConnectionStatus } from './Model/Adapter/AdapterConnectionStatus.js';
29
29
  export { AdapterConnectionConfigurationValue } from './Model/Adapter/AdapterConnectionConfigurationValue.js';
30
30
  export { AdapterConnectionEvent } from './Model/Adapter/AdapterConnectionEvent.js';
31
+ export { BlockedIp, FlaggedIp, IpRule } from './Service/FirewallEndpoint.js';
31
32
  export { Collection } from './Model/Collections/Collection.js';
32
33
  export { CollectionRecord } from './Model/Collections/CollectionRecord.js';
33
34
  export { EventType } from './Model/Event/EventType.js';
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.22.3";
1
+ export declare const VERSION = "1.22.5";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.22.3";
1
+ export const VERSION = "1.22.5";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.22.4",
3
+ "version": "1.23.0",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -26,6 +26,7 @@
26
26
  "files": [
27
27
  "dist/*"
28
28
  ],
29
+ "sideEffects": false,
29
30
  "author": "Stijn Duynslaeger <stijn@attlaz.com> (stijn@attlaz.com)",
30
31
  "license": "MIT",
31
32
  "scripts": {