@scalekit-sdk/node 2.1.7 → 2.1.9
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/buf.gen.yaml +1 -0
- package/lib/auth.d.ts +41 -9
- package/lib/auth.js +44 -12
- package/lib/auth.js.map +1 -1
- package/lib/connection.d.ts +195 -21
- package/lib/connection.js +197 -23
- package/lib/connection.js.map +1 -1
- package/lib/core.d.ts +2 -2
- package/lib/core.js +13 -12
- package/lib/core.js.map +1 -1
- package/lib/directory.d.ts +293 -40
- package/lib/directory.js +308 -44
- package/lib/directory.js.map +1 -1
- package/lib/domain.d.ts +172 -19
- package/lib/domain.js +192 -31
- package/lib/domain.js.map +1 -1
- package/lib/organization.d.ts +404 -44
- package/lib/organization.js +419 -54
- package/lib/organization.js.map +1 -1
- package/lib/permission.d.ts +179 -35
- package/lib/permission.js +190 -38
- package/lib/permission.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.d.ts +3 -3
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js +2 -2
- package/lib/pkg/grpc/scalekit/v1/auth/auth_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.d.ts +16 -16
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js +21 -21
- package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.d.ts +82 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js +90 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_connect.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.d.ts +647 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js +993 -0
- package/lib/pkg/grpc/scalekit/v1/auth/webauthn_pb.js.map +1 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.d.ts +142 -0
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js +165 -1
- package/lib/pkg/grpc/scalekit/v1/commons/commons_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.d.ts +1 -10
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js +0 -9
- package/lib/pkg/grpc/scalekit/v1/connections/connections_connect.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.d.ts +28 -63
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js +9 -90
- package/lib/pkg/grpc/scalekit/v1/connections/connections_pb.js.map +1 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.d.ts +2 -2
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js +1 -1
- package/lib/pkg/grpc/scalekit/v1/users/users_pb.js.map +1 -1
- package/lib/role.d.ts +252 -56
- package/lib/role.js +262 -62
- package/lib/role.js.map +1 -1
- package/lib/scalekit.d.ts +323 -54
- package/lib/scalekit.js +354 -76
- package/lib/scalekit.js.map +1 -1
- package/lib/session.d.ts +235 -22
- package/lib/session.js +237 -24
- package/lib/session.js.map +1 -1
- package/lib/user.d.ts +571 -53
- package/lib/user.js +598 -89
- package/lib/user.js.map +1 -1
- package/lib/webauthn.d.ts +33 -0
- package/lib/webauthn.js +80 -0
- package/lib/webauthn.js.map +1 -0
- package/package.json +2 -2
- package/src/auth.ts +53 -19
- package/src/connection.ts +237 -62
- package/src/core.ts +39 -33
- package/src/directory.ts +356 -98
- package/src/domain.ts +231 -62
- package/src/organization.ts +490 -112
- package/src/permission.ts +234 -88
- package/src/pkg/grpc/scalekit/v1/auth/auth_connect.ts +3 -3
- package/src/pkg/grpc/scalekit/v1/auth/auth_pb.ts +24 -24
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_connect.ts +89 -0
- package/src/pkg/grpc/scalekit/v1/auth/webauthn_pb.ts +1263 -0
- package/src/pkg/grpc/scalekit/v1/commons/commons_pb.ts +217 -0
- package/src/pkg/grpc/scalekit/v1/connections/connections_connect.ts +1 -10
- package/src/pkg/grpc/scalekit/v1/connections/connections_pb.ts +42 -129
- package/src/pkg/grpc/scalekit/v1/users/users_pb.ts +3 -3
- package/src/role.ts +336 -136
- package/src/scalekit.ts +478 -149
- package/src/session.ts +266 -63
- package/src/user.ts +675 -168
- package/src/webauthn.ts +98 -0
- package/tests/domain.test.ts +54 -0
package/src/webauthn.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { PromiseClient } from '@connectrpc/connect';
|
|
2
|
+
import GrpcConnect from './connect';
|
|
3
|
+
import CoreClient from './core';
|
|
4
|
+
import { WebAuthnService } from './pkg/grpc/scalekit/v1/auth/webauthn_connect';
|
|
5
|
+
import {
|
|
6
|
+
ListCredentialsRequest,
|
|
7
|
+
ListCredentialsResponse,
|
|
8
|
+
UpdateCredentialRequest,
|
|
9
|
+
UpdateCredentialResponse,
|
|
10
|
+
DeleteCredentialRequest,
|
|
11
|
+
DeleteCredentialResponse
|
|
12
|
+
} from './pkg/grpc/scalekit/v1/auth/webauthn_pb';
|
|
13
|
+
|
|
14
|
+
export default class WebAuthnClient {
|
|
15
|
+
private client: PromiseClient<typeof WebAuthnService>;
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
private readonly grpcConnect: GrpcConnect,
|
|
19
|
+
private readonly coreClient: CoreClient
|
|
20
|
+
) {
|
|
21
|
+
this.client = this.grpcConnect.createClient(WebAuthnService);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* List all WebAuthn credentials for a user
|
|
26
|
+
* @param {string} userId The user ID to list credentials for
|
|
27
|
+
* @returns {Promise<ListCredentialsResponse>} The response containing:
|
|
28
|
+
* - credentials: Array of WebAuthn credentials
|
|
29
|
+
* - allAcceptedCredentialsOptions: Options for all accepted credentials
|
|
30
|
+
*/
|
|
31
|
+
async listCredentials(userId: string): Promise<ListCredentialsResponse> {
|
|
32
|
+
if (!userId || typeof userId !== 'string') {
|
|
33
|
+
throw new Error('userId must be a non-empty string');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const request = new ListCredentialsRequest({
|
|
37
|
+
userId
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return this.coreClient.connectExec(
|
|
41
|
+
this.client.listCredentials,
|
|
42
|
+
request
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Update a WebAuthn credential's display name
|
|
48
|
+
* @param {string} credentialId The credential ID to update
|
|
49
|
+
* @param {string} displayName The new display name for the credential
|
|
50
|
+
* @returns {Promise<UpdateCredentialResponse>} The response containing:
|
|
51
|
+
* - credential: The updated WebAuthn credential
|
|
52
|
+
*/
|
|
53
|
+
async updateCredential(
|
|
54
|
+
credentialId: string,
|
|
55
|
+
displayName: string
|
|
56
|
+
): Promise<UpdateCredentialResponse> {
|
|
57
|
+
if (!credentialId || typeof credentialId !== 'string') {
|
|
58
|
+
throw new Error('credentialId must be a non-empty string');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!displayName || typeof displayName !== 'string') {
|
|
62
|
+
throw new Error('displayName must be a non-empty string');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const request = new UpdateCredentialRequest({
|
|
66
|
+
credentialId,
|
|
67
|
+
displayName
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
return this.coreClient.connectExec(
|
|
71
|
+
this.client.updateCredential,
|
|
72
|
+
request
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Delete a WebAuthn credential
|
|
78
|
+
* @param {string} credentialId The credential ID to delete
|
|
79
|
+
* @returns {Promise<DeleteCredentialResponse>} The response containing:
|
|
80
|
+
* - success: Boolean indicating if the deletion was successful
|
|
81
|
+
* - unknownCredentialOptions: Options if the credential was not found
|
|
82
|
+
*/
|
|
83
|
+
async deleteCredential(credentialId: string): Promise<DeleteCredentialResponse> {
|
|
84
|
+
if (!credentialId || typeof credentialId !== 'string') {
|
|
85
|
+
throw new Error('credentialId must be a non-empty string');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const request = new DeleteCredentialRequest({
|
|
89
|
+
credentialId
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return this.coreClient.connectExec(
|
|
93
|
+
this.client.deleteCredential,
|
|
94
|
+
request
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
package/tests/domain.test.ts
CHANGED
|
@@ -149,6 +149,60 @@ describe('Domains', () => {
|
|
|
149
149
|
expect(domainTypes).toContain(DomainType.ALLOWED_EMAIL_DOMAIN);
|
|
150
150
|
expect(domainTypes).toContain(DomainType.ORGANIZATION_DOMAIN);
|
|
151
151
|
});
|
|
152
|
+
|
|
153
|
+
it('should list domains filtered by ALLOWED_EMAIL_DOMAIN type', async () => {
|
|
154
|
+
// Create domains of different types
|
|
155
|
+
const { domainName: allowedDomainName } = await TestDomainManager.createTestDomain(client, testOrg, 'allowed');
|
|
156
|
+
const { domainName: orgDomainName } = await TestDomainManager.createTestDomain(client, testOrg, 'organization');
|
|
157
|
+
|
|
158
|
+
// Filter by ALLOWED_EMAIL_DOMAIN type
|
|
159
|
+
const response = await client.domain.listDomains(testOrg, {
|
|
160
|
+
domainType: DomainType.ALLOWED_EMAIL_DOMAIN
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
expect(response).toBeDefined();
|
|
164
|
+
expect(response.domains).toBeDefined();
|
|
165
|
+
expect(Array.isArray(response.domains)).toBe(true);
|
|
166
|
+
|
|
167
|
+
// Verify all returned domains are of type ALLOWED_EMAIL_DOMAIN
|
|
168
|
+
response.domains.forEach(domain => {
|
|
169
|
+
expect(domain.domainType).toBe(DomainType.ALLOWED_EMAIL_DOMAIN);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Verify the allowed domain is in the filtered list
|
|
173
|
+
const domainNames = response.domains.map(d => d.domain);
|
|
174
|
+
expect(domainNames).toContain(allowedDomainName);
|
|
175
|
+
|
|
176
|
+
// Verify the organization domain is NOT in the filtered list
|
|
177
|
+
expect(domainNames).not.toContain(orgDomainName);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('should list domains filtered by ORGANIZATION_DOMAIN type', async () => {
|
|
181
|
+
// Create domains of different types
|
|
182
|
+
const { domainName: allowedDomainName } = await TestDomainManager.createTestDomain(client, testOrg, 'allowed');
|
|
183
|
+
const { domainName: orgDomainName } = await TestDomainManager.createTestDomain(client, testOrg, 'organization');
|
|
184
|
+
|
|
185
|
+
// Filter by ORGANIZATION_DOMAIN type
|
|
186
|
+
const response = await client.domain.listDomains(testOrg, {
|
|
187
|
+
domainType: DomainType.ORGANIZATION_DOMAIN
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
expect(response).toBeDefined();
|
|
191
|
+
expect(response.domains).toBeDefined();
|
|
192
|
+
expect(Array.isArray(response.domains)).toBe(true);
|
|
193
|
+
|
|
194
|
+
// Verify all returned domains are of type ORGANIZATION_DOMAIN
|
|
195
|
+
response.domains.forEach(domain => {
|
|
196
|
+
expect(domain.domainType).toBe(DomainType.ORGANIZATION_DOMAIN);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// Verify the organization domain is in the filtered list
|
|
200
|
+
const domainNames = response.domains.map(d => d.domain);
|
|
201
|
+
expect(domainNames).toContain(orgDomainName);
|
|
202
|
+
|
|
203
|
+
// Verify the allowed domain is NOT in the filtered list
|
|
204
|
+
expect(domainNames).not.toContain(allowedDomainName);
|
|
205
|
+
});
|
|
152
206
|
});
|
|
153
207
|
|
|
154
208
|
describe('getDomain', () => {
|