{"_id":"@01-edu/api","_rev":"5-19c169427e22d1a196eb60f23d1da9b0","name":"@01-edu/api","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"@01-edu/api","version":"1.0.0","author":"","license":"MIT","_id":"@01-edu/api@1.0.0","maintainers":[{"name":"lee_silva","email":"leedasilva988@gmail.com"},{"name":"kigiri","email":"le.mikmac@gmail.com"}],"homepage":"https://github.com/LEEDASILVA/01-edu-api#readme","bugs":{"url":"https://github.com/LEEDASILVA/01-edu-api/issues"},"dist":{"shasum":"07eaefc16329ee45f643d0f1d3af42faec586ce4","tarball":"https://registry.npmjs.org/@01-edu/api/-/api-1.0.0.tgz","fileCount":2,"integrity":"sha512-mATFckVtcQ1F0lFiKtBYQJeJXyE5Of575vWiBWUFpGkRZltlSfwXmJOp4xjk9knXbAgVuR3VUBTDJCk4Y/e3Sg==","signatures":[{"sig":"MEQCIFvWN2S/k9OnunQMi7qQxFXCLOASodZPz/aoTE8/jlHBAiAsydbcXwRKIbJjk1NFS/cd1bOWijkqP5rqWEBWGq2Ing==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":476,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg9bCiCRA9TVsSAnZWagAAmy8P/3TNux3dgSp6Yt6mL2WO\nAb9fjdIUdKY2Ak4LOYSaXLexWACQuvr9/cBTwl4hddrvh6+0ggkCVljP8t1T\nbtgfQDCyV4xKYUjtvONHNmGJKaQVJXj7kjqX2vsEIE+51XaGtIxuwWjCqx6s\nNgiLLHEVpGmQFgakZGiyx0Ephhrmpvj7O6IpfSfAOu6jltX3iFK9jfLB7iD8\nFRf/x1bvzLnRPYGD+in26xwEJvSC9V2FdZim+m/FG0R6N6NqmQFGEMzh35FH\n/H+N4Rn41pFa/20Z74tH1hrjjWRVGszQ7uC+dLbNKLLv6I1EeAg7shSyiq3v\nRBBdrO3nCJUVOHplphjvt1IrbWwsD9rVfzXS9RpSTAzRgtmJ89XU5hNzQqJC\nzao+cafkzHoxAMTZ1rRQkN5LQWiT7BEx+VjoBhOg0PRm2TI0NscRNXh0HNlE\naM7oxjAzbRG0gH60YZSeVZVKi2Yw27xePUJWD2bK2JIkBm5IP8rnYcQNZSm5\nhCzwwm1bN5GrLo1wqS8Wqdf22M0qXwBuKNFMcrlnF1tIdBmHPWdM9r2AL761\nPKg20eu4t74opaPUc2qlzr8syyROgCHLvolBNybbj+uYFa3TKjB4c5S0tyqf\ns3F3b2BJSI/tuqzhR/sskAgEMvtGjG5U+LMVbXONFtk2EkDuA0jTzLlIs0D9\nsaoG\r\n=HZuV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","gitHead":"8fa55accbad05be6eb4177fd2ef0ce1a1b22b0cf","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"lee_silva","email":"leedasilva988@gmail.com"},"repository":{"url":"git+https://github.com/LEEDASILVA/01-edu-api.git","type":"git"},"_npmVersion":"7.15.1","description":"","directories":{},"_nodeVersion":"14.17.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/api_1.0.0_1626714274449_0.2543708269329976","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@01-edu/api","version":"1.1.0","author":"","license":"MIT","_id":"@01-edu/api@1.1.0","maintainers":[{"name":"kigiri","email":"le.mikmac@gmail.com"},{"name":"lee_silva","email":"leedasilva988@gmail.com"}],"homepage":"https://github.com/LEEDASILVA/01-edu-api#readme","bugs":{"url":"https://github.com/LEEDASILVA/01-edu-api/issues"},"dist":{"shasum":"4af2de1ddbff34d276c716529019331b10f15ff6","tarball":"https://registry.npmjs.org/@01-edu/api/-/api-1.1.0.tgz","fileCount":7,"integrity":"sha512-4KHJ7j40GRKjFdNtDwbJyQF4OtM+SpLUVUExXivDpp4Ir/LbDrzLUtBEZjyEuiGx8kBsiey+9xIWo0RIjR+7XQ==","signatures":[{"sig":"MEUCIQCYK4DkHK5LPNHaGKXoxNZlIyVFKPiiF2HKHzoLWLcrUQIgGnQi2p2+mWMi1XO9+RfvOJ0CIliNmpWHVHNnvUW1RL4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":42987,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhHQBOCRA9TVsSAnZWagAAQ/MP/RuBzQjIWJjY01JMEsYG\npydunPPuhuXJJb5/cQ0a5HUiWqUNq7yqmgykWv3JkaZ/18KmnbgllDW0OMrY\nldzinJgH/pSrZsfCapx4fESfVufBtqpVQ35xsOaOaIGhl8fD3nYspo6ipO1G\nhPfxb7dhOfTu/RGrhSNxTPhGuvLsO55+AiFpn7MTpeFAL0+BKloEE9DzPkfK\n367/X/5UuSSkwHBx8ySe9pg9rci8dkv0X1UW+ulZN3w34RFj2vz0eQSUPjSv\nnLzK1VtoaxmeugPzJ9K0qRgxq2hdUv0OOFwRCEVeXXukv4QYm/DHRRkCpUv8\ngIK0LFpqUEg98GMtxOoTCyQW3RBQ1oZWSQTh2kfwV+AKy2g59C/VxSITmTqE\nX/eHcszRQCyM9zAQjuoXFJ9bDOWh+1VmsTiAPm6b9kUV7WMIKfU9mXYTI/nw\n+VjYDi9DCqXMQQZVplG7fIdyqw31cvTf1RGOAqebO+BBrzwVUlfT1hrkkbJY\nGtl5ltyXFODhaW5R99u5LkIUTDj+Z9eal5KUUr6WwnlOQOrskO7GlACfbHJo\n9IWdNiyZ+8Msfmhdcp76PcliOq/uXxMSY6Up4Mapps7nTBY5KUahTLepS6r5\nyQFejMSBVgTm5XImMhYMUaA5FVcDEzNNnk9DzjnXxSFvEvvY8Gv5RC/UD1Dd\nL5g7\r\n=2HE4\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","type":"module","gitHead":"7e6c4f6b4edf277729865fc85addcd884c529c67","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"lee_silva","email":"leedasilva988@gmail.com"},"repository":{"url":"git+https://github.com/LEEDASILVA/01-edu-api.git","type":"git"},"_npmVersion":"7.15.1","description":"## Packages","directories":{},"_nodeVersion":"14.17.0","dependencies":{"https":"^1.0.0","form-data":"^4.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/api_1.1.0_1629290573838_0.8734215223214512","host":"s3://npm-registry-packages"}},"1.1.1":{"name":"@01-edu/api","version":"1.1.1","author":"","license":"MIT","_id":"@01-edu/api@1.1.1","maintainers":[{"name":"kigiri","email":"le.mikmac@gmail.com"},{"name":"lee_silva","email":"leedasilva988@gmail.com"}],"homepage":"https://github.com/LEEDASILVA/01-edu-api#readme","bugs":{"url":"https://github.com/LEEDASILVA/01-edu-api/issues"},"dist":{"shasum":"8c93f8c7dbac4c16773e9326ec585f7f27cf5c62","tarball":"https://registry.npmjs.org/@01-edu/api/-/api-1.1.1.tgz","fileCount":7,"integrity":"sha512-/gwpmLV0sQhg03nIFhYlLi9u4+BVqehoYXXalv+W+nPfCj4a/Gul4XUK6OU38sN0eY1Xw77XZRiW+LJwZ6qseg==","signatures":[{"sig":"MEUCIBHrDLa4Z7qkEVulivJOPaidSdorV6gOLIEN7mVzxsI1AiEAokCZsoz/ss4fe4b7sa8u3PIiLdjSPlcALXLbTzAfQp4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":42962,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiM2qVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpOPBAAhrRPO45OYjZBabc9YGpao918WpKhxNs5NSMR4FLkHmnAGvHk\r\nvikGrLM/NVSP69OOrfY0aIGLAc+d3KXX5zQlI1FfZvPqUwEyyWTy9sX2FuMv\r\nOfT4TuAuoQkbPN5LtoMEQa06BR4gWcExy1gR/3zNZGK3y9gwk/dMp5N2aITJ\r\nibXHlCnNNVUebSzflZzPaIAAZ7VjklwoDiwma+KZgGtXmegI3phviuSjh3sP\r\n6SHn+FkX6D6pDR36oMBIhC5zqbh2LpAoNti8ug+o4SC96c824z/2aKT0Z+IK\r\nrYUYBnbYoqmnSu9bsAzXvkk7EFrFE2PRVdfBaogdOOrVS2LPMWa9rq2wJYU4\r\nLbwUSGZS00/gE6gHPw7OUwj7zCj3R+Nwj/Ur7KnGBOi70kTRZYMWwNpF6Nwo\r\nYpmHIMAGAjxGVq6xX5iqCoTY6OLXPxRboicDt2rJe3pc18QVndp7M5Vhnp+u\r\nFzAi101XLrzyey0sUpyOlRV3XCo+54oGRfYARD2u5Em4Qzzfvi28oltI0X8R\r\nLyotc6Wn+3c5IThrSf9TjUbAstd7BvLZl/ZTbJo4lsKI8ZfK9SuTRu9LIASu\r\nO2gghDG7YXyjnr2Fw+N3GHi9AhZynYgIZHqCo0DeJKFkuzWPEa7LlDIEkRcI\r\n+eyVHATQvj0ez9qFCUWv/kvfqqLSSE9efwA=\r\n=JFpd\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","type":"module","gitHead":"8700a6b0e6424e200316263542e32a9a89e66bc7","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"lee_silva","email":"leedasilva988@gmail.com"},"repository":{"url":"git+https://github.com/LEEDASILVA/01-edu-api.git","type":"git"},"_npmVersion":"8.1.0","description":"## Packages","directories":{},"_nodeVersion":"16.13.0","dependencies":{"https":"^1.0.0","form-data":"^4.0.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/api_1.1.1_1647536789383_0.48840474491170527","host":"s3://npm-registry-packages"}}},"time":{"created":"2021-07-19T17:04:34.084Z","modified":"2026-02-16T11:35:38.091Z","1.0.0":"2021-07-19T17:04:34.633Z","1.1.0":"2021-08-18T12:42:54.168Z","1.1.1":"2022-03-17T17:06:29.550Z"},"bugs":{"url":"https://github.com/LEEDASILVA/01-edu-api/issues"},"license":"MIT","homepage":"https://github.com/LEEDASILVA/01-edu-api#readme","repository":{"url":"git+https://github.com/LEEDASILVA/01-edu-api.git","type":"git"},"description":"## Packages","maintainers":[{"email":"le.mikmac@gmail.com","name":"kigiri"},{"email":"leedasilva988@gmail.com","name":"lee_silva"},{"email":"sysadmin@01edu.ai","name":"01edu_ai"}],"readme":"# 01-API\n\n## Packages\n\n### Read-only-access API\n\n- Install\n\n```console\n$ npm i @01-edu/api\n```\n\n### Instructions\n\nThis package allows users to create a read only access to the schools database (keep in mind that this access will only be provided for admins).\n\n- How to get an access token from gitea?\n\nTo get an access token from gitea, you must go to **user/settings/application** then **Generate New Token** (https://DOMAIN/user/settings/applications).\n\n1. Go user settings on gitea.\n\n![instructions](./img/setting.png 'Instructions')\n\n2. Then in application you can create the token by inserting a name for this token then it will be generated.\n\n![instructions](./img/access_token.png 'Instructions')\n\nOr you can use `curl` and send a request to gitea:\n\n```sh\n$ curl -X 'POST' 'https://someone:123456@git.dev.01-edu.org/api/v1/users/someone/tokens' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{\"name\": \"access_token\"}'\n```\n\noutput\n\n```sh\n{\"id\":4,\"name\":\"access_token\",\"sha1\":\"592cfb612d027eeb45359d837a93b4e22b5e1\",\"token_last_eight\":\"e22bb5e1\"}\n```\n\n- What can you query?\n\nQuerying information is depended on the users role. You can see all possible tables that this role can query [here](https://public.01-edu.org/docs/db/db-authorization)\n\n- How to query the information? Where to find examples?\n\nYou can take a look into the documentation [here](https://public.01-edu.org/docs/db/graphql).\n\n---\n\n### **Usage**\n\nThis package contains the following exported functions:\n\n- `createClient`\n- `requestToken`\n- `decode`\n\n### `createClient`\n\nThis function allows the application to init a client. This client will :\n\n- generate a new **read only token** saving it in storage (global state)\n- initialize a refresh loop, where it will refresh the **read only token** whenever the token expires.\n\nReturns the `storage` and a function `run`.\\\nThe `run` function allows the application to query the database. The `storage` contains a set of functions that allows the application to access the local storage (where the token is saved)\n\nexample:\n\n```js\nconst domain = 'dev.01-edu.org'\n// access_token is the token provided by gitea\nconst access_token = '427faa391a0d73a68b69d4d3b65796fd798e9156'\n\nconst client = await createClient({\n  domain,\n  access_token,\n})\n\nclient.run('query {user{id, login}}').then(console.log)\nconsole.log(client.storage.get('hasura-jwt-token'))\n```\n\noutput:\n\n```console\n{\n  user: [\n    { id: 1, login: '01-edu' },\n    { id: 6, login: 'Joao' }\n    { id: 7, login: 'Someone' },\n    { id: 8, login: 'Lee' },\n  ]\n}\neyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI2IiwiaWF0IjoxN1MzY2LCJpcCI6IjE3Mi4xOC4wLjEsIDE3Mi4xOC4wLjMiLCJleHAiOjE2MjkpbXMiOnsieC1oYXN1cmEtYWxsb3dlZC1yb2xlcyI6WyJ1c2VyIiwiYWRtaW5fcmVhZF9vbmx5Il0sI1kWx0LXJvbGUiOiJhZG1pbl9yZWFkX29ubHkiLCJ4LWhhc3VyYS11c2VyLWlkIjoiNiIsIngtaGFzdXJhLXRva2VuLWlkIjoiZjgzZmM2YTItZWFhNC00NDVmLTgyNmYtYTg1NTgzZjA1NWY3In19.HObIGivW31TOqFNlzu6VY7ACuTC5x0numm6-hOKp0\n```\n\n---\n\n### `requestToken`\n\nThis allows application to generate a new token without the client being initialized.\n\nexample:\n\n```js\nrequestToken({ domain, access_token }).then(console.log)\n```\n\noutput:\n\n```js\neyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiI2IiwiaWF0IjoxNjI4Nzg4OTk1LCJpcCI6IjE3Mi4xOC4wLjEsIDE3Mi4xOC4wLjMiLCJleHAiOjE2MjkyMjA5OTUsImh0dOi8vaGFzdXJhLmlvL2p3dC9jbGFpbXMiOnsieC1oYXN1cmEtYWxsb3dlZC1yb2xlcyI6WyJ1c2VyIiwiYyZWFkX29ubHkiLCJ4LWhhc3VyYS11c2VyLWlkIjoiNiIsIngtaGFzdXJhLXRva2VuLWlkIjoiNTM5NzBkZGItMmIzNi00OTFiLTgwMDMtOTRhZTExMDU0N2U3In19.p6HtlfClZUbLwgbwx8JJs_eSPzGOMEvC0uDDsXtA\n{\n  sub: '6',\n  iat: 1628788995,\n  ip: '172.18.0.1, 172.18.0.3',\n  exp: 1629220995,\n  'https://hasura.io/jwt/claims': {\n    'x-hasura-allowed-roles': [ 'user', 'admin_read_only' ],\n    'x-hasura-campuses': '{}',\n    'x-hasura-default-role': 'admin_read_only',\n    'x-hasura-user-id': '6',\n    'x-hasura-token-id': '53970dd-2b36-491b-800-94ae1105477'\n  }\n}\n```\n","readmeFilename":"README.md"}