@affinidi/cli 2.7.0 ā 2.8.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 +2 -2
- package/bin/dev.cmd +1 -1
- package/bin/dev.js +5 -0
- package/bin/run.js +5 -0
- package/dist/commands/generate/app.d.ts +7 -7
- package/dist/commands/generate/app.js +72 -75
- package/dist/commands/generate/app.js.map +1 -1
- package/dist/commands/iam/add-principal.d.ts +3 -3
- package/dist/commands/iam/add-principal.js +27 -31
- package/dist/commands/iam/add-principal.js.map +1 -1
- package/dist/commands/iam/get-policies.d.ts +4 -4
- package/dist/commands/iam/get-policies.js +27 -31
- package/dist/commands/iam/get-policies.js.map +1 -1
- package/dist/commands/iam/list-principals.d.ts +2 -2
- package/dist/commands/iam/list-principals.js +9 -14
- package/dist/commands/iam/list-principals.js.map +1 -1
- package/dist/commands/iam/remove-principal.d.ts +4 -3
- package/dist/commands/iam/remove-principal.js +27 -31
- package/dist/commands/iam/remove-principal.js.map +1 -1
- package/dist/commands/iam/update-policies.d.ts +5 -5
- package/dist/commands/iam/update-policies.js +44 -48
- package/dist/commands/iam/update-policies.js.map +1 -1
- package/dist/commands/login/add-user-to-group.d.ts +4 -4
- package/dist/commands/login/add-user-to-group.js +16 -21
- package/dist/commands/login/add-user-to-group.js.map +1 -1
- package/dist/commands/login/create-config.d.ts +11 -10
- package/dist/commands/login/create-config.js +46 -50
- package/dist/commands/login/create-config.js.map +1 -1
- package/dist/commands/login/create-group.d.ts +3 -3
- package/dist/commands/login/create-group.js +15 -20
- package/dist/commands/login/create-group.js.map +1 -1
- package/dist/commands/login/delete-config.d.ts +2 -2
- package/dist/commands/login/delete-config.js +14 -19
- package/dist/commands/login/delete-config.js.map +1 -1
- package/dist/commands/login/delete-group.d.ts +2 -2
- package/dist/commands/login/delete-group.js +14 -19
- package/dist/commands/login/delete-group.js.map +1 -1
- package/dist/commands/login/export-configs.d.ts +3 -3
- package/dist/commands/login/export-configs.js +21 -27
- package/dist/commands/login/export-configs.js.map +1 -1
- package/dist/commands/login/export-groups.d.ts +3 -3
- package/dist/commands/login/export-groups.js +21 -27
- package/dist/commands/login/export-groups.js.map +1 -1
- package/dist/commands/login/get-config.d.ts +3 -3
- package/dist/commands/login/get-config.js +14 -19
- package/dist/commands/login/get-config.js.map +1 -1
- package/dist/commands/login/get-group.d.ts +3 -3
- package/dist/commands/login/get-group.js +14 -19
- package/dist/commands/login/get-group.js.map +1 -1
- package/dist/commands/login/import-configs.d.ts +3 -3
- package/dist/commands/login/import-configs.js +33 -37
- package/dist/commands/login/import-configs.js.map +1 -1
- package/dist/commands/login/import-groups.d.ts +3 -3
- package/dist/commands/login/import-groups.js +21 -26
- package/dist/commands/login/import-groups.js.map +1 -1
- package/dist/commands/login/list-configs.d.ts +2 -2
- package/dist/commands/login/list-configs.js +7 -11
- package/dist/commands/login/list-configs.js.map +1 -1
- package/dist/commands/login/list-groups.d.ts +2 -2
- package/dist/commands/login/list-groups.js +7 -11
- package/dist/commands/login/list-groups.js.map +1 -1
- package/dist/commands/login/list-users-in-group.d.ts +5 -5
- package/dist/commands/login/list-users-in-group.js +24 -29
- package/dist/commands/login/list-users-in-group.js.map +1 -1
- package/dist/commands/login/remove-user-from-group.d.ts +3 -3
- package/dist/commands/login/remove-user-from-group.js +16 -21
- package/dist/commands/login/remove-user-from-group.js.map +1 -1
- package/dist/commands/login/update-config.d.ts +10 -10
- package/dist/commands/login/update-config.js +40 -45
- package/dist/commands/login/update-config.js.map +1 -1
- package/dist/commands/project/create-project.d.ts +4 -4
- package/dist/commands/project/create-project.js +16 -21
- package/dist/commands/project/create-project.js.map +1 -1
- package/dist/commands/project/get-active-project.d.ts +2 -2
- package/dist/commands/project/get-active-project.js +7 -11
- package/dist/commands/project/get-active-project.js.map +1 -1
- package/dist/commands/project/list-projects.d.ts +2 -2
- package/dist/commands/project/list-projects.js +7 -11
- package/dist/commands/project/list-projects.js.map +1 -1
- package/dist/commands/project/select-project.d.ts +3 -3
- package/dist/commands/project/select-project.js +20 -25
- package/dist/commands/project/select-project.js.map +1 -1
- package/dist/commands/project/update-project.d.ts +5 -5
- package/dist/commands/project/update-project.js +18 -23
- package/dist/commands/project/update-project.js.map +1 -1
- package/dist/commands/start.d.ts +1 -1
- package/dist/commands/start.js +13 -18
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/stop.d.ts +1 -1
- package/dist/commands/stop.js +13 -18
- package/dist/commands/stop.js.map +1 -1
- package/dist/commands/token/create-token.d.ts +10 -9
- package/dist/commands/token/create-token.js +58 -60
- package/dist/commands/token/create-token.js.map +1 -1
- package/dist/commands/token/delete-token.d.ts +2 -2
- package/dist/commands/token/delete-token.js +13 -17
- package/dist/commands/token/delete-token.js.map +1 -1
- package/dist/commands/token/get-token.d.ts +3 -3
- package/dist/commands/token/get-token.js +13 -17
- package/dist/commands/token/get-token.js.map +1 -1
- package/dist/commands/token/list-tokens.d.ts +2 -2
- package/dist/commands/token/list-tokens.js +7 -11
- package/dist/commands/token/list-tokens.js.map +1 -1
- package/dist/commands/token/update-token.d.ts +8 -7
- package/dist/commands/token/update-token.js +30 -33
- package/dist/commands/token/update-token.js.map +1 -1
- package/dist/commands/whoami.d.ts +1 -1
- package/dist/commands/whoami.js +7 -11
- package/dist/commands/whoami.js.map +1 -1
- package/dist/common/base-command.d.ts +1 -12
- package/dist/common/base-command.js +13 -17
- package/dist/common/base-command.js.map +1 -1
- package/dist/common/constants.js +12 -15
- package/dist/common/constants.js.map +1 -1
- package/dist/common/error-messages.js +1 -5
- package/dist/common/error-messages.js.map +1 -1
- package/dist/common/prompts.js +7 -11
- package/dist/common/prompts.js.map +1 -1
- package/dist/common/validators.js +15 -21
- package/dist/common/validators.js.map +1 -1
- package/dist/helpers/app.js +17 -30
- package/dist/helpers/app.js.map +1 -1
- package/dist/helpers/degit.js +6 -11
- package/dist/helpers/degit.js.map +1 -1
- package/dist/helpers/jwk.d.ts +1 -1
- package/dist/helpers/jwk.js +16 -24
- package/dist/helpers/jwk.js.map +1 -1
- package/dist/helpers/token.d.ts +4 -5
- package/dist/helpers/token.js +13 -20
- package/dist/helpers/token.js.map +1 -1
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/dist/services/affinidi/auth/auth-result-page.js +1 -5
- package/dist/services/affinidi/auth/auth-result-page.js.map +1 -1
- package/dist/services/affinidi/auth/bff-auth-provider.d.ts +1 -1
- package/dist/services/affinidi/auth/bff-auth-provider.js +25 -30
- package/dist/services/affinidi/auth/bff-auth-provider.js.map +1 -1
- package/dist/services/affinidi/auth/types.d.ts +1 -1
- package/dist/services/affinidi/auth/types.js +1 -2
- package/dist/services/affinidi/bff-service.d.ts +5 -5
- package/dist/services/affinidi/bff-service.js +56 -61
- package/dist/services/affinidi/bff-service.js.map +1 -1
- package/dist/services/affinidi/bff-service.types.js +1 -2
- package/dist/services/affinidi/errors.js +21 -26
- package/dist/services/affinidi/errors.js.map +1 -1
- package/dist/services/affinidi/iam/iam.api.d.ts +21 -21
- package/dist/services/affinidi/iam/iam.api.js +6 -12
- package/dist/services/affinidi/iam/iam.api.js.map +1 -1
- package/dist/services/affinidi/iam/{index.d.ts ā service.d.ts} +4 -4
- package/dist/services/affinidi/iam/{index.js ā service.js} +36 -40
- package/dist/services/affinidi/iam/service.js.map +1 -0
- package/dist/services/affinidi/logger/console-logger-adapter.d.ts +1 -1
- package/dist/services/affinidi/logger/console-logger-adapter.js +1 -5
- package/dist/services/affinidi/logger/console-logger-adapter.js.map +1 -1
- package/dist/services/affinidi/logger/logger-adapter.js +1 -2
- package/dist/services/affinidi/vp-adapter/{index.d.ts ā service.d.ts} +2 -2
- package/dist/services/affinidi/vp-adapter/{index.js ā service.js} +38 -41
- package/dist/services/affinidi/vp-adapter/service.js.map +1 -0
- package/dist/services/affinidi/vp-adapter/vp-adapter.api.d.ts +43 -43
- package/dist/services/affinidi/vp-adapter/vp-adapter.api.js +8 -14
- package/dist/services/affinidi/vp-adapter/vp-adapter.api.js.map +1 -1
- package/dist/services/credentials-vault.d.ts +0 -1
- package/dist/services/credentials-vault.js +15 -21
- package/dist/services/credentials-vault.js.map +1 -1
- package/dist/services/env-config.d.ts +1 -1
- package/dist/services/env-config.js +6 -10
- package/dist/services/env-config.js.map +1 -1
- package/dist/services/generator/auth0.d.ts +1 -1
- package/dist/services/generator/auth0.js +3 -8
- package/dist/services/generator/auth0.js.map +1 -1
- package/dist/services/generator/env-configurer.js +5 -9
- package/dist/services/generator/env-configurer.js.map +1 -1
- package/package.json +39 -42
- package/theme.json +26 -0
- package/bin/dev +0 -17
- package/bin/run +0 -5
- package/dist/common/index.d.ts +0 -2
- package/dist/common/index.js +0 -8
- package/dist/common/index.js.map +0 -1
- package/dist/services/affinidi/iam/index.js.map +0 -1
- package/dist/services/affinidi/logger/index.d.ts +0 -2
- package/dist/services/affinidi/logger/index.js +0 -6
- package/dist/services/affinidi/logger/index.js.map +0 -1
- package/dist/services/affinidi/vp-adapter/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-messages.js","sourceRoot":"","sources":["../../src/common/error-messages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error-messages.js","sourceRoot":"","sources":["../../src/common/error-messages.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,yBAAyB,CAAC,IAAY;IACpD,OAAO,iFAAiF,IAAI,2BAA2B,CAAA;AACzH,CAAC"}
|
package/dist/common/prompts.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const error_messages_1 = require("./error-messages");
|
|
7
|
-
const validators_1 = require("./validators");
|
|
8
|
-
async function promptRequiredParameters(requiredFlags, inputFlags) {
|
|
1
|
+
import { input } from '@inquirer/prompts';
|
|
2
|
+
import { CLIError } from '@oclif/core/errors';
|
|
3
|
+
import { giveFlagInputErrorMessage } from './error-messages.js';
|
|
4
|
+
import { INPUT_LIMIT, validateInputLength } from './validators.js';
|
|
5
|
+
export async function promptRequiredParameters(requiredFlags, inputFlags) {
|
|
9
6
|
for (const key in Object.keys(requiredFlags)) {
|
|
10
7
|
if (!inputFlags[requiredFlags[key]]) {
|
|
11
8
|
if (inputFlags['no-input']) {
|
|
12
|
-
throw new
|
|
9
|
+
throw new CLIError(giveFlagInputErrorMessage(requiredFlags[key]));
|
|
13
10
|
}
|
|
14
|
-
const validatedInput =
|
|
11
|
+
const validatedInput = validateInputLength(await input({ message: `Enter the value for ${requiredFlags[key]}` }), INPUT_LIMIT);
|
|
15
12
|
inputFlags[requiredFlags[key]] = validatedInput;
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
15
|
return inputFlags;
|
|
19
16
|
}
|
|
20
|
-
exports.promptRequiredParameters = promptRequiredParameters;
|
|
21
17
|
//# sourceMappingURL=prompts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/common/prompts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/common/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAElE,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,aAAuB,EACvB,UAA+B;IAE/B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;QAC7C,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACpC,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC3B,MAAM,IAAI,QAAQ,CAAC,yBAAyB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;YACnE,CAAC;YACD,MAAM,cAAc,GAAG,mBAAmB,CACxC,MAAM,KAAK,CAAC,EAAE,OAAO,EAAE,uBAAuB,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EACrE,WAAW,CACZ,CAAA;YACD,UAAU,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,cAAc,CAAA;QACjD,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAA;AACnB,CAAC"}
|
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
exports.INPUT_LIMIT = 2000;
|
|
8
|
-
exports.TOKEN_LIMIT = 5000;
|
|
9
|
-
exports.PRESENTATION_DEFINITION_LIMIT = 5000;
|
|
10
|
-
function validateInputLength(text, maxLength) {
|
|
1
|
+
import { CLIError } from '@oclif/core/errors';
|
|
2
|
+
import z from 'zod';
|
|
3
|
+
export const INPUT_LIMIT = 2000;
|
|
4
|
+
export const TOKEN_LIMIT = 5000;
|
|
5
|
+
export const PRESENTATION_DEFINITION_LIMIT = 5000;
|
|
6
|
+
export function validateInputLength(text, maxLength) {
|
|
11
7
|
if (text.length > maxLength) {
|
|
12
|
-
throw new
|
|
8
|
+
throw new CLIError(`String must contain at most ${maxLength} character(s)`);
|
|
13
9
|
}
|
|
14
10
|
return text;
|
|
15
11
|
}
|
|
16
|
-
|
|
17
|
-
function split(text, delimiter) {
|
|
12
|
+
export function split(text, delimiter) {
|
|
18
13
|
return text.split(delimiter).filter((item) => item.length > 0);
|
|
19
14
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
statement: zod_1.default
|
|
15
|
+
export const policiesDataSchema = z.object({
|
|
16
|
+
version: z.string().max(INPUT_LIMIT),
|
|
17
|
+
statement: z
|
|
24
18
|
.object({
|
|
25
|
-
principal:
|
|
26
|
-
action:
|
|
27
|
-
resource:
|
|
28
|
-
effect:
|
|
19
|
+
principal: z.string().max(INPUT_LIMIT).array().length(1),
|
|
20
|
+
action: z.string().max(INPUT_LIMIT).array().nonempty(),
|
|
21
|
+
resource: z.string().max(INPUT_LIMIT).array().nonempty(),
|
|
22
|
+
effect: z.literal('Allow'),
|
|
29
23
|
})
|
|
30
24
|
.array()
|
|
31
25
|
.nonempty(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/common/validators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/common/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,CAAC,MAAM,KAAK,CAAA;AAEnB,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAA;AAC/B,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAA;AAC/B,MAAM,CAAC,MAAM,6BAA6B,GAAG,IAAI,CAAA;AAEjD,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,SAAiB;IACjE,IAAI,IAAI,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,QAAQ,CAAC,+BAA+B,SAAS,eAAe,CAAC,CAAA;IAC7E,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,IAAY,EAAE,SAAiB;IACnD,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;AAChE,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC;IACpC,SAAS,EAAE,CAAC;SACT,MAAM,CAAC;QACN,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QACxD,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;QACtD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,KAAK,EAAE,CAAC,QAAQ,EAAE;QACxD,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;KAC3B,CAAC;SACD,KAAK,EAAE;SACP,QAAQ,EAAE;CACd,CAAC,CAAA"}
|
package/dist/helpers/app.js
CHANGED
|
@@ -1,36 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const errors_1 = require("@oclif/core/lib/errors");
|
|
6
|
-
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
7
|
-
function getAppName(framework, provider, library) {
|
|
1
|
+
import { CLIError } from '@oclif/core/errors';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
export function getAppName(framework, provider, library) {
|
|
8
4
|
return `${provider}-${framework}-${library}`;
|
|
9
5
|
}
|
|
10
|
-
|
|
11
|
-
async function getApps(filePath) {
|
|
6
|
+
export async function getApps(filePath) {
|
|
12
7
|
const githubFileUrl = `https://api.github.com/repos/affinidi/reference-app-affinidi-vault/contents/${filePath}`;
|
|
13
8
|
// const githubFileUrl =
|
|
14
9
|
// 'https://api.github.com/repos/affinidi/reference-app-affinidi-vault/contents/samples/apps.json?ref=token-metadata'
|
|
15
10
|
try {
|
|
16
|
-
const response = await
|
|
11
|
+
const response = await axios.get(githubFileUrl);
|
|
17
12
|
if (response.data && response.data.content) {
|
|
18
13
|
const content = Buffer.from(response.data.content, 'base64').toString('utf-8');
|
|
19
14
|
const apps = JSON.parse(content);
|
|
20
15
|
return apps;
|
|
21
16
|
}
|
|
22
|
-
throw new
|
|
17
|
+
throw new CLIError('Unable to fetch supported apps');
|
|
23
18
|
}
|
|
24
19
|
catch (err) {
|
|
25
|
-
throw new
|
|
20
|
+
throw new CLIError('Unable to fetch supported apps');
|
|
26
21
|
}
|
|
27
22
|
}
|
|
28
|
-
|
|
29
|
-
function getSupportedSampleApps(appsInformation) {
|
|
23
|
+
export function getSupportedSampleApps(appsInformation) {
|
|
30
24
|
return Object.keys(appsInformation);
|
|
31
25
|
}
|
|
32
|
-
|
|
33
|
-
function getSupportedProviders(sampleApps) {
|
|
26
|
+
export function getSupportedProviders(sampleApps) {
|
|
34
27
|
try {
|
|
35
28
|
const providers = [];
|
|
36
29
|
for (const sampleApp of sampleApps) {
|
|
@@ -42,11 +35,10 @@ function getSupportedProviders(sampleApps) {
|
|
|
42
35
|
return providers;
|
|
43
36
|
}
|
|
44
37
|
catch (err) {
|
|
45
|
-
throw new
|
|
38
|
+
throw new CLIError('Unable to fetch supported providers');
|
|
46
39
|
}
|
|
47
40
|
}
|
|
48
|
-
|
|
49
|
-
function getSupportedFrameworks(sampleApps) {
|
|
41
|
+
export function getSupportedFrameworks(sampleApps) {
|
|
50
42
|
try {
|
|
51
43
|
const frameworks = new Map();
|
|
52
44
|
for (const sampleApp of sampleApps) {
|
|
@@ -64,11 +56,10 @@ function getSupportedFrameworks(sampleApps) {
|
|
|
64
56
|
return frameworks;
|
|
65
57
|
}
|
|
66
58
|
catch (err) {
|
|
67
|
-
throw new
|
|
59
|
+
throw new CLIError('Unable to fetch supported frameworks');
|
|
68
60
|
}
|
|
69
61
|
}
|
|
70
|
-
|
|
71
|
-
function getSupportedLibraries(sampleApps) {
|
|
62
|
+
export function getSupportedLibraries(sampleApps) {
|
|
72
63
|
try {
|
|
73
64
|
const libraries = new Map();
|
|
74
65
|
for (const sampleApp of sampleApps) {
|
|
@@ -87,24 +78,20 @@ function getSupportedLibraries(sampleApps) {
|
|
|
87
78
|
return libraries;
|
|
88
79
|
}
|
|
89
80
|
catch (err) {
|
|
90
|
-
throw new
|
|
81
|
+
throw new CLIError('Unable to fetch supported libraries');
|
|
91
82
|
}
|
|
92
83
|
}
|
|
93
|
-
|
|
94
|
-
function getSupportedAppsInformation(apps) {
|
|
84
|
+
export function getSupportedAppsInformation(apps) {
|
|
95
85
|
const sampleApps = getSupportedSampleApps(apps);
|
|
96
86
|
const providers = getSupportedProviders(sampleApps);
|
|
97
87
|
const frameworks = getSupportedFrameworks(sampleApps);
|
|
98
88
|
const libraries = getSupportedLibraries(sampleApps);
|
|
99
89
|
return { providers, frameworks, libraries };
|
|
100
90
|
}
|
|
101
|
-
|
|
102
|
-
function getRedirectUri(apps, appName) {
|
|
91
|
+
export function getRedirectUri(apps, appName) {
|
|
103
92
|
return apps[appName].redirectUris.callbackUrl;
|
|
104
93
|
}
|
|
105
|
-
|
|
106
|
-
function getAppMetadataToken(apps, appName) {
|
|
94
|
+
export function getAppMetadataToken(apps, appName) {
|
|
107
95
|
return apps[appName].metadata.token;
|
|
108
96
|
}
|
|
109
|
-
exports.getAppMetadataToken = getAppMetadataToken;
|
|
110
97
|
//# sourceMappingURL=app.js.map
|
package/dist/helpers/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/helpers/app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/helpers/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AAyCzB,MAAM,UAAU,UAAU,CAAC,SAAiB,EAAE,QAAgB,EAAE,OAAe;IAC7E,OAAO,GAAG,QAAQ,IAAI,SAAS,IAAI,OAAO,EAAE,CAAA;AAC9C,CAAC;AAED,MA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AC,IAAqB,EAAE,OAAe;IACxE,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAA;AACrC,CAAC"}
|
package/dist/helpers/degit.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
const degit_1 = tslib_1.__importDefault(require("degit"));
|
|
8
|
-
async function cloneWithDegit(source, destination, force) {
|
|
9
|
-
const emitter = (0, degit_1.default)(source, {
|
|
1
|
+
import { CLIError } from '@oclif/core/errors';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import degit from 'degit';
|
|
4
|
+
export async function cloneWithDegit(source, destination, force) {
|
|
5
|
+
const emitter = degit(source, {
|
|
10
6
|
cache: false,
|
|
11
7
|
force,
|
|
12
8
|
verbose: false,
|
|
@@ -19,8 +15,7 @@ async function cloneWithDegit(source, destination, force) {
|
|
|
19
15
|
message = message.replace('destination directory is not empty, aborting. Use options.force to override', 'Destination directory is not empty. Use flag --force to override');
|
|
20
16
|
message = message.replace('could not find commit hash for HEAD', `Reference application source code not found. Make sure you have git installed and added to your PATH.',
|
|
21
17
|
)}`);
|
|
22
|
-
throw new
|
|
18
|
+
throw new CLIError(`Unable to generate reference application\n${chalk.red(message)}`);
|
|
23
19
|
}
|
|
24
20
|
}
|
|
25
|
-
exports.cloneWithDegit = cloneWithDegit;
|
|
26
21
|
//# sourceMappingURL=degit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"degit.js","sourceRoot":"","sources":["../../src/helpers/degit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"degit.js","sourceRoot":"","sources":["../../src/helpers/degit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAc,EAAE,WAAmB,EAAE,KAAc;IACtF,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE;QAC5B,KAAK,EAAE,KAAK;QACZ,KAAK;QACL,OAAO,EAAE,KAAK;KACf,CAAC,CAAA;IAEF,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,OAAO,GAAI,KAAe,CAAC,OAAO,CAAA;QACtC,OAAO,GAAG,OAAO,CAAC,OAAO,CACvB,6EAA6E,EAC7E,kEAAkE,CACnE,CAAA;QACD,OAAO,GAAG,OAAO,CAAC,OAAO,CACvB,qCAAqC,EACrC;SACG,CACJ,CAAA;QACD,MAAM,IAAI,QAAQ,CAAC,6CAA6C,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;IACvF,CAAC;AACH,CAAC"}
|
package/dist/helpers/jwk.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as jose from 'jose';
|
|
2
|
-
import { SupportedAlgorithms, SupportedKeyTypes } from '../common';
|
|
2
|
+
import { SupportedAlgorithms, SupportedKeyTypes } from '../common/constants.js';
|
|
3
3
|
export declare function pemToJWK(publicKeyPEM: string, algorithm: SupportedAlgorithms): Promise<jose.JWK>;
|
|
4
4
|
export declare function getKeyType(algorithm: SupportedAlgorithms): SupportedKeyTypes;
|
|
5
5
|
export declare function JWKToPem(publicKey: jose.KeyLike): Promise<string>;
|
package/dist/helpers/jwk.js
CHANGED
|
@@ -1,49 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const errors_1 = require("@oclif/core/lib/errors");
|
|
6
|
-
const jose = tslib_1.__importStar(require("jose"));
|
|
7
|
-
const common_1 = require("../common");
|
|
8
|
-
async function pemToJWK(publicKeyPEM, algorithm) {
|
|
1
|
+
import { CLIError } from '@oclif/core/errors';
|
|
2
|
+
import * as jose from 'jose';
|
|
3
|
+
import { SupportedAlgorithms, SupportedKeyTypes } from '../common/constants.js';
|
|
4
|
+
export async function pemToJWK(publicKeyPEM, algorithm) {
|
|
9
5
|
try {
|
|
10
6
|
const publicKey = await jose.importSPKI(publicKeyPEM, algorithm);
|
|
11
7
|
return await jose.exportJWK(publicKey);
|
|
12
8
|
}
|
|
13
9
|
catch (error) {
|
|
14
|
-
throw new
|
|
10
|
+
throw new CLIError('Unable to decode the provided public key');
|
|
15
11
|
}
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
function getKeyType(algorithm) {
|
|
13
|
+
export function getKeyType(algorithm) {
|
|
19
14
|
switch (algorithm) {
|
|
20
|
-
case
|
|
21
|
-
case
|
|
22
|
-
return
|
|
23
|
-
case
|
|
24
|
-
case
|
|
25
|
-
return
|
|
15
|
+
case SupportedAlgorithms.ES256:
|
|
16
|
+
case SupportedAlgorithms.ES512:
|
|
17
|
+
return SupportedKeyTypes.EC;
|
|
18
|
+
case SupportedAlgorithms.RS256:
|
|
19
|
+
case SupportedAlgorithms.RS512:
|
|
20
|
+
return SupportedKeyTypes.RSA;
|
|
26
21
|
}
|
|
27
22
|
}
|
|
28
|
-
|
|
29
|
-
async function JWKToPem(publicKey) {
|
|
23
|
+
export async function JWKToPem(publicKey) {
|
|
30
24
|
try {
|
|
31
25
|
return await jose.exportSPKI(publicKey);
|
|
32
26
|
}
|
|
33
27
|
catch (_) {
|
|
34
|
-
throw new
|
|
28
|
+
throw new CLIError('Unable to convert the provided public key to pem format');
|
|
35
29
|
}
|
|
36
30
|
}
|
|
37
|
-
|
|
38
|
-
async function decryptSessionIdWithPrivateKey(message, privateKey) {
|
|
31
|
+
export async function decryptSessionIdWithPrivateKey(message, privateKey) {
|
|
39
32
|
try {
|
|
40
33
|
const { plaintext } = await jose.compactDecrypt(message, privateKey);
|
|
41
34
|
const decoder = new TextDecoder();
|
|
42
35
|
return decoder.decode(plaintext);
|
|
43
36
|
}
|
|
44
37
|
catch (_) {
|
|
45
|
-
throw new
|
|
38
|
+
throw new CLIError('Unable to decrypt the message with the private-key');
|
|
46
39
|
}
|
|
47
40
|
}
|
|
48
|
-
exports.decryptSessionIdWithPrivateKey = decryptSessionIdWithPrivateKey;
|
|
49
41
|
//# sourceMappingURL=jwk.js.map
|
package/dist/helpers/jwk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwk.js","sourceRoot":"","sources":["../../src/helpers/jwk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jwk.js","sourceRoot":"","sources":["../../src/helpers/jwk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE/E,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,YAAoB,EAAE,SAA8B;IACjF,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;QAChE,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,QAAQ,CAAC,0CAA0C,CAAC,CAAA;IAChE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,SAA8B;IACvD,QAAQ,SAAS,EAAE,CAAC;QAClB,KAAK,mBAAmB,CAAC,KAAK,CAAC;QAC/B,KAAK,mBAAmB,CAAC,KAAK;YAC5B,OAAO,iBAAiB,CAAC,EAAE,CAAA;QAC7B,KAAK,mBAAmB,CAAC,KAAK,CAAC;QAC/B,KAAK,mBAAmB,CAAC,KAAK;YAC5B,OAAO,iBAAiB,CAAC,GAAG,CAAA;IAChC,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,SAAuB;IACpD,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;IACzC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,QAAQ,CAAC,yDAAyD,CAAC,CAAA;IAC/E,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAC,OAAe,EAAE,UAAwB;IAC5F,IAAI,CAAC;QACH,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;QACpE,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;QACjC,OAAO,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IAClC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,MAAM,IAAI,QAAQ,CAAC,oDAAoD,CAAC,CAAA;IAC1E,CAAC;AACH,CAAC"}
|
package/dist/helpers/token.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { JsonWebKeySetDto } from '../services/affinidi/iam/iam.api';
|
|
1
|
+
import { SupportedAlgorithms } from '../common/constants.js';
|
|
2
|
+
import { JsonWebKeySetDto } from '../services/affinidi/iam/iam.api.js';
|
|
4
3
|
export declare function generateKeyPair(keyId: string, algorithm: string, passphrase?: string): {
|
|
5
4
|
publicKey: string | Buffer;
|
|
6
5
|
privateKey: string | Buffer;
|
|
@@ -25,6 +24,6 @@ export declare function generateKeyPair(keyId: string, algorithm: string, passph
|
|
|
25
24
|
}[];
|
|
26
25
|
};
|
|
27
26
|
};
|
|
28
|
-
export declare function createToken(name: string, algorithm: SupportedAlgorithms, jwks: JsonWebKeySetDto, keyId?: string): Promise<import("../services/affinidi/iam/iam.api").TokenDto>;
|
|
27
|
+
export declare function createToken(name: string, algorithm: SupportedAlgorithms, jwks: JsonWebKeySetDto, keyId?: string): Promise<import("../services/affinidi/iam/iam.api.js").TokenDto>;
|
|
29
28
|
export declare function addPrincipal(tokenId: string): Promise<void>;
|
|
30
|
-
export declare function updatePolicies(tokenId: string, activeProjectId: string, actions: string[], resources: string[]): Promise<import("../services/affinidi/iam/iam.api").PolicyDto>;
|
|
29
|
+
export declare function updatePolicies(tokenId: string, activeProjectId: string, actions: string[], resources: string[]): Promise<import("../services/affinidi/iam/iam.api.js").PolicyDto>;
|
package/dist/helpers/token.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const index_1 = require("../services/affinidi/iam/index");
|
|
7
|
-
function generateKeyPair(keyId, algorithm, passphrase) {
|
|
8
|
-
const { publicKey, privateKey } = (0, node_crypto_1.generateKeyPairSync)('rsa', { modulusLength: 4096 });
|
|
1
|
+
import { generateKeyPairSync } from 'node:crypto';
|
|
2
|
+
import { policiesDataSchema } from '../common/validators.js';
|
|
3
|
+
import { iamService } from '../services/affinidi/iam/service.js';
|
|
4
|
+
export function generateKeyPair(keyId, algorithm, passphrase) {
|
|
5
|
+
const { publicKey, privateKey } = generateKeyPairSync('rsa', { modulusLength: 4096 });
|
|
9
6
|
const publicKeyPem = publicKey.export({ format: 'pem', type: 'spki' });
|
|
10
7
|
const exportOptions = {
|
|
11
8
|
format: 'pem',
|
|
@@ -29,9 +26,8 @@ function generateKeyPair(keyId, algorithm, passphrase) {
|
|
|
29
26
|
};
|
|
30
27
|
return { publicKey: publicKeyPem, privateKey: privateKeyPem, jwks };
|
|
31
28
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
let token = await index_1.iamService.createToken({
|
|
29
|
+
export async function createToken(name, algorithm, jwks, keyId) {
|
|
30
|
+
let token = await iamService.createToken({
|
|
35
31
|
name,
|
|
36
32
|
authenticationMethod: {
|
|
37
33
|
type: 'PRIVATE_KEY',
|
|
@@ -44,7 +40,7 @@ async function createToken(name, algorithm, jwks, keyId) {
|
|
|
44
40
|
// If keyId was not provided it means that a randomly generated uuid was assigned and we should change it to the tokenId
|
|
45
41
|
if (!keyId) {
|
|
46
42
|
jwks.keys[0].kid = token.id;
|
|
47
|
-
token = await
|
|
43
|
+
token = await iamService.updateToken(token.id, {
|
|
48
44
|
name,
|
|
49
45
|
authenticationMethod: {
|
|
50
46
|
type: 'PRIVATE_KEY',
|
|
@@ -57,15 +53,13 @@ async function createToken(name, algorithm, jwks, keyId) {
|
|
|
57
53
|
}
|
|
58
54
|
return token;
|
|
59
55
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
await index_1.iamService.addPrincipalToProject({
|
|
56
|
+
export async function addPrincipal(tokenId) {
|
|
57
|
+
await iamService.addPrincipalToProject({
|
|
63
58
|
principalId: tokenId,
|
|
64
59
|
principalType: 'token',
|
|
65
60
|
});
|
|
66
61
|
}
|
|
67
|
-
|
|
68
|
-
async function updatePolicies(tokenId, activeProjectId, actions, resources) {
|
|
62
|
+
export async function updatePolicies(tokenId, activeProjectId, actions, resources) {
|
|
69
63
|
const policiesData = {
|
|
70
64
|
version: '2022-12-15',
|
|
71
65
|
statement: [
|
|
@@ -77,9 +71,8 @@ async function updatePolicies(tokenId, activeProjectId, actions, resources) {
|
|
|
77
71
|
},
|
|
78
72
|
],
|
|
79
73
|
};
|
|
80
|
-
const validatedPolicies =
|
|
81
|
-
const result = await
|
|
74
|
+
const validatedPolicies = policiesDataSchema.parse(policiesData);
|
|
75
|
+
const result = await iamService.updatePolicies(tokenId, 'token', validatedPolicies);
|
|
82
76
|
return result;
|
|
83
77
|
}
|
|
84
|
-
exports.updatePolicies = updatePolicies;
|
|
85
78
|
//# sourceMappingURL=token.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/helpers/token.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/helpers/token.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAA;AAEhE,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,SAAiB,EAAE,UAAmB;IACnF,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,mBAAmB,CAAC,KAAK,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IAErF,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;IACtE,MAAM,aAAa,GAA4B;QAC7C,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,OAAO;KACd,CAAA;IACD,IAAI,UAAU,EAAE,CAAC;QACf,aAAa,CAAC,MAAM,GAAG,aAAa,CAAA;QACpC,aAAa,CAAC,UAAU,GAAG,UAAU,CAAA;IACvC,CAAC;IACD,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;IACtD,MAAM,YAAY,GAAG,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;IAExD,MAAM,IAAI,GAAG;QACX,IAAI,EAAE;YACJ;gBACE,GAAG,EAAE,KAAK;gBACV,GAAG,EAAE,KAAK;gBACV,GAAG,EAAE,SAAS;gBACd,GAAG,YAAY;aAChB;SACF;KACF,CAAA;IAED,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,IAAI,EAAE,CAAA;AACrE,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,IAAY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CAAC,OAAO,EAAE,OAAO,EAAE,iBAAiB,CAAC,CAAA;IACnF,OAAO,MAAM,CAAA;AACf,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.run = void 0;
|
|
4
|
-
var core_1 = require("@oclif/core");
|
|
5
|
-
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
|
|
1
|
+
export { run } from '@oclif/core';
|
|
6
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.authResultPage = void 0;
|
|
4
|
-
const authResultPage = (title, content) => `<!DOCTYPE html>
|
|
1
|
+
export const authResultPage = (title, content) => `<!DOCTYPE html>
|
|
5
2
|
<html>
|
|
6
3
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
4
|
<head>
|
|
@@ -106,5 +103,4 @@ const authResultPage = (title, content) => `<!DOCTYPE html>
|
|
|
106
103
|
</body>
|
|
107
104
|
</html>
|
|
108
105
|
`;
|
|
109
|
-
exports.authResultPage = authResultPage;
|
|
110
106
|
//# sourceMappingURL=auth-result-page.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-result-page.js","sourceRoot":"","sources":["../../../../src/services/affinidi/auth/auth-result-page.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth-result-page.js","sourceRoot":"","sources":["../../../../src/services/affinidi/auth/auth-result-page.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,OAAe,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAgGtD,KAAK;;UAEP,OAAO;;;;;;CAMhB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { KeyLike } from 'jose';
|
|
2
|
-
import { AuthProvider, AuthProviderConfig } from './types';
|
|
2
|
+
import { AuthProvider, AuthProviderConfig } from './types.js';
|
|
3
3
|
export declare class BFFAuthProvider implements AuthProvider {
|
|
4
4
|
private readonly logger;
|
|
5
5
|
constructor({ logger }: AuthProviderConfig);
|
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const credentials_vault_1 = require("../../credentials-vault");
|
|
13
|
-
const env_config_1 = require("../../env-config");
|
|
14
|
-
const bff_service_1 = require("../bff-service");
|
|
15
|
-
class BFFAuthProvider {
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import helmet from 'helmet';
|
|
4
|
+
import open from 'open';
|
|
5
|
+
import { check } from 'tcp-port-used';
|
|
6
|
+
import { authResultPage } from './auth-result-page.js';
|
|
7
|
+
import { JWKToPem, decryptSessionIdWithPrivateKey } from '../../../helpers/jwk.js';
|
|
8
|
+
import { credentialsVault } from '../../credentials-vault.js';
|
|
9
|
+
import { config } from '../../env-config.js';
|
|
10
|
+
import { bffService } from '../bff-service.js';
|
|
11
|
+
export class BFFAuthProvider {
|
|
16
12
|
constructor({ logger }) {
|
|
17
13
|
this.logger = logger;
|
|
18
14
|
}
|
|
19
15
|
async authenticate({ privateKey, publicKey }) {
|
|
20
16
|
const port = 64287;
|
|
21
|
-
const isPortInUse = await
|
|
17
|
+
const isPortInUse = await check(config.redirectPort);
|
|
22
18
|
if (isPortInUse) {
|
|
23
19
|
throw new Error(`\nš„ Port [${port}] is unavailable. Affinidi CLI is currently relying on it.\n` +
|
|
24
20
|
`Please close the process that is using port [${port}] and try again.`);
|
|
25
21
|
}
|
|
26
|
-
const authUrl = await
|
|
22
|
+
const authUrl = await bffService.postAuthUrl(await JWKToPem(publicKey));
|
|
27
23
|
const state = authUrl.searchParams.get('state');
|
|
28
24
|
if (!state) {
|
|
29
25
|
throw new Error('Unexpected error occurred. state parameter missing');
|
|
30
26
|
}
|
|
31
27
|
return new Promise((resolve, reject) => {
|
|
32
28
|
this.logger.debug('Start express server');
|
|
33
|
-
const app = (
|
|
34
|
-
app.use((
|
|
29
|
+
const app = express();
|
|
30
|
+
app.use(helmet({
|
|
35
31
|
contentSecurityPolicy: {
|
|
36
32
|
directives: {
|
|
37
33
|
scriptSrc: ["'none'"],
|
|
@@ -43,8 +39,8 @@ class BFFAuthProvider {
|
|
|
43
39
|
});
|
|
44
40
|
const timeout = setTimeout(() => {
|
|
45
41
|
this.shutDownServer(server);
|
|
46
|
-
reject(new Error(`Authentication timeout (${
|
|
47
|
-
},
|
|
42
|
+
reject(new Error(`Authentication timeout (${config.redirectTimeoutMs / 1000}s) exceeded`));
|
|
43
|
+
}, config.redirectTimeoutMs);
|
|
48
44
|
app.get('/callback', async (req, res) => {
|
|
49
45
|
res.type('html');
|
|
50
46
|
if (req.query.state === 'error') {
|
|
@@ -58,9 +54,9 @@ class BFFAuthProvider {
|
|
|
58
54
|
});
|
|
59
55
|
this.logger.info(`\nAttempting to automatically open the authentication page in your default browser.\n` +
|
|
60
56
|
`\nIf the browser doesn't open automatically, or if your default browser isn't Google Chrome, please open the following URL in the Chrome browser:\n` +
|
|
61
|
-
`\n${
|
|
57
|
+
`\n${chalk.underline(authUrl)}\n\n`);
|
|
62
58
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
63
|
-
(
|
|
59
|
+
open(authUrl.href);
|
|
64
60
|
});
|
|
65
61
|
}
|
|
66
62
|
/**
|
|
@@ -76,20 +72,20 @@ class BFFAuthProvider {
|
|
|
76
72
|
clearTimeout(timeout);
|
|
77
73
|
try {
|
|
78
74
|
this.logger.debug(`Getting sessionId for state: ${JSON.stringify(state)}`);
|
|
79
|
-
const encryptedSessionIdBase64 = await
|
|
75
|
+
const encryptedSessionIdBase64 = await bffService.getSessionId(state);
|
|
80
76
|
const encryptedSessionId = Buffer.from(encryptedSessionIdBase64, 'base64').toString('utf-8');
|
|
81
|
-
const sessionId = await
|
|
77
|
+
const sessionId = await decryptSessionIdWithPrivateKey(encryptedSessionId, privateKey);
|
|
82
78
|
this.logger.debug(`Received session: ${JSON.stringify(sessionId)}`);
|
|
83
|
-
await
|
|
79
|
+
await credentialsVault.setSessionId(sessionId);
|
|
84
80
|
this.logger.debug('Session stored in vault');
|
|
85
81
|
resolve(sessionId);
|
|
86
|
-
res.end(
|
|
82
|
+
res.end(authResultPage('Logged in successfully', 'Head back to the terminal to continue using Affinidi CLI.<br><br>You can also access our services from the <a href="https://portal.affinidi.com" target="_blank">Affindi Portal</a>'));
|
|
87
83
|
}
|
|
88
84
|
catch (error) {
|
|
89
85
|
this.logger.info(error);
|
|
90
86
|
const errorMessage = this.generateErrorMessage();
|
|
91
87
|
reject(errorMessage);
|
|
92
|
-
res.end(
|
|
88
|
+
res.end(authResultPage('Login failed', errorMessage));
|
|
93
89
|
}
|
|
94
90
|
}
|
|
95
91
|
/**
|
|
@@ -106,7 +102,7 @@ class BFFAuthProvider {
|
|
|
106
102
|
clearTimeout(timeout);
|
|
107
103
|
const errorMessage = this.generateErrorMessage(type, description);
|
|
108
104
|
reject(errorMessage);
|
|
109
|
-
res.end(
|
|
105
|
+
res.end(authResultPage('Login failed', errorMessage));
|
|
110
106
|
}
|
|
111
107
|
generateErrorMessage(type, errorDescription) {
|
|
112
108
|
let errorMessage;
|
|
@@ -132,5 +128,4 @@ class BFFAuthProvider {
|
|
|
132
128
|
});
|
|
133
129
|
}
|
|
134
130
|
}
|
|
135
|
-
exports.BFFAuthProvider = BFFAuthProvider;
|
|
136
131
|
//# sourceMappingURL=bff-auth-provider.js.map
|