Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
jio
Commits
ff63c4ff
Commit
ff63c4ff
authored
Aug 23, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
defineConstant does not provide more security
parent
cb2d6448
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
46 deletions
+3
-46
src/jio/core/EventEmitter.js
src/jio/core/EventEmitter.js
+1
-1
src/jio/core/Storage.js
src/jio/core/Storage.js
+2
-2
src/jio/intro.js
src/jio/intro.js
+0
-43
No files found.
src/jio/core/EventEmitter.js
View file @
ff63c4ff
/*jslint indent: 2, maxlen: 80, nomen: true, sloppy: true */
/*global secureMethods, exports,
defineConstant,
console */
/*global secureMethods, exports, console */
/**
* Inspired by nodejs EventEmitter class
...
...
src/jio/core/Storage.js
View file @
ff63c4ff
/*jslint indent: 2, maxlen: 80, sloppy: true */
/*global exports, defaults
, defineConstant
*/
/*global exports, defaults */
function
Storage
()
{
// (storage_spec, util)
return
undefined
;
// this is a constructor
...
...
@@ -33,4 +33,4 @@ function addStorage(type, Constructor) {
// dictUpdate(Constructor.prototype, proto);
defaults
.
storage_types
[
type
]
=
Constructor
;
}
defineConstant
(
exports
,
'
addStorage
'
,
addStorage
)
;
exports
.
addStorage
=
addStorage
;
src/jio/intro.js
View file @
ff63c4ff
...
...
@@ -9,46 +9,3 @@
window
.
jIO
=
{};
module
(
window
.
jIO
);
}([
'
exports
'
],
function
(
exports
)
{
/**
* Add a secured (write permission denied) property to an object.
*
* @method defineConstant
* @param {Object} object The object to fill
* @param {String} key The object key where to store the property
* @param {Any} value The value to store
*/
function
defineConstant
(
object
,
key
,
value
)
{
Object
.
defineProperty
(
object
,
key
,
{
"
configurable
"
:
false
,
"
enumerable
"
:
true
,
"
writable
"
:
false
,
"
value
"
:
value
});
return
object
;
}
/**
* Secures all enumerable functions from an object, making them
* not configurable, not writable, not enumerable.
*
* @method secureMethods
* @param {Object} object The object to secure
*/
function
secureMethods
(
object
)
{
var
key
;
for
(
key
in
object
)
{
if
(
object
.
hasOwnProperty
(
key
))
{
if
(
typeof
object
[
key
]
===
"
function
"
)
{
Object
.
defineProperty
(
object
,
key
,
{
"
configurable
"
:
false
,
"
enumerable
"
:
false
,
"
writable
"
:
false
,
"
value
"
:
object
[
key
]
});
}
}
}
return
object
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment