@scalekit-sdk/node 2.2.2 → 2.3.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.
Files changed (52) hide show
  1. package/lib/auth.d.ts +6 -6
  2. package/lib/auth.js +6 -6
  3. package/lib/auth.js.map +1 -1
  4. package/lib/connect.js +1 -1
  5. package/lib/connect.js.map +1 -1
  6. package/lib/connection.d.ts +3 -3
  7. package/lib/constants/user.js +18 -18
  8. package/lib/constants/user.js.map +1 -1
  9. package/lib/core.d.ts +6 -6
  10. package/lib/core.js +13 -12
  11. package/lib/core.js.map +1 -1
  12. package/lib/directory.d.ts +3 -3
  13. package/lib/directory.js +1 -1
  14. package/lib/domain.d.ts +5 -5
  15. package/lib/domain.js +6 -6
  16. package/lib/domain.js.map +1 -1
  17. package/lib/errors/base-exception.js +80 -48
  18. package/lib/errors/base-exception.js.map +1 -1
  19. package/lib/errors/specific-exceptions.js +1 -1
  20. package/lib/errors/specific-exceptions.js.map +1 -1
  21. package/lib/index.d.ts +4 -4
  22. package/lib/organization.d.ts +6 -6
  23. package/lib/organization.js +6 -6
  24. package/lib/organization.js.map +1 -1
  25. package/lib/passwordless.js +8 -6
  26. package/lib/passwordless.js.map +1 -1
  27. package/lib/permission.d.ts +5 -5
  28. package/lib/permission.js.map +1 -1
  29. package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.d.ts +29 -0
  30. package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js +23 -17
  31. package/lib/pkg/grpc/scalekit/v1/auth/auth_pb.js.map +1 -1
  32. package/lib/pkg/grpc/scalekit/v1/tokens/tokens_pb.d.ts +404 -0
  33. package/lib/pkg/grpc/scalekit/v1/tokens/tokens_pb.js +96 -0
  34. package/lib/pkg/grpc/scalekit/v1/tokens/tokens_pb.js.map +1 -0
  35. package/lib/pkg/grpc/scalekit/v1/users/users_pb.d.ts +22 -0
  36. package/lib/pkg/grpc/scalekit/v1/users/users_pb.js +8 -3
  37. package/lib/pkg/grpc/scalekit/v1/users/users_pb.js.map +1 -1
  38. package/lib/role.d.ts +5 -5
  39. package/lib/scalekit.d.ts +2 -0
  40. package/lib/scalekit.js +34 -32
  41. package/lib/scalekit.js.map +1 -1
  42. package/lib/session.d.ts +3 -3
  43. package/lib/session.js +7 -3
  44. package/lib/session.js.map +1 -1
  45. package/lib/token.d.ts +187 -0
  46. package/lib/token.js +221 -0
  47. package/lib/token.js.map +1 -0
  48. package/lib/user.d.ts +6 -6
  49. package/lib/user.js +11 -11
  50. package/lib/webauthn.js +3 -3
  51. package/lib/webauthn.js.map +1 -1
  52. package/package.json +6 -2
package/lib/token.d.ts ADDED
@@ -0,0 +1,187 @@
1
+ import type { MessageShape } from '@bufbuild/protobuf';
2
+ import { EmptySchema } from '@bufbuild/protobuf/wkt';
3
+ import type { Timestamp } from '@bufbuild/protobuf/wkt';
4
+ import GrpcConnect from './connect';
5
+ import CoreClient from './core';
6
+ import { CreateTokenResponse, ValidateTokenResponse, ListTokensResponse, Token } from './pkg/grpc/scalekit/v1/tokens/tokens_pb';
7
+ /**
8
+ * Options for creating an API token.
9
+ */
10
+ export interface CreateTokenOptions {
11
+ /** Optional User ID to scope token to a specific user */
12
+ userId?: string;
13
+ /** Optional custom claims key-value pairs (max 20 entries) */
14
+ customClaims?: {
15
+ [key: string]: string;
16
+ };
17
+ /** Optional expiry timestamp */
18
+ expiry?: Timestamp;
19
+ /** Optional human-readable label (max 255 chars) */
20
+ description?: string;
21
+ }
22
+ /**
23
+ * Options for listing API tokens.
24
+ */
25
+ export interface ListTokensOptions {
26
+ /** Optional User ID to filter tokens */
27
+ userId?: string;
28
+ /** Page size (default 10, max 30) */
29
+ pageSize?: number;
30
+ /** Pagination cursor for next page */
31
+ pageToken?: string;
32
+ }
33
+ /**
34
+ * Client for managing API tokens in your Scalekit application.
35
+ *
36
+ * API tokens provide programmatic access credentials for automated clients
37
+ * and external systems. Each token is scoped to an organization and optionally
38
+ * to a specific user.
39
+ *
40
+ * @example
41
+ * const scalekitClient = new ScalekitClient(envUrl, clientId, clientSecret);
42
+ * const tokenClient = scalekitClient.token;
43
+ *
44
+ * @see {@link https://docs.scalekit.com/apis/#tag/tokens | Token API Documentation}
45
+ */
46
+ export default class TokenClient {
47
+ private readonly grpcConnect;
48
+ private readonly coreClient;
49
+ private client;
50
+ constructor(grpcConnect: GrpcConnect, coreClient: CoreClient);
51
+ /**
52
+ * Creates a new API token for an organization.
53
+ *
54
+ * Generates an opaque token string that can be used for programmatic access.
55
+ * The plain-text token value is returned only at creation time.
56
+ *
57
+ * @param {string} organizationId - The organization ID to scope the token to
58
+ * @param {CreateTokenOptions} [options] - Optional configuration
59
+ * @param {string} [options.userId] - Optional user ID to scope the token to
60
+ * @param {object} [options.customClaims] - Optional custom claims key-value pairs
61
+ * @param {Timestamp} [options.expiry] - Optional expiry timestamp
62
+ * @param {string} [options.description] - Optional human-readable label
63
+ *
64
+ * @returns {Promise<CreateTokenResponse>} Response containing:
65
+ * - token: The opaque token string (only returned at creation)
66
+ * - tokenId: Internal token identifier (format: apit_xxxxx)
67
+ * - tokenInfo: Token metadata
68
+ *
69
+ * @example
70
+ * // Create a basic organization token
71
+ * const response = await scalekitClient.token.createToken('org_12345');
72
+ * console.log('Token:', response.token);
73
+ * console.log('Token ID:', response.tokenId);
74
+ *
75
+ * @example
76
+ * // Create a user-scoped token with custom claims
77
+ * const response = await scalekitClient.token.createToken('org_12345', {
78
+ * userId: 'usr_67890',
79
+ * customClaims: { env: 'production', scope: 'read' },
80
+ * description: 'CI/CD pipeline token'
81
+ * });
82
+ *
83
+ * @see {@link https://docs.scalekit.com/apis/#tag/tokens | Create Token API}
84
+ */
85
+ createToken(organizationId: string, options?: CreateTokenOptions): Promise<CreateTokenResponse>;
86
+ /**
87
+ * Validates an API token and returns associated context.
88
+ *
89
+ * Verifies the token is valid and returns the organization/user context
90
+ * along with any custom claims.
91
+ *
92
+ * @param {string} token - The opaque token string or token_id (apit_xxxxx)
93
+ *
94
+ * @returns {Promise<ValidateTokenResponse>} Response containing:
95
+ * - tokenInfo: Token metadata including organization, user, and custom claims
96
+ *
97
+ * @throws {ScalekitValidateTokenFailureException} If the token is invalid, expired, or not found
98
+ * @throws {ScalekitServerException} If a network or server error occurs
99
+ *
100
+ * @example
101
+ * // Validate a token
102
+ * try {
103
+ * const response = await scalekitClient.token.validateToken('opaque_token_string');
104
+ * console.log('Organization:', response.tokenInfo?.organizationId);
105
+ * console.log('Custom Claims:', response.tokenInfo?.customClaims);
106
+ * } catch (error) {
107
+ * console.error('Invalid token:', error);
108
+ * }
109
+ *
110
+ * @see {@link https://docs.scalekit.com/apis/#tag/tokens | Validate Token API}
111
+ */
112
+ validateToken(token: string): Promise<ValidateTokenResponse>;
113
+ /**
114
+ * Invalidates (soft deletes) an API token.
115
+ *
116
+ * Marks the token as invalid. This operation is idempotent - it succeeds
117
+ * even if the token was already invalidated.
118
+ *
119
+ * @param {string} token - The opaque token string or token_id (apit_xxxxx)
120
+ *
121
+ * @returns {Promise<MessageShape<typeof EmptySchema>>} Empty response on success
122
+ *
123
+ * @example
124
+ * // Revoke a token
125
+ * await scalekitClient.token.invalidateToken('apit_123456789');
126
+ * console.log('Token invalidated');
127
+ *
128
+ * @example
129
+ * // Revoke using opaque token string
130
+ * await scalekitClient.token.invalidateToken(opaqueTokenString);
131
+ *
132
+ * @see {@link https://docs.scalekit.com/apis/#tag/tokens | Invalidate Token API}
133
+ */
134
+ invalidateToken(token: string): Promise<MessageShape<typeof EmptySchema>>;
135
+ /**
136
+ * Lists API tokens for an organization with pagination.
137
+ *
138
+ * Retrieves all active tokens for an organization, with optional
139
+ * filtering by user and support for pagination.
140
+ *
141
+ * @param {string} organizationId - The organization ID to list tokens for
142
+ * @param {ListTokensOptions} [options] - Optional configuration
143
+ * @param {string} [options.userId] - Optional user ID to filter tokens
144
+ * @param {number} [options.pageSize] - Page size (default 10, max 30)
145
+ * @param {string} [options.pageToken] - Pagination cursor for next page
146
+ *
147
+ * @returns {Promise<ListTokensResponse>} Response containing:
148
+ * - tokens: Array of token metadata objects
149
+ * - totalCount: Total number of matching tokens
150
+ * - nextPageToken: Cursor for next page (empty if no more pages)
151
+ * - prevPageToken: Cursor for previous page
152
+ *
153
+ * @example
154
+ * // List tokens for an organization
155
+ * const response = await scalekitClient.token.listTokens('org_12345', {
156
+ * pageSize: 20
157
+ * });
158
+ *
159
+ * console.log('Tokens:', response.tokens);
160
+ * console.log('Total:', response.totalCount);
161
+ *
162
+ * @example
163
+ * // List tokens for a specific user
164
+ * const response = await scalekitClient.token.listTokens('org_12345', {
165
+ * userId: 'usr_67890'
166
+ * });
167
+ *
168
+ * @example
169
+ * // Paginate through all tokens
170
+ * let pageToken: string | undefined;
171
+ * let allTokens: Token[] = [];
172
+ *
173
+ * do {
174
+ * const response = await scalekitClient.token.listTokens('org_12345', {
175
+ * pageSize: 30,
176
+ * pageToken
177
+ * });
178
+ *
179
+ * allTokens.push(...response.tokens);
180
+ * pageToken = response.nextPageToken || undefined;
181
+ * } while (pageToken);
182
+ *
183
+ * @see {@link https://docs.scalekit.com/apis/#tag/tokens | List Tokens API}
184
+ */
185
+ listTokens(organizationId: string, options?: ListTokensOptions): Promise<ListTokensResponse>;
186
+ }
187
+ export { Token, CreateTokenResponse, ValidateTokenResponse, ListTokensResponse, };
package/lib/token.js ADDED
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const connect_1 = require("@connectrpc/connect");
13
+ const base_exception_1 = require("./errors/base-exception");
14
+ const tokens_pb_1 = require("./pkg/grpc/scalekit/v1/tokens/tokens_pb");
15
+ /**
16
+ * Client for managing API tokens in your Scalekit application.
17
+ *
18
+ * API tokens provide programmatic access credentials for automated clients
19
+ * and external systems. Each token is scoped to an organization and optionally
20
+ * to a specific user.
21
+ *
22
+ * @example
23
+ * const scalekitClient = new ScalekitClient(envUrl, clientId, clientSecret);
24
+ * const tokenClient = scalekitClient.token;
25
+ *
26
+ * @see {@link https://docs.scalekit.com/apis/#tag/tokens | Token API Documentation}
27
+ */
28
+ class TokenClient {
29
+ constructor(grpcConnect, coreClient) {
30
+ this.grpcConnect = grpcConnect;
31
+ this.coreClient = coreClient;
32
+ this.client = this.grpcConnect.createClient(tokens_pb_1.ApiTokenService);
33
+ }
34
+ /**
35
+ * Creates a new API token for an organization.
36
+ *
37
+ * Generates an opaque token string that can be used for programmatic access.
38
+ * The plain-text token value is returned only at creation time.
39
+ *
40
+ * @param {string} organizationId - The organization ID to scope the token to
41
+ * @param {CreateTokenOptions} [options] - Optional configuration
42
+ * @param {string} [options.userId] - Optional user ID to scope the token to
43
+ * @param {object} [options.customClaims] - Optional custom claims key-value pairs
44
+ * @param {Timestamp} [options.expiry] - Optional expiry timestamp
45
+ * @param {string} [options.description] - Optional human-readable label
46
+ *
47
+ * @returns {Promise<CreateTokenResponse>} Response containing:
48
+ * - token: The opaque token string (only returned at creation)
49
+ * - tokenId: Internal token identifier (format: apit_xxxxx)
50
+ * - tokenInfo: Token metadata
51
+ *
52
+ * @example
53
+ * // Create a basic organization token
54
+ * const response = await scalekitClient.token.createToken('org_12345');
55
+ * console.log('Token:', response.token);
56
+ * console.log('Token ID:', response.tokenId);
57
+ *
58
+ * @example
59
+ * // Create a user-scoped token with custom claims
60
+ * const response = await scalekitClient.token.createToken('org_12345', {
61
+ * userId: 'usr_67890',
62
+ * customClaims: { env: 'production', scope: 'read' },
63
+ * description: 'CI/CD pipeline token'
64
+ * });
65
+ *
66
+ * @see {@link https://docs.scalekit.com/apis/#tag/tokens | Create Token API}
67
+ */
68
+ createToken(organizationId, options) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ if (!organizationId) {
71
+ throw new Error('organizationId is required');
72
+ }
73
+ return this.coreClient.connectExec(this.client.createToken, {
74
+ token: Object.assign(Object.assign(Object.assign(Object.assign({ organizationId }, ((options === null || options === void 0 ? void 0 : options.userId) && { userId: options.userId })), ((options === null || options === void 0 ? void 0 : options.customClaims) && { customClaims: options.customClaims })), ((options === null || options === void 0 ? void 0 : options.expiry) && { expiry: options.expiry })), ((options === null || options === void 0 ? void 0 : options.description) && { description: options.description })),
75
+ });
76
+ });
77
+ }
78
+ /**
79
+ * Validates an API token and returns associated context.
80
+ *
81
+ * Verifies the token is valid and returns the organization/user context
82
+ * along with any custom claims.
83
+ *
84
+ * @param {string} token - The opaque token string or token_id (apit_xxxxx)
85
+ *
86
+ * @returns {Promise<ValidateTokenResponse>} Response containing:
87
+ * - tokenInfo: Token metadata including organization, user, and custom claims
88
+ *
89
+ * @throws {ScalekitValidateTokenFailureException} If the token is invalid, expired, or not found
90
+ * @throws {ScalekitServerException} If a network or server error occurs
91
+ *
92
+ * @example
93
+ * // Validate a token
94
+ * try {
95
+ * const response = await scalekitClient.token.validateToken('opaque_token_string');
96
+ * console.log('Organization:', response.tokenInfo?.organizationId);
97
+ * console.log('Custom Claims:', response.tokenInfo?.customClaims);
98
+ * } catch (error) {
99
+ * console.error('Invalid token:', error);
100
+ * }
101
+ *
102
+ * @see {@link https://docs.scalekit.com/apis/#tag/tokens | Validate Token API}
103
+ */
104
+ validateToken(token) {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ if (!token) {
107
+ throw new Error('token is required');
108
+ }
109
+ try {
110
+ return yield this.coreClient.connectExec(this.client.validateToken, {
111
+ token,
112
+ });
113
+ }
114
+ catch (error) {
115
+ if (error instanceof base_exception_1.ScalekitServerException) {
116
+ const tokenFailureCodes = new Set([
117
+ connect_1.Code.Unauthenticated,
118
+ connect_1.Code.NotFound,
119
+ connect_1.Code.InvalidArgument,
120
+ connect_1.Code.PermissionDenied,
121
+ ]);
122
+ if (tokenFailureCodes.has(error.grpcStatus)) {
123
+ throw new base_exception_1.ScalekitValidateTokenFailureException(error);
124
+ }
125
+ }
126
+ throw error;
127
+ }
128
+ });
129
+ }
130
+ /**
131
+ * Invalidates (soft deletes) an API token.
132
+ *
133
+ * Marks the token as invalid. This operation is idempotent - it succeeds
134
+ * even if the token was already invalidated.
135
+ *
136
+ * @param {string} token - The opaque token string or token_id (apit_xxxxx)
137
+ *
138
+ * @returns {Promise<MessageShape<typeof EmptySchema>>} Empty response on success
139
+ *
140
+ * @example
141
+ * // Revoke a token
142
+ * await scalekitClient.token.invalidateToken('apit_123456789');
143
+ * console.log('Token invalidated');
144
+ *
145
+ * @example
146
+ * // Revoke using opaque token string
147
+ * await scalekitClient.token.invalidateToken(opaqueTokenString);
148
+ *
149
+ * @see {@link https://docs.scalekit.com/apis/#tag/tokens | Invalidate Token API}
150
+ */
151
+ invalidateToken(token) {
152
+ return __awaiter(this, void 0, void 0, function* () {
153
+ if (!token) {
154
+ throw new Error('token is required');
155
+ }
156
+ return this.coreClient.connectExec(this.client.invalidateToken, {
157
+ token,
158
+ });
159
+ });
160
+ }
161
+ /**
162
+ * Lists API tokens for an organization with pagination.
163
+ *
164
+ * Retrieves all active tokens for an organization, with optional
165
+ * filtering by user and support for pagination.
166
+ *
167
+ * @param {string} organizationId - The organization ID to list tokens for
168
+ * @param {ListTokensOptions} [options] - Optional configuration
169
+ * @param {string} [options.userId] - Optional user ID to filter tokens
170
+ * @param {number} [options.pageSize] - Page size (default 10, max 30)
171
+ * @param {string} [options.pageToken] - Pagination cursor for next page
172
+ *
173
+ * @returns {Promise<ListTokensResponse>} Response containing:
174
+ * - tokens: Array of token metadata objects
175
+ * - totalCount: Total number of matching tokens
176
+ * - nextPageToken: Cursor for next page (empty if no more pages)
177
+ * - prevPageToken: Cursor for previous page
178
+ *
179
+ * @example
180
+ * // List tokens for an organization
181
+ * const response = await scalekitClient.token.listTokens('org_12345', {
182
+ * pageSize: 20
183
+ * });
184
+ *
185
+ * console.log('Tokens:', response.tokens);
186
+ * console.log('Total:', response.totalCount);
187
+ *
188
+ * @example
189
+ * // List tokens for a specific user
190
+ * const response = await scalekitClient.token.listTokens('org_12345', {
191
+ * userId: 'usr_67890'
192
+ * });
193
+ *
194
+ * @example
195
+ * // Paginate through all tokens
196
+ * let pageToken: string | undefined;
197
+ * let allTokens: Token[] = [];
198
+ *
199
+ * do {
200
+ * const response = await scalekitClient.token.listTokens('org_12345', {
201
+ * pageSize: 30,
202
+ * pageToken
203
+ * });
204
+ *
205
+ * allTokens.push(...response.tokens);
206
+ * pageToken = response.nextPageToken || undefined;
207
+ * } while (pageToken);
208
+ *
209
+ * @see {@link https://docs.scalekit.com/apis/#tag/tokens | List Tokens API}
210
+ */
211
+ listTokens(organizationId, options) {
212
+ return __awaiter(this, void 0, void 0, function* () {
213
+ if (!organizationId) {
214
+ throw new Error('organizationId is required');
215
+ }
216
+ return this.coreClient.connectExec(this.client.listTokens, Object.assign(Object.assign(Object.assign({ organizationId }, ((options === null || options === void 0 ? void 0 : options.userId) && { userId: options.userId })), ((options === null || options === void 0 ? void 0 : options.pageSize) !== undefined && { pageSize: options.pageSize })), ((options === null || options === void 0 ? void 0 : options.pageToken) && { pageToken: options.pageToken })));
217
+ });
218
+ }
219
+ }
220
+ exports.default = TokenClient;
221
+ //# sourceMappingURL=token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.js","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":";;;;;;;;;;;AAGA,iDAA2C;AAI3C,4DAGiC;AACjC,uEAMiD;AA4BjD;;;;;;;;;;;;GAYG;AACH,MAAqB,WAAW;IAE9B,YACmB,WAAwB,EACxB,UAAsB;QADtB,gBAAW,GAAX,WAAW,CAAa;QACxB,eAAU,GAAV,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,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,GACnE,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,KAAI,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,EAC3D,CAAC;QACL,CAAC;KAAA;CACF;AA/MD,8BA+MC"}
package/lib/user.d.ts CHANGED
@@ -11,12 +11,12 @@
11
11
  *
12
12
  * @see {@link https://docs.scalekit.com/apis/#tag/users | User API Documentation}
13
13
  */
14
- import type { MessageShape } from "@bufbuild/protobuf";
15
- import { EmptySchema } from "@bufbuild/protobuf/wkt";
16
- import GrpcConnect from "./connect";
17
- import CoreClient from "./core";
18
- import { CreateUserAndMembershipResponse, GetUserResponse, ListUsersResponse, UpdateUserResponse, CreateMembershipResponse, UpdateMembershipResponse, ListOrganizationUsersResponse, ResendInviteResponse } from "./pkg/grpc/scalekit/v1/users/users_pb";
19
- import { CreateUserRequest, UpdateUserRequest as UpdateUserRequestType } from "./types/user";
14
+ import type { MessageShape } from '@bufbuild/protobuf';
15
+ import { EmptySchema } from '@bufbuild/protobuf/wkt';
16
+ import GrpcConnect from './connect';
17
+ import CoreClient from './core';
18
+ import { CreateUserAndMembershipResponse, GetUserResponse, ListUsersResponse, UpdateUserResponse, CreateMembershipResponse, UpdateMembershipResponse, ListOrganizationUsersResponse, ResendInviteResponse } from './pkg/grpc/scalekit/v1/users/users_pb';
19
+ import { CreateUserRequest, UpdateUserRequest as UpdateUserRequestType } from './types/user';
20
20
  export default class UserClient {
21
21
  private readonly grpcConnect;
22
22
  private readonly coreClient;
package/lib/user.js CHANGED
@@ -78,10 +78,10 @@ class UserClient {
78
78
  createUserAndMembership(organizationId, options) {
79
79
  return __awaiter(this, void 0, void 0, function* () {
80
80
  if (!organizationId) {
81
- throw new Error("organizationId is required");
81
+ throw new Error('organizationId is required');
82
82
  }
83
83
  if (!options.email) {
84
- throw new Error("email is required");
84
+ throw new Error('email is required');
85
85
  }
86
86
  const user = (0, protobuf_1.create)(users_pb_2.CreateUserSchema, {
87
87
  email: options.email,
@@ -100,7 +100,7 @@ class UserClient {
100
100
  });
101
101
  const response = yield this.coreClient.connectExec(this.client.createUserAndMembership, request);
102
102
  if (!response.user) {
103
- throw new Error("Failed to create user");
103
+ throw new Error('Failed to create user');
104
104
  }
105
105
  return response;
106
106
  });
@@ -169,7 +169,7 @@ class UserClient {
169
169
  return __awaiter(this, void 0, void 0, function* () {
170
170
  return this.coreClient.connectExec(this.client.getUser, {
171
171
  identities: {
172
- case: "id",
172
+ case: 'id',
173
173
  value: userId,
174
174
  },
175
175
  });
@@ -338,7 +338,7 @@ class UserClient {
338
338
  });
339
339
  return this.coreClient.connectExec(this.client.updateUser, {
340
340
  identities: {
341
- case: "id",
341
+ case: 'id',
342
342
  value: userId,
343
343
  },
344
344
  user: updateUser,
@@ -389,7 +389,7 @@ class UserClient {
389
389
  return __awaiter(this, void 0, void 0, function* () {
390
390
  return this.coreClient.connectExec(this.client.deleteUser, {
391
391
  identities: {
392
- case: "id",
392
+ case: 'id',
393
393
  value: userId,
394
394
  },
395
395
  });
@@ -471,7 +471,7 @@ class UserClient {
471
471
  const request = (0, protobuf_1.create)(users_pb_2.CreateMembershipRequestSchema, {
472
472
  organizationId,
473
473
  identities: {
474
- case: "id",
474
+ case: 'id',
475
475
  value: userId,
476
476
  },
477
477
  membership,
@@ -527,7 +527,7 @@ class UserClient {
527
527
  return this.coreClient.connectExec(this.client.deleteMembership, {
528
528
  organizationId,
529
529
  identities: {
530
- case: "id",
530
+ case: 'id',
531
531
  value: userId,
532
532
  },
533
533
  });
@@ -616,7 +616,7 @@ class UserClient {
616
616
  return this.coreClient.connectExec(this.client.updateMembership, {
617
617
  organizationId,
618
618
  identities: {
619
- case: "id",
619
+ case: 'id',
620
620
  value: userId,
621
621
  },
622
622
  membership,
@@ -728,10 +728,10 @@ class UserClient {
728
728
  resendInvite(organizationId, userId) {
729
729
  return __awaiter(this, void 0, void 0, function* () {
730
730
  if (!organizationId) {
731
- throw new Error("organizationId is required");
731
+ throw new Error('organizationId is required');
732
732
  }
733
733
  if (!userId) {
734
- throw new Error("userId is required");
734
+ throw new Error('userId is required');
735
735
  }
736
736
  const request = (0, protobuf_1.create)(users_pb_2.ResendInviteRequestSchema, {
737
737
  organizationId,
package/lib/webauthn.js CHANGED
@@ -31,7 +31,7 @@ class WebAuthnClient {
31
31
  throw new Error('userId must be a non-empty string');
32
32
  }
33
33
  const request = (0, protobuf_1.create)(webauthn_pb_2.ListCredentialsRequestSchema, {
34
- userId
34
+ userId,
35
35
  });
36
36
  return this.coreClient.connectExec(this.client.listCredentials, request);
37
37
  });
@@ -53,7 +53,7 @@ class WebAuthnClient {
53
53
  }
54
54
  const request = (0, protobuf_1.create)(webauthn_pb_2.UpdateCredentialRequestSchema, {
55
55
  credentialId,
56
- displayName
56
+ displayName,
57
57
  });
58
58
  return this.coreClient.connectExec(this.client.updateCredential, request);
59
59
  });
@@ -71,7 +71,7 @@ class WebAuthnClient {
71
71
  throw new Error('credentialId must be a non-empty string');
72
72
  }
73
73
  const request = (0, protobuf_1.create)(webauthn_pb_2.DeleteCredentialRequestSchema, {
74
- credentialId
74
+ credentialId,
75
75
  });
76
76
  return this.coreClient.connectExec(this.client.deleteCredential, request);
77
77
  });
@@ -1 +1 @@
1
- {"version":3,"file":"webauthn.js","sourceRoot":"","sources":["../src/webauthn.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,iDAA4C;AAI5C,yEAA0E;AAC1E,yEAOiD;AAEjD,MAAqB,cAAc;IAGjC,YACmB,WAAwB,EACxB,UAAsB;QADtB,gBAAW,GAAX,WAAW,CAAa;QACxB,eAAU,GAAV,UAAU,CAAY;QAEvC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,6BAAe,CAAC,CAAC;IAC/D,CAAC;IAED;;;;;;OAMG;IACG,eAAe,CAAC,MAAc;;YAClC,IAAI,CAAC,MAAM,IAAI,OAAO,MAA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AM,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAC5E,CAAC;KAAA;IAED;;;;;;OAMG;IACG,gBAAgB,CACpB,YAAoB;;YAEpB,IAAI,CAAC,YAAY,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;gBACtD,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;YAC7D,CAAC;YAED,MAAM,OAAO,GAAG,IAAA,iBAAM,EAAC,2CAA6B,EAAE;gBACpD,YAAY;aACb,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;QAC5E,CAAC;KAAA;CACF;AA5ED,iCA4EC"}
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.2.2",
2
+ "version": "2.3.0",
3
3
  "name": "@scalekit-sdk/node",
4
4
  "description": "Official Scalekit Node SDK",
5
5
  "main": "lib/index.js",
@@ -16,7 +16,10 @@
16
16
  },
17
17
  "scripts": {
18
18
  "generate": "npx buf generate $npm_config_src",
19
+ "prebuild": "prettier --write .",
19
20
  "build": "rm -rf lib && tsc",
21
+ "lint": "tsc --noEmit",
22
+ "prettier": "prettier --check .",
20
23
  "test": "jest",
21
24
  "test:watch": "jest --watch"
22
25
  },
@@ -47,7 +50,8 @@
47
50
  "jest": "^29.7.0",
48
51
  "ts-jest": "^29.4.0",
49
52
  "ts-node": "^10.9.2",
50
- "typescript": "^5.5.3"
53
+ "typescript": "^5.5.3",
54
+ "prettier": "^3.4.2"
51
55
  },
52
56
  "bugs": {
53
57
  "url": "https://github.com/scalekit-inc/scalekit-sdk-node/issues"