{"id":23497988,"url":"https://github.com/freedomben/libmalan","last_synced_at":"2025-07-09T04:34:28.122Z","repository":{"id":38050887,"uuid":"359561999","full_name":"FreedomBen/libmalan","owner":"FreedomBen","description":"Simple TypeScript utility methods for accessing the Malan authentication service","archived":false,"fork":false,"pushed_at":"2024-02-15T17:49:54.000Z","size":309,"stargazers_count":0,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-22T21:59:03.541Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FreedomBen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-19T18:36:46.000Z","updated_at":"2021-12-21T17:07:42.000Z","dependencies_parsed_at":"2024-02-15T18:44:30.196Z","dependency_job_id":"a42820c8-14a2-45b7-a82f-bdc491ab1975","html_url":"https://github.com/FreedomBen/libmalan","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/FreedomBen/libmalan","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Flibmalan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Flibmalan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Flibmalan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Flibmalan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FreedomBen","download_url":"https://codeload.github.com/FreedomBen/libmalan/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreedomBen%2Flibmalan/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264394596,"owners_count":23601336,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-25T05:17:39.414Z","updated_at":"2025-07-09T04:34:28.101Z","avatar_url":"https://github.com/FreedomBen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lib Malan\n\nSome JavaScript/TypeScript utility functions for accessing the [Malan Authentication Service](https://github.com/FreedomBen/malan)\n\n## Examples:\n\nNote this is not a production-ready example, more of a \"how to I start playing with this\" example.\n\n```typescript\nimport * as malan from 'libmalan'\n\nlet malanConfig = {\n  host: \"http://127.0.0.1\",\n  api_token: \"\",\n}\n\n// Log in with username and password\nconst { id, api_token, user_id } = await malan.login(malanConfig, \"username\", \"password\")\n\n// Save API token for later use\nmalanConfig.api_token = resp.api_token\n\n// Get the user object\nconst user = (await malan.getUser(malanConfig, user_id)).data\n\n// Get the session object\nlet session = await malan.getSession(malanConfig, user.id, session_id)\n\n// Validate that the current user token has admin role\nconst isAdmin = await malan.isValidWithRole(malanConfig, user.id, session_id, \"admin\")\n\n// Log the user out (this will invalidate the API token)\nsession = await malan.logout(malanConfig, user.id, session_id)\n```\n\n## Running the tests\n\n### Automated process\n\nThe easiest way to run the tests is to use the script that CI uses:\n\n```bash\nnpm run test:ci\n```\n\nThis requires that docker and docker-compose be installed.  It will pull the latest\nmalan image, initialize it and its database, invoke the tests with `npm`, and stop the\nmalan and database containers.\n\nThis is useful if you just want to run tests once with minimal effort.  If you are\ndeveloping though, it will have a lot of overhead.  I recommend you use the manual\ndescribed next.\n\n### Manual process\n\nThe tests expect a [malan](https://github.com/freedomben/malan) to be running on\nlocalhost:4000.  It is highly advised that you do _not_ run them against a staging\nor production instance of malan because some test data will most certainly not be\ncleaned up properly.\n\n#### 1.  Get a malan instance running\n\nThe fastest way to get started is to use the docker-compose file to start a malan\ninstance:\n\n```bash\ndocker-compose up malan\n```\n\n_Note:  If you're on an ARM device, you need to switch the malan image in\n`docker-compose.yml` otherwise malan will crash on startup.  The image name is\nalready there but is commented out.  You just need to switch the images._\n\nIf you prefer a native run (instead of in docker), make sure Elixir and postgres\nare installed, then run:\n\n```bash\ngit clone https://github.com/FreedomBen/malan\ncd malan\nmix deps.get\nmix phx.server\n```\n\n#### 2.  Run the tests\n\n\n```bash\nnpm run test\n```\n\n## Release Process\n\n### Authentication with npm\n\nTo publish, you'll need an npm auth token.  There are numerous different ways to\naccomplish this, such as running `npm login`.  If you have 2 factor enabled (which\nyou should if you don't), the easiest way is to issue an automation token.\n\nPut that automation token in the environment variable `NPM_TOKEN` then add to\n`libmalan/.npmrc`\n\n```bash\necho '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' \u003e\u003e .npmrc\n```\n\n### To release a new version:\n\n1.  Update version number in `package.json`\n1.  Install latest packages:  `npm install`\n1.  Run a build:  `npm run build`\n1.  Build a tarball you can verify:  `npm pack`\n1.  Commit updated package.json and package-lock.json\n1.  Tag new version:  Ex:  `git tag v0.0.17`\n1.  Push commits and tags:  `git push \u0026\u0026 git push --tags`\n1.  Publish latest version:  `npm publish`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreedomben%2Flibmalan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreedomben%2Flibmalan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreedomben%2Flibmalan/lists"}