@appsemble/node-utils 0.28.12 → 0.29.1
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 +3 -3
- package/package.json +3 -3
- package/scim.d.ts +12 -18
- package/scim.js +18 -20
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#  Appsemble Node Utilities
|
|
2
2
|
|
|
3
3
|
> NodeJS utilities used by Appsemble internally.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@appsemble/node-utils)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.29.1)
|
|
7
7
|
[](https://prettier.io)
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
@@ -26,5 +26,5 @@ compatibility is not guaranteed.
|
|
|
26
26
|
|
|
27
27
|
## License
|
|
28
28
|
|
|
29
|
-
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.
|
|
29
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.29.1/LICENSE.md) ©
|
|
30
30
|
[Appsemble](https://appsemble.com)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/node-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.1",
|
|
4
4
|
"description": "NodeJS utilities used by Appsemble internally.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"test": "vitest"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@appsemble/types": "0.
|
|
42
|
-
"@appsemble/utils": "0.
|
|
41
|
+
"@appsemble/types": "0.29.1",
|
|
42
|
+
"@appsemble/utils": "0.29.1",
|
|
43
43
|
"@formatjs/fast-memoize": "^2.0.0",
|
|
44
44
|
"@fortawesome/fontawesome-free": "^6.0.0",
|
|
45
45
|
"@koa/cors": "^4.0.0",
|
package/scim.d.ts
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
|
+
import { type Context } from 'koa';
|
|
1
2
|
/**
|
|
2
3
|
* The SCIM protocol uses the HTTP response status codes defined in
|
|
3
4
|
* [Section 6 of [RFC7231]](https://datatracker.ietf.org/doc/html/rfc7231#section-6) to indicate
|
|
4
|
-
* operation success or failure.
|
|
5
|
+
* operation success or failure.
|
|
6
|
+
*
|
|
7
|
+
* In addition to returning an HTTP response code, implementers
|
|
5
8
|
* **MUST** return the errors in the body of the response in a JSON format, using the attributes
|
|
6
|
-
* described below.
|
|
9
|
+
* described below.
|
|
10
|
+
*
|
|
11
|
+
* Error responses are identified using the following "schema" URI:
|
|
7
12
|
* `"urn:ietf:params:scim:api:messages:2.0:Error"`.
|
|
8
13
|
*
|
|
14
|
+
* @param condition The condition to check.
|
|
15
|
+
* @param ctx The Koa context used to throw the error response.
|
|
16
|
+
* @param status The HTTP status code (see [Section 6 of [RFC7231]](https://datatracker.ietf.org/doc/html/rfc7231#section-6)) expressed as a JSON string.
|
|
17
|
+
* @param detail A detailed human-readable message.
|
|
9
18
|
* @see https://datatracker.ietf.org/doc/html/rfc7644#section-3.12
|
|
10
19
|
*/
|
|
11
|
-
export declare
|
|
12
|
-
schemas: string[];
|
|
13
|
-
/**
|
|
14
|
-
* The HTTP status code (see
|
|
15
|
-
* [Section 6 of [RFC7231]](https://datatracker.ietf.org/doc/html/rfc7231#section-6)) expressed as
|
|
16
|
-
* a JSON string.
|
|
17
|
-
*/
|
|
18
|
-
status: string;
|
|
19
|
-
/**
|
|
20
|
-
* A detailed human-readable message.
|
|
21
|
-
*/
|
|
22
|
-
detail: string;
|
|
23
|
-
constructor(status: number, detail: string);
|
|
24
|
-
toJSON(): Pick<SCIMError, 'detail' | 'schemas' | 'status'>;
|
|
25
|
-
}
|
|
26
|
-
export declare function scimAssert(condition: unknown, status: number, detail: string): asserts condition;
|
|
20
|
+
export declare function scimAssert(condition: unknown, ctx: Context, status: number, detail: string): asserts condition;
|
package/scim.js
CHANGED
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The SCIM protocol uses the HTTP response status codes defined in
|
|
3
3
|
* [Section 6 of [RFC7231]](https://datatracker.ietf.org/doc/html/rfc7231#section-6) to indicate
|
|
4
|
-
* operation success or failure.
|
|
4
|
+
* operation success or failure.
|
|
5
|
+
*
|
|
6
|
+
* In addition to returning an HTTP response code, implementers
|
|
5
7
|
* **MUST** return the errors in the body of the response in a JSON format, using the attributes
|
|
6
|
-
* described below.
|
|
8
|
+
* described below.
|
|
9
|
+
*
|
|
10
|
+
* Error responses are identified using the following "schema" URI:
|
|
7
11
|
* `"urn:ietf:params:scim:api:messages:2.0:Error"`.
|
|
8
12
|
*
|
|
13
|
+
* @param condition The condition to check.
|
|
14
|
+
* @param ctx The Koa context used to throw the error response.
|
|
15
|
+
* @param status The HTTP status code (see [Section 6 of [RFC7231]](https://datatracker.ietf.org/doc/html/rfc7231#section-6)) expressed as a JSON string.
|
|
16
|
+
* @param detail A detailed human-readable message.
|
|
9
17
|
* @see https://datatracker.ietf.org/doc/html/rfc7644#section-3.12
|
|
10
18
|
*/
|
|
11
|
-
export
|
|
12
|
-
constructor(status, detail) {
|
|
13
|
-
super(detail);
|
|
14
|
-
this.schemas = ['urn:ietf:params:scim:api:messages:2.0:Error'];
|
|
15
|
-
this.detail = detail;
|
|
16
|
-
this.name = 'SCIMError';
|
|
17
|
-
this.status = String(status);
|
|
18
|
-
}
|
|
19
|
-
toJSON() {
|
|
20
|
-
return {
|
|
21
|
-
detail: this.detail,
|
|
22
|
-
schemas: this.schemas,
|
|
23
|
-
status: this.status,
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export function scimAssert(condition, status, detail) {
|
|
19
|
+
export function scimAssert(condition, ctx, status, detail) {
|
|
28
20
|
if (!condition) {
|
|
29
|
-
|
|
21
|
+
ctx.status = status;
|
|
22
|
+
ctx.body = {
|
|
23
|
+
detail,
|
|
24
|
+
schemas: ['urn:ietf:params:scim:api:messages:2.0:Error'],
|
|
25
|
+
status,
|
|
26
|
+
};
|
|
27
|
+
ctx.throw();
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
//# sourceMappingURL=scim.js.map
|