@appsemble/utils 0.39.2 → 0.40.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 CHANGED
@@ -1,9 +1,9 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.39.2/config/assets/logo.svg) Appsemble Utilities
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.40.1/config/assets/logo.svg) Appsemble Utilities
2
2
 
3
3
  > Internal utility functions used across multiple Appsemble projects.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@appsemble/utils)](https://www.npmjs.com/package/@appsemble/utils)
6
- [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.39.2/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.39.2)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.40.1/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.40.1)
7
7
  [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
8
8
 
9
9
  ## Table of Contents
@@ -26,5 +26,5 @@ not guaranteed.
26
26
 
27
27
  ## License
28
28
 
29
- [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.39.2/LICENSE.md) ©
29
+ [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.40.1/LICENSE.md) ©
30
30
  [Appsemble](https://appsemble.com)
@@ -29,7 +29,8 @@ export const AppOAuth2Secret = {
29
29
  },
30
30
  icon: {
31
31
  type: 'string',
32
- description: 'A Font Awesome icon which represents the OAuth2 provider.',
32
+ format: 'icon',
33
+ description: 'A Font Awesome icon or an `icon:<key>` reference to the app’s icon registry which represents the OAuth2 provider.',
33
34
  },
34
35
  name: {
35
36
  type: 'string',
@@ -25,7 +25,8 @@ export const AppSamlSecret = {
25
25
  },
26
26
  icon: {
27
27
  type: 'string',
28
- description: 'A Font Awesome icon which represents the SAML provider.',
28
+ format: 'icon',
29
+ description: 'A Font Awesome icon or an `icon:<key>` reference to the app’s icon registry which represents the SAML provider.',
29
30
  },
30
31
  name: {
31
32
  type: 'string',
@@ -53,6 +53,19 @@ export const AppServiceSecret = {
53
53
  type: 'string',
54
54
  description: 'The custom certificate authority.',
55
55
  },
56
+ lastTokenError: {
57
+ type: 'string',
58
+ nullable: true,
59
+ description: 'The provider’s message for the most recent failed client-credentials token request.',
60
+ readOnly: true,
61
+ },
62
+ lastTokenErrorAt: {
63
+ type: 'string',
64
+ format: 'date-time',
65
+ nullable: true,
66
+ description: 'When the most recent client-credentials token request failed.',
67
+ readOnly: true,
68
+ },
56
69
  },
57
70
  };
58
71
  //# sourceMappingURL=AppServiceSecret.js.map
@@ -14,7 +14,8 @@ export const SSOConfiguration = {
14
14
  },
15
15
  icon: {
16
16
  type: 'string',
17
- description: 'A Font Awesome icon.',
17
+ format: 'icon',
18
+ description: 'A Font Awesome icon or an `icon:<key>` reference to the app’s icon registry.',
18
19
  },
19
20
  },
20
21
  };
@@ -1,4 +1,5 @@
1
1
  export const pathItems = {
2
+ parameters: [{ $ref: '#/components/parameters/appId' }],
2
3
  post: {
3
4
  tags: ['app', 'auth', 'email'],
4
5
  description: 'Login using the Appsemble studio.',
@@ -48,7 +48,71 @@ export const pathItems = {
48
48
  },
49
49
  responses: {
50
50
  201: {
51
- description: 'The account that was created.',
51
+ description: 'The tokens for the session of the account that was created.',
52
+ content: {
53
+ 'application/json': {
54
+ schema: {
55
+ type: 'object',
56
+ required: ['access_token', 'expires_in', 'token_type'],
57
+ properties: {
58
+ access_token: {
59
+ type: 'string',
60
+ description: 'The access token.',
61
+ },
62
+ expires_in: {
63
+ type: 'number',
64
+ description: 'Token expiration time in seconds.',
65
+ },
66
+ refresh_token: {
67
+ type: 'string',
68
+ description: 'The refresh token.',
69
+ },
70
+ token_type: {
71
+ type: 'string',
72
+ description: 'The token type (bearer).',
73
+ },
74
+ },
75
+ },
76
+ },
77
+ },
78
+ },
79
+ 401: {
80
+ description: `The account was created, but no session was started.
81
+
82
+ On apps which require TOTP the second factor has to be verified before any token is issued. The
83
+ account exists either way, so this is the same challenge the other authentication endpoints
84
+ respond with.`,
85
+ content: {
86
+ 'application/json': {
87
+ schema: {
88
+ type: 'object',
89
+ required: ['data'],
90
+ properties: {
91
+ error: { type: 'string' },
92
+ message: { type: 'string' },
93
+ statusCode: { type: 'number' },
94
+ data: {
95
+ type: 'object',
96
+ required: ['totpRequired', 'totpEnabled', 'totpToken'],
97
+ properties: {
98
+ totpRequired: {
99
+ type: 'boolean',
100
+ description: 'Whether a second factor has to be verified before logging in.',
101
+ },
102
+ totpEnabled: {
103
+ type: 'boolean',
104
+ description: 'Whether the app member has already enrolled in TOTP.',
105
+ },
106
+ totpToken: {
107
+ type: 'string',
108
+ description: 'The pending TOTP token to verify the second factor with.',
109
+ },
110
+ },
111
+ },
112
+ },
113
+ },
114
+ },
115
+ },
52
116
  },
53
117
  },
54
118
  },
@@ -35,6 +35,9 @@ export const pathItems = {
35
35
  401: {
36
36
  description: 'User is not authenticated.',
37
37
  },
38
+ 429: {
39
+ description: 'Too many failed TOTP attempts.',
40
+ },
38
41
  },
39
42
  security: [{ app: [] }],
40
43
  },
@@ -2,7 +2,7 @@ export const pathItems = {
2
2
  parameters: [{ $ref: '#/components/parameters/appId' }],
3
3
  post: {
4
4
  tags: ['app', 'auth', 'totp'],
5
- description: 'Initialize TOTP setup for the current app member. Returns a secret and otpauth URL for QR code generation. When TOTP is required for the app, unauthenticated setup is allowed by providing a memberId.',
5
+ description: 'Initialize TOTP setup for the current app member. Returns a secret and otpauth URL for QR code generation. App members who still have to enroll to complete their login identify themselves with the pending TOTP token from the first login step instead of an access token.',
6
6
  operationId: 'setupAppMemberTotp',
7
7
  requestBody: {
8
8
  content: {
@@ -10,10 +10,9 @@ export const pathItems = {
10
10
  schema: {
11
11
  type: 'object',
12
12
  properties: {
13
- memberId: {
13
+ totpToken: {
14
14
  type: 'string',
15
- format: 'uuid',
16
- description: 'The app member ID. Only used for unauthenticated setup when TOTP is required.',
15
+ description: 'The pending TOTP token from the first login step. Only used when no access token is available yet.',
17
16
  },
18
17
  },
19
18
  },
@@ -47,9 +46,6 @@ export const pathItems = {
47
46
  401: {
48
47
  description: 'User is not authenticated.',
49
48
  },
50
- 403: {
51
- description: 'Unauthenticated TOTP setup is only allowed when TOTP is required.',
52
- },
53
49
  },
54
50
  security: [{ app: [] }, {}],
55
51
  },
@@ -2,22 +2,17 @@ export const pathItems = {
2
2
  parameters: [{ $ref: '#/components/parameters/appId' }],
3
3
  post: {
4
4
  tags: ['app', 'auth', 'totp'],
5
- description: 'Verify a TOTP token during login to complete the two-factor authentication process.',
5
+ description: 'Verify a TOTP token during login to complete the two-factor authentication process. The app member is identified by the pending TOTP token issued by the first login step, which is what binds both login steps together.',
6
6
  operationId: 'verifyAppMemberTotp',
7
7
  requestBody: {
8
- description: 'The member ID and TOTP token to verify.',
8
+ description: 'The pending TOTP token and the TOTP token to verify.',
9
9
  required: true,
10
10
  content: {
11
11
  'application/json': {
12
12
  schema: {
13
13
  type: 'object',
14
- required: ['memberId', 'token'],
14
+ required: ['token', 'totpToken'],
15
15
  properties: {
16
- memberId: {
17
- type: 'string',
18
- format: 'uuid',
19
- description: 'The ID of the app member attempting to login.',
20
- },
21
16
  token: {
22
17
  type: 'string',
23
18
  minLength: 6,
@@ -25,9 +20,9 @@ export const pathItems = {
25
20
  pattern: '^[0-9]{6}$',
26
21
  description: 'The 6-digit TOTP token from the authenticator app.',
27
22
  },
28
- scope: {
23
+ totpToken: {
29
24
  type: 'string',
30
- description: 'The OAuth2 scope to include in the token.',
25
+ description: 'The pending TOTP token from the first login step.',
31
26
  },
32
27
  },
33
28
  },
@@ -67,11 +62,14 @@ export const pathItems = {
67
62
  description: 'TOTP is not enabled for this member.',
68
63
  },
69
64
  401: {
70
- description: 'Invalid TOTP token.',
65
+ description: 'Invalid TOTP token, or a pending TOTP token which is invalid or spent.',
71
66
  },
72
67
  404: {
73
68
  description: 'App member not found.',
74
69
  },
70
+ 429: {
71
+ description: 'Too many failed TOTP attempts.',
72
+ },
75
73
  },
76
74
  },
77
75
  };
@@ -2,7 +2,7 @@ export const pathItems = {
2
2
  parameters: [{ $ref: '#/components/parameters/appId' }],
3
3
  post: {
4
4
  tags: ['app', 'auth', 'totp'],
5
- description: 'Verify a TOTP token to complete the TOTP setup process and enable two-factor authentication. When TOTP is required for the app, unauthenticated verification is allowed by providing a memberId.',
5
+ description: 'Verify a TOTP token to complete the TOTP setup process and enable two-factor authentication. App members who still have to enroll to complete their login identify themselves with the pending TOTP token from the first login step instead of an access token, in which case the login is completed and JWT tokens are returned.',
6
6
  operationId: 'verifyAppMemberTotpSetup',
7
7
  requestBody: {
8
8
  description: 'The TOTP token to verify.',
@@ -20,10 +20,9 @@ export const pathItems = {
20
20
  pattern: '^[0-9]{6}$',
21
21
  description: 'The 6-digit TOTP token from the authenticator app.',
22
22
  },
23
- memberId: {
23
+ totpToken: {
24
24
  type: 'string',
25
- format: 'uuid',
26
- description: 'The app member ID. Only used for unauthenticated verification when TOTP is required.',
25
+ description: 'The pending TOTP token from the first login step. Only used when no access token is available yet.',
27
26
  },
28
27
  },
29
28
  },
@@ -31,17 +30,42 @@ export const pathItems = {
31
30
  },
32
31
  },
33
32
  responses: {
34
- 204: {
35
- description: 'TOTP has been successfully enabled.',
33
+ 200: {
34
+ description: 'TOTP has been successfully enabled. When enrollment completed a pending login, JWT tokens are returned. Otherwise the response is empty with status 204.',
35
+ content: {
36
+ 'application/json': {
37
+ schema: {
38
+ type: 'object',
39
+ properties: {
40
+ access_token: {
41
+ type: 'string',
42
+ description: 'The access token.',
43
+ },
44
+ expires_in: {
45
+ type: 'number',
46
+ description: 'Token expiration time in seconds.',
47
+ },
48
+ refresh_token: {
49
+ type: 'string',
50
+ description: 'The refresh token.',
51
+ },
52
+ token_type: {
53
+ type: 'string',
54
+ description: 'The token type (bearer).',
55
+ },
56
+ },
57
+ },
58
+ },
59
+ },
36
60
  },
37
61
  400: {
38
62
  description: 'Invalid TOTP token or TOTP setup not initiated.',
39
63
  },
40
64
  401: {
41
- description: 'User is not authenticated.',
65
+ description: 'User is not authenticated, or the pending TOTP token is invalid or already spent.',
42
66
  },
43
- 403: {
44
- description: 'Unauthenticated TOTP verification is only allowed when TOTP is required.',
67
+ 429: {
68
+ description: 'Too many failed TOTP attempts.',
45
69
  },
46
70
  },
47
71
  security: [{ app: [] }, {}],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/utils",
3
- "version": "0.39.2",
3
+ "version": "0.40.1",
4
4
  "description": "Utility functions used in Appsemble internally",
5
5
  "keywords": [
6
6
  "app",
@@ -39,8 +39,8 @@
39
39
  "test": "vitest"
40
40
  },
41
41
  "dependencies": {
42
- "@appsemble/lang-sdk": "0.39.2",
43
- "@appsemble/types": "0.39.2",
42
+ "@appsemble/lang-sdk": "0.40.1",
43
+ "@appsemble/types": "0.40.1",
44
44
  "@fortawesome/fontawesome-common-types": "^6.0.0",
45
45
  "axios": "^1.0.0",
46
46
  "langmap": "^0.0.16",