grantcore 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,7 @@
1
- /** The first stable surface of the package. */
2
- export declare const grantcore = "0.0.1";
1
+ export interface Grant {
2
+ principalId: string;
3
+ resource: string;
4
+ permissions: readonly string[];
5
+ }
6
+ export declare function createGrant(grant: Grant): Readonly<Grant>;
7
+ export declare function grantsPermission(grant: Grant, permission: string): boolean;
package/dist/index.js CHANGED
@@ -1,2 +1,11 @@
1
- /** The first stable surface of the package. */
2
- export const grantcore = "0.0.1";
1
+ export function createGrant(grant) {
2
+ if (!grant.principalId || !grant.resource)
3
+ throw new TypeError("Grant principal and resource are required.");
4
+ return Object.freeze({
5
+ ...grant,
6
+ permissions: Object.freeze([...new Set(grant.permissions)]),
7
+ });
8
+ }
9
+ export function grantsPermission(grant, permission) {
10
+ return grant.permissions.includes(permission);
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grantcore",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Small, framework-neutral primitives for representing authorization grants.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -12,19 +12,33 @@
12
12
  "default": "./dist/index.js"
13
13
  }
14
14
  },
15
- "files": ["dist", "README.md"],
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
16
19
  "sideEffects": false,
17
20
  "scripts": {
18
21
  "build": "tsc --project tsconfig.json",
19
22
  "prepublishOnly": "npm run build"
20
23
  },
21
- "keywords": ["auth", "authorization", "grants", "identity"],
24
+ "keywords": [
25
+ "auth",
26
+ "authorization",
27
+ "grants",
28
+ "identity"
29
+ ],
22
30
  "homepage": "https://signway.dev/",
23
31
  "author": "Mosanic <dev@mosanic.io>",
24
32
  "license": "MIT",
25
- "engines": {"node": ">=20"},
26
- "publishConfig": {"access": "public"},
27
- "devDependencies": {"typescript": "^5.9.3"},
33
+ "engines": {
34
+ "node": ">=20"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "devDependencies": {
40
+ "typescript": "^5.9.3"
41
+ },
28
42
  "repository": {
29
43
  "type": "git",
30
44
  "url": "git+https://github.com/mosanic/mosa-platform.git",