mirror of
				https://github.com/esiur/esiur-js.git
				synced 2025-10-31 17:51:36 +00:00 
			
		
		
		
	1.5.0
This commit is contained in:
		
							
								
								
									
										2
									
								
								LICENSE
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								LICENSE
									
									
									
									
									
								
							| @@ -1,6 +1,6 @@ | |||||||
| MIT License | MIT License | ||||||
|  |  | ||||||
| Copyright (c) 2017-2020 Esyur | Copyright (c) 2017-2020 Esiur | ||||||
|  |  | ||||||
| Permission is hereby granted, free of charge, to any person obtaining a copy | Permission is hereby granted, free of charge, to any person obtaining a copy | ||||||
| of this software and associated documentation files (the "Software"), to deal | of this software and associated documentation files (the "Software"), to deal | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| # Esyur.JS | # Esiur.JS | ||||||
| Esyur Library for Javascript | Esiur Library for Javascript | ||||||
|  |  | ||||||
| # Usage | # Usage | ||||||
							
								
								
									
										9444
									
								
								build/esyur.js
									
									
									
									
									
								
							
							
						
						
									
										9444
									
								
								build/esyur.js
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,5 +1,5 @@ | |||||||
| exports.printMsg = function() { | exports.printMsg = function() { | ||||||
|   console.log("Esyur"); |   console.log("Esiur"); | ||||||
| } | } | ||||||
|  |  | ||||||
| module.exports = { wh }; | module.exports = { wh }; | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										4
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "esyur", |   "name": "Esiur", | ||||||
|   "version": "1.4.5", |   "version": "1.5.0", | ||||||
|   "lockfileVersion": 1, |   "lockfileVersion": 1, | ||||||
|   "requires": true, |   "requires": true, | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								package.json
									
									
									
									
									
								
							| @@ -1,23 +1,23 @@ | |||||||
| { | { | ||||||
|   "name": "esyur", |   "name": "esiur", | ||||||
|   "version": "1.4.8", |   "version": "1.5.0", | ||||||
|   "description": "Distributed Object Framework", |   "description": "Distributed Object Framework", | ||||||
|   "main": "esyur.js", |   "main": "esiur.js", | ||||||
|   "scripts": { |   "scripts": { | ||||||
|     "test": "echo \"Error: no test specified\" && exit 1", |     "test": "echo \"Error: no test specified\" && exit 1", | ||||||
|     "babel": "./node_modules/.bin/babel src -d build", |     "babel": "./node_modules/.bin/babel src -d build", | ||||||
|     "build": "browserify src/esyur.js -t babelify --outfile build/esyur.js" |     "build": "browserify src/esiur.js -t babelify --outfile build/esiur.js" | ||||||
|   }, |   }, | ||||||
|   "repository": { |   "repository": { | ||||||
|     "type": "git", |     "type": "git", | ||||||
|     "url": "git+https://github.com/esyur/esyur-js.git" |     "url": "git+https://github.com/esiur/esiur-js.git" | ||||||
|   }, |   }, | ||||||
|   "author": "Ahmed Zamil", |   "author": "Ahmed Zamil", | ||||||
|   "license": "MIT", |   "license": "MIT", | ||||||
|   "bugs": { |   "bugs": { | ||||||
|     "url": "https://github.com/esyur/esyur-js/issues" |     "url": "https://github.com/esiur/esiur-js/issues" | ||||||
|   }, |   }, | ||||||
|   "homepage": "https://github.com/esyur/esyur-js#readme", |   "homepage": "https://github.com/esiur/esiur-js#readme", | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@babel/polyfill": "^7.8.3", |     "@babel/polyfill": "^7.8.3", | ||||||
|     "@babel/runtime": "^7.8.4", |     "@babel/runtime": "^7.8.4", | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ export default //const ExceptionCode = | |||||||
| { | { | ||||||
|     HostNotReachable: 0, |     HostNotReachable: 0, | ||||||
|     AccessDenied: 1, |     AccessDenied: 1, | ||||||
|     UserNotFound: 2, |     UserOrTokenNotFound: 2, | ||||||
|     ChallengeFailed: 3, |     ChallengeFailed: 3, | ||||||
|     ResourceNotFound: 4, |     ResourceNotFound: 4, | ||||||
|     AttachDenied: 5, |     AttachDenied: 5, | ||||||
| @@ -28,5 +28,6 @@ export default //const ExceptionCode = | |||||||
|     MethodNotFound: 25, |     MethodNotFound: 25, | ||||||
|     PropertyNotFound: 26, |     PropertyNotFound: 26, | ||||||
|     SetPropertyDenied: 27, |     SetPropertyDenied: 27, | ||||||
|     ReadOnlyProperty: 28 |     ReadOnlyProperty: 28, | ||||||
|  |     GeneralFailure: 29, | ||||||
| }; | }; | ||||||
| @@ -112,6 +112,31 @@ export default class BinaryList | |||||||
|                     break; |                     break; | ||||||
|                 case DataType.UInt8Array: |                 case DataType.UInt8Array: | ||||||
|                     ars.push(this.list[i].value); |                     ars.push(this.list[i].value); | ||||||
|  |                     break; | ||||||
|  |  | ||||||
|  |                 case DataType.UInt16Array: | ||||||
|  |                     ars.push(DC.uint16ArrayToBytes(this.list[i].value)); | ||||||
|  |                     break; | ||||||
|  |      | ||||||
|  |                 case DataType.UInt32Array: | ||||||
|  |                     ars.push(DC.uint32ArrayToBytes(this.list[i].value)); | ||||||
|  |                     break; | ||||||
|  |  | ||||||
|  |                 case DataType.Int16Array: | ||||||
|  |                     ars.push(DC.int16ArrayToBytes(this.list[i].value)); | ||||||
|  |                     break; | ||||||
|  |  | ||||||
|  |                 case DataType.Int32Array: | ||||||
|  |                     ars.push(DC.int32ArrayToBytes(this.list[i].value)); | ||||||
|  |                     break; | ||||||
|  |  | ||||||
|  |                 case DataType.Float32Array: | ||||||
|  |                     ars.push(DC.float32ArrayToBytes(this.list[i].value)); | ||||||
|  |                     break; | ||||||
|  |  | ||||||
|  |                 case DataType.Float64Array: | ||||||
|  |                     ars.push(DC.float64ArrayToBytes(this.list[i].value)); | ||||||
|  |                     break; | ||||||
|  |  | ||||||
|                 //case DataType.Resource: |                 //case DataType.Resource: | ||||||
|                 //    ars.push(DC.uint32ToBytes(this.list[i].value.instance.id)); |                 //    ars.push(DC.uint32ToBytes(this.list[i].value.instance.id)); | ||||||
| @@ -127,7 +152,7 @@ export default class BinaryList | |||||||
|  |  | ||||||
|         var length = 0; |         var length = 0; | ||||||
|         ars.forEach(function(a){ |         ars.forEach(function(a){ | ||||||
|             length += a.length; |             length += a.length ;//?? a.byteLength; | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         var rt = new Uint8Array(length); |         var rt = new Uint8Array(length); | ||||||
| @@ -135,7 +160,7 @@ export default class BinaryList | |||||||
|         var offset = 0; |         var offset = 0; | ||||||
|         for(var i = 0; i < ars.length; i++) { |         for(var i = 0; i < ars.length; i++) { | ||||||
|             rt.set(ars[i], offset); |             rt.set(ars[i], offset); | ||||||
|             offset+=ars[i].length; |             offset+=ars[i].length;// ?? ars[i].byteLength; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return rt; |         return rt; | ||||||
|   | |||||||
| @@ -835,6 +835,18 @@ static getDataType(value, connection) { | |||||||
|                     || value instanceof ArrayBuffer) { |                     || value instanceof ArrayBuffer) { | ||||||
|                     return DataType.UInt8Array; |                     return DataType.UInt8Array; | ||||||
|                 } |                 } | ||||||
|  |                 else if (value instanceof Uint16Array) | ||||||
|  |                     return DataType.UInt16Array; | ||||||
|  |                 else if (value instanceof Uint32Array) | ||||||
|  |                     return DataType.UInt32Array; | ||||||
|  |                 else if (value instanceof Int16Array) | ||||||
|  |                     return DataType.Int16Array; | ||||||
|  |                 else if (value instanceof Int32Array) | ||||||
|  |                     return DataType.Int32Array; | ||||||
|  |                 else if (value instanceof Float32Array) | ||||||
|  |                     return DataType.Float32Array; | ||||||
|  |                 else if (value instanceof Float64Array) | ||||||
|  |                     return DataType.Float64Array; | ||||||
|                 else if (value instanceof Number) { |                 else if (value instanceof Number) { | ||||||
|                     // JS numbers are always 64-bit float |                     // JS numbers are always 64-bit float | ||||||
|                     return DataType.Float64; |                     return DataType.Float64; | ||||||
|   | |||||||
| @@ -172,6 +172,71 @@ export default class DC extends Uint8Array | |||||||
|         return list.toArray(); |         return list.toArray(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     static uint16ArrayToBytes(values) | ||||||
|  |     { | ||||||
|  |         var rt = new DC(values.length * 2); | ||||||
|  |         for(var i = 0; i < values.length; i++) | ||||||
|  |             rt.setUint16(i * 2, values[i]); | ||||||
|  |         return rt; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     static int16ArrayToBytes(values) | ||||||
|  |     { | ||||||
|  |         var rt = new DC(values.length * 2); | ||||||
|  |         for(var i = 0; i < values.length; i++) | ||||||
|  |             rt.setInt16(i * 2, values[i]); | ||||||
|  |         return rt; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     static uint32ArrayToBytes(values) | ||||||
|  |     { | ||||||
|  |         var rt = new DC(values.length * 4); | ||||||
|  |         for(var i = 0; i < values.length; i++) | ||||||
|  |             rt.setUint32(i * 4, values[i]); | ||||||
|  |         return rt; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     static int32ArrayToBytes(values) | ||||||
|  |     { | ||||||
|  |         var rt = new DC(values.length * 4); | ||||||
|  |         for(var i = 0; i < values.length; i++) | ||||||
|  |             rt.setInt32(i * 4, values[i]); | ||||||
|  |         return rt; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     static int64ArrayToBytes(values) | ||||||
|  |     { | ||||||
|  |         var rt = new DC(values.length * 8); | ||||||
|  |         for(var i = 0; i < values.length; i++) | ||||||
|  |             rt.setInt64(i * 8, values[i]); | ||||||
|  |         return rt; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     static uint64ArrayToBytes(values) | ||||||
|  |     { | ||||||
|  |         var rt = new DC(values.length * 8); | ||||||
|  |         for(var i = 0; i < values.length; i++) | ||||||
|  |             rt.setUint64(i * 8, values[i]); | ||||||
|  |         return rt; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     static float32ArrayToBytes(values) | ||||||
|  |     { | ||||||
|  |         var rt = new DC(values.length * 4); | ||||||
|  |         for(var i = 0; i < values.length; i++) | ||||||
|  |             rt.setFloat32(i * 4, values[i]); | ||||||
|  |         return rt; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     static float64ArrayToBytes(values) | ||||||
|  |     { | ||||||
|  |         var rt = new DC(values.length * 8); | ||||||
|  |         for(var i = 0; i < values.length; i++) | ||||||
|  |             rt.setFloat64(i * 8, values[i]); | ||||||
|  |         return rt; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     append(src, offset, length) |     append(src, offset, length) | ||||||
|     { |     { | ||||||
|         if (!(src instanceof DC)) |         if (!(src instanceof DC)) | ||||||
| @@ -304,6 +369,16 @@ export default class DC extends Uint8Array | |||||||
|         return rt; |         return rt; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     paste(offset, length, elementSize, func)  | ||||||
|  |     { | ||||||
|  |         let rt = new dstType(length / elementSize); | ||||||
|  |         let d = 0, end = offset + length; | ||||||
|  |         for (let i = offset; i < end; i += elementSize) | ||||||
|  |             rt[d++] = func.call(this, i); | ||||||
|  |         return rt; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     getInt16Array(offset, length) |     getInt16Array(offset, length) | ||||||
|     { |     { | ||||||
|         return this.copy(offset, length, 2, this.getInt16, Int16Array); |         return this.copy(offset, length, 2, this.getInt16, Int16Array); | ||||||
|   | |||||||
| @@ -122,6 +122,47 @@ export default class KeyList | |||||||
|         this.values.splice(index, 1); |         this.values.splice(index, 1); | ||||||
|      } |      } | ||||||
|  |  | ||||||
|  |      clear() | ||||||
|  |      { | ||||||
|  |         while(this.length > 0) | ||||||
|  |             this.removeAt(0); | ||||||
|  |      } | ||||||
|  |  | ||||||
|  |     filter(selector) | ||||||
|  |     {	 | ||||||
|  |         if (selector instanceof Function){ | ||||||
|  |             return this.values.filter(selector); | ||||||
|  |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             let match = function(small, big) | ||||||
|  |             { | ||||||
|  |                 if (small == big) | ||||||
|  |                 { | ||||||
|  |                     return true; | ||||||
|  |                 } | ||||||
|  |                 else if (typeof small == "object" && typeof big == "object" && small != null && big != null) | ||||||
|  |                 { | ||||||
|  |                     if (small.constructor.name == "Object") | ||||||
|  |                     { | ||||||
|  |                         for(var i in small) | ||||||
|  |                             if (!match(small[i], big[i])) | ||||||
|  |                                 return false; | ||||||
|  |                         return true; | ||||||
|  |                     } | ||||||
|  |                     else | ||||||
|  |                     { | ||||||
|  |                         return false; | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |                 else | ||||||
|  |                     return false; | ||||||
|  |             }; | ||||||
|  |  | ||||||
|  |             return this.values.filter((x) => match(selector, x)); | ||||||
|  |         } | ||||||
|  |      } | ||||||
|  |   | ||||||
|      get length() |      get length() | ||||||
|      { |      { | ||||||
|          return this.keys.length; |          return this.keys.length; | ||||||
|   | |||||||
| @@ -28,6 +28,14 @@ | |||||||
|  |  | ||||||
| export default class Structure | export default class Structure | ||||||
| { | { | ||||||
|  |     toPairs() { | ||||||
|  |         var rt = []; | ||||||
|  |         for (var i in this) | ||||||
|  |             if (!(this[i] instanceof Function)) | ||||||
|  |                 rt.push({ key: i, value: this[i]}); | ||||||
|  |         return rt; | ||||||
|  |     } | ||||||
|  |      | ||||||
|     getKeys() { |     getKeys() { | ||||||
|         var rt = []; |         var rt = []; | ||||||
|         for (var i in this) |         for (var i in this) | ||||||
|   | |||||||
| @@ -46,7 +46,7 @@ import IIPAuthPacket from "../Packets/IIPAuthPacket.js"; | |||||||
| import IIPPacket from "../Packets/IIPPacket.js"; | import IIPPacket from "../Packets/IIPPacket.js"; | ||||||
| import IIPAuthPacketAction from "../Packets/IIPAuthPacketAction.js"; | import IIPAuthPacketAction from "../Packets/IIPAuthPacketAction.js"; | ||||||
| import IIPAuthPacketCommand from "../Packets/IIPAuthPacketCommand.js"; | import IIPAuthPacketCommand from "../Packets/IIPAuthPacketCommand.js"; | ||||||
| import IIPAuthPacketMethod from "../Packets/IIPAuthPacketMethod.js"; | import AuthenticationMethod from "../../Security/Authority/AuthenticationMethod.js"; | ||||||
|  |  | ||||||
| import IIPPacketAction from "../Packets/IIPPacketAction.js"; | import IIPPacketAction from "../Packets/IIPPacketAction.js"; | ||||||
| import IIPPacketCommand from "../Packets/IIPPacketCommand.js"; | import IIPPacketCommand from "../Packets/IIPPacketCommand.js"; | ||||||
| @@ -68,6 +68,7 @@ import { ResourceTrigger } from '../../Resource/IResource.js'; | |||||||
|  |  | ||||||
| import Ruling from '../../Security/Permissions/Ruling.js'; | import Ruling from '../../Security/Permissions/Ruling.js'; | ||||||
| import ActionType from '../../Security/Permissions/ActionType.js'; | import ActionType from '../../Security/Permissions/ActionType.js'; | ||||||
|  | import AsyncException from '../../Core/AsyncException.js'; | ||||||
|  |  | ||||||
| export default class DistributedConnection extends IStore { | export default class DistributedConnection extends IStore { | ||||||
|  |  | ||||||
| @@ -372,7 +373,7 @@ export default class DistributedConnection extends IStore { | |||||||
|  |  | ||||||
|                     } |                     } | ||||||
|                 } catch (ex) { |                 } catch (ex) { | ||||||
|                     console.log("Esyur Error ", ex); |                     console.log("Esiur Error ", ex); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| @@ -390,8 +391,8 @@ export default class DistributedConnection extends IStore { | |||||||
|  |  | ||||||
|                 if (this.session.localAuthentication.type == AuthenticationType.Host) { |                 if (this.session.localAuthentication.type == AuthenticationType.Host) { | ||||||
|                     if (authPacket.command == IIPAuthPacketCommand.Declare) { |                     if (authPacket.command == IIPAuthPacketCommand.Declare) { | ||||||
|                         if (authPacket.remoteMethod == IIPAuthPacketMethod.credentials |                         if (authPacket.remoteMethod == AuthenticationMethod.credentials | ||||||
|                             && authPacket.localMethod == IIPAuthPacketMethod.None) { |                             && authPacket.localMethod == AuthenticationMethod.None) { | ||||||
|                             this.session.remoteAuthentication.username = authPacket.remoteUsername; |                             this.session.remoteAuthentication.username = authPacket.remoteUsername; | ||||||
|                             this.remoteNonce = authPacket.remoteNonce; |                             this.remoteNonce = authPacket.remoteNonce; | ||||||
|                             this.domain = authPacket.domain; |                             this.domain = authPacket.domain; | ||||||
| @@ -449,11 +450,7 @@ export default class DistributedConnection extends IStore { | |||||||
|  |  | ||||||
|                         // send our hash |                         // send our hash | ||||||
|  |  | ||||||
|                         //var localHash = new DC(sha256.arrayBuffer(BL().addUint8Array(this.localPassword) |                         var localHash = SHA256.compute(BL().addUint8Array(this.localPasswordOrToken) | ||||||
|                         //    .addUint8Array(this.localNonce) |  | ||||||
|                         //    .addUint8Array(this.remoteNonce).toArray())); |  | ||||||
|  |  | ||||||
|                         var localHash = SHA256.compute(BL().addUint8Array(this.localPassword) |  | ||||||
|                             .addUint8Array(this.localNonce) |                             .addUint8Array(this.localNonce) | ||||||
|                             .addUint8Array(this.remoteNonce).toDC()); |                             .addUint8Array(this.remoteNonce).toDC()); | ||||||
|  |  | ||||||
| @@ -461,15 +458,10 @@ export default class DistributedConnection extends IStore { | |||||||
|                     } |                     } | ||||||
|                     else if (authPacket.command == IIPAuthPacketCommand.Action) { |                     else if (authPacket.command == IIPAuthPacketCommand.Action) { | ||||||
|                         if (authPacket.action == IIPAuthPacketAction.AuthenticateHash) { |                         if (authPacket.action == IIPAuthPacketAction.AuthenticateHash) { | ||||||
|                             // check if the server knows my password |  | ||||||
|                             //var remoteHash = new DC(sha256.arrayBuffer(BL().addUint8Array(this.remoteNonce) |  | ||||||
|                             //    .addUint8Array(this.localNonce) |  | ||||||
|                             //    .addUint8Array(this.localPassword).toArray() |  | ||||||
|                             //)); |  | ||||||
|  |  | ||||||
|                             var remoteHash = SHA256.compute(BL().addUint8Array(this.remoteNonce) |                             var remoteHash = SHA256.compute(BL().addUint8Array(this.remoteNonce) | ||||||
|                                 .addUint8Array(this.localNonce) |                                 .addUint8Array(this.localNonce) | ||||||
|                                 .addUint8Array(this.localPassword).toDC()); |                                 .addUint8Array(this.localPasswordOrToken).toDC()); | ||||||
|  |  | ||||||
|  |  | ||||||
|                             if (remoteHash.sequenceEqual(authPacket.hash)) { |                             if (remoteHash.sequenceEqual(authPacket.hash)) { | ||||||
| @@ -527,10 +519,18 @@ export default class DistributedConnection extends IStore { | |||||||
|         this.ready = false; |         this.ready = false; | ||||||
|         this.readyToEstablish = false; |         this.readyToEstablish = false; | ||||||
|  |  | ||||||
|         this.requests.values.forEach((x) => x.triggerError(AsyncException(ErrorType.Management, 0, "Connection closed"))); |         try | ||||||
|         this.resourceRequests.values.forEach((x) => x.triggerError(new AsyncException(ErrorType.Management, 0, "Connection closed"))); |         { | ||||||
|         this.templateRequests.values.forEach((x) => x.triggerError(new AsyncException(ErrorType.Management, 0, "Connection closed"))); |             this.requests.values.forEach((x) => x.triggerError(new AsyncException(ErrorType.Management, 0, "Connection closed"))); | ||||||
|         this.resources.values.forEach((x) => x.suspend()); |             this.resourceRequests.values.forEach((x) => x.triggerError(new AsyncException(ErrorType.Management, 0, "Connection closed"))); | ||||||
|  |             this.templateRequests.values.forEach((x) => x.triggerError(new AsyncException(ErrorType.Management, 0, "Connection closed"))); | ||||||
|  |         } | ||||||
|  |         catch(ex) | ||||||
|  |         { | ||||||
|  |             // unhandled error | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         this.resources.values.forEach((x) => x._suspend()); | ||||||
|  |  | ||||||
|         this.requests.clear(); |         this.requests.clear(); | ||||||
|         this.resourceRequests.clear(); |         this.resourceRequests.clear(); | ||||||
| @@ -597,6 +597,8 @@ export default class DistributedConnection extends IStore { | |||||||
|                 checkInterval = 30, |                 checkInterval = 30, | ||||||
|                 connectionTimeout = 600, |                 connectionTimeout = 600, | ||||||
|                 revivingTime = 120, |                 revivingTime = 120, | ||||||
|  |                 tokenIndex = 0, | ||||||
|  |                 token = null, | ||||||
|                 debug = false } = this.instance.attributes.toObject(); |                 debug = false } = this.instance.attributes.toObject(); | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -605,27 +607,40 @@ export default class DistributedConnection extends IStore { | |||||||
|             this.connectionTimeout = connectionTimeout * 1000; // 10 minutes (4 pings failed) |             this.connectionTimeout = connectionTimeout * 1000; // 10 minutes (4 pings failed) | ||||||
|             this.revivingTime = revivingTime * 1000; // 2 minutes |             this.revivingTime = revivingTime * 1000; // 2 minutes | ||||||
|  |  | ||||||
|             var pw = DC.stringToBytes(password); |              | ||||||
|             var host = this.instance.name.split(':'); |             var host = this.instance.name.split(':'); | ||||||
|  |  | ||||||
|             var address = host[0]; |             var address = host[0]; | ||||||
|             var port = parseInt(host[1]); |             var port = parseInt(host[1]); | ||||||
|  |  | ||||||
|             return this.connect(secure, address, port, username, pw, domain); |             if (token != null) | ||||||
|  |             { | ||||||
|  |                 var tk = DC.stringToBytes(token); | ||||||
|  |                 return this.connect(secure, AuthenticationMethod.token, address, port, null, tokenIndex, tk, domain); | ||||||
|  |             } | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 var pw = DC.stringToBytes(password); | ||||||
|  |                 return this.connect(secure, AuthenticationMethod.credentials, address, port, username, null, pw, domain); | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         return new AsyncReply(true); |         return new AsyncReply(true); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     connect(secure, hostname, port, username, password, domain) { |     connect(secure, method, hostname, port, username, tokenIndex, passwordOrToken, domain) { | ||||||
|         this.openReply = new AsyncReply(); |         this.openReply = new AsyncReply(); | ||||||
|  |  | ||||||
|  |  | ||||||
|         if (secure !== undefined) { |         if (secure !== undefined) { | ||||||
|  |  | ||||||
|  |             this.session.localAuthentication.method = method; | ||||||
|  |             this.session.localAuthentication.tokenIndex = tokenIndex; | ||||||
|  |          | ||||||
|             this.session.localAuthentication.domain = domain; |             this.session.localAuthentication.domain = domain; | ||||||
|             this.session.localAuthentication.username = username; |             this.session.localAuthentication.username = username; | ||||||
|             this.localPassword = password; |             this.localPasswordOrToken = passwordOrToken; | ||||||
|  |  | ||||||
|             //this.url = `ws${secure ? 's' : ''}://${this.instance.name}`; |             //this.url = `ws${secure ? 's' : ''}://${this.instance.name}`; | ||||||
|             this.url = `ws${secure ? 's' : ''}://${hostname}:${port}`; |             this.url = `ws${secure ? 's' : ''}://${hostname}:${port}`; | ||||||
| @@ -806,6 +821,7 @@ export default class DistributedConnection extends IStore { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     IIPReplyInvoke(callbackId, result) { |     IIPReplyInvoke(callbackId, result) { | ||||||
|  |          | ||||||
|         var req = this.requests.item(callbackId); |         var req = this.requests.item(callbackId); | ||||||
|  |  | ||||||
|         if (req != null) { |         if (req != null) { | ||||||
| @@ -820,7 +836,7 @@ export default class DistributedConnection extends IStore { | |||||||
|  |  | ||||||
|     IIPReportError(callbackId, errorType, errorCode, errorMessage) { |     IIPReportError(callbackId, errorType, errorCode, errorMessage) { | ||||||
|         var req = this.requests.item(callbackId); |         var req = this.requests.item(callbackId); | ||||||
|         if (request != null) |         if (req != null) | ||||||
|         { |         { | ||||||
|             this.requests.remove(callbackId); |             this.requests.remove(callbackId); | ||||||
|             req.triggerError(errorType, errorCode, errorMessage); |             req.triggerError(errorType, errorCode, errorMessage); | ||||||
| @@ -872,7 +888,7 @@ export default class DistributedConnection extends IStore { | |||||||
|                 item.trigger(new DistributedResourceQueueItem(r, DistributedResourceQueueItemType.Propery, args, index)); |                 item.trigger(new DistributedResourceQueueItem(r, DistributedResourceQueueItemType.Propery, args, index)); | ||||||
|             }).error(function (ex) { |             }).error(function (ex) { | ||||||
|                 self.queue.remove(item); |                 self.queue.remove(item); | ||||||
|                 console.log("Esyur Property Error", ex); |                 console.log("Esiur Property Error", ex); | ||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| @@ -896,7 +912,7 @@ export default class DistributedConnection extends IStore { | |||||||
|  |  | ||||||
|             }).error(function (ex) { |             }).error(function (ex) { | ||||||
|                 self.queue.remove(item); |                 self.queue.remove(item); | ||||||
|                 console.log("Esyur Event Error", ex); |                 console.log("Esiur Event Error", ex); | ||||||
|             }); |             }); | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -79,13 +79,20 @@ export default class DistributedResource extends IResource | |||||||
|     { |     { | ||||||
|  |  | ||||||
|         if (this._p.attached) |         if (this._p.attached) | ||||||
|  |         { | ||||||
|  |             console.log("Already attached."); | ||||||
|             return false; |             return false; | ||||||
|  |         } | ||||||
|         else |         else | ||||||
|         {  |         {  | ||||||
|  |  | ||||||
|  |             this._p.attached = true; | ||||||
|  |  | ||||||
|             this._p.suspended = false; |             this._p.suspended = false; | ||||||
|  |  | ||||||
|             for(var i = 0; i  < properties.length; i++) |             this._p.properties = []; | ||||||
|  |              | ||||||
|  |             for(let i = 0; i  < properties.length; i++) | ||||||
|             { |             { | ||||||
|                 this.instance.setAge(i, properties[i].age); |                 this.instance.setAge(i, properties[i].age); | ||||||
|                 this.instance.setModificationDate(i, properties[i].date); |                 this.instance.setModificationDate(i, properties[i].date); | ||||||
| @@ -93,7 +100,6 @@ export default class DistributedResource extends IResource | |||||||
|             } |             } | ||||||
|  |  | ||||||
|  |  | ||||||
|             this._p.attached = true; |  | ||||||
|  |  | ||||||
|             var self = this; |             var self = this; | ||||||
|  |  | ||||||
| @@ -210,6 +216,12 @@ export default class DistributedResource extends IResource | |||||||
|  |  | ||||||
|     _set(index, value) |     _set(index, value) | ||||||
|     { |     { | ||||||
|  |         if (!this._p.attached) | ||||||
|  |         { | ||||||
|  |             console.log("What ?"); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         if (this._p.neglect) |         if (this._p.neglect) | ||||||
|             return; |             return; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -29,7 +29,7 @@ | |||||||
|  |  | ||||||
| import IIPAuthPacketCommand from "./IIPAuthPacketCommand.js"; | import IIPAuthPacketCommand from "./IIPAuthPacketCommand.js"; | ||||||
| import IIPAuthPacketAction from "./IIPAuthPacketAction.js"; | import IIPAuthPacketAction from "./IIPAuthPacketAction.js"; | ||||||
| import IIPAuthPacketMethod from "./IIPAuthPacketMethod.js"; | import AuthenticationMethod from "../../Security/Authority/AuthenticationMethod.js"; | ||||||
|  |  | ||||||
| export default class IIPAuthPacket | export default class IIPAuthPacket | ||||||
| { | { | ||||||
| @@ -138,9 +138,9 @@ export default class IIPAuthPacket | |||||||
|             offset += domainLength; |             offset += domainLength; | ||||||
|  |  | ||||||
|  |  | ||||||
|             if (this.remoteMethod == IIPAuthPacketMethod.Credentials) |             if (this.remoteMethod == AuthenticationMethod.Credentials) | ||||||
|             { |             { | ||||||
|                 if (this.localMethod == IIPAuthPacketMethod.None) |                 if (this.localMethod == AuthenticationMethod.None) | ||||||
|                 { |                 { | ||||||
|                     if (this.notEnough(offset, ends, 33)) |                     if (this.notEnough(offset, ends, 33)) | ||||||
|                         return -this.dataLengthNeeded; |                         return -this.dataLengthNeeded; | ||||||
| @@ -160,6 +160,21 @@ export default class IIPAuthPacket | |||||||
|                     offset += length; |                     offset += length; | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |             else if (this.remoteMethod == AuthenticationMethod.Token) | ||||||
|  |             { | ||||||
|  |                 if (this.localMethod == AuthenticationMethod.None) | ||||||
|  |                 { | ||||||
|  |                     if (this.notEnough(offset, ends, 40)) | ||||||
|  |                             return -this.dataLengthNeeded; | ||||||
|  |                      | ||||||
|  |                     this.remoteNonce = data.clip(offset, 32); | ||||||
|  |  | ||||||
|  |                     offset += 32; | ||||||
|  |  | ||||||
|  |                     this.remoteTokenIndex = data.getUint64(offset); | ||||||
|  |                     offset += 8; | ||||||
|  |                  } | ||||||
|  |             } | ||||||
|  |  | ||||||
|             if (encrypt) |             if (encrypt) | ||||||
|             { |             { | ||||||
| @@ -188,9 +203,10 @@ export default class IIPAuthPacket | |||||||
|                 return -this.dataLengthNeeded; |                 return -this.dataLengthNeeded; | ||||||
|  |  | ||||||
|  |  | ||||||
|             if (this.remoteMethod == IIPAuthPacketMethod.Credentials) |             if (this.remoteMethod == AuthenticationMethod.Credentials | ||||||
|  |                 || this.remoteMethod == AuthenticationMethod.Token) | ||||||
|             { |             { | ||||||
|                 if (this.localMethod == IIPAuthPacketMethod.None) |                 if (this.localMethod == AuthenticationMethod.None) | ||||||
|                 { |                 { | ||||||
|                     if (this.notEnough(offset, ends, 32)) |                     if (this.notEnough(offset, ends, 32)) | ||||||
|                         return -this.dataLengthNeeded; |                         return -this.dataLengthNeeded; | ||||||
|   | |||||||
| @@ -54,7 +54,7 @@ export default class IResource extends IDestructible | |||||||
|     static getTemplate() |     static getTemplate() | ||||||
|     { |     { | ||||||
|         return { |         return { | ||||||
|                 namespace: "Esyur", |                 namespace: "Esiur", | ||||||
|                 properties: [], |                 properties: [], | ||||||
|                 functions: [], |                 functions: [], | ||||||
|                 events: [] |                 events: [] | ||||||
|   | |||||||
| @@ -31,6 +31,8 @@ export default class Authentication | |||||||
| { | { | ||||||
|     constructor(type) |     constructor(type) | ||||||
|     { |     { | ||||||
|  |         this.method = 0; | ||||||
|  |         this.tokenIndex = 0; | ||||||
|         this.type = type; |         this.type = type; | ||||||
|         this.state = 0; |         this.state = 0; | ||||||
|         this.domain = null; |         this.domain = null; | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| export default //const IIPAuthPacketMethod =
 | export default | ||||||
| { | { | ||||||
|     None: 0, |     None: 0, | ||||||
|     Certificate: 1, |     Certificate: 1, | ||||||
| @@ -55,7 +55,7 @@ | |||||||
|          |          | ||||||
|         <script src="/iui-js/iui.js"></script> |         <script src="/iui-js/iui.js"></script> | ||||||
|  |  | ||||||
|         <script src="viewers/Esyur.Stores.MemoryStore.js"></script>         |         <script src="viewers/Esiur.Stores.MemoryStore.js"></script>         | ||||||
|  |  | ||||||
|         <script src="js/browser.js"></script>         |         <script src="js/browser.js"></script>         | ||||||
|         <script src="js/app.js"></script> |         <script src="js/app.js"></script> | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| class Esyur_Stores_MemoryStore extends IUIWidget | class Esiur_Stores_MemoryStore extends IUIWidget | ||||||
| { | { | ||||||
|     constuctor() |     constuctor() | ||||||
|     { |     { | ||||||
| @@ -6,4 +6,4 @@ class Esyur_Stores_MemoryStore extends IUIWidget | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| IUI.module("Esyur.Stores.MemoryStore", Esyur_Stores_MemoryStore); | IUI.module("Esiur.Stores.MemoryStore", Esiur_Stores_MemoryStore); | ||||||
		Reference in New Issue
	
	Block a user