UNPKG

vue-auth3

Version:

<p align="center"> <img src="./docs/public/icon.svg" width="180px"> </p>

51 lines (50 loc) 1.28 kB
import { defineAuthDriver } from "../../chunk-T4OYN7ZE.mjs"; import "../../chunk-MI2N2CU6.mjs"; // src/drivers/auth/devise.ts var devise_default = defineAuthDriver({ tokens: [ "Token-Type", "Access-Token", "Client", "Uid", "Expiry", "token-type", "access-token", "client", "uid", "expiry" ], request(auth, options, token) { var _a; const headers = {}, tokens = token.split("|"); (_a = auth.options.drivers.auth.tokens) == null ? void 0 : _a.forEach((tokenName, index) => { if (tokens[index]) { headers[tokenName] = tokens[index]; } }); Object.assign(options.headers, headers); return options; }, response(auth, { headers }) { var _a; const token = []; if (headers["access-token"] || headers["Access-Token"]) { (_a = auth.options.drivers.auth.tokens) == null ? void 0 : _a.forEach((tokenName) => { if (headers[tokenName]) { token.push(headers[tokenName]); } }); const tokenNow = auth.token(); if (!tokenNow || parseInt(token[4], 10) >= parseInt(tokenNow.split("|")[4], 10)) { return token.join("|"); } } return null; } }); export { devise_default as default }; //# sourceMappingURL=devise.mjs.map