Oauth
This commit is contained in:
11
Docs/Vue_ensemble_transcendance.html
Normal file
11
Docs/Vue_ensemble_transcendance.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=5,IE=9" ><![endif]-->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Untitled Diagram</title>
|
||||
<meta charset="utf-8"/>
|
||||
</head>
|
||||
<body><div class="mxgraph" style="max-width:100%;border:1px solid transparent;" data-mxgraph="{"highlight":"#0000ff","nav":true,"resize":true,"toolbar":"zoom layers tags lightbox","edit":"_blank","xml":"<mxfile host=\"www.draw.io\" modified=\"2022-10-31T09:17:07.403Z\" agent=\"5.0 (X11; Ubuntu)\" etag=\"c-fjD9Itp8SMr4AJSRT6\" version=\"20.5.1\"><diagram id=\"6a731a19-8d31-9384-78a2-239565b7b9f0\" name=\"Page-1\">7V1bc9q6Fv41zN7nIYzvl8eEhLYzTdMpyZzdR4EFuDWIbQuSnF9/JFs2tiyIMVgGah4Sa1nWxfrWRUtLck8fLN4+hWA1f0QeDHqa4r319PuepumaoZN/lPKeUFTVNhPKLPQ9RtsSRv7/ICMqjLr2PRgVMmKEAuyvisQJWi7hBBdoIAzRazHbFAXFWldgBkuE0QQEZep/fQ/P025Y7vbGZ+jP5qxqR7OTG2Mw+T0L0XrJ6luiJUzuLEBaDOtjNAcees2R9IeePggRwsnV4m0AA/pe0zeWPDfccTdrcgiXuNIDtmElz2xAsGYdZ03D7+mbgB55MSwZd0a/i7sHaSkKSf1aL1ZchjleBCSlksuskzRrAMYwuMve0AAFKNw+FWEQ4ls6eBxt6AcBKwEuvTTHJABR5E8SIstCa/wFMX5niAJrjAgJhXiOZmgJgq8IrdKW4RD9hmkbegS1Q/POHmR30nHXCWWKlngIFn5A8fwZBhuI/QlgN1hdqsXS+SJ1wzDvaZErMPGXM0I1Sao8UmzwIrQOJzAbHgY28g5mkGUcPt89gZvI+nHzMtMnd+bzzY11o9oOwxQdrVyJbOA/QbSAOHwnGUIYAOxvijAHjFtmWb7s0e/IJ23UFMbats74mDG24WjFIpK2sqe24CMXuWZsSTEkd8LT6eB5YfAkcl4/NRILGNoPGFcAGCsgbbvz/A25nNHL74j0lJFJmbk7JXRtoUSH5HXuYzgir4refSWa7wgs5Qe3QCyMK4GNCAF1x3sY/wgdBP5sSUFKRhiG6YOs32oJECCcsFJtklrB0CeDA8NRlknbh5oNDDF824sFdteylIJ00W02oK85HWyyPPOc+rWVU8AnLbm2vFFly5vawuTBMS1Dqy9MjD3gKmKHRxaH6bECdWhVFzqpeOGEjtWe0DHVDjUXihqzRdRoHWpaQw188/E/LA+9/km72DdZ6v4tteZo4p0lKiIt1WBNG0Vi81xTOAXqcIrxlOZ52qn91tYL9gM/Ahiuw11GV+mZlDQOecpF2WsZ8I+Gecle2497WfYaMcY4uJl9s5rFZp3GYjOrQHCECU9F2P93DSPqlIIUNPHlAuDJPLoSuE0VBzqqZLgpLcLNTD1pksBW9pb9iMU1WkYdNM4LGporFxr2kdbcVXmqVMt1YxQ2bvAdZZRZLXqqzM61eYGA0doDjCXyTZUsnQFdDnsjCukiDZgMBldrL/Pmsi7XXE4BnAPRPVqPA2oQE4adk575U/KmcYygs8aKZYzHUMbcShY2brJxT5fWTKkmjFVpNv9EYfKnzeOvDmtaq8ayZVRSZXOAGwBaeTWQyD9iy2jD7yEhDvTerUsTIKTuAW91JRAeKo6tmBIg3JZqNbjABNWRi+myI+p24VMXEy1EU8YB+nedoOvsfQUmmJLpyRVJO843oEoWd12QlUgQnc1UzxBO9VpcGrREzqSS3nqEUQRmsRd7q7miWNocpPmii9RnVyekeP1lyZVRnTvqAmWU3aKMKkfaDcJEBjHvQbLMNpmD5ZIGh3fSpE1pInmGZ4uclZ04aVycpHEt21iWn71cKIswroWALHzPPUSTP1lX4sT2sTh1aDyMMEg4FWhNx8MYTtGnVsL36eJhdgTm22VBKTLmaBzCI/jtd5HJjUUml6SnAL2VI5O1qs7ZU0Qmf7DnYz+0vkLgwXCMQOh10DpHaJkOF9WingG0jo1pvioFLm/njViBp2Gqhynwrcrep8A5DfyhRv9AzRXVfLIf5+RaPYv7SlfKVKNYRNLgklYvF6RyBWmyzYN0+1wXBn42YeD2/jjwLbsVmI09dnJ+27V3oSHW0rkAcsO00xCFQ5mLL8rU7b6b+zmyWU207PjH6jR5IVd1NlvsYrKmeCwNjKmy09pshPFUXhWZZt/YzS1VmVC1i8VahnQNVylE/xNCs0IY0gRggqtLnLCcY7TIURMULlrEkLk0sQtU3Zrq2cjyqrOT85PkdiOS/EZX+9yM3lH3WT4fyvL2ZHellejR46gT1GcoqKVuj9qFINHCcglBD8+k+KeXiigiLwhzUBGNf360Gak0TvR1k6EObtmNhe95tBohNova4wTjxdlmIsefJRguvcHhqrRa8dmPiHFGt1P2ut2UbW6ZOwp9usvB7wzEhSta0ujcYZLcYTUdyXWc1nXNO5EzbK8suygPmSbbJ+Z27ufz47dqkRenciRbDbGJbfQV21Cyn13kGkXru7ZWj2/49R/N1GTzjWiz1Hnwzda7kGedo/wL18M6dQKkarObJWS3ZtzHuuYWWcJVavIWFzmoW3t9F81zWrdq024oYZ5PKq/ayIhE2AZAS+EwIz3TOuUwTa9t99l2X8n9DC5YV7P6Zu62KpvlRCs2Hcud90KpWmC45tzrwp0IkuJ8VKfmKqjDedoM3oW2g6cIqMB7LtuKZoh2N9jROcNUVfa3i8ufBjJtWTppwakZXLR6VvLy3a6pS480mLr21ss44WUev1+Q3s4ct4rHPICr+IQ1fzpNNoNQOMHL3GJ29YGnNhccbyqCw0hsgQOQP1TylA7A7iCtdgJPj/b92c07/w74HkIi4k6ukWyDj4XgiqiqkfiCTLXd4Di30jrdY6IARis4wXtPdO0Ee5uC3eF3PVU9C6PBHQWuaGXxPDxmf5KnWc4s4YBVmkTwNOB+3jvFNgy17uTdSvfKZ0VpfFFNS2tHOXaZtLOSjrOSuNn2h7H/8pZIP9DvUubtrslxm1LTGe3yBz63ayU5qSuu47v7VsJOz9oZLV5d1ZpRb0VftGFqfduqx2Oqxs1oiDgzZPNVpbCzlLQunfpX6RjAUi5CKxVV+aTB3Y14ef7y9cvo9vnh5cehtVc9vnAd8JTAzyjm3VuP6C5NKXx5g0D7lvydAj+kU7gA9Oi3KiN6vUJxhtjFtxZ+rSNXet364ijB9wjHbkFnkfkRQ8jOxbuN/YQKiE/Nq1ozrWdn3QSXOK4c0p6tAjrh3NOSCBLxGJ9c8/cGJa1O6GSqu8ZxqcP/yG/aX2ADMDhgNOpUTNHg7T4JWHqf+WNmG+ryHBB1O8tGeoFwerkiupL+/xts4IT8jxvUwujnAdhW3Q3z41/zYjhxFkkM91dMBWhODnJmWI0g8cLUvWB/sNRzbAvd0P4InVhoA8NpEBtbc9/zSDcbCBpXFe6caMF2LCOd7uadO9m3lU/v3XFU0YT0UhX44Onbt4d/vjx9O03dHyjrjGVyZ/fLFdaVKz6pqD6ouycV1E0Iju1c6HIEh8gtLJQcfCxZBcFBktsPmScThe2X4vWH/wM=</diagram></mxfile>"}"></div>
|
||||
<script type="text/javascript" src="https://viewer.diagrams.net/js/viewer-static.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
123
package-lock.json
generated
Normal file
123
package-lock.json
generated
Normal file
@@ -0,0 +1,123 @@
|
||||
{
|
||||
"name": "15_ft_transcendence",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"passport-42": "^1.2.6"
|
||||
}
|
||||
},
|
||||
"node_modules/base64url": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz",
|
||||
"integrity": "sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A==",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/oauth": {
|
||||
"version": "0.9.15",
|
||||
"resolved": "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz",
|
||||
"integrity": "sha512-a5ERWK1kh38ExDEfoO6qUHJb32rd7aYmPHuyCu3Fta/cnICvYmgd2uhuKXvPD+PXB+gCEYYEaQdIRAjCOwAKNA=="
|
||||
},
|
||||
"node_modules/passport-42": {
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/passport-42/-/passport-42-1.2.6.tgz",
|
||||
"integrity": "sha512-a1SraWSwH33NqRDe9ScG4MQwfj7RRBYLFtrJySn4tU4Ou7+caLxj6VQgaL4i+eZoKC6QAooL1Nqevn/W8vLXuQ==",
|
||||
"dependencies": {
|
||||
"passport-oauth2": "^1.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-oauth2": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/passport-oauth2/-/passport-oauth2-1.6.1.tgz",
|
||||
"integrity": "sha512-ZbV43Hq9d/SBSYQ22GOiglFsjsD1YY/qdiptA+8ej+9C1dL1TVB+mBE5kDH/D4AJo50+2i8f4bx0vg4/yDDZCQ==",
|
||||
"dependencies": {
|
||||
"base64url": "3.x.x",
|
||||
"oauth": "0.9.x",
|
||||
"passport-strategy": "1.x.x",
|
||||
"uid2": "0.0.x",
|
||||
"utils-merge": "1.x.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/jaredhanson"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-strategy": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz",
|
||||
"integrity": "sha512-CB97UUvDKJde2V0KDWWB3lyf6PC3FaZP7YxZ2G8OAtn9p4HI9j9JLP9qjOGZFvyl8uwNT8qM+hGnz/n16NI7oA==",
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uid2": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/uid2/-/uid2-0.0.4.tgz",
|
||||
"integrity": "sha512-IevTus0SbGwQzYh3+fRsAMTVVPOoIVufzacXcHPmdlle1jUpq7BRL+mw3dgeLanvGZdwwbWhRV6XrcFNdBmjWA=="
|
||||
},
|
||||
"node_modules/utils-merge": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"base64url": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz",
|
||||
"integrity": "sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A=="
|
||||
},
|
||||
"oauth": {
|
||||
"version": "0.9.15",
|
||||
"resolved": "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz",
|
||||
"integrity": "sha512-a5ERWK1kh38ExDEfoO6qUHJb32rd7aYmPHuyCu3Fta/cnICvYmgd2uhuKXvPD+PXB+gCEYYEaQdIRAjCOwAKNA=="
|
||||
},
|
||||
"passport-42": {
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/passport-42/-/passport-42-1.2.6.tgz",
|
||||
"integrity": "sha512-a1SraWSwH33NqRDe9ScG4MQwfj7RRBYLFtrJySn4tU4Ou7+caLxj6VQgaL4i+eZoKC6QAooL1Nqevn/W8vLXuQ==",
|
||||
"requires": {
|
||||
"passport-oauth2": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"passport-oauth2": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/passport-oauth2/-/passport-oauth2-1.6.1.tgz",
|
||||
"integrity": "sha512-ZbV43Hq9d/SBSYQ22GOiglFsjsD1YY/qdiptA+8ej+9C1dL1TVB+mBE5kDH/D4AJo50+2i8f4bx0vg4/yDDZCQ==",
|
||||
"requires": {
|
||||
"base64url": "3.x.x",
|
||||
"oauth": "0.9.x",
|
||||
"passport-strategy": "1.x.x",
|
||||
"uid2": "0.0.x",
|
||||
"utils-merge": "1.x.x"
|
||||
}
|
||||
},
|
||||
"passport-strategy": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz",
|
||||
"integrity": "sha512-CB97UUvDKJde2V0KDWWB3lyf6PC3FaZP7YxZ2G8OAtn9p4HI9j9JLP9qjOGZFvyl8uwNT8qM+hGnz/n16NI7oA=="
|
||||
},
|
||||
"uid2": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/uid2/-/uid2-0.0.4.tgz",
|
||||
"integrity": "sha512-IevTus0SbGwQzYh3+fRsAMTVVPOoIVufzacXcHPmdlle1jUpq7BRL+mw3dgeLanvGZdwwbWhRV6XrcFNdBmjWA=="
|
||||
},
|
||||
"utils-merge": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA=="
|
||||
}
|
||||
}
|
||||
}
|
||||
5
package.json
Normal file
5
package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"passport-42": "^1.2.6"
|
||||
}
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAC3C,uDAAmD;AACnD,6CAAgD;AAChD,2CAA8C;AAC9C,wEAAoE;AAsB7D,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IApBrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0BAAW;YACpB,sCAAiB;YACjB,qBAAY,CAAC,OAAO,EAAE;YACtB,uBAAa,CAAC,OAAO,CAAC;gBACrB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBAC/B,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;gBACzC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBACnC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;gBACvC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;gBACvC,gBAAgB,EAAE,IAAI;gBAGtB,WAAW,EAAE,IAAI;aACjB,CAAC;SACJ;QACC,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"}
|
||||
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAC3C,uDAAmD;AACnD,6CAAgD;AAChD,2CAA8C;AAC9C,wEAAoE;AAuB7D,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IApBrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0BAAW;YACpB,sCAAiB;YACjB,qBAAY,CAAC,OAAO,EAAE;YACtB,uBAAa,CAAC,OAAO,CAAC;gBACrB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBAC/B,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;gBACzC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBACnC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;gBACvC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;gBACvC,gBAAgB,EAAE,IAAI;gBAGtB,WAAW,EAAE,IAAI;aACjB,CAAC;SACJ;QACC,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"}
|
||||
7
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.controller.d.ts
vendored
Normal file
7
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.controller.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Response } from 'express';
|
||||
export declare class AuthenticationController {
|
||||
login(): string;
|
||||
redirect(res: Response): void;
|
||||
status(): string;
|
||||
logout(): string;
|
||||
}
|
||||
60
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.controller.js
vendored
Normal file
60
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.controller.js
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthenticationController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
let AuthenticationController = class AuthenticationController {
|
||||
login() {
|
||||
return 'login';
|
||||
}
|
||||
redirect(res) {
|
||||
res.send(200);
|
||||
}
|
||||
status() {
|
||||
return 'status';
|
||||
}
|
||||
logout() {
|
||||
return 'logout';
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Get)('login'),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthenticationController.prototype, "login", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('redirect'),
|
||||
__param(0, (0, common_1.Res)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthenticationController.prototype, "redirect", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('status'),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthenticationController.prototype, "status", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('logout'),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthenticationController.prototype, "logout", null);
|
||||
AuthenticationController = __decorate([
|
||||
(0, common_1.Controller)('auth')
|
||||
], AuthenticationController);
|
||||
exports.AuthenticationController = AuthenticationController;
|
||||
//# sourceMappingURL=authentication.controller.js.map
|
||||
1
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.controller.js.map
vendored
Normal file
1
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.controller.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"authentication.controller.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsD;AAI/C,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAQpC,KAAK;QACJ,OAAO,OAAO,CAAC;IAChB,CAAC;IAQD,QAAQ,CAAQ,GAAa;QAC5B,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAQD,MAAM;QACL,OAAO,QAAQ,CAAC;IACjB,CAAC;IAOD,MAAM;QACL,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD,CAAA;AAjCA;IAAC,IAAA,YAAG,EAAC,OAAO,CAAC;;;;qDAGZ;AAOD;IAAC,IAAA,YAAG,EAAC,UAAU,CAAC;IACN,WAAA,IAAA,YAAG,GAAE,CAAA;;;;wDAEd;AAOD;IAAC,IAAA,YAAG,EAAC,QAAQ,CAAC;;;;sDAGb;AAMD;IAAC,IAAA,YAAG,EAAC,QAAQ,CAAC;;;;sDAGb;AAvCW,wBAAwB;IADpC,IAAA,mBAAU,EAAC,MAAM,CAAC;GACN,wBAAwB,CAwCpC;AAxCY,4DAAwB"}
|
||||
2
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.module.d.ts
vendored
Normal file
2
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.module.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare class AuthenticationModule {
|
||||
}
|
||||
23
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.module.js
vendored
Normal file
23
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.module.js
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthenticationModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const users_module_1 = require("../../users/users.module");
|
||||
const authentication_service_1 = require("./authentication.service");
|
||||
const strategy_1 = require("./strategy/strategy");
|
||||
let AuthenticationModule = class AuthenticationModule {
|
||||
};
|
||||
AuthenticationModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [users_module_1.UsersModule],
|
||||
providers: [authentication_service_1.AuthenticationService, strategy_1.FortyTwoStrategy],
|
||||
})
|
||||
], AuthenticationModule);
|
||||
exports.AuthenticationModule = AuthenticationModule;
|
||||
//# sourceMappingURL=authentication.module.js.map
|
||||
1
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.module.js.map
vendored
Normal file
1
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.module.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"authentication.module.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2DAAqD;AACrD,qEAAiE;AACjE,kDAAuD;AAMhD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oBAAoB;IAJhC,IAAA,eAAM,EAAC;QACL,OAAO,EAAE,CAAC,0BAAW,CAAC;QACtB,SAAS,EAAE,CAAC,8CAAqB,EAAE,2BAAgB,CAAC;KACtD,CAAC;GACW,oBAAoB,CAAG;AAAvB,oDAAoB"}
|
||||
2
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.service.d.ts
vendored
Normal file
2
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.service.d.ts
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export declare class AuthenticationService {
|
||||
}
|
||||
17
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.service.js
vendored
Normal file
17
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.service.js
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthenticationService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
let AuthenticationService = class AuthenticationService {
|
||||
};
|
||||
AuthenticationService = __decorate([
|
||||
(0, common_1.Injectable)()
|
||||
], AuthenticationService);
|
||||
exports.AuthenticationService = AuthenticationService;
|
||||
//# sourceMappingURL=authentication.service.js.map
|
||||
1
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.service.js.map
vendored
Normal file
1
srcs/requirements/nestjs/api_back/dist/auth/42/authentication.service.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;CAAG,CAAA;AAAxB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;GACA,qBAAqB,CAAG;AAAxB,sDAAqB"}
|
||||
6
srcs/requirements/nestjs/api_back/dist/auth/42/guards/guards.d.ts
vendored
Normal file
6
srcs/requirements/nestjs/api_back/dist/auth/42/guards/guards.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { ExecutionContext } from "@nestjs/common";
|
||||
declare const FortyTwoAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
||||
export declare class FortyTwoAuthGuard extends FortyTwoAuthGuard_base {
|
||||
canActivate(context: ExecutionContext): Promise<any>;
|
||||
}
|
||||
export {};
|
||||
25
srcs/requirements/nestjs/api_back/dist/auth/42/guards/guards.js
vendored
Normal file
25
srcs/requirements/nestjs/api_back/dist/auth/42/guards/guards.js
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FortyTwoAuthGuard = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const passport_1 = require("@nestjs/passport");
|
||||
let FortyTwoAuthGuard = class FortyTwoAuthGuard extends (0, passport_1.AuthGuard)('42') {
|
||||
async canActivate(context) {
|
||||
const activate = (await super.canActivate(context));
|
||||
const request = context.switchToHttp().getRequest();
|
||||
console.log(request.user);
|
||||
await super.logIn(request);
|
||||
return activate;
|
||||
}
|
||||
};
|
||||
FortyTwoAuthGuard = __decorate([
|
||||
(0, common_1.Injectable)()
|
||||
], FortyTwoAuthGuard);
|
||||
exports.FortyTwoAuthGuard = FortyTwoAuthGuard;
|
||||
//# sourceMappingURL=guards.js.map
|
||||
1
srcs/requirements/nestjs/api_back/dist/auth/42/guards/guards.js.map
vendored
Normal file
1
srcs/requirements/nestjs/api_back/dist/auth/42/guards/guards.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../../src/auth/42/guards/guards.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA2E;AAC3E,+CAA6C;AAGtC,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,IAAA,oBAAS,EAAC,IAAI,CAAC;IACpD,KAAK,CAAC,WAAW,CAAC,OAAyB;QAC5C,MAAM,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAY,CAAC;QAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,OAAO,QAAQ,CAAC;IACf,CAAC;CACF,CAAA;AARY,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAQ7B;AARY,8CAAiB"}
|
||||
9
srcs/requirements/nestjs/api_back/dist/auth/42/strategy/strategy.d.ts
vendored
Normal file
9
srcs/requirements/nestjs/api_back/dist/auth/42/strategy/strategy.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Profile } from "passport-42/lib";
|
||||
import { AuthenticationService } from "../authentication.service";
|
||||
declare const FortyTwoStrategy_base: new (...args: any[]) => any;
|
||||
export declare class FortyTwoStrategy extends FortyTwoStrategy_base {
|
||||
private readonly authenticationService;
|
||||
constructor(authenticationService: AuthenticationService);
|
||||
validate(accessToken: string, refreshToken: string, profile: Profile, callbackURL: string): Promise<void>;
|
||||
}
|
||||
export {};
|
||||
35
srcs/requirements/nestjs/api_back/dist/auth/42/strategy/strategy.js
vendored
Normal file
35
srcs/requirements/nestjs/api_back/dist/auth/42/strategy/strategy.js
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FortyTwoStrategy = void 0;
|
||||
const lib_1 = require("passport-42/lib");
|
||||
const passport_1 = require("@nestjs/passport");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const authentication_service_1 = require("../authentication.service");
|
||||
let FortyTwoStrategy = class FortyTwoStrategy extends (0, passport_1.PassportStrategy)(lib_1.Strategy, "42") {
|
||||
constructor(authenticationService) {
|
||||
super({
|
||||
clientID: process.env.FORTYTWO_CLIENT_ID,
|
||||
clientSecret: process.env.FORTYTWO_CLIENT_SECRET,
|
||||
callbackURL: process.env.FORTYTWO_CALLBACK_URL,
|
||||
scope: ["public"],
|
||||
});
|
||||
this.authenticationService = authenticationService;
|
||||
}
|
||||
async validate(accessToken, refreshToken, profile, callbackURL) {
|
||||
}
|
||||
};
|
||||
FortyTwoStrategy = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [authentication_service_1.AuthenticationService])
|
||||
], FortyTwoStrategy);
|
||||
exports.FortyTwoStrategy = FortyTwoStrategy;
|
||||
//# sourceMappingURL=strategy.js.map
|
||||
1
srcs/requirements/nestjs/api_back/dist/auth/42/strategy/strategy.js.map
vendored
Normal file
1
srcs/requirements/nestjs/api_back/dist/auth/42/strategy/strategy.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../../src/auth/42/strategy/strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAoD;AACpD,+CAAoD;AACpD,2CAA4C;AAC5C,sEAAkE;AAG3D,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,IAAA,2BAAgB,EAAC,cAAQ,EAAE,IAAI,CAAC;IACnE,YAA6B,qBAA4C;QAC3E,KAAK,CAAC;YACJ,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;YACxC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;YAChD,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;YAC9C,KAAK,EAAE,CAAC,QAAQ,CAAC;SAClB,CAAC,CAAC;QAN4B,0BAAqB,GAArB,qBAAqB,CAAuB;IAO1E,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,WAAmB,EAAE,YAAoB,EAAE,OAAgB,EAAE,WAAmB;IAE/F,CAAC;CACF,CAAA;AAbY,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAE0C,8CAAqB;GAD/D,gBAAgB,CAa5B;AAbY,4CAAgB"}
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"friendship.entity.js","sourceRoot":"","sources":["../../../src/friendship/entities/friendship.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAmI;AACnI,kEAAwD;AAExD,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,mCAAe,CAAA;IACf,kCAAc,CAAA;IACd,kCAAc,CAAA;IACd,iCAAa,CAAA;AACd,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B;AAGM,IAAM,UAAU,GAAhB,MAAM,UAAU;CAmBtB,CAAA;AAlBA;IAAC,IAAA,gCAAsB,GAAE;;sCACd;AAEX;IAAC,IAAA,0BAAgB,GAAE;8BACZ,IAAI;wCAAC;AAGZ;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;+CAC9B;AAEpB;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;+CAC9B;AAGpB;IAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,CAAC,SAAS,EAAC,CAAC;;0CAC5D;AAlBb,UAAU;IADtB,IAAA,gBAAM,EAAC,aAAa,CAAC;GACT,UAAU,CAmBtB;AAnBY,gCAAU"}
|
||||
{"version":3,"file":"friendship.entity.js","sourceRoot":"","sources":["../../../src/friendship/entities/friendship.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAmI;AACnI,kEAAwD;AAExD,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,mCAAe,CAAA;IACf,kCAAc,CAAA;IACd,kCAAc,CAAA;IACd,iCAAa,CAAA;AACd,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B;AAGM,IAAM,UAAU,GAAhB,MAAM,UAAU;CAkBtB,CAAA;AAjBA;IAAC,IAAA,gCAAsB,GAAE;;sCACd;AAEX;IAAC,IAAA,0BAAgB,GAAE;8BACZ,IAAI;wCAAC;AAGZ;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;+CAC9B;AAEpB;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;+CAC9B;AAEpB;IAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,CAAC,SAAS,EAAC,CAAC;;0CAC5D;AAjBb,UAAU;IADtB,IAAA,gBAAM,EAAC,aAAa,CAAC;GACT,UAAU,CAkBtB;AAlBY,gCAAU"}
|
||||
@@ -13,6 +13,7 @@ async function bootstrap() {
|
||||
enableImplicitConversion: true,
|
||||
},
|
||||
}));
|
||||
app.setGlobalPrefix('api/v2');
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,2CAAgD;AAChD,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IAEtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAGhD,GAAG,CAAC,cAAc,CACnB,IAAI,uBAAc,CAAC;QAElB,SAAS,EAAE,IAAI;QAEf,oBAAoB,EAAE,IAAI;QAE1B,SAAS,EAAE,IAAI;QACf,gBAAgB,EAAE;YACjB,wBAAwB,EAAE,IAAI;SAC9B;KACD,CAAC,CACA,CAAC;IACF,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AACD,SAAS,EAAE,CAAC"}
|
||||
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,2CAAgD;AAChD,6CAAyC;AAEzC,KAAK,UAAU,SAAS;IAEtB,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,sBAAS,CAAC,CAAC;IAGhD,GAAG,CAAC,cAAc,CACnB,IAAI,uBAAc,CAAC;QAElB,SAAS,EAAE,IAAI;QAEf,oBAAoB,EAAE,IAAI;QAE1B,SAAS,EAAE,IAAI;QACf,gBAAgB,EAAE;YACjB,wBAAwB,EAAE,IAAI;SAC9B;KACD,CAAC,CACA,CAAC;IACF,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC9B,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AACD,SAAS,EAAE,CAAC"}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,9 +1,11 @@
|
||||
import { Friendship } from "../../friendship/entities/friendship.entity";
|
||||
export declare class User {
|
||||
id: number;
|
||||
fourtyTwoId: string;
|
||||
username: string;
|
||||
email: string;
|
||||
password: string;
|
||||
avatar: string;
|
||||
status: [string];
|
||||
requesterId: Friendship[];
|
||||
addresseeId: Friendship[];
|
||||
|
||||
@@ -19,6 +19,10 @@ __decorate([
|
||||
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
||||
__metadata("design:type", Number)
|
||||
], User.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ name: 'fourty_two_id' }),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "fourtyTwoId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)(),
|
||||
__metadata("design:type", String)
|
||||
@@ -32,6 +36,10 @@ __decorate([
|
||||
(0, typeorm_1.Column)(),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "password", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "avatar", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)('json', { nullable: true }),
|
||||
__metadata("design:type", Array)
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/users/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qDAAkD;AAClD,qCAA2G;AAC3G,mFAAyE;AAKlE,IAAM,IAAI,GAAV,MAAM,IAAI;CAyBhB,CAAA;AAvBA;IAAC,IAAA,gCAAsB,GAAE;;gCACd;AAEX;IAAC,IAAA,gBAAM,GAAE;;sCACQ;AAEjB;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,yBAAO,GAAE;;mCACI;AAEd;IAAC,IAAA,gBAAM,GAAE;;sCACQ;AAEjB;IAAC,IAAA,gBAAM,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oCAClB;AAEjB;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AAE1B;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AAxBd,IAAI;IAFhB,IAAA,gBAAM,EAAC,MAAM,CAAC;IACd,IAAA,gBAAM,EAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;GACjB,IAAI,CAyBhB;AAzBY,oBAAI"}
|
||||
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/users/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qDAAkD;AAClD,qCAA2G;AAC3G,mFAAyE;AAKlE,IAAM,IAAI,GAAV,MAAM,IAAI;CA+BhB,CAAA;AA7BA;IAAC,IAAA,gCAAsB,GAAE;;gCACd;AAEX;IAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC;;yCACd;AAEpB;IAAC,IAAA,gBAAM,GAAE;;sCACQ;AAEjB;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,yBAAO,GAAE;;mCACI;AAEd;IAAC,IAAA,gBAAM,GAAE;;sCACQ;AAEjB;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oCACZ;AAEf;IAAC,IAAA,gBAAM,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oCAClB;AAEjB;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AAE1B;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AA9Bd,IAAI;IAFhB,IAAA,gBAAM,EAAC,MAAM,CAAC;IACd,IAAA,gBAAM,EAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;GACjB,IAAI,CA+BhB;AA/BY,oBAAI"}
|
||||
48
srcs/requirements/nestjs/api_back/node_modules/.package-lock.json
generated
vendored
48
srcs/requirements/nestjs/api_back/node_modules/.package-lock.json
generated
vendored
@@ -2827,6 +2827,14 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/base64url": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz",
|
||||
"integrity": "sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A==",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/binary-extensions": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
|
||||
@@ -6419,6 +6427,11 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/oauth": {
|
||||
"version": "0.9.15",
|
||||
"resolved": "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz",
|
||||
"integrity": "sha512-a5ERWK1kh38ExDEfoO6qUHJb32rd7aYmPHuyCu3Fta/cnICvYmgd2uhuKXvPD+PXB+gCEYYEaQdIRAjCOwAKNA=="
|
||||
},
|
||||
"node_modules/object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
@@ -6675,6 +6688,17 @@
|
||||
"url": "https://github.com/sponsors/jaredhanson"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-42": {
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/passport-42/-/passport-42-1.2.6.tgz",
|
||||
"integrity": "sha512-a1SraWSwH33NqRDe9ScG4MQwfj7RRBYLFtrJySn4tU4Ou7+caLxj6VQgaL4i+eZoKC6QAooL1Nqevn/W8vLXuQ==",
|
||||
"dependencies": {
|
||||
"passport-oauth2": "^1.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-local": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz",
|
||||
@@ -6686,6 +6710,25 @@
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-oauth2": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/passport-oauth2/-/passport-oauth2-1.6.1.tgz",
|
||||
"integrity": "sha512-ZbV43Hq9d/SBSYQ22GOiglFsjsD1YY/qdiptA+8ej+9C1dL1TVB+mBE5kDH/D4AJo50+2i8f4bx0vg4/yDDZCQ==",
|
||||
"dependencies": {
|
||||
"base64url": "3.x.x",
|
||||
"oauth": "0.9.x",
|
||||
"passport-strategy": "1.x.x",
|
||||
"uid2": "0.0.x",
|
||||
"utils-merge": "1.x.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/jaredhanson"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-strategy": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz",
|
||||
@@ -8510,6 +8553,11 @@
|
||||
"node": ">=4.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uid2": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/uid2/-/uid2-0.0.4.tgz",
|
||||
"integrity": "sha512-IevTus0SbGwQzYh3+fRsAMTVVPOoIVufzacXcHPmdlle1jUpq7BRL+mw3dgeLanvGZdwwbWhRV6XrcFNdBmjWA=="
|
||||
},
|
||||
"node_modules/universalify": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
|
||||
|
||||
20
srcs/requirements/nestjs/api_back/node_modules/base64url/LICENSE
generated
vendored
Normal file
20
srcs/requirements/nestjs/api_back/node_modules/base64url/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2013–2016 Brian J. Brennan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
0
srcs/requirements/nestjs/api_back/node_modules/base64url/dist/.gitkeep
generated
vendored
Normal file
0
srcs/requirements/nestjs/api_back/node_modules/base64url/dist/.gitkeep
generated
vendored
Normal file
11
srcs/requirements/nestjs/api_back/node_modules/base64url/dist/base64url.d.ts
generated
vendored
Normal file
11
srcs/requirements/nestjs/api_back/node_modules/base64url/dist/base64url.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/// <reference types="node" />
|
||||
export interface Base64Url {
|
||||
(input: string | Buffer, encoding?: string): string;
|
||||
encode(input: string | Buffer, encoding?: string): string;
|
||||
decode(base64url: string, encoding?: string): string;
|
||||
toBase64(base64url: string | Buffer): string;
|
||||
fromBase64(base64: string): string;
|
||||
toBuffer(base64url: string): Buffer;
|
||||
}
|
||||
declare let base64url: Base64Url;
|
||||
export default base64url;
|
||||
37
srcs/requirements/nestjs/api_back/node_modules/base64url/dist/base64url.js
generated
vendored
Normal file
37
srcs/requirements/nestjs/api_back/node_modules/base64url/dist/base64url.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var pad_string_1 = require("./pad-string");
|
||||
function encode(input, encoding) {
|
||||
if (encoding === void 0) { encoding = "utf8"; }
|
||||
if (Buffer.isBuffer(input)) {
|
||||
return fromBase64(input.toString("base64"));
|
||||
}
|
||||
return fromBase64(Buffer.from(input, encoding).toString("base64"));
|
||||
}
|
||||
;
|
||||
function decode(base64url, encoding) {
|
||||
if (encoding === void 0) { encoding = "utf8"; }
|
||||
return Buffer.from(toBase64(base64url), "base64").toString(encoding);
|
||||
}
|
||||
function toBase64(base64url) {
|
||||
base64url = base64url.toString();
|
||||
return pad_string_1.default(base64url)
|
||||
.replace(/\-/g, "+")
|
||||
.replace(/_/g, "/");
|
||||
}
|
||||
function fromBase64(base64) {
|
||||
return base64
|
||||
.replace(/=/g, "")
|
||||
.replace(/\+/g, "-")
|
||||
.replace(/\//g, "_");
|
||||
}
|
||||
function toBuffer(base64url) {
|
||||
return Buffer.from(toBase64(base64url), "base64");
|
||||
}
|
||||
var base64url = encode;
|
||||
base64url.encode = encode;
|
||||
base64url.decode = decode;
|
||||
base64url.toBase64 = toBase64;
|
||||
base64url.fromBase64 = fromBase64;
|
||||
base64url.toBuffer = toBuffer;
|
||||
exports.default = base64url;
|
||||
1
srcs/requirements/nestjs/api_back/node_modules/base64url/dist/pad-string.d.ts
generated
vendored
Normal file
1
srcs/requirements/nestjs/api_back/node_modules/base64url/dist/pad-string.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export default function padString(input: string): string;
|
||||
20
srcs/requirements/nestjs/api_back/node_modules/base64url/dist/pad-string.js
generated
vendored
Normal file
20
srcs/requirements/nestjs/api_back/node_modules/base64url/dist/pad-string.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
function padString(input) {
|
||||
var segmentLength = 4;
|
||||
var stringLength = input.length;
|
||||
var diff = stringLength % segmentLength;
|
||||
if (!diff) {
|
||||
return input;
|
||||
}
|
||||
var position = stringLength;
|
||||
var padLength = segmentLength - diff;
|
||||
var paddedStringLength = stringLength + padLength;
|
||||
var buffer = Buffer.alloc(paddedStringLength);
|
||||
buffer.write(input);
|
||||
while (padLength--) {
|
||||
buffer.write("=", position++);
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
exports.default = padString;
|
||||
2
srcs/requirements/nestjs/api_back/node_modules/base64url/index.js
generated
vendored
Normal file
2
srcs/requirements/nestjs/api_back/node_modules/base64url/index.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
module.exports = require('./dist/base64url').default;
|
||||
module.exports.default = module.exports;
|
||||
35
srcs/requirements/nestjs/api_back/node_modules/base64url/package.json
generated
vendored
Normal file
35
srcs/requirements/nestjs/api_back/node_modules/base64url/package.json
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "base64url",
|
||||
"version": "3.0.1",
|
||||
"description": "For encoding to/from base64urls",
|
||||
"main": "index.js",
|
||||
"types": "./dist/base64url.d.ts",
|
||||
"files": [
|
||||
"dist/",
|
||||
"index.js"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"clean": "rm -f dist/*",
|
||||
"test": "npm run clean && npm run build && tap test/*.test.js",
|
||||
"prepublishOnly": "npm run test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/brianloveswords/base64url.git"
|
||||
},
|
||||
"keywords": [
|
||||
"base64",
|
||||
"base64url"
|
||||
],
|
||||
"author": "Brian J Brennan",
|
||||
"license": "MIT",
|
||||
"readmeFilename": "README.md",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^10.0.0",
|
||||
"tap": "^12.1.0"
|
||||
}
|
||||
}
|
||||
127
srcs/requirements/nestjs/api_back/node_modules/base64url/readme.md
generated
vendored
Normal file
127
srcs/requirements/nestjs/api_back/node_modules/base64url/readme.md
generated
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
# base64url [](http://travis-ci.org/brianloveswords/base64url)
|
||||
|
||||
Converting to, and from, [base64url](http://en.wikipedia.org/wiki/Base64#RFC_4648)
|
||||
|
||||
# Install
|
||||
|
||||
```bash
|
||||
$ npm install base64url
|
||||
```
|
||||
|
||||
After installing with `npm` you can require this library from JavaScript or TypeScript:
|
||||
|
||||
JavaScript
|
||||
```js
|
||||
const base64url = require('base64url');
|
||||
```
|
||||
|
||||
TypeScript:
|
||||
```typescript
|
||||
import base64url from "base64url";
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
## CLI
|
||||
|
||||
The CLI has been removed. For the time being, please install `base64url@1.0.6` if you need the CLI.
|
||||
|
||||
## Library
|
||||
|
||||
### base64url(input: string | Buffer, encoding: string = "utf8"): string
|
||||
|
||||
### base64url.encode(input: string | Buffer, encoding: string = "utf8"): string
|
||||
|
||||
base64url encode `input`. Input should be a `string` or a `Buffer`.
|
||||
|
||||
|
||||
Example
|
||||
|
||||
```js
|
||||
> base64url("ladies and gentlemen we are floating in space")
|
||||
'bGFkaWVzIGFuZCBnZW50bGVtYW4sIHdlIGFyZSBmbG9hdGluZyBpbiBzcGFjZQ'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### base64url.decode(input: string, encoding: string = "utf8"): string
|
||||
|
||||
Convert a base64url encoded string into a raw string. The `encoding` argument can be used if the input is a string that's not utf8.
|
||||
|
||||
```js
|
||||
> base64url.decode("cmlkZTogZHJlYW1zIGJ1cm4gZG93bg")
|
||||
'ride: dreams burn down'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### base64url.fromBase64(input: string): string
|
||||
|
||||
Convert a base64 encoded string to a base64url encoded string.
|
||||
|
||||
Example
|
||||
|
||||
```js
|
||||
> base64url.fromBase64('qL8R4QIcQ/ZsRqOAbeRfcZhilN/MksRtDaErMA==')
|
||||
'qL8R4QIcQ_ZsRqOAbeRfcZhilN_MksRtDaErMA'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
### base64url.toBase64(input: string): string
|
||||
|
||||
Convert a base64url encoded string to a base64 encoded string.
|
||||
|
||||
```js
|
||||
> base64url.toBase64('qL8R4QIcQ_ZsRqOAbeRfcZhilN_MksRtDaErMA')
|
||||
'qL8R4QIcQ/ZsRqOAbeRfcZhilN/MksRtDaErMA=='
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
|
||||
### base64url.toBuffer(input: string): Buffer
|
||||
|
||||
Convert a base64url encoded string to a Buffer containing the decoded bytes.
|
||||
|
||||
```js
|
||||
> base64url.toBuffer('c3Bpcml0dWFsaXplZA')
|
||||
<Buffer 73 70 69 72 69 74 75 61 6c 69 7a 65 64>
|
||||
```
|
||||
|
||||
# Alternatives
|
||||
|
||||
- [base64-url](https://github.com/joaquimserafim/base64-url)
|
||||
|
||||
# Supported Node.js versions
|
||||
|
||||
This library should be used with current versions of the Node.js runtime's long-term stable (LTS)
|
||||
schedule. More information can be found [at the Node.js Release Working Group](https://github.com/nodejs/Release) repo.
|
||||
|
||||
# License
|
||||
|
||||
MIT
|
||||
|
||||
```
|
||||
Copyright (c) 2013–2016 Brian J. Brennan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
```
|
||||
1
srcs/requirements/nestjs/api_back/node_modules/oauth/.npmignore
generated
vendored
Normal file
1
srcs/requirements/nestjs/api_back/node_modules/oauth/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
8
srcs/requirements/nestjs/api_back/node_modules/oauth/LICENSE
generated
vendored
Normal file
8
srcs/requirements/nestjs/api_back/node_modules/oauth/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
The MIT License (MIT)
|
||||
Copyright (c) <2010-2012> <Ciaran Jessup>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
7
srcs/requirements/nestjs/api_back/node_modules/oauth/Makefile
generated
vendored
Normal file
7
srcs/requirements/nestjs/api_back/node_modules/oauth/Makefile
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#
|
||||
# Run all tests
|
||||
#
|
||||
test:
|
||||
@@node_modules/.bin/vows tests/*tests.js --spec
|
||||
|
||||
.PHONY: test install
|
||||
190
srcs/requirements/nestjs/api_back/node_modules/oauth/Readme.md
generated
vendored
Normal file
190
srcs/requirements/nestjs/api_back/node_modules/oauth/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
node-oauth
|
||||
===========
|
||||
A simple oauth API for node.js . This API allows users to authenticate against OAUTH providers, and thus act as OAuth consumers. It also has support for OAuth Echo, which is used for communicating with 3rd party media providers such as TwitPic and yFrog.
|
||||
|
||||
Tested against Twitter (http://twitter.com), term.ie (http://term.ie/oauth/example/), TwitPic, and Yahoo!
|
||||
|
||||
Also provides rudimentary OAuth2 support, tested against facebook, github, foursquare, google and Janrain. For more complete usage examples please take a look at connect-auth (http://github.com/ciaranj/connect-auth)
|
||||
|
||||
[][koding]
|
||||
[koding]: https://koding.com/Teamwork?import=https://github.com/ciaranj/node-oauth/archive/master.zip&c=git1
|
||||
[][Thinkful]
|
||||
[Thinkful]: http://start.thinkful.com/node/?utm_source=github&utm_medium=badge&utm_campaign=node-oauth
|
||||
|
||||
Installation
|
||||
==============
|
||||
|
||||
$ npm install oauth
|
||||
|
||||
|
||||
Examples
|
||||
==========
|
||||
|
||||
To run examples/tests install Mocha `$ npm install -g mocha` and run `$ mocha you-file-name.js`:
|
||||
|
||||
## OAuth1.0
|
||||
|
||||
```javascript
|
||||
describe('OAuth1.0',function(){
|
||||
var OAuth = require('oauth');
|
||||
|
||||
it('tests trends Twitter API v1.1',function(done){
|
||||
var oauth = new OAuth.OAuth(
|
||||
'https://api.twitter.com/oauth/request_token',
|
||||
'https://api.twitter.com/oauth/access_token',
|
||||
'your application consumer key',
|
||||
'your application secret',
|
||||
'1.0A',
|
||||
null,
|
||||
'HMAC-SHA1'
|
||||
);
|
||||
oauth.get(
|
||||
'https://api.twitter.com/1.1/trends/place.json?id=23424977',
|
||||
'your user token for this app', //test user token
|
||||
'your user secret for this app', //test user secret
|
||||
function (e, data, res){
|
||||
if (e) console.error(e);
|
||||
console.log(require('util').inspect(data));
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
## OAuth2.0
|
||||
```javascript
|
||||
describe('OAuth2',function(){
|
||||
var OAuth = require('oauth');
|
||||
|
||||
it('gets bearer token', function(done){
|
||||
var OAuth2 = OAuth.OAuth2;
|
||||
var twitterConsumerKey = 'your key';
|
||||
var twitterConsumerSecret = 'your secret';
|
||||
var oauth2 = new OAuth2(server.config.keys.twitter.consumerKey,
|
||||
twitterConsumerSecret,
|
||||
'https://api.twitter.com/',
|
||||
null,
|
||||
'oauth2/token',
|
||||
null);
|
||||
oauth2.getOAuthAccessToken(
|
||||
'',
|
||||
{'grant_type':'client_credentials'},
|
||||
function (e, access_token, refresh_token, results){
|
||||
console.log('bearer: ',access_token);
|
||||
done();
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
Change History
|
||||
==============
|
||||
* 0.9.15
|
||||
- OAuth2: Allow specification of agent
|
||||
* 0.9.14
|
||||
- OAuth2: Extend 'successful' token responses to include anything in the 2xx range.
|
||||
* 0.9.13
|
||||
- OAuth2: Fixes the "createCredentials() is deprecated, use tls.createSecureContext instead" message. (thank you AJ ONeal)
|
||||
* 0.9.12
|
||||
- OAuth1/2: Can now pass Buffer instance directly for PUTs+POSTs (thank you Evan Prodromou)
|
||||
- OAuth1: Improve interoperability with libraries that mess with the prototype. (thank you Jose Ignacio Andres)
|
||||
- OAuth2: Adds PUT support for OAuth2 (thank you Derek Brooks)
|
||||
- OAuth1: Improves use_strict compatibility (thank you Ted Goddard)
|
||||
* 0.9.11
|
||||
- OAuth2: No longer sends the type=webserver argument with the OAuth2 requests (thank you bendiy)
|
||||
- OAuth2: Provides a default (and overrideable) User-Agent header (thanks to Andrew Martens & Daniel Mahlow)
|
||||
- OAuth1: New followRedirects client option (true by default) (thanks to Pieter Joost van de Sande)
|
||||
- OAuth1: Adds RSA-SHA1 support (thanks to Jeffrey D. Van Alstine & Michael Garvin & Andreas Knecht)
|
||||
* 0.9.10
|
||||
- OAuth2: Addresses 2 issues that came in with 0.9.9, #129 & #125 (thank you José F. Romaniello)
|
||||
* 0.9.9
|
||||
- OAuth1: Fix the mismatch between the output of querystring.stringify() and this._encodeData(). (thank you rolandboon)
|
||||
- OAuth2: Adds Authorization Header and supports extra headers by default ( thanks to Brian Park)
|
||||
* 0.9.8
|
||||
- OAuth1: Support overly-strict OAuth server's that require whitespace separating the Authorization Header parameters (e.g. 500px.com) (Thanks to Christian Schwarz)
|
||||
- OAuth1: Fix incorrect double-encoding of PLAINTEXT OAuth connections (Thanks to Joe Rozner)
|
||||
- OAuth1: Minor safety check added when checking hostnames. (Thanks to Garrick Cheung)
|
||||
* 0.9.7
|
||||
- OAuth2: Pass back any extra response data for calls to getOAuthAccessToken (Thanks to Tang Bo Hao)
|
||||
- OAuth2: Don't force a https request if given a http url (Thanks to Damien Mathieu)
|
||||
- OAuth2: Supports specifying a grant-type of 'refresh-token' (Thanks to Luke Baker)
|
||||
* 0.9.6
|
||||
- OAuth2: Support for 302 redirects (Thanks Patrick Negri).
|
||||
- OAuth1/2: Some code tidying. ( Thanks to Raoul Millais )
|
||||
* 0.9.5
|
||||
- OAuth1: Allow usage of HTTP verbs other than GET for retrieving the access and request tokens (Thanks to Raoul Millais)
|
||||
* 0.9.4
|
||||
- OAuth1/2: Support for OAuth providers that drop connections (don't send response lengths? [Google])
|
||||
- OAuth2: Change getOAuthAccessToken to POST rather than GET ( Possible Breaking change!!! ... re-tested against Google, Github, Facebook, FourSquare and Janrain and seems ok .. is closer to the spec (v20) )
|
||||
* 0.9.3
|
||||
- OAuth1: Adds support for following 301 redirects (Thanks bdickason)
|
||||
* 0.9.2
|
||||
- OAuth1: Correct content length calculated for non-ascii post bodies (Thanks selead)
|
||||
- OAuth1: Allowed for configuration of the 'access token' name used when requesting protected resources (OAuth2)
|
||||
* 0.9.1
|
||||
- OAuth1: Added support for automatically following 302 redirects (Thanks neyric)
|
||||
- OAuth1: Added support for OAuth Echo (Thanks Ryan LeFevre).
|
||||
- OAuth1: Improved handling of 2xx responses (Thanks Neil Mansilla).
|
||||
* 0.9.0
|
||||
- OAuth1/2: Compatibility fixes to bring node-oauth up to speed with node.js 0.4x [thanks to Rasmus Andersson for starting the work ]
|
||||
* 0.8.4
|
||||
- OAuth1: Fixed issue #14 (Parameter ordering ignored encodings).
|
||||
- OAuth1: Added support for repeated parameter names.
|
||||
- OAuth1/2: Implements issue #15 (Use native SHA1 if available, 10x speed improvement!).
|
||||
- OAuth2: Fixed issue #16 (Should use POST when requesting access tokens.).
|
||||
- OAuth2: Fixed Issue #17 (OAuth2 spec compliance).
|
||||
- OAuth1: Implemented enhancement #13 (Adds support for PUT & DELETE http verbs).
|
||||
- OAuth1: Fixes issue #18 (Complex/Composite url arguments [thanks novemberborn])
|
||||
* 0.8.3
|
||||
- OAuth1: Fixed an issue where the auth header code depended on the Array's toString method (Yohei Sasaki) Updated the getOAuthRequestToken method so we can access google's OAuth secured methods. Also re-implemented and fleshed out the test suite.
|
||||
* 0.8.2
|
||||
- OAuth1: The request returning methods will now write the POST body if provided (Chris Anderson), the code responsible for manipulating the headers is a bit safe now when working with other code (Paul McKellar)
|
||||
- Package: Tweaked the package.json to use index.js instead of main.js
|
||||
* 0.8.1
|
||||
- OAuth1: Added mechanism to get hold of a signed Node Request object, ready for attaching response listeners etc. (Perfect for streaming APIs)
|
||||
* 0.8.0
|
||||
- OAuth1: Standardised method capitalisation, the old getOauthAccessToken is now getOAuthAccessToken (Breaking change to existing code)
|
||||
* 0.7.7
|
||||
- OAuth1: Looks like non oauth_ parameters where appearing within the Authorization headers, which I believe to be incorrect.
|
||||
* 0.7.6
|
||||
- OAuth1: Added in oauth_verifier property to getAccessToken required for 1.0A
|
||||
* 0.7.5
|
||||
- Package: Added in a main.js to simplify the require'ing of OAuth
|
||||
* 0.7.4
|
||||
- OAuth1: Minor change to add an error listener to the OAuth client (thanks troyk)
|
||||
* 0.7.3
|
||||
- OAuth2: Now sends a Content-Length Http header to keep nginx happy :)
|
||||
* 0.7.2
|
||||
- OAuth1: Fixes some broken unit tests!
|
||||
* 0.7.0
|
||||
- OAuth1/2: Introduces support for HTTPS end points and callback URLS for OAuth 1.0A and Oauth 2 (Please be aware that this was a breaking change to the constructor arguments order)
|
||||
|
||||
Contributors (In no particular order)
|
||||
=====================================
|
||||
|
||||
* Evan Prodromou
|
||||
* Jose Ignacio Andres
|
||||
* Ted Goddard
|
||||
* Derek Brooks
|
||||
* Ciaran Jessup - ciaranj@gmail.com
|
||||
* Mark Wubben - http://equalmedia.com/
|
||||
* Ryan LeFevre - http://meltingice.net
|
||||
* Raoul Millais
|
||||
* Patrick Negri - http://github.com/pnegri
|
||||
* Tang Bo Hao - http://github.com/btspoony
|
||||
* Damien Mathieu - http://42.dmathieu.com
|
||||
* Luke Baker - http://github.com/lukebaker
|
||||
* Christian Schwarz - http://github.com/chrischw/
|
||||
* Joe Rozer - http://www.deadbytes.net
|
||||
* Garrick Cheung - http://www.garrickcheung.com/
|
||||
* rolandboon - http://rolandboon.com
|
||||
* Brian Park - http://github.com/yaru22
|
||||
* José F. Romaniello - http://github.com/jfromaniello
|
||||
* bendiy - https://github.com/bendiy
|
||||
* Andrew Martins - http://www.andrewmartens.com
|
||||
* Daniel Mahlow - https://github.com/dmahlow
|
||||
* Pieter Joost van de Sande - https://github.com/pjvds
|
||||
* Jeffrey D. Van Alstine
|
||||
* Michael Garvin
|
||||
* Andreas Knecht
|
||||
* AJ ONeal
|
||||
* Philip Skinner - https://github.com/PhilipSkinner
|
||||
168
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/express-gdata/server.js
generated
vendored
Normal file
168
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/express-gdata/server.js
generated
vendored
Normal file
@@ -0,0 +1,168 @@
|
||||
var express = require('express'),
|
||||
OAuth = require('oauth').OAuth,
|
||||
querystring = require('querystring');
|
||||
|
||||
// Setup the Express.js server
|
||||
var app = express.createServer();
|
||||
app.use(express.logger());
|
||||
app.use(express.bodyParser());
|
||||
app.use(express.cookieParser());
|
||||
app.use(express.session({
|
||||
secret: "skjghskdjfhbqigohqdiouk"
|
||||
}));
|
||||
|
||||
// Home Page
|
||||
app.get('/', function(req, res){
|
||||
if(!req.session.oauth_access_token) {
|
||||
res.redirect("/google_login");
|
||||
}
|
||||
else {
|
||||
res.redirect("/google_contacts");
|
||||
}
|
||||
});
|
||||
|
||||
// Request an OAuth Request Token, and redirects the user to authorize it
|
||||
app.get('/google_login', function(req, res) {
|
||||
|
||||
var getRequestTokenUrl = "https://www.google.com/accounts/OAuthGetRequestToken";
|
||||
|
||||
// GData specifid: scopes that wa want access to
|
||||
var gdataScopes = [
|
||||
querystring.escape("https://www.google.com/m8/feeds/"),
|
||||
querystring.escape("https://www.google.com/calendar/feeds/")
|
||||
];
|
||||
|
||||
var oa = new OAuth(getRequestTokenUrl+"?scope="+gdataScopes.join('+'),
|
||||
"https://www.google.com/accounts/OAuthGetAccessToken",
|
||||
"anonymous",
|
||||
"anonymous",
|
||||
"1.0",
|
||||
"http://localhost:3000/google_cb"+( req.param('action') && req.param('action') != "" ? "?action="+querystring.escape(req.param('action')) : "" ),
|
||||
"HMAC-SHA1");
|
||||
|
||||
oa.getOAuthRequestToken(function(error, oauth_token, oauth_token_secret, results){
|
||||
if(error) {
|
||||
console.log('error');
|
||||
console.log(error);
|
||||
}
|
||||
else {
|
||||
// store the tokens in the session
|
||||
req.session.oa = oa;
|
||||
req.session.oauth_token = oauth_token;
|
||||
req.session.oauth_token_secret = oauth_token_secret;
|
||||
|
||||
// redirect the user to authorize the token
|
||||
res.redirect("https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token="+oauth_token);
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
// Callback for the authorization page
|
||||
app.get('/google_cb', function(req, res) {
|
||||
|
||||
// get the OAuth access token with the 'oauth_verifier' that we received
|
||||
|
||||
var oa = new OAuth(req.session.oa._requestUrl,
|
||||
req.session.oa._accessUrl,
|
||||
req.session.oa._consumerKey,
|
||||
req.session.oa._consumerSecret,
|
||||
req.session.oa._version,
|
||||
req.session.oa._authorize_callback,
|
||||
req.session.oa._signatureMethod);
|
||||
|
||||
console.log(oa);
|
||||
|
||||
oa.getOAuthAccessToken(
|
||||
req.session.oauth_token,
|
||||
req.session.oauth_token_secret,
|
||||
req.param('oauth_verifier'),
|
||||
function(error, oauth_access_token, oauth_access_token_secret, results2) {
|
||||
|
||||
if(error) {
|
||||
console.log('error');
|
||||
console.log(error);
|
||||
}
|
||||
else {
|
||||
|
||||
// store the access token in the session
|
||||
req.session.oauth_access_token = oauth_access_token;
|
||||
req.session.oauth_access_token_secret = oauth_access_token_secret;
|
||||
|
||||
res.redirect((req.param('action') && req.param('action') != "") ? req.param('action') : "/google_contacts");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
function require_google_login(req, res, next) {
|
||||
if(!req.session.oauth_access_token) {
|
||||
res.redirect("/google_login?action="+querystring.escape(req.originalUrl));
|
||||
return;
|
||||
}
|
||||
next();
|
||||
};
|
||||
|
||||
app.get('/google_contacts', require_google_login, function(req, res) {
|
||||
var oa = new OAuth(req.session.oa._requestUrl,
|
||||
req.session.oa._accessUrl,
|
||||
req.session.oa._consumerKey,
|
||||
req.session.oa._consumerSecret,
|
||||
req.session.oa._version,
|
||||
req.session.oa._authorize_callback,
|
||||
req.session.oa._signatureMethod);
|
||||
|
||||
console.log(oa);
|
||||
|
||||
// Example using GData API v3
|
||||
// GData Specific Header
|
||||
oa._headers['GData-Version'] = '3.0';
|
||||
|
||||
oa.getProtectedResource(
|
||||
"https://www.google.com/m8/feeds/contacts/default/full?alt=json",
|
||||
"GET",
|
||||
req.session.oauth_access_token,
|
||||
req.session.oauth_access_token_secret,
|
||||
function (error, data, response) {
|
||||
|
||||
var feed = JSON.parse(data);
|
||||
|
||||
res.render('google_contacts.ejs', {
|
||||
locals: { feed: feed }
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
app.get('/google_calendars', require_google_login, function(req, res) {
|
||||
var oa = new OAuth(req.session.oa._requestUrl,
|
||||
req.session.oa._accessUrl,
|
||||
req.session.oa._consumerKey,
|
||||
req.session.oa._consumerSecret,
|
||||
req.session.oa._version,
|
||||
req.session.oa._authorize_callback,
|
||||
req.session.oa._signatureMethod);
|
||||
// Example using GData API v2
|
||||
// GData Specific Header
|
||||
oa._headers['GData-Version'] = '2';
|
||||
|
||||
oa.getProtectedResource(
|
||||
"https://www.google.com/calendar/feeds/default/allcalendars/full?alt=jsonc",
|
||||
"GET",
|
||||
req.session.oauth_access_token,
|
||||
req.session.oauth_access_token_secret,
|
||||
function (error, data, response) {
|
||||
|
||||
var feed = JSON.parse(data);
|
||||
|
||||
res.render('google_calendars.ejs', {
|
||||
locals: { feed: feed }
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
app.listen(3000);
|
||||
console.log("listening on http://localhost:3000");
|
||||
21
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/express-gdata/views/google_calendars.ejs
generated
vendored
Normal file
21
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/express-gdata/views/google_calendars.ejs
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
<p><a href="/google_contacts">Check google_contacts</a></p>
|
||||
|
||||
<h1>Google Calendars</h1>
|
||||
|
||||
<% for(var i = 0 ; i < feed.data.items.length ; i++ ) {
|
||||
|
||||
var calendar = feed.data.items[i]; %>
|
||||
<div>
|
||||
|
||||
<h2 style="color:white;background-color:<%= calendar["color"] %>"><%= calendar["title"] %></h2>
|
||||
|
||||
<p>canEdit: <%= calendar["canEdit"] %></p>
|
||||
<p>accessLevel: <%= calendar["accessLevel"] %></p>
|
||||
<p>timeZone: <%= calendar["timeZone"] %></p>
|
||||
<p>kind: <%= calendar["kind"] %></p>
|
||||
<p>updated: <%= calendar["updated"] %></p>
|
||||
<p>created: <%= calendar["created"] %></p>
|
||||
|
||||
</div>
|
||||
<% } %>
|
||||
24
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/express-gdata/views/google_contacts.ejs
generated
vendored
Normal file
24
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/express-gdata/views/google_contacts.ejs
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
<p><a href="/google_calendars">Check google_calendars</a></p>
|
||||
|
||||
<h1>Google Contacts</h1>
|
||||
|
||||
<% for(var i = 0 ; i < feed.feed.entry.length ; i++ ) {
|
||||
|
||||
var contact = feed.feed.entry[i]; %>
|
||||
|
||||
<div>
|
||||
<!-- you can access much more ! Just a sample: -->
|
||||
<%= contact["title"]["$t"] %>
|
||||
<% emails = contact["gd$email"] %>
|
||||
|
||||
<ul>
|
||||
<% for(var j = 0 ; j < emails.length ; j++) { %>
|
||||
<li><%= emails[j]["address" ]%></li>
|
||||
<% } %>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<% } %>
|
||||
9
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/express-gdata/views/layout.ejs
generated
vendored
Normal file
9
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/express-gdata/views/layout.ejs
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<%- body %>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
73
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/github-example.js
generated
vendored
Normal file
73
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/github-example.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
var http = require('http');
|
||||
var qs = require('querystring');
|
||||
// var OAuth = require('oauth'), OAuth2 = OAuth.OAuth2;
|
||||
var OAuth2 = require('../lib/oauth2.js').OAuth2;
|
||||
|
||||
var clientID = '';
|
||||
var clientSecret = '';
|
||||
var oauth2 = new OAuth2(clientID,
|
||||
clientSecret,
|
||||
'https://github.com/',
|
||||
'login/oauth/authorize',
|
||||
'login/oauth/access_token',
|
||||
null); /** Custom headers */
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
var p = req.url.split('/');
|
||||
pLen = p.length;
|
||||
|
||||
/**
|
||||
* Authorised url as per github docs:
|
||||
* https://developer.github.com/v3/oauth/#redirect-users-to-request-github-access
|
||||
*
|
||||
* getAuthorizedUrl: https://github.com/ciaranj/node-oauth/blob/master/lib/oauth2.js#L148
|
||||
* Adding params to authorize url with fields as mentioned in github docs
|
||||
*
|
||||
*/
|
||||
var authURL = oauth2.getAuthorizeUrl({
|
||||
redirect_uri: 'http://localhost:8080/code',
|
||||
scope: ['repo', 'user'],
|
||||
state: 'some random string to protect against cross-site request forgery attacks'
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* Creating an anchor with authURL as href and sending as response
|
||||
*/
|
||||
var body = '<a href="' + authURL + '"> Get Code </a>';
|
||||
if (pLen === 2 && p[1] === '') {
|
||||
res.writeHead(200, {
|
||||
'Content-Length': body.length,
|
||||
'Content-Type': 'text/html' });
|
||||
res.end(body);
|
||||
} else if (pLen === 2 && p[1].indexOf('code') === 0) {
|
||||
|
||||
/** Github sends auth code so that access_token can be obtained */
|
||||
var qsObj = {};
|
||||
|
||||
/** To obtain and parse code='...' from code?code='...' */
|
||||
qsObj = qs.parse(p[1].split('?')[1]);
|
||||
|
||||
/** Obtaining access_token */
|
||||
oauth2.getOAuthAccessToken(
|
||||
qsObj.code,
|
||||
{'redirect_uri': 'http://localhost:8080/code/'},
|
||||
function (e, access_token, refresh_token, results){
|
||||
if (e) {
|
||||
console.log(e);
|
||||
res.end(e);
|
||||
} else if (results.error) {
|
||||
console.log(results);
|
||||
res.end(JSON.stringify(results));
|
||||
}
|
||||
else {
|
||||
console.log('Obtained access_token: ', access_token);
|
||||
res.end( access_token);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
// Unhandled url
|
||||
}
|
||||
|
||||
}).listen(8080);
|
||||
31
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/term.ie.oauth-HMAC-SHA1.js
generated
vendored
Normal file
31
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/term.ie.oauth-HMAC-SHA1.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
var util= require('util')
|
||||
|
||||
var OAuth= require('../lib/oauth').OAuth;
|
||||
|
||||
var oa= new OAuth("http://term.ie/oauth/example/request_token.php",
|
||||
"http://term.ie/oauth/example/access_token.php",
|
||||
"key",
|
||||
"secret",
|
||||
"1.0",
|
||||
null,
|
||||
"HMAC-SHA1")
|
||||
|
||||
oa.getOAuthRequestToken(function(error, oauth_token, oauth_token_secret, results){
|
||||
if(error) util.puts('error :' + error)
|
||||
else {
|
||||
util.puts('oauth_token :' + oauth_token)
|
||||
util.puts('oauth_token_secret :' + oauth_token_secret)
|
||||
util.puts('requestoken results :' + util.inspect(results))
|
||||
util.puts("Requesting access token")
|
||||
oa.getOAuthAccessToken(oauth_token, oauth_token_secret, function(error, oauth_access_token, oauth_access_token_secret, results2) {
|
||||
util.puts('oauth_access_token :' + oauth_access_token)
|
||||
util.puts('oauth_token_secret :' + oauth_access_token_secret)
|
||||
util.puts('accesstoken results :' + util.inspect(results2))
|
||||
util.puts("Requesting access token")
|
||||
var data= "";
|
||||
oa.getProtectedResource("http://term.ie/oauth/example/echo_api.php?foo=bar&too=roo", "GET", oauth_access_token, oauth_access_token_secret, function (error, data, response) {
|
||||
util.puts(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
75
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/twitter-example.js
generated
vendored
Normal file
75
srcs/requirements/nestjs/api_back/node_modules/oauth/examples/twitter-example.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
var http = require('http');
|
||||
var OAuth = require('../lib/oauth.js').OAuth;
|
||||
var nodeUrl = require('url');
|
||||
var clientID = '';
|
||||
var clientSecret = '';
|
||||
var callbackURL = '';
|
||||
|
||||
oa = new OAuth(
|
||||
'https://api.twitter.com/oauth/request_token',
|
||||
'https://api.twitter.com/oauth/access_token',
|
||||
clientID,
|
||||
clientSecret,
|
||||
'1.0',
|
||||
callbackURL,
|
||||
'HMAC-SHA1'
|
||||
);
|
||||
|
||||
http.createServer(function (request, response) {
|
||||
oa.getOAuthRequestToken(function (error, oAuthToken, oAuthTokenSecret, results) {
|
||||
var urlObj = nodeUrl.parse(request.url, true);
|
||||
var authURL = 'https://twitter.com/' +
|
||||
'oauth/authenticate?oauth_token=' + oAuthToken;
|
||||
var handlers = {
|
||||
'/': function (request, response) {
|
||||
/**
|
||||
* Creating an anchor with authURL as href and sending as response
|
||||
*/
|
||||
var body = '<a href="' + authURL + '"> Get Code </a>';
|
||||
response.writeHead(200, {
|
||||
'Content-Length': body.length,
|
||||
'Content-Type': 'text/html' });
|
||||
response.end(body);
|
||||
},
|
||||
'/callback': function (request, response) {
|
||||
/** Obtaining access_token */
|
||||
var getOAuthRequestTokenCallback = function (error, oAuthAccessToken,
|
||||
oAuthAccessTokenSecret, results) {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
response.end(JSON.stringify({
|
||||
message: 'Error occured while getting access token',
|
||||
error: error
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
oa.get('https://api.twitter.com/1.1/account/verify_credentials.json',
|
||||
oAuthAccessToken,
|
||||
oAuthAccessTokenSecret,
|
||||
function (error, twitterResponseData, result) {
|
||||
if (error) {
|
||||
console.log(error)
|
||||
res.end(JSON.stringify(error));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
console.log(JSON.parse(twitterResponseData));
|
||||
} catch (parseError) {
|
||||
console.log(parseError);
|
||||
}
|
||||
console.log(twitterResponseData);
|
||||
response.end(twitterResponseData);
|
||||
});
|
||||
};
|
||||
|
||||
oa.getOAuthAccessToken(urlObj.query.oauth_token, oAuthTokenSecret,
|
||||
urlObj.query.oauth_verifier,
|
||||
getOAuthRequestTokenCallback);
|
||||
|
||||
}
|
||||
};
|
||||
handlers[urlObj.pathname](request, response);
|
||||
})
|
||||
|
||||
}).listen(3000);
|
||||
3
srcs/requirements/nestjs/api_back/node_modules/oauth/index.js
generated
vendored
Normal file
3
srcs/requirements/nestjs/api_back/node_modules/oauth/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
exports.OAuth = require("./lib/oauth").OAuth;
|
||||
exports.OAuthEcho = require("./lib/oauth").OAuthEcho;
|
||||
exports.OAuth2 = require("./lib/oauth2").OAuth2;
|
||||
4
srcs/requirements/nestjs/api_back/node_modules/oauth/lib/_utils.js
generated
vendored
Normal file
4
srcs/requirements/nestjs/api_back/node_modules/oauth/lib/_utils.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// Returns true if this is a host that closes *before* it ends?!?!
|
||||
module.exports.isAnEarlyCloseHost= function( hostName ) {
|
||||
return hostName && hostName.match(".*google(apis)?.com$")
|
||||
}
|
||||
581
srcs/requirements/nestjs/api_back/node_modules/oauth/lib/oauth.js
generated
vendored
Normal file
581
srcs/requirements/nestjs/api_back/node_modules/oauth/lib/oauth.js
generated
vendored
Normal file
@@ -0,0 +1,581 @@
|
||||
var crypto= require('crypto'),
|
||||
sha1= require('./sha1'),
|
||||
http= require('http'),
|
||||
https= require('https'),
|
||||
URL= require('url'),
|
||||
querystring= require('querystring'),
|
||||
OAuthUtils= require('./_utils');
|
||||
|
||||
exports.OAuth= function(requestUrl, accessUrl, consumerKey, consumerSecret, version, authorize_callback, signatureMethod, nonceSize, customHeaders) {
|
||||
this._isEcho = false;
|
||||
|
||||
this._requestUrl= requestUrl;
|
||||
this._accessUrl= accessUrl;
|
||||
this._consumerKey= consumerKey;
|
||||
this._consumerSecret= this._encodeData( consumerSecret );
|
||||
if (signatureMethod == "RSA-SHA1") {
|
||||
this._privateKey = consumerSecret;
|
||||
}
|
||||
this._version= version;
|
||||
if( authorize_callback === undefined ) {
|
||||
this._authorize_callback= "oob";
|
||||
}
|
||||
else {
|
||||
this._authorize_callback= authorize_callback;
|
||||
}
|
||||
|
||||
if( signatureMethod != "PLAINTEXT" && signatureMethod != "HMAC-SHA1" && signatureMethod != "RSA-SHA1")
|
||||
throw new Error("Un-supported signature method: " + signatureMethod )
|
||||
this._signatureMethod= signatureMethod;
|
||||
this._nonceSize= nonceSize || 32;
|
||||
this._headers= customHeaders || {"Accept" : "*/*",
|
||||
"Connection" : "close",
|
||||
"User-Agent" : "Node authentication"}
|
||||
this._clientOptions= this._defaultClientOptions= {"requestTokenHttpMethod": "POST",
|
||||
"accessTokenHttpMethod": "POST",
|
||||
"followRedirects": true};
|
||||
this._oauthParameterSeperator = ",";
|
||||
};
|
||||
|
||||
exports.OAuthEcho= function(realm, verify_credentials, consumerKey, consumerSecret, version, signatureMethod, nonceSize, customHeaders) {
|
||||
this._isEcho = true;
|
||||
|
||||
this._realm= realm;
|
||||
this._verifyCredentials = verify_credentials;
|
||||
this._consumerKey= consumerKey;
|
||||
this._consumerSecret= this._encodeData( consumerSecret );
|
||||
if (signatureMethod == "RSA-SHA1") {
|
||||
this._privateKey = consumerSecret;
|
||||
}
|
||||
this._version= version;
|
||||
|
||||
if( signatureMethod != "PLAINTEXT" && signatureMethod != "HMAC-SHA1" && signatureMethod != "RSA-SHA1")
|
||||
throw new Error("Un-supported signature method: " + signatureMethod );
|
||||
this._signatureMethod= signatureMethod;
|
||||
this._nonceSize= nonceSize || 32;
|
||||
this._headers= customHeaders || {"Accept" : "*/*",
|
||||
"Connection" : "close",
|
||||
"User-Agent" : "Node authentication"};
|
||||
this._oauthParameterSeperator = ",";
|
||||
}
|
||||
|
||||
exports.OAuthEcho.prototype = exports.OAuth.prototype;
|
||||
|
||||
exports.OAuth.prototype._getTimestamp= function() {
|
||||
return Math.floor( (new Date()).getTime() / 1000 );
|
||||
}
|
||||
|
||||
exports.OAuth.prototype._encodeData= function(toEncode){
|
||||
if( toEncode == null || toEncode == "" ) return ""
|
||||
else {
|
||||
var result= encodeURIComponent(toEncode);
|
||||
// Fix the mismatch between OAuth's RFC3986's and Javascript's beliefs in what is right and wrong ;)
|
||||
return result.replace(/\!/g, "%21")
|
||||
.replace(/\'/g, "%27")
|
||||
.replace(/\(/g, "%28")
|
||||
.replace(/\)/g, "%29")
|
||||
.replace(/\*/g, "%2A");
|
||||
}
|
||||
}
|
||||
|
||||
exports.OAuth.prototype._decodeData= function(toDecode) {
|
||||
if( toDecode != null ) {
|
||||
toDecode = toDecode.replace(/\+/g, " ");
|
||||
}
|
||||
return decodeURIComponent( toDecode);
|
||||
}
|
||||
|
||||
exports.OAuth.prototype._getSignature= function(method, url, parameters, tokenSecret) {
|
||||
var signatureBase= this._createSignatureBase(method, url, parameters);
|
||||
return this._createSignature( signatureBase, tokenSecret );
|
||||
}
|
||||
|
||||
exports.OAuth.prototype._normalizeUrl= function(url) {
|
||||
var parsedUrl= URL.parse(url, true)
|
||||
var port ="";
|
||||
if( parsedUrl.port ) {
|
||||
if( (parsedUrl.protocol == "http:" && parsedUrl.port != "80" ) ||
|
||||
(parsedUrl.protocol == "https:" && parsedUrl.port != "443") ) {
|
||||
port= ":" + parsedUrl.port;
|
||||
}
|
||||
}
|
||||
|
||||
if( !parsedUrl.pathname || parsedUrl.pathname == "" ) parsedUrl.pathname ="/";
|
||||
|
||||
return parsedUrl.protocol + "//" + parsedUrl.hostname + port + parsedUrl.pathname;
|
||||
}
|
||||
|
||||
// Is the parameter considered an OAuth parameter
|
||||
exports.OAuth.prototype._isParameterNameAnOAuthParameter= function(parameter) {
|
||||
var m = parameter.match('^oauth_');
|
||||
if( m && ( m[0] === "oauth_" ) ) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// build the OAuth request authorization header
|
||||
exports.OAuth.prototype._buildAuthorizationHeaders= function(orderedParameters) {
|
||||
var authHeader="OAuth ";
|
||||
if( this._isEcho ) {
|
||||
authHeader += 'realm="' + this._realm + '",';
|
||||
}
|
||||
|
||||
for( var i= 0 ; i < orderedParameters.length; i++) {
|
||||
// Whilst the all the parameters should be included within the signature, only the oauth_ arguments
|
||||
// should appear within the authorization header.
|
||||
if( this._isParameterNameAnOAuthParameter(orderedParameters[i][0]) ) {
|
||||
authHeader+= "" + this._encodeData(orderedParameters[i][0])+"=\""+ this._encodeData(orderedParameters[i][1])+"\""+ this._oauthParameterSeperator;
|
||||
}
|
||||
}
|
||||
|
||||
authHeader= authHeader.substring(0, authHeader.length-this._oauthParameterSeperator.length);
|
||||
return authHeader;
|
||||
}
|
||||
|
||||
// Takes an object literal that represents the arguments, and returns an array
|
||||
// of argument/value pairs.
|
||||
exports.OAuth.prototype._makeArrayOfArgumentsHash= function(argumentsHash) {
|
||||
var argument_pairs= [];
|
||||
for(var key in argumentsHash ) {
|
||||
if (argumentsHash.hasOwnProperty(key)) {
|
||||
var value= argumentsHash[key];
|
||||
if( Array.isArray(value) ) {
|
||||
for(var i=0;i<value.length;i++) {
|
||||
argument_pairs[argument_pairs.length]= [key, value[i]];
|
||||
}
|
||||
}
|
||||
else {
|
||||
argument_pairs[argument_pairs.length]= [key, value];
|
||||
}
|
||||
}
|
||||
}
|
||||
return argument_pairs;
|
||||
}
|
||||
|
||||
// Sorts the encoded key value pairs by encoded name, then encoded value
|
||||
exports.OAuth.prototype._sortRequestParams= function(argument_pairs) {
|
||||
// Sort by name, then value.
|
||||
argument_pairs.sort(function(a,b) {
|
||||
if ( a[0]== b[0] ) {
|
||||
return a[1] < b[1] ? -1 : 1;
|
||||
}
|
||||
else return a[0] < b[0] ? -1 : 1;
|
||||
});
|
||||
|
||||
return argument_pairs;
|
||||
}
|
||||
|
||||
exports.OAuth.prototype._normaliseRequestParams= function(args) {
|
||||
var argument_pairs= this._makeArrayOfArgumentsHash(args);
|
||||
// First encode them #3.4.1.3.2 .1
|
||||
for(var i=0;i<argument_pairs.length;i++) {
|
||||
argument_pairs[i][0]= this._encodeData( argument_pairs[i][0] );
|
||||
argument_pairs[i][1]= this._encodeData( argument_pairs[i][1] );
|
||||
}
|
||||
|
||||
// Then sort them #3.4.1.3.2 .2
|
||||
argument_pairs= this._sortRequestParams( argument_pairs );
|
||||
|
||||
// Then concatenate together #3.4.1.3.2 .3 & .4
|
||||
var args= "";
|
||||
for(var i=0;i<argument_pairs.length;i++) {
|
||||
args+= argument_pairs[i][0];
|
||||
args+= "="
|
||||
args+= argument_pairs[i][1];
|
||||
if( i < argument_pairs.length-1 ) args+= "&";
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
exports.OAuth.prototype._createSignatureBase= function(method, url, parameters) {
|
||||
url= this._encodeData( this._normalizeUrl(url) );
|
||||
parameters= this._encodeData( parameters );
|
||||
return method.toUpperCase() + "&" + url + "&" + parameters;
|
||||
}
|
||||
|
||||
exports.OAuth.prototype._createSignature= function(signatureBase, tokenSecret) {
|
||||
if( tokenSecret === undefined ) var tokenSecret= "";
|
||||
else tokenSecret= this._encodeData( tokenSecret );
|
||||
// consumerSecret is already encoded
|
||||
var key= this._consumerSecret + "&" + tokenSecret;
|
||||
|
||||
var hash= ""
|
||||
if( this._signatureMethod == "PLAINTEXT" ) {
|
||||
hash= key;
|
||||
}
|
||||
else if (this._signatureMethod == "RSA-SHA1") {
|
||||
key = this._privateKey || "";
|
||||
hash= crypto.createSign("RSA-SHA1").update(signatureBase).sign(key, 'base64');
|
||||
}
|
||||
else {
|
||||
if( crypto.Hmac ) {
|
||||
hash = crypto.createHmac("sha1", key).update(signatureBase).digest("base64");
|
||||
}
|
||||
else {
|
||||
hash= sha1.HMACSHA1(key, signatureBase);
|
||||
}
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
exports.OAuth.prototype.NONCE_CHARS= ['a','b','c','d','e','f','g','h','i','j','k','l','m','n',
|
||||
'o','p','q','r','s','t','u','v','w','x','y','z','A','B',
|
||||
'C','D','E','F','G','H','I','J','K','L','M','N','O','P',
|
||||
'Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3',
|
||||
'4','5','6','7','8','9'];
|
||||
|
||||
exports.OAuth.prototype._getNonce= function(nonceSize) {
|
||||
var result = [];
|
||||
var chars= this.NONCE_CHARS;
|
||||
var char_pos;
|
||||
var nonce_chars_length= chars.length;
|
||||
|
||||
for (var i = 0; i < nonceSize; i++) {
|
||||
char_pos= Math.floor(Math.random() * nonce_chars_length);
|
||||
result[i]= chars[char_pos];
|
||||
}
|
||||
return result.join('');
|
||||
}
|
||||
|
||||
exports.OAuth.prototype._createClient= function( port, hostname, method, path, headers, sslEnabled ) {
|
||||
var options = {
|
||||
host: hostname,
|
||||
port: port,
|
||||
path: path,
|
||||
method: method,
|
||||
headers: headers
|
||||
};
|
||||
var httpModel;
|
||||
if( sslEnabled ) {
|
||||
httpModel= https;
|
||||
} else {
|
||||
httpModel= http;
|
||||
}
|
||||
return httpModel.request(options);
|
||||
}
|
||||
|
||||
exports.OAuth.prototype._prepareParameters= function( oauth_token, oauth_token_secret, method, url, extra_params ) {
|
||||
var oauthParameters= {
|
||||
"oauth_timestamp": this._getTimestamp(),
|
||||
"oauth_nonce": this._getNonce(this._nonceSize),
|
||||
"oauth_version": this._version,
|
||||
"oauth_signature_method": this._signatureMethod,
|
||||
"oauth_consumer_key": this._consumerKey
|
||||
};
|
||||
|
||||
if( oauth_token ) {
|
||||
oauthParameters["oauth_token"]= oauth_token;
|
||||
}
|
||||
|
||||
var sig;
|
||||
if( this._isEcho ) {
|
||||
sig = this._getSignature( "GET", this._verifyCredentials, this._normaliseRequestParams(oauthParameters), oauth_token_secret);
|
||||
}
|
||||
else {
|
||||
if( extra_params ) {
|
||||
for( var key in extra_params ) {
|
||||
if (extra_params.hasOwnProperty(key)) oauthParameters[key]= extra_params[key];
|
||||
}
|
||||
}
|
||||
var parsedUrl= URL.parse( url, false );
|
||||
|
||||
if( parsedUrl.query ) {
|
||||
var key2;
|
||||
var extraParameters= querystring.parse(parsedUrl.query);
|
||||
for(var key in extraParameters ) {
|
||||
var value= extraParameters[key];
|
||||
if( typeof value == "object" ){
|
||||
// TODO: This probably should be recursive
|
||||
for(key2 in value){
|
||||
oauthParameters[key + "[" + key2 + "]"] = value[key2];
|
||||
}
|
||||
} else {
|
||||
oauthParameters[key]= value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sig = this._getSignature( method, url, this._normaliseRequestParams(oauthParameters), oauth_token_secret);
|
||||
}
|
||||
|
||||
var orderedParameters= this._sortRequestParams( this._makeArrayOfArgumentsHash(oauthParameters) );
|
||||
orderedParameters[orderedParameters.length]= ["oauth_signature", sig];
|
||||
return orderedParameters;
|
||||
}
|
||||
|
||||
exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_token_secret, method, url, extra_params, post_body, post_content_type, callback ) {
|
||||
var orderedParameters= this._prepareParameters(oauth_token, oauth_token_secret, method, url, extra_params);
|
||||
|
||||
if( !post_content_type ) {
|
||||
post_content_type= "application/x-www-form-urlencoded";
|
||||
}
|
||||
var parsedUrl= URL.parse( url, false );
|
||||
if( parsedUrl.protocol == "http:" && !parsedUrl.port ) parsedUrl.port= 80;
|
||||
if( parsedUrl.protocol == "https:" && !parsedUrl.port ) parsedUrl.port= 443;
|
||||
|
||||
var headers= {};
|
||||
var authorization = this._buildAuthorizationHeaders(orderedParameters);
|
||||
if ( this._isEcho ) {
|
||||
headers["X-Verify-Credentials-Authorization"]= authorization;
|
||||
}
|
||||
else {
|
||||
headers["Authorization"]= authorization;
|
||||
}
|
||||
|
||||
headers["Host"] = parsedUrl.host
|
||||
|
||||
for( var key in this._headers ) {
|
||||
if (this._headers.hasOwnProperty(key)) {
|
||||
headers[key]= this._headers[key];
|
||||
}
|
||||
}
|
||||
|
||||
// Filter out any passed extra_params that are really to do with OAuth
|
||||
for(var key in extra_params) {
|
||||
if( this._isParameterNameAnOAuthParameter( key ) ) {
|
||||
delete extra_params[key];
|
||||
}
|
||||
}
|
||||
|
||||
if( (method == "POST" || method == "PUT") && ( post_body == null && extra_params != null) ) {
|
||||
// Fix the mismatch between the output of querystring.stringify() and this._encodeData()
|
||||
post_body= querystring.stringify(extra_params)
|
||||
.replace(/\!/g, "%21")
|
||||
.replace(/\'/g, "%27")
|
||||
.replace(/\(/g, "%28")
|
||||
.replace(/\)/g, "%29")
|
||||
.replace(/\*/g, "%2A");
|
||||
}
|
||||
|
||||
if( post_body ) {
|
||||
if ( Buffer.isBuffer(post_body) ) {
|
||||
headers["Content-length"]= post_body.length;
|
||||
} else {
|
||||
headers["Content-length"]= Buffer.byteLength(post_body);
|
||||
}
|
||||
} else {
|
||||
headers["Content-length"]= 0;
|
||||
}
|
||||
|
||||
headers["Content-Type"]= post_content_type;
|
||||
|
||||
var path;
|
||||
if( !parsedUrl.pathname || parsedUrl.pathname == "" ) parsedUrl.pathname ="/";
|
||||
if( parsedUrl.query ) path= parsedUrl.pathname + "?"+ parsedUrl.query ;
|
||||
else path= parsedUrl.pathname;
|
||||
|
||||
var request;
|
||||
if( parsedUrl.protocol == "https:" ) {
|
||||
request= this._createClient(parsedUrl.port, parsedUrl.hostname, method, path, headers, true);
|
||||
}
|
||||
else {
|
||||
request= this._createClient(parsedUrl.port, parsedUrl.hostname, method, path, headers);
|
||||
}
|
||||
|
||||
var clientOptions = this._clientOptions;
|
||||
if( callback ) {
|
||||
var data="";
|
||||
var self= this;
|
||||
|
||||
// Some hosts *cough* google appear to close the connection early / send no content-length header
|
||||
// allow this behaviour.
|
||||
var allowEarlyClose= OAuthUtils.isAnEarlyCloseHost( parsedUrl.hostname );
|
||||
var callbackCalled= false;
|
||||
var passBackControl = function( response ) {
|
||||
if(!callbackCalled) {
|
||||
callbackCalled= true;
|
||||
if ( response.statusCode >= 200 && response.statusCode <= 299 ) {
|
||||
callback(null, data, response);
|
||||
} else {
|
||||
// Follow 301 or 302 redirects with Location HTTP header
|
||||
if((response.statusCode == 301 || response.statusCode == 302) && clientOptions.followRedirects && response.headers && response.headers.location) {
|
||||
self._performSecureRequest( oauth_token, oauth_token_secret, method, response.headers.location, extra_params, post_body, post_content_type, callback);
|
||||
}
|
||||
else {
|
||||
callback({ statusCode: response.statusCode, data: data }, data, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
request.on('response', function (response) {
|
||||
response.setEncoding('utf8');
|
||||
response.on('data', function (chunk) {
|
||||
data+=chunk;
|
||||
});
|
||||
response.on('end', function () {
|
||||
passBackControl( response );
|
||||
});
|
||||
response.on('close', function () {
|
||||
if( allowEarlyClose ) {
|
||||
passBackControl( response );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
request.on("error", function(err) {
|
||||
if(!callbackCalled) {
|
||||
callbackCalled= true;
|
||||
callback( err )
|
||||
}
|
||||
});
|
||||
|
||||
if( (method == "POST" || method =="PUT") && post_body != null && post_body != "" ) {
|
||||
request.write(post_body);
|
||||
}
|
||||
request.end();
|
||||
}
|
||||
else {
|
||||
if( (method == "POST" || method =="PUT") && post_body != null && post_body != "" ) {
|
||||
request.write(post_body);
|
||||
}
|
||||
return request;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
exports.OAuth.prototype.setClientOptions= function(options) {
|
||||
var key,
|
||||
mergedOptions= {},
|
||||
hasOwnProperty= Object.prototype.hasOwnProperty;
|
||||
|
||||
for( key in this._defaultClientOptions ) {
|
||||
if( !hasOwnProperty.call(options, key) ) {
|
||||
mergedOptions[key]= this._defaultClientOptions[key];
|
||||
} else {
|
||||
mergedOptions[key]= options[key];
|
||||
}
|
||||
}
|
||||
|
||||
this._clientOptions= mergedOptions;
|
||||
};
|
||||
|
||||
exports.OAuth.prototype.getOAuthAccessToken= function(oauth_token, oauth_token_secret, oauth_verifier, callback) {
|
||||
var extraParams= {};
|
||||
if( typeof oauth_verifier == "function" ) {
|
||||
callback= oauth_verifier;
|
||||
} else {
|
||||
extraParams.oauth_verifier= oauth_verifier;
|
||||
}
|
||||
|
||||
this._performSecureRequest( oauth_token, oauth_token_secret, this._clientOptions.accessTokenHttpMethod, this._accessUrl, extraParams, null, null, function(error, data, response) {
|
||||
if( error ) callback(error);
|
||||
else {
|
||||
var results= querystring.parse( data );
|
||||
var oauth_access_token= results["oauth_token"];
|
||||
delete results["oauth_token"];
|
||||
var oauth_access_token_secret= results["oauth_token_secret"];
|
||||
delete results["oauth_token_secret"];
|
||||
callback(null, oauth_access_token, oauth_access_token_secret, results );
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
exports.OAuth.prototype.getProtectedResource= function(url, method, oauth_token, oauth_token_secret, callback) {
|
||||
this._performSecureRequest( oauth_token, oauth_token_secret, method, url, null, "", null, callback );
|
||||
}
|
||||
|
||||
exports.OAuth.prototype.delete= function(url, oauth_token, oauth_token_secret, callback) {
|
||||
return this._performSecureRequest( oauth_token, oauth_token_secret, "DELETE", url, null, "", null, callback );
|
||||
}
|
||||
|
||||
exports.OAuth.prototype.get= function(url, oauth_token, oauth_token_secret, callback) {
|
||||
return this._performSecureRequest( oauth_token, oauth_token_secret, "GET", url, null, "", null, callback );
|
||||
}
|
||||
|
||||
exports.OAuth.prototype._putOrPost= function(method, url, oauth_token, oauth_token_secret, post_body, post_content_type, callback) {
|
||||
var extra_params= null;
|
||||
if( typeof post_content_type == "function" ) {
|
||||
callback= post_content_type;
|
||||
post_content_type= null;
|
||||
}
|
||||
if ( typeof post_body != "string" && !Buffer.isBuffer(post_body) ) {
|
||||
post_content_type= "application/x-www-form-urlencoded"
|
||||
extra_params= post_body;
|
||||
post_body= null;
|
||||
}
|
||||
return this._performSecureRequest( oauth_token, oauth_token_secret, method, url, extra_params, post_body, post_content_type, callback );
|
||||
}
|
||||
|
||||
|
||||
exports.OAuth.prototype.put= function(url, oauth_token, oauth_token_secret, post_body, post_content_type, callback) {
|
||||
return this._putOrPost("PUT", url, oauth_token, oauth_token_secret, post_body, post_content_type, callback);
|
||||
}
|
||||
|
||||
exports.OAuth.prototype.post= function(url, oauth_token, oauth_token_secret, post_body, post_content_type, callback) {
|
||||
return this._putOrPost("POST", url, oauth_token, oauth_token_secret, post_body, post_content_type, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a request token from the OAuth provider and passes that information back
|
||||
* to the calling code.
|
||||
*
|
||||
* The callback should expect a function of the following form:
|
||||
*
|
||||
* function(err, token, token_secret, parsedQueryString) {}
|
||||
*
|
||||
* This method has optional parameters so can be called in the following 2 ways:
|
||||
*
|
||||
* 1) Primary use case: Does a basic request with no extra parameters
|
||||
* getOAuthRequestToken( callbackFunction )
|
||||
*
|
||||
* 2) As above but allows for provision of extra parameters to be sent as part of the query to the server.
|
||||
* getOAuthRequestToken( extraParams, callbackFunction )
|
||||
*
|
||||
* N.B. This method will HTTP POST verbs by default, if you wish to override this behaviour you will
|
||||
* need to provide a requestTokenHttpMethod option when creating the client.
|
||||
*
|
||||
**/
|
||||
exports.OAuth.prototype.getOAuthRequestToken= function( extraParams, callback ) {
|
||||
if( typeof extraParams == "function" ){
|
||||
callback = extraParams;
|
||||
extraParams = {};
|
||||
}
|
||||
// Callbacks are 1.0A related
|
||||
if( this._authorize_callback ) {
|
||||
extraParams["oauth_callback"]= this._authorize_callback;
|
||||
}
|
||||
this._performSecureRequest( null, null, this._clientOptions.requestTokenHttpMethod, this._requestUrl, extraParams, null, null, function(error, data, response) {
|
||||
if( error ) callback(error);
|
||||
else {
|
||||
var results= querystring.parse(data);
|
||||
|
||||
var oauth_token= results["oauth_token"];
|
||||
var oauth_token_secret= results["oauth_token_secret"];
|
||||
delete results["oauth_token"];
|
||||
delete results["oauth_token_secret"];
|
||||
callback(null, oauth_token, oauth_token_secret, results );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
exports.OAuth.prototype.signUrl= function(url, oauth_token, oauth_token_secret, method) {
|
||||
|
||||
if( method === undefined ) {
|
||||
var method= "GET";
|
||||
}
|
||||
|
||||
var orderedParameters= this._prepareParameters(oauth_token, oauth_token_secret, method, url, {});
|
||||
var parsedUrl= URL.parse( url, false );
|
||||
|
||||
var query="";
|
||||
for( var i= 0 ; i < orderedParameters.length; i++) {
|
||||
query+= orderedParameters[i][0]+"="+ this._encodeData(orderedParameters[i][1]) + "&";
|
||||
}
|
||||
query= query.substring(0, query.length-1);
|
||||
|
||||
return parsedUrl.protocol + "//"+ parsedUrl.host + parsedUrl.pathname + "?" + query;
|
||||
};
|
||||
|
||||
exports.OAuth.prototype.authHeader= function(url, oauth_token, oauth_token_secret, method) {
|
||||
if( method === undefined ) {
|
||||
var method= "GET";
|
||||
}
|
||||
|
||||
var orderedParameters= this._prepareParameters(oauth_token, oauth_token_secret, method, url, {});
|
||||
return this._buildAuthorizationHeaders(orderedParameters);
|
||||
};
|
||||
228
srcs/requirements/nestjs/api_back/node_modules/oauth/lib/oauth2.js
generated
vendored
Normal file
228
srcs/requirements/nestjs/api_back/node_modules/oauth/lib/oauth2.js
generated
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
var querystring= require('querystring'),
|
||||
crypto= require('crypto'),
|
||||
https= require('https'),
|
||||
http= require('http'),
|
||||
URL= require('url'),
|
||||
OAuthUtils= require('./_utils');
|
||||
|
||||
exports.OAuth2= function(clientId, clientSecret, baseSite, authorizePath, accessTokenPath, customHeaders) {
|
||||
this._clientId= clientId;
|
||||
this._clientSecret= clientSecret;
|
||||
this._baseSite= baseSite;
|
||||
this._authorizeUrl= authorizePath || "/oauth/authorize";
|
||||
this._accessTokenUrl= accessTokenPath || "/oauth/access_token";
|
||||
this._accessTokenName= "access_token";
|
||||
this._authMethod= "Bearer";
|
||||
this._customHeaders = customHeaders || {};
|
||||
this._useAuthorizationHeaderForGET= false;
|
||||
|
||||
//our agent
|
||||
this._agent = undefined;
|
||||
};
|
||||
|
||||
// Allows you to set an agent to use instead of the default HTTP or
|
||||
// HTTPS agents. Useful when dealing with your own certificates.
|
||||
exports.OAuth2.prototype.setAgent = function(agent) {
|
||||
this._agent = agent;
|
||||
};
|
||||
|
||||
// This 'hack' method is required for sites that don't use
|
||||
// 'access_token' as the name of the access token (for requests).
|
||||
// ( http://tools.ietf.org/html/draft-ietf-oauth-v2-16#section-7 )
|
||||
// it isn't clear what the correct value should be atm, so allowing
|
||||
// for specific (temporary?) override for now.
|
||||
exports.OAuth2.prototype.setAccessTokenName= function ( name ) {
|
||||
this._accessTokenName= name;
|
||||
}
|
||||
|
||||
// Sets the authorization method for Authorization header.
|
||||
// e.g. Authorization: Bearer <token> # "Bearer" is the authorization method.
|
||||
exports.OAuth2.prototype.setAuthMethod = function ( authMethod ) {
|
||||
this._authMethod = authMethod;
|
||||
};
|
||||
|
||||
|
||||
// If you use the OAuth2 exposed 'get' method (and don't construct your own _request call )
|
||||
// this will specify whether to use an 'Authorize' header instead of passing the access_token as a query parameter
|
||||
exports.OAuth2.prototype.useAuthorizationHeaderforGET = function(useIt) {
|
||||
this._useAuthorizationHeaderForGET= useIt;
|
||||
}
|
||||
|
||||
exports.OAuth2.prototype._getAccessTokenUrl= function() {
|
||||
return this._baseSite + this._accessTokenUrl; /* + "?" + querystring.stringify(params); */
|
||||
}
|
||||
|
||||
// Build the authorization header. In particular, build the part after the colon.
|
||||
// e.g. Authorization: Bearer <token> # Build "Bearer <token>"
|
||||
exports.OAuth2.prototype.buildAuthHeader= function(token) {
|
||||
return this._authMethod + ' ' + token;
|
||||
};
|
||||
|
||||
exports.OAuth2.prototype._chooseHttpLibrary= function( parsedUrl ) {
|
||||
var http_library= https;
|
||||
// As this is OAUth2, we *assume* https unless told explicitly otherwise.
|
||||
if( parsedUrl.protocol != "https:" ) {
|
||||
http_library= http;
|
||||
}
|
||||
return http_library;
|
||||
};
|
||||
|
||||
exports.OAuth2.prototype._request= function(method, url, headers, post_body, access_token, callback) {
|
||||
|
||||
var parsedUrl= URL.parse( url, true );
|
||||
if( parsedUrl.protocol == "https:" && !parsedUrl.port ) {
|
||||
parsedUrl.port= 443;
|
||||
}
|
||||
|
||||
var http_library= this._chooseHttpLibrary( parsedUrl );
|
||||
|
||||
|
||||
var realHeaders= {};
|
||||
for( var key in this._customHeaders ) {
|
||||
realHeaders[key]= this._customHeaders[key];
|
||||
}
|
||||
if( headers ) {
|
||||
for(var key in headers) {
|
||||
realHeaders[key] = headers[key];
|
||||
}
|
||||
}
|
||||
realHeaders['Host']= parsedUrl.host;
|
||||
|
||||
if (!realHeaders['User-Agent']) {
|
||||
realHeaders['User-Agent'] = 'Node-oauth';
|
||||
}
|
||||
|
||||
if( post_body ) {
|
||||
if ( Buffer.isBuffer(post_body) ) {
|
||||
realHeaders["Content-Length"]= post_body.length;
|
||||
} else {
|
||||
realHeaders["Content-Length"]= Buffer.byteLength(post_body);
|
||||
}
|
||||
} else {
|
||||
realHeaders["Content-length"]= 0;
|
||||
}
|
||||
|
||||
if( access_token && !('Authorization' in realHeaders)) {
|
||||
if( ! parsedUrl.query ) parsedUrl.query= {};
|
||||
parsedUrl.query[this._accessTokenName]= access_token;
|
||||
}
|
||||
|
||||
var queryStr= querystring.stringify(parsedUrl.query);
|
||||
if( queryStr ) queryStr= "?" + queryStr;
|
||||
var options = {
|
||||
host:parsedUrl.hostname,
|
||||
port: parsedUrl.port,
|
||||
path: parsedUrl.pathname + queryStr,
|
||||
method: method,
|
||||
headers: realHeaders
|
||||
};
|
||||
|
||||
this._executeRequest( http_library, options, post_body, callback );
|
||||
}
|
||||
|
||||
exports.OAuth2.prototype._executeRequest= function( http_library, options, post_body, callback ) {
|
||||
// Some hosts *cough* google appear to close the connection early / send no content-length header
|
||||
// allow this behaviour.
|
||||
var allowEarlyClose= OAuthUtils.isAnEarlyCloseHost(options.host);
|
||||
var callbackCalled= false;
|
||||
function passBackControl( response, result ) {
|
||||
if(!callbackCalled) {
|
||||
callbackCalled=true;
|
||||
if( !(response.statusCode >= 200 && response.statusCode <= 299) && (response.statusCode != 301) && (response.statusCode != 302) ) {
|
||||
callback({ statusCode: response.statusCode, data: result });
|
||||
} else {
|
||||
callback(null, result, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var result= "";
|
||||
|
||||
//set the agent on the request options
|
||||
if (this._agent) {
|
||||
options.agent = this._agent;
|
||||
}
|
||||
|
||||
var request = http_library.request(options);
|
||||
request.on('response', function (response) {
|
||||
response.on("data", function (chunk) {
|
||||
result+= chunk
|
||||
});
|
||||
response.on("close", function (err) {
|
||||
if( allowEarlyClose ) {
|
||||
passBackControl( response, result );
|
||||
}
|
||||
});
|
||||
response.addListener("end", function () {
|
||||
passBackControl( response, result );
|
||||
});
|
||||
});
|
||||
request.on('error', function(e) {
|
||||
callbackCalled= true;
|
||||
callback(e);
|
||||
});
|
||||
|
||||
if( (options.method == 'POST' || options.method == 'PUT') && post_body ) {
|
||||
request.write(post_body);
|
||||
}
|
||||
request.end();
|
||||
}
|
||||
|
||||
exports.OAuth2.prototype.getAuthorizeUrl= function( params ) {
|
||||
var params= params || {};
|
||||
params['client_id'] = this._clientId;
|
||||
return this._baseSite + this._authorizeUrl + "?" + querystring.stringify(params);
|
||||
}
|
||||
|
||||
exports.OAuth2.prototype.getOAuthAccessToken= function(code, params, callback) {
|
||||
var params= params || {};
|
||||
params['client_id'] = this._clientId;
|
||||
params['client_secret'] = this._clientSecret;
|
||||
var codeParam = (params.grant_type === 'refresh_token') ? 'refresh_token' : 'code';
|
||||
params[codeParam]= code;
|
||||
|
||||
var post_data= querystring.stringify( params );
|
||||
var post_headers= {
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
};
|
||||
|
||||
|
||||
this._request("POST", this._getAccessTokenUrl(), post_headers, post_data, null, function(error, data, response) {
|
||||
if( error ) callback(error);
|
||||
else {
|
||||
var results;
|
||||
try {
|
||||
// As of http://tools.ietf.org/html/draft-ietf-oauth-v2-07
|
||||
// responses should be in JSON
|
||||
results= JSON.parse( data );
|
||||
}
|
||||
catch(e) {
|
||||
// .... However both Facebook + Github currently use rev05 of the spec
|
||||
// and neither seem to specify a content-type correctly in their response headers :(
|
||||
// clients of these services will suffer a *minor* performance cost of the exception
|
||||
// being thrown
|
||||
results= querystring.parse( data );
|
||||
}
|
||||
var access_token= results["access_token"];
|
||||
var refresh_token= results["refresh_token"];
|
||||
delete results["refresh_token"];
|
||||
callback(null, access_token, refresh_token, results); // callback results =-=
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
exports.OAuth2.prototype.getProtectedResource= function(url, access_token, callback) {
|
||||
this._request("GET", url, {}, "", access_token, callback );
|
||||
}
|
||||
|
||||
exports.OAuth2.prototype.get= function(url, access_token, callback) {
|
||||
if( this._useAuthorizationHeaderForGET ) {
|
||||
var headers= {'Authorization': this.buildAuthHeader(access_token) }
|
||||
access_token= null;
|
||||
}
|
||||
else {
|
||||
headers= {};
|
||||
}
|
||||
this._request("GET", url, headers, "", access_token, callback );
|
||||
}
|
||||
334
srcs/requirements/nestjs/api_back/node_modules/oauth/lib/sha1.js
generated
vendored
Normal file
334
srcs/requirements/nestjs/api_back/node_modules/oauth/lib/sha1.js
generated
vendored
Normal file
@@ -0,0 +1,334 @@
|
||||
/*
|
||||
* A JavaScript implementation of the Secure Hash Algorithm, SHA-1, as defined
|
||||
* in FIPS 180-1
|
||||
* Version 2.2 Copyright Paul Johnston 2000 - 2009.
|
||||
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
* Distributed under the BSD License
|
||||
* See http://pajhome.org.uk/crypt/md5 for details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Configurable variables. You may need to tweak these to be compatible with
|
||||
* the server-side, but the defaults work in most cases.
|
||||
*/
|
||||
var hexcase = 1; /* hex output format. 0 - lowercase; 1 - uppercase */
|
||||
var b64pad = "="; /* base-64 pad character. "=" for strict RFC compliance */
|
||||
|
||||
/*
|
||||
* These are the functions you'll usually want to call
|
||||
* They take string arguments and return either hex or base-64 encoded strings
|
||||
*/
|
||||
function hex_sha1(s) { return rstr2hex(rstr_sha1(str2rstr_utf8(s))); }
|
||||
function b64_sha1(s) { return rstr2b64(rstr_sha1(str2rstr_utf8(s))); }
|
||||
function any_sha1(s, e) { return rstr2any(rstr_sha1(str2rstr_utf8(s)), e); }
|
||||
function hex_hmac_sha1(k, d)
|
||||
{ return rstr2hex(rstr_hmac_sha1(str2rstr_utf8(k), str2rstr_utf8(d))); }
|
||||
function b64_hmac_sha1(k, d)
|
||||
{ return rstr2b64(rstr_hmac_sha1(str2rstr_utf8(k), str2rstr_utf8(d))); }
|
||||
function any_hmac_sha1(k, d, e)
|
||||
{ return rstr2any(rstr_hmac_sha1(str2rstr_utf8(k), str2rstr_utf8(d)), e); }
|
||||
|
||||
/*
|
||||
* Perform a simple self-test to see if the VM is working
|
||||
*/
|
||||
function sha1_vm_test()
|
||||
{
|
||||
return hex_sha1("abc").toLowerCase() == "a9993e364706816aba3e25717850c26c9cd0d89d";
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the SHA1 of a raw string
|
||||
*/
|
||||
function rstr_sha1(s)
|
||||
{
|
||||
return binb2rstr(binb_sha1(rstr2binb(s), s.length * 8));
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the HMAC-SHA1 of a key and some data (raw strings)
|
||||
*/
|
||||
function rstr_hmac_sha1(key, data)
|
||||
{
|
||||
var bkey = rstr2binb(key);
|
||||
if(bkey.length > 16) bkey = binb_sha1(bkey, key.length * 8);
|
||||
|
||||
var ipad = Array(16), opad = Array(16);
|
||||
for(var i = 0; i < 16; i++)
|
||||
{
|
||||
ipad[i] = bkey[i] ^ 0x36363636;
|
||||
opad[i] = bkey[i] ^ 0x5C5C5C5C;
|
||||
}
|
||||
|
||||
var hash = binb_sha1(ipad.concat(rstr2binb(data)), 512 + data.length * 8);
|
||||
return binb2rstr(binb_sha1(opad.concat(hash), 512 + 160));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to a hex string
|
||||
*/
|
||||
function rstr2hex(input)
|
||||
{
|
||||
try { hexcase } catch(e) { hexcase=0; }
|
||||
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
|
||||
var output = "";
|
||||
var x;
|
||||
for(var i = 0; i < input.length; i++)
|
||||
{
|
||||
x = input.charCodeAt(i);
|
||||
output += hex_tab.charAt((x >>> 4) & 0x0F)
|
||||
+ hex_tab.charAt( x & 0x0F);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to a base-64 string
|
||||
*/
|
||||
function rstr2b64(input)
|
||||
{
|
||||
try { b64pad } catch(e) { b64pad=''; }
|
||||
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var output = "";
|
||||
var len = input.length;
|
||||
for(var i = 0; i < len; i += 3)
|
||||
{
|
||||
var triplet = (input.charCodeAt(i) << 16)
|
||||
| (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
|
||||
| (i + 2 < len ? input.charCodeAt(i+2) : 0);
|
||||
for(var j = 0; j < 4; j++)
|
||||
{
|
||||
if(i * 8 + j * 6 > input.length * 8) output += b64pad;
|
||||
else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to an arbitrary string encoding
|
||||
*/
|
||||
function rstr2any(input, encoding)
|
||||
{
|
||||
var divisor = encoding.length;
|
||||
var remainders = Array();
|
||||
var i, q, x, quotient;
|
||||
|
||||
/* Convert to an array of 16-bit big-endian values, forming the dividend */
|
||||
var dividend = Array(Math.ceil(input.length / 2));
|
||||
for(i = 0; i < dividend.length; i++)
|
||||
{
|
||||
dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Repeatedly perform a long division. The binary array forms the dividend,
|
||||
* the length of the encoding is the divisor. Once computed, the quotient
|
||||
* forms the dividend for the next step. We stop when the dividend is zero.
|
||||
* All remainders are stored for later use.
|
||||
*/
|
||||
while(dividend.length > 0)
|
||||
{
|
||||
quotient = Array();
|
||||
x = 0;
|
||||
for(i = 0; i < dividend.length; i++)
|
||||
{
|
||||
x = (x << 16) + dividend[i];
|
||||
q = Math.floor(x / divisor);
|
||||
x -= q * divisor;
|
||||
if(quotient.length > 0 || q > 0)
|
||||
quotient[quotient.length] = q;
|
||||
}
|
||||
remainders[remainders.length] = x;
|
||||
dividend = quotient;
|
||||
}
|
||||
|
||||
/* Convert the remainders to the output string */
|
||||
var output = "";
|
||||
for(i = remainders.length - 1; i >= 0; i--)
|
||||
output += encoding.charAt(remainders[i]);
|
||||
|
||||
/* Append leading zero equivalents */
|
||||
var full_length = Math.ceil(input.length * 8 /
|
||||
(Math.log(encoding.length) / Math.log(2)))
|
||||
for(i = output.length; i < full_length; i++)
|
||||
output = encoding[0] + output;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode a string as utf-8.
|
||||
* For efficiency, this assumes the input is valid utf-16.
|
||||
*/
|
||||
function str2rstr_utf8(input)
|
||||
{
|
||||
var output = "";
|
||||
var i = -1;
|
||||
var x, y;
|
||||
|
||||
while(++i < input.length)
|
||||
{
|
||||
/* Decode utf-16 surrogate pairs */
|
||||
x = input.charCodeAt(i);
|
||||
y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
|
||||
if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF)
|
||||
{
|
||||
x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Encode output as utf-8 */
|
||||
if(x <= 0x7F)
|
||||
output += String.fromCharCode(x);
|
||||
else if(x <= 0x7FF)
|
||||
output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
|
||||
0x80 | ( x & 0x3F));
|
||||
else if(x <= 0xFFFF)
|
||||
output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
|
||||
0x80 | ((x >>> 6 ) & 0x3F),
|
||||
0x80 | ( x & 0x3F));
|
||||
else if(x <= 0x1FFFFF)
|
||||
output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
|
||||
0x80 | ((x >>> 12) & 0x3F),
|
||||
0x80 | ((x >>> 6 ) & 0x3F),
|
||||
0x80 | ( x & 0x3F));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode a string as utf-16
|
||||
*/
|
||||
function str2rstr_utf16le(input)
|
||||
{
|
||||
var output = "";
|
||||
for(var i = 0; i < input.length; i++)
|
||||
output += String.fromCharCode( input.charCodeAt(i) & 0xFF,
|
||||
(input.charCodeAt(i) >>> 8) & 0xFF);
|
||||
return output;
|
||||
}
|
||||
|
||||
function str2rstr_utf16be(input)
|
||||
{
|
||||
var output = "";
|
||||
for(var i = 0; i < input.length; i++)
|
||||
output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
|
||||
input.charCodeAt(i) & 0xFF);
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to an array of big-endian words
|
||||
* Characters >255 have their high-byte silently ignored.
|
||||
*/
|
||||
function rstr2binb(input)
|
||||
{
|
||||
var output = Array(input.length >> 2);
|
||||
for(var i = 0; i < output.length; i++)
|
||||
output[i] = 0;
|
||||
for(var i = 0; i < input.length * 8; i += 8)
|
||||
output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (24 - i % 32);
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of big-endian words to a string
|
||||
*/
|
||||
function binb2rstr(input)
|
||||
{
|
||||
var output = "";
|
||||
for(var i = 0; i < input.length * 32; i += 8)
|
||||
output += String.fromCharCode((input[i>>5] >>> (24 - i % 32)) & 0xFF);
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the SHA-1 of an array of big-endian words, and a bit length
|
||||
*/
|
||||
function binb_sha1(x, len)
|
||||
{
|
||||
/* append padding */
|
||||
x[len >> 5] |= 0x80 << (24 - len % 32);
|
||||
x[((len + 64 >> 9) << 4) + 15] = len;
|
||||
|
||||
var w = Array(80);
|
||||
var a = 1732584193;
|
||||
var b = -271733879;
|
||||
var c = -1732584194;
|
||||
var d = 271733878;
|
||||
var e = -1009589776;
|
||||
|
||||
for(var i = 0; i < x.length; i += 16)
|
||||
{
|
||||
var olda = a;
|
||||
var oldb = b;
|
||||
var oldc = c;
|
||||
var oldd = d;
|
||||
var olde = e;
|
||||
|
||||
for(var j = 0; j < 80; j++)
|
||||
{
|
||||
if(j < 16) w[j] = x[i + j];
|
||||
else w[j] = bit_rol(w[j-3] ^ w[j-8] ^ w[j-14] ^ w[j-16], 1);
|
||||
var t = safe_add(safe_add(bit_rol(a, 5), sha1_ft(j, b, c, d)),
|
||||
safe_add(safe_add(e, w[j]), sha1_kt(j)));
|
||||
e = d;
|
||||
d = c;
|
||||
c = bit_rol(b, 30);
|
||||
b = a;
|
||||
a = t;
|
||||
}
|
||||
|
||||
a = safe_add(a, olda);
|
||||
b = safe_add(b, oldb);
|
||||
c = safe_add(c, oldc);
|
||||
d = safe_add(d, oldd);
|
||||
e = safe_add(e, olde);
|
||||
}
|
||||
return Array(a, b, c, d, e);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Perform the appropriate triplet combination function for the current
|
||||
* iteration
|
||||
*/
|
||||
function sha1_ft(t, b, c, d)
|
||||
{
|
||||
if(t < 20) return (b & c) | ((~b) & d);
|
||||
if(t < 40) return b ^ c ^ d;
|
||||
if(t < 60) return (b & c) | (b & d) | (c & d);
|
||||
return b ^ c ^ d;
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the appropriate additive constant for the current iteration
|
||||
*/
|
||||
function sha1_kt(t)
|
||||
{
|
||||
return (t < 20) ? 1518500249 : (t < 40) ? 1859775393 :
|
||||
(t < 60) ? -1894007588 : -899497514;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
||||
* to work around bugs in some JS interpreters.
|
||||
*/
|
||||
function safe_add(x, y)
|
||||
{
|
||||
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
|
||||
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xFFFF);
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitwise rotate a 32-bit number to the left.
|
||||
*/
|
||||
function bit_rol(num, cnt)
|
||||
{
|
||||
return (num << cnt) | (num >>> (32 - cnt));
|
||||
}
|
||||
|
||||
exports.HMACSHA1= function(key, data) {
|
||||
return b64_hmac_sha1(key, data);
|
||||
}
|
||||
15
srcs/requirements/nestjs/api_back/node_modules/oauth/package.json
generated
vendored
Normal file
15
srcs/requirements/nestjs/api_back/node_modules/oauth/package.json
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{ "name" : "oauth"
|
||||
, "description" : "Library for interacting with OAuth 1.0, 1.0A, 2 and Echo. Provides simplified client access and allows for construction of more complex apis and OAuth providers."
|
||||
, "version" : "0.9.15"
|
||||
, "directories" : { "lib" : "./lib" }
|
||||
, "main" : "index.js"
|
||||
, "author" : "Ciaran Jessup <ciaranj@gmail.com>"
|
||||
, "repository" : { "type":"git", "url":"http://github.com/ciaranj/node-oauth.git" }
|
||||
, "devDependencies": {
|
||||
"vows": "0.5.x"
|
||||
}
|
||||
, "scripts": {
|
||||
"test": "make test"
|
||||
}
|
||||
, "license": "MIT"
|
||||
}
|
||||
304
srcs/requirements/nestjs/api_back/node_modules/oauth/tests/oauth2tests.js
generated
vendored
Normal file
304
srcs/requirements/nestjs/api_back/node_modules/oauth/tests/oauth2tests.js
generated
vendored
Normal file
@@ -0,0 +1,304 @@
|
||||
var vows = require('vows'),
|
||||
assert = require('assert'),
|
||||
DummyResponse= require('./shared').DummyResponse,
|
||||
DummyRequest= require('./shared').DummyRequest,
|
||||
https = require('https'),
|
||||
OAuth2= require('../lib/oauth2').OAuth2,
|
||||
url = require('url');
|
||||
|
||||
vows.describe('OAuth2').addBatch({
|
||||
'Given an OAuth2 instance with clientId and clientSecret, ': {
|
||||
topic: new OAuth2("clientId", "clientSecret"),
|
||||
'When dealing with the response from the OP': {
|
||||
'we should treat a 201 response as a success': function(oa) {
|
||||
var callbackCalled= false;
|
||||
var http_library= {
|
||||
request: function() {
|
||||
return new DummyRequest(new DummyResponse(201));
|
||||
}
|
||||
};
|
||||
oa._executeRequest( http_library, {}, null, function(err, result, response) {
|
||||
callbackCalled= true;
|
||||
assert.equal(err, null);
|
||||
});
|
||||
assert.ok(callbackCalled);
|
||||
},
|
||||
'we should treat a 200 response as a success': function(oa) {
|
||||
var callbackCalled= false;
|
||||
var http_library= {
|
||||
request: function() {
|
||||
return new DummyRequest(new DummyResponse(200));
|
||||
}
|
||||
};
|
||||
oa._executeRequest( http_library, {}, null, function(err, result, response) {
|
||||
callbackCalled= true;
|
||||
assert.equal(err, null);
|
||||
});
|
||||
assert.ok(callbackCalled);
|
||||
}
|
||||
},
|
||||
'When handling the access token response': {
|
||||
'we should correctly extract the token if received as form-data': function (oa) {
|
||||
oa._request= function( method, url, fo, bar, bleh, callback) {
|
||||
callback(null, "access_token=access&refresh_token=refresh");
|
||||
};
|
||||
oa.getOAuthAccessToken("", {}, function(error, access_token, refresh_token) {
|
||||
assert.equal( access_token, "access");
|
||||
assert.equal( refresh_token, "refresh");
|
||||
});
|
||||
},
|
||||
'we should not include access token in both querystring and headers (favours headers if specified)': function (oa) {
|
||||
oa._request = new OAuth2("clientId", "clientSecret")._request.bind(oa);
|
||||
oa._executeRequest= function( http_library, options, post_body, callback) {
|
||||
callback(null, url.parse(options.path, true).query, options.headers);
|
||||
};
|
||||
|
||||
oa._request("GET", "http://foo/", {"Authorization":"Bearer BadNews"}, null, "accessx", function(error, query, headers) {
|
||||
assert.ok( !('access_token' in query), "access_token also in query");
|
||||
assert.ok( 'Authorization' in headers, "Authorization not in headers");
|
||||
});
|
||||
},
|
||||
'we should include access token in the querystring if no Authorization header present to override it': function (oa) {
|
||||
oa._request = new OAuth2("clientId", "clientSecret")._request.bind(oa);
|
||||
oa._executeRequest= function( http_library, options, post_body, callback) {
|
||||
callback(null, url.parse(options.path, true).query, options.headers);
|
||||
};
|
||||
oa._request("GET", "http://foo/", {}, null, "access", function(error, query, headers) {
|
||||
assert.ok( 'access_token' in query, "access_token not present in query");
|
||||
assert.ok( !('Authorization' in headers), "Authorization in headers");
|
||||
});
|
||||
},
|
||||
'we should correctly extract the token if received as a JSON literal': function (oa) {
|
||||
oa._request= function(method, url, headers, post_body, access_token, callback) {
|
||||
callback(null, '{"access_token":"access","refresh_token":"refresh"}');
|
||||
};
|
||||
oa.getOAuthAccessToken("", {}, function(error, access_token, refresh_token) {
|
||||
assert.equal( access_token, "access");
|
||||
assert.equal( refresh_token, "refresh");
|
||||
});
|
||||
},
|
||||
'we should return the received data to the calling method': function (oa) {
|
||||
oa._request= function(method, url, headers, post_body, access_token, callback) {
|
||||
callback(null, '{"access_token":"access","refresh_token":"refresh","extra_1":1, "extra_2":"foo"}');
|
||||
};
|
||||
oa.getOAuthAccessToken("", {}, function(error, access_token, refresh_token, results) {
|
||||
assert.equal( access_token, "access");
|
||||
assert.equal( refresh_token, "refresh");
|
||||
assert.isNotNull( results );
|
||||
assert.equal( results.extra_1, 1);
|
||||
assert.equal( results.extra_2, "foo");
|
||||
});
|
||||
}
|
||||
},
|
||||
'When no grant_type parameter is specified': {
|
||||
'we should pass the value of the code argument as the code parameter': function(oa) {
|
||||
oa._request= function(method, url, headers, post_body, access_token, callback) {
|
||||
assert.isTrue( post_body.indexOf("code=xsds23") != -1 );
|
||||
};
|
||||
oa.getOAuthAccessToken("xsds23", {} );
|
||||
}
|
||||
},
|
||||
'When an invalid grant_type parameter is specified': {
|
||||
'we should pass the value of the code argument as the code parameter': function(oa) {
|
||||
oa._request= function(method, url, headers, post_body, access_token, callback) {
|
||||
assert.isTrue( post_body.indexOf("code=xsds23") != -1 );
|
||||
};
|
||||
oa.getOAuthAccessToken("xsds23", {grant_type:"refresh_toucan"} );
|
||||
}
|
||||
},
|
||||
'When a grant_type parameter of value "refresh_token" is specified': {
|
||||
'we should pass the value of the code argument as the refresh_token parameter, should pass a grant_type parameter, but shouldn\'t pass a code parameter' : function(oa) {
|
||||
oa._request= function(method, url, headers, post_body, access_token, callback) {
|
||||
assert.isTrue( post_body.indexOf("refresh_token=sdsds2") != -1 );
|
||||
assert.isTrue( post_body.indexOf("grant_type=refresh_token") != -1 );
|
||||
assert.isTrue( post_body.indexOf("code=") == -1 );
|
||||
};
|
||||
oa.getOAuthAccessToken("sdsds2", {grant_type:"refresh_token"} );
|
||||
}
|
||||
},
|
||||
'When we use the authorization header': {
|
||||
'and call get with the default authorization method': {
|
||||
'we should pass the authorization header with Bearer method and value of the access_token, _request should be passed a null access_token' : function(oa) {
|
||||
oa._request= function(method, url, headers, post_body, access_token, callback) {
|
||||
assert.equal(headers["Authorization"], "Bearer abcd5");
|
||||
assert.isNull( access_token );
|
||||
};
|
||||
oa.useAuthorizationHeaderforGET(true);
|
||||
oa.get("", "abcd5");
|
||||
}
|
||||
},
|
||||
'and call get with the authorization method set to Basic': {
|
||||
'we should pass the authorization header with Basic method and value of the access_token, _request should be passed a null access_token' : function(oa) {
|
||||
oa._request= function(method, url, headers, post_body, access_token, callback) {
|
||||
assert.equal(headers["Authorization"], "Basic cdg2");
|
||||
assert.isNull( access_token );
|
||||
};
|
||||
oa.useAuthorizationHeaderforGET(true);
|
||||
oa.setAuthMethod("Basic");
|
||||
oa.get("", "cdg2");
|
||||
}
|
||||
}
|
||||
},
|
||||
'When we do not use the authorization header': {
|
||||
'and call get': {
|
||||
'we should pass NOT provide an authorization header and the access_token should be being passed to _request' : function(oa) {
|
||||
oa._request= function(method, url, headers, post_body, access_token, callback) {
|
||||
assert.isUndefined(headers["Authorization"]);
|
||||
assert.equal( access_token, "abcd5" );
|
||||
};
|
||||
oa.useAuthorizationHeaderforGET(false);
|
||||
oa.get("", "abcd5");
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'Given an OAuth2 instance with clientId, clientSecret and customHeaders': {
|
||||
topic: new OAuth2("clientId", "clientSecret", undefined, undefined, undefined,
|
||||
{ 'SomeHeader': '123' }),
|
||||
'When GETing': {
|
||||
'we should see the custom headers mixed into headers property in options passed to http-library' : function(oa) {
|
||||
oa._executeRequest= function( http_library, options, callback ) {
|
||||
assert.equal(options.headers["SomeHeader"], "123");
|
||||
};
|
||||
oa.get("", {});
|
||||
},
|
||||
}
|
||||
},
|
||||
'Given an OAuth2 instance with a clientId and clientSecret': {
|
||||
topic: new OAuth2("clientId", "clientSecret"),
|
||||
'When POSTing': {
|
||||
'we should see a given string being sent to the request' : function(oa) {
|
||||
var bodyWritten= false;
|
||||
oa._chooseHttpLibrary= function() {
|
||||
return {
|
||||
request: function(options) {
|
||||
assert.equal(options.headers["Content-Type"], "text/plain");
|
||||
assert.equal(options.headers["Content-Length"], 26);
|
||||
assert.equal(options.method, "POST");
|
||||
return {
|
||||
end: function() {},
|
||||
on: function() {},
|
||||
write: function(body) {
|
||||
bodyWritten= true;
|
||||
assert.isNotNull(body);
|
||||
assert.equal(body, "THIS_IS_A_POST_BODY_STRING")
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
oa._request("POST", "", {"Content-Type":"text/plain"}, "THIS_IS_A_POST_BODY_STRING");
|
||||
assert.ok( bodyWritten );
|
||||
},
|
||||
'we should see a given buffer being sent to the request' : function(oa) {
|
||||
var bodyWritten= false;
|
||||
oa._chooseHttpLibrary= function() {
|
||||
return {
|
||||
request: function(options) {
|
||||
assert.equal(options.headers["Content-Type"], "application/octet-stream");
|
||||
assert.equal(options.headers["Content-Length"], 4);
|
||||
assert.equal(options.method, "POST");
|
||||
return {
|
||||
end: function() {},
|
||||
on: function() {},
|
||||
write: function(body) {
|
||||
bodyWritten= true;
|
||||
assert.isNotNull(body);
|
||||
assert.equal(4, body.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
oa._request("POST", "", {"Content-Type":"application/octet-stream"}, new Buffer([1,2,3,4]));
|
||||
assert.ok( bodyWritten );
|
||||
}
|
||||
},
|
||||
'When PUTing': {
|
||||
'we should see a given string being sent to the request' : function(oa) {
|
||||
var bodyWritten= false;
|
||||
oa._chooseHttpLibrary= function() {
|
||||
return {
|
||||
request: function(options) {
|
||||
assert.equal(options.headers["Content-Type"], "text/plain");
|
||||
assert.equal(options.headers["Content-Length"], 25);
|
||||
assert.equal(options.method, "PUT");
|
||||
return {
|
||||
end: function() {},
|
||||
on: function() {},
|
||||
write: function(body) {
|
||||
bodyWritten= true;
|
||||
assert.isNotNull(body);
|
||||
assert.equal(body, "THIS_IS_A_PUT_BODY_STRING")
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
oa._request("PUT", "", {"Content-Type":"text/plain"}, "THIS_IS_A_PUT_BODY_STRING");
|
||||
assert.ok( bodyWritten );
|
||||
},
|
||||
'we should see a given buffer being sent to the request' : function(oa) {
|
||||
var bodyWritten= false;
|
||||
oa._chooseHttpLibrary= function() {
|
||||
return {
|
||||
request: function(options) {
|
||||
assert.equal(options.headers["Content-Type"], "application/octet-stream");
|
||||
assert.equal(options.headers["Content-Length"], 4);
|
||||
assert.equal(options.method, "PUT");
|
||||
return {
|
||||
end: function() {},
|
||||
on: function() {},
|
||||
write: function(body) {
|
||||
bodyWritten= true;
|
||||
assert.isNotNull(body);
|
||||
assert.equal(4, body.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
oa._request("PUT", "", {"Content-Type":"application/octet-stream"}, new Buffer([1,2,3,4]));
|
||||
assert.ok( bodyWritten );
|
||||
}
|
||||
}
|
||||
},
|
||||
'When the user passes in the User-Agent in customHeaders': {
|
||||
topic: new OAuth2("clientId", "clientSecret", undefined, undefined, undefined,
|
||||
{ 'User-Agent': '123Agent' }),
|
||||
'When calling get': {
|
||||
'we should see the User-Agent mixed into headers property in options passed to http-library' : function(oa) {
|
||||
oa._executeRequest= function( http_library, options, callback ) {
|
||||
assert.equal(options.headers["User-Agent"], "123Agent");
|
||||
};
|
||||
oa.get("", {});
|
||||
}
|
||||
}
|
||||
},
|
||||
'When the user does not pass in a User-Agent in customHeaders': {
|
||||
topic: new OAuth2("clientId", "clientSecret", undefined, undefined, undefined,
|
||||
undefined),
|
||||
'When calling get': {
|
||||
'we should see the default User-Agent mixed into headers property in options passed to http-library' : function(oa) {
|
||||
oa._executeRequest= function( http_library, options, callback ) {
|
||||
assert.equal(options.headers["User-Agent"], "Node-oauth");
|
||||
};
|
||||
oa.get("", {});
|
||||
}
|
||||
}
|
||||
},
|
||||
'When specifying an agent, that agent is passed to the HTTP request method' : {
|
||||
topic : new OAuth2('clientId', 'clientSecret', undefined, undefined, undefined, undefined),
|
||||
'When calling _executeRequest': {
|
||||
'we whould see the agent being put into the options' : function(oa) {
|
||||
oa.setAgent('awesome agent');
|
||||
oa._executeRequest({
|
||||
request : function(options, cb) {
|
||||
assert.equal(options.agent, 'awesome agent');
|
||||
return new DummyRequest(new DummyResponse(200));
|
||||
}
|
||||
}, {}, null, function() {});
|
||||
}
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
1064
srcs/requirements/nestjs/api_back/node_modules/oauth/tests/oauthtests.js
generated
vendored
Normal file
1064
srcs/requirements/nestjs/api_back/node_modules/oauth/tests/oauthtests.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
13
srcs/requirements/nestjs/api_back/node_modules/oauth/tests/sha1tests.js
generated
vendored
Normal file
13
srcs/requirements/nestjs/api_back/node_modules/oauth/tests/sha1tests.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
var vows = require('vows'),
|
||||
assert = require('assert');
|
||||
|
||||
vows.describe('SHA1 Hashing').addBatch({
|
||||
'When using the SHA1 Hashing function': {
|
||||
topic: require('../lib/sha1'),
|
||||
'we get the specified digest as described in http://oauth.net/core/1.0/#sig_base_example (A.5.2)': function (sha1) {
|
||||
assert.equal (sha1.HMACSHA1( "kd94hf93k423kf44&pfkkdhi9sl3r4s00",
|
||||
"GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal"),
|
||||
"tR3+Ty81lMeYAr/Fid0kMTYa/WM=");
|
||||
}
|
||||
}
|
||||
}).export(module);
|
||||
26
srcs/requirements/nestjs/api_back/node_modules/oauth/tests/shared.js
generated
vendored
Normal file
26
srcs/requirements/nestjs/api_back/node_modules/oauth/tests/shared.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
var events = require('events');
|
||||
|
||||
exports.DummyResponse = function( statusCode ) {
|
||||
this.statusCode= statusCode;
|
||||
this.headers= {};
|
||||
}
|
||||
exports.DummyResponse.prototype= events.EventEmitter.prototype;
|
||||
exports.DummyResponse.prototype.setEncoding= function() {}
|
||||
|
||||
exports.DummyRequest =function( response ) {
|
||||
this.response= response;
|
||||
this.responseSent= false;
|
||||
}
|
||||
exports.DummyRequest.prototype= events.EventEmitter.prototype;
|
||||
exports.DummyRequest.prototype.write= function(post_body){}
|
||||
exports.DummyRequest.prototype.write= function(post_body){
|
||||
this.responseSent= true;
|
||||
this.emit('response',this.response);
|
||||
}
|
||||
exports.DummyRequest.prototype.end= function(){
|
||||
if(!this.responseSent) {
|
||||
this.responseSent= true;
|
||||
this.emit('response',this.response);
|
||||
}
|
||||
this.response.emit('end');
|
||||
}
|
||||
70
srcs/requirements/nestjs/api_back/node_modules/passport-42/.eslintrc
generated
vendored
Normal file
70
srcs/requirements/nestjs/api_back/node_modules/passport-42/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"env": {
|
||||
"mocha": true,
|
||||
"node": true
|
||||
},
|
||||
"globals": {},
|
||||
"rules": {
|
||||
"no-bitwise": 2,
|
||||
"camelcase": 2,
|
||||
"curly": 2,
|
||||
"eqeqeq": 2,
|
||||
"guard-for-in": 2,
|
||||
"no-extend-native": 2,
|
||||
"wrap-iife": [
|
||||
2,
|
||||
"any"
|
||||
],
|
||||
"indent": [
|
||||
2,
|
||||
2,
|
||||
{
|
||||
"SwitchCase": 1
|
||||
}
|
||||
],
|
||||
"no-use-before-define": 2,
|
||||
"new-cap": 2,
|
||||
"no-caller": 2,
|
||||
"no-empty": 2,
|
||||
"no-irregular-whitespace": 2,
|
||||
"no-new": 2,
|
||||
"no-plusplus": 0,
|
||||
"quotes": [
|
||||
2,
|
||||
"single"
|
||||
],
|
||||
"no-undef": 2,
|
||||
"no-unused-vars": 2,
|
||||
"strict": 0,
|
||||
"max-params": 0,
|
||||
"max-depth": 0,
|
||||
"max-statements": 0,
|
||||
"complexity": 0,
|
||||
"max-len": 2,
|
||||
"no-var": 0,
|
||||
"semi": 0,
|
||||
"no-cond-assign": 0,
|
||||
"no-debugger": 0,
|
||||
"no-eq-null": 0,
|
||||
"no-eval": 0,
|
||||
"no-unused-expressions": 0,
|
||||
"block-scoped-var": 0,
|
||||
"no-iterator": 0,
|
||||
"linebreak-style": 0,
|
||||
"comma-style": [
|
||||
2,
|
||||
"last"
|
||||
],
|
||||
"no-loop-func": 0,
|
||||
"no-multi-str": 0,
|
||||
"require-yield": 0,
|
||||
"valid-typeof": 0,
|
||||
"no-proto": 0,
|
||||
"no-script-url": 0,
|
||||
"no-shadow": 2,
|
||||
"dot-notation": 2,
|
||||
"no-new-func": 0,
|
||||
"no-new-wrappers": 0,
|
||||
"no-invalid-this": 0
|
||||
}
|
||||
}
|
||||
20
srcs/requirements/nestjs/api_back/node_modules/passport-42/LICENSE
generated
vendored
Normal file
20
srcs/requirements/nestjs/api_back/node_modules/passport-42/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2016 Adrien "Pandark" Pachkoff
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
148
srcs/requirements/nestjs/api_back/node_modules/passport-42/README.md
generated
vendored
Normal file
148
srcs/requirements/nestjs/api_back/node_modules/passport-42/README.md
generated
vendored
Normal file
@@ -0,0 +1,148 @@
|
||||
# passport-42
|
||||
|
||||
[](https://travis-ci.org/pandark/passport-42)
|
||||
[](https://coveralls.io/r/pandark/passport-42)
|
||||
[](https://codeclimate.com/github/pandark/passport-42)
|
||||
[](https://greenkeeper.io/)
|
||||
[](https://david-dm.org/pandark/passport-42)
|
||||
|
||||
[Passport](http://passportjs.org/) strategy for authenticating with
|
||||
[42](https://api.intra.42.fr/apidoc) using the OAuth 2.0 API.
|
||||
|
||||
This module lets you authenticate using 42 in your Node.js applications.
|
||||
By plugging into Passport, 42 authentication can be easily and unobtrusively
|
||||
integrated into any application or framework that supports
|
||||
[Connect](http://www.senchalabs.org/connect/)-style middleware, including
|
||||
[Express](http://expressjs.com/).
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
$ npm install passport-42
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Create an Application
|
||||
|
||||
Before using `passport-42`, you must register an application with
|
||||
42. If you have not already done so, a new application can be created at
|
||||
[42 Applications](https://profile.intra.42.fr/oauth/applications). Your
|
||||
application will be issued an app UID and app SECRET, which need to be provided
|
||||
to the strategy. You will also need to configure a redirect URI which matches
|
||||
the route in your application.
|
||||
|
||||
### Configure Strategy
|
||||
|
||||
The 42 authentication strategy authenticates users using a 42 account and OAuth
|
||||
2.0 tokens. The app UID and SECRET obtained when creating an application are
|
||||
supplied as options when creating the strategy. The strategy also requires a
|
||||
`verify` callback, which receives the access token and optional refresh token,
|
||||
as well as `profile` which contains the authenticated user's 42 profile. The
|
||||
`verify` callback must call `cb` providing a user to complete authentication.
|
||||
|
||||
```js
|
||||
var FortyTwoStrategy = require('passport-42').Strategy;
|
||||
|
||||
passport.use(new FortyTwoStrategy({
|
||||
clientID: FORTYTWO_APP_ID,
|
||||
clientSecret: FORTYTWO_APP_SECRET,
|
||||
callbackURL: "http://127.0.0.1:3000/auth/42/callback"
|
||||
},
|
||||
function(accessToken, refreshToken, profile, cb) {
|
||||
User.findOrCreate({ fortytwoId: profile.id }, function (err, user) {
|
||||
return cb(err, user);
|
||||
});
|
||||
}
|
||||
));
|
||||
```
|
||||
|
||||
### Authenticate Requests
|
||||
|
||||
Use `passport.authenticate()`, specifying the `'42'` strategy, to
|
||||
authenticate requests.
|
||||
|
||||
For example, as route middleware in an [Express](http://expressjs.com/)
|
||||
application:
|
||||
|
||||
```js
|
||||
app.get('/auth/42',
|
||||
passport.authenticate('42'));
|
||||
|
||||
app.get('/auth/42/callback',
|
||||
passport.authenticate('42', { failureRedirect: '/login' }),
|
||||
function(req, res) {
|
||||
// Successful authentication, redirect home.
|
||||
res.redirect('/');
|
||||
});
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
Developers using the popular [Express](http://expressjs.com/) web framework can
|
||||
refer to an [example](https://github.com/pandark/passport-42-example)
|
||||
as a starting point for their own web applications.
|
||||
|
||||
## Options
|
||||
|
||||
### Specify profile fields
|
||||
|
||||
The 42 profile contains a lot of information about a user. The fields needed
|
||||
by an application can be indicated by setting the `profileFields` option.
|
||||
|
||||
```js
|
||||
new FortyTwoStrategy({
|
||||
clientID: FORTYTWO_APP_ID,
|
||||
clientSecret: FORTYTWO_APP_SECRET,
|
||||
callbackURL: "http://127.0.0.1:3000/auth/42/callback",
|
||||
profileFields: {
|
||||
'id': function (obj) { return String(obj.id); },
|
||||
'username': 'login',
|
||||
'displayName': 'displayname',
|
||||
'name.familyName': 'last_name',
|
||||
'name.givenName': 'first_name',
|
||||
'profileUrl': 'url',
|
||||
'emails.0.value': 'email',
|
||||
'phoneNumbers.0.value': 'phone',
|
||||
'photos.0.value': 'image_url'
|
||||
}
|
||||
}), ...)
|
||||
```
|
||||
|
||||
Refer to the [User](https://api.intra.42.fr/apidoc/2.0/users/show.html) 42 API
|
||||
Reference for the complete set of available fields.
|
||||
|
||||
### User agent
|
||||
|
||||
Although 42 API doesn't require a user agent in the requests header,
|
||||
passport-42 sets one, by default "passport-42". You can set a different one
|
||||
using the `userAgent` option.
|
||||
|
||||
## Contributing
|
||||
|
||||
### Tests
|
||||
|
||||
The test suite is located in the `test/` directory. All new features are
|
||||
expected to have corresponding test cases. Ensure that the complete test suite
|
||||
passes by executing:
|
||||
|
||||
```bash
|
||||
$ make test
|
||||
```
|
||||
|
||||
### Coverage
|
||||
|
||||
The test suite covers 100% of the code base. All new feature development is
|
||||
expected to maintain that level. Coverage reports can be viewed by executing:
|
||||
|
||||
```bash
|
||||
$ make test-cov
|
||||
$ make view-cov
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[The MIT License](http://opensource.org/licenses/MIT)
|
||||
|
||||
Copyright (c) 2016 Adrien "Pandark" Pachkoff
|
||||
<[https://lifeleaks.com/](https://lifeleaks.com/)>
|
||||
8
srcs/requirements/nestjs/api_back/node_modules/passport-42/lib/index.js
generated
vendored
Normal file
8
srcs/requirements/nestjs/api_back/node_modules/passport-42/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
// Load modules.
|
||||
var Strategy = require('./strategy');
|
||||
|
||||
// Expose Strategy.
|
||||
exports = module.exports = Strategy;
|
||||
|
||||
// Exports.
|
||||
exports.Strategy = Strategy;
|
||||
65
srcs/requirements/nestjs/api_back/node_modules/passport-42/lib/profile.js
generated
vendored
Normal file
65
srcs/requirements/nestjs/api_back/node_modules/passport-42/lib/profile.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Parse profile.
|
||||
*
|
||||
* @param {object|string} json
|
||||
* @param {object} profileFields
|
||||
* @return {object}
|
||||
* @access public
|
||||
*/
|
||||
exports.parse = function(json, profileFields) {
|
||||
if ('string' === typeof json) {
|
||||
json = JSON.parse(json);
|
||||
}
|
||||
|
||||
profileFields = profileFields || {
|
||||
'id': function (obj) { return String(obj.id); },
|
||||
'username': 'login',
|
||||
'displayName': 'displayname',
|
||||
'name.familyName': 'last_name',
|
||||
'name.givenName': 'first_name',
|
||||
'profileUrl': 'url',
|
||||
'emails.0.value': 'email',
|
||||
'phoneNumbers.0.value': 'phone',
|
||||
'photos.0.value': 'image_url'
|
||||
};
|
||||
|
||||
var profile = {};
|
||||
Object.getOwnPropertyNames(profileFields).forEach(function(flatProps) {
|
||||
var profileCur = profile;
|
||||
var props = flatProps.split('.').map(function(p) {
|
||||
return (/^\d+$/.test(p)) ? parseInt(p, 10) : p;
|
||||
});
|
||||
var propsLen = props.length;
|
||||
props.forEach(function(prop, i) {
|
||||
if (i !== propsLen - 1) {
|
||||
if (profileCur[prop] === undefined) {
|
||||
if (Number.isInteger(props[i + 1])) {
|
||||
profileCur[prop] = [];
|
||||
} else {
|
||||
profileCur[prop] = {};
|
||||
}
|
||||
}
|
||||
profileCur = profileCur[prop];
|
||||
} else {
|
||||
if (typeof profileFields[flatProps] === 'function') {
|
||||
profileCur[prop] = (profileFields[flatProps])(json);
|
||||
} else {
|
||||
var jsonCur = json;
|
||||
var valFields = profileFields[flatProps].split('.').map(function(v) {
|
||||
return (/^\d+$/.test(v)) ? parseInt(v, 10) : v;
|
||||
});
|
||||
var valLen = valFields.length;
|
||||
valFields.forEach(function(val, j) {
|
||||
if (j !== valLen - 1) {
|
||||
jsonCur = jsonCur[val];
|
||||
} else {
|
||||
profileCur[prop] = jsonCur[val];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return profile;
|
||||
};
|
||||
125
srcs/requirements/nestjs/api_back/node_modules/passport-42/lib/strategy.js
generated
vendored
Normal file
125
srcs/requirements/nestjs/api_back/node_modules/passport-42/lib/strategy.js
generated
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
// Load modules.
|
||||
var OAuth2Strategy = require('passport-oauth2');
|
||||
var util = require('util');
|
||||
var Profile = require('./profile');
|
||||
var InternalOAuthError = require('passport-oauth2').InternalOAuthError;
|
||||
|
||||
|
||||
/**
|
||||
* `Strategy` constructor.
|
||||
*
|
||||
* The 42 authentication strategy authenticates requests by delegating to 42
|
||||
* using the OAuth 2.0 protocol.
|
||||
*
|
||||
* Applications must supply a `verify` callback which accepts an `accessToken`,
|
||||
* `refreshToken` and service-specific `profile`, and then calls the `cb`
|
||||
* callback supplying a `user`, which should be set to `false` if the
|
||||
* credentials are not valid. If an exception occured, `err` should be set.
|
||||
*
|
||||
* Options:
|
||||
* - `clientID` your 42 application's UID
|
||||
* - `clientSecret` your 42 application's SECRET
|
||||
* - `callbackURL` URL to which 42 will redirect the user after granting
|
||||
* authorization
|
||||
* — `userAgent` User Agent string used in all API requests. e.g: domain
|
||||
* name of your application.
|
||||
* — `profileFields` Object specifying fields to include in the user profile.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* passport.use(new FortyTwoStrategy({
|
||||
* clientID: '123-456-789',
|
||||
* clientSecret: 'shhh-its-a-secret'
|
||||
* callbackURL: 'https://www.example.net/auth/42/callback'
|
||||
* },
|
||||
* function(accessToken, refreshToken, profile, cb) {
|
||||
* User.findOrCreate(..., function (err, user) {
|
||||
* cb(err, user);
|
||||
* });
|
||||
* }
|
||||
* ));
|
||||
*
|
||||
* @constructor
|
||||
* @param {object} options
|
||||
* @param {function} verify
|
||||
* @access public
|
||||
*/
|
||||
function Strategy(options, verify) {
|
||||
options = options || {};
|
||||
options.authorizationURL = options.authorizationURL ||
|
||||
'https://api.intra.42.fr/oauth/authorize';
|
||||
options.tokenURL = options.tokenURL || 'https://api.intra.42.fr/oauth/token';
|
||||
options.customHeaders = options.customHeaders || {};
|
||||
|
||||
if (!options.customHeaders['User-Agent']) {
|
||||
options.customHeaders['User-Agent'] = options.userAgent || 'passport-42';
|
||||
}
|
||||
|
||||
OAuth2Strategy.call(this, options, verify);
|
||||
this.name = '42';
|
||||
this._profileURL = options.profileURL || 'https://api.intra.42.fr/v2/me';
|
||||
this._profileFields = options.profileFields || null;
|
||||
this._oauth2.useAuthorizationHeaderforGET(true);
|
||||
}
|
||||
|
||||
// Inherit from `OAuth2Strategy`.
|
||||
util.inherits(Strategy, OAuth2Strategy);
|
||||
|
||||
/**
|
||||
* Retrieve user profile from 42.
|
||||
*
|
||||
* This function constructs a normalized profile, with the following properties
|
||||
* (or the ones specified in `options.profileFields`):
|
||||
*
|
||||
* - `provider` always set to `42`
|
||||
* - `id` the user's 42 ID
|
||||
* - `username` the user's 42 xlogin
|
||||
* - `displayName` the user's full name
|
||||
* - `name.familyName` the user's last name
|
||||
* - `name.givenName` the user's first name
|
||||
* - `profileUrl` the URL of the profile for the user on 42 intra
|
||||
* - `emails` the user's email address
|
||||
* - `photos ` the user's photo
|
||||
* - `phoneNumbers` the user's phone number
|
||||
*
|
||||
* @param {string} accessToken
|
||||
* @param {function} done
|
||||
* @access protected
|
||||
*/
|
||||
Strategy.prototype.userProfile = function(accessToken, done) {
|
||||
var fields = this._profileFields;
|
||||
this._oauth2.get(this._profileURL, accessToken, function (err, body) {
|
||||
var json;
|
||||
|
||||
if (err) {
|
||||
if (err.data) {
|
||||
try {
|
||||
json = JSON.parse(err.data);
|
||||
} catch (_) {
|
||||
// nothing
|
||||
}
|
||||
}
|
||||
if (json && json.message) {
|
||||
return done(new InternalOAuthError(json.message, err));
|
||||
}
|
||||
return done(new InternalOAuthError('Failed to fetch user profile', err));
|
||||
}
|
||||
|
||||
try {
|
||||
json = JSON.parse(body);
|
||||
} catch (ex) {
|
||||
return done(new Error('Failed to parse user profile'));
|
||||
}
|
||||
|
||||
var profile = Profile.parse(json, fields);
|
||||
profile.provider = '42';
|
||||
profile._raw = body;
|
||||
profile._json = json;
|
||||
|
||||
done(null, profile);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// Expose constructor.
|
||||
module.exports = Strategy;
|
||||
53
srcs/requirements/nestjs/api_back/node_modules/passport-42/package.json
generated
vendored
Normal file
53
srcs/requirements/nestjs/api_back/node_modules/passport-42/package.json
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
{
|
||||
"name": "passport-42",
|
||||
"version": "1.2.6",
|
||||
"description": "42 authentication strategy for Passport.",
|
||||
"keywords": [
|
||||
"passport",
|
||||
"42",
|
||||
"auth",
|
||||
"authn",
|
||||
"authentication",
|
||||
"identity",
|
||||
"42born2code",
|
||||
"born2code",
|
||||
"borntocode",
|
||||
"forty-two"
|
||||
],
|
||||
"author": {
|
||||
"name": "Adrien \"Pandark\" Pachkoff",
|
||||
"email": "adrien-dev@pachkoff.com",
|
||||
"url": "https://lifeleaks.com/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pandark/passport-42.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/pandark/passport-42/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://opensource.org/licenses/MIT"
|
||||
}
|
||||
],
|
||||
"main": "./lib",
|
||||
"dependencies": {
|
||||
"passport-oauth2": "^1.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"chai-passport-strategy": "^1.0.1",
|
||||
"make-node": "~0.3.5",
|
||||
"mocha": "^6.2.0",
|
||||
"proxyquire": "^2.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node_modules/.bin/mocha --require test/bootstrap/node test/*.test.js"
|
||||
}
|
||||
}
|
||||
3
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/.github/FUNDING.yml
generated
vendored
Normal file
3
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/.github/FUNDING.yml
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
github: jaredhanson
|
||||
patreon: jaredhanson
|
||||
ko_fi: jaredhanson
|
||||
19
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/CHANGELOG.md
generated
vendored
Normal file
19
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.6.1] - 2021-09-24
|
||||
### Fixed
|
||||
- Error in cases where the authorization server returns a successful access
|
||||
token response which is missing an `access_token` parameter.
|
||||
|
||||
## [1.6.0] - 2021-07-01
|
||||
### Added
|
||||
|
||||
- Support for `store: true` option to `Strategy` constructor, which initializes
|
||||
a state store capable of storing application-level state.
|
||||
- Support for `state` object passed as option to `authenticate`, which will be
|
||||
persisted in the session by state store.
|
||||
- `callbackURL` property added to metadata passed to state store.
|
||||
20
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/LICENSE
generated
vendored
Normal file
20
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2011-2016 Jared Hanson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
122
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/README.md
generated
vendored
Normal file
122
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/README.md
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
# passport-oauth2
|
||||
|
||||
General-purpose OAuth 2.0 authentication strategy for [Passport](http://passportjs.org/).
|
||||
|
||||
This module lets you authenticate using OAuth 2.0 in your Node.js applications.
|
||||
By plugging into Passport, OAuth 2.0 authentication can be easily and
|
||||
unobtrusively integrated into any application or framework that supports
|
||||
[Connect](http://www.senchalabs.org/connect/)-style middleware, including
|
||||
[Express](http://expressjs.com/).
|
||||
|
||||
Note that this strategy provides generic OAuth 2.0 support. In many cases, a
|
||||
provider-specific strategy can be used instead, which cuts down on unnecessary
|
||||
configuration, and accommodates any provider-specific quirks. See the
|
||||
[list](https://github.com/jaredhanson/passport/wiki/Strategies) for supported
|
||||
providers.
|
||||
|
||||
Developers who need to implement authentication against an OAuth 2.0 provider
|
||||
that is not already supported are encouraged to sub-class this strategy. If you
|
||||
choose to open source the new provider-specific strategy, please add it to the
|
||||
list so other people can find it.
|
||||
|
||||
---
|
||||
|
||||
<p align="center">
|
||||
<sup>Advertisement</sup>
|
||||
<br>
|
||||
<a href="https://click.linksynergy.com/link?id=D*o7yui4/NM&offerid=507388.380582&type=2&murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Flearn-oauth-2%2F&u1=5I2riUEiNIRjPjdjxj6X4exzu3lhRkWY0et6Y8eyT3">Learn OAuth 2.0 - Get started as an API Security Expert</a><br>Just imagine what could happen to YOUR professional career if you had skills in OAuth > 8500 satisfied students
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
[](https://www.npmjs.com/package/passport-oauth2)
|
||||
[](https://travis-ci.org/jaredhanson/passport-oauth2)
|
||||
[](https://coveralls.io/github/jaredhanson/passport-oauth2)
|
||||
[...](https://github.com/jaredhanson/passport-oauth2/wiki/Status)
|
||||
|
||||
## Install
|
||||
|
||||
$ npm install passport-oauth2
|
||||
|
||||
## Usage
|
||||
|
||||
#### Configure Strategy
|
||||
|
||||
The OAuth 2.0 authentication strategy authenticates users using a third-party
|
||||
account and OAuth 2.0 tokens. The provider's OAuth 2.0 endpoints, as well as
|
||||
the client identifer and secret, are specified as options. The strategy
|
||||
requires a `verify` callback, which receives an access token and profile,
|
||||
and calls `cb` providing a user.
|
||||
|
||||
```js
|
||||
passport.use(new OAuth2Strategy({
|
||||
authorizationURL: 'https://www.example.com/oauth2/authorize',
|
||||
tokenURL: 'https://www.example.com/oauth2/token',
|
||||
clientID: EXAMPLE_CLIENT_ID,
|
||||
clientSecret: EXAMPLE_CLIENT_SECRET,
|
||||
callbackURL: "http://localhost:3000/auth/example/callback"
|
||||
},
|
||||
function(accessToken, refreshToken, profile, cb) {
|
||||
User.findOrCreate({ exampleId: profile.id }, function (err, user) {
|
||||
return cb(err, user);
|
||||
});
|
||||
}
|
||||
));
|
||||
```
|
||||
|
||||
#### Authenticate Requests
|
||||
|
||||
Use `passport.authenticate()`, specifying the `'oauth2'` strategy, to
|
||||
authenticate requests.
|
||||
|
||||
For example, as route middleware in an [Express](http://expressjs.com/)
|
||||
application:
|
||||
|
||||
```js
|
||||
app.get('/auth/example',
|
||||
passport.authenticate('oauth2'));
|
||||
|
||||
app.get('/auth/example/callback',
|
||||
passport.authenticate('oauth2', { failureRedirect: '/login' }),
|
||||
function(req, res) {
|
||||
// Successful authentication, redirect home.
|
||||
res.redirect('/');
|
||||
});
|
||||
```
|
||||
|
||||
## Related Modules
|
||||
|
||||
- [passport-oauth1](https://github.com/jaredhanson/passport-oauth1) — OAuth 1.0 authentication strategy
|
||||
- [passport-http-bearer](https://github.com/jaredhanson/passport-http-bearer) — Bearer token authentication strategy for APIs
|
||||
- [OAuth2orize](https://github.com/jaredhanson/oauth2orize) — OAuth 2.0 authorization server toolkit
|
||||
|
||||
## Contributing
|
||||
|
||||
#### Tests
|
||||
|
||||
The test suite is located in the `test/` directory. All new features are
|
||||
expected to have corresponding test cases. Ensure that the complete test suite
|
||||
passes by executing:
|
||||
|
||||
```bash
|
||||
$ make test
|
||||
```
|
||||
|
||||
#### Coverage
|
||||
|
||||
All new feature development is expected to have test coverage. Patches that
|
||||
increse test coverage are happily accepted. Coverage reports can be viewed by
|
||||
executing:
|
||||
|
||||
```bash
|
||||
$ make test-cov
|
||||
$ make view-cov
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[The MIT License](http://opensource.org/licenses/MIT)
|
||||
|
||||
Copyright (c) 2011-2016 Jared Hanson <[http://jaredhanson.net/](http://jaredhanson.net/)>
|
||||
|
||||
|
||||
44
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/errors/authorizationerror.js
generated
vendored
Normal file
44
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/errors/authorizationerror.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* `AuthorizationError` error.
|
||||
*
|
||||
* AuthorizationError represents an error in response to an authorization
|
||||
* request. For details, refer to RFC 6749, section 4.1.2.1.
|
||||
*
|
||||
* References:
|
||||
* - [The OAuth 2.0 Authorization Framework](http://tools.ietf.org/html/rfc6749)
|
||||
*
|
||||
* @constructor
|
||||
* @param {String} [message]
|
||||
* @param {String} [code]
|
||||
* @param {String} [uri]
|
||||
* @param {Number} [status]
|
||||
* @api public
|
||||
*/
|
||||
function AuthorizationError(message, code, uri, status) {
|
||||
if (!status) {
|
||||
switch (code) {
|
||||
case 'access_denied': status = 403; break;
|
||||
case 'server_error': status = 502; break;
|
||||
case 'temporarily_unavailable': status = 503; break;
|
||||
}
|
||||
}
|
||||
|
||||
Error.call(this);
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
this.name = this.constructor.name;
|
||||
this.message = message;
|
||||
this.code = code || 'server_error';
|
||||
this.uri = uri;
|
||||
this.status = status || 500;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit from `Error`.
|
||||
*/
|
||||
AuthorizationError.prototype.__proto__ = Error.prototype;
|
||||
|
||||
|
||||
/**
|
||||
* Expose `AuthorizationError`.
|
||||
*/
|
||||
module.exports = AuthorizationError;
|
||||
49
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/errors/internaloautherror.js
generated
vendored
Normal file
49
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/errors/internaloautherror.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* `InternalOAuthError` error.
|
||||
*
|
||||
* InternalOAuthError wraps errors generated by node-oauth. By wrapping these
|
||||
* objects, error messages can be formatted in a manner that aids in debugging
|
||||
* OAuth issues.
|
||||
*
|
||||
* @constructor
|
||||
* @param {String} [message]
|
||||
* @param {Object|Error} [err]
|
||||
* @api public
|
||||
*/
|
||||
function InternalOAuthError(message, err) {
|
||||
Error.call(this);
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
this.name = this.constructor.name;
|
||||
this.message = message;
|
||||
this.oauthError = err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit from `Error`.
|
||||
*/
|
||||
InternalOAuthError.prototype.__proto__ = Error.prototype;
|
||||
|
||||
/**
|
||||
* Returns a string representing the error.
|
||||
*
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
InternalOAuthError.prototype.toString = function() {
|
||||
var m = this.name;
|
||||
if (this.message) { m += ': ' + this.message; }
|
||||
if (this.oauthError) {
|
||||
if (this.oauthError instanceof Error) {
|
||||
m = this.oauthError.toString();
|
||||
} else if (this.oauthError.statusCode && this.oauthError.data) {
|
||||
m += ' (status: ' + this.oauthError.statusCode + ' data: ' + this.oauthError.data + ')';
|
||||
}
|
||||
}
|
||||
return m;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Expose `InternalOAuthError`.
|
||||
*/
|
||||
module.exports = InternalOAuthError;
|
||||
36
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/errors/tokenerror.js
generated
vendored
Normal file
36
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/errors/tokenerror.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* `TokenError` error.
|
||||
*
|
||||
* TokenError represents an error received from a token endpoint. For details,
|
||||
* refer to RFC 6749, section 5.2.
|
||||
*
|
||||
* References:
|
||||
* - [The OAuth 2.0 Authorization Framework](http://tools.ietf.org/html/rfc6749)
|
||||
*
|
||||
* @constructor
|
||||
* @param {String} [message]
|
||||
* @param {String} [code]
|
||||
* @param {String} [uri]
|
||||
* @param {Number} [status]
|
||||
* @api public
|
||||
*/
|
||||
function TokenError(message, code, uri, status) {
|
||||
Error.call(this);
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
this.name = this.constructor.name;
|
||||
this.message = message;
|
||||
this.code = code || 'invalid_request';
|
||||
this.uri = uri;
|
||||
this.status = status || 500;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inherit from `Error`.
|
||||
*/
|
||||
TokenError.prototype.__proto__ = Error.prototype;
|
||||
|
||||
|
||||
/**
|
||||
* Expose `TokenError`.
|
||||
*/
|
||||
module.exports = TokenError;
|
||||
16
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/index.js
generated
vendored
Normal file
16
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// Load modules.
|
||||
var Strategy = require('./strategy')
|
||||
, AuthorizationError = require('./errors/authorizationerror')
|
||||
, TokenError = require('./errors/tokenerror')
|
||||
, InternalOAuthError = require('./errors/internaloautherror');
|
||||
|
||||
|
||||
// Expose Strategy.
|
||||
exports = module.exports = Strategy;
|
||||
|
||||
// Exports.
|
||||
exports.Strategy = Strategy;
|
||||
|
||||
exports.AuthorizationError = AuthorizationError;
|
||||
exports.TokenError = TokenError;
|
||||
exports.InternalOAuthError = InternalOAuthError;
|
||||
13
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/state/null.js
generated
vendored
Normal file
13
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/state/null.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
function NullStore(options) {
|
||||
}
|
||||
|
||||
NullStore.prototype.store = function(req, cb) {
|
||||
cb();
|
||||
}
|
||||
|
||||
NullStore.prototype.verify = function(req, providedState, cb) {
|
||||
cb(null, true);
|
||||
}
|
||||
|
||||
|
||||
module.exports = NullStore;
|
||||
89
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/state/pkcesession.js
generated
vendored
Normal file
89
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/state/pkcesession.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
var uid = require('uid2');
|
||||
|
||||
/**
|
||||
* Creates an instance of `SessionStore`.
|
||||
*
|
||||
* This is the state store implementation for the OAuth2Strategy used when
|
||||
* the `state` option is enabled. It generates a random state and stores it in
|
||||
* `req.session` and verifies it when the service provider redirects the user
|
||||
* back to the application.
|
||||
*
|
||||
* This state store requires session support. If no session exists, an error
|
||||
* will be thrown.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `key` The key in the session under which to store the state
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} options
|
||||
* @api public
|
||||
*/
|
||||
function PKCESessionStore(options) {
|
||||
if (!options.key) { throw new TypeError('Session-based state store requires a session key'); }
|
||||
this._key = options.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store request state.
|
||||
*
|
||||
* This implementation simply generates a random string and stores the value in
|
||||
* the session, where it will be used for verification when the user is
|
||||
* redirected back to the application.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {Function} callback
|
||||
* @api protected
|
||||
*/
|
||||
PKCESessionStore.prototype.store = function(req, verifier, state, meta, callback) {
|
||||
if (!req.session) { return callback(new Error('OAuth 2.0 authentication requires session support when using state. Did you forget to use express-session middleware?')); }
|
||||
|
||||
var key = this._key;
|
||||
var sstate = {
|
||||
handle: uid(24),
|
||||
code_verifier: verifier
|
||||
};
|
||||
if (state) { sstate.state = state; }
|
||||
if (!req.session[key]) { req.session[key] = {}; }
|
||||
req.session[key].state = sstate;
|
||||
callback(null, sstate.handle);
|
||||
};
|
||||
|
||||
/**
|
||||
* Verify request state.
|
||||
*
|
||||
* This implementation simply compares the state parameter in the request to the
|
||||
* value generated earlier and stored in the session.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {String} providedState
|
||||
* @param {Function} callback
|
||||
* @api protected
|
||||
*/
|
||||
PKCESessionStore.prototype.verify = function(req, providedState, callback) {
|
||||
if (!req.session) { return callback(new Error('OAuth 2.0 authentication requires session support when using state. Did you forget to use express-session middleware?')); }
|
||||
|
||||
var key = this._key;
|
||||
if (!req.session[key]) {
|
||||
return callback(null, false, { message: 'Unable to verify authorization request state.' });
|
||||
}
|
||||
|
||||
var state = req.session[key].state;
|
||||
if (!state) {
|
||||
return callback(null, false, { message: 'Unable to verify authorization request state.' });
|
||||
}
|
||||
|
||||
delete req.session[key].state;
|
||||
if (Object.keys(req.session[key]).length === 0) {
|
||||
delete req.session[key];
|
||||
}
|
||||
|
||||
if (state.handle !== providedState) {
|
||||
return callback(null, false, { message: 'Invalid authorization request state.' });
|
||||
}
|
||||
|
||||
return callback(null, state.code_verifier, state.state);
|
||||
};
|
||||
|
||||
// Expose constructor.
|
||||
module.exports = PKCESessionStore;
|
||||
85
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/state/session.js
generated
vendored
Normal file
85
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/state/session.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
var uid = require('uid2');
|
||||
|
||||
/**
|
||||
* Creates an instance of `SessionStore`.
|
||||
*
|
||||
* This is the state store implementation for the OAuth2Strategy used when
|
||||
* the `state` option is enabled. It generates a random state and stores it in
|
||||
* `req.session` and verifies it when the service provider redirects the user
|
||||
* back to the application.
|
||||
*
|
||||
* This state store requires session support. If no session exists, an error
|
||||
* will be thrown.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `key` The key in the session under which to store the state
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} options
|
||||
* @api public
|
||||
*/
|
||||
function SessionStore(options) {
|
||||
if (!options.key) { throw new TypeError('Session-based state store requires a session key'); }
|
||||
this._key = options.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store request state.
|
||||
*
|
||||
* This implementation simply generates a random string and stores the value in
|
||||
* the session, where it will be used for verification when the user is
|
||||
* redirected back to the application.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {Function} callback
|
||||
* @api protected
|
||||
*/
|
||||
SessionStore.prototype.store = function(req, callback) {
|
||||
if (!req.session) { return callback(new Error('OAuth 2.0 authentication requires session support when using state. Did you forget to use express-session middleware?')); }
|
||||
|
||||
var key = this._key;
|
||||
var state = uid(24);
|
||||
if (!req.session[key]) { req.session[key] = {}; }
|
||||
req.session[key].state = state;
|
||||
callback(null, state);
|
||||
};
|
||||
|
||||
/**
|
||||
* Verify request state.
|
||||
*
|
||||
* This implementation simply compares the state parameter in the request to the
|
||||
* value generated earlier and stored in the session.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {String} providedState
|
||||
* @param {Function} callback
|
||||
* @api protected
|
||||
*/
|
||||
SessionStore.prototype.verify = function(req, providedState, callback) {
|
||||
if (!req.session) { return callback(new Error('OAuth 2.0 authentication requires session support when using state. Did you forget to use express-session middleware?')); }
|
||||
|
||||
var key = this._key;
|
||||
if (!req.session[key]) {
|
||||
return callback(null, false, { message: 'Unable to verify authorization request state.' });
|
||||
}
|
||||
|
||||
var state = req.session[key].state;
|
||||
if (!state) {
|
||||
return callback(null, false, { message: 'Unable to verify authorization request state.' });
|
||||
}
|
||||
|
||||
delete req.session[key].state;
|
||||
if (Object.keys(req.session[key]).length === 0) {
|
||||
delete req.session[key];
|
||||
}
|
||||
|
||||
if (state !== providedState) {
|
||||
return callback(null, false, { message: 'Invalid authorization request state.' });
|
||||
}
|
||||
|
||||
return callback(null, true);
|
||||
};
|
||||
|
||||
// Expose constructor.
|
||||
module.exports = SessionStore;
|
||||
88
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/state/store.js
generated
vendored
Normal file
88
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/state/store.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
var uid = require('uid2');
|
||||
|
||||
/**
|
||||
* Creates an instance of `SessionStore`.
|
||||
*
|
||||
* This is the state store implementation for the OAuth2Strategy used when
|
||||
* the `state` option is enabled. It generates a random state and stores it in
|
||||
* `req.session` and verifies it when the service provider redirects the user
|
||||
* back to the application.
|
||||
*
|
||||
* This state store requires session support. If no session exists, an error
|
||||
* will be thrown.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `key` The key in the session under which to store the state
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} options
|
||||
* @api public
|
||||
*/
|
||||
function SessionStore(options) {
|
||||
if (!options.key) { throw new TypeError('Session-based state store requires a session key'); }
|
||||
this._key = options.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store request state.
|
||||
*
|
||||
* This implementation simply generates a random string and stores the value in
|
||||
* the session, where it will be used for verification when the user is
|
||||
* redirected back to the application.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {Function} callback
|
||||
* @api protected
|
||||
*/
|
||||
SessionStore.prototype.store = function(req, state, meta, callback) {
|
||||
if (!req.session) { return callback(new Error('OAuth 2.0 authentication requires session support when using state. Did you forget to use express-session middleware?')); }
|
||||
|
||||
var key = this._key;
|
||||
var sstate = {
|
||||
handle: uid(24)
|
||||
};
|
||||
if (state) { sstate.state = state; }
|
||||
if (!req.session[key]) { req.session[key] = {}; }
|
||||
req.session[key].state = sstate;
|
||||
callback(null, sstate.handle);
|
||||
};
|
||||
|
||||
/**
|
||||
* Verify request state.
|
||||
*
|
||||
* This implementation simply compares the state parameter in the request to the
|
||||
* value generated earlier and stored in the session.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {String} providedState
|
||||
* @param {Function} callback
|
||||
* @api protected
|
||||
*/
|
||||
SessionStore.prototype.verify = function(req, providedState, callback) {
|
||||
if (!req.session) { return callback(new Error('OAuth 2.0 authentication requires session support when using state. Did you forget to use express-session middleware?')); }
|
||||
|
||||
var key = this._key;
|
||||
if (!req.session[key]) {
|
||||
return callback(null, false, { message: 'Unable to verify authorization request state.' });
|
||||
}
|
||||
|
||||
var state = req.session[key].state;
|
||||
if (!state) {
|
||||
return callback(null, false, { message: 'Unable to verify authorization request state.' });
|
||||
}
|
||||
|
||||
delete req.session[key].state;
|
||||
if (Object.keys(req.session[key]).length === 0) {
|
||||
delete req.session[key];
|
||||
}
|
||||
|
||||
if (state.handle !== providedState) {
|
||||
return callback(null, false, { message: 'Invalid authorization request state.' });
|
||||
}
|
||||
|
||||
return callback(null, true, state.state);
|
||||
};
|
||||
|
||||
// Expose constructor.
|
||||
module.exports = SessionStore;
|
||||
429
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/strategy.js
generated
vendored
Normal file
429
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/strategy.js
generated
vendored
Normal file
@@ -0,0 +1,429 @@
|
||||
// Load modules.
|
||||
var passport = require('passport-strategy')
|
||||
, url = require('url')
|
||||
, uid = require('uid2')
|
||||
, crypto = require('crypto')
|
||||
, base64url = require('base64url')
|
||||
, util = require('util')
|
||||
, utils = require('./utils')
|
||||
, OAuth2 = require('oauth').OAuth2
|
||||
, NullStore = require('./state/null')
|
||||
, NonceStore = require('./state/session')
|
||||
, StateStore = require('./state/store')
|
||||
, PKCEStateStore = require('./state/pkcesession')
|
||||
, AuthorizationError = require('./errors/authorizationerror')
|
||||
, TokenError = require('./errors/tokenerror')
|
||||
, InternalOAuthError = require('./errors/internaloautherror');
|
||||
|
||||
|
||||
/**
|
||||
* Creates an instance of `OAuth2Strategy`.
|
||||
*
|
||||
* The OAuth 2.0 authentication strategy authenticates requests using the OAuth
|
||||
* 2.0 framework.
|
||||
*
|
||||
* OAuth 2.0 provides a facility for delegated authentication, whereby users can
|
||||
* authenticate using a third-party service such as Facebook. Delegating in
|
||||
* this manner involves a sequence of events, including redirecting the user to
|
||||
* the third-party service for authorization. Once authorization has been
|
||||
* granted, the user is redirected back to the application and an authorization
|
||||
* code can be used to obtain credentials.
|
||||
*
|
||||
* Applications must supply a `verify` callback, for which the function
|
||||
* signature is:
|
||||
*
|
||||
* function(accessToken, refreshToken, profile, done) { ... }
|
||||
*
|
||||
* The verify callback is responsible for finding or creating the user, and
|
||||
* invoking `done` with the following arguments:
|
||||
*
|
||||
* done(err, user, info);
|
||||
*
|
||||
* `user` should be set to `false` to indicate an authentication failure.
|
||||
* Additional `info` can optionally be passed as a third argument, typically
|
||||
* used to display informational messages. If an exception occured, `err`
|
||||
* should be set.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `authorizationURL` URL used to obtain an authorization grant
|
||||
* - `tokenURL` URL used to obtain an access token
|
||||
* - `clientID` identifies client to service provider
|
||||
* - `clientSecret` secret used to establish ownership of the client identifer
|
||||
* - `callbackURL` URL to which the service provider will redirect the user after obtaining authorization
|
||||
* - `passReqToCallback` when `true`, `req` is the first argument to the verify callback (default: `false`)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* passport.use(new OAuth2Strategy({
|
||||
* authorizationURL: 'https://www.example.com/oauth2/authorize',
|
||||
* tokenURL: 'https://www.example.com/oauth2/token',
|
||||
* clientID: '123-456-789',
|
||||
* clientSecret: 'shhh-its-a-secret'
|
||||
* callbackURL: 'https://www.example.net/auth/example/callback'
|
||||
* },
|
||||
* function(accessToken, refreshToken, profile, done) {
|
||||
* User.findOrCreate(..., function (err, user) {
|
||||
* done(err, user);
|
||||
* });
|
||||
* }
|
||||
* ));
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} options
|
||||
* @param {Function} verify
|
||||
* @api public
|
||||
*/
|
||||
function OAuth2Strategy(options, verify) {
|
||||
if (typeof options == 'function') {
|
||||
verify = options;
|
||||
options = undefined;
|
||||
}
|
||||
options = options || {};
|
||||
|
||||
if (!verify) { throw new TypeError('OAuth2Strategy requires a verify callback'); }
|
||||
if (!options.authorizationURL) { throw new TypeError('OAuth2Strategy requires a authorizationURL option'); }
|
||||
if (!options.tokenURL) { throw new TypeError('OAuth2Strategy requires a tokenURL option'); }
|
||||
if (!options.clientID) { throw new TypeError('OAuth2Strategy requires a clientID option'); }
|
||||
|
||||
passport.Strategy.call(this);
|
||||
this.name = 'oauth2';
|
||||
this._verify = verify;
|
||||
|
||||
// NOTE: The _oauth2 property is considered "protected". Subclasses are
|
||||
// allowed to use it when making protected resource requests to retrieve
|
||||
// the user profile.
|
||||
this._oauth2 = new OAuth2(options.clientID, options.clientSecret,
|
||||
'', options.authorizationURL, options.tokenURL, options.customHeaders);
|
||||
|
||||
this._callbackURL = options.callbackURL;
|
||||
this._scope = options.scope;
|
||||
this._scopeSeparator = options.scopeSeparator || ' ';
|
||||
this._pkceMethod = (options.pkce === true) ? 'S256' : options.pkce;
|
||||
this._key = options.sessionKey || ('oauth2:' + url.parse(options.authorizationURL).hostname);
|
||||
|
||||
if (options.store && typeof options.store == 'object') {
|
||||
this._stateStore = options.store;
|
||||
} else if (options.store) {
|
||||
this._stateStore = options.pkce ? new PKCEStateStore({ key: this._key }) : new StateStore({ key: this._key });
|
||||
} else if (options.state) {
|
||||
this._stateStore = options.pkce ? new PKCEStateStore({ key: this._key }) : new NonceStore({ key: this._key });
|
||||
} else {
|
||||
if (options.pkce) { throw new TypeError('OAuth2Strategy requires `state: true` option when PKCE is enabled'); }
|
||||
this._stateStore = new NullStore();
|
||||
}
|
||||
this._trustProxy = options.proxy;
|
||||
this._passReqToCallback = options.passReqToCallback;
|
||||
this._skipUserProfile = (options.skipUserProfile === undefined) ? false : options.skipUserProfile;
|
||||
}
|
||||
|
||||
// Inherit from `passport.Strategy`.
|
||||
util.inherits(OAuth2Strategy, passport.Strategy);
|
||||
|
||||
|
||||
/**
|
||||
* Authenticate request by delegating to a service provider using OAuth 2.0.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @api protected
|
||||
*/
|
||||
OAuth2Strategy.prototype.authenticate = function(req, options) {
|
||||
options = options || {};
|
||||
var self = this;
|
||||
|
||||
if (req.query && req.query.error) {
|
||||
if (req.query.error == 'access_denied') {
|
||||
return this.fail({ message: req.query.error_description });
|
||||
} else {
|
||||
return this.error(new AuthorizationError(req.query.error_description, req.query.error, req.query.error_uri));
|
||||
}
|
||||
}
|
||||
|
||||
var callbackURL = options.callbackURL || this._callbackURL;
|
||||
if (callbackURL) {
|
||||
var parsed = url.parse(callbackURL);
|
||||
if (!parsed.protocol) {
|
||||
// The callback URL is relative, resolve a fully qualified URL from the
|
||||
// URL of the originating request.
|
||||
callbackURL = url.resolve(utils.originalURL(req, { proxy: this._trustProxy }), callbackURL);
|
||||
}
|
||||
}
|
||||
|
||||
var meta = {
|
||||
authorizationURL: this._oauth2._authorizeUrl,
|
||||
tokenURL: this._oauth2._accessTokenUrl,
|
||||
clientID: this._oauth2._clientId,
|
||||
callbackURL: callbackURL
|
||||
}
|
||||
|
||||
if (req.query && req.query.code) {
|
||||
function loaded(err, ok, state) {
|
||||
if (err) { return self.error(err); }
|
||||
if (!ok) {
|
||||
return self.fail(state, 403);
|
||||
}
|
||||
|
||||
var code = req.query.code;
|
||||
|
||||
var params = self.tokenParams(options);
|
||||
params.grant_type = 'authorization_code';
|
||||
if (callbackURL) { params.redirect_uri = callbackURL; }
|
||||
if (typeof ok == 'string') { // PKCE
|
||||
params.code_verifier = ok;
|
||||
}
|
||||
|
||||
self._oauth2.getOAuthAccessToken(code, params,
|
||||
function(err, accessToken, refreshToken, params) {
|
||||
if (err) { return self.error(self._createOAuthError('Failed to obtain access token', err)); }
|
||||
if (!accessToken) { return self.error(new Error('Failed to obtain access token')); }
|
||||
|
||||
self._loadUserProfile(accessToken, function(err, profile) {
|
||||
if (err) { return self.error(err); }
|
||||
|
||||
function verified(err, user, info) {
|
||||
if (err) { return self.error(err); }
|
||||
if (!user) { return self.fail(info); }
|
||||
|
||||
info = info || {};
|
||||
if (state) { info.state = state; }
|
||||
self.success(user, info);
|
||||
}
|
||||
|
||||
try {
|
||||
if (self._passReqToCallback) {
|
||||
var arity = self._verify.length;
|
||||
if (arity == 6) {
|
||||
self._verify(req, accessToken, refreshToken, params, profile, verified);
|
||||
} else { // arity == 5
|
||||
self._verify(req, accessToken, refreshToken, profile, verified);
|
||||
}
|
||||
} else {
|
||||
var arity = self._verify.length;
|
||||
if (arity == 5) {
|
||||
self._verify(accessToken, refreshToken, params, profile, verified);
|
||||
} else { // arity == 4
|
||||
self._verify(accessToken, refreshToken, profile, verified);
|
||||
}
|
||||
}
|
||||
} catch (ex) {
|
||||
return self.error(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
var state = req.query.state;
|
||||
try {
|
||||
var arity = this._stateStore.verify.length;
|
||||
if (arity == 4) {
|
||||
this._stateStore.verify(req, state, meta, loaded);
|
||||
} else { // arity == 3
|
||||
this._stateStore.verify(req, state, loaded);
|
||||
}
|
||||
} catch (ex) {
|
||||
return this.error(ex);
|
||||
}
|
||||
} else {
|
||||
var params = this.authorizationParams(options);
|
||||
params.response_type = 'code';
|
||||
if (callbackURL) { params.redirect_uri = callbackURL; }
|
||||
var scope = options.scope || this._scope;
|
||||
if (scope) {
|
||||
if (Array.isArray(scope)) { scope = scope.join(this._scopeSeparator); }
|
||||
params.scope = scope;
|
||||
}
|
||||
var verifier, challenge;
|
||||
|
||||
if (this._pkceMethod) {
|
||||
verifier = base64url(crypto.pseudoRandomBytes(32))
|
||||
switch (this._pkceMethod) {
|
||||
case 'plain':
|
||||
challenge = verifier;
|
||||
break;
|
||||
case 'S256':
|
||||
challenge = base64url(crypto.createHash('sha256').update(verifier).digest());
|
||||
break;
|
||||
default:
|
||||
return this.error(new Error('Unsupported code verifier transformation method: ' + this._pkceMethod));
|
||||
}
|
||||
|
||||
params.code_challenge = challenge;
|
||||
params.code_challenge_method = this._pkceMethod;
|
||||
}
|
||||
|
||||
var state = options.state;
|
||||
if (state && typeof state == 'string') {
|
||||
// NOTE: In passport-oauth2@1.5.0 and earlier, `state` could be passed as
|
||||
// an object. However, it would result in an empty string being
|
||||
// serialized as the value of the query parameter by `url.format()`,
|
||||
// effectively ignoring the option. This implies that `state` was
|
||||
// only functional when passed as a string value.
|
||||
//
|
||||
// This fact is taken advantage of here to fall into the `else`
|
||||
// branch below when `state` is passed as an object. In that case
|
||||
// the state will be automatically managed and persisted by the
|
||||
// state store.
|
||||
params.state = state;
|
||||
|
||||
var parsed = url.parse(this._oauth2._authorizeUrl, true);
|
||||
utils.merge(parsed.query, params);
|
||||
parsed.query['client_id'] = this._oauth2._clientId;
|
||||
delete parsed.search;
|
||||
var location = url.format(parsed);
|
||||
this.redirect(location);
|
||||
} else {
|
||||
function stored(err, state) {
|
||||
if (err) { return self.error(err); }
|
||||
|
||||
if (state) { params.state = state; }
|
||||
var parsed = url.parse(self._oauth2._authorizeUrl, true);
|
||||
utils.merge(parsed.query, params);
|
||||
parsed.query['client_id'] = self._oauth2._clientId;
|
||||
delete parsed.search;
|
||||
var location = url.format(parsed);
|
||||
self.redirect(location);
|
||||
}
|
||||
|
||||
try {
|
||||
var arity = this._stateStore.store.length;
|
||||
if (arity == 5) {
|
||||
this._stateStore.store(req, verifier, state, meta, stored);
|
||||
} else if (arity == 4) {
|
||||
this._stateStore.store(req, state, meta, stored);
|
||||
} else if (arity == 3) {
|
||||
this._stateStore.store(req, meta, stored);
|
||||
} else { // arity == 2
|
||||
this._stateStore.store(req, stored);
|
||||
}
|
||||
} catch (ex) {
|
||||
return this.error(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve user profile from service provider.
|
||||
*
|
||||
* OAuth 2.0-based authentication strategies can overrride this function in
|
||||
* order to load the user's profile from the service provider. This assists
|
||||
* applications (and users of those applications) in the initial registration
|
||||
* process by automatically submitting required information.
|
||||
*
|
||||
* @param {String} accessToken
|
||||
* @param {Function} done
|
||||
* @api protected
|
||||
*/
|
||||
OAuth2Strategy.prototype.userProfile = function(accessToken, done) {
|
||||
return done(null, {});
|
||||
};
|
||||
|
||||
/**
|
||||
* Return extra parameters to be included in the authorization request.
|
||||
*
|
||||
* Some OAuth 2.0 providers allow additional, non-standard parameters to be
|
||||
* included when requesting authorization. Since these parameters are not
|
||||
* standardized by the OAuth 2.0 specification, OAuth 2.0-based authentication
|
||||
* strategies can overrride this function in order to populate these parameters
|
||||
* as required by the provider.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @return {Object}
|
||||
* @api protected
|
||||
*/
|
||||
OAuth2Strategy.prototype.authorizationParams = function(options) {
|
||||
return {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Return extra parameters to be included in the token request.
|
||||
*
|
||||
* Some OAuth 2.0 providers allow additional, non-standard parameters to be
|
||||
* included when requesting an access token. Since these parameters are not
|
||||
* standardized by the OAuth 2.0 specification, OAuth 2.0-based authentication
|
||||
* strategies can overrride this function in order to populate these parameters
|
||||
* as required by the provider.
|
||||
*
|
||||
* @return {Object}
|
||||
* @api protected
|
||||
*/
|
||||
OAuth2Strategy.prototype.tokenParams = function(options) {
|
||||
return {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse error response from OAuth 2.0 endpoint.
|
||||
*
|
||||
* OAuth 2.0-based authentication strategies can overrride this function in
|
||||
* order to parse error responses received from the token endpoint, allowing the
|
||||
* most informative message to be displayed.
|
||||
*
|
||||
* If this function is not overridden, the body will be parsed in accordance
|
||||
* with RFC 6749, section 5.2.
|
||||
*
|
||||
* @param {String} body
|
||||
* @param {Number} status
|
||||
* @return {Error}
|
||||
* @api protected
|
||||
*/
|
||||
OAuth2Strategy.prototype.parseErrorResponse = function(body, status) {
|
||||
var json = JSON.parse(body);
|
||||
if (json.error) {
|
||||
return new TokenError(json.error_description, json.error, json.error_uri);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Load user profile, contingent upon options.
|
||||
*
|
||||
* @param {String} accessToken
|
||||
* @param {Function} done
|
||||
* @api private
|
||||
*/
|
||||
OAuth2Strategy.prototype._loadUserProfile = function(accessToken, done) {
|
||||
var self = this;
|
||||
|
||||
function loadIt() {
|
||||
return self.userProfile(accessToken, done);
|
||||
}
|
||||
function skipIt() {
|
||||
return done(null);
|
||||
}
|
||||
|
||||
if (typeof this._skipUserProfile == 'function' && this._skipUserProfile.length > 1) {
|
||||
// async
|
||||
this._skipUserProfile(accessToken, function(err, skip) {
|
||||
if (err) { return done(err); }
|
||||
if (!skip) { return loadIt(); }
|
||||
return skipIt();
|
||||
});
|
||||
} else {
|
||||
var skip = (typeof this._skipUserProfile == 'function') ? this._skipUserProfile() : this._skipUserProfile;
|
||||
if (!skip) { return loadIt(); }
|
||||
return skipIt();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create an OAuth error.
|
||||
*
|
||||
* @param {String} message
|
||||
* @param {Object|Error} err
|
||||
* @api private
|
||||
*/
|
||||
OAuth2Strategy.prototype._createOAuthError = function(message, err) {
|
||||
var e;
|
||||
if (err.statusCode && err.data) {
|
||||
try {
|
||||
e = this.parseErrorResponse(err.data, err.statusCode);
|
||||
} catch (_) {}
|
||||
}
|
||||
if (!e) { e = new InternalOAuthError(message, err); }
|
||||
return e;
|
||||
};
|
||||
|
||||
|
||||
// Expose constructor.
|
||||
module.exports = OAuth2Strategy;
|
||||
32
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/utils.js
generated
vendored
Normal file
32
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/lib/utils.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
exports.merge = require('utils-merge');
|
||||
|
||||
/**
|
||||
* Reconstructs the original URL of the request.
|
||||
*
|
||||
* This function builds a URL that corresponds the original URL requested by the
|
||||
* client, including the protocol (http or https) and host.
|
||||
*
|
||||
* If the request passed through any proxies that terminate SSL, the
|
||||
* `X-Forwarded-Proto` header is used to detect if the request was encrypted to
|
||||
* the proxy, assuming that the proxy has been flagged as trusted.
|
||||
*
|
||||
* @param {http.IncomingMessage} req
|
||||
* @param {Object} [options]
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
exports.originalURL = function(req, options) {
|
||||
options = options || {};
|
||||
var app = req.app;
|
||||
if (app && app.get && app.get('trust proxy')) {
|
||||
options.proxy = true;
|
||||
}
|
||||
var trustProxy = options.proxy;
|
||||
|
||||
var proto = (req.headers['x-forwarded-proto'] || '').toLowerCase()
|
||||
, tls = req.connection.encrypted || (trustProxy && 'https' == proto.split(/\s*,\s*/)[0])
|
||||
, host = (trustProxy && req.headers['x-forwarded-host']) || req.headers.host
|
||||
, protocol = tls ? 'https' : 'http'
|
||||
, path = req.url || '';
|
||||
return protocol + '://' + host + path;
|
||||
};
|
||||
59
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/package.json
generated
vendored
Normal file
59
srcs/requirements/nestjs/api_back/node_modules/passport-oauth2/package.json
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "passport-oauth2",
|
||||
"version": "1.6.1",
|
||||
"description": "OAuth 2.0 authentication strategy for Passport.",
|
||||
"keywords": [
|
||||
"passport",
|
||||
"auth",
|
||||
"authn",
|
||||
"authentication",
|
||||
"authz",
|
||||
"authorization",
|
||||
"oauth",
|
||||
"oauth2"
|
||||
],
|
||||
"author": {
|
||||
"name": "Jared Hanson",
|
||||
"email": "jaredhanson@gmail.com",
|
||||
"url": "http://www.jaredhanson.net/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/jaredhanson/passport-oauth2.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/jaredhanson/passport-oauth2/issues"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/jaredhanson"
|
||||
},
|
||||
"license": "MIT",
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://opensource.org/licenses/MIT"
|
||||
}
|
||||
],
|
||||
"main": "./lib",
|
||||
"dependencies": {
|
||||
"base64url": "3.x.x",
|
||||
"oauth": "0.9.x",
|
||||
"passport-strategy": "1.x.x",
|
||||
"uid2": "0.0.x",
|
||||
"utils-merge": "1.x.x"
|
||||
},
|
||||
"devDependencies": {
|
||||
"make-node": "0.4.6",
|
||||
"mocha": "2.x.x",
|
||||
"chai": "2.x.x",
|
||||
"proxyquire": "0.6.x",
|
||||
"chai-passport-strategy": "1.x.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node_modules/.bin/mocha --reporter spec --require test/bootstrap/node test/*.test.js test/**/*.test.js"
|
||||
}
|
||||
}
|
||||
21
srcs/requirements/nestjs/api_back/node_modules/uid2/HISTORY.md
generated
vendored
Normal file
21
srcs/requirements/nestjs/api_back/node_modules/uid2/HISTORY.md
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# 0.0.4 - August 24, 2021
|
||||
|
||||
- Add _README.md_
|
||||
- Add `repository` field to _package.json_
|
||||
- Add `license` field to _package.json_
|
||||
- Removed unused var, added param documentation
|
||||
|
||||
# 0.0.3 - July 6, 2013
|
||||
|
||||
- Add MIT License
|
||||
- Change string generation to not rely internally on base64 byte buffer encoding
|
||||
- Change string generation to only use the 62 latin alphanumeric chars
|
||||
- Switch from `crypto.randomBytes()` to `crypto.pseudoRandomBytes()`
|
||||
|
||||
# 0.0.2 - February 25, 2013
|
||||
|
||||
- Make unique ids safe for use in URLs (Using 62 latin alphanumeric chars, `-` and `_`)
|
||||
|
||||
# 0.0.1 - February 4, 2013
|
||||
|
||||
- Initial Release
|
||||
21
srcs/requirements/nestjs/api_back/node_modules/uid2/LICENSE
generated
vendored
Normal file
21
srcs/requirements/nestjs/api_back/node_modules/uid2/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Marco Aurelio
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
32
srcs/requirements/nestjs/api_back/node_modules/uid2/README.md
generated
vendored
Normal file
32
srcs/requirements/nestjs/api_back/node_modules/uid2/README.md
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
# uid2
|
||||
|
||||
[](http://badge.fury.io/js/uid2)
|
||||
|
||||
Generate unique ids. Pass in a `length` and it returns a `string`.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
npm install uid2
|
||||
|
||||
## Examples
|
||||
|
||||
Without a callback it is synchronous:
|
||||
|
||||
```js
|
||||
uid(10)
|
||||
// => "hbswt489ts"
|
||||
```
|
||||
|
||||
With a callback it is asynchronous:
|
||||
|
||||
```js
|
||||
uid(10, function (err, id) {
|
||||
if (err) throw err;
|
||||
// id => "hbswt489ts"
|
||||
});
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
55
srcs/requirements/nestjs/api_back/node_modules/uid2/index.js
generated
vendored
Normal file
55
srcs/requirements/nestjs/api_back/node_modules/uid2/index.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
|
||||
var crypto = require('crypto');
|
||||
|
||||
/**
|
||||
* 62 characters in the ascii range that can be used in URLs without special
|
||||
* encoding.
|
||||
*/
|
||||
var UIDCHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
|
||||
/**
|
||||
* Make a Buffer into a string ready for use in URLs
|
||||
*
|
||||
* @param {String} bytes a Buffer containing the bytes to convert
|
||||
* @returns {String} UID
|
||||
* @api private
|
||||
*/
|
||||
function tostr(bytes) {
|
||||
var r, i;
|
||||
|
||||
r = [];
|
||||
for (i = 0; i < bytes.length; i++) {
|
||||
r.push(UIDCHARS[bytes[i] % UIDCHARS.length]);
|
||||
}
|
||||
|
||||
return r.join('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an Unique Id
|
||||
*
|
||||
* @param {Number} length The number of chars of the uid
|
||||
* @param {Number} cb (optional) Callback for async uid generation
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function uid(length, cb) {
|
||||
|
||||
if (typeof cb === 'undefined') {
|
||||
return tostr(crypto.pseudoRandomBytes(length));
|
||||
} else {
|
||||
crypto.pseudoRandomBytes(length, function(err, bytes) {
|
||||
if (err) return cb(err);
|
||||
cb(null, tostr(bytes));
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports
|
||||
*/
|
||||
|
||||
module.exports = uid;
|
||||
12
srcs/requirements/nestjs/api_back/node_modules/uid2/package.json
generated
vendored
Normal file
12
srcs/requirements/nestjs/api_back/node_modules/uid2/package.json
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "uid2",
|
||||
"description": "strong uid",
|
||||
"tags": ["uid"],
|
||||
"version": "0.0.4",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/coreh/uid2.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {}
|
||||
}
|
||||
84
srcs/requirements/nestjs/api_back/package-lock.json
generated
84
srcs/requirements/nestjs/api_back/package-lock.json
generated
@@ -21,6 +21,7 @@
|
||||
"class-validator": "^0.13.2",
|
||||
"nest-router": "^1.0.9",
|
||||
"passport": "^0.6.0",
|
||||
"passport-42": "^1.2.6",
|
||||
"passport-local": "^1.0.0",
|
||||
"pg": "^8.8.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
@@ -2876,6 +2877,14 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/base64url": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz",
|
||||
"integrity": "sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A==",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/binary-extensions": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
|
||||
@@ -6482,6 +6491,11 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/oauth": {
|
||||
"version": "0.9.15",
|
||||
"resolved": "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz",
|
||||
"integrity": "sha512-a5ERWK1kh38ExDEfoO6qUHJb32rd7aYmPHuyCu3Fta/cnICvYmgd2uhuKXvPD+PXB+gCEYYEaQdIRAjCOwAKNA=="
|
||||
},
|
||||
"node_modules/object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
@@ -6738,6 +6752,17 @@
|
||||
"url": "https://github.com/sponsors/jaredhanson"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-42": {
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/passport-42/-/passport-42-1.2.6.tgz",
|
||||
"integrity": "sha512-a1SraWSwH33NqRDe9ScG4MQwfj7RRBYLFtrJySn4tU4Ou7+caLxj6VQgaL4i+eZoKC6QAooL1Nqevn/W8vLXuQ==",
|
||||
"dependencies": {
|
||||
"passport-oauth2": "^1.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-local": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz",
|
||||
@@ -6749,6 +6774,25 @@
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-oauth2": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/passport-oauth2/-/passport-oauth2-1.6.1.tgz",
|
||||
"integrity": "sha512-ZbV43Hq9d/SBSYQ22GOiglFsjsD1YY/qdiptA+8ej+9C1dL1TVB+mBE5kDH/D4AJo50+2i8f4bx0vg4/yDDZCQ==",
|
||||
"dependencies": {
|
||||
"base64url": "3.x.x",
|
||||
"oauth": "0.9.x",
|
||||
"passport-strategy": "1.x.x",
|
||||
"uid2": "0.0.x",
|
||||
"utils-merge": "1.x.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/jaredhanson"
|
||||
}
|
||||
},
|
||||
"node_modules/passport-strategy": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz",
|
||||
@@ -8573,6 +8617,11 @@
|
||||
"node": ">=4.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uid2": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/uid2/-/uid2-0.0.4.tgz",
|
||||
"integrity": "sha512-IevTus0SbGwQzYh3+fRsAMTVVPOoIVufzacXcHPmdlle1jUpq7BRL+mw3dgeLanvGZdwwbWhRV6XrcFNdBmjWA=="
|
||||
},
|
||||
"node_modules/universalify": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
|
||||
@@ -11182,6 +11231,11 @@
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA=="
|
||||
},
|
||||
"base64url": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz",
|
||||
"integrity": "sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A=="
|
||||
},
|
||||
"binary-extensions": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
|
||||
@@ -13884,6 +13938,11 @@
|
||||
"path-key": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"oauth": {
|
||||
"version": "0.9.15",
|
||||
"resolved": "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz",
|
||||
"integrity": "sha512-a5ERWK1kh38ExDEfoO6qUHJb32rd7aYmPHuyCu3Fta/cnICvYmgd2uhuKXvPD+PXB+gCEYYEaQdIRAjCOwAKNA=="
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
@@ -14068,6 +14127,14 @@
|
||||
"utils-merge": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"passport-42": {
|
||||
"version": "1.2.6",
|
||||
"resolved": "https://registry.npmjs.org/passport-42/-/passport-42-1.2.6.tgz",
|
||||
"integrity": "sha512-a1SraWSwH33NqRDe9ScG4MQwfj7RRBYLFtrJySn4tU4Ou7+caLxj6VQgaL4i+eZoKC6QAooL1Nqevn/W8vLXuQ==",
|
||||
"requires": {
|
||||
"passport-oauth2": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"passport-local": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-local/-/passport-local-1.0.0.tgz",
|
||||
@@ -14076,6 +14143,18 @@
|
||||
"passport-strategy": "1.x.x"
|
||||
}
|
||||
},
|
||||
"passport-oauth2": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/passport-oauth2/-/passport-oauth2-1.6.1.tgz",
|
||||
"integrity": "sha512-ZbV43Hq9d/SBSYQ22GOiglFsjsD1YY/qdiptA+8ej+9C1dL1TVB+mBE5kDH/D4AJo50+2i8f4bx0vg4/yDDZCQ==",
|
||||
"requires": {
|
||||
"base64url": "3.x.x",
|
||||
"oauth": "0.9.x",
|
||||
"passport-strategy": "1.x.x",
|
||||
"uid2": "0.0.x",
|
||||
"utils-merge": "1.x.x"
|
||||
}
|
||||
},
|
||||
"passport-strategy": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz",
|
||||
@@ -15316,6 +15395,11 @@
|
||||
"integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==",
|
||||
"devOptional": true
|
||||
},
|
||||
"uid2": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/uid2/-/uid2-0.0.4.tgz",
|
||||
"integrity": "sha512-IevTus0SbGwQzYh3+fRsAMTVVPOoIVufzacXcHPmdlle1jUpq7BRL+mw3dgeLanvGZdwwbWhRV6XrcFNdBmjWA=="
|
||||
},
|
||||
"universalify": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"class-validator": "^0.13.2",
|
||||
"nest-router": "^1.0.9",
|
||||
"passport": "^0.6.0",
|
||||
"passport-42": "^1.2.6",
|
||||
"passport-local": "^1.0.0",
|
||||
"pg": "^8.8.0",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
|
||||
@@ -5,6 +5,7 @@ import { UsersModule } from './users/users.module';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { FriendshipsModule } from './friendship/friendships.module';
|
||||
import { AuthenticationModule } from './auth/42/authentication.module';
|
||||
|
||||
@Module({
|
||||
imports: [UsersModule,
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { Controller, Get, Res } from '@nestjs/common';
|
||||
import { Response } from 'express';
|
||||
|
||||
@Controller('auth')
|
||||
export class AuthenticationController {
|
||||
|
||||
|
||||
/**
|
||||
* GET /api/v2/auth/login
|
||||
* Route pour l'autentification des utilisateurs
|
||||
*/
|
||||
@Get('login')
|
||||
login() {
|
||||
return 'login';
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v2/auth/redirect
|
||||
* C'est la route que nous devons spécifier à l'Oauth de 42.
|
||||
* L'api de 42 redirige vers cette route après l'autentification.
|
||||
*/
|
||||
@Get('redirect')
|
||||
redirect(@Res() res: Response) {
|
||||
res.send(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v2/auth/status
|
||||
* Route pour vérifier si l'utilisateur est connecté
|
||||
* ou non.
|
||||
*/
|
||||
@Get('status')
|
||||
status() {
|
||||
return 'status';
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v2/auth/logout
|
||||
* Route pour déconnecter l'utilisateur
|
||||
*/
|
||||
@Get('logout')
|
||||
logout() {
|
||||
return 'logout';
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { UsersModule } from 'src/users/users.module';
|
||||
import { AuthenticationService } from './authentication.service';
|
||||
import { FortyTwoStrategy } from './strategy/strategy';
|
||||
|
||||
@Module({
|
||||
imports: [UsersModule],
|
||||
providers: [AuthenticationService],
|
||||
providers: [AuthenticationService, FortyTwoStrategy],
|
||||
})
|
||||
export class AuthenticationModule {}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { CanActivate, ExecutionContext, Injectable } from "@nestjs/common";
|
||||
import { AuthGuard } from "@nestjs/passport";
|
||||
|
||||
@Injectable()
|
||||
export class FortyTwoAuthGuard extends AuthGuard('42') {
|
||||
async canActivate(context: ExecutionContext): Promise<any> {
|
||||
const activate = (await super.canActivate(context)) as boolean;
|
||||
const request = context.switchToHttp().getRequest();
|
||||
console.log(request.user);
|
||||
await super.logIn(request);
|
||||
return activate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Strategy, Profile } from "passport-42/lib";
|
||||
import { PassportStrategy } from "@nestjs/passport";
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { AuthenticationService } from "../authentication.service";
|
||||
|
||||
@Injectable()
|
||||
export class FortyTwoStrategy extends PassportStrategy(Strategy, "42") {
|
||||
constructor(private readonly authenticationService: AuthenticationService) {
|
||||
super({
|
||||
clientID: process.env.FORTYTWO_CLIENT_ID,
|
||||
clientSecret: process.env.FORTYTWO_CLIENT_SECRET,
|
||||
callbackURL: process.env.FORTYTWO_CALLBACK_URL,
|
||||
scope: ["public"],
|
||||
});
|
||||
}
|
||||
|
||||
async validate(accessToken: string, refreshToken: string, profile: Profile, callbackURL: string) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
import { Controller } from '@nestjs/common';
|
||||
|
||||
@Controller('/')
|
||||
export class AuthenticationController {
|
||||
|
||||
|
||||
}
|
||||
@@ -26,7 +26,6 @@ export class Friendship {
|
||||
@ManyToOne(type => User, user => user.addresseeId)
|
||||
addresseeId: string;
|
||||
|
||||
|
||||
@Column({ type: 'enum', enum: FriendshipStatus, default: FriendshipStatus.REQUESTED})
|
||||
status: FriendshipStatus;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ async function bootstrap() {
|
||||
},
|
||||
}),
|
||||
);
|
||||
app.setGlobalPrefix('api/v2');
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
@@ -11,6 +11,9 @@ export class User {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column({ name: 'fourty_two_id' })
|
||||
fourtyTwoId: string;
|
||||
|
||||
@Column()
|
||||
username: string;
|
||||
|
||||
@@ -21,6 +24,9 @@ export class User {
|
||||
@Column()
|
||||
password: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
avatar: string;
|
||||
|
||||
@Column('json', { nullable: true })
|
||||
status: [string];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user