@sphereon/ssi-sdk.uni-resolver-registrar-api 0.33.1-feature.vcdm2.tsup.32 → 0.33.1-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-functions.d.ts +30 -0
- package/dist/api-functions.d.ts.map +1 -0
- package/dist/api-functions.js +300 -0
- package/dist/api-functions.js.map +1 -0
- package/dist/did-web-server.d.ts +20 -0
- package/dist/did-web-server.d.ts.map +1 -0
- package/dist/did-web-server.js +51 -0
- package/dist/did-web-server.js.map +1 -0
- package/dist/index.d.ts +5 -143
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -337
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +98 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/uni-resolver-api-server.d.ts +20 -0
- package/dist/uni-resolver-api-server.d.ts.map +1 -0
- package/dist/uni-resolver-api-server.js +49 -0
- package/dist/uni-resolver-api-server.js.map +1 -0
- package/package.json +21 -31
- package/src/types.ts +0 -1
- package/dist/index.cjs +0 -370
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -145
package/package.json
CHANGED
|
@@ -1,34 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.uni-resolver-registrar-api",
|
|
3
|
-
"version": "0.33.1-
|
|
3
|
+
"version": "0.33.1-next.2+6f7f40b9",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"module": "./dist/index.js",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"exports": {
|
|
10
|
-
"react-native": "./dist/index.js",
|
|
11
|
-
"import": {
|
|
12
|
-
"types": "./dist/index.d.ts",
|
|
13
|
-
"import": "./dist/index.js"
|
|
14
|
-
},
|
|
15
|
-
"require": {
|
|
16
|
-
"types": "./dist/index.d.cts",
|
|
17
|
-
"require": "./dist/index.cjs"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
20
7
|
"scripts": {
|
|
21
|
-
"build": "
|
|
8
|
+
"build": "tsc --build",
|
|
9
|
+
"build:clean": "tsc --build --clean && tsc --build",
|
|
22
10
|
"start:prod": "node build/index.js",
|
|
23
11
|
"start:dev": "ts-node __tests__/agent.ts"
|
|
24
12
|
},
|
|
25
13
|
"dependencies": {
|
|
26
|
-
"@sphereon/ssi-express-support": "
|
|
27
|
-
"@sphereon/ssi-sdk-ext.did-utils": "0.28.
|
|
28
|
-
"@sphereon/ssi-sdk-ext.key-manager": "0.28.
|
|
29
|
-
"@sphereon/ssi-sdk-ext.key-utils": "0.28.
|
|
30
|
-
"@sphereon/ssi-sdk.core": "
|
|
31
|
-
"@sphereon/ssi-types": "
|
|
14
|
+
"@sphereon/ssi-express-support": "0.33.1-next.2+6f7f40b9",
|
|
15
|
+
"@sphereon/ssi-sdk-ext.did-utils": "0.28.0",
|
|
16
|
+
"@sphereon/ssi-sdk-ext.key-manager": "0.28.0",
|
|
17
|
+
"@sphereon/ssi-sdk-ext.key-utils": "0.28.0",
|
|
18
|
+
"@sphereon/ssi-sdk.core": "0.33.1-next.2+6f7f40b9",
|
|
19
|
+
"@sphereon/ssi-types": "0.33.1-next.2+6f7f40b9",
|
|
32
20
|
"@veramo/core": "4.2.0",
|
|
33
21
|
"body-parser": "^1.20.2",
|
|
34
22
|
"casbin": "^5.30.0",
|
|
@@ -43,10 +31,10 @@
|
|
|
43
31
|
},
|
|
44
32
|
"devDependencies": {
|
|
45
33
|
"@sphereon/did-uni-client": "^0.6.3",
|
|
46
|
-
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.28.
|
|
47
|
-
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.28.
|
|
48
|
-
"@sphereon/ssi-sdk.data-store": "
|
|
49
|
-
"@sphereon/ssi-sdk.vc-handler-ld-local": "
|
|
34
|
+
"@sphereon/ssi-sdk-ext.did-provider-jwk": "0.28.0",
|
|
35
|
+
"@sphereon/ssi-sdk-ext.did-resolver-jwk": "0.28.0",
|
|
36
|
+
"@sphereon/ssi-sdk.data-store": "0.33.1-next.2+6f7f40b9",
|
|
37
|
+
"@sphereon/ssi-sdk.vc-handler-ld-local": "0.33.1-next.2+6f7f40b9",
|
|
50
38
|
"@types/body-parser": "^1.19.5",
|
|
51
39
|
"@types/cookie-parser": "^1.4.7",
|
|
52
40
|
"@types/cors": "^2.8.17",
|
|
@@ -75,12 +63,13 @@
|
|
|
75
63
|
"passport": "^0.6.0",
|
|
76
64
|
"passport-azure-ad": "^4.3.5",
|
|
77
65
|
"ts-node": "^10.9.2",
|
|
78
|
-
"typeorm": "0.3.
|
|
66
|
+
"typeorm": "^0.3.21",
|
|
79
67
|
"web-did-resolver": "^2.0.27"
|
|
80
68
|
},
|
|
81
69
|
"files": [
|
|
82
|
-
"
|
|
83
|
-
"
|
|
70
|
+
".yalc/**/*",
|
|
71
|
+
"dist/**/*",
|
|
72
|
+
"src/**/*",
|
|
84
73
|
"README.md",
|
|
85
74
|
"plugin.schema.json",
|
|
86
75
|
"LICENSE"
|
|
@@ -101,5 +90,6 @@
|
|
|
101
90
|
"Inversal Registrar",
|
|
102
91
|
"DIF"
|
|
103
92
|
],
|
|
104
|
-
"
|
|
93
|
+
"nx": {},
|
|
94
|
+
"gitHead": "6f7f40b94beb385369fede046c3912bd0c053408"
|
|
105
95
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DIDDocument } from '@sphereon/did-uni-client'
|
|
2
2
|
import { GenericAuthArgs, ISingleEndpointOpts } from '@sphereon/ssi-express-support'
|
|
3
|
-
import { JsonWebKey } from '@sphereon/ssi-types'
|
|
4
3
|
import { IAgentContext, IDataStoreORM, IDIDManager, IKeyManager, IResolver } from '@veramo/core'
|
|
5
4
|
import { VerificationMethod } from 'did-resolver'
|
|
6
5
|
|
package/dist/index.cjs
DELETED
|
@@ -1,370 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/index.ts
|
|
32
|
-
var index_exports = {};
|
|
33
|
-
__export(index_exports, {
|
|
34
|
-
UniResolverApiServer: () => UniResolverApiServer,
|
|
35
|
-
createDidEndpoint: () => createDidEndpoint,
|
|
36
|
-
deactivateDidEndpoint: () => deactivateDidEndpoint,
|
|
37
|
-
deleteDidEndpoint: () => deleteDidEndpoint,
|
|
38
|
-
didWebDomainEndpoint: () => didWebDomainEndpoint,
|
|
39
|
-
getDidMethodsEndpoint: () => getDidMethodsEndpoint,
|
|
40
|
-
resolveDidEndpoint: () => resolveDidEndpoint
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(index_exports);
|
|
43
|
-
|
|
44
|
-
// src/uni-resolver-api-server.ts
|
|
45
|
-
var import_ssi_sdk = require("@sphereon/ssi-sdk.core");
|
|
46
|
-
var import_ssi_express_support2 = require("@sphereon/ssi-express-support");
|
|
47
|
-
var import_express = __toESM(require("express"), 1);
|
|
48
|
-
|
|
49
|
-
// src/api-functions.ts
|
|
50
|
-
var import_ssi_sdk_ext = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
51
|
-
var import_ssi_sdk_ext2 = require("@sphereon/ssi-sdk-ext.key-utils");
|
|
52
|
-
var import_ssi_express_support = require("@sphereon/ssi-express-support");
|
|
53
|
-
var import_ssi_types = require("@sphereon/ssi-types");
|
|
54
|
-
var import_uuid = require("uuid");
|
|
55
|
-
var import_debug = __toESM(require("debug"), 1);
|
|
56
|
-
var debug = (0, import_debug.default)("sphereon:ssi-sdk:uni-resolver-registrar");
|
|
57
|
-
function createDidEndpoint(router, context, opts) {
|
|
58
|
-
if (opts?.enabled === false) {
|
|
59
|
-
console.log(`create DID endpoint is disabled`);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const path = opts?.path ?? "/identifiers";
|
|
63
|
-
router.post(path, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
64
|
-
try {
|
|
65
|
-
const createRequest = request.body;
|
|
66
|
-
if (!createRequest) {
|
|
67
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "No DID create request present");
|
|
68
|
-
}
|
|
69
|
-
const did = createRequest.did;
|
|
70
|
-
const didMethod = request.query.method ?? (did ? (0, import_ssi_types.parseDid)(did).method : opts?.defaultMethod);
|
|
71
|
-
const allDidMethods = await (0, import_ssi_sdk_ext.getAgentDIDMethods)(context);
|
|
72
|
-
if (!didMethod) {
|
|
73
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "No DID method supplied or deductible");
|
|
74
|
-
} else if (did && (0, import_ssi_types.parseDid)(did).method != didMethod) {
|
|
75
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "DID method did not match method param");
|
|
76
|
-
} else if (!allDidMethods.includes(didMethod)) {
|
|
77
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "DID method not supported");
|
|
78
|
-
}
|
|
79
|
-
const provider = `did:${didMethod}`;
|
|
80
|
-
const jobId = createRequest.jobId ?? (0, import_uuid.v4)();
|
|
81
|
-
let alias = void 0;
|
|
82
|
-
if (didMethod === "web") {
|
|
83
|
-
if (!did) {
|
|
84
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 400, 'Please provide a value for "did" in the request body when creating a DID web');
|
|
85
|
-
}
|
|
86
|
-
alias = (0, import_ssi_types.parseDid)(did).id;
|
|
87
|
-
if (!alias) {
|
|
88
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "Could not determine alias from did:web DID value: " + did);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
let identifier;
|
|
92
|
-
let state;
|
|
93
|
-
if (opts?.noErrorOnExistingDid && did) {
|
|
94
|
-
try {
|
|
95
|
-
identifier = await context.agent.didManagerGet({
|
|
96
|
-
did
|
|
97
|
-
});
|
|
98
|
-
state = "exists";
|
|
99
|
-
} catch (e) {
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (identifier === void 0) {
|
|
103
|
-
if (createRequest.options.storeSecrets === false) {
|
|
104
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "Only storeSecrets mode is supported currently");
|
|
105
|
-
} else if (createRequest.options.storeSecrets || opts?.storeSecrets) {
|
|
106
|
-
identifier = await context.agent.didManagerCreate({
|
|
107
|
-
provider,
|
|
108
|
-
alias,
|
|
109
|
-
kms: opts?.kms
|
|
110
|
-
});
|
|
111
|
-
state = "finished";
|
|
112
|
-
} else {
|
|
113
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "Only storeSecrets mode is supported currently");
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (!identifier || !state) {
|
|
117
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "An identifier and did state should be present at this point");
|
|
118
|
-
}
|
|
119
|
-
const didDocument = (0, import_ssi_sdk_ext.toDidDocument)(identifier, {
|
|
120
|
-
did,
|
|
121
|
-
use: [
|
|
122
|
-
import_ssi_sdk_ext2.JwkKeyUse.Signature,
|
|
123
|
-
import_ssi_sdk_ext2.JwkKeyUse.Encryption
|
|
124
|
-
]
|
|
125
|
-
});
|
|
126
|
-
const createState = {
|
|
127
|
-
jobId,
|
|
128
|
-
didState: {
|
|
129
|
-
did: identifier.did,
|
|
130
|
-
state,
|
|
131
|
-
didDocument
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
response.statusCode = 200;
|
|
135
|
-
return response.send(createState);
|
|
136
|
-
} catch (e) {
|
|
137
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, e.message, e);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
__name(createDidEndpoint, "createDidEndpoint");
|
|
142
|
-
function getDidMethodsEndpoint(router, context, opts) {
|
|
143
|
-
if (opts?.enabled === false) {
|
|
144
|
-
console.log(`Get DID methods endpoint is disabled`);
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const path = opts?.path ?? "/methods";
|
|
148
|
-
router.get(path, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
149
|
-
try {
|
|
150
|
-
const methods = await (0, import_ssi_sdk_ext.getAgentDIDMethods)(context);
|
|
151
|
-
response.statusCode = 200;
|
|
152
|
-
return response.send(methods);
|
|
153
|
-
} catch (e) {
|
|
154
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, e.message, e);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
__name(getDidMethodsEndpoint, "getDidMethodsEndpoint");
|
|
159
|
-
async function agentDidToResolutionResult(context, did) {
|
|
160
|
-
try {
|
|
161
|
-
const identifier = await context.agent.didManagerGet({
|
|
162
|
-
did
|
|
163
|
-
});
|
|
164
|
-
debug(JSON.stringify(identifier, null, 2));
|
|
165
|
-
return (0, import_ssi_sdk_ext.toDidResolutionResult)(identifier, {
|
|
166
|
-
did,
|
|
167
|
-
supportedMethods: await (0, import_ssi_sdk_ext.getAgentDIDMethods)(context)
|
|
168
|
-
});
|
|
169
|
-
} catch (error) {
|
|
170
|
-
console.log(JSON.stringify(error.message));
|
|
171
|
-
return {
|
|
172
|
-
didDocument: null,
|
|
173
|
-
didResolutionMetadata: {
|
|
174
|
-
error: "notFound"
|
|
175
|
-
},
|
|
176
|
-
didDocumentMetadata: {}
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
__name(agentDidToResolutionResult, "agentDidToResolutionResult");
|
|
181
|
-
function resolveDidEndpoint(router, context, opts) {
|
|
182
|
-
if (opts?.enabled === false) {
|
|
183
|
-
console.log(`Resolve DID endpoint is disabled`);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
const path = opts?.path ?? "/identifiers/:identifier";
|
|
187
|
-
router.get(path, (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
188
|
-
try {
|
|
189
|
-
const did = request.params.identifier;
|
|
190
|
-
if (!did) {
|
|
191
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "no identifier provided");
|
|
192
|
-
}
|
|
193
|
-
const mode = request.query.mode?.toString().toLowerCase() ?? opts?.mode?.toLowerCase() ?? "hybrid";
|
|
194
|
-
let resolutionResult;
|
|
195
|
-
if (mode === "local" || mode === "hybrid") {
|
|
196
|
-
resolutionResult = await agentDidToResolutionResult(context, did);
|
|
197
|
-
}
|
|
198
|
-
if (mode !== "local" && !resolutionResult?.didDocument) {
|
|
199
|
-
resolutionResult = await context.agent.resolveDid({
|
|
200
|
-
didUrl: did
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
response.statusCode = 200;
|
|
204
|
-
return response.send(resolutionResult);
|
|
205
|
-
} catch (e) {
|
|
206
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, e.message, e);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
__name(resolveDidEndpoint, "resolveDidEndpoint");
|
|
211
|
-
function deleteDidEndpoint(router, context, opts) {
|
|
212
|
-
if (opts?.enabled === false) {
|
|
213
|
-
console.log(`Deactivate DID endpoint is disabled`);
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
router.delete(opts?.path ?? "/identifiers/:identifier", (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
217
|
-
try {
|
|
218
|
-
const did = request.params.identifier;
|
|
219
|
-
if (!did) {
|
|
220
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "no DID provided");
|
|
221
|
-
}
|
|
222
|
-
const result = await context.agent.didManagerDelete({
|
|
223
|
-
did
|
|
224
|
-
});
|
|
225
|
-
if (!result) {
|
|
226
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 404, `id ${did} not found`);
|
|
227
|
-
}
|
|
228
|
-
response.statusCode = 200;
|
|
229
|
-
return response.send();
|
|
230
|
-
} catch (e) {
|
|
231
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, e.message, e);
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
__name(deleteDidEndpoint, "deleteDidEndpoint");
|
|
236
|
-
function deactivateDidEndpoint(router, context, opts) {
|
|
237
|
-
if (opts?.enabled === false) {
|
|
238
|
-
console.log("Deactivate DID endpoint is disabled");
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
router.post(opts?.path ?? "/deactivate", (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
242
|
-
try {
|
|
243
|
-
const deactivateRequest = request.body;
|
|
244
|
-
if (!deactivateRequest) {
|
|
245
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "Invalid request body", {
|
|
246
|
-
state: "failed"
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
const { did, jobId = (0, import_uuid.v4)() } = deactivateRequest;
|
|
250
|
-
if (!did) {
|
|
251
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 400, "No DID provided", {
|
|
252
|
-
state: "failed"
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
const result = await context.agent.didManagerDelete({
|
|
256
|
-
did
|
|
257
|
-
});
|
|
258
|
-
if (!result) {
|
|
259
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 404, `DID ${did} not found`, {
|
|
260
|
-
state: "failed"
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
response.status(200).json({
|
|
264
|
-
state: "finished",
|
|
265
|
-
did,
|
|
266
|
-
jobId
|
|
267
|
-
});
|
|
268
|
-
return response.send();
|
|
269
|
-
} catch (e) {
|
|
270
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, e.message, {
|
|
271
|
-
state: "failed",
|
|
272
|
-
errorDetails: e
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
__name(deactivateDidEndpoint, "deactivateDidEndpoint");
|
|
278
|
-
function didWebDomainEndpoint(router, context, opts) {
|
|
279
|
-
if (opts?.enabled === false) {
|
|
280
|
-
console.log(`DID Web domain resolution endpoint is disabled`);
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
router.get(opts?.path ?? ":path(*)/did.json", (0, import_ssi_express_support.checkAuth)(opts?.endpoint), async (request, response) => {
|
|
284
|
-
try {
|
|
285
|
-
const path = request.params.path;
|
|
286
|
-
if (!path || path.length === 0) {
|
|
287
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 404, "Not found");
|
|
288
|
-
}
|
|
289
|
-
let did;
|
|
290
|
-
did = `did:web:${opts?.hostname?.replace("https://", "")?.replace("http://", "") ?? request.hostname}`;
|
|
291
|
-
if (path !== "/.well-known") {
|
|
292
|
-
if (opts?.disableSubPaths) {
|
|
293
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 404, "Not found");
|
|
294
|
-
}
|
|
295
|
-
const suffix = path.replace(/\//g, ":").replace(/%2F/g, ":");
|
|
296
|
-
if (!suffix.startsWith(":")) {
|
|
297
|
-
did += ":";
|
|
298
|
-
}
|
|
299
|
-
did += suffix;
|
|
300
|
-
} else if (opts?.disableWellKnown) {
|
|
301
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 404, "Not found");
|
|
302
|
-
}
|
|
303
|
-
const resolutionResult = await agentDidToResolutionResult(context, did);
|
|
304
|
-
if (!resolutionResult || !resolutionResult.didDocument || resolutionResult?.didResolutionMetadata?.error === "notFound") {
|
|
305
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 404, "Not found");
|
|
306
|
-
}
|
|
307
|
-
response.statusCode = 200;
|
|
308
|
-
return response.send(resolutionResult.didDocument);
|
|
309
|
-
} catch (e) {
|
|
310
|
-
return (0, import_ssi_express_support.sendErrorResponse)(response, 500, e.message, e);
|
|
311
|
-
}
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
__name(didWebDomainEndpoint, "didWebDomainEndpoint");
|
|
315
|
-
|
|
316
|
-
// src/uni-resolver-api-server.ts
|
|
317
|
-
var UniResolverApiServer = class {
|
|
318
|
-
static {
|
|
319
|
-
__name(this, "UniResolverApiServer");
|
|
320
|
-
}
|
|
321
|
-
get router() {
|
|
322
|
-
return this._router;
|
|
323
|
-
}
|
|
324
|
-
_express;
|
|
325
|
-
_agent;
|
|
326
|
-
_opts;
|
|
327
|
-
_router;
|
|
328
|
-
constructor(args) {
|
|
329
|
-
const { agent, opts } = args;
|
|
330
|
-
this._agent = agent;
|
|
331
|
-
(0, import_ssi_express_support2.copyGlobalAuthToEndpoints)({
|
|
332
|
-
opts,
|
|
333
|
-
keys: [
|
|
334
|
-
"getDidMethods",
|
|
335
|
-
"createDid",
|
|
336
|
-
"resolveDid",
|
|
337
|
-
"deactivateDid"
|
|
338
|
-
]
|
|
339
|
-
});
|
|
340
|
-
this._opts = opts;
|
|
341
|
-
this._express = args.expressSupport.express;
|
|
342
|
-
this._router = import_express.default.Router();
|
|
343
|
-
const context = (0, import_ssi_sdk.agentContext)(agent);
|
|
344
|
-
const features = opts?.enableFeatures ?? [
|
|
345
|
-
"did-resolve",
|
|
346
|
-
"did-persist"
|
|
347
|
-
];
|
|
348
|
-
console.log(`DID Uni Resolver and Registrar API enabled, with features: ${JSON.stringify(features)}}`);
|
|
349
|
-
if (features.includes("did-resolve")) {
|
|
350
|
-
resolveDidEndpoint(this.router, context, opts?.endpointOpts?.resolveDid);
|
|
351
|
-
getDidMethodsEndpoint(this.router, context, opts?.endpointOpts?.getDidMethods);
|
|
352
|
-
}
|
|
353
|
-
if (features.includes("did-persist")) {
|
|
354
|
-
createDidEndpoint(this.router, context, opts?.endpointOpts?.createDid);
|
|
355
|
-
deleteDidEndpoint(this.router, context, opts?.endpointOpts?.deactivateDid);
|
|
356
|
-
deactivateDidEndpoint(this.router, context, opts?.endpointOpts?.deactivateDid);
|
|
357
|
-
}
|
|
358
|
-
this._express.use(opts?.endpointOpts?.basePath ?? "", this.router);
|
|
359
|
-
}
|
|
360
|
-
get agent() {
|
|
361
|
-
return this._agent;
|
|
362
|
-
}
|
|
363
|
-
get opts() {
|
|
364
|
-
return this._opts;
|
|
365
|
-
}
|
|
366
|
-
get express() {
|
|
367
|
-
return this._express;
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/uni-resolver-api-server.ts","../src/api-functions.ts"],"sourcesContent":["/**\n * @public\n */\nexport * from './uni-resolver-api-server'\nexport * from './types'\nexport * from './api-functions'\n","import { agentContext } from '@sphereon/ssi-sdk.core'\nimport { copyGlobalAuthToEndpoints, ExpressSupport } from '@sphereon/ssi-express-support'\nimport { TAgent } from '@veramo/core'\n\nimport express, { Express, Router } from 'express'\nimport { createDidEndpoint, deleteDidEndpoint, deactivateDidEndpoint, getDidMethodsEndpoint, resolveDidEndpoint } from './api-functions'\nimport { IDidAPIOpts, IRequiredPlugins } from './types'\n\nexport class UniResolverApiServer {\n get router(): express.Router {\n return this._router\n }\n\n private readonly _express: Express\n private readonly _agent: TAgent<IRequiredPlugins>\n private readonly _opts?: IDidAPIOpts\n private readonly _router: Router\n\n constructor(args: { agent: TAgent<IRequiredPlugins>; expressSupport: ExpressSupport; opts?: IDidAPIOpts }) {\n const { agent, opts } = args\n this._agent = agent\n copyGlobalAuthToEndpoints({ opts, keys: ['getDidMethods', 'createDid', 'resolveDid', 'deactivateDid'] })\n this._opts = opts\n this._express = args.expressSupport.express\n this._router = express.Router()\n const context = agentContext(agent)\n const features = opts?.enableFeatures ?? ['did-resolve', 'did-persist']\n console.log(`DID Uni Resolver and Registrar API enabled, with features: ${JSON.stringify(features)}}`)\n\n // DID endpoints\n if (features.includes('did-resolve')) {\n resolveDidEndpoint(this.router, context, opts?.endpointOpts?.resolveDid)\n getDidMethodsEndpoint(this.router, context, opts?.endpointOpts?.getDidMethods)\n }\n if (features.includes('did-persist')) {\n createDidEndpoint(this.router, context, opts?.endpointOpts?.createDid)\n deleteDidEndpoint(this.router, context, opts?.endpointOpts?.deactivateDid) // not in spec.\n deactivateDidEndpoint(this.router, context, opts?.endpointOpts?.deactivateDid)\n }\n this._express.use(opts?.endpointOpts?.basePath ?? '', this.router)\n }\n\n get agent(): TAgent<IRequiredPlugins> {\n return this._agent\n }\n\n get opts(): IDidAPIOpts | undefined {\n return this._opts\n }\n\n get express(): Express {\n return this._express\n }\n}\n","import { DIDResolutionResult } from '@sphereon/did-uni-client'\nimport { getAgentDIDMethods, toDidDocument, toDidResolutionResult } from '@sphereon/ssi-sdk-ext.did-utils'\nimport { JwkKeyUse } from '@sphereon/ssi-sdk-ext.key-utils'\nimport { checkAuth, ISingleEndpointOpts, sendErrorResponse } from '@sphereon/ssi-express-support'\nimport { parseDid } from '@sphereon/ssi-types'\nimport { IIdentifier } from '@veramo/core'\nimport { Request, Response, Router } from 'express'\nimport { v4 } from 'uuid'\nimport {\n CreateState,\n DidRegistrationCreateRequest,\n DidRegistrationDeactivateRequest,\n DidStateValue,\n ICreateDidEndpointOpts,\n IGlobalDidWebEndpointOpts,\n IRequiredContext,\n IResolveEndpointOpts,\n} from './types'\nimport Debug from 'debug'\n\nconst debug = Debug('sphereon:ssi-sdk:uni-resolver-registrar')\n\nexport function createDidEndpoint(router: Router, context: IRequiredContext, opts?: ICreateDidEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`create DID endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/identifiers'\n\n router.post(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const createRequest: DidRegistrationCreateRequest = request.body\n if (!createRequest) {\n return sendErrorResponse(response, 400, 'No DID create request present')\n }\n const did = createRequest.did\n const didMethod = (request.query.method as string) ?? (did ? parseDid(did).method : opts?.defaultMethod)\n const allDidMethods = await getAgentDIDMethods(context)\n if (!didMethod) {\n return sendErrorResponse(response, 400, 'No DID method supplied or deductible')\n } else if (did && parseDid(did).method != didMethod) {\n return sendErrorResponse(response, 400, 'DID method did not match method param')\n } else if (!allDidMethods.includes(didMethod)) {\n return sendErrorResponse(response, 400, 'DID method not supported')\n }\n const provider = `did:${didMethod}`\n const jobId = createRequest.jobId ?? v4()\n let alias: string | undefined = undefined\n if (didMethod === 'web') {\n if (!did) {\n return sendErrorResponse(response, 400, 'Please provide a value for \"did\" in the request body when creating a DID web')\n }\n alias = parseDid(did).id\n if (!alias) {\n return sendErrorResponse(response, 400, 'Could not determine alias from did:web DID value: ' + did)\n }\n }\n\n let identifier: IIdentifier | undefined\n let state: DidStateValue | undefined\n if (opts?.noErrorOnExistingDid && did) {\n try {\n identifier = await context.agent.didManagerGet({ did })\n state = 'exists'\n } catch (e) {\n // Okay, since we will create a new one\n }\n }\n if (identifier === undefined) {\n if (createRequest.options.storeSecrets === false) {\n return sendErrorResponse(response, 400, 'Only storeSecrets mode is supported currently')\n /*const memoryKMS = new SphereonKeyManager({\n store: new MemoryKeyStore(),\n kms: {'mem': new KeyManagementSystem(new MemoryPrivateKeyStore())}\n })\n identifier = await memoryKMS..didManagerCreate({provider, alias, kms: opts?.kms})*/\n } else if (createRequest.options.storeSecrets || opts?.storeSecrets) {\n identifier = await context.agent.didManagerCreate({ provider, alias, kms: opts?.kms })\n state = 'finished'\n } else {\n return sendErrorResponse(response, 400, 'Only storeSecrets mode is supported currently')\n }\n }\n if (!identifier || !state) {\n return sendErrorResponse(response, 400, 'An identifier and did state should be present at this point')\n }\n\n const didDocument = toDidDocument(identifier, { did, use: [JwkKeyUse.Signature, JwkKeyUse.Encryption] })\n const createState: CreateState = {\n jobId,\n didState: {\n did: identifier.did,\n state,\n didDocument,\n },\n }\n response.statusCode = 200\n return response.send(createState)\n } catch (e) {\n return sendErrorResponse(response, 500, e.message as string, e)\n }\n })\n}\n\nexport function getDidMethodsEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`Get DID methods endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/methods'\n router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const methods = await getAgentDIDMethods(context) // these are already without the 'did:' prefix\n response.statusCode = 200\n return response.send(methods)\n } catch (e) {\n return sendErrorResponse(response, 500, e.message as string, e)\n }\n })\n}\n\nasync function agentDidToResolutionResult(context: IRequiredContext, did: string) {\n try {\n const identifier = await context.agent.didManagerGet({ did })\n debug(JSON.stringify(identifier, null, 2))\n return toDidResolutionResult(identifier, {\n did,\n supportedMethods: await getAgentDIDMethods(context),\n })\n } catch (error) {\n console.log(JSON.stringify(error.message))\n return {\n didDocument: null,\n didResolutionMetadata: {\n error: 'notFound',\n },\n didDocumentMetadata: {},\n }\n }\n}\n\nexport function resolveDidEndpoint(router: Router, context: IRequiredContext, opts?: IResolveEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`Resolve DID endpoint is disabled`)\n return\n }\n const path = opts?.path ?? '/identifiers/:identifier'\n router.get(path, checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const did = request.params.identifier\n if (!did) {\n return sendErrorResponse(response, 400, 'no identifier provided')\n }\n const mode = request.query.mode?.toString().toLowerCase() ?? opts?.mode?.toLowerCase() ?? 'hybrid'\n let resolutionResult: DIDResolutionResult | undefined\n if (mode === 'local' || mode === 'hybrid') {\n resolutionResult = await agentDidToResolutionResult(context, did)\n }\n if (mode !== 'local' && !resolutionResult?.didDocument) {\n resolutionResult = await context.agent.resolveDid({ didUrl: did })\n }\n\n response.statusCode = 200\n return response.send(resolutionResult)\n } catch (e) {\n return sendErrorResponse(response, 500, e.message as string, e)\n }\n })\n}\n\n/**\n * @param router\n * @param context\n * @param opts\n */\nexport function deleteDidEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`Deactivate DID endpoint is disabled`)\n return\n }\n router.delete(opts?.path ?? '/identifiers/:identifier', checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const did = request.params.identifier\n if (!did) {\n return sendErrorResponse(response, 400, 'no DID provided')\n }\n\n const result = await context.agent.didManagerDelete({ did })\n if (!result) {\n return sendErrorResponse(response, 404, `id ${did} not found`)\n }\n response.statusCode = 200\n return response.send()\n } catch (e) {\n return sendErrorResponse(response, 500, e.message as string, e)\n }\n })\n}\n\nexport function deactivateDidEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts) {\n if (opts?.enabled === false) {\n console.log('Deactivate DID endpoint is disabled')\n return\n }\n\n router.post(opts?.path ?? '/deactivate', checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const deactivateRequest: DidRegistrationDeactivateRequest = request.body\n if (!deactivateRequest) {\n return sendErrorResponse(response, 400, 'Invalid request body', { state: 'failed' })\n }\n\n const { did, jobId = v4() } = deactivateRequest\n if (!did) {\n return sendErrorResponse(response, 400, 'No DID provided', { state: 'failed' })\n }\n\n const result = await context.agent.didManagerDelete({ did })\n if (!result) {\n return sendErrorResponse(response, 404, `DID ${did} not found`, { state: 'failed' })\n }\n\n response.status(200).json({\n state: 'finished',\n did,\n jobId,\n })\n return response.send()\n } catch (e) {\n return sendErrorResponse(response, 500, e.message as string, { state: 'failed', errorDetails: e })\n }\n })\n}\n\n/**\n * Endpoint that eases DID web resolution, by mapping did-web paths to stored agent DIDs.\n *\n * Typically, you will have a reverse proxy or load balancer in front of this endpoint.\n *\n * Some examples of how did:web behaves:\n * did:web:example.com resolves to https://example.com/.well-known/did.json\n * did:web:example.com:sub:paths resolves to https://example.com/sub/paths/did.json\n *\n * This endpoint translate both forms by looking at the paths that end in /did.json.\n *\n * @param router\n * @param context\n * @param opts\n */\nexport function didWebDomainEndpoint(router: Router, context: IRequiredContext, opts?: IGlobalDidWebEndpointOpts) {\n if (opts?.enabled === false) {\n console.log(`DID Web domain resolution endpoint is disabled`)\n return\n }\n router.get(opts?.path ?? ':path(*)/did.json', checkAuth(opts?.endpoint), async (request: Request, response: Response) => {\n try {\n const path = request.params.path\n if (!path || path.length === 0) {\n return sendErrorResponse(response, 404, 'Not found')\n }\n let did: string\n did = `did:web:${opts?.hostname?.replace('https://', '')?.replace('http://', '') ?? request.hostname}`\n if (path !== '/.well-known') {\n if (opts?.disableSubPaths) {\n return sendErrorResponse(response, 404, 'Not found')\n }\n const suffix = path.replace(/\\//g, ':').replace(/%2F/g, ':')\n if (!suffix.startsWith(':')) {\n did += ':'\n }\n did += suffix\n } else if (opts?.disableWellKnown) {\n return sendErrorResponse(response, 404, 'Not found')\n }\n\n const resolutionResult = await agentDidToResolutionResult(context, did)\n if (!resolutionResult || !resolutionResult.didDocument || resolutionResult?.didResolutionMetadata?.error === 'notFound') {\n return sendErrorResponse(response, 404, 'Not found')\n }\n response.statusCode = 200\n return response.send(resolutionResult.didDocument)\n } catch (e) {\n return sendErrorResponse(response, 500, e.message as string, e)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;ACAA,qBAA6B;AAC7B,IAAAA,8BAA0D;AAG1D,qBAAyC;;;ACHzC,yBAAyE;AACzE,IAAAC,sBAA0B;AAC1B,iCAAkE;AAClE,uBAAyB;AAGzB,kBAAmB;AAWnB,mBAAkB;AAElB,IAAMC,YAAQC,aAAAA,SAAM,yCAAA;AAEb,SAASC,kBAAkBC,QAAgBC,SAA2BC,MAA6B;AACxG,MAAIA,MAAMC,YAAY,OAAO;AAC3BC,YAAQC,IAAI,iCAAiC;AAC7C;EACF;AACA,QAAMC,OAAOJ,MAAMI,QAAQ;AAE3BN,SAAOO,KAAKD,UAAME,sCAAUN,MAAMO,QAAAA,GAAW,OAAOC,SAAkBC,aAAAA;AACpE,QAAI;AACF,YAAMC,gBAA8CF,QAAQG;AAC5D,UAAI,CAACD,eAAe;AAClB,mBAAOE,8CAAkBH,UAAU,KAAK,+BAAA;MAC1C;AACA,YAAMI,MAAMH,cAAcG;AAC1B,YAAMC,YAAaN,QAAQO,MAAMC,WAAsBH,UAAMI,2BAASJ,GAAAA,EAAKG,SAAShB,MAAMkB;AAC1F,YAAMC,gBAAgB,UAAMC,uCAAmBrB,OAAAA;AAC/C,UAAI,CAACe,WAAW;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AC/D;EACF,CAAA;AACF;AApCgB4C;;;ADjPT,IAAMQ,uBAAN,MAAMA;EARb,OAQaA;;;EACX,IAAIC,SAAyB;AAC3B,WAAO,KAAKC;EACd;EAEiBC;EACAC;EACAC;EACAH;EAEjBI,YAAYC,MAA+F;AACzG,UAAM,EAAEC,OAAOC,KAAI,IAAKF;AACxB,SAAKH,SAASI;AACdE,+DAA0B;MAAED;MAAME,MAAM;QAAC;QAAiB;QAAa;QAAc;;IAAiB,CAAA;AACtG,SAAKN,QAAQI;AACb,SAAKN,WAAWI,KAAKK,eAAeC;AACpC,SAAKX,UAAUW,eAAAA,QAAQC,OAAM;AAC7B,UAAMC,cAAUC,6BAAaR,KAAAA;AAC7B,UAAMS,WAAWR,MAAMS,kBAAkB;MAAC;MAAe;;AACzDC,YAAQC,IAAI,8DAA8DC,KAAKC,UAAUL,QAAAA,CAAAA,GAAY;AAGrG,QAAIA,SAASM,SAAS,aAAA,GAAgB;AACpCC,yBAAmB,KAAKvB,QAAQc,SAASN,MAAMgB,cAAcC,UAAAA;AAC7DC,4BAAsB,KAAK1B,QAAQc,SAASN,MAAMgB,cAAcG,aAAAA;IAClE;AACA,QAAIX,SAASM,SAAS,aAAA,GAAgB;AACpCM,wBAAkB,KAAK5B,QAAQc,SAASN,MAAMgB,cAAcK,SAAAA;AAC5DC,wBAAkB,KAAK9B,QAAQc,SAASN,MAAMgB,cAAcO,aAAAA;AAC5DC,4BAAsB,KAAKhC,QAAQc,SAASN,MAAMgB,cAAcO,aAAAA;IAClE;AACA,SAAK7B,SAAS+B,IAAIzB,MAAMgB,cAAcU,YAAY,IAAI,KAAKlC,MAAM;EACnE;EAEA,IAAIO,QAAkC;AACpC,WAAO,KAAKJ;EACd;EAEA,IAAIK,OAAgC;AAClC,WAAO,KAAKJ;EACd;EAEA,IAAIQ,UAAmB;AACrB,WAAO,KAAKV;EACd;AACF;","names":["import_ssi_express_support","import_ssi_sdk_ext","debug","Debug","createDidEndpoint","router","context","opts","enabled","console","log","path","post","checkAuth","endpoint","request","response","createRequest","body","sendErrorResponse","did","didMethod","query","method","parseDid","defaultMethod","allDidMethods","getAgentDIDMethods","includes","provider","jobId","v4","alias","undefined","id","identifier","state","noErrorOnExistingDid","agent","didManagerGet","e","options","storeSecrets","didManagerCreate","kms","didDocument","toDidDocument","use","JwkKeyUse","Signature","Encryption","createState","didState","statusCode","send","message","getDidMethodsEndpoint","get","methods","agentDidToResolutionResult","JSON","stringify","toDidResolutionResult","supportedMethods","error","didResolutionMetadata","didDocumentMetadata","resolveDidEndpoint","params","mode","toString","toLowerCase","resolutionResult","resolveDid","didUrl","deleteDidEndpoint","delete","result","didManagerDelete","deactivateDidEndpoint","deactivateRequest","status","json","errorDetails","didWebDomainEndpoint","length","hostname","replace","disableSubPaths","suffix","startsWith","disableWellKnown","UniResolverApiServer","router","_router","_express","_agent","_opts","constructor","args","agent","opts","copyGlobalAuthToEndpoints","keys","expressSupport","express","Router","context","agentContext","features","enableFeatures","console","log","JSON","stringify","includes","resolveDidEndpoint","endpointOpts","resolveDid","getDidMethodsEndpoint","getDidMethods","createDidEndpoint","createDid","deleteDidEndpoint","deactivateDid","deactivateDidEndpoint","use","basePath"]}
|
package/dist/index.d.cts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { GenericAuthArgs, ISingleEndpointOpts, ExpressSupport } from '@sphereon/ssi-express-support';
|
|
2
|
-
import { IDataStoreORM, IDIDManager, IKeyManager, IResolver, IAgentContext, TAgent } from '@veramo/core';
|
|
3
|
-
import express, { Express, Router } from 'express';
|
|
4
|
-
import { DIDDocument } from '@sphereon/did-uni-client';
|
|
5
|
-
import { JsonWebKey } from '@sphereon/ssi-types';
|
|
6
|
-
import { VerificationMethod } from 'did-resolver';
|
|
7
|
-
|
|
8
|
-
type IRequiredPlugins = IDataStoreORM & IDIDManager & IKeyManager & IResolver;
|
|
9
|
-
type IRequiredContext = IAgentContext<IRequiredPlugins>;
|
|
10
|
-
interface DidRegistrationCreateRequest {
|
|
11
|
-
did?: string;
|
|
12
|
-
jobId: string;
|
|
13
|
-
options: DidRegistrationOptions;
|
|
14
|
-
secret: DidRegistrationSecret;
|
|
15
|
-
didDocument?: DIDDocument;
|
|
16
|
-
}
|
|
17
|
-
interface DidRegistrationUpdateRequest {
|
|
18
|
-
did: string;
|
|
19
|
-
jobId: string;
|
|
20
|
-
options: DidRegistrationOptions;
|
|
21
|
-
secret: DidRegistrationSecret;
|
|
22
|
-
didDocumentOperation: DidDocumentOperation[];
|
|
23
|
-
didDocument?: DIDDocument[];
|
|
24
|
-
}
|
|
25
|
-
interface DidRegistrationDeactivateRequest {
|
|
26
|
-
did: string;
|
|
27
|
-
jobId?: string;
|
|
28
|
-
options?: DidRegistrationOptions;
|
|
29
|
-
secret?: DidRegistrationSecret;
|
|
30
|
-
}
|
|
31
|
-
type DidDocumentOperation = 'setDidDocument' | 'addToDidDocument' | 'removeFromDidDocument' | string;
|
|
32
|
-
interface DidRegistrationOptions {
|
|
33
|
-
network?: string;
|
|
34
|
-
storeSecrets?: boolean;
|
|
35
|
-
returnSecrets?: boolean;
|
|
36
|
-
[x: string]: any;
|
|
37
|
-
}
|
|
38
|
-
interface DidRegistrationSecret {
|
|
39
|
-
seed?: string;
|
|
40
|
-
verificationMethod?: CreateVerificationMethod[];
|
|
41
|
-
[x: string]: any;
|
|
42
|
-
}
|
|
43
|
-
interface CreateVerificationMethod extends VerificationMethod {
|
|
44
|
-
privateKeyBase58?: string;
|
|
45
|
-
privateKeyBase64?: string;
|
|
46
|
-
privateKeyJwk?: JsonWebKey;
|
|
47
|
-
privateKeyHex?: string;
|
|
48
|
-
privateKeyMultibase?: string;
|
|
49
|
-
purpose?: ('authentication' | 'assertionMethod' | 'capabilityDelegation' | 'capabilityInvocation')[];
|
|
50
|
-
}
|
|
51
|
-
interface CreateState {
|
|
52
|
-
jobId: string;
|
|
53
|
-
didState: DidState;
|
|
54
|
-
didRegistrationMetadata?: Record<string, any>;
|
|
55
|
-
didDocumentMetadata?: Record<string, any>;
|
|
56
|
-
}
|
|
57
|
-
type DidStateValue = 'finished' | 'failed' | 'action' | 'wait' | 'exists';
|
|
58
|
-
type DidStateAction = 'redirect' | 'getVerificationMethod' | 'signPayload' | 'decryptPayload';
|
|
59
|
-
interface DidState {
|
|
60
|
-
state: DidStateValue;
|
|
61
|
-
action?: DidStateAction;
|
|
62
|
-
wait?: string;
|
|
63
|
-
waitTime?: number;
|
|
64
|
-
did: string;
|
|
65
|
-
secret?: DidRegistrationSecret;
|
|
66
|
-
didDocument?: DIDDocument;
|
|
67
|
-
}
|
|
68
|
-
interface IDidWebServiceOpts {
|
|
69
|
-
globalAuth?: GenericAuthArgs;
|
|
70
|
-
endpointOpts?: IGlobalDidWebEndpointOpts;
|
|
71
|
-
enableFeatures?: DidWebServiceFeatures[];
|
|
72
|
-
}
|
|
73
|
-
interface IDidAPIOpts {
|
|
74
|
-
endpointOpts?: IDidAPIEndpointOpts;
|
|
75
|
-
enableFeatures?: DidApiFeatures[];
|
|
76
|
-
}
|
|
77
|
-
interface IDidAPIEndpointOpts {
|
|
78
|
-
basePath?: string;
|
|
79
|
-
globalAuth?: GenericAuthArgs;
|
|
80
|
-
createDid?: ICreateDidEndpointOpts;
|
|
81
|
-
resolveDid?: IResolveEndpointOpts;
|
|
82
|
-
deactivateDid?: ISingleEndpointOpts;
|
|
83
|
-
getDidMethods?: ISingleEndpointOpts;
|
|
84
|
-
}
|
|
85
|
-
interface IGlobalDidWebEndpointOpts extends ISingleEndpointOpts {
|
|
86
|
-
hostname?: string;
|
|
87
|
-
disableWellKnown?: boolean;
|
|
88
|
-
disableSubPaths?: boolean;
|
|
89
|
-
}
|
|
90
|
-
interface ICreateDidEndpointOpts extends ISingleEndpointOpts {
|
|
91
|
-
kms?: string;
|
|
92
|
-
storeSecrets?: boolean;
|
|
93
|
-
noErrorOnExistingDid?: boolean;
|
|
94
|
-
defaultMethod?: string;
|
|
95
|
-
}
|
|
96
|
-
interface IResolveEndpointOpts extends ISingleEndpointOpts {
|
|
97
|
-
mode?: 'local' | 'hybrid' | 'global';
|
|
98
|
-
}
|
|
99
|
-
type DidWebServiceFeatures = 'did-web-global-resolution';
|
|
100
|
-
type DidApiFeatures = 'did-resolve' | 'did-persist';
|
|
101
|
-
|
|
102
|
-
declare class UniResolverApiServer {
|
|
103
|
-
get router(): express.Router;
|
|
104
|
-
private readonly _express;
|
|
105
|
-
private readonly _agent;
|
|
106
|
-
private readonly _opts?;
|
|
107
|
-
private readonly _router;
|
|
108
|
-
constructor(args: {
|
|
109
|
-
agent: TAgent<IRequiredPlugins>;
|
|
110
|
-
expressSupport: ExpressSupport;
|
|
111
|
-
opts?: IDidAPIOpts;
|
|
112
|
-
});
|
|
113
|
-
get agent(): TAgent<IRequiredPlugins>;
|
|
114
|
-
get opts(): IDidAPIOpts | undefined;
|
|
115
|
-
get express(): Express;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
declare function createDidEndpoint(router: Router, context: IRequiredContext, opts?: ICreateDidEndpointOpts): void;
|
|
119
|
-
declare function getDidMethodsEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
120
|
-
declare function resolveDidEndpoint(router: Router, context: IRequiredContext, opts?: IResolveEndpointOpts): void;
|
|
121
|
-
/**
|
|
122
|
-
* @param router
|
|
123
|
-
* @param context
|
|
124
|
-
* @param opts
|
|
125
|
-
*/
|
|
126
|
-
declare function deleteDidEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
127
|
-
declare function deactivateDidEndpoint(router: Router, context: IRequiredContext, opts?: ISingleEndpointOpts): void;
|
|
128
|
-
/**
|
|
129
|
-
* Endpoint that eases DID web resolution, by mapping did-web paths to stored agent DIDs.
|
|
130
|
-
*
|
|
131
|
-
* Typically, you will have a reverse proxy or load balancer in front of this endpoint.
|
|
132
|
-
*
|
|
133
|
-
* Some examples of how did:web behaves:
|
|
134
|
-
* did:web:example.com resolves to https://example.com/.well-known/did.json
|
|
135
|
-
* did:web:example.com:sub:paths resolves to https://example.com/sub/paths/did.json
|
|
136
|
-
*
|
|
137
|
-
* This endpoint translate both forms by looking at the paths that end in /did.json.
|
|
138
|
-
*
|
|
139
|
-
* @param router
|
|
140
|
-
* @param context
|
|
141
|
-
* @param opts
|
|
142
|
-
*/
|
|
143
|
-
declare function didWebDomainEndpoint(router: Router, context: IRequiredContext, opts?: IGlobalDidWebEndpointOpts): void;
|
|
144
|
-
|
|
145
|
-
export { type CreateState, type CreateVerificationMethod, type DidApiFeatures, type DidDocumentOperation, type DidRegistrationCreateRequest, type DidRegistrationDeactivateRequest, type DidRegistrationOptions, type DidRegistrationSecret, type DidRegistrationUpdateRequest, type DidState, type DidStateAction, type DidStateValue, type DidWebServiceFeatures, type ICreateDidEndpointOpts, type IDidAPIEndpointOpts, type IDidAPIOpts, type IDidWebServiceOpts, type IGlobalDidWebEndpointOpts, type IRequiredContext, type IRequiredPlugins, type IResolveEndpointOpts, UniResolverApiServer, createDidEndpoint, deactivateDidEndpoint, deleteDidEndpoint, didWebDomainEndpoint, getDidMethodsEndpoint, resolveDidEndpoint };
|