@oxyhq/core 3.18.1 → 4.0.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.
- package/dist/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/OxyServices.js +3 -2
- package/dist/cjs/mixins/OxyServices.accounts.js +480 -0
- package/dist/cjs/mixins/OxyServices.connectedApps.js +73 -0
- package/dist/cjs/mixins/OxyServices.utility.js +3 -2
- package/dist/cjs/mixins/index.js +9 -6
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/OxyServices.js +3 -2
- package/dist/esm/mixins/OxyServices.accounts.js +477 -0
- package/dist/esm/mixins/OxyServices.connectedApps.js +70 -0
- package/dist/esm/mixins/OxyServices.utility.js +3 -2
- package/dist/esm/mixins/index.js +9 -6
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/OxyServices.d.ts +3 -2
- package/dist/types/index.d.ts +2 -3
- package/dist/types/mixins/OxyServices.accounts.d.ts +642 -0
- package/dist/types/mixins/OxyServices.auth.d.ts +1 -1
- package/dist/types/mixins/OxyServices.connectedApps.d.ts +168 -0
- package/dist/types/mixins/OxyServices.utility.d.ts +6 -3
- package/dist/types/mixins/index.d.ts +3 -4
- package/package.json +1 -1
- package/src/OxyServices.ts +3 -2
- package/src/index.ts +33 -34
- package/src/mixins/OxyServices.accounts.ts +1079 -0
- package/src/mixins/OxyServices.auth.ts +1 -1
- package/src/mixins/OxyServices.connectedApps.ts +165 -0
- package/src/mixins/OxyServices.utility.ts +7 -4
- package/src/mixins/__tests__/accounts.test.ts +667 -0
- package/src/mixins/__tests__/connectedApps.test.ts +1 -1
- package/src/mixins/index.ts +11 -9
- package/dist/cjs/mixins/OxyServices.applications.js +0 -350
- package/dist/cjs/mixins/OxyServices.managedAccounts.js +0 -143
- package/dist/cjs/mixins/OxyServices.workspaces.js +0 -181
- package/dist/esm/mixins/OxyServices.applications.js +0 -347
- package/dist/esm/mixins/OxyServices.managedAccounts.js +0 -140
- package/dist/esm/mixins/OxyServices.workspaces.js +0 -178
- package/dist/types/mixins/OxyServices.applications.d.ts +0 -496
- package/dist/types/mixins/OxyServices.managedAccounts.d.ts +0 -145
- package/dist/types/mixins/OxyServices.workspaces.d.ts +0 -219
- package/src/mixins/OxyServices.applications.ts +0 -773
- package/src/mixins/OxyServices.managedAccounts.ts +0 -173
- package/src/mixins/OxyServices.workspaces.ts +0 -351
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import { CACHE_TIMES } from './mixinHelpers.js';
|
|
2
|
-
export function OxyServicesWorkspacesMixin(Base) {
|
|
3
|
-
return class extends Base {
|
|
4
|
-
constructor(...args) {
|
|
5
|
-
super(...args);
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* List workspaces the current user is an active member of.
|
|
9
|
-
*/
|
|
10
|
-
async getWorkspaces() {
|
|
11
|
-
try {
|
|
12
|
-
const res = await this.makeRequest('GET', '/workspaces', undefined, { cache: true, cacheTTL: CACHE_TIMES.MEDIUM });
|
|
13
|
-
return res.workspaces ?? [];
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
throw this.handleError(error);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Create a new team workspace. The caller becomes its `owner`.
|
|
21
|
-
* @param data - Workspace configuration.
|
|
22
|
-
*/
|
|
23
|
-
async createWorkspace(data) {
|
|
24
|
-
try {
|
|
25
|
-
const res = await this.makeRequest('POST', '/workspaces', data, { cache: false });
|
|
26
|
-
// Bust the cached workspace list so the new workspace appears on the
|
|
27
|
-
// next `getWorkspaces()` read within the TTL window.
|
|
28
|
-
this.clearCacheEntry('GET:/workspaces');
|
|
29
|
-
return res.workspace;
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
throw this.handleError(error);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Fetch a single workspace by id.
|
|
37
|
-
* @param workspaceId - The workspace's Mongo `_id`.
|
|
38
|
-
*/
|
|
39
|
-
async getWorkspace(workspaceId) {
|
|
40
|
-
try {
|
|
41
|
-
const res = await this.makeRequest('GET', `/workspaces/${encodeURIComponent(workspaceId)}`, undefined, { cache: true, cacheTTL: CACHE_TIMES.LONG });
|
|
42
|
-
return res.workspace;
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
throw this.handleError(error);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Update a workspace's mutable fields.
|
|
50
|
-
* @param workspaceId - The workspace's Mongo `_id`.
|
|
51
|
-
* @param data - Subset of updatable fields.
|
|
52
|
-
*/
|
|
53
|
-
async updateWorkspace(workspaceId, data) {
|
|
54
|
-
try {
|
|
55
|
-
const res = await this.makeRequest('PATCH', `/workspaces/${encodeURIComponent(workspaceId)}`, data, { cache: false });
|
|
56
|
-
// Bust the cached detail and list — both surface workspace fields.
|
|
57
|
-
this.clearCacheEntry(`GET:/workspaces/${encodeURIComponent(workspaceId)}`);
|
|
58
|
-
this.clearCacheEntry('GET:/workspaces');
|
|
59
|
-
return res.workspace;
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
throw this.handleError(error);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Soft-delete a workspace (owner only).
|
|
67
|
-
* @param workspaceId - The workspace's Mongo `_id`.
|
|
68
|
-
*/
|
|
69
|
-
async deleteWorkspace(workspaceId) {
|
|
70
|
-
try {
|
|
71
|
-
const result = await this.makeRequest('DELETE', `/workspaces/${encodeURIComponent(workspaceId)}`, undefined, { cache: false });
|
|
72
|
-
// Bust every cached representation of the deleted workspace.
|
|
73
|
-
this.clearCacheEntry(`GET:/workspaces/${encodeURIComponent(workspaceId)}`);
|
|
74
|
-
this.clearCacheEntry(`GET:/workspaces/${encodeURIComponent(workspaceId)}/members`);
|
|
75
|
-
this.clearCacheEntry('GET:/workspaces');
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
throw this.handleError(error);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* List members of a workspace.
|
|
84
|
-
* @param workspaceId - The workspace's Mongo `_id`.
|
|
85
|
-
*/
|
|
86
|
-
async getWorkspaceMembers(workspaceId) {
|
|
87
|
-
try {
|
|
88
|
-
const res = await this.makeRequest('GET', `/workspaces/${encodeURIComponent(workspaceId)}/members`, undefined, { cache: true, cacheTTL: CACHE_TIMES.MEDIUM });
|
|
89
|
-
return res.members ?? [];
|
|
90
|
-
}
|
|
91
|
-
catch (error) {
|
|
92
|
-
throw this.handleError(error);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Add a member to a workspace.
|
|
97
|
-
* @param workspaceId - The workspace's Mongo `_id`.
|
|
98
|
-
* @param data - Target user's username or email and role (never `owner`).
|
|
99
|
-
* The server resolves `usernameOrEmail` to a user; an unknown value yields
|
|
100
|
-
* a 404 "User not found".
|
|
101
|
-
*/
|
|
102
|
-
async inviteWorkspaceMember(workspaceId, data) {
|
|
103
|
-
try {
|
|
104
|
-
const res = await this.makeRequest('POST', `/workspaces/${encodeURIComponent(workspaceId)}/members`, data, { cache: false });
|
|
105
|
-
this._invalidateWorkspaceMembership(workspaceId);
|
|
106
|
-
return res.member;
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
109
|
-
throw this.handleError(error);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Change a member's role.
|
|
114
|
-
* @param workspaceId - The workspace's Mongo `_id`.
|
|
115
|
-
* @param memberId - The member's Mongo `_id`.
|
|
116
|
-
* @param data - New role (never `owner`).
|
|
117
|
-
*/
|
|
118
|
-
async updateWorkspaceMember(workspaceId, memberId, data) {
|
|
119
|
-
try {
|
|
120
|
-
const res = await this.makeRequest('PATCH', `/workspaces/${encodeURIComponent(workspaceId)}/members/${encodeURIComponent(memberId)}`, data, { cache: false });
|
|
121
|
-
this._invalidateWorkspaceMembership(workspaceId);
|
|
122
|
-
return res.member;
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
throw this.handleError(error);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Remove a member from a workspace.
|
|
130
|
-
* @param workspaceId - The workspace's Mongo `_id`.
|
|
131
|
-
* @param memberId - The member's Mongo `_id`.
|
|
132
|
-
*/
|
|
133
|
-
async removeWorkspaceMember(workspaceId, memberId) {
|
|
134
|
-
try {
|
|
135
|
-
const result = await this.makeRequest('DELETE', `/workspaces/${encodeURIComponent(workspaceId)}/members/${encodeURIComponent(memberId)}`, undefined, { cache: false });
|
|
136
|
-
this._invalidateWorkspaceMembership(workspaceId);
|
|
137
|
-
return result;
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
throw this.handleError(error);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Transfer ownership of a workspace to another member (owner only).
|
|
145
|
-
* Demotes the current owner and promotes the target to `owner`.
|
|
146
|
-
* @param workspaceId - The workspace's Mongo `_id`.
|
|
147
|
-
* @param data - Target user id.
|
|
148
|
-
*/
|
|
149
|
-
async transferWorkspaceOwnership(workspaceId, data) {
|
|
150
|
-
try {
|
|
151
|
-
const result = await this.makeRequest('POST', `/workspaces/${encodeURIComponent(workspaceId)}/transfer-ownership`, data, { cache: false });
|
|
152
|
-
// Ownership change alters roles in the member list AND the detail, and
|
|
153
|
-
// can change which workspaces the caller "owns" in the list view.
|
|
154
|
-
this._invalidateWorkspaceMembership(workspaceId);
|
|
155
|
-
this.clearCacheEntry('GET:/workspaces');
|
|
156
|
-
return result;
|
|
157
|
-
}
|
|
158
|
-
catch (error) {
|
|
159
|
-
throw this.handleError(error);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Bust the cached member list and detail for a workspace after a membership
|
|
164
|
-
* mutation. The member list (`getWorkspaceMembers`) and the detail
|
|
165
|
-
* (`getWorkspace`, which can embed member counts) both go stale when the
|
|
166
|
-
* member set or a member's role changes.
|
|
167
|
-
*
|
|
168
|
-
* Internal helper (leading underscore); not part of the supported public
|
|
169
|
-
* surface. Public rather than `private` because mixins compose into an
|
|
170
|
-
* exported anonymous class, where TypeScript cannot represent a private
|
|
171
|
-
* member in the emitted declaration file (TS4094).
|
|
172
|
-
*/
|
|
173
|
-
_invalidateWorkspaceMembership(workspaceId) {
|
|
174
|
-
this.clearCacheEntry(`GET:/workspaces/${encodeURIComponent(workspaceId)}/members`);
|
|
175
|
-
this.clearCacheEntry(`GET:/workspaces/${encodeURIComponent(workspaceId)}`);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
}
|
|
@@ -1,496 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Applications Methods Mixin
|
|
3
|
-
*
|
|
4
|
-
* Provides methods for managing Oxy applications, their members, and their
|
|
5
|
-
* credentials via the `/applications` API. An application is a multi-user
|
|
6
|
-
* entity: membership (with a role) grants permissions; credentials
|
|
7
|
-
* (public/confidential/service) carry OAuth client identifiers and the
|
|
8
|
-
* service-token API key material.
|
|
9
|
-
*
|
|
10
|
-
* Reference applications by their Mongo `_id` (`applicationId`) and credentials
|
|
11
|
-
* by their `credentialId`. Never by name.
|
|
12
|
-
*/
|
|
13
|
-
import type { OxyServicesBase } from '../OxyServices.base';
|
|
14
|
-
/**
|
|
15
|
-
* Application classification. Set only by Oxy platform staff — never editable
|
|
16
|
-
* through the normal member-facing update path.
|
|
17
|
-
*/
|
|
18
|
-
export type ApplicationType = 'first_party' | 'third_party' | 'internal' | 'system';
|
|
19
|
-
/** Lifecycle status of an application. */
|
|
20
|
-
export type ApplicationStatus = 'active' | 'suspended' | 'deleted' | 'pending_review';
|
|
21
|
-
/** Role a member holds within an application. */
|
|
22
|
-
export type ApplicationRole = 'owner' | 'admin' | 'developer' | 'viewer' | 'billing';
|
|
23
|
-
/** Membership lifecycle status. */
|
|
24
|
-
export type ApplicationMemberStatus = 'active' | 'invited' | 'removed';
|
|
25
|
-
/** Credential kind. `service` credentials mint service tokens. */
|
|
26
|
-
export type ApplicationCredentialType = 'public' | 'confidential' | 'service';
|
|
27
|
-
/** Deployment environment a credential is scoped to. */
|
|
28
|
-
export type ApplicationEnvironment = 'development' | 'staging' | 'production';
|
|
29
|
-
/** Credential lifecycle status. */
|
|
30
|
-
export type ApplicationCredentialStatus = 'active' | 'deprecated' | 'revoked';
|
|
31
|
-
/**
|
|
32
|
-
* Client-facing Application shape returned by the `/applications` API.
|
|
33
|
-
* Mirrors the server `Application` model with `_id` as a string and dates
|
|
34
|
-
* serialized to ISO strings.
|
|
35
|
-
*/
|
|
36
|
-
export interface Application {
|
|
37
|
-
_id: string;
|
|
38
|
-
name: string;
|
|
39
|
-
description?: string;
|
|
40
|
-
websiteUrl?: string;
|
|
41
|
-
icon?: string;
|
|
42
|
-
type: ApplicationType;
|
|
43
|
-
status: ApplicationStatus;
|
|
44
|
-
isOfficial: boolean;
|
|
45
|
-
isInternal: boolean;
|
|
46
|
-
capabilities: string[];
|
|
47
|
-
redirectUris: string[];
|
|
48
|
-
scopes: string[];
|
|
49
|
-
webhookUrl?: string;
|
|
50
|
-
devWebhookUrl?: string;
|
|
51
|
-
createdByUserId: string;
|
|
52
|
-
/**
|
|
53
|
-
* The workspace this application belongs to (workspace `_id`), or `null` for
|
|
54
|
-
* applications not owned by a workspace. Used by the console to scope apps to
|
|
55
|
-
* a workspace and to branch on workspace-derived access.
|
|
56
|
-
*/
|
|
57
|
-
workspaceId: string | null;
|
|
58
|
-
createdAt: string;
|
|
59
|
-
updatedAt: string;
|
|
60
|
-
/**
|
|
61
|
-
* The calling user's own membership in this application, embedded by the API
|
|
62
|
-
* on list (`GET /applications`) and detail (`GET /applications/:appId`)
|
|
63
|
-
* responses. Use `callerMembership.permissions` to gate UI affordances.
|
|
64
|
-
*
|
|
65
|
-
* When the caller's access is derived from a workspace membership rather than
|
|
66
|
-
* a direct application membership, the API returns a synthetic membership
|
|
67
|
-
* with `source: 'workspace'` and `_id: null`.
|
|
68
|
-
*/
|
|
69
|
-
callerMembership?: ApplicationMember;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Client-facing ApplicationMember shape. `permissions` is derived from `role`
|
|
73
|
-
* on the server at write time.
|
|
74
|
-
*/
|
|
75
|
-
export interface ApplicationMember {
|
|
76
|
-
/**
|
|
77
|
-
* The membership's Mongo `_id`. `null` for a synthetic, workspace-derived
|
|
78
|
-
* membership (see {@link Application.callerMembership} and `source`).
|
|
79
|
-
*/
|
|
80
|
-
_id: string | null;
|
|
81
|
-
applicationId: string;
|
|
82
|
-
userId: string;
|
|
83
|
-
role: ApplicationRole;
|
|
84
|
-
permissions: string[];
|
|
85
|
-
invitedByUserId?: string;
|
|
86
|
-
joinedAt?: string;
|
|
87
|
-
status: ApplicationMemberStatus;
|
|
88
|
-
/**
|
|
89
|
-
* Origin of this membership. When `'workspace'`, the membership is synthetic
|
|
90
|
-
* and derived from the caller's workspace membership rather than a direct
|
|
91
|
-
* application membership (in which case `_id` is `null`). Absent or any other
|
|
92
|
-
* value indicates a direct application membership.
|
|
93
|
-
*/
|
|
94
|
-
source?: 'workspace';
|
|
95
|
-
createdAt: string;
|
|
96
|
-
updatedAt: string;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Client-facing ApplicationCredential shape. The raw secret is NEVER part of
|
|
100
|
-
* this shape — it is returned exactly once, separately, at creation/rotation.
|
|
101
|
-
*/
|
|
102
|
-
export interface ApplicationCredential {
|
|
103
|
-
_id: string;
|
|
104
|
-
applicationId: string;
|
|
105
|
-
name: string;
|
|
106
|
-
publicKey: string;
|
|
107
|
-
type: ApplicationCredentialType;
|
|
108
|
-
environment: ApplicationEnvironment;
|
|
109
|
-
scopes: string[];
|
|
110
|
-
status: ApplicationCredentialStatus;
|
|
111
|
-
lastUsedAt?: string;
|
|
112
|
-
expiresAt?: string;
|
|
113
|
-
/**
|
|
114
|
-
* Audit link to the credential this one was rotated FROM. Populated by the
|
|
115
|
-
* API on credentials created via rotation; absent on original credentials.
|
|
116
|
-
*/
|
|
117
|
-
rotatedFromCredentialId?: string;
|
|
118
|
-
createdByUserId: string;
|
|
119
|
-
createdAt: string;
|
|
120
|
-
updatedAt: string;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Sanitized, PUBLIC application identity returned by the API when resolving a
|
|
124
|
-
* cross-app/OAuth client to a registered {@link Application}.
|
|
125
|
-
*
|
|
126
|
-
* Unlike {@link Application}, this shape carries NO sensitive or membership
|
|
127
|
-
* fields — it is safe to display unauthenticated in consent/authorize screens
|
|
128
|
-
* and device-flow approval UIs. The API resolves a `client_id` (OAuth
|
|
129
|
-
* credential public key) to the owning application and projects only the
|
|
130
|
-
* fields below. `id` is the application's `_id` as a string.
|
|
131
|
-
*/
|
|
132
|
-
export interface PublicApplication {
|
|
133
|
-
/** The application's Mongo `_id` as a string. */
|
|
134
|
-
id: string;
|
|
135
|
-
/** Human-readable application name shown to the user. */
|
|
136
|
-
name: string;
|
|
137
|
-
/** Optional short description of what the application does. */
|
|
138
|
-
description?: string;
|
|
139
|
-
/** Optional icon URL for the application. */
|
|
140
|
-
icon?: string;
|
|
141
|
-
/** Optional public website/homepage URL for the application. */
|
|
142
|
-
websiteUrl?: string;
|
|
143
|
-
/** Application classification (set by Oxy platform staff). */
|
|
144
|
-
type: ApplicationType;
|
|
145
|
-
/** Whether the application is an officially endorsed Oxy application. */
|
|
146
|
-
isOfficial: boolean;
|
|
147
|
-
/** Whether the application is an internal Oxy ecosystem application. */
|
|
148
|
-
isInternal: boolean;
|
|
149
|
-
/** OAuth scopes the application is configured to request. */
|
|
150
|
-
scopes: string[];
|
|
151
|
-
/** Optional display name of the developer/owner organisation. */
|
|
152
|
-
developerName?: string;
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* A connected (OAuth-authorized) application from the current user's point of
|
|
156
|
-
* view: an application the user has granted access to via the consent flow.
|
|
157
|
-
*
|
|
158
|
-
* Returned by `GET /auth/grants` and rendered in the user-facing "Connected
|
|
159
|
-
* apps" management surface. Keyed by `applicationId` (the application's Mongo
|
|
160
|
-
* `_id`) rather than a credential/client id, so the grant — and a subsequent
|
|
161
|
-
* {@link OxyServicesApplicationsMixin.revokeAppGrant} — survive credential
|
|
162
|
-
* rotation. This is a display shape: it carries the application's name/logo and
|
|
163
|
-
* the granted scopes, never any membership or credential material.
|
|
164
|
-
*/
|
|
165
|
-
export interface ConnectedApp {
|
|
166
|
-
/** The connected application's Mongo `_id`. Use this to revoke the grant. */
|
|
167
|
-
applicationId: string;
|
|
168
|
-
/** Human-readable application name shown to the user. */
|
|
169
|
-
name: string;
|
|
170
|
-
/** Optional logo URL for the application. */
|
|
171
|
-
logoUrl?: string;
|
|
172
|
-
/** OAuth scopes the user has granted to the application. */
|
|
173
|
-
scopes: string[];
|
|
174
|
-
/** ISO timestamp of when the user first authorized the application. */
|
|
175
|
-
firstGrantedAt: string;
|
|
176
|
-
/** ISO timestamp of when the grant was last exercised. */
|
|
177
|
-
lastUsedAt: string;
|
|
178
|
-
}
|
|
179
|
-
/** Input accepted by `createApplication`. Staff-only fields are not settable here. */
|
|
180
|
-
export interface CreateApplicationInput {
|
|
181
|
-
name: string;
|
|
182
|
-
description?: string;
|
|
183
|
-
websiteUrl?: string;
|
|
184
|
-
icon?: string;
|
|
185
|
-
redirectUris?: string[];
|
|
186
|
-
scopes?: string[];
|
|
187
|
-
/**
|
|
188
|
-
* Optional workspace `_id` to create the app in. Omitted → API defaults to
|
|
189
|
-
* the caller's personal workspace.
|
|
190
|
-
*/
|
|
191
|
-
workspaceId?: string;
|
|
192
|
-
}
|
|
193
|
-
/** Input accepted by `updateApplication`. Staff-only fields are not settable here. */
|
|
194
|
-
export interface UpdateApplicationInput {
|
|
195
|
-
name?: string;
|
|
196
|
-
description?: string;
|
|
197
|
-
websiteUrl?: string;
|
|
198
|
-
icon?: string;
|
|
199
|
-
redirectUris?: string[];
|
|
200
|
-
scopes?: string[];
|
|
201
|
-
webhookUrl?: string;
|
|
202
|
-
devWebhookUrl?: string;
|
|
203
|
-
status?: ApplicationStatus;
|
|
204
|
-
}
|
|
205
|
-
/** Input accepted by `inviteApplicationMember`. The owner role cannot be invited. */
|
|
206
|
-
export interface InviteApplicationMemberInput {
|
|
207
|
-
/**
|
|
208
|
-
* The username or email of the user to invite. Resolved to a user server-side;
|
|
209
|
-
* an unknown value yields a 404 "User not found".
|
|
210
|
-
*/
|
|
211
|
-
usernameOrEmail: string;
|
|
212
|
-
role: Exclude<ApplicationRole, 'owner'>;
|
|
213
|
-
}
|
|
214
|
-
/** Input accepted by `updateApplicationMember`. */
|
|
215
|
-
export interface UpdateApplicationMemberInput {
|
|
216
|
-
role: ApplicationRole;
|
|
217
|
-
}
|
|
218
|
-
/** Input accepted by `transferApplicationOwnership`. */
|
|
219
|
-
export interface TransferApplicationOwnershipInput {
|
|
220
|
-
userId: string;
|
|
221
|
-
}
|
|
222
|
-
/** Input accepted by `createApplicationCredential`. */
|
|
223
|
-
export interface CreateApplicationCredentialInput {
|
|
224
|
-
name: string;
|
|
225
|
-
type: ApplicationCredentialType;
|
|
226
|
-
environment: ApplicationEnvironment;
|
|
227
|
-
scopes?: string[];
|
|
228
|
-
}
|
|
229
|
-
/** Result of creating a credential — `secret` is returned ONCE. */
|
|
230
|
-
export interface ApplicationCredentialWithSecret {
|
|
231
|
-
credential: ApplicationCredential;
|
|
232
|
-
secret: string;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Result of rotating a credential. Extends the create result with audit fields:
|
|
236
|
-
* the new plaintext `secret` is returned ONCE, plus `rotatedFrom` (the previous
|
|
237
|
-
* credential's `credentialId`) and `graceExpiresAt` (ISO string marking when the
|
|
238
|
-
* old credential stops being honoured during the rotation grace window).
|
|
239
|
-
*/
|
|
240
|
-
export interface RotateApplicationCredentialResult extends ApplicationCredentialWithSecret {
|
|
241
|
-
/** The previous credential's `credentialId` that this rotation supersedes. */
|
|
242
|
-
rotatedFrom: string;
|
|
243
|
-
/** ISO timestamp at which the rotated-from credential's grace window ends. */
|
|
244
|
-
graceExpiresAt: string;
|
|
245
|
-
}
|
|
246
|
-
/** Time window for application usage statistics. */
|
|
247
|
-
export type ApplicationUsagePeriod = '24h' | '7d' | '30d' | '90d';
|
|
248
|
-
/** Aggregate totals for an application over the requested period. */
|
|
249
|
-
export interface ApplicationUsageSummary {
|
|
250
|
-
totalRequests: number;
|
|
251
|
-
totalTokens: number;
|
|
252
|
-
totalCredits: number;
|
|
253
|
-
avgResponseTime: number;
|
|
254
|
-
successfulRequests: number;
|
|
255
|
-
errorRequests: number;
|
|
256
|
-
}
|
|
257
|
-
/** Per-day usage bucket. `_id` is the day key (e.g. `YYYY-MM-DD`). */
|
|
258
|
-
export interface ApplicationUsageByDay {
|
|
259
|
-
_id: string;
|
|
260
|
-
requests: number;
|
|
261
|
-
tokens: number;
|
|
262
|
-
credits: number;
|
|
263
|
-
}
|
|
264
|
-
/** Per-endpoint usage bucket. `_id` is the endpoint identifier. */
|
|
265
|
-
export interface ApplicationUsageByEndpoint {
|
|
266
|
-
_id: string;
|
|
267
|
-
requests: number;
|
|
268
|
-
tokens: number;
|
|
269
|
-
}
|
|
270
|
-
/** Usage statistics for an application over a period. */
|
|
271
|
-
export interface ApplicationUsageStats {
|
|
272
|
-
summary: ApplicationUsageSummary;
|
|
273
|
-
byDay: ApplicationUsageByDay[];
|
|
274
|
-
byEndpoint: ApplicationUsageByEndpoint[];
|
|
275
|
-
}
|
|
276
|
-
/** Result of a delete/remove/revoke/transfer operation. */
|
|
277
|
-
export interface ApplicationSuccessResult {
|
|
278
|
-
success: boolean;
|
|
279
|
-
}
|
|
280
|
-
export declare function OxyServicesApplicationsMixin<T extends typeof OxyServicesBase>(Base: T): {
|
|
281
|
-
new (...args: any[]): {
|
|
282
|
-
/**
|
|
283
|
-
* Resolve an OAuth client identifier to the owning application's PUBLIC
|
|
284
|
-
* identity. No authentication required — the API returns only sanitized,
|
|
285
|
-
* display-safe metadata ({@link PublicApplication}). Use this to render the
|
|
286
|
-
* requesting application's name/icon in consent, authorize, and device-flow
|
|
287
|
-
* approval UIs before any session exists.
|
|
288
|
-
*
|
|
289
|
-
* @param clientId - The OAuth `client_id` (an active credential's public
|
|
290
|
-
* key). URL-encoded before being placed in the path.
|
|
291
|
-
*/
|
|
292
|
-
getPublicApplication(clientId: string): Promise<PublicApplication>;
|
|
293
|
-
/**
|
|
294
|
-
* List the OAuth-authorized applications the current user has connected —
|
|
295
|
-
* the third-party apps the user granted access to via the consent flow.
|
|
296
|
-
* Each entry is a {@link ConnectedApp} carrying the application's display
|
|
297
|
-
* identity, the granted scopes, and when the grant was first made and last
|
|
298
|
-
* exercised. Requires an authenticated session.
|
|
299
|
-
*
|
|
300
|
-
* Backed by `GET /auth/grants`. The response is briefly cached
|
|
301
|
-
* (identity-scoped); {@link revokeAppGrant} busts that cache so a revoke is
|
|
302
|
-
* reflected on the next read.
|
|
303
|
-
*/
|
|
304
|
-
listConnectedApps(): Promise<ConnectedApp[]>;
|
|
305
|
-
/**
|
|
306
|
-
* Revoke the current user's grant for a connected application, identified by
|
|
307
|
-
* its application `_id` (a {@link ConnectedApp.applicationId}, NOT a
|
|
308
|
-
* credential/client id — keyed by application so the revocation survives
|
|
309
|
-
* credential rotation). After this the application can no longer act on the
|
|
310
|
-
* user's behalf until it is re-authorized.
|
|
311
|
-
*
|
|
312
|
-
* Backed by `DELETE /auth/grants/:applicationId`. On success the cached
|
|
313
|
-
* connected-apps list (`GET:/auth/grants`) is invalidated so the next
|
|
314
|
-
* {@link listConnectedApps} read reflects the removal.
|
|
315
|
-
*
|
|
316
|
-
* @param applicationId - The connected application's Mongo `_id`.
|
|
317
|
-
*/
|
|
318
|
-
revokeAppGrant(applicationId: string): Promise<void>;
|
|
319
|
-
/**
|
|
320
|
-
* List applications the current user is an active member of.
|
|
321
|
-
*
|
|
322
|
-
* @param workspaceId - Optional workspace `_id` to scope the listing to
|
|
323
|
-
* applications belonging to that workspace. When provided it is appended
|
|
324
|
-
* as a `workspaceId` query parameter (URL-encoded). The query string is
|
|
325
|
-
* part of the request path, so the response cache keys on it
|
|
326
|
-
* automatically — scoped and unscoped lists never collide.
|
|
327
|
-
*/
|
|
328
|
-
getApplications(workspaceId?: string): Promise<Application[]>;
|
|
329
|
-
/**
|
|
330
|
-
* Create a new application. The caller becomes its `owner`.
|
|
331
|
-
* @param data - Application configuration. Staff-only fields are ignored.
|
|
332
|
-
*/
|
|
333
|
-
createApplication(data: CreateApplicationInput): Promise<Application>;
|
|
334
|
-
/**
|
|
335
|
-
* Fetch a single application by id.
|
|
336
|
-
* @param applicationId - The application's Mongo `_id`.
|
|
337
|
-
*/
|
|
338
|
-
getApplication(applicationId: string): Promise<Application>;
|
|
339
|
-
/**
|
|
340
|
-
* Update an application's mutable fields.
|
|
341
|
-
* @param applicationId - The application's Mongo `_id`.
|
|
342
|
-
* @param data - Subset of updatable fields. Staff-only fields are ignored.
|
|
343
|
-
*/
|
|
344
|
-
updateApplication(applicationId: string, data: UpdateApplicationInput): Promise<Application>;
|
|
345
|
-
/**
|
|
346
|
-
* Soft-delete an application (owner only).
|
|
347
|
-
* @param applicationId - The application's Mongo `_id`.
|
|
348
|
-
*/
|
|
349
|
-
deleteApplication(applicationId: string): Promise<ApplicationSuccessResult>;
|
|
350
|
-
/**
|
|
351
|
-
* List members of an application.
|
|
352
|
-
* @param applicationId - The application's Mongo `_id`.
|
|
353
|
-
*/
|
|
354
|
-
getApplicationMembers(applicationId: string): Promise<ApplicationMember[]>;
|
|
355
|
-
/**
|
|
356
|
-
* Add a member to an application.
|
|
357
|
-
* @param applicationId - The application's Mongo `_id`.
|
|
358
|
-
* @param data - Target user's username or email and role (never `owner`).
|
|
359
|
-
* The server resolves `usernameOrEmail` to a user; an unknown value yields
|
|
360
|
-
* a 404 "User not found".
|
|
361
|
-
*/
|
|
362
|
-
inviteApplicationMember(applicationId: string, data: InviteApplicationMemberInput): Promise<ApplicationMember>;
|
|
363
|
-
/**
|
|
364
|
-
* Change a member's role.
|
|
365
|
-
* @param applicationId - The application's Mongo `_id`.
|
|
366
|
-
* @param memberId - The member's Mongo `_id`.
|
|
367
|
-
* @param data - New role.
|
|
368
|
-
*/
|
|
369
|
-
updateApplicationMember(applicationId: string, memberId: string, data: UpdateApplicationMemberInput): Promise<ApplicationMember>;
|
|
370
|
-
/**
|
|
371
|
-
* Remove a member from an application.
|
|
372
|
-
* @param applicationId - The application's Mongo `_id`.
|
|
373
|
-
* @param memberId - The member's Mongo `_id`.
|
|
374
|
-
*/
|
|
375
|
-
removeApplicationMember(applicationId: string, memberId: string): Promise<ApplicationSuccessResult>;
|
|
376
|
-
/**
|
|
377
|
-
* Transfer ownership of an application to another member (owner only).
|
|
378
|
-
* Demotes the current owner to `admin` and promotes the target to `owner`.
|
|
379
|
-
* @param applicationId - The application's Mongo `_id`.
|
|
380
|
-
* @param data - Target user id.
|
|
381
|
-
*/
|
|
382
|
-
transferApplicationOwnership(applicationId: string, data: TransferApplicationOwnershipInput): Promise<ApplicationSuccessResult>;
|
|
383
|
-
/**
|
|
384
|
-
* List an application's credentials. The response NEVER includes secrets.
|
|
385
|
-
* @param applicationId - The application's Mongo `_id`.
|
|
386
|
-
*/
|
|
387
|
-
getApplicationCredentials(applicationId: string): Promise<ApplicationCredential[]>;
|
|
388
|
-
/**
|
|
389
|
-
* Create a credential. The plaintext `secret` is returned exactly ONCE;
|
|
390
|
-
* the server stores only a hash and will never return it again.
|
|
391
|
-
* @param applicationId - The application's Mongo `_id`.
|
|
392
|
-
* @param data - Credential configuration.
|
|
393
|
-
*/
|
|
394
|
-
createApplicationCredential(applicationId: string, data: CreateApplicationCredentialInput): Promise<ApplicationCredentialWithSecret>;
|
|
395
|
-
/**
|
|
396
|
-
* Rotate a credential's secret. The new plaintext `secret` is returned
|
|
397
|
-
* exactly ONCE, along with audit fields: `rotatedFrom` (the previous
|
|
398
|
-
* credentialId) and `graceExpiresAt` (ISO string for the grace window during
|
|
399
|
-
* which the old credential is still honoured).
|
|
400
|
-
* @param applicationId - The application's Mongo `_id`.
|
|
401
|
-
* @param credentialId - The credential's Mongo `_id`.
|
|
402
|
-
*/
|
|
403
|
-
rotateApplicationCredential(applicationId: string, credentialId: string): Promise<RotateApplicationCredentialResult>;
|
|
404
|
-
/**
|
|
405
|
-
* Revoke a credential (`status='revoked'`). Revoked credentials can no
|
|
406
|
-
* longer authenticate.
|
|
407
|
-
* @param applicationId - The application's Mongo `_id`.
|
|
408
|
-
* @param credentialId - The credential's Mongo `_id`.
|
|
409
|
-
*/
|
|
410
|
-
revokeApplicationCredential(applicationId: string, credentialId: string): Promise<ApplicationSuccessResult>;
|
|
411
|
-
/**
|
|
412
|
-
* Fetch usage statistics for an application.
|
|
413
|
-
* @param applicationId - The application's Mongo `_id`.
|
|
414
|
-
* @param period - Time window (defaults to the server default).
|
|
415
|
-
*/
|
|
416
|
-
getApplicationUsage(applicationId: string, period?: ApplicationUsagePeriod): Promise<ApplicationUsageStats>;
|
|
417
|
-
/**
|
|
418
|
-
* Bust every cached application list. `getApplications(workspaceId?)` keys
|
|
419
|
-
* the unscoped list as `GET:/applications` and each workspace-scoped list as
|
|
420
|
-
* `GET:/applications?workspaceId=<id>` (the query string is part of the URL
|
|
421
|
-
* path). A change to list membership (create/delete/ownership transfer)
|
|
422
|
-
* invalidates all of them, so we clear the unscoped entry plus every
|
|
423
|
-
* `?workspaceId=` variant via a prefix sweep. The prefix `GET:/applications?`
|
|
424
|
-
* matches only the query-string list variants, never the `GET:/applications/<id>…`
|
|
425
|
-
* detail/sub-resource keys.
|
|
426
|
-
*
|
|
427
|
-
* Internal helper (leading underscore); not part of the supported public
|
|
428
|
-
* surface. Public rather than `private` because mixins compose into an
|
|
429
|
-
* exported anonymous class, where TypeScript cannot represent a private
|
|
430
|
-
* member in the emitted declaration file (TS4094).
|
|
431
|
-
*/
|
|
432
|
-
_invalidateApplicationLists(): void;
|
|
433
|
-
/**
|
|
434
|
-
* Bust the cached member list and detail for an application after a
|
|
435
|
-
* membership mutation. The member list (`getApplicationMembers`) and the
|
|
436
|
-
* detail (`getApplication`, which can embed member counts) both go stale
|
|
437
|
-
* when the member set or a member's role changes.
|
|
438
|
-
*
|
|
439
|
-
* Internal helper (leading underscore); see `_invalidateApplicationLists`
|
|
440
|
-
* for why this is public rather than `private`.
|
|
441
|
-
*/
|
|
442
|
-
_invalidateApplicationMembership(applicationId: string): void;
|
|
443
|
-
httpService: import("../HttpService").HttpService;
|
|
444
|
-
cloudURL: string;
|
|
445
|
-
config: import("../OxyServices.base").OxyConfig;
|
|
446
|
-
__resetTokensForTests(): void;
|
|
447
|
-
makeRequest<T_1>(method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE", url: string, data?: any, options?: import("../HttpService").RequestOptions): Promise<T_1>;
|
|
448
|
-
getBaseURL(): string;
|
|
449
|
-
getSessionBaseUrl(): string;
|
|
450
|
-
getClient(): import("../HttpService").HttpService;
|
|
451
|
-
createLinkedClient(config: import("../OxyServices.base").OxyConfig): import("..").LinkedHttpClient;
|
|
452
|
-
getMetrics(): {
|
|
453
|
-
totalRequests: number;
|
|
454
|
-
successfulRequests: number;
|
|
455
|
-
failedRequests: number;
|
|
456
|
-
cacheHits: number;
|
|
457
|
-
cacheMisses: number;
|
|
458
|
-
averageResponseTime: number;
|
|
459
|
-
};
|
|
460
|
-
clearCache(): void;
|
|
461
|
-
clearCacheEntry(key: string): void;
|
|
462
|
-
clearCacheByPrefix(prefix: string): number;
|
|
463
|
-
getCacheStats(): {
|
|
464
|
-
size: number;
|
|
465
|
-
hits: number;
|
|
466
|
-
misses: number;
|
|
467
|
-
hitRate: number;
|
|
468
|
-
};
|
|
469
|
-
getCloudURL(): string;
|
|
470
|
-
setTokens(accessToken: string): void;
|
|
471
|
-
clearTokens(): void;
|
|
472
|
-
onTokensChanged(listener: (accessToken: string | null) => void): () => void;
|
|
473
|
-
_cachedUserId: string | null | undefined;
|
|
474
|
-
_cachedAccessToken: string | null;
|
|
475
|
-
getCurrentUserId(): string | null;
|
|
476
|
-
hasValidToken(): boolean;
|
|
477
|
-
getAccessToken(): string | null;
|
|
478
|
-
getAccessTokenExpiry(): number | null;
|
|
479
|
-
setActingAs(userId: string | null): void;
|
|
480
|
-
getActingAs(): string | null;
|
|
481
|
-
waitForAuth(timeoutMs?: number): Promise<boolean>;
|
|
482
|
-
withAuthRetry<T_1>(operation: () => Promise<T_1>, operationName: string, options?: {
|
|
483
|
-
maxRetries?: number;
|
|
484
|
-
retryDelay?: number;
|
|
485
|
-
authTimeoutMs?: number;
|
|
486
|
-
}): Promise<T_1>;
|
|
487
|
-
validate(): Promise<boolean>;
|
|
488
|
-
handleError(error: unknown): Error;
|
|
489
|
-
healthCheck(): Promise<{
|
|
490
|
-
status: string;
|
|
491
|
-
users?: number;
|
|
492
|
-
timestamp?: string;
|
|
493
|
-
[key: string]: any;
|
|
494
|
-
}>;
|
|
495
|
-
};
|
|
496
|
-
} & T;
|