{"_id":"@del-internet/sdk-radius","_rev":"1-3c7f7f05aca81936ae4b42f48e658e1b","name":"@del-internet/sdk-radius","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@del-internet/sdk-radius","version":"1.0.0","keywords":["xarxa","Delinternet"],"author":{"name":"Ismail Zare","email":"zarehesmaiel@gmail.com"},"license":"MIT","_id":"@del-internet/sdk-radius@1.0.0","maintainers":[{"name":"zareismail","email":"zarehesmaiel@gmail.com"}],"homepage":"https://gitlab.delinternet.com/k8s/internet-contracts/sdk-radius/-/blob/main/README.md","bugs":{"url":"https://gitlab.delinternet.com/k8s/internet-contracts/sdk-radius/-/issues"},"dist":{"shasum":"e8cf09c1a78208c63e262b7d434400bec9fe698a","tarball":"https://registry.npmjs.org/@del-internet/sdk-radius/-/sdk-radius-1.0.0.tgz","fileCount":3,"integrity":"sha512-RS65wNIehpaxnyb+ZN9FgAboO1E8AFcqUAU8brgUeM0LRgWS8kFBrwcFY4KGfsLYBl6ic7+QoPIff1a+agj2pw==","signatures":[{"sig":"MEYCIQDLP8yWZVy4y1V0WCvfhkeXNtTd7hNf7aYSaFdtJ5UGvQIhAJbNhVb+glKC5mD7AsEwEteUoRUXBQWWf9jwoPucmxZG","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6052},"main":"dist/index.js","engines":{"node":">= 18.0.0"},"gitHead":"21fecee79cdb2dba50585ead785b91acf2bdfd03","private":false,"scripts":{"test":"NODE_ENV=test NODE_CONFIG_DIR=./src/config jest --forceExit","build":"npx tsc --build --clean & npx tsc --build","watch":"npx tsc --watch","format":"npx @biomejs/biome check --write --verbose","start:dev":"DEBUG=app:*,avonjs:* NODE_CONFIG_DIR='./src/config' node --watch -r ts-node/register -r tsconfig-paths/register -r dotenv/config src/index.ts","test:verbose":"DEBUG=app:*,avonjs:*,knex:* NODE_ENV=test NODE_CONFIG_DIR=./src/config jest --forceExit --verbose"},"_npmUser":{"name":"zareismail","email":"zarehesmaiel@gmail.com"},"repository":{"url":"https://gitlab.delinternet.com/k8s/internet-contracts/sdk-radius.git","type":"git"},"_npmVersion":"10.8.0","description":"TypeScript package to interacts with radius service","directories":{},"_nodeVersion":"20.12.2","dependencies":{"npm":"^10.9.0","debug":"^4.3.7","await-to-js":"^3.0.0","@avonjs/client":"^1.0.0","@faker-js/faker":"^9.0.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^29.7.0","ts-jest":"^29.2.5","lefthook":"^1.8.1","typescript":"^5.6.3","@types/jest":"^29.5.14","@types/node":"^22.7","@types/debug":"^4.1.12","@jest/globals":"^29.7.0","@types/config":"^3.3.5","@biomejs/biome":"1.9.4","jest-fetch-mock":"^3.0.3"},"_npmOperationalInternal":{"tmp":"tmp/sdk-radius_1.0.0_1739345195584_0.4595735756039747","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@del-internet/sdk-radius","version":"1.0.1","description":"TypeScript package to interacts with radius service","main":"dist/index.js","private":false,"publishConfig":{"access":"public"},"engines":{"node":">= 18.0.0"},"scripts":{"build":"npx tsc --build --clean & npx tsc --build","watch":"npx tsc --watch","test":"NODE_ENV=test NODE_CONFIG_DIR=./src/config jest --forceExit","test:verbose":"DEBUG=app:*,avonjs:*,knex:* NODE_ENV=test NODE_CONFIG_DIR=./src/config jest --forceExit --verbose","start:dev":"DEBUG=app:*,avonjs:* NODE_CONFIG_DIR='./src/config' node --watch -r ts-node/register -r tsconfig-paths/register -r dotenv/config src/index.ts","format":"npx @biomejs/biome check --write --verbose"},"repository":{"type":"git","url":"https://gitlab.delinternet.com/k8s/internet-contracts/sdk-radius.git"},"author":{"name":"Ismail Zare","email":"zarehesmaiel@gmail.com"},"license":"MIT","bugs":{"url":"https://gitlab.delinternet.com/k8s/internet-contracts/sdk-radius/-/issues"},"homepage":"https://gitlab.delinternet.com/k8s/internet-contracts/sdk-radius/-/blob/main/README.md","keywords":["xarxa","Delinternet"],"dependencies":{"@avonjs/client":"^1.0.0","@faker-js/faker":"^9.0.3","await-to-js":"^3.0.0","debug":"^4.3.7","npm":"^10.9.0"},"devDependencies":{"@biomejs/biome":"1.9.4","@jest/globals":"^29.7.0","@types/config":"^3.3.5","@types/debug":"^4.1.12","@types/jest":"^29.5.14","@types/node":"^22.7","jest":"^29.7.0","jest-fetch-mock":"^3.0.3","lefthook":"^1.8.1","ts-jest":"^29.2.5","typescript":"^5.6.3"},"_id":"@del-internet/sdk-radius@1.0.1","gitHead":"d566f502b84036169c376fdb5ef6dc7c0b293ed3","types":"./dist/index.d.ts","_nodeVersion":"20.12.2","_npmVersion":"10.8.0","dist":{"integrity":"sha512-8fs1IvKtCubISJQJ22+94Dld4GbTjo5v210ZCTywBqsHqHJwPjpQGWlk5usg8RfZX+As/02G+5TEECsMIYpSSQ==","shasum":"e31ceff2267bc9499bc575cb2c06519da4524544","tarball":"https://registry.npmjs.org/@del-internet/sdk-radius/-/sdk-radius-1.0.1.tgz","fileCount":9,"unpackedSize":19808,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGju2WgvS0C+YaVK2NYLYAVH2C16+UY+g27R4wfRg+iAAiEAhN3BmxAPllUkRKPPpGj9hc3G4vdwWyp3ksu0znXOPs0="}]},"_npmUser":{"name":"zareismail","email":"zarehesmaiel@gmail.com"},"directories":{},"maintainers":[{"name":"zareismail","email":"zarehesmaiel@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk-radius_1.0.1_1739350302141_0.4217651214852023"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-12T07:26:35.465Z","modified":"2025-02-12T08:51:42.488Z","1.0.0":"2025-02-12T07:26:35.773Z","1.0.1":"2025-02-12T08:51:42.312Z"},"bugs":{"url":"https://gitlab.delinternet.com/k8s/internet-contracts/sdk-radius/-/issues"},"author":{"name":"Ismail Zare","email":"zarehesmaiel@gmail.com"},"license":"MIT","homepage":"https://gitlab.delinternet.com/k8s/internet-contracts/sdk-radius/-/blob/main/README.md","keywords":["xarxa","Delinternet"],"repository":{"type":"git","url":"https://gitlab.delinternet.com/k8s/internet-contracts/sdk-radius.git"},"description":"TypeScript package to interacts with radius service","maintainers":[{"name":"zareismail","email":"zarehesmaiel@gmail.com"}],"readme":"## `Gate` SDK Methods\n\n### `async can(user: User, ability: string): Promise<boolean>`\n\nChecks if a decoded JWT user has a specific ability.\n\n- **Parameters**:\n  - `user`: The decoded JWT object representing the user.\n  - `ability`: The specific permission to check (e.g., `blog.articles.create`).\n\n- **Returns**: A boolean indicating whether the user has the specified ability.\n\n---\n\n### `async any(user: User, abilities: string[]): Promise<boolean>`\n\nChecks if the decoded JWT user has at least one of the specified abilities.\n\n- **Parameters**:\n  - `user`: The decoded JWT object.\n  - `abilities`: Array of abilities to check.\n\n- **Returns**: `true` if the user has any of the abilities, `false` otherwise.\n\n---\n\n### `async every(user: User, abilities: string[]): Promise<boolean>`\n\nChecks if the decoded JWT user has all of the specified abilities.\n\n- **Parameters**:\n  - `user`: The decoded JWT object.\n  - `abilities`: Array of abilities to check.\n\n- **Returns**: `true` if the user has all specified abilities, `false` otherwise.\n\n---\n\n### `async forUser(user: User): Promise<PermissionCollection>`\n\nFetches all permissions for the decoded JWT user and returns them as a `PermissionCollection` object.\n\n- **Parameters**:\n  - `user`: The decoded JWT object.\n\n- **Returns**: A `PermissionCollection` instance.\n\n---\n\n### `async share(user: User, permissions: string[], ttl: number)`\n\nStores permissions for a decoded JWT user in Redis with a time-to-live (TTL).\n\n- **Parameters**:\n  - `user`: The decoded JWT object.\n  - `permissions`: Array of permissions to store.\n  - `ttl`: Expiry time for the permissions in seconds.\n\n- **Returns**: The `Gate` instance for method chaining.\n\n---\n\n### `async authorize(user: User, permissions: string[], ttl: number)`\n\nAlias for `share`. Adds permissions for a decoded JWT user with a specified TTL.\n\n---\n\n### `async forget(user: User)`\n\nDeletes all cached permissions for the decoded JWT user from Redis.\n\n- **Parameters**:\n  - `user`: The decoded JWT object.\n\n- **Returns**: The `Gate` instance for method chaining.\n\n---\n\n### `async refresh(user: User, permissions: string[])`\n\nUpdates the permissions for a decoded JWT user, preserving existing TTLs for the cached data.\n\n- **Parameters**:\n  - `user`: The decoded JWT object.\n  - `permissions`: New set of permissions to update.\n\n- **Returns**: The `Gate` instance for method chaining.\n\n---\n\n### `async all(user: User): Promise<string[]>`\n\nRetrieves all permissions for a decoded JWT user from Redis as an array of strings.\n\n- **Parameters**:\n  - `user`: The decoded JWT object.\n\n- **Returns**: Array of permissions associated with the user.\n\n---\n\n### `async isRevoked(user: User): Promise<boolean>`\n\nChecks if the decoded JWT user has no active permissions.\n\n- **Parameters**:\n  - `user`: The decoded JWT object.\n\n- **Returns**: `true` if the user has no permissions, `false` otherwise.\n\n---\n\n### `debugUsing(debugUsing: Debugger)`\n\nSets a custom debugger function for logging.\n\n- **Parameters**:\n  - `debugUsing`: The custom debug function to use.\n\n- **Returns**: The `Gate` instance for method chaining.\n\n---\n\n### Example Usage\n\nInstall the SDK:\n\n```\nnpm i @del-internet/sdk-radius\n```\nThen: \n\n```typescript\nimport Gate from '@del-internet/sdk-radius';\n\nconst config = { host: 'localhost', port: 6379 };\nconst gate = new Gate(config);\n\nasync function checkUserPermissions() {\n  const user = { id: 'user123', key: 'user:permissions:user123' }; // Decoded JWT object\n  const permissions = ['blog.articles.create', 'blog.articles.update'];\n\n  await gate.share(user, permissions, 3600); // Cache permissions for 1 hour\n\n  const canCreate = await gate.can(user, 'blog.articles.create');\n  console.log(`User can create: ${canCreate}`);\n}\n\ncheckUserPermissions();\n```\n\nThis documentation assumes the user parameter represents a decoded JWT object containing relevant details such as `id` and `key`.\n","readmeFilename":"README.md"}