@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.
- package/README.md +231 -0
- package/bin/dev +17 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +5 -0
- package/bin/run.cmd +3 -0
- package/dist/commands/create/project.d.ts +10 -0
- package/dist/commands/create/project.js +41 -0
- package/dist/commands/create/project.js.map +1 -0
- package/dist/commands/generate-application/index.d.ts +16 -0
- package/dist/commands/generate-application/index.js +90 -0
- package/dist/commands/generate-application/index.js.map +1 -0
- package/dist/commands/issue-vc.d.ts +14 -0
- package/dist/commands/issue-vc.js +85 -0
- package/dist/commands/issue-vc.js.map +1 -0
- package/dist/commands/list/index.d.ts +7 -0
- package/dist/commands/list/index.js +24 -0
- package/dist/commands/list/index.js.map +1 -0
- package/dist/commands/list/projects.d.ts +15 -0
- package/dist/commands/list/projects.js +69 -0
- package/dist/commands/list/projects.js.map +1 -0
- package/dist/commands/list/schemas.d.ts +28 -0
- package/dist/commands/list/schemas.js +109 -0
- package/dist/commands/list/schemas.js.map +1 -0
- package/dist/commands/login/index.d.ts +10 -0
- package/dist/commands/login/index.js +50 -0
- package/dist/commands/login/index.js.map +1 -0
- package/dist/commands/logout/index.d.ts +7 -0
- package/dist/commands/logout/index.js +32 -0
- package/dist/commands/logout/index.js.map +1 -0
- package/dist/commands/show/index.d.ts +7 -0
- package/dist/commands/show/index.js +24 -0
- package/dist/commands/show/index.js.map +1 -0
- package/dist/commands/show/project.d.ts +14 -0
- package/dist/commands/show/project.js +84 -0
- package/dist/commands/show/project.js.map +1 -0
- package/dist/commands/show/schema.d.ts +13 -0
- package/dist/commands/show/schema.js +61 -0
- package/dist/commands/show/schema.js.map +1 -0
- package/dist/commands/sign-up/index.d.ts +10 -0
- package/dist/commands/sign-up/index.js +56 -0
- package/dist/commands/sign-up/index.js.map +1 -0
- package/dist/commands/use/index.d.ts +7 -0
- package/dist/commands/use/index.js +20 -0
- package/dist/commands/use/index.js.map +1 -0
- package/dist/commands/use/project.d.ts +13 -0
- package/dist/commands/use/project.js +77 -0
- package/dist/commands/use/project.js.map +1 -0
- package/dist/commands/verify-vc.d.ts +10 -0
- package/dist/commands/verify-vc.js +37 -0
- package/dist/commands/verify-vc.js.map +1 -0
- package/dist/errors/index.d.ts +20 -0
- package/dist/errors/index.js +63 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/fixtures/mock-projects.d.ts +22 -0
- package/dist/fixtures/mock-projects.js +38 -0
- package/dist/fixtures/mock-projects.js.map +1 -0
- package/dist/fixtures/mock-schemas.d.ts +4 -0
- package/dist/fixtures/mock-schemas.js +34 -0
- package/dist/fixtures/mock-schemas.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/render/functions.d.ts +2 -0
- package/dist/render/functions.js +28 -0
- package/dist/render/functions.js.map +1 -0
- package/dist/render/texts.d.ts +4 -0
- package/dist/render/texts.js +31 -0
- package/dist/render/texts.js.map +1 -0
- package/dist/services/git/index.d.ts +3 -0
- package/dist/services/git/index.js +20 -0
- package/dist/services/git/index.js.map +1 -0
- package/dist/services/iam/iam.api.d.ts +145 -0
- package/dist/services/iam/iam.api.js +202 -0
- package/dist/services/iam/iam.api.js.map +1 -0
- package/dist/services/iam/index.d.ts +11 -0
- package/dist/services/iam/index.js +59 -0
- package/dist/services/iam/index.js.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.js +13 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/issuance/index.d.ts +10 -0
- package/dist/services/issuance/index.js +40 -0
- package/dist/services/issuance/index.js.map +1 -0
- package/dist/services/issuance/issuance.api.d.ts +360 -0
- package/dist/services/issuance/issuance.api.js +311 -0
- package/dist/services/issuance/issuance.api.js.map +1 -0
- package/dist/services/issuance/parse.schema.url.d.ts +5 -0
- package/dist/services/issuance/parse.schema.url.js +73 -0
- package/dist/services/issuance/parse.schema.url.js.map +1 -0
- package/dist/services/schema-manager/index.d.ts +19 -0
- package/dist/services/schema-manager/index.js +43 -0
- package/dist/services/schema-manager/index.js.map +1 -0
- package/dist/services/schema-manager/schema-manager.api.d.ts +279 -0
- package/dist/services/schema-manager/schema-manager.api.js +171 -0
- package/dist/services/schema-manager/schema-manager.api.js.map +1 -0
- package/dist/services/user-management/index.d.ts +35 -0
- package/dist/services/user-management/index.js +108 -0
- package/dist/services/user-management/index.js.map +1 -0
- package/dist/services/user-management/user-management.api.d.ts +110 -0
- package/dist/services/user-management/user-management.api.js +185 -0
- package/dist/services/user-management/user-management.api.js.map +1 -0
- package/dist/services/vault/index.d.ts +23 -0
- package/dist/services/vault/index.js +67 -0
- package/dist/services/vault/index.js.map +1 -0
- package/dist/services/verification/index.d.ts +9 -0
- package/dist/services/verification/index.js +29 -0
- package/dist/services/verification/index.js.map +1 -0
- package/dist/services/verification/verifier.api.d.ts +202 -0
- package/dist/services/verification/verifier.api.js +187 -0
- package/dist/services/verification/verifier.api.js.map +1 -0
- package/dist/services/writer/index.d.ts +3 -0
- package/dist/services/writer/index.js +17 -0
- package/dist/services/writer/index.js.map +1 -0
- package/dist/user-actions/index.d.ts +1 -0
- package/dist/user-actions/index.js +13 -0
- package/dist/user-actions/index.js.map +1 -0
- package/dist/user-actions/prompts.d.ts +10 -0
- package/dist/user-actions/prompts.js +36 -0
- package/dist/user-actions/prompts.js.map +1 -0
- package/package.json +145 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.userManagementService = exports.createSession = exports.getSession = exports.parseJwt = exports.USER_MANAGEMENT_URL = void 0;
|
|
4
|
+
const nanoid_1 = require("nanoid");
|
|
5
|
+
const user_management_api_1 = require("./user-management.api");
|
|
6
|
+
const errors_1 = require("../../errors");
|
|
7
|
+
const vault_1 = require("../vault");
|
|
8
|
+
exports.USER_MANAGEMENT_URL = 'https://console-user-management.apse1.affinidi.com/api/v1';
|
|
9
|
+
const SERVICE = 'userManagement';
|
|
10
|
+
const parseJwt = (token) => {
|
|
11
|
+
return JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString());
|
|
12
|
+
};
|
|
13
|
+
exports.parseJwt = parseJwt;
|
|
14
|
+
const getSession = () => {
|
|
15
|
+
const storageValue = vault_1.vaultService.get(vault_1.VAULT_KEYS.session);
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
17
|
+
return storageValue ? JSON.parse(storageValue) : undefined;
|
|
18
|
+
};
|
|
19
|
+
exports.getSession = getSession;
|
|
20
|
+
const createSession = (accountLabel, accountId, accessToken, scopes = []) => {
|
|
21
|
+
const session = {
|
|
22
|
+
id: (0, nanoid_1.nanoid)(),
|
|
23
|
+
accessToken,
|
|
24
|
+
account: { label: accountLabel, id: accountId },
|
|
25
|
+
scopes,
|
|
26
|
+
};
|
|
27
|
+
vault_1.vaultService.set(vault_1.VAULT_KEYS.session, JSON.stringify(session));
|
|
28
|
+
return session;
|
|
29
|
+
};
|
|
30
|
+
exports.createSession = createSession;
|
|
31
|
+
class UserManagementService {
|
|
32
|
+
constructor(client = new user_management_api_1.Api({
|
|
33
|
+
baseURL: exports.USER_MANAGEMENT_URL,
|
|
34
|
+
withCredentials: true,
|
|
35
|
+
})) {
|
|
36
|
+
this.client = client;
|
|
37
|
+
this.confirm = async (token, confirmationCode, flow) => {
|
|
38
|
+
try {
|
|
39
|
+
switch (flow) {
|
|
40
|
+
case 'signup':
|
|
41
|
+
return this.client.auth.signupConfirmation({ token, confirmationCode });
|
|
42
|
+
case 'login':
|
|
43
|
+
return this.client.auth.loginConfirmation({ token, confirmationCode });
|
|
44
|
+
default:
|
|
45
|
+
throw Error(`cannot call the ${flow} method from the user-management service`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
return (0, errors_1.handleErrors)(new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
this.signUp = async (username) => {
|
|
53
|
+
try {
|
|
54
|
+
const result = await this.client.auth.signupUser({ username });
|
|
55
|
+
return result.data;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
return (0, errors_1.handleErrors)(new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE));
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
this.login = async (username) => {
|
|
62
|
+
try {
|
|
63
|
+
const result = await this.client.auth.login({ username });
|
|
64
|
+
return result.data;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
return (0, errors_1.handleErrors)(new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE));
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
this.confirmAndGetToken = async (token, confirmationCode, flow) => {
|
|
71
|
+
try {
|
|
72
|
+
const response = await this.confirm(token, confirmationCode, flow);
|
|
73
|
+
const cookies = response.headers['set-cookie'];
|
|
74
|
+
const cookie = cookies.pop();
|
|
75
|
+
if (!cookie) {
|
|
76
|
+
throw Error('Empty cookie');
|
|
77
|
+
}
|
|
78
|
+
return cookie;
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
return (0, errors_1.handleErrors)(new errors_1.CliError(err === null || err === void 0 ? void 0 : err.message, err.response.status, SERVICE));
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
this.signout = async ({ token }) => {
|
|
85
|
+
try {
|
|
86
|
+
await this.client.auth.logout({
|
|
87
|
+
headers: { Cookie: token, 'content-type': 'application/json' },
|
|
88
|
+
});
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
(0, errors_1.handleErrors)(new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE));
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
this.me = async () => {
|
|
96
|
+
try {
|
|
97
|
+
const result = await this.client.auth.me();
|
|
98
|
+
return result.data;
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
return (0, errors_1.handleErrors)(new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE));
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const userManagementService = new UserManagementService();
|
|
107
|
+
exports.userManagementService = userManagementService;
|
|
108
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/user-management/index.ts"],"names":[],"mappings":";;;AACA,mCAA+B;AAC/B,+DAAgE;AAChE,yCAAqD;AACrD,oCAAmD;AAKtC,QAAA,mBAAmB,GAAG,2DAA2D,CAAA;AAC9F,MAAM,OAAO,GAAG,gBAAgB,CAAA;AAYzB,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,EAAE;IACxC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;AAC1E,CAAC,CAAA;AAFY,QAAA,QAAQ,YAEpB;AAEM,MAAM,UAAU,GAAG,GAAY,EAAE;IACtC,MAAM,YAAY,GAAG,oBAAY,CAAC,GAAG,CAAC,kBAAU,CAAC,OAAO,CAAC,CAAA;IACzD,yEAAyE;IACzE,OAAO,YAAY,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAa,CAAC,CAAC,CAAC,SAAS,CAAA;AACzE,CAAC,CAAA;AAJY,QAAA,UAAU,cAItB;AAEM,MAAM,aAAa,GAAG,CAC3B,YAAoB,EACpB,SAAiB,EACjB,WAAmB,EACnB,SAAmB,EAAE,EACZ,EAAE;IACX,MAAM,OAAO,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
+
confirmationCode: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AuthLoginInput {
|
|
9
|
+
username: string;
|
|
10
|
+
}
|
|
11
|
+
import { AxiosInstance, AxiosRequestConfig, AxiosResponse, ResponseType } from 'axios';
|
|
12
|
+
export declare type QueryParamsType = Record<string | number, any>;
|
|
13
|
+
export interface FullRequestParams extends Omit<AxiosRequestConfig, 'data' | 'params' | 'url' | 'responseType'> {
|
|
14
|
+
/** set parameter to `true` for call `securityWorker` for this request */
|
|
15
|
+
secure?: boolean;
|
|
16
|
+
/** request path */
|
|
17
|
+
path: string;
|
|
18
|
+
/** content type of request body */
|
|
19
|
+
type?: ContentType;
|
|
20
|
+
/** query params */
|
|
21
|
+
query?: QueryParamsType;
|
|
22
|
+
/** format of response (i.e. response.json() -> format: "json") */
|
|
23
|
+
format?: ResponseType;
|
|
24
|
+
/** request body */
|
|
25
|
+
body?: unknown;
|
|
26
|
+
}
|
|
27
|
+
export declare type RequestParams = Omit<FullRequestParams, 'body' | 'method' | 'query' | 'path'>;
|
|
28
|
+
export interface ApiConfig<SecurityDataType = unknown> extends Omit<AxiosRequestConfig, 'data' | 'cancelToken'> {
|
|
29
|
+
securityWorker?: (securityData: SecurityDataType | null) => Promise<AxiosRequestConfig | void> | AxiosRequestConfig | void;
|
|
30
|
+
secure?: boolean;
|
|
31
|
+
format?: ResponseType;
|
|
32
|
+
}
|
|
33
|
+
export declare enum ContentType {
|
|
34
|
+
Json = "application/json",
|
|
35
|
+
FormData = "multipart/form-data",
|
|
36
|
+
UrlEncoded = "application/x-www-form-urlencoded"
|
|
37
|
+
}
|
|
38
|
+
export declare class HttpClient<SecurityDataType = unknown> {
|
|
39
|
+
instance: AxiosInstance;
|
|
40
|
+
private securityData;
|
|
41
|
+
private securityWorker?;
|
|
42
|
+
private secure?;
|
|
43
|
+
private format?;
|
|
44
|
+
constructor({ securityWorker, secure, format, ...axiosConfig }?: ApiConfig<SecurityDataType>);
|
|
45
|
+
setSecurityData: (data: SecurityDataType | null) => void;
|
|
46
|
+
protected mergeRequestParams(params1: AxiosRequestConfig, params2?: AxiosRequestConfig): AxiosRequestConfig;
|
|
47
|
+
protected stringifyFormItem(formItem: unknown): string;
|
|
48
|
+
protected createFormData(input: Record<string, unknown>): FormData;
|
|
49
|
+
request: <T = any, _E = any>({ secure, path, type, query, format, body, ...params }: FullRequestParams) => Promise<AxiosResponse<T, any>>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @title console-user-management
|
|
53
|
+
* @version 1.19.1
|
|
54
|
+
* @license ISC
|
|
55
|
+
* @baseUrl /api/v1
|
|
56
|
+
* @contact Dmytro Filipenko dmytro.f@affinidi.com
|
|
57
|
+
*
|
|
58
|
+
* This is a new service
|
|
59
|
+
*/
|
|
60
|
+
export declare class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDataType> {
|
|
61
|
+
auth: {
|
|
62
|
+
/**
|
|
63
|
+
* No description
|
|
64
|
+
*
|
|
65
|
+
* @name SignupUser
|
|
66
|
+
* @request POST:/auth/signup
|
|
67
|
+
*/
|
|
68
|
+
signupUser: (data: AuthSignupInput, params?: RequestParams) => Promise<AxiosResponse<string, any>>;
|
|
69
|
+
/**
|
|
70
|
+
* No description
|
|
71
|
+
*
|
|
72
|
+
* @name SignupConfirmation
|
|
73
|
+
* @request POST:/auth/signup/confirm
|
|
74
|
+
*/
|
|
75
|
+
signupConfirmation: (data: AuthConfirmationInput, params?: RequestParams) => Promise<AxiosResponse<void, any>>;
|
|
76
|
+
/**
|
|
77
|
+
* No description
|
|
78
|
+
*
|
|
79
|
+
* @name Login
|
|
80
|
+
* @request POST:/auth/login
|
|
81
|
+
*/
|
|
82
|
+
login: (data: AuthLoginInput, params?: RequestParams) => Promise<AxiosResponse<string, any>>;
|
|
83
|
+
/**
|
|
84
|
+
* No description
|
|
85
|
+
*
|
|
86
|
+
* @name LoginConfirmation
|
|
87
|
+
* @request POST:/auth/login/confirm
|
|
88
|
+
*/
|
|
89
|
+
loginConfirmation: (data: AuthConfirmationInput, params?: RequestParams) => Promise<AxiosResponse<void, any>>;
|
|
90
|
+
/**
|
|
91
|
+
* No description
|
|
92
|
+
*
|
|
93
|
+
* @name Logout
|
|
94
|
+
* @request POST:/auth/logout
|
|
95
|
+
*/
|
|
96
|
+
logout: (params?: RequestParams) => Promise<AxiosResponse<void, any>>;
|
|
97
|
+
/**
|
|
98
|
+
* No description
|
|
99
|
+
*
|
|
100
|
+
* @name Me
|
|
101
|
+
* @request GET:/auth/me
|
|
102
|
+
*/
|
|
103
|
+
me: (params?: RequestParams) => Promise<AxiosResponse<{
|
|
104
|
+
tenantIds?: string;
|
|
105
|
+
role?: string;
|
|
106
|
+
userId: string;
|
|
107
|
+
username: string;
|
|
108
|
+
}, any>>;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/*
|
|
5
|
+
* ---------------------------------------------------------------
|
|
6
|
+
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
|
|
7
|
+
* ## ##
|
|
8
|
+
* ## AUTHOR: acacode ##
|
|
9
|
+
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
|
|
10
|
+
* ---------------------------------------------------------------
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.Api = exports.HttpClient = exports.ContentType = void 0;
|
|
14
|
+
const tslib_1 = require("tslib");
|
|
15
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
16
|
+
var ContentType;
|
|
17
|
+
(function (ContentType) {
|
|
18
|
+
ContentType["Json"] = "application/json";
|
|
19
|
+
ContentType["FormData"] = "multipart/form-data";
|
|
20
|
+
ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
|
|
21
|
+
})(ContentType = exports.ContentType || (exports.ContentType = {}));
|
|
22
|
+
class HttpClient {
|
|
23
|
+
constructor({ securityWorker, secure, format, ...axiosConfig } = {}) {
|
|
24
|
+
this.securityData = null;
|
|
25
|
+
this.setSecurityData = (data) => {
|
|
26
|
+
this.securityData = data;
|
|
27
|
+
};
|
|
28
|
+
this.request = async ({ secure, path, type, query, format, body, ...params }) => {
|
|
29
|
+
const secureParams = ((typeof secure === 'boolean' ? secure : this.secure) &&
|
|
30
|
+
this.securityWorker &&
|
|
31
|
+
(await this.securityWorker(this.securityData))) ||
|
|
32
|
+
{};
|
|
33
|
+
const requestParams = this.mergeRequestParams(params, secureParams);
|
|
34
|
+
const responseFormat = format || this.format || undefined;
|
|
35
|
+
if (type === ContentType.FormData && body && body !== null && typeof body === 'object') {
|
|
36
|
+
body = this.createFormData(body);
|
|
37
|
+
}
|
|
38
|
+
return this.instance.request({
|
|
39
|
+
...requestParams,
|
|
40
|
+
headers: {
|
|
41
|
+
...(requestParams.headers || {}),
|
|
42
|
+
...(type && type !== ContentType.FormData ? { 'Content-Type': type } : {}),
|
|
43
|
+
},
|
|
44
|
+
params: query,
|
|
45
|
+
responseType: responseFormat,
|
|
46
|
+
data: body,
|
|
47
|
+
url: path,
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
this.instance = axios_1.default.create({ ...axiosConfig, baseURL: axiosConfig.baseURL || '/api/v1' });
|
|
51
|
+
this.secure = secure;
|
|
52
|
+
this.format = format;
|
|
53
|
+
this.securityWorker = securityWorker;
|
|
54
|
+
}
|
|
55
|
+
mergeRequestParams(params1, params2) {
|
|
56
|
+
const method = params1.method || (params2 && params2.method);
|
|
57
|
+
return {
|
|
58
|
+
...this.instance.defaults,
|
|
59
|
+
...params1,
|
|
60
|
+
...(params2 || {}),
|
|
61
|
+
headers: {
|
|
62
|
+
...((method &&
|
|
63
|
+
this.instance.defaults.headers[method.toLowerCase()]) ||
|
|
64
|
+
{}),
|
|
65
|
+
...(params1.headers || {}),
|
|
66
|
+
...((params2 && params2.headers) || {}),
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
stringifyFormItem(formItem) {
|
|
71
|
+
if (typeof formItem === 'object' && formItem !== null) {
|
|
72
|
+
return JSON.stringify(formItem);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return `${formItem}`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
createFormData(input) {
|
|
79
|
+
return Object.keys(input || {}).reduce((formData, key) => {
|
|
80
|
+
const property = input[key];
|
|
81
|
+
const propertyContent = property instanceof Array ? property : [property];
|
|
82
|
+
for (const formItem of propertyContent) {
|
|
83
|
+
const isFileType = formItem instanceof Blob || formItem instanceof File;
|
|
84
|
+
formData.append(key, isFileType ? formItem : this.stringifyFormItem(formItem));
|
|
85
|
+
}
|
|
86
|
+
return formData;
|
|
87
|
+
}, new FormData());
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.HttpClient = HttpClient;
|
|
91
|
+
/**
|
|
92
|
+
* @title console-user-management
|
|
93
|
+
* @version 1.19.1
|
|
94
|
+
* @license ISC
|
|
95
|
+
* @baseUrl /api/v1
|
|
96
|
+
* @contact Dmytro Filipenko dmytro.f@affinidi.com
|
|
97
|
+
*
|
|
98
|
+
* This is a new service
|
|
99
|
+
*/
|
|
100
|
+
class Api extends HttpClient {
|
|
101
|
+
constructor() {
|
|
102
|
+
super(...arguments);
|
|
103
|
+
this.auth = {
|
|
104
|
+
/**
|
|
105
|
+
* No description
|
|
106
|
+
*
|
|
107
|
+
* @name SignupUser
|
|
108
|
+
* @request POST:/auth/signup
|
|
109
|
+
*/
|
|
110
|
+
signupUser: (data, params = {}) => this.request({
|
|
111
|
+
path: `/auth/signup`,
|
|
112
|
+
method: 'POST',
|
|
113
|
+
body: data,
|
|
114
|
+
type: ContentType.Json,
|
|
115
|
+
format: 'json',
|
|
116
|
+
...params,
|
|
117
|
+
}),
|
|
118
|
+
/**
|
|
119
|
+
* No description
|
|
120
|
+
*
|
|
121
|
+
* @name SignupConfirmation
|
|
122
|
+
* @request POST:/auth/signup/confirm
|
|
123
|
+
*/
|
|
124
|
+
signupConfirmation: (data, params = {}) => this.request({
|
|
125
|
+
path: `/auth/signup/confirm`,
|
|
126
|
+
method: 'POST',
|
|
127
|
+
body: data,
|
|
128
|
+
type: ContentType.Json,
|
|
129
|
+
...params,
|
|
130
|
+
}),
|
|
131
|
+
/**
|
|
132
|
+
* No description
|
|
133
|
+
*
|
|
134
|
+
* @name Login
|
|
135
|
+
* @request POST:/auth/login
|
|
136
|
+
*/
|
|
137
|
+
login: (data, params = {}) => this.request({
|
|
138
|
+
path: `/auth/login`,
|
|
139
|
+
method: 'POST',
|
|
140
|
+
body: data,
|
|
141
|
+
type: ContentType.Json,
|
|
142
|
+
format: 'json',
|
|
143
|
+
...params,
|
|
144
|
+
}),
|
|
145
|
+
/**
|
|
146
|
+
* No description
|
|
147
|
+
*
|
|
148
|
+
* @name LoginConfirmation
|
|
149
|
+
* @request POST:/auth/login/confirm
|
|
150
|
+
*/
|
|
151
|
+
loginConfirmation: (data, params = {}) => this.request({
|
|
152
|
+
path: `/auth/login/confirm`,
|
|
153
|
+
method: 'POST',
|
|
154
|
+
body: data,
|
|
155
|
+
type: ContentType.Json,
|
|
156
|
+
...params,
|
|
157
|
+
}),
|
|
158
|
+
/**
|
|
159
|
+
* No description
|
|
160
|
+
*
|
|
161
|
+
* @name Logout
|
|
162
|
+
* @request POST:/auth/logout
|
|
163
|
+
*/
|
|
164
|
+
logout: (params = {}) => this.request({
|
|
165
|
+
path: `/auth/logout`,
|
|
166
|
+
method: 'POST',
|
|
167
|
+
...params,
|
|
168
|
+
}),
|
|
169
|
+
/**
|
|
170
|
+
* No description
|
|
171
|
+
*
|
|
172
|
+
* @name Me
|
|
173
|
+
* @request GET:/auth/me
|
|
174
|
+
*/
|
|
175
|
+
me: (params = {}) => this.request({
|
|
176
|
+
path: `/auth/me`,
|
|
177
|
+
method: 'GET',
|
|
178
|
+
format: 'json',
|
|
179
|
+
...params,
|
|
180
|
+
}),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.Api = Api;
|
|
185
|
+
//# sourceMappingURL=user-management.api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-management.api.js","sourceRoot":"","sources":["../../../src/services/user-management/user-management.api.ts"],"names":[],"mappings":";AAAA,oBAAoB;AACpB,oBAAoB;AACpB;;;;;;;GAOG;;;;AAeH,0DAMc;AA+Bd,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,+CAAgC,CAAA;IAChC,+DAAgD,CAAA;AAClD,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAED,MAAa,UAAU;IAOrB,YAAY,EACV,cAAc,EACd,MAAM,EACN,MAAM,EACN,GAAG,WAAW,KACiB,EAAE;QAV3B,iBAAY,GAA4B,IAAI,CAAA;QAiB7C,oBAAe,GAAG,CAAC,IAA6B,EAAE,EAAE;YACzD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAA;QAC1B,CAAC,CAAA;QA4CM,YAAO,GAAG,KAAK,EAAqB,EACzC,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,MAAM,EACN,IAAI,EACJ,GAAG,MAAM,EACS,EAA6B,EAAE;YACjD,MAAM,YAAY,GAChB,CAAC,CAAC,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;gBACnD,IAAI,CAAC,cAAc;gBACnB,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;gBACjD,EAAE,CAAA;YACJ,MAAM,aAAa,GAAG,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;YACnE,MAAM,cAAc,GAAG,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS,CAAA;YAEzD,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;;;eAKG;YACH,EAAE,EAAE,CAAC,SAAwB,EAAE,EAAE,EAAE,CACjC,IAAI,CAAC,OAAO,CAQV;gBACA,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE,MAAM;gBACd,GAAG,MAAM;aACV,CAAC;SACL,CAAA;IACH,CAAC;CAAA;AAnGD,kBAmGC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const VAULT_KEYS: {
|
|
2
|
+
projectId: string;
|
|
3
|
+
projectName: string;
|
|
4
|
+
projectAPIKey: string;
|
|
5
|
+
projectDID: string;
|
|
6
|
+
session: string;
|
|
7
|
+
};
|
|
8
|
+
interface IVaultSetterGetter {
|
|
9
|
+
clear: () => void;
|
|
10
|
+
delete: (key: string) => void;
|
|
11
|
+
get(key: string): string | null;
|
|
12
|
+
set(key: string, value: string): void;
|
|
13
|
+
}
|
|
14
|
+
declare class VaultService {
|
|
15
|
+
private readonly storer;
|
|
16
|
+
constructor(storer: IVaultSetterGetter);
|
|
17
|
+
clear: () => void;
|
|
18
|
+
delete: (key: string) => void;
|
|
19
|
+
get: (key: string) => string | null;
|
|
20
|
+
set: (key: string, value: string) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const vaultService: VaultService;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.vaultService = exports.VAULT_KEYS = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const conf_1 = tslib_1.__importDefault(require("conf"));
|
|
6
|
+
const os = tslib_1.__importStar(require("os"));
|
|
7
|
+
const path = tslib_1.__importStar(require("path"));
|
|
8
|
+
exports.VAULT_KEYS = {
|
|
9
|
+
projectId: 'active-project-id',
|
|
10
|
+
projectName: 'active-project-name',
|
|
11
|
+
projectAPIKey: 'active-project-api-key',
|
|
12
|
+
projectDID: 'active-project-did',
|
|
13
|
+
session: 'session',
|
|
14
|
+
};
|
|
15
|
+
const doNothing = () => { };
|
|
16
|
+
class VaultService {
|
|
17
|
+
constructor(storer) {
|
|
18
|
+
this.clear = () => {
|
|
19
|
+
this.storer.clear();
|
|
20
|
+
};
|
|
21
|
+
this.delete = (key) => {
|
|
22
|
+
this.storer.delete(key);
|
|
23
|
+
};
|
|
24
|
+
this.get = (key) => {
|
|
25
|
+
const value = this.storer.get(key);
|
|
26
|
+
return typeof value === 'string' ? value : null;
|
|
27
|
+
};
|
|
28
|
+
this.set = (key, value) => {
|
|
29
|
+
this.storer.set(key, value);
|
|
30
|
+
};
|
|
31
|
+
this.storer = storer;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const testStore = new Map();
|
|
35
|
+
const testStorer = {
|
|
36
|
+
clear: doNothing,
|
|
37
|
+
delete: (key) => {
|
|
38
|
+
testStore.delete(key);
|
|
39
|
+
},
|
|
40
|
+
get: (key) => {
|
|
41
|
+
const value = testStore.get(key);
|
|
42
|
+
return typeof value === 'string' ? value : null;
|
|
43
|
+
},
|
|
44
|
+
set: (key, value) => {
|
|
45
|
+
testStore.set(key, value);
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
const credentialConf = new conf_1.default({
|
|
49
|
+
cwd: path.join(os.homedir(), '.affinidi', 'credentials'),
|
|
50
|
+
});
|
|
51
|
+
const storer = {
|
|
52
|
+
clear: () => {
|
|
53
|
+
credentialConf.clear();
|
|
54
|
+
},
|
|
55
|
+
delete: (key) => {
|
|
56
|
+
credentialConf.delete(key);
|
|
57
|
+
},
|
|
58
|
+
get: (key) => {
|
|
59
|
+
const value = credentialConf.get(key);
|
|
60
|
+
return typeof value === 'string' ? value : null;
|
|
61
|
+
},
|
|
62
|
+
set: (key, value) => {
|
|
63
|
+
credentialConf.set(key, value);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
exports.vaultService = new VaultService(process.env.NODE_ENV === 'test' ? testStorer : storer);
|
|
67
|
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U,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Api as VerifierApi, VerifyCredentialInput, VerifyCredentialOutput } from './verifier.api';
|
|
2
|
+
export declare const VERIFIER_URL = "https://affinity-verifier.prod.affinity-project.org/api/v1";
|
|
3
|
+
declare class VerifierService {
|
|
4
|
+
private readonly client;
|
|
5
|
+
constructor(client?: VerifierApi<unknown>);
|
|
6
|
+
verifyVC: (apiKey: string, verifyVCInput: VerifyCredentialInput) => Promise<VerifyCredentialOutput>;
|
|
7
|
+
}
|
|
8
|
+
declare const verfierService: VerifierService;
|
|
9
|
+
export { verfierService };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verfierService = exports.VERIFIER_URL = void 0;
|
|
4
|
+
const errors_1 = require("../../errors");
|
|
5
|
+
const verifier_api_1 = require("./verifier.api");
|
|
6
|
+
exports.VERIFIER_URL = 'https://affinity-verifier.prod.affinity-project.org/api/v1';
|
|
7
|
+
const SERVICE = 'verification';
|
|
8
|
+
class VerifierService {
|
|
9
|
+
constructor(client = new verifier_api_1.Api({
|
|
10
|
+
baseURL: exports.VERIFIER_URL,
|
|
11
|
+
withCredentials: true,
|
|
12
|
+
})) {
|
|
13
|
+
this.client = client;
|
|
14
|
+
this.verifyVC = async (apiKey, verifyVCInput) => {
|
|
15
|
+
try {
|
|
16
|
+
const resp = await this.client.verifier.verifyCredentials(verifyVCInput, {
|
|
17
|
+
headers: { 'Api-Key': apiKey },
|
|
18
|
+
});
|
|
19
|
+
return resp.data;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
return (0, errors_1.handleErrors)(new errors_1.CliError(error === null || error === void 0 ? void 0 : error.message, error.response.status, SERVICE));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const verfierService = new VerifierService();
|
|
28
|
+
exports.verfierService = verfierService;
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/verification/index.ts"],"names":[],"mappings":";;;AAAA,yCAAqD;AACrD,iDAAkG;AAErF,QAAA,YAAY,GAAG,4DAA4D,CAAA;AACxF,MAAM,OAAO,GAAG,cAAc,CAAA;AAE9B,MAAM,eAAe;IACnB,YACmB,SAAS,IAAI,kBAAW,CAAC;QACxC,OAAO,EAAE,oBAAY;QACrB,eAAe,EAAE,IAAI;KACtB,CAAC;QAHe,WAAM,GAAN,MAAM,CAGrB;QAGG,aAAQ,GAAG,KAAK,EACrB,MAAc,EACd,aAAoC,EACH,EAAE;YACnC,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,aAAa,EAAE;oBACvE,OAAO,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;iBAC/B,CAAC,CAAA;gBACF,OAAO,IAAI,CAAC,IAAI,CAAA;aACjB;YAAC,OAAO,KAAK,EAAE;gBACd,OAAO,IAAA,qBAAY,EAAC,IAAI,iBAAQ,CAAC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;aAClF;QACH,CAAC,CAAA;IAdE,CAAC;CAeL;AAED,MAAM,cAAc,GAAG,IAAI,eAAe,EAAE,CAAA;AACnC,wCAAc"}
|