How to use authHeader method in argos

Best JavaScript code snippet using argos

api.js

Source:api.js Github

copy

Full Screen

...3const API_URL = process.env.REACT_APP_API_URL;4class AdminService {5 //LoginAs6 loginAs(data) {7 return axios.post(API_URL + 'auth/login_as', data, { headers: authHeader() });8 }9 //Login10 login(data) {11 return axios.post(API_URL + 'auth/login', data, {});12 }13 //firstLogin14 firstLogin(data) {15 return axios.post(API_URL + 'auth/firstLogin', data, {});16 }17 //verifySMS18 verifySMS(data) {19 return axios.post(API_URL + 'auth/verifySMS', data, {});20 }21 //forgotPassword22 forgotPassword(data) {23 return axios.post(API_URL + 'auth/forgotPassword', data, {});24 }25 //resetPassword26 resetPassword(data) {27 return axios.post(API_URL + 'auth/resetPassword', data, {});28 }29 //verifyToken30 verifyToken(data) {31 return axios.post(API_URL + 'auth/verifyToken', data, {});32 }33 //My Account34 updateProfile(data) {35 return axios.post(API_URL + 'web/admin/profile', data, { headers: authHeader() });36 }37 getProfile() {38 return axios.get(API_URL + 'web/admin/profile', { headers: authHeader() });39 }40 //User41 getUserList(data) {42 return axios.post(API_URL + 'web/admin/userList', data, { headers: authHeader() });43 }44 getUser(id) {45 return axios.get(API_URL + 'web/admin/user/' + id, { headers: authHeader() });46 }47 createUser(data) {48 return axios.post(API_URL + 'web/admin/user', data, { headers: authHeader() });49 }50 updateUser(id, data) {51 return axios.put(API_URL + 'web/admin/user/' + id, data, { headers: authHeader() });52 }53 deleteUser(id, status) {54 return axios.post(API_URL + 'web/admin/user/' + id + '/delete', status, { headers: authHeader() });55 }56 emptyTrashUser(status) {57 return axios.post(API_URL + 'web/admin/trash/user/deleteAll', status, { headers: authHeader() });58 }59 //Company Part60 getCompanyList(data) {61 return axios.post(API_URL + 'web/admin/companyList', data, { headers: authHeader() });62 }63 addCompany(data) {64 return axios.post(API_URL + 'web/admin/company', data, { headers: authHeader() });65 }66 updateCompany(id, data) {67 return axios.put(API_URL + 'web/admin/company/' + id, data, { headers: authHeader() });68 }69 getCompany(id) {70 return axios.get(API_URL + 'web/admin/company/' + id, { headers: authHeader() });71 }72 deleteCompany(id, status) {73 return axios.post(API_URL + 'web/admin/company/' + id + '/delete', status, { headers: authHeader() });74 }75 emptyTrashCompany(status) {76 return axios.post(API_URL + 'web/admin/trash/company/deleteAll', status, { headers: authHeader() });77 }78 updateBankInfo(id, data) {79 return axios.put(API_URL + 'web/admin/company/' + id + '/bank', data, { headers: authHeader() });80 }81 updateBuildingBankInfo(id, data) {82 return axios.put(API_URL + 'web/admin/building/' + id + '/bank', data, { headers: authHeader() });83 }84 //Card Part85 getCardList(data) {86 return axios.post(API_URL + 'web/admin/cardList', data, { headers: authHeader() });87 }88 createCard(data) {89 return axios.post(API_URL + 'web/admin/card', data, { headers: authHeader() });90 }91 updateCard(id, data) {92 return axios.put(API_URL + 'web/admin/card/' + id, data, { headers: authHeader() });93 }94 getCard(id) {95 return axios.get(API_URL + 'web/admin/card/' + id, { headers: authHeader() });96 }97 deleteCard(id) {98 return axios.delete(API_URL + 'web/admin/card/' + id, { headers: authHeader() });99 }100 //Building Part101 getBuildingList(data) {102 return axios.post(API_URL + 'web/admin/buildingList', data, { headers: authHeader() });103 }104 createBuilding(data) {105 return axios.post(API_URL + 'web/admin/building', data, { headers: authHeader() });106 }107 updateBuilding(id, data) {108 return axios.put(API_URL + 'web/admin/building/' + id, data, { headers: authHeader() });109 }110 getBuilding(id) {111 return axios.get(API_URL + 'web/admin/building/' + id, { headers: authHeader() });112 }113 deleteBuilding(id, status) {114 return axios.post(API_URL + 'web/admin/building/' + id + '/delete', status, { headers: authHeader() });115 }116 emptyTrashBuilding(status) {117 return axios.post(API_URL + 'web/admin/trash/building/deleteAll', status, { headers: authHeader() });118 }119 importBuilding(data) {120 return axios.post(API_URL + 'web/admin/building/import_csv', data, { headers: authHeader() });121 }122 exportBuilding(data) {123 return axios.post(API_URL + 'web/admin/building/export_csv', data, { headers: authHeader() ,responseType: 'blob'});124 }125 //Owner Part126 getOwnerList(data) {127 return axios.post(API_URL + 'web/admin/ownerList', data, { headers: authHeader() });128 }129 createOwner(data) {130 return axios.post(API_URL + 'web/admin/owner', data, { headers: authHeader() });131 }132 setSuspendOwner(id, data) {133 return axios.put(API_URL + 'web/admin/owner/' + id + '/status', data, { headers: authHeader() });134 }135 updateOwner(id, data) {136 return axios.put(API_URL + 'web/admin/owner/' + id, data, { headers: authHeader() });137 }138 getOwner(id, data) {139 return axios.post(API_URL + 'web/admin/owner/' + id, data, { headers: authHeader() });140 }141 deleteOwner(id, status) {142 return axios.post(API_URL + 'web/admin/owner/' + id + '/delete', status, { headers: authHeader() });143 }144 emptyTrashOwner(status) {145 return axios.post(API_URL + 'web/admin/trash/owner/deleteAll', status, { headers: authHeader() });146 }147 importOwner(data) {148 return axios.post(API_URL + 'web/admin/owner_import_csv', data, { headers: authHeader() });149 }150 exportOwner(data) {151 return axios.post(API_URL + 'web/admin/owner_export_csv', data, { headers: authHeader() ,responseType: 'blob'});152 }153 //Manager Part154 getManagerList(data) {155 return axios.post(API_URL + 'web/admin/managerList', data, { headers: authHeader() });156 }157 createManager(data) {158 return axios.post(API_URL + 'web/admin/manager', data, { headers: authHeader() });159 }160 updateManager(id, data) {161 return axios.put(API_URL + 'web/admin/manager/' + id, data, { headers: authHeader() });162 }163 getManager(id) {164 return axios.get(API_URL + 'web/admin/manager/' + id, { headers: authHeader() });165 }166 setSuspendManager(id, data) {167 return axios.put(API_URL + 'web/admin/manager/' + id + '/status', data, { headers: authHeader() });168 }169 deleteManager(id, status) {170 return axios.post(API_URL + 'web/admin/manager/' + id + '/delete', status, { headers: authHeader() });171 }172 emptyTrashManager(status) {173 return axios.post(API_URL + 'web/admin/trash/manager/deleteAll', status, { headers: authHeader() });174 }175 //DiscountCode Part176 getDiscountCodesList(data) {177 return axios.post(API_URL + 'web/admin/discountCodeList', data, { headers: authHeader() });178 }179 createDiscountCode(data) {180 return axios.post(API_URL + 'web/admin/discountCode', data, { headers: authHeader() });181 }182 updateDiscountCode(id, data) {183 return axios.put(API_URL + 'web/admin/discountCode/' + id, data, { headers: authHeader() });184 }185 getDiscountCode(id) {186 return axios.get(API_URL + 'web/admin/discountCode/' + id, { headers: authHeader() });187 }188 deleteDiscountCode(id, status) {189 return axios.post(API_URL + 'web/admin/discountCode/' + id + '/delete', status, { headers: authHeader() });190 }191 emptyTrashCode(status) {192 return axios.post(API_URL + 'web/admin/trash/discountCode/deleteAll', status, { headers: authHeader() });193 }194 //Product Part195 getProductList(data) {196 return axios.post(API_URL + 'web/admin/productList', data, { headers: authHeader() });197 }198 createProduct(data) {199 return axios.post(API_URL + 'web/admin/product', data, { headers: authHeader() });200 }201 updateProduct(id, data) {202 return axios.put(API_URL + 'web/admin/product/' + id, data, { headers: authHeader() });203 }204 getProduct(id) {205 return axios.get(API_URL + 'web/admin/product/' + id, { headers: authHeader() });206 }207 deleteProduct(id, status) {208 return axios.post(API_URL + 'web/admin/product/' + id + '/delete', status, { headers: authHeader() });209 }210 emptyTrashProduct(status) {211 return axios.post(API_URL + 'web/admin/trash/product/deleteAll', status, { headers: authHeader() });212 }213 //Order Part214 getOrderList(data) {215 return axios.post(API_URL + 'web/admin/orderList', data, { headers: authHeader() });216 }217 createOrder(data) {218 return axios.post(API_URL + 'web/admin/order', data, { headers: authHeader() });219 }220 updateOrder(id, data) {221 return axios.put(API_URL + 'web/admin/order/' + id, data, { headers: authHeader() });222 }223 getOrder(id) {224 return axios.get(API_URL + 'web/admin/order/' + id, { headers: authHeader() });225 }226 deleteOrder(id, status) {227 return axios.post(API_URL + 'web/admin/order/' + id + '/delete', status, { headers: authHeader() });228 }229 emptyTrashOrder(status) {230 return axios.post(API_URL + 'web/admin/trash/order/deleteAll', status, { headers: authHeader() });231 }232 downloadInvoiceCompany(data) {233 return axios.post(API_URL + 'web/admin/downloadInvoiceCompany', data, { headers: authHeader() ,responseType: 'blob'});234 }235 downloadInvoiceBuilding(data) {236 return axios.post(API_URL + 'web/admin/downloadInvoiceBuilding', data, { headers: authHeader() ,responseType: 'blob'});237 }238 downloadInvoiceOwner(data) {239 return axios.post(API_URL + 'web/admin/downloadInvoiceOwner', data, { headers: authHeader() ,responseType: 'blob'});240 }241 downloadZipCompany(data) {242 return axios.post(API_URL + 'web/admin/downloadZipCompany', data, { headers: authHeader() ,responseType: 'blob'});243 }244 downloadZipBuilding(data) {245 return axios.post(API_URL + 'web/admin/downloadZipBuilding', data, { headers: authHeader() ,responseType: 'blob'});246 }247 downloadZipOwner(data) {248 return axios.post(API_URL + 'web/admin/downloadZipOwner', data, { headers: authHeader() ,responseType: 'blob'});249 }250 getBuyerList(data) {251 return axios.post(API_URL + 'web/admin/buyerList',data, { headers: authHeader() });252 }253 getBuyerList(data) {254 return axios.post(API_URL + 'web/admin/buyerList',data, { headers: authHeader() });255 }256 getCodeList(data) {257 return axios.post(API_URL + 'web/admin/discountCodeListByType',data, { headers: authHeader() });258 }259 //Common260 getBuildingListByCompany(data) {261 return axios.post(API_URL + 'web/admin/buildingListByCompany', data, { headers: authHeader() });262 }263 getCompanyListByUser() {264 return axios.get(API_URL + 'web/admin/companyListByUser', { headers: authHeader() });265 }266}267export class OwnerService {268 //My Account269 updateProfile(data) {270 return axios.post(API_URL + 'web/owner/profile', data, { headers: authHeader() });271 }272 getProfile() {273 return axios.get(API_URL + 'web/owner/profile', { headers: authHeader() });274 }275 //SubAccount Part276 getOwnerList(data) {277 return axios.post(API_URL + 'web/owner/subAccountList', data, { headers: authHeader() });278 }279 createOwner(data) {280 return axios.post(API_URL + 'web/owner/subAccount', data, { headers: authHeader() });281 }282 getOwner(id, data) {283 return axios.post(API_URL + 'web/owner/subAccount/' + id, data, { headers: authHeader() });284 }285 deleteOwner(id) {286 return axios.delete(API_URL + 'web/owner/subAccount/' + id, { headers: authHeader() });287 }288 reinviteOwner(id, data) {289 return axios.post(API_URL + 'web/owner/subAccount/' + id + '/reinvite', data, { headers: authHeader() });290 }291 acceptInvitation(data) {292 return axios.post(API_URL + 'web/owner/invitation', data, {});293 }294 getBuildingListByOwner() {295 return axios.get(API_URL + 'web/owner/buildingListByOwner', { headers: authHeader() });296 }297 //Payment Part298 //Card Part299 getCardList(data) {300 return axios.post(API_URL + 'web/owner/cardList', data, { headers: authHeader() });301 }302 createCard(data) {303 return axios.post(API_URL + 'web/owner/card', data, { headers: authHeader() });304 }305 updateCard(id, data) {306 return axios.put(API_URL + 'web/owner/card/' + id, data, { headers: authHeader() });307 }308 getCard(id) {309 return axios.get(API_URL + 'web/owner/card/' + id, { headers: authHeader() });310 }311 deleteCard(id) {312 return axios.delete(API_URL + 'web/owner/card/' + id, { headers: authHeader() });313 }314}315export class ManagerService {316 //My Account317 updateProfile(data) {318 return axios.post(API_URL + 'web/manager/profile', data, { headers: authHeader() });319 }320 getProfile() {321 return axios.get(API_URL + 'web/manager/profile', { headers: authHeader() });322 }323 //My Company324 updateMyCompany(data) {325 return axios.post(API_URL + 'web/manager/mycompany', data, { headers: authHeader() });326 }327 getMyCompany() {328 return axios.get(API_URL + 'web/manager/mycompany', { headers: authHeader() });329 }330 //Invoice Part331 getInvoiceSubscription(data) {332 return axios.post(API_URL + 'web/manager/invoice_order', data, { headers: authHeader() });333 }334 getInvoiceAddon(data) {335 return axios.post(API_URL + 'web/manager/invoice_addon', data, { headers: authHeader() });336 }337 downloadInvoiceSubscription(data) {338 return axios.post(API_URL + 'web/manager/downloadInvoiceOrder', data, { headers: authHeader() ,responseType: 'blob'});339 }340 downloadInvoiceAddon(data) {341 return axios.post(API_URL + 'web/manager/downloadInvoiceAddon', data, { headers: authHeader() ,responseType: 'blob'});342 }343 //Addon Part344 getAddonsByBuildingID(data) {345 return axios.post(API_URL + 'web/manager/addonsByBuildingID', data, { headers: authHeader() });346 }347 getAddon() {348 return axios.get(API_URL + 'web/manager/addon', { headers: authHeader() });349 }350 buyAddon(data) {351 return axios.post(API_URL + 'web/manager/buyAddon', data, { headers: authHeader() });352 }353 getDiscountCode(id) {354 return axios.get(API_URL + 'web/manager/discountCode/' + id, { headers: authHeader() });355 }356 getDiscountCodesList(data) {357 return axios.post(API_URL + 'web/manager/discountCodeListByType', data, { headers: authHeader() });358 }359 //Building Part360 getBuildingList(data) {361 return axios.post(API_URL + 'web/manager/buildingList', data, { headers: authHeader() });362 }363 createBuilding(data) {364 return axios.post(API_URL + 'web/manager/building', data, { headers: authHeader() });365 }366 updateBuilding(id, data) {367 return axios.put(API_URL + 'web/manager/building/' + id, data, { headers: authHeader() });368 }369 getBuilding(id) {370 return axios.get(API_URL + 'web/manager/building/' + id, { headers: authHeader() });371 }372 deleteBuilding(id, status) {373 return axios.post(API_URL + 'web/manager/building/' + id + '/delete', status, { headers: authHeader() });374 }375 emptyTrashBuilding(status) {376 return axios.post(API_URL + 'web/manager/trash/building/deleteAll', status, { headers: authHeader() });377 }378 importBuilding(data) {379 return axios.post(API_URL + 'web/manager/building/import_csv', data, { headers: authHeader() });380 }381 exportBuilding(data) {382 return axios.post(API_URL + 'web/manager/building/export_csv', data, { headers: authHeader() ,responseType: 'blob'});383 }384 //Owner Part385 getOwnerList(data) {386 return axios.post(API_URL + 'web/manager/ownerList', data, { headers: authHeader() });387 }388 createOwner(data) {389 return axios.post(API_URL + 'web/manager/owner', data, { headers: authHeader() });390 }391 updateOwner(id, data) {392 return axios.put(API_URL + 'web/manager/owner/' + id, data, { headers: authHeader() });393 }394 getOwner(id, data) {395 return axios.post(API_URL + 'web/manager/owner/' + id, data, { headers: authHeader() });396 }397 setSuspendOwner(id, data) {398 return axios.put(API_URL + 'web/manager/owner/' + id + '/status', data, { headers: authHeader() });399 }400 deleteOwner(id, status) {401 return axios.post(API_URL + 'web/manager/owner/' + id + '/delete', status, { headers: authHeader() });402 }403 emptyTrashOwner(status) {404 return axios.post(API_URL + 'web/manager/trash/owner/deleteAll', status, { headers: authHeader() });405 }406 importOwner(data) {407 return axios.post(API_URL + 'web/manager/owner_import_csv', data, { headers: authHeader() });408 }409 exportOwner(data) {410 return axios.post(API_URL + 'web/manager/owner_export_csv', data, { headers: authHeader() ,responseType: 'blob'});411 }412 //Team Part413 getTeamMemberList(data) {414 return axios.post(API_URL + 'web/manager/teamList', data, { headers: authHeader() });415 }416 createTeamMember(data) {417 return axios.post(API_URL + 'web/manager/team', data, { headers: authHeader() });418 }419 updateTeamMember(id, data) {420 return axios.put(API_URL + 'web/manager/team/' + id, data, { headers: authHeader() });421 }422 getTeamMember(id) {423 return axios.get(API_URL + 'web/manager/team/' + id, { headers: authHeader() });424 }425 setSuspendTeamMember(id, data) {426 return axios.put(API_URL + 'web/manager/team/' + id + '/status', data, { headers: authHeader() });427 }428 deleteTeamMember(id, status) {429 return axios.post(API_URL + 'web/manager/team/' + id + '/delete', status, { headers: authHeader() });430 }431 emptyTrashTeamMember(status) {432 return axios.post(API_URL + 'web/manager/trash/team/deleteAll', status, { headers: authHeader() });433 }434 //Common435 getCompanyListByUser() {436 return axios.get(API_URL + 'web/manager/companyListByUser', { headers: authHeader() });437 }438 getBuildingListByCompany(data) {439 return axios.post(API_URL + 'web/manager/owner_building_list', data, { headers: authHeader() });440 }441 //PaymentMethod Part442 //Card Part443 getCardList(data) {444 return axios.post(API_URL + 'web/manager/cardList', data, { headers: authHeader() });445 }446 createCard(data) {447 return axios.post(API_URL + 'web/manager/card', data, { headers: authHeader() });448 }449 updateCard(id, data) {450 return axios.put(API_URL + 'web/manager/card/' + id, data, { headers: authHeader() });451 }452 getCard(id) {453 return axios.get(API_URL + 'web/manager/card/' + id, { headers: authHeader() });454 }455 deleteCard(id) {456 return axios.delete(API_URL + 'web/manager/card/' + id, { headers: authHeader() });457 }458 //Bank Information Part459 updateBankInfo(id, data) {460 return axios.put(API_URL + 'web/manager/building/' + id + '/bank', data, { headers: authHeader() });461 }462 updateCompanyBankInfo(data) {463 return axios.put(API_URL + 'web/manager/bank', data, { headers: authHeader() });464 }465 //Event Part466 getEventList(data) {467 return axios.post(API_URL + 'web/manager/eventList', data, { headers: authHeader() });468 }469 createEvent(data) {470 return axios.post(API_URL + 'web/manager/event', data, { headers: authHeader() });471 }472 updateEvent(id, data) {473 return axios.put(API_URL + 'web/manager/event/' + id, data, { headers: authHeader() });474 }475 getEvent(id) {476 return axios.get(API_URL + 'web/manager/event/' + id, { headers: authHeader() });477 }478 deleteEvent(id, status) {479 return axios.post(API_URL + 'web/manager/event/' + id + '/delete', status, { headers: authHeader() });480 }481 emptyTrashEvent(status) {482 return axios.post(API_URL + 'web/manager/trash/event/deleteAll', status, { headers: authHeader() });483 }484 //Provider Part485 getProviderList(data) {486 return axios.post(API_URL + 'web/manager/providerList', data, { headers: authHeader() });487 }488 createProvider(data) {489 return axios.post(API_URL + 'web/manager/provider', data, { headers: authHeader() });490 }491 updateProvider(id, data) {492 return axios.put(API_URL + 'web/manager/provider/' + id, data, { headers: authHeader() });493 }494 getProvider(id) {495 return axios.get(API_URL + 'web/manager/provider/' + id, { headers: authHeader() });496 }497 deleteProvider(id, status) {498 return axios.post(API_URL + 'web/manager/provider/' + id + '/delete', status, { headers: authHeader() });499 }500 emptyTrashProvider(status) {501 return axios.post(API_URL + 'web/manager/trash/provider/deleteAll', status, { headers: authHeader() });502 }503 ///Decision Part504 getDecisionList(id, data) {505 return axios.post(API_URL + 'web/manager/assembly/DecisionList/' + id, data, { headers: authHeader() });506 }507 createDecision(data) {508 return axios.post(API_URL + 'web/manager/assembly/Decision', data, { headers: authHeader() });509 }510 updateDecision(id, data) {511 return axios.put(API_URL + 'web/manager/assembly/Decision/' + id, data, { headers: authHeader() });512 }513 getDecision(id) {514 return axios.get(API_URL + 'web/manager/assembly/Decision/' + id, { headers: authHeader() });515 }516 importAssemblyDecisions(data) {517 return axios.post(API_URL + 'web/manager/assembly/Decision/import_csv', data, { headers: authHeader() });518 }519 exportAssemblyDecisions(data) {520 return axios.post(API_URL + 'web/manager/assembly/Decision/export_csv', data, { headers: authHeader() ,responseType: 'blob'});521 }522 523 deleteDecision(id) {524 return axios.delete(API_URL + 'web/manager/assembly/Decision/' + id, { headers: authHeader() });525 }526 emptyTrashDecision(status) {527 return axios.post(API_URL + 'web/manager/assembly/Decision/deleteAll', status, { headers: authHeader() });528 }529 ///PostalVote Part530 getOwnerListForVote() {531 return axios.get(API_URL + 'web/manager/assembly/postalVote/OwnerList', { headers: authHeader() });532 }533 getPostalVoteList(data) {534 return axios.post(API_URL + 'web/manager/assembly/postalVoteList', data, { headers: authHeader() });535 }536 createPostalVote(data) {537 return axios.post(API_URL + 'web/manager/assembly/postalVote', data, { headers: authHeader() });538 }539 getPostalVoteDetail(id, data) {540 return axios.post(API_URL + 'web/manager/assembly/postalVoteDetail/' + id, data, { headers: authHeader() });541 }542 deletePostalVote(id, data) {543 return axios.post(API_URL + 'web/manager/assembly/postalVote/' + id, data, { headers: authHeader() });544 }545 emptyTrashPostalVotes(status) {546 return axios.post(API_URL + 'web/manager/assembly/postalVote/deleteAll', status, { headers: authHeader() });547 }548 //Assembly Part549 createAssembly(data) {550 return axios.post(API_URL + 'web/manager/assembly', data, { headers: authHeader() });551 }552 getAssemblyList(data) {553 return axios.post(API_URL + 'web/manager/assemblyList', data, { headers: authHeader() });554 }555 deleteAssembly(id) {556 return axios.delete(API_URL + 'web/manager/assembly/' + id, { headers: authHeader() });557 }558 getAssembly(id) {559 return axios.get(API_URL + 'web/manager/assembly/' + id, { headers: authHeader() });560 }561 updateAssembly(id, data) {562 return axios.put(API_URL + 'web/manager/assembly/' + id, data, { headers: authHeader() });563 }564 exportAssembly(data) {565 return axios.post(API_URL + 'web/manager/assembly/export_csv', data, { headers: authHeader() ,responseType: 'blob'});566 }567 importAssembly(data) {568 return axios.post(API_URL + 'web/manager/assembly/import_csv', data, { headers: authHeader() });569 }570 //Document Part571 createAssemblyFile(data) {572 return axios.post(API_URL + 'web/manager/assembly/File', data, { headers: authHeader() });573 }574 getAssemblyFiles(id) {575 return axios.get(API_URL + 'web/manager/assembly/FileList/' + id, { headers: authHeader() });576 }577 deleteAssemblyFile(id) {578 return axios.delete(API_URL + 'web/manager/assembly/File/' + id, { headers: authHeader() });579 }580}...

Full Screen

Full Screen

auth.js

Source:auth.js Github

copy

Full Screen

1'use strict'2var caseless = require('caseless')3var uuid = require('uuid/v4')4var helpers = require('./helpers')5var md5 = helpers.md56var toBase64 = helpers.toBase647function Auth (request) {8 // define all public properties here9 this.request = request10 this.hasAuth = false11 this.sentAuth = false12 this.bearerToken = null13 this.user = null14 this.pass = null15}16Auth.prototype.basic = function (user, pass, sendImmediately) {17 var self = this18 if (typeof user !== 'string' || (pass !== undefined && typeof pass !== 'string')) {19 self.request.emit('error', new Error('auth() received invalid user or password'))20 }21 self.user = user22 self.pass = pass23 self.hasAuth = true24 var header = user + ':' + (pass || '')25 if (sendImmediately || typeof sendImmediately === 'undefined') {26 var authHeader = 'Basic ' + toBase64(header)27 self.sentAuth = true28 return authHeader29 }30}31Auth.prototype.bearer = function (bearer, sendImmediately) {32 var self = this33 self.bearerToken = bearer34 self.hasAuth = true35 if (sendImmediately || typeof sendImmediately === 'undefined') {36 if (typeof bearer === 'function') {37 bearer = bearer()38 }39 var authHeader = 'Bearer ' + (bearer || '')40 self.sentAuth = true41 return authHeader42 }43}44Auth.prototype.digest = function (method, path, authHeader) {45 // TODO: More complete implementation of RFC 2617.46 // - handle challenge.domain47 // - support qop="auth-int" only48 // - handle Authentication-Info (not necessarily?)49 // - check challenge.stale (not necessarily?)50 // - increase nc (not necessarily?)51 // For reference:52 // http://tools.ietf.org/html/rfc2617#section-353 // https://github.com/bagder/curl/blob/master/lib/http_digest.c54 var self = this55 var challenge = {}56 var re = /([a-z0-9_-]+)=(?:"([^"]+)"|([a-z0-9_-]+))/gi57 while (true) {58 var match = re.exec(authHeader)59 if (!match) {60 break61 }62 challenge[match[1]] = match[2] || match[3]63 }64 /**65 * RFC 2617: handle both MD5 and MD5-sess algorithms.66 *67 * If the algorithm directive's value is "MD5" or unspecified, then HA1 is68 * HA1=MD5(username:realm:password)69 * If the algorithm directive's value is "MD5-sess", then HA1 is70 * HA1=MD5(MD5(username:realm:password):nonce:cnonce)71 */72 var ha1Compute = function (algorithm, user, realm, pass, nonce, cnonce) {73 var ha1 = md5(user + ':' + realm + ':' + pass)74 if (algorithm && algorithm.toLowerCase() === 'md5-sess') {75 return md5(ha1 + ':' + nonce + ':' + cnonce)76 } else {77 return ha178 }79 }80 var qop = /(^|,)\s*auth\s*($|,)/.test(challenge.qop) && 'auth'81 var nc = qop && '00000001'82 var cnonce = qop && uuid().replace(/-/g, '')83 var ha1 = ha1Compute(challenge.algorithm, self.user, challenge.realm, self.pass, challenge.nonce, cnonce)84 var ha2 = md5(method + ':' + path)85 var digestResponse = qop86 ? md5(ha1 + ':' + challenge.nonce + ':' + nc + ':' + cnonce + ':' + qop + ':' + ha2)87 : md5(ha1 + ':' + challenge.nonce + ':' + ha2)88 var authValues = {89 username: self.user,90 realm: challenge.realm,91 nonce: challenge.nonce,92 uri: path,93 qop: qop,94 response: digestResponse,95 nc: nc,96 cnonce: cnonce,97 algorithm: challenge.algorithm,98 opaque: challenge.opaque99 }100 authHeader = []101 for (var k in authValues) {102 if (authValues[k]) {103 if (k === 'qop' || k === 'nc' || k === 'algorithm') {104 authHeader.push(k + '=' + authValues[k])105 } else {106 authHeader.push(k + '="' + authValues[k] + '"')107 }108 }109 }110 authHeader = 'Digest ' + authHeader.join(', ')111 self.sentAuth = true112 return authHeader113}114Auth.prototype.onRequest = function (user, pass, sendImmediately, bearer) {115 var self = this116 var request = self.request117 var authHeader118 if (bearer === undefined && user === undefined) {119 self.request.emit('error', new Error('no auth mechanism defined'))120 } else if (bearer !== undefined) {121 authHeader = self.bearer(bearer, sendImmediately)122 } else {123 authHeader = self.basic(user, pass, sendImmediately)124 }125 if (authHeader) {126 request.setHeader('authorization', authHeader)127 }128}129Auth.prototype.onResponse = function (response) {130 var self = this131 var request = self.request132 if (!self.hasAuth || self.sentAuth) { return null }133 var c = caseless(response.headers)134 var authHeader = c.get('www-authenticate')135 var authVerb = authHeader && authHeader.split(' ')[0].toLowerCase()136 request.debug('reauth', authVerb)137 switch (authVerb) {138 case 'basic':139 return self.basic(self.user, self.pass, true)140 case 'bearer':141 return self.bearer(self.bearerToken, true)142 case 'digest':143 return self.digest(request.method, request.path, authHeader)144 }145}...

Full Screen

Full Screen

TutorialService.js

Source:TutorialService.js Github

copy

Full Screen

1import http from "../http-common";2import authHeader from "./auth-header";3const addCard = data => {4 let r = http.post("/tutorials/addcard", data, { headers: authHeader() });5 return r;6};7const getCards = tutorialId => {8 return http.get(`/tutorials/getcards/${tutorialId}`, { headers: authHeader() });9};10const updateCardPublishStatus = (tutorialId, data) => {11 return http.put(`/tutorials/updatecardpublishstatus/${tutorialId}`, data, { headers: authHeader() });12};13const updateCard = (tutorialId, data) => {14 return http.put(`/tutorials/updatecard/${tutorialId}`, data, { headers: authHeader() });15};16const deleteCard = (cardId, params) => {17 return http.delete(`/tutorials/deletecard/` + cardId, { headers: authHeader(), params:params });18};19const getAll = (params) => {20 let r = http.get("/tutorials", { headers: authHeader(), params:params});21 return r;22};23const getMy = (params) => {24 let r = http.get("/tutorials/my", { headers: authHeader(), params:params});25 return r;26};27const get = id => {28 return http.get(`/tutorials/${id}`, { headers: authHeader() });29};30const create = data => {31 return http.post("/tutorials", data, { headers: authHeader() });32};33const updateOrder = (id, data) => {34 return http.put(`/tutorials/updateorder/${id}`, data, { headers: authHeader() });35};36const update = (id, data) => {37 return http.put(`/tutorials/${id}`, data, { headers: authHeader() });38};39const publish = (id, data) => {40 return http.put(`/tutorials/publish/${id}`, data, { headers: authHeader() });41};42const distribute = () => {43 return http.get(`/tutorials/distribute`, { headers: authHeader() });44};45const deleteTutorial = id => {46 return http.delete(`/tutorials/${id}`, { headers: authHeader() });47};48const findByTitle = params => {49 return http.get(`/tutorials`, { headers: authHeader(), params:params});50};51const findMyByTitle = (params) => {52 let r = http.get("/tutorials/my", { headers: authHeader(), params:params});53 return r;54}55const getCategories = () => {56 return http.get(`/tutorials/getcategories`, { headers: authHeader() });57}58const createCategory = (data) => {59 return http.post(`/tutorials/createcategory`, data, { headers: authHeader() });60}61const deleteCategory = (data) => {62 return http.post(`/tutorials/deletecategory`, data, { headers: authHeader() });63}64const updateCategory = (data) => {65 return http.put(`/tutorials/updatecategory`, data, { headers: authHeader() });66}67const deployCategoriesJson = () => {68 return http.get(`/tutorials/deploycategoriesjson`, { headers: authHeader() });69}70const getCategoriesJson = () => {71 return http.get(`/tutorials/getcategoriesjson`, { headers: authHeader() });72}73const getHintCategoryArr = () => {74 return http.get(`/tutorials/gethintcategoryarr`, { headers: authHeader(), params: {} })75}76const backupDb = () => {77 return http.get(`/tutorials/backupdb`, { headers: authHeader(), params: {} })78}79const importDb = () => {80 return http.get(`/tutorials/importdb`, { headers: authHeader(), params: {} })81}82let obj = {83 backupDb,84 importDb,85 getCategoriesJson,86 deployCategoriesJson,87 deleteCategory,88 updateCategory,89 createCategory,90 getCategories,91 getAll,92 get,93 getMy,94 create,...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var authHeader = require('argos-sdk/src/SecurityManager').authHeader;2var getAuthHeader = require('argos-sdk/src/SecurityManager').getAuthHeader;3var SecurityManager = require('argos-sdk/src/SecurityManager');4var authHeader = SecurityManager.authHeader;5var getAuthHeader = SecurityManager.getAuthHeader;6var authHeader = require('argos-sdk/src/SecurityManager').authHeader;7var getAuthHeader = require('argos-sdk/src/SecurityManager').getAuthHeader;8var SecurityManager = require('argos-sdk/src/SecurityManager');9var authHeader = SecurityManager.authHeader;10var getAuthHeader = SecurityManager.getAuthHeader;11var authHeader = require('argos-sdk/src/SecurityManager').authHeader;12var getAuthHeader = require('argos-sdk/src/SecurityManager').getAuthHeader;13var SecurityManager = require('argos-sdk/src/SecurityManager');14var authHeader = SecurityManager.authHeader;15var getAuthHeader = SecurityManager.getAuthHeader;16var authHeader = require('argos-sdk/src/SecurityManager').authHeader;17var getAuthHeader = require('argos-sdk/src/SecurityManager').getAuthHeader;18var SecurityManager = require('argos-sdk/src/SecurityManager');19var authHeader = SecurityManager.authHeader;20var getAuthHeader = SecurityManager.getAuthHeader;21var authHeader = require('argos-sdk/src/SecurityManager').authHeader;22var getAuthHeader = require('argos-sdk/src

Full Screen

Using AI Code Generation

copy

Full Screen

1var sdk = require('argos-sdk');2var authHeader = sdk.authHeader;3var request = require('request');4var sdk = require('argos-sdk');5var authHeader = sdk.authHeader;6var request = require('request');7var sdk = require('argos-sdk');8var authHeader = sdk.authHeader;9var request = require('request');10var sdk = require('argos-sdk');11var authHeader = sdk.authHeader;12var request = require('request');13var sdk = require('argos-sdk');14var authHeader = sdk.authHeader;15var request = require('request');16var sdk = require('argos-sdk');17var authHeader = sdk.authHeader;18var request = require('request');19var sdk = require('argos-sdk');20var authHeader = sdk.authHeader;21var request = require('request');22var sdk = require('argos-sdk');23var authHeader = sdk.authHeader;24var request = require('request');25var sdk = require('argos-sdk');26var authHeader = sdk.authHeader;27var request = require('request');28var sdk = require('argos-sdk');29var authHeader = sdk.authHeader;30var request = require('request');31var sdk = require('argos-sdk');32var authHeader = sdk.authHeader;33var request = require('request');34var sdk = require('argos-sdk');35var authHeader = sdk.authHeader;36var request = require('request');37var sdk = require('argos-sdk');38var authHeader = sdk.authHeader;39var request = require('request');40var sdk = require('argos-sdk');41var authHeader = sdk.authHeader;42var request = require('request');

Full Screen

Using AI Code Generation

copy

Full Screen

1var authHeader = require('argosy-auth').authHeader2var argosy = require('argosy')3var seneca = require('seneca')()4var auth = argosy({5})6auth.pipe(authHeader()).pipe(auth)7var authHeader = require('argosy-auth').authHeader8var argosy = require('argosy')9var seneca = require('seneca')()10var auth = argosy({11})12auth.pipe(authHeader()).pipe(auth)13var authHeader = require('argosy-auth').authHeader14var argosy = require('argosy')15var seneca = require('seneca')()16var auth = argosy({17})18auth.pipe(authHeader()).pipe(auth)19var authHeader = require('argosy-auth').authHeader20var argosy = require('argosy')21var seneca = require('seneca')()22var auth = argosy({23})24auth.pipe(authHeader()).pipe(auth)25var authHeader = require('argosy-auth').authHeader26var argosy = require('argosy')27var seneca = require('seneca')()28var auth = argosy({29})30auth.pipe(authHeader()).pipe(auth)31var authHeader = require('argosy-auth').authHeader32var argosy = require('argosy')33var seneca = require('seneca')()34var auth = argosy({35})36auth.pipe(authHeader()).pipe(auth)37var authHeader = require('argosy-auth').authHeader38var argosy = require('argosy')39var seneca = require('seneca')()40var auth = argosy({41})42auth.pipe(authHeader()).pipe(auth)

Full Screen

Using AI Code Generation

copy

Full Screen

1var authHeader = require('argos-sdk/src/SDK/AuthHeader');2var authHeader = require('argos-sdk/src/SDK/AuthHeader');3var xhr = new XMLHttpRequest();4xhr.setRequestHeader('Authorization', authHeader());5xhr.send();6var authHeader = require('argos-sdk/src/SDK/AuthHeader');7var xhr = new XMLHttpRequest();8xhr.setRequestHeader('Authorization', authHeader());9xhr.send();

Full Screen

Using AI Code Generation

copy

Full Screen

1var authHeader = require('argos-sdk/src/SDK/authHeader');2var AuthManager = require('argos-sdk/src/SDK/AuthManager');3var authHeader = require('argos-sdk/src/SDK/authHeader');4var AuthManager = require('argos-sdk/src/SDK/AuthManager');5var authHeader = require('argos-sdk/src/SDK/authHeader');6var AuthManager = require('argos-sdk/src/SDK/AuthManager');7var authHeader = require('argos-sdk/src/SDK/authHeader');8var AuthManager = require('argos-sdk/src/SDK/AuthManager');9var authHeader = require('argos-sdk/src/SDK/authHeader');10var AuthManager = require('argos-sdk/src/SDK/AuthManager');11var authHeader = require('argos-sdk/src/SDK/authHeader');12var AuthManager = require('argos-sdk/src/SDK/AuthManager');13var authHeader = require('argos-sdk/src/SDK/authHeader');14var AuthManager = require('argos-sdk/src/SDK/AuthManager');15var authHeader = require('argos-sdk/src/SDK/authHeader');16var AuthManager = require('argos-sdk/src/SDK/AuthManager');17var authHeader = require('argos-sdk/src/SDK/authHeader');18var AuthManager = require('argos-sdk/src/SDK/AuthManager');19var authHeader = require('argos-sdk/src/SDK/authHeader');

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run argos automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful