@affinidi/cli 1.19.0

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 (120) hide show
  1. package/README.md +231 -0
  2. package/bin/dev +17 -0
  3. package/bin/dev.cmd +3 -0
  4. package/bin/run +5 -0
  5. package/bin/run.cmd +3 -0
  6. package/dist/commands/create/project.d.ts +10 -0
  7. package/dist/commands/create/project.js +41 -0
  8. package/dist/commands/create/project.js.map +1 -0
  9. package/dist/commands/generate-application/index.d.ts +16 -0
  10. package/dist/commands/generate-application/index.js +90 -0
  11. package/dist/commands/generate-application/index.js.map +1 -0
  12. package/dist/commands/issue-vc.d.ts +14 -0
  13. package/dist/commands/issue-vc.js +85 -0
  14. package/dist/commands/issue-vc.js.map +1 -0
  15. package/dist/commands/list/index.d.ts +7 -0
  16. package/dist/commands/list/index.js +24 -0
  17. package/dist/commands/list/index.js.map +1 -0
  18. package/dist/commands/list/projects.d.ts +15 -0
  19. package/dist/commands/list/projects.js +69 -0
  20. package/dist/commands/list/projects.js.map +1 -0
  21. package/dist/commands/list/schemas.d.ts +28 -0
  22. package/dist/commands/list/schemas.js +109 -0
  23. package/dist/commands/list/schemas.js.map +1 -0
  24. package/dist/commands/login/index.d.ts +10 -0
  25. package/dist/commands/login/index.js +50 -0
  26. package/dist/commands/login/index.js.map +1 -0
  27. package/dist/commands/logout/index.d.ts +7 -0
  28. package/dist/commands/logout/index.js +32 -0
  29. package/dist/commands/logout/index.js.map +1 -0
  30. package/dist/commands/show/index.d.ts +7 -0
  31. package/dist/commands/show/index.js +24 -0
  32. package/dist/commands/show/index.js.map +1 -0
  33. package/dist/commands/show/project.d.ts +14 -0
  34. package/dist/commands/show/project.js +84 -0
  35. package/dist/commands/show/project.js.map +1 -0
  36. package/dist/commands/show/schema.d.ts +13 -0
  37. package/dist/commands/show/schema.js +61 -0
  38. package/dist/commands/show/schema.js.map +1 -0
  39. package/dist/commands/sign-up/index.d.ts +10 -0
  40. package/dist/commands/sign-up/index.js +56 -0
  41. package/dist/commands/sign-up/index.js.map +1 -0
  42. package/dist/commands/use/index.d.ts +7 -0
  43. package/dist/commands/use/index.js +20 -0
  44. package/dist/commands/use/index.js.map +1 -0
  45. package/dist/commands/use/project.d.ts +13 -0
  46. package/dist/commands/use/project.js +77 -0
  47. package/dist/commands/use/project.js.map +1 -0
  48. package/dist/commands/verify-vc.d.ts +10 -0
  49. package/dist/commands/verify-vc.js +37 -0
  50. package/dist/commands/verify-vc.js.map +1 -0
  51. package/dist/errors/index.d.ts +20 -0
  52. package/dist/errors/index.js +63 -0
  53. package/dist/errors/index.js.map +1 -0
  54. package/dist/fixtures/mock-projects.d.ts +22 -0
  55. package/dist/fixtures/mock-projects.js +38 -0
  56. package/dist/fixtures/mock-projects.js.map +1 -0
  57. package/dist/fixtures/mock-schemas.d.ts +4 -0
  58. package/dist/fixtures/mock-schemas.js +34 -0
  59. package/dist/fixtures/mock-schemas.js.map +1 -0
  60. package/dist/index.d.ts +1 -0
  61. package/dist/index.js +6 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/render/functions.d.ts +2 -0
  64. package/dist/render/functions.js +28 -0
  65. package/dist/render/functions.js.map +1 -0
  66. package/dist/render/texts.d.ts +4 -0
  67. package/dist/render/texts.js +31 -0
  68. package/dist/render/texts.js.map +1 -0
  69. package/dist/services/git/index.d.ts +3 -0
  70. package/dist/services/git/index.js +20 -0
  71. package/dist/services/git/index.js.map +1 -0
  72. package/dist/services/iam/iam.api.d.ts +145 -0
  73. package/dist/services/iam/iam.api.js +202 -0
  74. package/dist/services/iam/iam.api.js.map +1 -0
  75. package/dist/services/iam/index.d.ts +11 -0
  76. package/dist/services/iam/index.js +59 -0
  77. package/dist/services/iam/index.js.map +1 -0
  78. package/dist/services/index.d.ts +4 -0
  79. package/dist/services/index.js +13 -0
  80. package/dist/services/index.js.map +1 -0
  81. package/dist/services/issuance/index.d.ts +10 -0
  82. package/dist/services/issuance/index.js +40 -0
  83. package/dist/services/issuance/index.js.map +1 -0
  84. package/dist/services/issuance/issuance.api.d.ts +360 -0
  85. package/dist/services/issuance/issuance.api.js +311 -0
  86. package/dist/services/issuance/issuance.api.js.map +1 -0
  87. package/dist/services/issuance/parse.schema.url.d.ts +5 -0
  88. package/dist/services/issuance/parse.schema.url.js +73 -0
  89. package/dist/services/issuance/parse.schema.url.js.map +1 -0
  90. package/dist/services/schema-manager/index.d.ts +19 -0
  91. package/dist/services/schema-manager/index.js +43 -0
  92. package/dist/services/schema-manager/index.js.map +1 -0
  93. package/dist/services/schema-manager/schema-manager.api.d.ts +279 -0
  94. package/dist/services/schema-manager/schema-manager.api.js +171 -0
  95. package/dist/services/schema-manager/schema-manager.api.js.map +1 -0
  96. package/dist/services/user-management/index.d.ts +35 -0
  97. package/dist/services/user-management/index.js +108 -0
  98. package/dist/services/user-management/index.js.map +1 -0
  99. package/dist/services/user-management/user-management.api.d.ts +110 -0
  100. package/dist/services/user-management/user-management.api.js +185 -0
  101. package/dist/services/user-management/user-management.api.js.map +1 -0
  102. package/dist/services/vault/index.d.ts +23 -0
  103. package/dist/services/vault/index.js +67 -0
  104. package/dist/services/vault/index.js.map +1 -0
  105. package/dist/services/verification/index.d.ts +9 -0
  106. package/dist/services/verification/index.js +29 -0
  107. package/dist/services/verification/index.js.map +1 -0
  108. package/dist/services/verification/verifier.api.d.ts +202 -0
  109. package/dist/services/verification/verifier.api.js +187 -0
  110. package/dist/services/verification/verifier.api.js.map +1 -0
  111. package/dist/services/writer/index.d.ts +3 -0
  112. package/dist/services/writer/index.js +17 -0
  113. package/dist/services/writer/index.js.map +1 -0
  114. package/dist/user-actions/index.d.ts +1 -0
  115. package/dist/user-actions/index.js +13 -0
  116. package/dist/user-actions/index.js.map +1 -0
  117. package/dist/user-actions/prompts.d.ts +10 -0
  118. package/dist/user-actions/prompts.js +36 -0
  119. package/dist/user-actions/prompts.js.map +1 -0
  120. package/package.json +145 -0
@@ -0,0 +1,28 @@
1
+ import { Command, Interfaces } from '@oclif/core';
2
+ import { CommandError } from '@oclif/core/lib/interfaces';
3
+ import { ScopeType } from '../../services/schema-manager';
4
+ declare type OutputType = 'csv' | 'table' | 'json';
5
+ export default class Schemas extends Command {
6
+ static description: string;
7
+ static examples: Interfaces.Example[];
8
+ static flags: {
9
+ limit: Interfaces.OptionFlag<number>;
10
+ output: Interfaces.OptionFlag<OutputType>;
11
+ scope: Interfaces.OptionFlag<ScopeType>;
12
+ public: Interfaces.OptionFlag<"false" | "true">;
13
+ skip: Interfaces.OptionFlag<number>;
14
+ columns: Interfaces.OptionFlag<string>;
15
+ sort: Interfaces.OptionFlag<string>;
16
+ filter: Interfaces.OptionFlag<string>;
17
+ csv: Interfaces.Flag<boolean>;
18
+ extended: Interfaces.Flag<boolean>;
19
+ 'no-truncate': Interfaces.Flag<boolean>;
20
+ 'no-header': Interfaces.Flag<boolean>;
21
+ };
22
+ static args: {
23
+ name: string;
24
+ }[];
25
+ run(): Promise<void>;
26
+ protected catch(err: CommandError): Promise<void>;
27
+ }
28
+ export {};
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const csv_stringify_1 = require("csv-stringify");
5
+ const services_1 = require("../../services");
6
+ const schema_manager_1 = require("../../services/schema-manager");
7
+ const printData = (data, { extended, output }) => {
8
+ switch (output) {
9
+ case 'csv':
10
+ (0, csv_stringify_1.stringify)(data, { header: true }).pipe(process.stdout);
11
+ break;
12
+ case 'table':
13
+ core_1.CliUx.ux.table(data, {
14
+ index: { header: '' },
15
+ id: { header: 'ID' },
16
+ description: { header: 'DESC' },
17
+ createdAt: { header: 'Created', extended: true },
18
+ parentId: { header: 'parent Id', extended: true },
19
+ authorDid: { header: 'author Did', extended: true },
20
+ version: {},
21
+ revision: { extended: true },
22
+ type: {},
23
+ jsonSchemaUrl: { header: 'Schema Url', extended: true },
24
+ }, {
25
+ extended,
26
+ });
27
+ break;
28
+ default:
29
+ core_1.CliUx.ux.info(JSON.stringify(data, null, ' '));
30
+ }
31
+ };
32
+ class Schemas extends core_1.Command {
33
+ async run() {
34
+ const { flags } = await this.parse(Schemas);
35
+ const { extended, limit, public: publicFlag, output, scope, skip } = flags;
36
+ const apiKey = services_1.vaultService.get(services_1.VAULT_KEYS.projectAPIKey);
37
+ const did = services_1.vaultService.get(services_1.VAULT_KEYS.projectDID);
38
+ const params = {
39
+ apiKey,
40
+ authorDid: did,
41
+ did,
42
+ limit,
43
+ scope: publicFlag === 'false' ? 'unlisted' : scope,
44
+ skip,
45
+ };
46
+ const schemas = await schema_manager_1.schemaManagerService.search(params);
47
+ const data = schemas
48
+ .map((s, index) => {
49
+ return {
50
+ index,
51
+ id: s.id,
52
+ parentId: s.parentId,
53
+ authorDid: s.authorDid,
54
+ description: s.description,
55
+ createdAt: s.createdAt,
56
+ type: s.type,
57
+ version: s.version,
58
+ revision: s.revision,
59
+ jsonSchemaUrl: s.jsonSchemaUrl,
60
+ };
61
+ })
62
+ .slice(skip, skip + limit);
63
+ printData(data, { extended, output });
64
+ }
65
+ async catch(err) {
66
+ core_1.CliUx.ux.info(err.message);
67
+ }
68
+ }
69
+ exports.default = Schemas;
70
+ Schemas.description = `
71
+ Fetches the schemas from the schema-manager and displays them in different format:
72
+ json, csv or table
73
+ `;
74
+ Schemas.examples = [
75
+ {
76
+ description: 'Display in an extended table the schemas from the 5th to the 15th',
77
+ command: '<%= config.bin %> <%= command.id %> --output table --extended --skip 5 --limit 10',
78
+ },
79
+ ];
80
+ Schemas.flags = {
81
+ ...core_1.CliUx.ux.table.flags(),
82
+ limit: core_1.Flags.integer({
83
+ char: 'l',
84
+ description: 'The number of schemas to display',
85
+ default: 10,
86
+ }),
87
+ output: core_1.Flags.enum({
88
+ char: 'o',
89
+ options: ['csv', 'json', 'table'],
90
+ description: 'The type of output',
91
+ default: 'json',
92
+ }),
93
+ scope: core_1.Flags.enum({
94
+ char: 'c',
95
+ options: ['default', 'public', 'unlisted'],
96
+ description: 'The type of scope',
97
+ default: 'default',
98
+ }),
99
+ public: core_1.Flags.enum({
100
+ char: 'p',
101
+ options: ['true', 'false'],
102
+ description: 'To specify if you want to get public or private schemas',
103
+ default: 'true',
104
+ }),
105
+ // search: Flags.string({ char: 'q', description: 'The name of the schema to search for' }),
106
+ skip: core_1.Flags.integer({ char: 's', description: 'The number of schemas to skip', default: 0 }),
107
+ };
108
+ Schemas.args = [{ name: 'file' }];
109
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/commands/list/schemas.ts"],"names":[],"mappings":";;AAAA,sCAA+D;AAE/D,iDAAyD;AAEzD,6CAAyD;AACzD,kEAA+E;AAI/E,MAAM,SAAS,GAAG,CAChB,IAA+B,EAC/B,EAAE,QAAQ,EAAE,MAAM,EAA6C,EACzD,EAAE;IACR,QAAQ,MAAM,EAAE;QACd,KAAK,KAAK;YACR,IAAA,yBAAY,EAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACzD,MAAK;QACP,KAAK,OAAO;YACV,YAAK,CAAC,EAAE,CAAC,KAAK,CACZ,IAAI,EACJ;gBACE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;gBACrB,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;gBACpB,WAAW,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;gBAC/B,SAAS,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;gBAChD,QAAQ,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE;gBACjD,SAAS,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,IAAI,EAAE;gBACnD,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE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AM,EAAE,YAAK,CAAC,IAAI,CAAmB;QACnC,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;QAC1B,WAAW,EAAE,yDAAyD;QACtE,OAAO,EAAE,MAAM;KAChB,CAAC;IACF,4FAA4F;IAC5F,IAAI,EAAE,YAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,WAAW,EAAE,+BAA+B,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;CAC7F,CAAA;AAEM,YAAI,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Login extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ name: string;
7
+ }[];
8
+ run(): Promise<void>;
9
+ catch(error: Error): Promise<void>;
10
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const EmailValidator = tslib_1.__importStar(require("email-validator"));
6
+ const user_actions_1 = require("../../user-actions");
7
+ const services_1 = require("../../services");
8
+ const errors_1 = require("../../errors");
9
+ const user_management_1 = require("../../services/user-management");
10
+ const MAX_EMAIL_ATTEMPT = 3;
11
+ class Login extends core_1.Command {
12
+ async run() {
13
+ const { args } = await this.parse(Login);
14
+ let { email } = args;
15
+ if (!email) {
16
+ email = await (0, user_actions_1.enterEmailPrompt)();
17
+ }
18
+ let wrongEmailCount = 0;
19
+ while (!EmailValidator.validate(email)) {
20
+ email = await (0, user_actions_1.enterEmailPrompt)();
21
+ wrongEmailCount += 1;
22
+ if (wrongEmailCount === MAX_EMAIL_ATTEMPT) {
23
+ core_1.CliUx.ux.error(errors_1.WrongEmailError);
24
+ }
25
+ }
26
+ // http request to affinidi sign-up endpoint
27
+ core_1.CliUx.ux.action.start('Start loging in to Affinidi');
28
+ const token = await services_1.userManagementService.login(email);
29
+ // mask input after enter is pressed
30
+ const confirmationCode = await (0, user_actions_1.enterOTPPrompt)();
31
+ core_1.CliUx.ux.action.start('Verifying the OTP');
32
+ const sessionToken = await services_1.userManagementService.confirmAndGetToken(token, confirmationCode, 'login');
33
+ core_1.CliUx.ux.action.stop('OTP verified');
34
+ core_1.CliUx.ux.action.stop('Log-in successful');
35
+ // Get userId from cookie. Slice removes `console_authtoken=` prefix.
36
+ const { userId } = (0, user_management_1.parseJwt)(sessionToken.slice('console_authtoken='.length));
37
+ (0, user_management_1.createSession)(email, userId, sessionToken);
38
+ core_1.CliUx.ux.info('You are authenticated');
39
+ core_1.CliUx.ux.info(`Welcome back to Affinidi ${email}!`);
40
+ }
41
+ async catch(error) {
42
+ core_1.CliUx.ux.action.stop('');
43
+ core_1.CliUx.ux.info(error === null || error === void 0 ? void 0 : error.message);
44
+ }
45
+ }
46
+ exports.default = Login;
47
+ Login.description = 'Please log-in with your email address to use Affinidi privacy preserving services."';
48
+ Login.examples = ['<%= config.bin %> <%= command.id %>'];
49
+ Login.args = [{ name: 'email' }];
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/login/index.ts"],"names":[],"mappings":";;;AAAA,sCAA4C;AAC5C,wEAAiD;AAEjD,qDAAqE;AACrE,6CAAsD;AACtD,yCAA8C;AAC9C,oEAAwE;AAExE,MAAM,iBAAiB,GAAG,CAAC,CAAA;AAE3B,MAAqB,KAAM,SAAQ,cAAO;IAQjC,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAExC,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;QACpB,IAAI,CAAC,KAAK,EAAE;YACV,KAAK,GAAG,MAAM,IAAA,+BAAgB,GAAE,CAAA;SACjC;QAED,IAAI,eAAe,GAAG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C,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACxB,YAAK,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,CAAC,CAAA;IAC/B,CAAC;;AArDH,wBAsDC;AArDQ,iBAAW,GAChB,qFAAqF,CAAA;AAEhF,cAAQ,GAAG,CAAC,qCAAqC,CAAC,CAAA;AAElD,UAAI,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class Logout extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ run(): Promise<void>;
6
+ catch(error: string | Error): Promise<void>;
7
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const user_actions_1 = require("../../user-actions");
5
+ const services_1 = require("../../services");
6
+ const errors_1 = require("../../errors");
7
+ const user_management_1 = require("../../services/user-management");
8
+ class Logout extends core_1.Command {
9
+ async run() {
10
+ var _a;
11
+ const answer = await (0, user_actions_1.confirmSignOut)();
12
+ if (answer !== 'y') {
13
+ await core_1.CliUx.ux.done();
14
+ return;
15
+ }
16
+ const token = (_a = (0, user_management_1.getSession)()) === null || _a === void 0 ? void 0 : _a.accessToken;
17
+ if (!token) {
18
+ core_1.CliUx.ux.error(errors_1.SignoutError);
19
+ }
20
+ await services_1.userManagementService.signout({ token });
21
+ services_1.vaultService.clear();
22
+ core_1.CliUx.ux.info("Thank you for using Affinidi's services");
23
+ }
24
+ async catch(error) {
25
+ core_1.CliUx.ux.info(`There was an error while trying to log you out. Please try again later.`);
26
+ // CliUx.ux.info(`${error.toString()}`)
27
+ }
28
+ }
29
+ exports.default = Logout;
30
+ Logout.description = 'Use this command to end your affinidi session';
31
+ Logout.examples = ['<%= config.bin %> <%= command.id %>'];
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/logout/index.ts"],"names":[],"mappings":";;AAAA,sCAA4C;AAE5C,qDAAmD;AACnD,6CAAoE;AACpE,yCAA2C;AAC3C,oEAA2D;AAE3D,MAAqB,MAAO,SAAQ,cAAO;IAKlC,KAAK,CAAC,GAAG;;QACd,MAAM,MAAM,GAAG,MAAM,IAAA,6BAAc,GAAE,CAAA;QACrC,IAAI,MAAM,KAAK,GAAG,EAAE;YAClB,MAAM,YAAK,CAAC,EAAE,CAAC,IAAI,EAAE,CAAA;YACrB,OAAM;SACP;QAED,MAAM,KAAK,GAAG,MAAA,IAAA,4BAAU,GAAE,0CAAE,WAAW,CAAA;QAEvC,IAAI,CAAC,KAAK,EAAE;YACV,YAAK,CAAC,EAAE,CAAC,KAAK,CAAC,qBAAY,CAAC,CAAA;SAC7B;QAED,MAAM,gCAAqB,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QAC9C,uBAAY,CAAC,KAAK,EAAE,CAAA;QAEpB,YAAK,CAAC,EAAE,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAA;IAC1D,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,KAAqB;QAC/B,YAAK,CAAC,EAAE,CAAC,IAAI,CAAC,yEAAyE,CAAC,CAAA;QACxF,uCAAuC;IACzC,CAAC;;AA3BH,yBA4BC;AA3BQ,kBAAW,GAAG,+CAA+C,CAAA;AAE7D,eAAQ,GAAG,CAAC,qCAAqC,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { Command, Interfaces } from '@oclif/core';
2
+ export default class Show extends Command {
3
+ static summary: string;
4
+ static description: string;
5
+ static examples: Interfaces.Example[];
6
+ run(): Promise<void>;
7
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const texts_1 = require("../../render/texts");
5
+ class Show extends core_1.Command {
6
+ async run() {
7
+ core_1.CliUx.ux.log(Show.summary);
8
+ core_1.CliUx.ux.log(Show.description);
9
+ }
10
+ }
11
+ exports.default = Show;
12
+ Show.summary = 'The Show command to display the detail of a resource';
13
+ Show.description = texts_1.showCommandDescription;
14
+ Show.examples = [
15
+ {
16
+ description: 'Shows the details of a schema',
17
+ command: '$ <%= config.bin %> <%= command.id %> schema [<schema-id>] [--output json]',
18
+ },
19
+ {
20
+ description: 'Shows information about a specific project that you own.',
21
+ command: '$ <%= config.bin %> <%= command.id %> [<project-id>] [--output json]',
22
+ },
23
+ ];
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/show/index.ts"],"names":[],"mappings":";;AAAA,sCAAwD;AAExD,8CAA2D;AAE3D,MAAqB,IAAK,SAAQ,cAAO;IAgBhC,KAAK,CAAC,GAAG;QACd,YAAK,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC1B,YAAK,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAChC,CAAC;;AAnBH,uBAoBC;AAnBQ,YAAO,GAAG,sDAAsD,CAAA;AAEhE,gBAAW,GAAG,8BAAsB,CAAA;AAEpC,aAAQ,GAAyB;IACtC;QACE,WAAW,EAAE,+BAA+B;QAC5C,OAAO,EAAE,4EAA4E;KACtF;IACD;QACE,WAAW,EAAE,0DAA0D;QACvE,OAAO,EAAE,sEAAsE;KAChF;CACF,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { Command, Interfaces } from '@oclif/core';
2
+ declare type UseFieldType = 'json' | 'json-file';
3
+ export default class ShowProject extends Command {
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ output: Interfaces.OptionFlag<UseFieldType>;
8
+ active: Interfaces.BooleanFlag<boolean>;
9
+ };
10
+ static args: Interfaces.Arg[];
11
+ run(): Promise<void>;
12
+ catch(error: string | Error): Promise<void>;
13
+ }
14
+ export {};
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const fs = tslib_1.__importStar(require("fs/promises"));
6
+ const inquirer = tslib_1.__importStar(require("inquirer"));
7
+ const user_management_1 = require("../../services/user-management");
8
+ const services_1 = require("../../services");
9
+ class ShowProject extends core_1.Command {
10
+ async run() {
11
+ var _a, _b, _c, _d, _e;
12
+ const { args, flags } = await this.parse(ShowProject);
13
+ const token = (_a = (0, user_management_1.getSession)()) === null || _a === void 0 ? void 0 : _a.accessToken;
14
+ let projectId = args['project-id'];
15
+ if (flags.active) {
16
+ projectId = services_1.vaultService.get(services_1.VAULT_KEYS.projectId);
17
+ core_1.CliUx.ux.action.start('Showing active project');
18
+ }
19
+ else if (projectId) {
20
+ core_1.CliUx.ux.action.start(`Showing project with id: ${projectId}`);
21
+ }
22
+ else {
23
+ core_1.CliUx.ux.action.start('Fetching projects');
24
+ const projectData = await services_1.iAmService.listProjects(token, 0, Number.MAX_SAFE_INTEGER);
25
+ core_1.CliUx.ux.action.stop('List of projects: ');
26
+ const maxNameLength = projectData
27
+ .map((p) => p.name.length)
28
+ .reduce((p, c) => Math.max(p, c), 0);
29
+ await inquirer
30
+ .prompt([
31
+ {
32
+ type: 'list',
33
+ name: 'projectId',
34
+ message: 'select a project',
35
+ choices: projectData.map((data) => ({
36
+ name: `${data.projectId} ${data.name.padEnd(maxNameLength)} ${data.createdAt}`,
37
+ })),
38
+ },
39
+ ])
40
+ .then(function (answer) {
41
+ projectId = answer.projectId.split(' ')[0];
42
+ });
43
+ core_1.CliUx.ux.action.start(`Showing project with id: ${projectId}`);
44
+ }
45
+ core_1.CliUx.ux.action.stop('');
46
+ const projectData = await services_1.iAmService.getProjectSummary(token, projectId);
47
+ if ((_b = projectData.apiKey) === null || _b === void 0 ? void 0 : _b.apiKeyHash) {
48
+ projectData.apiKey.apiKeyHash = ''.padEnd((_c = projectData.apiKey.apiKeyHash) === null || _c === void 0 ? void 0 : _c.length, '*');
49
+ }
50
+ if ((_d = projectData.wallet) === null || _d === void 0 ? void 0 : _d.didUrl) {
51
+ projectData.wallet.didUrl = ''.padEnd((_e = projectData.wallet.didUrl) === null || _e === void 0 ? void 0 : _e.length, '*');
52
+ }
53
+ if (flags.output === 'json-file') {
54
+ await fs.writeFile('projects.json', JSON.stringify(projectData, null, ' '));
55
+ }
56
+ else {
57
+ core_1.CliUx.ux.info(JSON.stringify(projectData, null, ' '));
58
+ }
59
+ }
60
+ async catch(error) {
61
+ core_1.CliUx.ux.info(error.toString());
62
+ }
63
+ }
64
+ exports.default = ShowProject;
65
+ ShowProject.description = 'describe the command here';
66
+ ShowProject.examples = ['<%= config.bin %> <%= command.id %>'];
67
+ ShowProject.flags = {
68
+ output: core_1.Flags.enum({
69
+ char: 'o',
70
+ options: ['json', 'json-file'],
71
+ description: 'The details of the schema to show',
72
+ default: 'json',
73
+ }),
74
+ active: core_1.Flags.boolean({
75
+ char: 'a',
76
+ }),
77
+ };
78
+ ShowProject.args = [
79
+ {
80
+ name: 'project-id',
81
+ description: 'id of the project to use',
82
+ },
83
+ ];
84
+ //# sourceMappingURL=project.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.js","sourceRoot":"","sources":["../../../src/commands/show/project.ts"],"names":[],"mappings":";;;AAAA,sCAA+D;AAC/D,wDAAiC;AACjC,2DAAoC;AACpC,oEAA2D;AAE3D,6CAAqE;AAIrE,MAAqB,WAAY,SAAQ,cAAO;IAwBvC,KAAK,CAAC,GAAG;;QACd,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;QAErD,MAAM,KAAK,GAAG,MAAA,IAAA,4BAAU,GAAE,0CAAE,WAAW,CAAA;QACvC,IAAI,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,CA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,uBAAW,GAAG,2BAA2B,CAAA;AAEzC,oBAAQ,GAAG,CAAC,qCAAqC,CAAC,CAAA;AAElD,iBAAK,GAAG;IACb,MAAM,EAAE,YAAK,CAAC,IAAI,CAAe;QAC/B,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,CAAC;QAC9B,WAAW,EAAE,mCAAmC;QAChD,OAAO,EAAE,MAAM;KAChB,CAAC;IACF,MAAM,EAAE,YAAK,CAAC,OAAO,CAAC;QACpB,IAAI,EAAE,GAAG;KACV,CAAC;CACH,CAAA;AAEM,gBAAI,GAAqB;IAC9B;QACE,IAAI,EAAE,YAAY;QAClB,WAAW,EAAE,0BAA0B;KACxC;CACF,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { Command, Interfaces } from '@oclif/core';
2
+ import { CommandError } from '@oclif/core/lib/interfaces';
3
+ export declare type ShowFieldType = 'info' | 'json' | 'jsonld';
4
+ export default class Schema extends Command {
5
+ static description: string;
6
+ static examples: Interfaces.Example[];
7
+ static flags: {
8
+ show: Interfaces.OptionFlag<ShowFieldType>;
9
+ };
10
+ static args: Interfaces.Arg[];
11
+ run(): Promise<void>;
12
+ protected catch(err: CommandError): Promise<void>;
13
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const vault_1 = require("../../services/vault");
5
+ const schema_manager_1 = require("../../services/schema-manager");
6
+ class Schema extends core_1.Command {
7
+ async run() {
8
+ const { args, flags } = await this.parse(Schema);
9
+ const apiKey = vault_1.vaultService.get(vault_1.VAULT_KEYS.projectAPIKey);
10
+ const schema = await schema_manager_1.schemaManagerService.getById(args['schema-id'], apiKey);
11
+ let output = '';
12
+ switch (flags.show) {
13
+ case 'json':
14
+ output = schema.jsonSchemaUrl;
15
+ break;
16
+ case 'jsonld':
17
+ output = schema.jsonLdContextUrl;
18
+ break;
19
+ default:
20
+ output = JSON.stringify(schema, null, ' ');
21
+ }
22
+ core_1.CliUx.ux.log(output);
23
+ }
24
+ async catch(err) {
25
+ core_1.CliUx.ux.info(err.message);
26
+ }
27
+ }
28
+ exports.default = Schema;
29
+ Schema.description = `
30
+ Fetches the information of a specific schema.
31
+ `;
32
+ Schema.examples = [
33
+ {
34
+ description: 'Shows the url to complete details of the given schema',
35
+ command: '<%= config.bin %> <%= command.id %> [SCHEMA-ID]',
36
+ },
37
+ {
38
+ description: 'Shows the url to the json file of the given schema',
39
+ command: '<%= config.bin %> <%= command.id %> [SCHEMA-ID] --show json',
40
+ },
41
+ {
42
+ description: 'Shows the url to the json-ld-context of the given schema',
43
+ command: '<%= config.bin %> <%= command.id %> [SCHEMA-ID] --show jsonld',
44
+ },
45
+ ];
46
+ Schema.flags = {
47
+ show: core_1.Flags.enum({
48
+ char: 's',
49
+ options: ['info', 'json', 'jsonld'],
50
+ description: 'The details of the schema to show',
51
+ default: 'info',
52
+ }),
53
+ };
54
+ Schema.args = [
55
+ {
56
+ name: 'schema-id',
57
+ required: true,
58
+ description: 'id or name of the schema to display',
59
+ },
60
+ ];
61
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/commands/show/schema.ts"],"names":[],"mappings":";;AAAA,sCAA+D;AAG/D,gDAA+D;AAC/D,kEAA+E;AAI/E,MAAqB,MAAO,SAAQ,cAAO;IAqClC,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAEhD,MAAM,MAAM,GAAG,oBAAY,CAAC,GAAG,CAAC,kBAAU,CAAC,aAAa,CAAC,CAAA;QACzD,MAAM,MAAM,GAAG,MAAM,qCAAoB,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,CAAA;QAE5E,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,QAAQ,KAAK,CAAC,IAAI,EAAE;YAClB,KAAK,MAAM;gBACT,MAAM,GAAG,MAAM,CAAC,aAAa,CAAA;gBAC7B,MAAK;YACP,KAAK,QAAQ;gBACX,MAAM,GAAG,MAAM,CAAC,gBAAgB,CAAA;gBAChC,MAAK;YACP;gBACE,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;SAC9C;QAED,YAAK,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACtB,CAAC;IAES,KAAK,CAAC,KAAK,CAAC,GAAiB;QACrC,YAAK,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAC5B,CAAC;;AA5DH,yBA6DC;AA5DQ,kBAAW,GAAG;;GAEpB,CAAA;AAEM,eAAQ,GAAyB;IACtC;QACE,WAAW,EAAE,uDAAuD;QACpE,OAAO,EAAE,iDAAiD;KAC3D;IACD;QACE,WAAW,EAAE,oDAAoD;QACjE,OAAO,EAAE,6DAA6D;KACvE;IACD;QACE,WAAW,EAAE,0DAA0D;QACvE,OAAO,EAAE,+DAA+D;KACzE;CACF,CAAA;AAEM,YAAK,GAAG;IACb,IAAI,EAAE,YAAK,CAAC,IAAI,CAAgB;QAC9B,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC;QACnC,WAAW,EAAE,mCAAmC;QAChD,OAAO,EAAE,MAAM;KAChB,CAAC;CACH,CAAA;AAEM,WAAI,GAAqB;IAC9B;QACE,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,qCAAqC;KACnD;CACF,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class SignUp extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ name: string;
7
+ }[];
8
+ run(): Promise<void>;
9
+ catch(error: string | Error): Promise<void>;
10
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const core_1 = require("@oclif/core");
5
+ const EmailValidator = tslib_1.__importStar(require("email-validator"));
6
+ const user_actions_1 = require("../../user-actions");
7
+ const services_1 = require("../../services");
8
+ const errors_1 = require("../../errors");
9
+ const functions_1 = require("../../render/functions");
10
+ const user_management_1 = require("../../services/user-management");
11
+ const MAX_EMAIL_ATTEMPT = 3;
12
+ class SignUp extends core_1.Command {
13
+ async run() {
14
+ const { args } = await this.parse(SignUp);
15
+ let { email } = args;
16
+ if (!email) {
17
+ email = await (0, user_actions_1.enterEmailPrompt)();
18
+ }
19
+ let wrongEmailCount = 0;
20
+ while (!EmailValidator.validate(email)) {
21
+ email = await (0, user_actions_1.enterEmailPrompt)();
22
+ wrongEmailCount += 1;
23
+ if (wrongEmailCount === MAX_EMAIL_ATTEMPT) {
24
+ core_1.CliUx.ux.error(errors_1.WrongEmailError);
25
+ }
26
+ }
27
+ const answer = await (0, user_actions_1.acceptConditionsAndPolicy)();
28
+ if (answer !== user_actions_1.AnswerYes) {
29
+ core_1.CliUx.ux.info("You must accept the conditions and policy to use Affinidi's services");
30
+ return;
31
+ }
32
+ // http request to affinidi sign-up endpoint
33
+ core_1.CliUx.ux.action.start('Start signing-up to Affinidi');
34
+ const token = await services_1.userManagementService.signUp(email);
35
+ // mask input after enter is pressed
36
+ core_1.CliUx.ux.action.start('Verifying the OTP');
37
+ const confirmationCode = await (0, user_actions_1.enterOTPPrompt)();
38
+ core_1.CliUx.ux.action.start('Verifying the OTP');
39
+ const sessionToken = await services_1.userManagementService.confirmAndGetToken(token, confirmationCode, 'signup');
40
+ core_1.CliUx.ux.action.stop('OTP verified');
41
+ core_1.CliUx.ux.action.stop('Sign-up successful');
42
+ // Get userId from cookie. Slice removes `console_authtoken=` prefix.
43
+ const { userId } = (0, user_management_1.parseJwt)(sessionToken.slice('console_authtoken='.length));
44
+ (0, user_management_1.createSession)(email, userId, sessionToken);
45
+ core_1.CliUx.ux.info((0, functions_1.buildWelcomeUserMessage)());
46
+ }
47
+ async catch(error) {
48
+ core_1.CliUx.ux.action.stop('');
49
+ core_1.CliUx.ux.info(error.toString());
50
+ }
51
+ }
52
+ exports.default = SignUp;
53
+ SignUp.description = 'Use this command with your email address to create a new Affinid account.';
54
+ SignUp.examples = ['<%= config.bin %> <%= command.id %>'];
55
+ SignUp.args = [{ name: 'email' }];
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/sign-up/index.ts"],"names":[],"mappings":";;;AAAA,sCAA4C;AAC5C,wEAAiD;AAEjD,qDAK2B;AAC3B,6CAAsD;AACtD,yCAA8C;AAC9C,sDAAgE;AAChE,oEAAwE;AAExE,MAAM,iBAAiB,GAAG,CAAC,CAAA;AAE3B,MAAqB,MAAO,SAAQ,cAAO;IAOlC,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAEzC,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;QACpB,IAAI,CAAC,KAAK,EAAE;YACV,KAAK,GAAG,MAAM,IAAA,+BAAgB,GAAE,CAAA;SACjC;QAED,IAAI,eAAe,GAAG,CAAC,CAAA;QACvB,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YACtC,KAAK,GAAG,MAAM,IAAA,+BAAgB,GAAE,CAAA;YAChC,eAAe,IAAI,CAAC,CAAA;YACpB,IAAI,eAAe,KAAK,iBAAiB,EAAE;gBACzC,YAAK,CAAC,EAAE,CAAC,KAAK,CAAC,wBAAe,CAAC,CAAA;aAChC;SACF;QAED,MAAM,MAAM,GAAG,MAAM,IAAA,wCAAyB,GAAE,CAAA;QAChD,IAAI,MAAM,KAAK,wBAAS,EAA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1DQ,kBAAW,GAAG,2EAA2E,CAAA;AAEzF,eAAQ,GAAG,CAAC,qCAAqC,CAAC,CAAA;AAElD,WAAI,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { Command, Interfaces } from '@oclif/core';
2
+ export default class Use extends Command {
3
+ static summary: string;
4
+ static description: string;
5
+ static examples: Interfaces.Example[];
6
+ run(): Promise<void>;
7
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const texts_1 = require("../../render/texts");
5
+ class Use extends core_1.Command {
6
+ async run() {
7
+ core_1.CliUx.ux.log(Use.summary);
8
+ core_1.CliUx.ux.log(Use.description);
9
+ }
10
+ }
11
+ exports.default = Use;
12
+ Use.summary = 'The Use command selects an entity to work with';
13
+ Use.description = texts_1.useCommandDescription;
14
+ Use.examples = [
15
+ {
16
+ description: 'Use a given project',
17
+ command: '$ <%= config.bin %> <%= command.id %> use [<project-id>]',
18
+ },
19
+ ];
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/use/index.ts"],"names":[],"mappings":";;AAAA,sCAAwD;AAExD,8CAA0D;AAE1D,MAAqB,GAAI,SAAQ,cAAO;IAY/B,KAAK,CAAC,GAAG;QACd,YAAK,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACzB,YAAK,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IAC/B,CAAC;;AAfH,sBAgBC;AAfQ,WAAO,GAAG,gDAAgD,CAAA;AAE1D,eAAW,GAAG,6BAAqB,CAAA;AAEnC,YAAQ,GAAyB;IACtC;QACE,WAAW,EAAE,qBAAqB;QAClC,OAAO,EAAE,0DAA0D;KACpE;CACF,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { Command, Interfaces } from '@oclif/core';
2
+ declare type UseFieldType = 'json' | 'json-file';
3
+ export default class Project extends Command {
4
+ static description: string;
5
+ static examples: string[];
6
+ static flags: {
7
+ output: Interfaces.OptionFlag<UseFieldType>;
8
+ };
9
+ static args: Interfaces.Arg[];
10
+ run(): Promise<void>;
11
+ catch(error: string | Error): Promise<void>;
12
+ }
13
+ export {};