@gzl10/nexus-plugin-pocketid 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.
- package/README.md +0 -0
- package/dist/index.d.ts +296 -0
- package/dist/index.js +1437 -0
- package/dist/index.js.map +1 -0
- package/dist/serve.d.ts +2 -0
- package/dist/serve.js +1437 -0
- package/dist/serve.js.map +1 -0
- package/migrations/pocketid__1772411851359_auto.js +93 -0
- package/package.json +56 -0
package/README.md
ADDED
|
File without changes
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { ConfigEntityDefinition, ModuleManifest, OidcState, ActionEntityDefinition, CollectionEntityDefinition, EventEntityDefinition, PluginManifest } from '@gzl10/nexus-sdk';
|
|
2
|
+
export { IdTokenClaims, OidcClient, OidcDiscoveryDocument, OidcTokens, OidcUserInfo, createOidcClient, getOidcClient } from '@gzl10/nexus-sdk';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* PocketID Configuration Types
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* PocketID config stored in database
|
|
9
|
+
*/
|
|
10
|
+
interface PocketIdConfig {
|
|
11
|
+
/** Enable/disable PocketID authentication */
|
|
12
|
+
enabled: boolean;
|
|
13
|
+
/** PocketID issuer URL (e.g., https://auth.example.com) */
|
|
14
|
+
issuer_url: string;
|
|
15
|
+
/** OIDC Client ID */
|
|
16
|
+
client_id: string;
|
|
17
|
+
/** OIDC Client Secret (encrypted) */
|
|
18
|
+
client_secret: string;
|
|
19
|
+
/** Scopes to request (default: openid profile email) */
|
|
20
|
+
scopes: string;
|
|
21
|
+
/** Auto-register new users */
|
|
22
|
+
auto_register: boolean;
|
|
23
|
+
/** Allowed email domains (JSON array, optional) */
|
|
24
|
+
allowed_domains: string | null;
|
|
25
|
+
/** Default role for new users */
|
|
26
|
+
default_role: string | null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Config service interface
|
|
30
|
+
*/
|
|
31
|
+
interface ConfigService {
|
|
32
|
+
/** Get current config */
|
|
33
|
+
getConfig(): Promise<PocketIdConfig | null>;
|
|
34
|
+
/** Check if PocketID is enabled */
|
|
35
|
+
isEnabled(): Promise<boolean>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* PocketID Config Entity
|
|
40
|
+
*
|
|
41
|
+
* Stores OIDC configuration for PocketID authentication
|
|
42
|
+
*/
|
|
43
|
+
declare const pocketIdConfigEntity: ConfigEntityDefinition;
|
|
44
|
+
|
|
45
|
+
declare function getConfigService(): ConfigService;
|
|
46
|
+
declare function setConfigService(service: ConfigService): void;
|
|
47
|
+
/**
|
|
48
|
+
* PocketID Config Module
|
|
49
|
+
*/
|
|
50
|
+
declare const configModule: ModuleManifest;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* PocketID Auth Types
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Session result after successful authentication
|
|
58
|
+
*/
|
|
59
|
+
interface SessionResult {
|
|
60
|
+
accessToken: string;
|
|
61
|
+
refreshToken: string;
|
|
62
|
+
expiresIn: number;
|
|
63
|
+
user: {
|
|
64
|
+
id: string;
|
|
65
|
+
email: string;
|
|
66
|
+
name?: string;
|
|
67
|
+
};
|
|
68
|
+
/** Frontend URL to redirect user after auth (server-side flow) */
|
|
69
|
+
returnUrl?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* PocketID-specific OIDC state (extends base)
|
|
73
|
+
*/
|
|
74
|
+
interface PocketIdState extends OidcState {
|
|
75
|
+
/** User ID if linking account */
|
|
76
|
+
linkUserId?: string;
|
|
77
|
+
/** Frontend URL to redirect user after auth completes */
|
|
78
|
+
returnUrl?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Auth service interface
|
|
82
|
+
*/
|
|
83
|
+
interface PocketIdAuthService {
|
|
84
|
+
/** Generate authorization URL and state */
|
|
85
|
+
getAuthorizationUrl(redirectUri: string, linkUserId?: string, returnUrl?: string): Promise<{
|
|
86
|
+
url: string;
|
|
87
|
+
state: string;
|
|
88
|
+
}>;
|
|
89
|
+
/** Handle callback from PocketID */
|
|
90
|
+
handleCallback(code: string, state: string): Promise<SessionResult>;
|
|
91
|
+
/** Verify state is valid */
|
|
92
|
+
verifyState(state: string): Promise<PocketIdState | null>;
|
|
93
|
+
/** Clear state after use */
|
|
94
|
+
clearState(state: string): Promise<void>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
declare function getAuthService(): PocketIdAuthService;
|
|
98
|
+
declare function setAuthService(service: PocketIdAuthService): void;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* PocketID Auth Controller
|
|
102
|
+
*
|
|
103
|
+
* Handles OIDC endpoints:
|
|
104
|
+
* - GET /pocketid_auth/authorize - Start OIDC flow
|
|
105
|
+
* - GET /pocketid_auth/callback - Handle OIDC callback (from PocketID redirect)
|
|
106
|
+
* - GET /pocketid_auth/link - Link existing account (requires auth)
|
|
107
|
+
* - GET /pocketid_auth/status - Check if PocketID is linked
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
declare const authActions: ActionEntityDefinition[];
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* PocketID Auth Module
|
|
114
|
+
*
|
|
115
|
+
* Provides OIDC authentication endpoints:
|
|
116
|
+
* - GET /pocketid/authorize - Start auth flow
|
|
117
|
+
* - GET /pocketid/callback - Handle callback
|
|
118
|
+
* - GET /pocketid/link - Link existing account
|
|
119
|
+
* - GET /pocketid/status - Check link status
|
|
120
|
+
*/
|
|
121
|
+
declare const authModule: ModuleManifest;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* SCIM Entity Definitions
|
|
125
|
+
*
|
|
126
|
+
* - scim_config: SCIM server configuration (token, behavior)
|
|
127
|
+
* - scim_users: SCIM-provisioned user mappings
|
|
128
|
+
* - scim_groups: SCIM group-to-role mappings
|
|
129
|
+
* - scim_log: Audit log of SCIM operations
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
declare const scimConfigEntity: ConfigEntityDefinition;
|
|
133
|
+
declare const scimUsersEntity: CollectionEntityDefinition;
|
|
134
|
+
declare const scimGroupsEntity: CollectionEntityDefinition;
|
|
135
|
+
declare const scimLogEntity: EventEntityDefinition;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* SCIM 2.0 Protocol Types (RFC 7643/7644)
|
|
139
|
+
*
|
|
140
|
+
* Types for the SCIM server that receives provisioning
|
|
141
|
+
* requests from PocketID.
|
|
142
|
+
*/
|
|
143
|
+
interface ScimMeta {
|
|
144
|
+
resourceType: string;
|
|
145
|
+
created?: string;
|
|
146
|
+
lastModified?: string;
|
|
147
|
+
location?: string;
|
|
148
|
+
}
|
|
149
|
+
interface ScimUserName {
|
|
150
|
+
formatted?: string;
|
|
151
|
+
familyName?: string;
|
|
152
|
+
givenName?: string;
|
|
153
|
+
}
|
|
154
|
+
interface ScimUserEmail {
|
|
155
|
+
value: string;
|
|
156
|
+
type?: string;
|
|
157
|
+
primary?: boolean;
|
|
158
|
+
}
|
|
159
|
+
interface ScimUser {
|
|
160
|
+
schemas: string[];
|
|
161
|
+
id?: string;
|
|
162
|
+
externalId?: string;
|
|
163
|
+
userName: string;
|
|
164
|
+
name?: ScimUserName;
|
|
165
|
+
displayName?: string;
|
|
166
|
+
emails?: ScimUserEmail[];
|
|
167
|
+
active?: boolean;
|
|
168
|
+
meta?: ScimMeta;
|
|
169
|
+
}
|
|
170
|
+
interface ScimGroupMember {
|
|
171
|
+
value: string;
|
|
172
|
+
display?: string;
|
|
173
|
+
$ref?: string;
|
|
174
|
+
}
|
|
175
|
+
interface ScimGroup {
|
|
176
|
+
schemas: string[];
|
|
177
|
+
id?: string;
|
|
178
|
+
externalId?: string;
|
|
179
|
+
displayName: string;
|
|
180
|
+
members?: ScimGroupMember[];
|
|
181
|
+
meta?: ScimMeta;
|
|
182
|
+
}
|
|
183
|
+
interface ScimListResponse<T = ScimUser | ScimGroup> {
|
|
184
|
+
schemas: ['urn:ietf:params:scim:api:messages:2.0:ListResponse'];
|
|
185
|
+
totalResults: number;
|
|
186
|
+
startIndex: number;
|
|
187
|
+
itemsPerPage: number;
|
|
188
|
+
Resources: T[];
|
|
189
|
+
}
|
|
190
|
+
interface ScimPatchOp {
|
|
191
|
+
op: 'add' | 'remove' | 'replace';
|
|
192
|
+
path?: string;
|
|
193
|
+
value?: unknown;
|
|
194
|
+
}
|
|
195
|
+
/** SCIM user stored in pocketid_scim_users */
|
|
196
|
+
interface ScimUserRecord {
|
|
197
|
+
id: string;
|
|
198
|
+
scim_id: string;
|
|
199
|
+
user_id: string;
|
|
200
|
+
scim_username: string;
|
|
201
|
+
scim_email: string | null;
|
|
202
|
+
scim_display_name: string | null;
|
|
203
|
+
active: boolean;
|
|
204
|
+
scim_payload: string | null;
|
|
205
|
+
created_at: string;
|
|
206
|
+
updated_at: string;
|
|
207
|
+
}
|
|
208
|
+
/** SCIM group stored in pocketid_scim_groups */
|
|
209
|
+
interface ScimGroupRecord {
|
|
210
|
+
id: string;
|
|
211
|
+
scim_id: string;
|
|
212
|
+
display_name: string;
|
|
213
|
+
nexus_role: string;
|
|
214
|
+
created_at: string;
|
|
215
|
+
updated_at: string;
|
|
216
|
+
}
|
|
217
|
+
/** SCIM sync log entry */
|
|
218
|
+
interface ScimLogEntry {
|
|
219
|
+
id: string;
|
|
220
|
+
operation: 'CREATE' | 'UPDATE' | 'DELETE';
|
|
221
|
+
resource_type: 'User' | 'Group';
|
|
222
|
+
scim_id: string;
|
|
223
|
+
nexus_id: string | null;
|
|
224
|
+
status: 'success' | 'error';
|
|
225
|
+
error_message: string | null;
|
|
226
|
+
created_at: string;
|
|
227
|
+
}
|
|
228
|
+
/** SCIM service interface */
|
|
229
|
+
interface ScimService {
|
|
230
|
+
getUser(scimId: string): Promise<ScimUser | null>;
|
|
231
|
+
listUsers(filter?: string, startIndex?: number, count?: number): Promise<ScimListResponse<ScimUser>>;
|
|
232
|
+
createUser(user: ScimUser): Promise<ScimUser>;
|
|
233
|
+
replaceUser(scimId: string, user: ScimUser): Promise<ScimUser>;
|
|
234
|
+
patchUser(scimId: string, ops: ScimPatchOp[]): Promise<ScimUser>;
|
|
235
|
+
deleteUser(scimId: string): Promise<void>;
|
|
236
|
+
getGroup(scimId: string): Promise<ScimGroup | null>;
|
|
237
|
+
listGroups(filter?: string, startIndex?: number, count?: number): Promise<ScimListResponse<ScimGroup>>;
|
|
238
|
+
createGroup(group: ScimGroup): Promise<ScimGroup>;
|
|
239
|
+
replaceGroup(scimId: string, group: ScimGroup): Promise<ScimGroup>;
|
|
240
|
+
patchGroup(scimId: string, ops: ScimPatchOp[]): Promise<ScimGroup>;
|
|
241
|
+
deleteGroup(scimId: string): Promise<void>;
|
|
242
|
+
}
|
|
243
|
+
/** SCIM config stored in database */
|
|
244
|
+
interface ScimConfig {
|
|
245
|
+
enabled: boolean;
|
|
246
|
+
token: string;
|
|
247
|
+
auto_create_users: boolean;
|
|
248
|
+
default_role: string;
|
|
249
|
+
sync_groups: boolean;
|
|
250
|
+
deprovisioning_action: 'deactivate' | 'delete';
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* SCIM Provisioning Service
|
|
255
|
+
*
|
|
256
|
+
* Handles SCIM 2.0 operations mapping PocketID users/groups
|
|
257
|
+
* to Nexus users and roles.
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
declare function getScimService(): ScimService;
|
|
261
|
+
declare function setScimService(service: ScimService): void;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* PocketID SCIM Module
|
|
265
|
+
*
|
|
266
|
+
* Provides a SCIM 2.0 server for user/group provisioning from PocketID.
|
|
267
|
+
* PocketID pushes user and group changes to our SCIM endpoints.
|
|
268
|
+
*
|
|
269
|
+
* Endpoints mounted at: /api/v1/pocketid/scim/
|
|
270
|
+
*/
|
|
271
|
+
declare const scimModule: ModuleManifest;
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* PocketID Plugin for Nexus.
|
|
275
|
+
*
|
|
276
|
+
* Provides OIDC authentication with PocketID for passwordless passkey login.
|
|
277
|
+
*
|
|
278
|
+
* Features:
|
|
279
|
+
* - OIDC Authorization Code Flow
|
|
280
|
+
* - User auto-registration or linking
|
|
281
|
+
* - Passkey-based authentication via PocketID
|
|
282
|
+
* - Domain allowlist support
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```typescript
|
|
286
|
+
* import { createNexus } from '@gzl10/nexus-backend'
|
|
287
|
+
* import { pocketIdPlugin } from '@gzl10/nexus-plugin-pocketid'
|
|
288
|
+
*
|
|
289
|
+
* const nexus = createNexus({
|
|
290
|
+
* plugins: [pocketIdPlugin]
|
|
291
|
+
* })
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
declare const pocketIdPlugin: PluginManifest;
|
|
295
|
+
|
|
296
|
+
export { type ConfigService, type PocketIdAuthService, type PocketIdConfig, type PocketIdState, type ScimConfig, type ScimGroup, type ScimGroupRecord, type ScimLogEntry, type ScimService, type ScimUser, type ScimUserRecord, type SessionResult, authActions, authModule, configModule, pocketIdPlugin as default, getAuthService, getConfigService, getScimService, pocketIdConfigEntity, pocketIdPlugin, scimConfigEntity, scimGroupsEntity, scimLogEntity, scimModule, scimUsersEntity, setAuthService, setConfigService, setScimService };
|