Skip to content

Commit

Permalink
chore(release): set package.json to 1.0.0 [skip ci]
Browse files Browse the repository at this point in the history
# 1.0.0 (2022-07-20)

### Features

* initial version ([d7b740d](d7b740d))
  • Loading branch information
semantic-release-bot committed Jul 20, 2022
1 parent af459e1 commit e044485
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# 1.0.0 (2022-07-20)


### Features

* initial version ([d7b740d](https://github.com/jozefhruska/next-auth-swr/commit/d7b740d03375f756ca367274725a7a6e8fe48964))
1 change: 1 addition & 0 deletions dist/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"use strict";var U=Object.create;var c=Object.defineProperty,g=Object.defineProperties,x=Object.getOwnPropertyDescriptor,W=Object.getOwnPropertyDescriptors,b=Object.getOwnPropertyNames,l=Object.getOwnPropertySymbols,d=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var a=(n,s,e)=>s in n?c(n,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[s]=e,R=(n,s)=>{for(var e in s||(s={}))p.call(s,e)&&a(n,e,s[e]);if(l)for(var e of l(s))E.call(s,e)&&a(n,e,s[e]);return n},O=(n,s)=>g(n,W(s));var j=(n,s)=>{for(var e in s)c(n,e,{get:s[e],enumerable:!0})},m=(n,s,e,o)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of b(s))!p.call(n,i)&&i!==e&&c(n,i,{get:()=>s[i],enumerable:!(o=x(s,i))||o.enumerable});return n};var P=(n,s,e)=>(e=n!=null?U(d(n)):{},m(s||!n||!n.__esModule?c(e,"default",{value:n,enumerable:!0}):e,n)),k=n=>m(c({},"__esModule",{value:!0}),n);var h=(n,s,e)=>new Promise((o,i)=>{var r=t=>{try{f(e.next(t))}catch(S){i(S)}},u=t=>{try{f(e.throw(t))}catch(S){i(S)}},f=t=>t.done?o(t.value):Promise.resolve(t.value).then(r,u);f((e=e.apply(n,s)).next())});var z={};j(z,{useSession:()=>v});module.exports=k(z);var y=P(require("swr")),q=n=>fetch(n).then(s=>h(void 0,null,function*(){let e=yield s.json();return Object.keys(e).length?e:null})),v=n=>{let{required:s,onUnauthenticated:e,config:o}=n!=null?n:{};return(0,y.default)("/api/auth/session",q,O(R({},o),{onSuccess:(i,r,u)=>{typeof(o==null?void 0:o.onSuccess)=="function"&&o.onSuccess(i,r,u),!(s&&!i)&&typeof e=="function"&&e()},onError:(i,r,u)=>{typeof(o==null?void 0:o.onError)=="function"&&o.onError(i,r,u),!(s&&!i)&&typeof e=="function"&&e()}}))};
8 changes: 8 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Session } from 'next-auth';
import { SWRConfiguration, SWRResponse } from 'swr';
import { UseSessionOptions as OriginalUseSessionOptions } from 'next-auth/react';
export interface UseSessionOptions<R extends boolean> extends Partial<OriginalUseSessionOptions<R>> {
config?: SWRConfiguration<Session | null>;
}
export declare const useSession: <R extends boolean>(options?: UseSessionOptions<R> | undefined) => SWRResponse<Session | null>;
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var O=Object.defineProperty,m=Object.defineProperties;var h=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var y=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var l=(s,e,n)=>e in s?O(s,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[e]=n,a=(s,e)=>{for(var n in e||(e={}))y.call(e,n)&&l(s,n,e[n]);if(S)for(var n of S(e))U.call(e,n)&&l(s,n,e[n]);return s},p=(s,e)=>m(s,h(e));var R=(s,e,n)=>new Promise((o,i)=>{var r=t=>{try{c(n.next(t))}catch(f){i(f)}},u=t=>{try{c(n.throw(t))}catch(f){i(f)}},c=t=>t.done?o(t.value):Promise.resolve(t.value).then(r,u);c((n=n.apply(s,e)).next())});import g from"swr";var x=s=>fetch(s).then(e=>R(void 0,null,function*(){let n=yield e.json();return Object.keys(n).length?n:null})),j=s=>{let{required:e,onUnauthenticated:n,config:o}=s!=null?s:{};return g("/api/auth/session",x,p(a({},o),{onSuccess:(i,r,u)=>{typeof(o==null?void 0:o.onSuccess)=="function"&&o.onSuccess(i,r,u),!(e&&!i)&&typeof n=="function"&&n()},onError:(i,r,u)=>{typeof(o==null?void 0:o.onError)=="function"&&o.onError(i,r,u),!(e&&!i)&&typeof n=="function"&&n()}}))};export{j as useSession};
//# sourceMappingURL=index.mjs.map
7 changes: 7 additions & 0 deletions dist/index.mjs.map
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../src/index.ts"],
"sourcesContent": ["import { Session } from 'next-auth';\nimport useSWR, { SWRConfiguration, SWRResponse } from 'swr';\nimport { UseSessionOptions as OriginalUseSessionOptions } from 'next-auth/react';\n\nconst fetcher = (url: string): Promise<Session | null> => {\n return fetch(url).then(async (response) => {\n const session = await response.json();\n\n if (Object.keys(session).length) {\n return session;\n }\n\n return null;\n });\n};\n\nexport interface UseSessionOptions<R extends boolean>\n extends Partial<OriginalUseSessionOptions<R>> {\n config?: SWRConfiguration<Session | null>;\n}\n\nexport const useSession = <R extends boolean>(\n options?: UseSessionOptions<R>\n): SWRResponse<Session | null> => {\n const { required, onUnauthenticated, config: swrConfig } = options ?? {};\n\n return useSWR<Session | null>('/api/auth/session', fetcher, {\n ...swrConfig,\n onSuccess: (data, key, config) => {\n if (typeof swrConfig?.onSuccess === 'function') {\n swrConfig.onSuccess(data, key, config);\n }\n\n if (required && !data) {\n return;\n }\n\n if (typeof onUnauthenticated === 'function') {\n onUnauthenticated();\n }\n },\n onError: (data, key, config) => {\n if (typeof swrConfig?.onError === 'function') {\n swrConfig.onError(data, key, config);\n }\n\n if (required && !data) {\n return;\n }\n\n if (typeof onUnauthenticated === 'function') {\n onUnauthenticated();\n }\n },\n });\n};\n"],
"mappings": "0nBACA,mBAGA,GAAM,GAAU,AAAC,GACR,MAAM,CAAG,EAAE,KAAK,AAAO,GAAa,0BACzC,GAAM,GAAU,KAAM,GAAS,KAAK,EAEpC,MAAI,QAAO,KAAK,CAAO,EAAE,OAChB,EAGF,IACT,EAAC,EAQU,EAAa,AACxB,GACgC,CAChC,GAAM,CAAE,WAAU,oBAAmB,OAAQ,GAAc,UAAW,CAAC,EAEvE,MAAO,GAAuB,oBAAqB,EAAS,OACvD,GADuD,CAE1D,UAAW,CAAC,EAAM,EAAK,IAAW,CAKhC,AAJI,MAAO,kBAAW,YAAc,YAClC,EAAU,UAAU,EAAM,EAAK,CAAM,EAGnC,KAAY,CAAC,IAIb,MAAO,IAAsB,YAC/B,EAAkB,CAEtB,EACA,QAAS,CAAC,EAAM,EAAK,IAAW,CAK9B,AAJI,MAAO,kBAAW,UAAY,YAChC,EAAU,QAAQ,EAAM,EAAK,CAAM,EAGjC,KAAY,CAAC,IAIb,MAAO,IAAsB,YAC/B,EAAkB,CAEtB,CACF,EAAC,CACH",
"names": []
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-auth-swr",
"version": "0.0.1",
"version": "1.0.0",
"description": "An SWR-powered alternative to NextAuth.js built-in client",
"license": "MIT",
"author": "Jozef Hruška <[email protected]>",
Expand Down

0 comments on commit e044485

Please sign in to comment.