@palmetto/users-sdk 1.2.0 → 1.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.
- package/dist/__generated__/schema.d.ts +15 -0
- package/dist/client.d.ts +88 -31
- package/dist/client.js +19 -3
- package/dist/main.d.ts +2 -2
- package/dist/main.js +0 -1
- package/package.json +4 -1
- package/dist/scopes.d.ts +0 -11
- package/dist/scopes.js +0 -50
|
@@ -925,6 +925,11 @@ export interface components {
|
|
|
925
925
|
/** @enum {string} */
|
|
926
926
|
grant_type: "authorization_code";
|
|
927
927
|
code: string;
|
|
928
|
+
/**
|
|
929
|
+
* @deprecated
|
|
930
|
+
* @description Obtain access tokens without verifying that the user exists
|
|
931
|
+
*/
|
|
932
|
+
skip_user_verification?: boolean;
|
|
928
933
|
} | {
|
|
929
934
|
/** @enum {string} */
|
|
930
935
|
grant_type: "refresh_token";
|
|
@@ -947,6 +952,7 @@ export interface components {
|
|
|
947
952
|
lastName?: string;
|
|
948
953
|
/** Format: email */
|
|
949
954
|
email?: string;
|
|
955
|
+
roleIds?: string[];
|
|
950
956
|
};
|
|
951
957
|
/** SignUpToken */
|
|
952
958
|
SignUpTokenDto: {
|
|
@@ -2282,6 +2288,15 @@ export interface operations {
|
|
|
2282
2288
|
"application/json": components["schemas"]["BadRequestErrorDto"];
|
|
2283
2289
|
};
|
|
2284
2290
|
};
|
|
2291
|
+
/** @description When the user does not exist for the exchange token */
|
|
2292
|
+
404: {
|
|
2293
|
+
headers: {
|
|
2294
|
+
[name: string]: unknown;
|
|
2295
|
+
};
|
|
2296
|
+
content: {
|
|
2297
|
+
"application/json": components["schemas"]["NotFoundErrorDto"];
|
|
2298
|
+
};
|
|
2299
|
+
};
|
|
2285
2300
|
};
|
|
2286
2301
|
};
|
|
2287
2302
|
SignUpsController_findAll: {
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ApiInput, ApiResponse, BaseSdkClient, CreateSdkClientInput, RequestOptions, SdkError } from "@palmetto/base-sdk-client";
|
|
2
2
|
import { ResultOk } from "@palmetto/result";
|
|
3
|
+
import { ErrorResponse } from "openapi-typescript-helpers";
|
|
3
4
|
import { paths } from "./__generated__/schema";
|
|
5
|
+
export type ReExportedErrorResponse<T extends Record<string | number, any>> = ErrorResponse<T>;
|
|
4
6
|
export declare class UsersApiClient extends BaseSdkClient<paths> {
|
|
5
7
|
constructor(input: CreateSdkClientInput);
|
|
6
8
|
me(input: MeInput, opts?: RequestOptions): Promise<ResultOk<MeResponseV2> | SdkError<paths["/api/v2/users/me"]["get"]["responses"]["401"]["content"]["application/json"] | paths["/api/v2/users/me"]["get"]["responses"]["403"]["content"]["application/json"]>>;
|
|
@@ -23,7 +25,7 @@ export declare class UsersApiClient extends BaseSdkClient<paths> {
|
|
|
23
25
|
phoneNumber: string;
|
|
24
26
|
organizationId: string;
|
|
25
27
|
hasPAT: boolean;
|
|
26
|
-
}> | SdkError<
|
|
28
|
+
}> | SdkError<ErrorResponse<{
|
|
27
29
|
200: {
|
|
28
30
|
headers: {
|
|
29
31
|
[name: string]: unknown;
|
|
@@ -77,7 +79,7 @@ export declare class UsersApiClient extends BaseSdkClient<paths> {
|
|
|
77
79
|
totalRecords: number;
|
|
78
80
|
totalPages: number;
|
|
79
81
|
};
|
|
80
|
-
}> | SdkError<
|
|
82
|
+
}> | SdkError<ErrorResponse<{
|
|
81
83
|
200: {
|
|
82
84
|
headers: {
|
|
83
85
|
[name: string]: unknown;
|
|
@@ -129,7 +131,7 @@ export declare class UsersApiClient extends BaseSdkClient<paths> {
|
|
|
129
131
|
phoneNumber: string;
|
|
130
132
|
organizationId: string;
|
|
131
133
|
hasPAT: boolean;
|
|
132
|
-
}> | SdkError<
|
|
134
|
+
}> | SdkError<ErrorResponse<{
|
|
133
135
|
200: {
|
|
134
136
|
headers: {
|
|
135
137
|
[name: string]: unknown;
|
|
@@ -181,7 +183,7 @@ export declare class UsersApiClient extends BaseSdkClient<paths> {
|
|
|
181
183
|
permissions: {
|
|
182
184
|
[key: string]: string[];
|
|
183
185
|
};
|
|
184
|
-
}> | SdkError<
|
|
186
|
+
}> | SdkError<ErrorResponse<{
|
|
185
187
|
200: {
|
|
186
188
|
headers: {
|
|
187
189
|
[name: string]: unknown;
|
|
@@ -233,7 +235,7 @@ export declare class UsersApiClient extends BaseSdkClient<paths> {
|
|
|
233
235
|
permissions: {
|
|
234
236
|
[key: string]: string[];
|
|
235
237
|
};
|
|
236
|
-
}> | SdkError<
|
|
238
|
+
}> | SdkError<ErrorResponse<{
|
|
237
239
|
200: {
|
|
238
240
|
headers: {
|
|
239
241
|
[name: string]: unknown;
|
|
@@ -277,7 +279,7 @@ export declare class UsersApiClient extends BaseSdkClient<paths> {
|
|
|
277
279
|
}, `${string}/${string}`>>>;
|
|
278
280
|
createSignUp(input: CreateSignUpInput, opts?: RequestOptions): Promise<ResultOk<{
|
|
279
281
|
token: string;
|
|
280
|
-
}> | SdkError<
|
|
282
|
+
}> | SdkError<ErrorResponse<{
|
|
281
283
|
201: {
|
|
282
284
|
headers: {
|
|
283
285
|
[name: string]: unknown;
|
|
@@ -320,7 +322,7 @@ export declare class UsersApiClient extends BaseSdkClient<paths> {
|
|
|
320
322
|
lastName?: string;
|
|
321
323
|
email?: string;
|
|
322
324
|
expiresAt: string;
|
|
323
|
-
}> | SdkError<
|
|
325
|
+
}> | SdkError<ErrorResponse<{
|
|
324
326
|
200: {
|
|
325
327
|
headers: {
|
|
326
328
|
[name: string]: unknown;
|
|
@@ -358,7 +360,7 @@ export declare class UsersApiClient extends BaseSdkClient<paths> {
|
|
|
358
360
|
totalRecords: number;
|
|
359
361
|
totalPages: number;
|
|
360
362
|
};
|
|
361
|
-
}> | SdkError<
|
|
363
|
+
}> | SdkError<ErrorResponse<{
|
|
362
364
|
200: {
|
|
363
365
|
headers: {
|
|
364
366
|
[name: string]: unknown;
|
|
@@ -403,7 +405,7 @@ export declare class UsersApiClient extends BaseSdkClient<paths> {
|
|
|
403
405
|
lastName?: string;
|
|
404
406
|
email?: string;
|
|
405
407
|
expiresAt: string;
|
|
406
|
-
}> | SdkError<
|
|
408
|
+
}> | SdkError<ErrorResponse<{
|
|
407
409
|
200: {
|
|
408
410
|
headers: {
|
|
409
411
|
[name: string]: unknown;
|
|
@@ -445,35 +447,87 @@ export declare class UsersApiClient extends BaseSdkClient<paths> {
|
|
|
445
447
|
};
|
|
446
448
|
};
|
|
447
449
|
}, `${string}/${string}`>>>;
|
|
448
|
-
getAuthToken({ code }: GetAuthTokenInput, opts?: RequestOptions): Promise<ResultOk<
|
|
449
|
-
accessToken: string;
|
|
450
|
-
idToken: string;
|
|
451
|
-
refreshToken: string;
|
|
452
|
-
expiresIn: number;
|
|
453
|
-
}> | SdkError<{
|
|
454
|
-
error: "BadRequest";
|
|
455
|
-
statusCode: 400;
|
|
456
|
-
message: string;
|
|
457
|
-
reason: string;
|
|
458
|
-
validations: {
|
|
459
|
-
[key: string]: string[];
|
|
460
|
-
};
|
|
461
|
-
}>>;
|
|
450
|
+
getAuthToken({ code, skipUserVerification }: GetAuthTokenInput, opts?: RequestOptions): Promise<ResultOk<GetTokenResponse> | SdkError<ReExportedErrorResponse<paths["/api/auth/token"]["post"]["responses"]>>>;
|
|
462
451
|
refreshToken({ refreshToken }: RefreshTokenInput, opts?: RequestOptions): Promise<ResultOk<{
|
|
463
452
|
accessToken: string;
|
|
464
453
|
idToken: string;
|
|
465
454
|
refreshToken: string;
|
|
466
455
|
expiresIn: number;
|
|
467
|
-
}> | SdkError<{
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
456
|
+
}> | SdkError<ErrorResponse<{
|
|
457
|
+
200: {
|
|
458
|
+
headers: {
|
|
459
|
+
[name: string]: unknown;
|
|
460
|
+
};
|
|
461
|
+
content: {
|
|
462
|
+
"application/json": import("./__generated__/schema").components["schemas"]["TokenResponseDto"];
|
|
463
|
+
};
|
|
474
464
|
};
|
|
475
|
-
|
|
465
|
+
400: {
|
|
466
|
+
headers: {
|
|
467
|
+
[name: string]: unknown;
|
|
468
|
+
};
|
|
469
|
+
content: {
|
|
470
|
+
"application/json": import("./__generated__/schema").components["schemas"]["BadRequestErrorDto"];
|
|
471
|
+
};
|
|
472
|
+
};
|
|
473
|
+
404: {
|
|
474
|
+
headers: {
|
|
475
|
+
[name: string]: unknown;
|
|
476
|
+
};
|
|
477
|
+
content: {
|
|
478
|
+
"application/json": import("./__generated__/schema").components["schemas"]["NotFoundErrorDto"];
|
|
479
|
+
};
|
|
480
|
+
};
|
|
481
|
+
}, `${string}/${string}`>>>;
|
|
476
482
|
private getToken;
|
|
483
|
+
getRoles(input: GetRolesInput, opts?: RequestOptions): Promise<ResultOk<{
|
|
484
|
+
data: import("./__generated__/schema").components["schemas"]["RoleDto"][];
|
|
485
|
+
} & {
|
|
486
|
+
data: unknown[];
|
|
487
|
+
paging: {
|
|
488
|
+
limit: number;
|
|
489
|
+
page: number;
|
|
490
|
+
pageStart: number;
|
|
491
|
+
pageEnd: number;
|
|
492
|
+
totalRecords: number;
|
|
493
|
+
totalPages: number;
|
|
494
|
+
};
|
|
495
|
+
}> | SdkError<ErrorResponse<{
|
|
496
|
+
200: {
|
|
497
|
+
headers: {
|
|
498
|
+
[name: string]: unknown;
|
|
499
|
+
};
|
|
500
|
+
content: {
|
|
501
|
+
"application/json": {
|
|
502
|
+
data: import("./__generated__/schema").components["schemas"]["RoleDto"][];
|
|
503
|
+
} & import("./__generated__/schema").components["schemas"]["PaginatedListDto"];
|
|
504
|
+
};
|
|
505
|
+
};
|
|
506
|
+
400: {
|
|
507
|
+
headers: {
|
|
508
|
+
[name: string]: unknown;
|
|
509
|
+
};
|
|
510
|
+
content: {
|
|
511
|
+
"application/json": import("./__generated__/schema").components["schemas"]["BadRequestErrorDto"];
|
|
512
|
+
};
|
|
513
|
+
};
|
|
514
|
+
401: {
|
|
515
|
+
headers: {
|
|
516
|
+
[name: string]: unknown;
|
|
517
|
+
};
|
|
518
|
+
content: {
|
|
519
|
+
"application/json": import("./__generated__/schema").components["schemas"]["UnauthorizedErrorDto"];
|
|
520
|
+
};
|
|
521
|
+
};
|
|
522
|
+
403: {
|
|
523
|
+
headers: {
|
|
524
|
+
[name: string]: unknown;
|
|
525
|
+
};
|
|
526
|
+
content: {
|
|
527
|
+
"application/json": import("./__generated__/schema").components["schemas"]["ForbiddenErrorDto"];
|
|
528
|
+
};
|
|
529
|
+
};
|
|
530
|
+
}, `${string}/${string}`>>>;
|
|
477
531
|
}
|
|
478
532
|
export interface MeInput {
|
|
479
533
|
v2Response: true;
|
|
@@ -504,8 +558,11 @@ export type GetSignUpInput = ApiInput<paths["/api/sign-ups/{token}"]["get"]>;
|
|
|
504
558
|
export type GetSignUpResponse = ApiResponse<paths["/api/sign-ups/{token}"]["get"]>;
|
|
505
559
|
export type CreateSignUpUserInput = ApiInput<paths["/api/sign-ups/{token}/user"]["post"]>;
|
|
506
560
|
export type CreateSignUpUserResponse = ApiResponse<paths["/api/sign-ups/{token}/user"]["post"]>;
|
|
561
|
+
export type GetRolesInput = ApiInput<paths["/api/roles"]["get"]>;
|
|
562
|
+
export type GetRolesResponse = ApiResponse<paths["/api/roles"]["get"]>;
|
|
507
563
|
export interface GetAuthTokenInput {
|
|
508
564
|
code: string;
|
|
565
|
+
skipUserVerification: boolean;
|
|
509
566
|
}
|
|
510
567
|
export interface RefreshTokenInput {
|
|
511
568
|
refreshToken: string;
|
package/dist/client.js
CHANGED
|
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.UsersApiClient = void 0;
|
|
24
24
|
const base_sdk_client_1 = require("@palmetto/base-sdk-client");
|
|
25
25
|
const result_1 = require("@palmetto/result");
|
|
26
|
-
const SDK_VERSION_SLUG = "palmetto-users-sdk/1.2.
|
|
26
|
+
const SDK_VERSION_SLUG = "palmetto-users-sdk/1.2.1";
|
|
27
27
|
class UsersApiClient extends base_sdk_client_1.BaseSdkClient {
|
|
28
28
|
constructor(input) {
|
|
29
29
|
super(Object.assign(Object.assign({}, input), { sdkVersion: SDK_VERSION_SLUG }));
|
|
@@ -177,8 +177,12 @@ class UsersApiClient extends base_sdk_client_1.BaseSdkClient {
|
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
179
|
getAuthToken(_a, opts_1) {
|
|
180
|
-
return __awaiter(this, arguments, void 0, function* ({ code }, opts) {
|
|
181
|
-
return this.getToken({
|
|
180
|
+
return __awaiter(this, arguments, void 0, function* ({ code, skipUserVerification }, opts) {
|
|
181
|
+
return this.getToken({
|
|
182
|
+
grant_type: "authorization_code",
|
|
183
|
+
code,
|
|
184
|
+
skip_user_verification: skipUserVerification,
|
|
185
|
+
}, opts);
|
|
182
186
|
});
|
|
183
187
|
}
|
|
184
188
|
refreshToken(_a, opts_1) {
|
|
@@ -206,5 +210,17 @@ class UsersApiClient extends base_sdk_client_1.BaseSdkClient {
|
|
|
206
210
|
return this.handleErrorResponse(error, response);
|
|
207
211
|
});
|
|
208
212
|
}
|
|
213
|
+
getRoles(input, opts) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
const { data, error, response } = yield this.client.GET("/api/roles", {
|
|
216
|
+
params: { query: input },
|
|
217
|
+
headers: this.generateHeaders(opts),
|
|
218
|
+
});
|
|
219
|
+
if (data) {
|
|
220
|
+
return (0, result_1.Ok)(data);
|
|
221
|
+
}
|
|
222
|
+
return this.handleErrorResponse(error, response);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
209
225
|
}
|
|
210
226
|
exports.UsersApiClient = UsersApiClient;
|
package/dist/main.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * from "./client.js";
|
|
2
|
-
export
|
|
3
|
-
export { type
|
|
2
|
+
export { type RequestOptions, type SdkError } from "@palmetto/base-sdk-client";
|
|
3
|
+
export { type ErrorResponse } from "openapi-typescript-helpers";
|
package/dist/main.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@palmetto/users-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "./dist/main.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**/*",
|
|
@@ -15,8 +15,11 @@
|
|
|
15
15
|
"tc": "tsc --noEmit",
|
|
16
16
|
"start:dev": "tsc --watch",
|
|
17
17
|
"build": "tsc",
|
|
18
|
+
"clean": "rm -rf ./dist/",
|
|
18
19
|
"generate": "node ./scripts/generateApiSchema.mjs",
|
|
20
|
+
"refresh": "yarn generate && yarn build",
|
|
19
21
|
"prepublishOnly": "yarn build",
|
|
22
|
+
"ci:build": "tsc",
|
|
20
23
|
"ci:lint": "eslint . && prettier --check --loglevel warn ./src",
|
|
21
24
|
"ci:tc": "yarn tc",
|
|
22
25
|
"hook:lint": "eslint --cache --fix",
|
package/dist/scopes.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type GrantScope = "@deny" | "@self" | "@org" | "@admin";
|
|
2
|
-
export declare function isGrantScope(value: unknown): value is GrantScope;
|
|
3
|
-
export declare function valueOfScope(scope: GrantScope): number;
|
|
4
|
-
export declare function compareScopes(a: GrantScope, b: GrantScope): -1 | 0 | 1;
|
|
5
|
-
export declare function highestScope(scopes: GrantScope[]): GrantScope;
|
|
6
|
-
export interface LowestScopeOptions {
|
|
7
|
-
includeDeny: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare function lowestScope(scopes: GrantScope[], options?: LowestScopeOptions): GrantScope;
|
|
10
|
-
export type ScopeOperator = "eq" | "neq" | "lt" | "lte" | "gt" | "gte";
|
|
11
|
-
export declare function scopeMatch(left: GrantScope, op: ScopeOperator, right: GrantScope): boolean;
|
package/dist/scopes.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isGrantScope = isGrantScope;
|
|
4
|
-
exports.valueOfScope = valueOfScope;
|
|
5
|
-
exports.compareScopes = compareScopes;
|
|
6
|
-
exports.highestScope = highestScope;
|
|
7
|
-
exports.lowestScope = lowestScope;
|
|
8
|
-
exports.scopeMatch = scopeMatch;
|
|
9
|
-
const scopeOrder = ["@deny", "@self", "@org", "@admin"];
|
|
10
|
-
function isGrantScope(value) {
|
|
11
|
-
return typeof value === "string" && scopeOrder.includes(value);
|
|
12
|
-
}
|
|
13
|
-
function valueOfScope(scope) {
|
|
14
|
-
return scopeOrder.indexOf(scope);
|
|
15
|
-
}
|
|
16
|
-
function compareScopes(a, b) {
|
|
17
|
-
if (a === b) {
|
|
18
|
-
return 0;
|
|
19
|
-
}
|
|
20
|
-
return valueOfScope(a) < valueOfScope(b) ? -1 : 1;
|
|
21
|
-
}
|
|
22
|
-
function highestScope(scopes) {
|
|
23
|
-
var _a;
|
|
24
|
-
return (_a = [...scopes].sort(compareScopes)[scopes.length - 1]) !== null && _a !== void 0 ? _a : "@deny";
|
|
25
|
-
}
|
|
26
|
-
function lowestScope(scopes, options) {
|
|
27
|
-
var _a;
|
|
28
|
-
const filtered = (options === null || options === void 0 ? void 0 : options.includeDeny)
|
|
29
|
-
? [...scopes]
|
|
30
|
-
: [...scopes].filter((elem) => elem !== "@deny");
|
|
31
|
-
return (_a = filtered.sort(compareScopes)[0]) !== null && _a !== void 0 ? _a : "@deny";
|
|
32
|
-
}
|
|
33
|
-
function scopeMatch(left, op, right) {
|
|
34
|
-
const leftValue = valueOfScope(left);
|
|
35
|
-
const rightValue = valueOfScope(right);
|
|
36
|
-
switch (op) {
|
|
37
|
-
case "eq":
|
|
38
|
-
return leftValue === rightValue;
|
|
39
|
-
case "neq":
|
|
40
|
-
return leftValue !== rightValue;
|
|
41
|
-
case "lt":
|
|
42
|
-
return leftValue < rightValue;
|
|
43
|
-
case "lte":
|
|
44
|
-
return leftValue <= rightValue;
|
|
45
|
-
case "gt":
|
|
46
|
-
return leftValue > rightValue;
|
|
47
|
-
case "gte":
|
|
48
|
-
return leftValue >= rightValue;
|
|
49
|
-
}
|
|
50
|
-
}
|