Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F21283
conduit_client_for_node.js
All Users
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
epriestley
Oct 16 2012, 1:44 AM
2012-10-16 01:44:06 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
conduit_client_for_node.js
View Options
var
https
=
require
(
'https'
);
var
querystring
=
require
(
'querystring'
);
var
crypto
=
require
(
'crypto'
);
var
CONDUIT_HOST
=
"secure.phabricator.com"
;
var
CONDUIT_USER
=
"epriestley"
;
var
CONDUIT_CERT
=
"xxxxx"
;
function
call_conduit
(
method
,
params
)
{
var
post_data
=
querystring
.
stringify
({
params
:
JSON
.
stringify
(
params
),
output
:
"json"
,
__conduit__
:
"true"
,
});
var
request
=
https
.
request
(
{
host
:
CONDUIT_HOST
,
path
:
"/api/"
+
method
,
method
:
"POST"
,
headers
:
{
"Host"
:
CONDUIT_HOST
,
"Content-Type"
:
"application/x-www-form-urlencoded"
,
"Content-Length"
:
post_data
.
length
}
},
function
(
res
)
{
res
.
setEncoding
(
"utf8"
);
res
.
on
(
"data"
,
function
(
chunk
)
{
console
.
log
(
'>>> '
+
chunk
);
});
});
request
.
write
(
post_data
);
request
.
end
();
}
function
get_auth
()
{
var
token
=
parseInt
(
new
Date
()
/
1000
)
+
''
;
var
sig
=
crypto
.
createHash
(
'sha1'
)
.
update
(
token
)
.
update
(
CONDUIT_CERT
)
.
digest
(
'hex'
);
return
{
token
:
token
,
sig
:
sig
};
}
var
auth
=
get_auth
();
call_conduit
(
'conduit.connect'
,
{
client
:
"node.js"
,
clientVersion
:
"0.0001alpha"
,
host
:
"https://"
+
CONDUIT_HOST
+
"/"
,
clientDescription
:
"example node.js script"
,
user
:
CONDUIT_USER
,
authToken
:
auth
.
token
,
authSignature
:
auth
.
sig
});
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/lz4i5qbj2oj3ynxzqzoa
Default Alt Text
conduit_client_for_node.js (1 KB)
Attached To
Mode
P571 conduit_client_for_node.js
Attached
Detach File
Event Timeline
Log In to Comment