@live-change/framework
Advanced tools
Comparing version 0.5.12 to 0.5.13
@@ -76,3 +76,3 @@ const { uidGenerator, randomString } = require('@live-change/uid') | ||
this.instanceId = randomString(4) | ||
this.uidGenerator = uidGenerator(this.instanceId) | ||
this.uidGenerator = uidGenerator(this.instanceId, this.config.uidBorders) | ||
@@ -79,0 +79,0 @@ this.activeTimeouts = new Set() |
@@ -31,20 +31,20 @@ const LcDao = require("@live-change/dao") | ||
let credentials = { ...credentialsp, ip, roles: [] } | ||
const allAuthenticators = [] | ||
if(this.config.authenticators) { | ||
const auth = Array.isArray(this.config.authenticators) | ||
? this.config.authenticators : [this.config.authenticators] | ||
for(const authenticator of auth) { | ||
if(authenticator && authenticator.prepareCredentials) | ||
await authenticator.prepareCredentials(credentials, this.config) | ||
} | ||
allAuthenticators.push(...auth.filter(a => !!a)) | ||
} | ||
for(const service of this.config.services) { | ||
console.log("SERIVCE AUTH", service.name, service.authenticators) | ||
//console.log("SERIVCE AUTH", service.name, service.authenticators) | ||
if(service.authenticators) { | ||
for(const authenticator of service.authenticators) { | ||
if(authenticator && authenticator.prepareCredentials) | ||
await authenticator.prepareCredentials(credentials, this.config) | ||
} | ||
allAuthenticators.push(...service.authenticators.filter(a => !!a)) | ||
} | ||
} | ||
const dao = new this.DaoConstructor(this.config, { ...credentials }) | ||
for(const authenticator of allAuthenticators) { | ||
if(authenticator.prepareCredentials) { | ||
await authenticator.prepareCredentials(credentials, this.config) | ||
} | ||
} | ||
const dao = new this.DaoConstructor({ ...this.config, authenticators: allAuthenticators }, { ...credentials }) | ||
await dao.start() | ||
@@ -51,0 +51,0 @@ return dao |
@@ -14,18 +14,4 @@ const LcDao = require("@live-change/dao") | ||
if(this.config.authenticators) { | ||
const auth = Array.isArray(this.config.authenticators) | ||
? this.config.authenticators : [this.config.authenticators] | ||
for(const authenticator of auth) { | ||
if(authenticator && authenticator.authenticatorObservable) | ||
this.authenticators.push(authenticator) | ||
} | ||
this.authenticators = this.config.authenticators.filter(a => a.credentialsObservable) | ||
} | ||
for(const service of this.config.services) { | ||
console.log("SERIVCE AUTH", service.name, service.authenticators) | ||
if(service.authenticators) { | ||
for(const authenticator of service.authenticators) { | ||
if(authenticator && authenticator.authenticatorObservable) | ||
this.authenticators.push(authenticator) | ||
} | ||
} | ||
} | ||
@@ -52,4 +38,4 @@ this.currentDao = null | ||
...credentials, | ||
...credentialsObservers.credentials, | ||
roles: [...credentials.roles, ...credentialsObserver.credentials.roles] | ||
...credentialsObserver.credentials, | ||
roles: [...credentials.roles, ...(credentialsObserver.credentials.roles || [])] | ||
} | ||
@@ -62,9 +48,17 @@ } | ||
this.credentialsObservations = this.authenticators.map(authenticator => { | ||
const observable = authenticator.authenticatorObservable(this.initialCredentials) | ||
const result = authenticator.credentialsObservable(this.initialCredentials) | ||
const observable = result.then ? new LcDao.ObservablePromiseProxy(result) : result | ||
const observer = { | ||
set: (newCredentials) => { | ||
state.credentials = newCredentials | ||
set: (data) => { | ||
console.log("NEW CREDENTIALS", data) | ||
if(data) { | ||
const { id, ...newCredentials } = data | ||
state.credentials = newCredentials | ||
} else { | ||
state.credentials = {} | ||
} | ||
this.refreshCredentials() | ||
} | ||
} | ||
observable.observe(observer) | ||
const promise = waitForSignal(observable) | ||
@@ -71,0 +65,0 @@ const state = { |
{ | ||
"name": "@live-change/framework", | ||
"version": "0.5.12", | ||
"version": "0.5.13", | ||
"description": "Live Change Framework - ultimate solution for real time mobile/web apps", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
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
161347
4382