next-tinacms-github
Advanced tools
Comparing version 0.0.1 to 0.0.2-a
@@ -1,2 +0,18 @@ | ||
declare const _default: (clientId: string, secret: string) => (req: any, res: any) => void; | ||
export default _default; | ||
/** | ||
Copyright 2019 Forestry.io Inc | ||
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. | ||
*/ | ||
export declare const createCreateAccessTokenFn: (clientId: string, secret: string) => (req: any, res: any) => void; |
@@ -1,2 +0,18 @@ | ||
declare const _default: (req: any, res: any) => void; | ||
export default _default; | ||
/** | ||
Copyright 2019 Forestry.io Inc | ||
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. | ||
*/ | ||
export declare const proxy: (req: any, res: any) => void; |
'use strict'; | ||
require('cookie'); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var cookie = require('cookie'); | ||
/** | ||
Copyright 2019 Forestry.io Inc | ||
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 createPreviewFn = function createPreviewFn(forkCookieKey, headBranchCookieKey, githubAccessTokenCookieKey) { | ||
return function (req, res) { | ||
var previewData = { | ||
fork_full_name: req.cookies[forkCookieKey], | ||
github_access_token: req.cookies[githubAccessTokenCookieKey], | ||
head_branch: req.cookies[headBranchCookieKey] || 'master' | ||
}; | ||
res.setPreviewData(previewData); | ||
res.status(200).end(); | ||
}; | ||
}; | ||
/** | ||
Copyright 2019 Forestry.io Inc | ||
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 qs = | ||
/*#__PURE__*/ | ||
require('qs'); | ||
var axios = | ||
/*#__PURE__*/ | ||
require('axios'); | ||
var createCreateAccessTokenFn = function createCreateAccessTokenFn(clientId, secret) { | ||
return function (req, res) { | ||
createAccessToken(clientId, secret, req.query.code, req.query.state).then(function (tokenResp) { | ||
var _qs$parse = qs.parse(tokenResp.data), | ||
access_token = _qs$parse.access_token, | ||
error = _qs$parse.error; | ||
if (error) { | ||
res.status(400).json({ | ||
error: error | ||
}); | ||
} else { | ||
res.setHeader('Set-Cookie', cookie.serialize('github_access_token', access_token, { | ||
path: '/', | ||
httpOnly: true | ||
})); | ||
res.status(200).json({}); | ||
} | ||
}); | ||
}; | ||
}; | ||
var createAccessToken = function createAccessToken(clientId, clientSecret, code, state) { | ||
return axios.post("https://github.com/login/oauth/access_token", qs.stringify({ | ||
client_id: clientId, | ||
client_secret: clientSecret, | ||
code: code, | ||
state: state | ||
})); | ||
}; | ||
exports.createCreateAccessTokenFn = createCreateAccessTokenFn; | ||
exports.createPreviewFn = createPreviewFn; | ||
//# sourceMappingURL=next-tinacms-github.cjs.development.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";require("cookie"); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("cookie"),t=require("qs"),r=require("axios");exports.createCreateAccessTokenFn=function(s,o){return function(n,c){(function(e,s,o,n){return r.post("https://github.com/login/oauth/access_token",t.stringify({client_id:e,client_secret:s,code:o,state:n}))})(s,o,n.query.code,n.query.state).then((function(r){var s=t.parse(r.data),o=s.access_token,n=s.error;n?c.status(400).json({error:n}):(c.setHeader("Set-Cookie",e.serialize("github_access_token",o,{path:"/",httpOnly:!0})),c.status(200).json({}))}))}},exports.createPreviewFn=function(e,t,r){return function(s,o){o.setPreviewData({fork_full_name:s.cookies[e],github_access_token:s.cookies[r],head_branch:s.cookies[t]||"master"}),o.status(200).end()}}; | ||
//# sourceMappingURL=next-tinacms-github.cjs.production.min.js.map |
@@ -1,2 +0,88 @@ | ||
import 'cookie'; | ||
import { serialize } from 'cookie'; | ||
/** | ||
Copyright 2019 Forestry.io Inc | ||
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 createPreviewFn = function createPreviewFn(forkCookieKey, headBranchCookieKey, githubAccessTokenCookieKey) { | ||
return function (req, res) { | ||
var previewData = { | ||
fork_full_name: req.cookies[forkCookieKey], | ||
github_access_token: req.cookies[githubAccessTokenCookieKey], | ||
head_branch: req.cookies[headBranchCookieKey] || 'master' | ||
}; | ||
res.setPreviewData(previewData); | ||
res.status(200).end(); | ||
}; | ||
}; | ||
/** | ||
Copyright 2019 Forestry.io Inc | ||
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 qs = | ||
/*#__PURE__*/ | ||
require('qs'); | ||
var axios = | ||
/*#__PURE__*/ | ||
require('axios'); | ||
var createCreateAccessTokenFn = function createCreateAccessTokenFn(clientId, secret) { | ||
return function (req, res) { | ||
createAccessToken(clientId, secret, req.query.code, req.query.state).then(function (tokenResp) { | ||
var _qs$parse = qs.parse(tokenResp.data), | ||
access_token = _qs$parse.access_token, | ||
error = _qs$parse.error; | ||
if (error) { | ||
res.status(400).json({ | ||
error: error | ||
}); | ||
} else { | ||
res.setHeader('Set-Cookie', serialize('github_access_token', access_token, { | ||
path: '/', | ||
httpOnly: true | ||
})); | ||
res.status(200).json({}); | ||
} | ||
}); | ||
}; | ||
}; | ||
var createAccessToken = function createAccessToken(clientId, clientSecret, code, state) { | ||
return axios.post("https://github.com/login/oauth/access_token", qs.stringify({ | ||
client_id: clientId, | ||
client_secret: clientSecret, | ||
code: code, | ||
state: state | ||
})); | ||
}; | ||
export { createCreateAccessTokenFn, createPreviewFn }; | ||
//# sourceMappingURL=next-tinacms-github.esm.js.map |
@@ -1,2 +0,18 @@ | ||
declare const _default: (req: any, res: any) => void; | ||
export default _default; | ||
/** | ||
Copyright 2019 Forestry.io Inc | ||
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. | ||
*/ | ||
export declare const createPreviewFn: (forkCookieKey: string, headBranchCookieKey: string, githubAccessTokenCookieKey: string) => (req: any, res: any) => void; |
{ | ||
"name": "next-tinacms-github", | ||
"version": "0.0.1", | ||
"version": "0.0.2-a", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -23,3 +23,6 @@ /** | ||
export default (clientId: string, secret: string) => (req: any, res: any) => { | ||
export const createCreateAccessTokenFn = (clientId: string, secret: string) => ( | ||
req: any, | ||
res: any | ||
) => { | ||
createAccessToken(clientId, secret, req.query.code, req.query.state).then( | ||
@@ -26,0 +29,0 @@ (tokenResp: any) => { |
@@ -21,3 +21,3 @@ /** | ||
export default (req: any, res: any) => { | ||
export const proxy = (req: any, res: any) => { | ||
const { headers, ...data } = JSON.parse(req.body) | ||
@@ -24,0 +24,0 @@ |
@@ -19,3 +19,3 @@ /** | ||
export default ( | ||
export const createPreviewFn = ( | ||
forkCookieKey: string, | ||
@@ -22,0 +22,0 @@ headBranchCookieKey: string, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28634
364
18
3