Comparing version 0.10.0 to 0.10.3
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
import { DIDDocument } from 'did-resolver'; | ||
import { IdentityManager, IdentityController } from './identity-manager'; | ||
import { ServiceControllerWithConfig, LastMessageTimestamp } from './service-manager'; | ||
import { MessageValidator } from './message-validator'; | ||
import { ActionHandler } from './action-handler'; | ||
import { IdentityManager, IdentityController } from './identity/identity-manager'; | ||
import { LastMessageTimestampForInstance } from './service/service-manager'; | ||
import { ServiceControllerDerived } from './service/abstract-service-controller'; | ||
import { MessageValidator } from './message/message-validator'; | ||
import { ActionHandler } from './action/action-handler'; | ||
import { Action } from './types'; | ||
import { EncryptionKeyManager } from './encryption-manager'; | ||
import { Message } from './message'; | ||
import { Message } from './message/message'; | ||
export declare const EventTypes: { | ||
@@ -21,3 +22,3 @@ validatedMessage: string; | ||
identityControllers: IdentityController[]; | ||
serviceControllersWithConfig: ServiceControllerWithConfig[]; | ||
serviceControllers: ServiceControllerDerived[]; | ||
messageValidator: MessageValidator; | ||
@@ -35,4 +36,6 @@ actionHandler?: ActionHandler; | ||
constructor(config: Config); | ||
startServices(): Promise<void>; | ||
syncServices(lastMessageTimestamps: LastMessageTimestamp[]): Promise<void>; | ||
setupServices(): Promise<void>; | ||
listen(): Promise<void>; | ||
getMessagesSince(ts: LastMessageTimestampForInstance[]): Promise<Message[]>; | ||
validateMessages(messages: Message[]): Promise<Message[]>; | ||
validateMessage(message: Message): Promise<Message>; | ||
@@ -39,0 +42,0 @@ handleAction(action: Action): Promise<any>; |
@@ -51,2 +51,13 @@ "use strict"; | ||
}; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -57,6 +68,6 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var events_1 = require("events"); | ||
var identity_manager_1 = require("./identity-manager"); | ||
var service_manager_1 = require("./service-manager"); | ||
var identity_manager_1 = require("./identity/identity-manager"); | ||
var service_manager_1 = require("./service/service-manager"); | ||
var debug_1 = __importDefault(require("debug")); | ||
var debug = debug_1.default('core'); | ||
var debug = debug_1.default('daf:core'); | ||
exports.EventTypes = { | ||
@@ -76,4 +87,3 @@ validatedMessage: 'validatedMessage', | ||
_this.serviceManager = new service_manager_1.ServiceManager({ | ||
serviceControllersWithConfig: config.serviceControllersWithConfig, | ||
validateMessage: _this.validateMessage.bind(_this), | ||
controllers: config.serviceControllers, | ||
didResolver: _this.didResolver, | ||
@@ -85,3 +95,3 @@ }); | ||
} | ||
Core.prototype.startServices = function () { | ||
Core.prototype.setupServices = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -94,8 +104,5 @@ var issuers; | ||
issuers = _a.sent(); | ||
return [4 /*yield*/, this.serviceManager.configureServices(issuers)]; | ||
return [4 /*yield*/, this.serviceManager.setupServices(issuers)]; | ||
case 2: | ||
_a.sent(); | ||
return [4 /*yield*/, this.serviceManager.initServices()]; | ||
case 3: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
@@ -106,10 +113,21 @@ } | ||
}; | ||
Core.prototype.syncServices = function (lastMessageTimestamps) { | ||
Core.prototype.listen = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
debug('Listening for new messages'); | ||
this.serviceManager.on(service_manager_1.ServiceEventTypes.NewMessages, this.validateMessages.bind(this)); | ||
this.serviceManager.listen(); | ||
return [2 /*return*/]; | ||
}); | ||
}); | ||
}; | ||
Core.prototype.getMessagesSince = function (ts) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var rawMessages; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.serviceManager.syncServices(lastMessageTimestamps)]; | ||
case 0: return [4 /*yield*/, this.serviceManager.getMessagesSince(ts)]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
rawMessages = _a.sent(); | ||
return [2 /*return*/, this.validateMessages(rawMessages)]; | ||
} | ||
@@ -119,2 +137,48 @@ }); | ||
}; | ||
Core.prototype.validateMessages = function (messages) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var result, messages_1, messages_1_1, message, validMessage, e_1, e_2_1; | ||
var e_2, _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
result = []; | ||
_b.label = 1; | ||
case 1: | ||
_b.trys.push([1, 8, 9, 10]); | ||
messages_1 = __values(messages), messages_1_1 = messages_1.next(); | ||
_b.label = 2; | ||
case 2: | ||
if (!!messages_1_1.done) return [3 /*break*/, 7]; | ||
message = messages_1_1.value; | ||
_b.label = 3; | ||
case 3: | ||
_b.trys.push([3, 5, , 6]); | ||
return [4 /*yield*/, this.validateMessage(message)]; | ||
case 4: | ||
validMessage = _b.sent(); | ||
result.push(validMessage); | ||
return [3 /*break*/, 6]; | ||
case 5: | ||
e_1 = _b.sent(); | ||
return [3 /*break*/, 6]; | ||
case 6: | ||
messages_1_1 = messages_1.next(); | ||
return [3 /*break*/, 2]; | ||
case 7: return [3 /*break*/, 10]; | ||
case 8: | ||
e_2_1 = _b.sent(); | ||
e_2 = { error: e_2_1 }; | ||
return [3 /*break*/, 10]; | ||
case 9: | ||
try { | ||
if (messages_1_1 && !messages_1_1.done && (_a = messages_1.return)) _a.call(messages_1); | ||
} | ||
finally { if (e_2) throw e_2.error; } | ||
return [7 /*endfinally*/]; | ||
case 10: return [2 /*return*/, result]; | ||
} | ||
}); | ||
}); | ||
}; | ||
Core.prototype.validateMessage = function (message) { | ||
@@ -121,0 +185,0 @@ return __awaiter(this, void 0, void 0, function () { |
export { Core, EventTypes, Resolver } from './core'; | ||
export { AbstractActionHandler } from './action-handler'; | ||
export { AbstractActionHandler } from './action/action-handler'; | ||
export { EncryptionKeyManager, KeyPair } from './encryption-manager'; | ||
export { IdentityController, IdentityManager, Issuer } from './identity-manager'; | ||
export { AbstractMessageValidator } from './message-validator'; | ||
export { Message } from './message'; | ||
export { ServiceController, ServiceControllerOptions, ServiceControllerWithConfig, ServiceInstanceId, } from './service-manager'; | ||
export { IdentityController, IdentityManager, Issuer } from './identity/identity-manager'; | ||
export { AbstractMessageValidator } from './message/message-validator'; | ||
export { Message } from './message/message'; | ||
export { ServiceManager, LastMessageTimestampForInstance, ServiceEventTypes } from './service/service-manager'; | ||
export { AbstractServiceController } from './service/abstract-service-controller'; | ||
import * as Types from './types'; | ||
import * as GqlCore from './graphql-core'; | ||
import * as GqlIdentityManager from './graphql-identity-manager'; | ||
import * as GqlCore from './graphql/graphql-core'; | ||
import * as GqlIdentityManager from './graphql/graphql-identity-manager'; | ||
declare const Gql: { | ||
@@ -12,0 +13,0 @@ baseTypeDefs: string; |
@@ -13,17 +13,20 @@ "use strict"; | ||
exports.EventTypes = core_1.EventTypes; | ||
var action_handler_1 = require("./action-handler"); | ||
var action_handler_1 = require("./action/action-handler"); | ||
exports.AbstractActionHandler = action_handler_1.AbstractActionHandler; | ||
var identity_manager_1 = require("./identity-manager"); | ||
var identity_manager_1 = require("./identity/identity-manager"); | ||
exports.IdentityManager = identity_manager_1.IdentityManager; | ||
var message_validator_1 = require("./message-validator"); | ||
var message_validator_1 = require("./message/message-validator"); | ||
exports.AbstractMessageValidator = message_validator_1.AbstractMessageValidator; | ||
var message_1 = require("./message"); | ||
var message_1 = require("./message/message"); | ||
exports.Message = message_1.Message; | ||
var service_manager_1 = require("./service-manager"); | ||
exports.ServiceController = service_manager_1.ServiceController; | ||
var service_manager_1 = require("./service/service-manager"); | ||
exports.ServiceManager = service_manager_1.ServiceManager; | ||
exports.ServiceEventTypes = service_manager_1.ServiceEventTypes; | ||
var abstract_service_controller_1 = require("./service/abstract-service-controller"); | ||
exports.AbstractServiceController = abstract_service_controller_1.AbstractServiceController; | ||
var Types = __importStar(require("./types")); | ||
exports.Types = Types; | ||
var graphql_base_type_defs_1 = require("./graphql-base-type-defs"); | ||
var GqlCore = __importStar(require("./graphql-core")); | ||
var GqlIdentityManager = __importStar(require("./graphql-identity-manager")); | ||
var graphql_base_type_defs_1 = require("./graphql/graphql-base-type-defs"); | ||
var GqlCore = __importStar(require("./graphql/graphql-core")); | ||
var GqlIdentityManager = __importStar(require("./graphql/graphql-identity-manager")); | ||
var Gql = { | ||
@@ -30,0 +33,0 @@ baseTypeDefs: graphql_base_type_defs_1.baseTypeDefs, |
@@ -6,2 +6,15 @@ # Change Log | ||
## [0.10.3](https://github.com/uport-project/daf/compare/v0.10.2...v0.10.3) (2019-12-12) | ||
### Bug Fixes | ||
* EventEmmiter ([dc52b55](https://github.com/uport-project/daf/commit/dc52b55aad6c612266ce136636f6aa65e524b59b)) | ||
* ServiceManager and AbstractServiceController ([284badc](https://github.com/uport-project/daf/commit/284badc52b420c637d0c7bc6823b71f1ea5c449d)) | ||
* Unifying debug messages ([efb4f3b](https://github.com/uport-project/daf/commit/efb4f3bf9f6d3f0d412eb80da7bb4ae92ce8ca72)) | ||
# [0.10.0](https://github.com/uport-project/daf/compare/v0.9.0...v0.10.0) (2019-12-10) | ||
@@ -8,0 +21,0 @@ |
{ | ||
"name": "daf-core", | ||
"description": "DID Agent Framework Core", | ||
"version": "0.10.0", | ||
"version": "0.10.3", | ||
"main": "build/index.js", | ||
@@ -30,3 +30,3 @@ "types": "build/index.d.ts", | ||
"keywords": [], | ||
"gitHead": "a194a5cf6c9bbe98b033f3add2044175dcc68391" | ||
"gitHead": "7714b6dd24142a6aa55fe863af59dc35eeb7b7ad" | ||
} |
import { EventEmitter } from 'events' | ||
import { DIDDocument } from 'did-resolver' | ||
import { IdentityManager, IdentityController } from './identity-manager' | ||
import { ServiceManager, ServiceControllerWithConfig, LastMessageTimestamp } from './service-manager' | ||
import { MessageValidator } from './message-validator' | ||
import { ActionHandler } from './action-handler' | ||
import { IdentityManager, IdentityController } from './identity/identity-manager' | ||
import { ServiceManager, LastMessageTimestampForInstance, ServiceEventTypes } from './service/service-manager' | ||
import { ServiceControllerDerived } from './service/abstract-service-controller' | ||
import { MessageValidator } from './message/message-validator' | ||
import { ActionHandler } from './action/action-handler' | ||
import { Action } from './types' | ||
import { EncryptionKeyManager } from './encryption-manager' | ||
import { Message } from './message' | ||
import { Message } from './message/message' | ||
import Debug from 'debug' | ||
const debug = Debug('core') | ||
const debug = Debug('daf:core') | ||
@@ -26,3 +27,3 @@ export const EventTypes = { | ||
identityControllers: IdentityController[] | ||
serviceControllersWithConfig: ServiceControllerWithConfig[] | ||
serviceControllers: ServiceControllerDerived[] | ||
messageValidator: MessageValidator | ||
@@ -53,4 +54,3 @@ actionHandler?: ActionHandler | ||
this.serviceManager = new ServiceManager({ | ||
serviceControllersWithConfig: config.serviceControllersWithConfig, | ||
validateMessage: this.validateMessage.bind(this), | ||
controllers: config.serviceControllers, | ||
didResolver: this.didResolver, | ||
@@ -64,12 +64,30 @@ }) | ||
async startServices() { | ||
async setupServices() { | ||
const issuers = await this.identityManager.listIssuers() | ||
await this.serviceManager.configureServices(issuers) | ||
await this.serviceManager.initServices() | ||
await this.serviceManager.setupServices(issuers) | ||
} | ||
async syncServices(lastMessageTimestamps: LastMessageTimestamp[]) { | ||
await this.serviceManager.syncServices(lastMessageTimestamps) | ||
async listen() { | ||
debug('Listening for new messages') | ||
this.serviceManager.on(ServiceEventTypes.NewMessages, this.validateMessages.bind(this)) | ||
this.serviceManager.listen() | ||
} | ||
async getMessagesSince(ts: LastMessageTimestampForInstance[]): Promise<Message[]> { | ||
const rawMessages = await this.serviceManager.getMessagesSince(ts) | ||
return this.validateMessages(rawMessages) | ||
} | ||
public async validateMessages(messages: Message[]): Promise<Message[]> { | ||
const result: Message[] = [] | ||
for (const message of messages) { | ||
try { | ||
const validMessage = await this.validateMessage(message) | ||
result.push(validMessage) | ||
} catch (e) {} | ||
} | ||
return result | ||
} | ||
public async validateMessage(message: Message): Promise<Message> { | ||
@@ -76,0 +94,0 @@ debug('Raw message %O', message) |
export { Core, EventTypes, Resolver } from './core' | ||
export { AbstractActionHandler } from './action-handler' | ||
export { AbstractActionHandler } from './action/action-handler' | ||
export { EncryptionKeyManager, KeyPair } from './encryption-manager' | ||
export { IdentityController, IdentityManager, Issuer } from './identity-manager' | ||
export { AbstractMessageValidator } from './message-validator' | ||
export { Message } from './message' | ||
export { | ||
ServiceController, | ||
ServiceControllerOptions, | ||
ServiceControllerWithConfig, | ||
ServiceInstanceId, | ||
} from './service-manager' | ||
export { IdentityController, IdentityManager, Issuer } from './identity/identity-manager' | ||
export { AbstractMessageValidator } from './message/message-validator' | ||
export { Message } from './message/message' | ||
export { ServiceManager, LastMessageTimestampForInstance, ServiceEventTypes } from './service/service-manager' | ||
export { AbstractServiceController } from './service/abstract-service-controller' | ||
import * as Types from './types' | ||
import { baseTypeDefs } from './graphql-base-type-defs' | ||
import * as GqlCore from './graphql-core' | ||
import * as GqlIdentityManager from './graphql-identity-manager' | ||
import { baseTypeDefs } from './graphql/graphql-base-type-defs' | ||
import * as GqlCore from './graphql/graphql-core' | ||
import * as GqlIdentityManager from './graphql/graphql-identity-manager' | ||
@@ -18,0 +14,0 @@ const Gql = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118018
59
2101
1