UNPKG

@workfront/cookie

Version:
84 lines (79 loc) 3.01 kB
/** * Copyright 2016 Workfront * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var COOKIE_NAME = 'attask'; /** * Copyright 2016 Workfront * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ function readCookie(name, cookieString) { cookieString = cookieString || document.cookie; var match = cookieString.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)')); if (match) { return decodeURIComponent(match[3]); } } /** * Copyright 2016 Workfront * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ function getSessionID(cookieString) { var cookie = readCookie(COOKIE_NAME, cookieString); if (cookie) { return cookie.split('#')[0]; } } /** * Copyright 2016 Workfront * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ function getXSRFToken(cookieString) { return readCookie('XSRF-TOKEN', cookieString) || undefined; } export { COOKIE_NAME, getSessionID, getXSRFToken, readCookie }; //# sourceMappingURL=workfront-cookie.esm.js.map