diff --git a/README.md b/README.md index e88923c..57f7705 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,23 @@ # ali_ecc_js -阿里云盘 签名 js版 +#阿里云盘 签名 js版 + +###install the packages + +` +npm install +` +### set the user data and file_id +. deviceId + +. userId + +. drive_id + +. authorization + +. file_id +### run +` +npm start +` diff --git a/ali.js b/ali.js index 5c68384..bc63a86 100644 --- a/ali.js +++ b/ali.js @@ -10,7 +10,7 @@ const userData = { publicKey: "", signatureData: "", drive_id:"6xxxx93", // DevTools -> Application -> Local Storage -> cna - authorization: "Bearer xxxxxxxxxx" // Request Headers -> authorization + authorization: "" // Request Headers -> authorization Bearer xxxxxxxxxx } const headers = { @@ -59,7 +59,7 @@ const DownloadFile = (file_id) => { headers: {...headers}, }); } -const InitAliKey = async () => { +const InitAliKey = () => { const {appId, deviceId, userId, nonce} = userData; const max = 32; const privKey = randomString(max); @@ -82,7 +82,10 @@ const InitAliKey = async () => { const main = async () => { InitAliKey(); - if(!userData.publicKey || !headers['x-signature'] || !userData.authorization) return; + if(!userData.publicKey || !headers['x-signature'] || !userData.authorization) { + console.log('need set the userdata'); + return + } const session = await CreateSession(); console.log(session.data) // { result: true, success: true, code: null, message: null } // file_id diff --git a/package.json b/package.json index 3f11ff9..f9ab79b 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "", "main": "ali.js", "scripts": { + "start": "node ali.js", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "fly1397@sina.com",