@eulab/connect 0.8.0 → 0.8.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/README.md CHANGED
@@ -26,4 +26,8 @@ L'entrypoint server espone `ConnectServer` e `verifyWebhook`:
26
26
  import {ConnectServer, verifyWebhook} from '@eulab/connect/server';
27
27
  ```
28
28
 
29
- Gli export browser e server includono le dichiarazioni TypeScript. Il pacchetto contiene solo JavaScript compilato, tipi e questo README; non contiene credenziali o profili WhatsApp. I segreti dell'installazione devono rimanere sul backend. Il backend deve verificare licenza e permessi per ogni operazione.
29
+ Gli export browser e server includono le dichiarazioni TypeScript. Il pacchetto contiene solo JavaScript compilato, tipi e questo README; non contiene credenziali o profili WhatsApp. I segreti dell’installazione devono rimanere sul backend. Il backend deve verificare licenza e permessi per ogni operazione.
30
+
31
+ `ConnectServer.mirrorUser()` collega un utente locale a Connect. Il campo opzionale `initialPassword` proviene da una verifica locale appena conclusa, serve solo a inizializzare una nuova identità nel provider e non viene conservato da Connect. Non è disponibile nell’SDK browser.
32
+
33
+ Le API `/v1/team` sono esposte da `teamOverview`, `teamUsers`, `teamRoles`, `teamFunctions`, `createTeamRole`, `updateTeamRole`, `deleteTeamRole`, `setTeamUserRoles`, `revokeTeamUser` e `restoreTeamUser`. Cliente e applicazione derivano dall’installazione autenticata; ogni assegnazione resta limitata a funzioni attive, licenziate e presenti nella delega del chiamante. Le operazioni di modifica richiedono `team.manage` nella delega effettiva.
package/dist/browser.d.ts CHANGED
@@ -3,8 +3,8 @@ export type { IVRInput, IVRPrompt, IVRChannel, VoiceIVRSession } from './bot.js'
3
3
  export type { WhatsAppRealtimeEvent, WhatsAppSnapshot, WhatsAppRealtimeStatus, WhatsAppSubscribeOptions, WhatsAppSubscription } from './realtime.js';
4
4
  export type { WhatsAppBotDefinition, WhatsAppBotNode, WhatsAppBotState, WhatsAppBotTurn, WhatsAppBot } from './bot.js';
5
5
  export { defineFunctions, functionsResponse, functionCatalogPath } from './functions.js';
6
- export type { AppFunction, FunctionMatrix, AccessResult, ConnectUser } from './functions.js';
7
- import type { AccessResult, ConnectUser } from './functions.js';
6
+ export type { AppFunction, FunctionMatrix, AccessResult, ConnectUser, TeamFunction, TeamRole, TeamUser, TeamOverview, TeamRoleInput, TeamUserAssignment, TeamRevocation, TeamRestore } from './functions.js';
7
+ import type { AccessResult, ConnectUser, TeamFunction, TeamOverview, TeamRole, TeamRoleInput, TeamUser, TeamUserAssignment, TeamRevocation, TeamRestore } from './functions.js';
8
8
  export type { WhatsAppSession, WhatsAppArchive, Conversation, WhatsAppMessage, WhatsAppPayload } from './whatsapp.js';
9
9
  export interface BrowserConfig {
10
10
  apiUrl: string;
@@ -84,6 +84,18 @@ export declare class ConnectBrowser {
84
84
  can(functionKey: string): boolean;
85
85
  permissions(): Promise<AccessResult>;
86
86
  users(): Promise<ConnectUser[]>;
87
+ teamOverview(): Promise<TeamOverview>;
88
+ teamUsers(): Promise<TeamUser[]>;
89
+ teamRoles(): Promise<TeamRole[]>;
90
+ teamFunctions(): Promise<TeamFunction[]>;
91
+ createTeamRole(role: TeamRoleInput): Promise<TeamRole>;
92
+ updateTeamRole(id: string, role: TeamRoleInput): Promise<TeamRole>;
93
+ deleteTeamRole(id: string): Promise<{
94
+ removed: boolean;
95
+ }>;
96
+ setTeamUserRoles(subject: string, roleIds: string[]): Promise<TeamUserAssignment>;
97
+ revokeTeamUser(subject: string): Promise<TeamRevocation>;
98
+ restoreTeamUser(subject: string): Promise<TeamRestore>;
87
99
  watchAccess(onChange: (access: AccessResult | null) => void, intervalMs?: number): () => void;
88
100
  watchSession(onChange: (valid: boolean | null) => void, intervalMs?: number): () => void;
89
101
  get authenticated(): boolean;
package/dist/browser.js CHANGED
@@ -111,6 +111,16 @@ export class ConnectBrowser {
111
111
  can(functionKey) { return !!this.accessState?.canLogin && this.accessState.functions.some(f => f.key === functionKey); }
112
112
  async permissions() { const result = await this.request('/v1/access'); this.accessState = result; return result; }
113
113
  users() { return this.request('/v1/users'); }
114
+ teamOverview() { return this.request('/v1/team'); }
115
+ teamUsers() { return this.request('/v1/team/users'); }
116
+ teamRoles() { return this.request('/v1/team/roles'); }
117
+ teamFunctions() { return this.request('/v1/team/functions'); }
118
+ createTeamRole(role) { return this.request('/v1/team/roles', 'POST', role); }
119
+ updateTeamRole(id, role) { return this.request('/v1/team/roles/' + encodeURIComponent(id), 'PUT', role); }
120
+ deleteTeamRole(id) { return this.request('/v1/team/roles/' + encodeURIComponent(id), 'DELETE'); }
121
+ setTeamUserRoles(subject, roleIds) { return this.request('/v1/team/users/' + encodeURIComponent(subject) + '/roles', 'PUT', { roleIds }); }
122
+ revokeTeamUser(subject) { return this.request('/v1/team/users/' + encodeURIComponent(subject), 'DELETE'); }
123
+ restoreTeamUser(subject) { return this.request('/v1/team/users/' + encodeURIComponent(subject) + '/restore', 'POST'); }
114
124
  watchAccess(onChange, intervalMs = 30000) { const refresh = async () => { try {
115
125
  if (!await this.checkSession()) {
116
126
  this.accessState = null;
@@ -30,5 +30,63 @@ export interface ConnectUser {
30
30
  name: string;
31
31
  }[];
32
32
  }
33
+ export interface TeamFunction {
34
+ key: string;
35
+ name: string;
36
+ delegable: boolean;
37
+ }
38
+ export interface TeamRole {
39
+ id: string;
40
+ name: string;
41
+ permissions: string[];
42
+ }
43
+ export interface TeamUser {
44
+ subject: string;
45
+ localUserId: string;
46
+ displayName: string;
47
+ identityEnabled: boolean;
48
+ membershipEnabled: boolean;
49
+ accessRevoked: boolean;
50
+ roles: {
51
+ id: string;
52
+ name: string;
53
+ }[];
54
+ }
55
+ export interface TeamOverview {
56
+ installationId: string;
57
+ customerId: string;
58
+ appId: string;
59
+ canManage: boolean;
60
+ functions: TeamFunction[];
61
+ delegation: {
62
+ key: string;
63
+ name: string;
64
+ }[];
65
+ roles: TeamRole[];
66
+ users: TeamUser[];
67
+ }
68
+ export interface TeamRoleInput {
69
+ name: string;
70
+ permissions: string[];
71
+ }
72
+ export interface TeamUserAssignment {
73
+ subject: string;
74
+ localUserId: string;
75
+ roleIds: string[];
76
+ accessRestored: boolean;
77
+ }
78
+ export interface TeamRevocation {
79
+ revoked: boolean;
80
+ subject: string;
81
+ localUserId: string;
82
+ identityPreserved: boolean;
83
+ membershipPreserved: boolean;
84
+ otherApplicationsPreserved: boolean;
85
+ }
86
+ export interface TeamRestore {
87
+ restored: boolean;
88
+ subject: string;
89
+ localUserId: string;
90
+ }
33
91
  export declare function defineFunctions(input: Omit<FunctionMatrix, 'schemaVersion'>): FunctionMatrix;
34
92
  export declare function functionsResponse(matrix: FunctionMatrix): Response;
package/dist/server.d.ts CHANGED
@@ -3,14 +3,15 @@ export type { IVRInput, IVRPrompt, IVRChannel, VoiceIVRSession } from './bot.js'
3
3
  export type { WhatsAppRealtimeEvent, WhatsAppSnapshot, WhatsAppRealtimeStatus, WhatsAppSubscribeOptions, WhatsAppSubscription } from './realtime.js';
4
4
  export type { WhatsAppBotDefinition, WhatsAppBotNode, WhatsAppBotState, WhatsAppBotTurn, WhatsAppBot } from './bot.js';
5
5
  export { defineFunctions, functionsResponse, functionCatalogPath } from './functions.js';
6
- export type { AppFunction, FunctionMatrix, AccessResult, ConnectUser } from './functions.js';
7
- import type { AccessResult, ConnectUser } from './functions.js';
6
+ export type { AppFunction, FunctionMatrix, AccessResult, ConnectUser, TeamFunction, TeamRole, TeamUser, TeamOverview, TeamRoleInput, TeamUserAssignment, TeamRevocation, TeamRestore } from './functions.js';
7
+ import type { AccessResult, ConnectUser, TeamFunction, TeamOverview, TeamRole, TeamRoleInput, TeamUser, TeamUserAssignment, TeamRevocation, TeamRestore } from './functions.js';
8
8
  export type { WhatsAppSession, WhatsAppArchive, Conversation, WhatsAppMessage, WhatsAppPayload } from './whatsapp.js';
9
9
  export interface LocalUserProfile {
10
10
  localUserId: string;
11
11
  username: string;
12
12
  email: string;
13
13
  displayName: string;
14
+ initialPassword?: string;
14
15
  }
15
16
  export interface MirroredUser {
16
17
  installationId: string;
@@ -119,7 +120,27 @@ export declare class ConnectServer {
119
120
  }>;
120
121
  };
121
122
  registerFunctions(url?: string): Promise<any>;
123
+ /**
124
+ * Crea o recupera l'identità centrale collegata all'utente locale.
125
+ *
126
+ * `initialPassword` deve provenire da una verifica locale appena conclusa e viene usata
127
+ * soltanto per inizializzare una nuova identità nel provider. Non viene conservata da
128
+ * Connect, non compare nelle risposte e non viene applicata a identità già esistenti.
129
+ * Le chiamate esistenti senza il campo mantengono il comportamento precedente.
130
+ */
122
131
  mirrorUser(user: LocalUserProfile): Promise<MirroredUser>;
132
+ teamOverview(accessToken: string): Promise<TeamOverview>;
133
+ teamUsers(accessToken: string): Promise<TeamUser[]>;
134
+ teamRoles(accessToken: string): Promise<TeamRole[]>;
135
+ teamFunctions(accessToken: string): Promise<TeamFunction[]>;
136
+ createTeamRole(accessToken: string, role: TeamRoleInput): Promise<TeamRole>;
137
+ updateTeamRole(accessToken: string, id: string, role: TeamRoleInput): Promise<TeamRole>;
138
+ deleteTeamRole(accessToken: string, id: string): Promise<{
139
+ removed: boolean;
140
+ }>;
141
+ setTeamUserRoles(accessToken: string, subject: string, roleIds: string[]): Promise<TeamUserAssignment>;
142
+ revokeTeamUser(accessToken: string, subject: string): Promise<TeamRevocation>;
143
+ restoreTeamUser(accessToken: string, subject: string): Promise<TeamRestore>;
123
144
  permissions(accessToken: string): Promise<AccessResult>;
124
145
  notifications(accessToken: string, options?: {
125
146
  unread?: boolean;
package/dist/server.js CHANGED
@@ -26,7 +26,25 @@ export class ConnectServer {
26
26
  whatsapp(accessToken) { return whatsappClient(async (path, method, body, extra) => this.request(path, method, body, typeof accessToken === 'function' ? await accessToken() : accessToken, extra), this.config.installationId, { apiUrl: this.config.apiUrl }); }
27
27
  registerFunctions(url) { const source = url || this.config.catalogUrl || (this.config.domain ? this.config.domain + (this.config.basePath || '') + functionCatalogPath : undefined); if (!source)
28
28
  throw new Error('URL funzioni o dominio richiesto'); return this.request('/v1/catalog-source', 'POST', { url: source }); }
29
+ /**
30
+ * Crea o recupera l'identità centrale collegata all'utente locale.
31
+ *
32
+ * `initialPassword` deve provenire da una verifica locale appena conclusa e viene usata
33
+ * soltanto per inizializzare una nuova identità nel provider. Non viene conservata da
34
+ * Connect, non compare nelle risposte e non viene applicata a identità già esistenti.
35
+ * Le chiamate esistenti senza il campo mantengono il comportamento precedente.
36
+ */
29
37
  mirrorUser(user) { return this.request('/v1/users/mirror', 'POST', user); }
38
+ teamOverview(accessToken) { return this.request('/v1/team', 'GET', undefined, accessToken); }
39
+ teamUsers(accessToken) { return this.request('/v1/team/users', 'GET', undefined, accessToken); }
40
+ teamRoles(accessToken) { return this.request('/v1/team/roles', 'GET', undefined, accessToken); }
41
+ teamFunctions(accessToken) { return this.request('/v1/team/functions', 'GET', undefined, accessToken); }
42
+ createTeamRole(accessToken, role) { return this.request('/v1/team/roles', 'POST', role, accessToken); }
43
+ updateTeamRole(accessToken, id, role) { return this.request('/v1/team/roles/' + encodeURIComponent(id), 'PUT', role, accessToken); }
44
+ deleteTeamRole(accessToken, id) { return this.request('/v1/team/roles/' + encodeURIComponent(id), 'DELETE', undefined, accessToken); }
45
+ setTeamUserRoles(accessToken, subject, roleIds) { return this.request('/v1/team/users/' + encodeURIComponent(subject) + '/roles', 'PUT', { roleIds }, accessToken); }
46
+ revokeTeamUser(accessToken, subject) { return this.request('/v1/team/users/' + encodeURIComponent(subject), 'DELETE', undefined, accessToken); }
47
+ restoreTeamUser(accessToken, subject) { return this.request('/v1/team/users/' + encodeURIComponent(subject) + '/restore', 'POST', undefined, accessToken); }
30
48
  permissions(accessToken) { return this.request('/v1/access', 'GET', undefined, accessToken); }
31
49
  notifications(accessToken, options = {}) { const query = new URLSearchParams(); for (const [key, value] of Object.entries(options))
32
50
  if (value !== undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eulab/connect",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "SDK EULab Connect per browser e server: SSO, permessi e WhatsApp",
5
5
  "author": "EULAB",
6
6
  "type": "module",