@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.
Files changed (184) hide show
  1. package/README.md +2 -2
  2. package/bin/dev.cmd +1 -1
  3. package/bin/dev.js +5 -0
  4. package/bin/run.js +5 -0
  5. package/dist/commands/generate/app.d.ts +7 -7
  6. package/dist/commands/generate/app.js +72 -75
  7. package/dist/commands/generate/app.js.map +1 -1
  8. package/dist/commands/iam/add-principal.d.ts +3 -3
  9. package/dist/commands/iam/add-principal.js +27 -31
  10. package/dist/commands/iam/add-principal.js.map +1 -1
  11. package/dist/commands/iam/get-policies.d.ts +4 -4
  12. package/dist/commands/iam/get-policies.js +27 -31
  13. package/dist/commands/iam/get-policies.js.map +1 -1
  14. package/dist/commands/iam/list-principals.d.ts +2 -2
  15. package/dist/commands/iam/list-principals.js +9 -14
  16. package/dist/commands/iam/list-principals.js.map +1 -1
  17. package/dist/commands/iam/remove-principal.d.ts +4 -3
  18. package/dist/commands/iam/remove-principal.js +27 -31
  19. package/dist/commands/iam/remove-principal.js.map +1 -1
  20. package/dist/commands/iam/update-policies.d.ts +5 -5
  21. package/dist/commands/iam/update-policies.js +44 -48
  22. package/dist/commands/iam/update-policies.js.map +1 -1
  23. package/dist/commands/login/add-user-to-group.d.ts +4 -4
  24. package/dist/commands/login/add-user-to-group.js +16 -21
  25. package/dist/commands/login/add-user-to-group.js.map +1 -1
  26. package/dist/commands/login/create-config.d.ts +11 -10
  27. package/dist/commands/login/create-config.js +46 -50
  28. package/dist/commands/login/create-config.js.map +1 -1
  29. package/dist/commands/login/create-group.d.ts +3 -3
  30. package/dist/commands/login/create-group.js +15 -20
  31. package/dist/commands/login/create-group.js.map +1 -1
  32. package/dist/commands/login/delete-config.d.ts +2 -2
  33. package/dist/commands/login/delete-config.js +14 -19
  34. package/dist/commands/login/delete-config.js.map +1 -1
  35. package/dist/commands/login/delete-group.d.ts +2 -2
  36. package/dist/commands/login/delete-group.js +14 -19
  37. package/dist/commands/login/delete-group.js.map +1 -1
  38. package/dist/commands/login/export-configs.d.ts +3 -3
  39. package/dist/commands/login/export-configs.js +21 -27
  40. package/dist/commands/login/export-configs.js.map +1 -1
  41. package/dist/commands/login/export-groups.d.ts +3 -3
  42. package/dist/commands/login/export-groups.js +21 -27
  43. package/dist/commands/login/export-groups.js.map +1 -1
  44. package/dist/commands/login/get-config.d.ts +3 -3
  45. package/dist/commands/login/get-config.js +14 -19
  46. package/dist/commands/login/get-config.js.map +1 -1
  47. package/dist/commands/login/get-group.d.ts +3 -3
  48. package/dist/commands/login/get-group.js +14 -19
  49. package/dist/commands/login/get-group.js.map +1 -1
  50. package/dist/commands/login/import-configs.d.ts +3 -3
  51. package/dist/commands/login/import-configs.js +33 -37
  52. package/dist/commands/login/import-configs.js.map +1 -1
  53. package/dist/commands/login/import-groups.d.ts +3 -3
  54. package/dist/commands/login/import-groups.js +21 -26
  55. package/dist/commands/login/import-groups.js.map +1 -1
  56. package/dist/commands/login/list-configs.d.ts +2 -2
  57. package/dist/commands/login/list-configs.js +7 -11
  58. package/dist/commands/login/list-configs.js.map +1 -1
  59. package/dist/commands/login/list-groups.d.ts +2 -2
  60. package/dist/commands/login/list-groups.js +7 -11
  61. package/dist/commands/login/list-groups.js.map +1 -1
  62. package/dist/commands/login/list-users-in-group.d.ts +5 -5
  63. package/dist/commands/login/list-users-in-group.js +24 -29
  64. package/dist/commands/login/list-users-in-group.js.map +1 -1
  65. package/dist/commands/login/remove-user-from-group.d.ts +3 -3
  66. package/dist/commands/login/remove-user-from-group.js +16 -21
  67. package/dist/commands/login/remove-user-from-group.js.map +1 -1
  68. package/dist/commands/login/update-config.d.ts +10 -10
  69. package/dist/commands/login/update-config.js +40 -45
  70. package/dist/commands/login/update-config.js.map +1 -1
  71. package/dist/commands/project/create-project.d.ts +4 -4
  72. package/dist/commands/project/create-project.js +16 -21
  73. package/dist/commands/project/create-project.js.map +1 -1
  74. package/dist/commands/project/get-active-project.d.ts +2 -2
  75. package/dist/commands/project/get-active-project.js +7 -11
  76. package/dist/commands/project/get-active-project.js.map +1 -1
  77. package/dist/commands/project/list-projects.d.ts +2 -2
  78. package/dist/commands/project/list-projects.js +7 -11
  79. package/dist/commands/project/list-projects.js.map +1 -1
  80. package/dist/commands/project/select-project.d.ts +3 -3
  81. package/dist/commands/project/select-project.js +20 -25
  82. package/dist/commands/project/select-project.js.map +1 -1
  83. package/dist/commands/project/update-project.d.ts +5 -5
  84. package/dist/commands/project/update-project.js +18 -23
  85. package/dist/commands/project/update-project.js.map +1 -1
  86. package/dist/commands/start.d.ts +1 -1
  87. package/dist/commands/start.js +13 -18
  88. package/dist/commands/start.js.map +1 -1
  89. package/dist/commands/stop.d.ts +1 -1
  90. package/dist/commands/stop.js +13 -18
  91. package/dist/commands/stop.js.map +1 -1
  92. package/dist/commands/token/create-token.d.ts +10 -9
  93. package/dist/commands/token/create-token.js +58 -60
  94. package/dist/commands/token/create-token.js.map +1 -1
  95. package/dist/commands/token/delete-token.d.ts +2 -2
  96. package/dist/commands/token/delete-token.js +13 -17
  97. package/dist/commands/token/delete-token.js.map +1 -1
  98. package/dist/commands/token/get-token.d.ts +3 -3
  99. package/dist/commands/token/get-token.js +13 -17
  100. package/dist/commands/token/get-token.js.map +1 -1
  101. package/dist/commands/token/list-tokens.d.ts +2 -2
  102. package/dist/commands/token/list-tokens.js +7 -11
  103. package/dist/commands/token/list-tokens.js.map +1 -1
  104. package/dist/commands/token/update-token.d.ts +8 -7
  105. package/dist/commands/token/update-token.js +30 -33
  106. package/dist/commands/token/update-token.js.map +1 -1
  107. package/dist/commands/whoami.d.ts +1 -1
  108. package/dist/commands/whoami.js +7 -11
  109. package/dist/commands/whoami.js.map +1 -1
  110. package/dist/common/base-command.d.ts +1 -12
  111. package/dist/common/base-command.js +13 -17
  112. package/dist/common/base-command.js.map +1 -1
  113. package/dist/common/constants.js +12 -15
  114. package/dist/common/constants.js.map +1 -1
  115. package/dist/common/error-messages.js +1 -5
  116. package/dist/common/error-messages.js.map +1 -1
  117. package/dist/common/prompts.js +7 -11
  118. package/dist/common/prompts.js.map +1 -1
  119. package/dist/common/validators.js +15 -21
  120. package/dist/common/validators.js.map +1 -1
  121. package/dist/helpers/app.js +17 -30
  122. package/dist/helpers/app.js.map +1 -1
  123. package/dist/helpers/degit.js +6 -11
  124. package/dist/helpers/degit.js.map +1 -1
  125. package/dist/helpers/jwk.d.ts +1 -1
  126. package/dist/helpers/jwk.js +16 -24
  127. package/dist/helpers/jwk.js.map +1 -1
  128. package/dist/helpers/token.d.ts +4 -5
  129. package/dist/helpers/token.js +13 -20
  130. package/dist/helpers/token.js.map +1 -1
  131. package/dist/index.js +1 -5
  132. package/dist/index.js.map +1 -1
  133. package/dist/services/affinidi/auth/auth-result-page.js +1 -5
  134. package/dist/services/affinidi/auth/auth-result-page.js.map +1 -1
  135. package/dist/services/affinidi/auth/bff-auth-provider.d.ts +1 -1
  136. package/dist/services/affinidi/auth/bff-auth-provider.js +25 -30
  137. package/dist/services/affinidi/auth/bff-auth-provider.js.map +1 -1
  138. package/dist/services/affinidi/auth/types.d.ts +1 -1
  139. package/dist/services/affinidi/auth/types.js +1 -2
  140. package/dist/services/affinidi/bff-service.d.ts +5 -5
  141. package/dist/services/affinidi/bff-service.js +56 -61
  142. package/dist/services/affinidi/bff-service.js.map +1 -1
  143. package/dist/services/affinidi/bff-service.types.js +1 -2
  144. package/dist/services/affinidi/errors.js +21 -26
  145. package/dist/services/affinidi/errors.js.map +1 -1
  146. package/dist/services/affinidi/iam/iam.api.d.ts +21 -21
  147. package/dist/services/affinidi/iam/iam.api.js +6 -12
  148. package/dist/services/affinidi/iam/iam.api.js.map +1 -1
  149. package/dist/services/affinidi/iam/{index.d.ts → service.d.ts} +4 -4
  150. package/dist/services/affinidi/iam/{index.js → service.js} +36 -40
  151. package/dist/services/affinidi/iam/service.js.map +1 -0
  152. package/dist/services/affinidi/logger/console-logger-adapter.d.ts +1 -1
  153. package/dist/services/affinidi/logger/console-logger-adapter.js +1 -5
  154. package/dist/services/affinidi/logger/console-logger-adapter.js.map +1 -1
  155. package/dist/services/affinidi/logger/logger-adapter.js +1 -2
  156. package/dist/services/affinidi/vp-adapter/{index.d.ts → service.d.ts} +2 -2
  157. package/dist/services/affinidi/vp-adapter/{index.js → service.js} +38 -41
  158. package/dist/services/affinidi/vp-adapter/service.js.map +1 -0
  159. package/dist/services/affinidi/vp-adapter/vp-adapter.api.d.ts +43 -43
  160. package/dist/services/affinidi/vp-adapter/vp-adapter.api.js +8 -14
  161. package/dist/services/affinidi/vp-adapter/vp-adapter.api.js.map +1 -1
  162. package/dist/services/credentials-vault.d.ts +0 -1
  163. package/dist/services/credentials-vault.js +15 -21
  164. package/dist/services/credentials-vault.js.map +1 -1
  165. package/dist/services/env-config.d.ts +1 -1
  166. package/dist/services/env-config.js +6 -10
  167. package/dist/services/env-config.js.map +1 -1
  168. package/dist/services/generator/auth0.d.ts +1 -1
  169. package/dist/services/generator/auth0.js +3 -8
  170. package/dist/services/generator/auth0.js.map +1 -1
  171. package/dist/services/generator/env-configurer.js +5 -9
  172. package/dist/services/generator/env-configurer.js.map +1 -1
  173. package/package.json +39 -42
  174. package/theme.json +26 -0
  175. package/bin/dev +0 -17
  176. package/bin/run +0 -5
  177. package/dist/common/index.d.ts +0 -2
  178. package/dist/common/index.js +0 -8
  179. package/dist/common/index.js.map +0 -1
  180. package/dist/services/affinidi/iam/index.js.map +0 -1
  181. package/dist/services/affinidi/logger/index.d.ts +0 -2
  182. package/dist/services/affinidi/logger/index.js +0 -6
  183. package/dist/services/affinidi/logger/index.js.map +0 -1
  184. 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":";;;AAAA,SAAgB,yBAAyB,CAAC,IAAY;IACpD,OAAO,iFAAiF,IAAI,2BAA2B,CAAA;AACzH,CAAC;AAFD,8DAEC"}
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"}
@@ -1,21 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promptRequiredParameters = void 0;
4
- const prompts_1 = require("@inquirer/prompts");
5
- const errors_1 = require("@oclif/core/lib/errors");
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 errors_1.CLIError((0, error_messages_1.giveFlagInputErrorMessage)(requiredFlags[key]));
9
+ throw new CLIError(giveFlagInputErrorMessage(requiredFlags[key]));
13
10
  }
14
- const validatedInput = (0, validators_1.validateInputLength)(await (0, prompts_1.input)({ message: `Enter the value for ${requiredFlags[key]}` }), validators_1.INPUT_LIMIT);
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":";;;AAAA,+CAAyC;AACzC,mDAAiD;AACjD,qDAA4D;AAC5D,6CAA+D;AAExD,K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AAa,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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.policiesDataSchema = exports.split = exports.validateInputLength = exports.PRESENTATION_DEFINITION_LIMIT = exports.TOKEN_LIMIT = exports.INPUT_LIMIT = void 0;
4
- const tslib_1 = require("tslib");
5
- const errors_1 = require("@oclif/core/lib/errors");
6
- const zod_1 = tslib_1.__importDefault(require("zod"));
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 errors_1.CLIError(`String must contain at most ${maxLength} character(s)`);
8
+ throw new CLIError(`String must contain at most ${maxLength} character(s)`);
13
9
  }
14
10
  return text;
15
11
  }
16
- exports.validateInputLength = validateInputLength;
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
- exports.split = split;
21
- exports.policiesDataSchema = zod_1.default.object({
22
- version: zod_1.default.string().max(exports.INPUT_LIMIT),
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: zod_1.default.string().max(exports.INPUT_LIMIT).array().length(1),
26
- action: zod_1.default.string().max(exports.INPUT_LIMIT).array().nonempty(),
27
- resource: zod_1.default.string().max(exports.INPUT_LIMIT).array().nonempty(),
28
- effect: zod_1.default.literal('Allow'),
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":";;;;AAAA,mDAAiD;AACjD,sDAAmB;AAEN,QAAA,WAAW,GAAG,IAAI,CAAA;AAClB,QAAA,WAAW,GAAG,IAAI,CAAA;AAClB,QAAA,6BAA6B,GAAG,IAAI,CAAA;AAEjD,SAAgB,mBAAmB,CAAC,IAAY,EAAE,SAAiB;IACjE,IAAI,IAAI,CAAC,MAAM,GAAG,SAAS,EAAE;QAC3B,MAAM,IAAI,iBAAQ,CAAC,+BAA+B,SAAS,eAAe,CAAC,CAAA;KAC5E;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAND,kDAMC;AAED,SAAgB,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;AAFD,sBAEC;AAEY,QAAA,kBAAkB,GAAG,aAAC,CAAC,MAAM,CAAC;IACzC,OAAO,EAAE,aAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,mBAAW,CAAC;IACpC,SAAS,EAAE,aAAC;SACT,MAAM,CAAC;QACN,SAAS,EAAE,aAAC,CAAC,MAAM,EAAE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C,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"}
@@ -1,36 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAppMetadataToken = exports.getRedirectUri = exports.getSupportedAppsInformation = exports.getSupportedLibraries = exports.getSupportedFrameworks = exports.getSupportedProviders = exports.getSupportedSampleApps = exports.getApps = exports.getAppName = void 0;
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
- exports.getAppName = getAppName;
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 axios_1.default.get(githubFileUrl);
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 errors_1.CLIError('Unable to fetch supported apps');
17
+ throw new CLIError('Unable to fetch supported apps');
23
18
  }
24
19
  catch (err) {
25
- throw new errors_1.CLIError('Unable to fetch supported apps');
20
+ throw new CLIError('Unable to fetch supported apps');
26
21
  }
27
22
  }
28
- exports.getApps = getApps;
29
- function getSupportedSampleApps(appsInformation) {
23
+ export function getSupportedSampleApps(appsInformation) {
30
24
  return Object.keys(appsInformation);
31
25
  }
32
- exports.getSupportedSampleApps = getSupportedSampleApps;
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 errors_1.CLIError('Unable to fetch supported providers');
38
+ throw new CLIError('Unable to fetch supported providers');
46
39
  }
47
40
  }
48
- exports.getSupportedProviders = getSupportedProviders;
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 errors_1.CLIError('Unable to fetch supported frameworks');
59
+ throw new CLIError('Unable to fetch supported frameworks');
68
60
  }
69
61
  }
70
- exports.getSupportedFrameworks = getSupportedFrameworks;
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 errors_1.CLIError('Unable to fetch supported libraries');
81
+ throw new CLIError('Unable to fetch supported libraries');
91
82
  }
92
83
  }
93
- exports.getSupportedLibraries = getSupportedLibraries;
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
- exports.getSupportedAppsInformation = getSupportedAppsInformation;
102
- function getRedirectUri(apps, appName) {
91
+ export function getRedirectUri(apps, appName) {
103
92
  return apps[appName].redirectUris.callbackUrl;
104
93
  }
105
- exports.getRedirectUri = getRedirectUri;
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
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/helpers/app.ts"],"names":[],"mappings":";;;;AAAA,mDAAiD;AACjD,0DAAyB;AAyCzB,SAAgB,UAAU,CAAC,SAAiB,EAAE,QAAgB,EAAE,OAAe;IAC7E,OAAO,GAAG,QAAQ,IAAI,SAAS,IAAI,OAAO,EAAE,CAAA;AAC9C,CAAC;AAFD,gCAEC;AAEM,KAAK,UAAU,OAAO,CAAC,QAAgB;IAC5C,MAAM,aAAa,GAAG,+EAA+E,QAAQ,EAAE,CAAA;IAC/G,wBAAwB;IACxB,uHAAuH;IAEvH,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;QAC/C,IAAI,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE;YAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ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OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAA;AACrC,CAAC"}
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cloneWithDegit = void 0;
4
- const tslib_1 = require("tslib");
5
- const errors_1 = require("@oclif/core/lib/errors");
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 errors_1.CLIError(`Unable to generate reference application\n${chalk_1.default.red(message)}`);
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":";;;;AAAA,mDAAiD;AACjD,0DAAyB;AACzB,0DAAyB;AAElB,KAAK,UAAU,cAAc,CAAC,MAAc,EAAE,WAAmB,EAAE,KAAc;IACtF,MAAM,OAAO,GAAG,IAAA,eAAK,EAAC,MAAM,EAAE;QAC5B,KAAK,EAAE,KAAK;QACZ,KAAK;QACL,OAAO,EAAE,KAAK;KACf,CAAC,CAAA;IAEF,IAAI;QACF,MAAM,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;KACjC;IAAC,OAAO,KAAK,EAAE;QACd,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,iBAAQ,CAAC,6CAA6C,eAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;KACtF;AACH,CAAC;AAtBD,wCAsBC"}
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"}
@@ -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>;
@@ -1,49 +1,41 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.decryptSessionIdWithPrivateKey = exports.JWKToPem = exports.getKeyType = exports.pemToJWK = void 0;
4
- const tslib_1 = require("tslib");
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 errors_1.CLIError('Unable to decode the provided public key');
10
+ throw new CLIError('Unable to decode the provided public key');
15
11
  }
16
12
  }
17
- exports.pemToJWK = pemToJWK;
18
- function getKeyType(algorithm) {
13
+ export function getKeyType(algorithm) {
19
14
  switch (algorithm) {
20
- case common_1.SupportedAlgorithms.ES256:
21
- case common_1.SupportedAlgorithms.ES512:
22
- return common_1.SupportedKeyTypes.EC;
23
- case common_1.SupportedAlgorithms.RS256:
24
- case common_1.SupportedAlgorithms.RS512:
25
- return common_1.SupportedKeyTypes.RSA;
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
- exports.getKeyType = getKeyType;
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 errors_1.CLIError('Unable to convert the provided public key to pem format');
28
+ throw new CLIError('Unable to convert the provided public key to pem format');
35
29
  }
36
30
  }
37
- exports.JWKToPem = JWKToPem;
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 errors_1.CLIError('Unable to decrypt the message with the private-key');
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
@@ -1 +1 @@
1
- {"version":3,"file":"jwk.js","sourceRoot":"","sources":["../../src/helpers/jwk.ts"],"names":[],"mappings":";;;;AAAA,mDAAiD;AACjD,mDAA4B;AAC5B,sCAAkE;AAE3D,KAAK,UAAU,QAAQ,CAAC,YAAoB,EAAE,SAA8B;IACjF,IAAI;QACF,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,SAAS,CAAC,CAAA;QAChE,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAA;KACvC;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,iBAAQ,CAAC,0CAA0C,CAAC,CAAA;KAC/D;AACH,CAAC;AAPD,4BAOC;AAED,SAAgB,UAAU,CAAC,SAA8B;IACvD,QAAQ,SAAS,EAAE;QACjB,KAAK,4BAAmB,CAAC,KAAK,CAAC;QAC/B,KAAK,4BAAmB,CAAC,KAAK;YAC5B,OAAO,0BAAiB,CAAC,EAA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,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"}
@@ -1,6 +1,5 @@
1
- /// <reference types="node" />
2
- import { SupportedAlgorithms } from '../common';
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>;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updatePolicies = exports.addPrincipal = exports.createToken = exports.generateKeyPair = void 0;
4
- const node_crypto_1 = require("node:crypto");
5
- const validators_1 = require("../common/validators");
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
- exports.generateKeyPair = generateKeyPair;
33
- async function createToken(name, algorithm, jwks, keyId) {
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 index_1.iamService.updateToken(token.id, {
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
- exports.createToken = createToken;
61
- async function addPrincipal(tokenId) {
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
- exports.addPrincipal = addPrincipal;
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 = validators_1.policiesDataSchema.parse(policiesData);
81
- const result = await index_1.iamService.updatePolicies(tokenId, 'token', validatedPolicies);
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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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":";;;AAAA,oCAAiC;AAAxB,2FAAA,GAAG,OAAA"}
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
- "use strict";
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":";;;AAAO,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,OAAe,EAAE,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAgGtD,KAAK;;UAEP,OAAO;;;;;;CAMhB,CAAA;AAxGY,QAAA,cAAc,kBAwG1B"}
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BFFAuthProvider = void 0;
4
- const tslib_1 = require("tslib");
5
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
6
- const express_1 = tslib_1.__importDefault(require("express"));
7
- const helmet_1 = tslib_1.__importDefault(require("helmet"));
8
- const open_1 = tslib_1.__importDefault(require("open"));
9
- const tcp_port_used_1 = require("tcp-port-used");
10
- const auth_result_page_1 = require("./auth-result-page");
11
- const jwk_1 = require("../../../helpers/jwk");
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 (0, tcp_port_used_1.check)(env_config_1.config.redirectPort);
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 bff_service_1.bffService.postAuthUrl(await (0, jwk_1.JWKToPem)(publicKey));
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 = (0, express_1.default)();
34
- app.use((0, helmet_1.default)({
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 (${env_config_1.config.redirectTimeoutMs / 1000}s) exceeded`));
47
- }, env_config_1.config.redirectTimeoutMs);
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${chalk_1.default.underline(authUrl)}\n\n`);
57
+ `\n${chalk.underline(authUrl)}\n\n`);
62
58
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
63
- (0, open_1.default)(authUrl.href);
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 bff_service_1.bffService.getSessionId(state);
75
+ const encryptedSessionIdBase64 = await bffService.getSessionId(state);
80
76
  const encryptedSessionId = Buffer.from(encryptedSessionIdBase64, 'base64').toString('utf-8');
81
- const sessionId = await (0, jwk_1.decryptSessionIdWithPrivateKey)(encryptedSessionId, privateKey);
77
+ const sessionId = await decryptSessionIdWithPrivateKey(encryptedSessionId, privateKey);
82
78
  this.logger.debug(`Received session: ${JSON.stringify(sessionId)}`);
83
- await credentials_vault_1.credentialsVault.setSessionId(sessionId);
79
+ await credentialsVault.setSessionId(sessionId);
84
80
  this.logger.debug('Session stored in vault');
85
81
  resolve(sessionId);
86
- res.end((0, auth_result_page_1.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>'));
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((0, auth_result_page_1.authResultPage)('Login failed', errorMessage));
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((0, auth_result_page_1.authResultPage)('Login failed', errorMessage));
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