nucleus-core-ts 0.9.888 → 0.9.889
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/.build-ok +1 -1
- package/dist/fe/components/IntegrationsPage/components/ConnectionAuthFields.js +4 -3
- package/dist/fe/components/IntegrationsPage/components/ConnectionOauthFields.js +5 -3
- package/dist/fe/components/IntegrationsPage/components/authOptions.d.ts +14 -4
- package/dist/fe/components/IntegrationsPage/components/authOptions.js +63 -58
- package/dist/fe/components/IntegrationsPage/text/index.d.ts +14 -0
- package/dist/fe/components/IntegrationsPage/text/index.js +10 -0
- package/package.json +1 -1
package/dist/.build-ok
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.9.
|
|
1
|
+
0.9.889
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useLabels } from '../text/context';
|
|
4
4
|
import { integrationsPageTheme } from '../theme';
|
|
5
|
-
import {
|
|
5
|
+
import { authTypeHint, authTypeOptions, toAuthType } from './authOptions';
|
|
6
6
|
import { ConnectionOauthFields } from './ConnectionOauthFields';
|
|
7
7
|
import { usesHeaderName, usesQueryParam } from './connectionDraft';
|
|
8
8
|
import { describedBy } from './formSupport';
|
|
@@ -18,13 +18,14 @@ import { Field } from './Primitives';
|
|
|
18
18
|
*/ const theme = integrationsPageTheme;
|
|
19
19
|
export function ConnectionAuthFields(props) {
|
|
20
20
|
const labels = useLabels();
|
|
21
|
+
const authTypes = authTypeOptions(labels.auth);
|
|
21
22
|
const { draft, disabled, onChange } = props;
|
|
22
23
|
return /*#__PURE__*/ _jsxs("section", {
|
|
23
24
|
"aria-label": labels.auth.sectionLabel,
|
|
24
25
|
className: "flex flex-col gap-3",
|
|
25
26
|
children: [
|
|
26
27
|
/*#__PURE__*/ _jsx(Field, {
|
|
27
|
-
hint: authTypeHint(draft.authType),
|
|
28
|
+
hint: authTypeHint(draft.authType, labels.auth),
|
|
28
29
|
htmlFor: "connection-auth-type",
|
|
29
30
|
label: labels.auth.type,
|
|
30
31
|
children: /*#__PURE__*/ _jsx("select", {
|
|
@@ -39,7 +40,7 @@ export function ConnectionAuthFields(props) {
|
|
|
39
40
|
});
|
|
40
41
|
},
|
|
41
42
|
value: draft.authType,
|
|
42
|
-
children:
|
|
43
|
+
children: authTypes.map((option)=>/*#__PURE__*/ _jsx("option", {
|
|
43
44
|
value: option.value,
|
|
44
45
|
children: option.label
|
|
45
46
|
}, option.value))
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useLabels } from '../text/context';
|
|
4
4
|
import { integrationsPageTheme } from '../theme';
|
|
5
|
-
import {
|
|
5
|
+
import { clientAuthOptions, grantTypeOptions, toClientAuth, toGrantType } from './authOptions';
|
|
6
6
|
import { usesOauth } from './connectionDraft';
|
|
7
7
|
import { describedBy } from './formSupport';
|
|
8
8
|
import { Field } from './Primitives';
|
|
@@ -15,6 +15,8 @@ import { Field } from './Primitives';
|
|
|
15
15
|
*/ const theme = integrationsPageTheme;
|
|
16
16
|
export function ConnectionOauthFields({ draft, errors, disabled, onChange }) {
|
|
17
17
|
const labels = useLabels();
|
|
18
|
+
const grantTypes = grantTypeOptions(labels.auth);
|
|
19
|
+
const clientAuths = clientAuthOptions(labels.auth);
|
|
18
20
|
if (!usesOauth(draft.authType)) return null;
|
|
19
21
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
20
22
|
children: [
|
|
@@ -52,7 +54,7 @@ export function ConnectionOauthFields({ draft, errors, disabled, onChange }) {
|
|
|
52
54
|
});
|
|
53
55
|
},
|
|
54
56
|
value: draft.oauthGrantType,
|
|
55
|
-
children:
|
|
57
|
+
children: grantTypes.map((option)=>/*#__PURE__*/ _jsx("option", {
|
|
56
58
|
value: option.value,
|
|
57
59
|
children: option.label
|
|
58
60
|
}, option.value))
|
|
@@ -122,7 +124,7 @@ export function ConnectionOauthFields({ draft, errors, disabled, onChange }) {
|
|
|
122
124
|
});
|
|
123
125
|
},
|
|
124
126
|
value: draft.oauthClientAuth,
|
|
125
|
-
children:
|
|
127
|
+
children: clientAuths.map((option)=>/*#__PURE__*/ _jsx("option", {
|
|
126
128
|
value: option.value,
|
|
127
129
|
children: option.label
|
|
128
130
|
}, option.value))
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IntegrationsLabels } from '../text';
|
|
1
2
|
import type { IntegrationAuthType } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* The three closed choices in the auth section, and the only way a `<select>`
|
|
@@ -12,18 +13,27 @@ export type AuthTypeOption = {
|
|
|
12
13
|
label: string;
|
|
13
14
|
hint: string;
|
|
14
15
|
};
|
|
15
|
-
|
|
16
|
+
type AuthText = IntegrationsLabels['auth'];
|
|
17
|
+
/** Every scheme there is, in the order the select offers them. */
|
|
18
|
+
export declare const AUTH_TYPE_VALUES: IntegrationAuthType[];
|
|
19
|
+
/**
|
|
20
|
+
* The scheme names are protocol words — `Bearer token`, `Basic`, `OAuth 2` are
|
|
21
|
+
* what the specifications call them and what the service's own documentation
|
|
22
|
+
* will say — so they are not label material. The sentence under each one is.
|
|
23
|
+
*/
|
|
24
|
+
export declare const authTypeOptions: (t: AuthText) => AuthTypeOption[];
|
|
16
25
|
export type GrantTypeValue = 'password' | 'client_credentials';
|
|
17
26
|
export type ClientAuthValue = 'basic' | 'body';
|
|
18
|
-
export declare const
|
|
27
|
+
export declare const grantTypeOptions: (t: AuthText) => {
|
|
19
28
|
value: GrantTypeValue;
|
|
20
29
|
label: string;
|
|
21
30
|
}[];
|
|
22
|
-
export declare const
|
|
31
|
+
export declare const clientAuthOptions: (t: AuthText) => {
|
|
23
32
|
value: ClientAuthValue;
|
|
24
33
|
label: string;
|
|
25
34
|
}[];
|
|
26
35
|
export declare function toAuthType(value: string): IntegrationAuthType | null;
|
|
27
36
|
export declare function toGrantType(value: string): GrantTypeValue | null;
|
|
28
37
|
export declare function toClientAuth(value: string): ClientAuthValue | null;
|
|
29
|
-
export declare function authTypeHint(authType: IntegrationAuthType): string;
|
|
38
|
+
export declare function authTypeHint(authType: IntegrationAuthType, t: AuthText): string;
|
|
39
|
+
export {};
|
|
@@ -1,70 +1,75 @@
|
|
|
1
|
-
export const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
value: 'bearer',
|
|
9
|
-
label: 'Bearer token',
|
|
10
|
-
hint: 'A token is sent on every request, by default as Authorization: Bearer …'
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
value: 'api_key',
|
|
14
|
-
label: 'API key',
|
|
15
|
-
hint: 'A key is sent in a header or as a query parameter. Say which below.'
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
value: 'basic',
|
|
19
|
-
label: 'Basic',
|
|
20
|
-
hint: 'A user name and password pair, sent as HTTP basic authentication.'
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
value: 'oauth2',
|
|
24
|
-
label: 'OAuth 2',
|
|
25
|
-
hint: 'A token is fetched from the token endpoint before each batch of calls and refreshed when it expires.'
|
|
26
|
-
}
|
|
27
|
-
];
|
|
28
|
-
export const GRANT_TYPE_OPTIONS = [
|
|
29
|
-
{
|
|
30
|
-
value: 'client_credentials',
|
|
31
|
-
label: 'Client credentials'
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
value: 'password',
|
|
35
|
-
label: 'Password'
|
|
36
|
-
}
|
|
37
|
-
];
|
|
38
|
-
export const CLIENT_AUTH_OPTIONS = [
|
|
39
|
-
{
|
|
40
|
-
value: 'basic',
|
|
41
|
-
label: 'Authorization header (basic)'
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
value: 'body',
|
|
45
|
-
label: 'Request body'
|
|
46
|
-
}
|
|
1
|
+
/** Every scheme there is, in the order the select offers them. */ export const AUTH_TYPE_VALUES = [
|
|
2
|
+
'none',
|
|
3
|
+
'bearer',
|
|
4
|
+
'api_key',
|
|
5
|
+
'basic',
|
|
6
|
+
'oauth2'
|
|
47
7
|
];
|
|
8
|
+
/**
|
|
9
|
+
* The scheme names are protocol words — `Bearer token`, `Basic`, `OAuth 2` are
|
|
10
|
+
* what the specifications call them and what the service's own documentation
|
|
11
|
+
* will say — so they are not label material. The sentence under each one is.
|
|
12
|
+
*/ export const authTypeOptions = (t)=>[
|
|
13
|
+
{
|
|
14
|
+
value: 'none',
|
|
15
|
+
label: t.typeNone,
|
|
16
|
+
hint: t.typeNoneHint
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
value: 'bearer',
|
|
20
|
+
label: 'Bearer token',
|
|
21
|
+
hint: t.typeBearerHint
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
value: 'api_key',
|
|
25
|
+
label: 'API key',
|
|
26
|
+
hint: t.typeApiKeyHint
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
value: 'basic',
|
|
30
|
+
label: 'Basic',
|
|
31
|
+
hint: t.typeBasicHint
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
value: 'oauth2',
|
|
35
|
+
label: 'OAuth 2',
|
|
36
|
+
hint: t.typeOauth2Hint
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
export const grantTypeOptions = (t)=>[
|
|
40
|
+
{
|
|
41
|
+
value: 'client_credentials',
|
|
42
|
+
label: t.grantClientCredentials
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
value: 'password',
|
|
46
|
+
label: t.grantPassword
|
|
47
|
+
}
|
|
48
|
+
];
|
|
49
|
+
export const clientAuthOptions = (t)=>[
|
|
50
|
+
{
|
|
51
|
+
value: 'basic',
|
|
52
|
+
label: t.clientAuthHeader
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
value: 'body',
|
|
56
|
+
label: t.clientAuthBody
|
|
57
|
+
}
|
|
58
|
+
];
|
|
48
59
|
export function toAuthType(value) {
|
|
49
|
-
for (const
|
|
50
|
-
if (
|
|
60
|
+
for (const known of AUTH_TYPE_VALUES){
|
|
61
|
+
if (known === value) return known;
|
|
51
62
|
}
|
|
52
63
|
return null;
|
|
53
64
|
}
|
|
54
65
|
export function toGrantType(value) {
|
|
55
|
-
|
|
56
|
-
if (option.value === value) return option.value;
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
66
|
+
return value === 'password' || value === 'client_credentials' ? value : null;
|
|
59
67
|
}
|
|
60
68
|
export function toClientAuth(value) {
|
|
61
|
-
|
|
62
|
-
if (option.value === value) return option.value;
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
69
|
+
return value === 'basic' || value === 'body' ? value : null;
|
|
65
70
|
}
|
|
66
|
-
export function authTypeHint(authType) {
|
|
67
|
-
for (const option of
|
|
71
|
+
export function authTypeHint(authType, t) {
|
|
72
|
+
for (const option of authTypeOptions(t)){
|
|
68
73
|
if (option.value === authType) return option.hint;
|
|
69
74
|
}
|
|
70
75
|
return '';
|
|
@@ -242,6 +242,20 @@ export type IntegrationsLabels = {
|
|
|
242
242
|
auth: {
|
|
243
243
|
sectionLabel: string;
|
|
244
244
|
type: string;
|
|
245
|
+
/**
|
|
246
|
+
* The closed choices. The scheme NAMES are protocol words and stay as they
|
|
247
|
+
* are; what each one does is a sentence, and that is read.
|
|
248
|
+
*/
|
|
249
|
+
typeNone: string;
|
|
250
|
+
typeNoneHint: string;
|
|
251
|
+
typeBearerHint: string;
|
|
252
|
+
typeApiKeyHint: string;
|
|
253
|
+
typeBasicHint: string;
|
|
254
|
+
typeOauth2Hint: string;
|
|
255
|
+
grantClientCredentials: string;
|
|
256
|
+
grantPassword: string;
|
|
257
|
+
clientAuthHeader: string;
|
|
258
|
+
clientAuthBody: string;
|
|
245
259
|
headerName: string;
|
|
246
260
|
headerNameHint: string;
|
|
247
261
|
headerNamePlaceholder: string;
|
|
@@ -231,6 +231,16 @@
|
|
|
231
231
|
auth: {
|
|
232
232
|
sectionLabel: 'Authentication',
|
|
233
233
|
type: 'How we prove who we are',
|
|
234
|
+
typeNone: 'None',
|
|
235
|
+
typeNoneHint: 'The service is called with no credential of any kind.',
|
|
236
|
+
typeBearerHint: 'A token is sent on every request, by default as Authorization: Bearer …',
|
|
237
|
+
typeApiKeyHint: 'A key is sent in a header or as a query parameter. Say which below.',
|
|
238
|
+
typeBasicHint: 'A user name and password pair, sent as HTTP basic authentication.',
|
|
239
|
+
typeOauth2Hint: 'A token is fetched from the token endpoint before each batch of calls and refreshed when it expires.',
|
|
240
|
+
grantClientCredentials: 'Client credentials',
|
|
241
|
+
grantPassword: 'Password',
|
|
242
|
+
clientAuthHeader: 'Authorization header (basic)',
|
|
243
|
+
clientAuthBody: 'Request body',
|
|
234
244
|
headerName: 'Header name',
|
|
235
245
|
headerNameHint: 'Empty means Authorization. Set it when the service reads the credential from a header of its own.',
|
|
236
246
|
headerNamePlaceholder: 'X-Api-Key',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.889",
|
|
4
4
|
"description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
|
|
5
5
|
"author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|