Add @ssttevee method of authentication (from pull request #43)
This commit is contained in:
parent
b48877b786
commit
ab35bb4439
4
src/interface/IConfig.d.ts
vendored
4
src/interface/IConfig.d.ts
vendored
@ -23,12 +23,16 @@ interface IConfig {
|
||||
retry?: number;
|
||||
// Login options
|
||||
logUsingApi?: boolean;
|
||||
logUsingCookie?: boolean;
|
||||
crSessionUrl?: string;
|
||||
crDeviceType?: string;
|
||||
crAPIVersion?: string;
|
||||
crLocale?: string;
|
||||
crSessionKey?: string;
|
||||
crLoginUrl?: string;
|
||||
// Third method, injecting data from cookies
|
||||
crUserId?: string;
|
||||
crUserKey?: string;
|
||||
// Generated values
|
||||
crDeviceId?: string;
|
||||
crSessionId?: string;
|
||||
|
||||
@ -16,6 +16,8 @@ const cookieStore = require('tough-cookie-file-store');
|
||||
// tslint:disable-next-line:no-var-requires
|
||||
const cloudscraper = require('cloudscraper');
|
||||
|
||||
const CR_COOKIE_DOMAIN = 'http://crunchyroll.com';
|
||||
|
||||
let isAuthenticated = false;
|
||||
let isPremium = false;
|
||||
|
||||
@ -265,6 +267,25 @@ function authenticate(config: IConfig, done: (err: Error) => void)
|
||||
});
|
||||
});
|
||||
}
|
||||
else if (config.logUsingCookie)
|
||||
{
|
||||
j.setCookie(request.cookie('c_userid=' + config.crUserId + '; Domain=crunchyroll.com; HttpOnly; hostOnly=false;'),
|
||||
CR_COOKIE_DOMAIN);
|
||||
j.setCookie(request.cookie('c_userkey=' + config.crUserKey + '; Domain=crunchyroll.com; HttpOnly; hostOnly=false;'),
|
||||
CR_COOKIE_DOMAIN);
|
||||
|
||||
checkIfUserIsAuth(config, (errCheckAuth2) =>
|
||||
{
|
||||
if (isAuthenticated)
|
||||
{
|
||||
return done(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
return done(errCheckAuth2);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
log.error('This method of login is currently unsupported...\n');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user