@pgpm/jwt-claims 0.13.0 → 0.15.0

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/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
1
  The MIT License (MIT)
2
2
 
3
3
  Copyright (c) 2025 Dan Lynch <pyramation@gmail.com>
4
- Copyright (c) 2025 Interweb, Inc.
4
+ Copyright (c) 2025 Constructive
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the "Software"), to deal
package/Makefile CHANGED
@@ -1,5 +1,5 @@
1
- EXTENSION = launchql-jwt-claims
2
- DATA = sql/launchql-jwt-claims--0.9.0.sql
1
+ EXTENSION = pgpm-jwt-claims
2
+ DATA = sql/pgpm-jwt-claims--0.14.0.sql
3
3
 
4
4
  PG_CONFIG = pg_config
5
5
  PGXS := $(shell $(PG_CONFIG) --pgxs)
package/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # @pgpm/jwt-claims
2
2
 
3
3
  <p align="center" width="100%">
4
- <img height="250" src="https://raw.githubusercontent.com/launchql/launchql/refs/heads/main/assets/outline-logo.svg" />
4
+ <img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
5
5
  </p>
6
6
 
7
7
  <p align="center" width="100%">
8
- <a href="https://github.com/launchql/pgpm-modules/actions/workflows/ci.yml">
9
- <img height="20" src="https://github.com/launchql/pgpm-modules/actions/workflows/ci.yml/badge.svg" />
8
+ <a href="https://github.com/constructive-io/pgpm-modules/actions/workflows/ci.yml">
9
+ <img height="20" src="https://github.com/constructive-io/pgpm-modules/actions/workflows/ci.yml/badge.svg" />
10
10
  </a>
11
- <a href="https://github.com/launchql/pgpm-modules/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
12
- <a href="https://www.npmjs.com/package/@pgpm/jwt-claims"><img height="20" src="https://img.shields.io/github/package-json/v/launchql/pgpm-modules?filename=packages%2Fsecurity%2Fjwt-claims%2Fpackage.json"/></a>
11
+ <a href="https://github.com/constructive-io/pgpm-modules/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
12
+ <a href="https://www.npmjs.com/package/@pgpm/jwt-claims"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/pgpm-modules?filename=packages%2Fsecurity%2Fjwt-claims%2Fpackage.json"/></a>
13
13
  </p>
14
14
 
15
15
  JWT claim handling and validation functions.
@@ -65,7 +65,7 @@ pgpm deploy
65
65
 
66
66
  ```bash
67
67
  # 1. Create a workspace
68
- pgpm init --workspace
68
+ pgpm init workspace
69
69
 
70
70
  # 2. Create your first module
71
71
  cd my-workspace
@@ -338,13 +338,13 @@ pnpm test
338
338
 
339
339
  ## Related Tooling
340
340
 
341
- * [pgpm](https://github.com/launchql/launchql/tree/main/packages/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
342
- * [pgsql-test](https://github.com/launchql/launchql/tree/main/packages/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
343
- * [supabase-test](https://github.com/launchql/launchql/tree/main/packages/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
344
- * [graphile-test](https://github.com/launchql/launchql/tree/main/packages/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
345
- * [pgsql-parser](https://github.com/launchql/pgsql-parser): **🔄 SQL conversion engine** that interprets and converts PostgreSQL syntax.
346
- * [libpg-query-node](https://github.com/launchql/libpg-query-node): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
347
- * [pg-proto-parser](https://github.com/launchql/pg-proto-parser): **📦 Protobuf parser** for parsing PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
341
+ * [pgpm](https://github.com/constructive-io/constructive/tree/main/packages/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
342
+ * [pgsql-test](https://github.com/constructive-io/constructive/tree/main/packages/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
343
+ * [supabase-test](https://github.com/constructive-io/constructive/tree/main/packages/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
344
+ * [graphile-test](https://github.com/constructive-io/constructive/tree/main/packages/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
345
+ * [pgsql-parser](https://github.com/constructive-io/pgsql-parser): **🔄 SQL conversion engine** that interprets and converts PostgreSQL syntax.
346
+ * [libpg-query-node](https://github.com/constructive-io/libpg-query-node): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
347
+ * [pg-proto-parser](https://github.com/constructive-io/pg-proto-parser): **📦 Protobuf parser** for parsing PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
348
348
 
349
349
  ## Disclaimer
350
350
 
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@pgpm/jwt-claims",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "JWT claim handling and validation functions",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "contributors": [
7
- "Interweb <developers@interweb.co>"
7
+ "Constructive <developers@constructive.io>"
8
8
  ],
9
9
  "keywords": [
10
10
  "postgresql",
@@ -21,19 +21,19 @@
21
21
  "test:watch": "jest --watch"
22
22
  },
23
23
  "devDependencies": {
24
- "pgpm": "^0.2.0"
24
+ "pgpm": "^1.0.0"
25
25
  },
26
26
  "dependencies": {
27
- "@pgpm/types": "0.13.0",
28
- "@pgpm/verify": "0.13.0"
27
+ "@pgpm/types": "0.15.0",
28
+ "@pgpm/verify": "0.15.0"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",
32
- "url": "https://github.com/launchql/pgpm-modules"
32
+ "url": "https://github.com/constructive-io/pgpm-modules"
33
33
  },
34
- "homepage": "https://github.com/launchql/pgpm-modules",
34
+ "homepage": "https://github.com/constructive-io/pgpm-modules",
35
35
  "bugs": {
36
- "url": "https://github.com/launchql/pgpm-modules/issues"
36
+ "url": "https://github.com/constructive-io/pgpm-modules/issues"
37
37
  },
38
- "gitHead": "e7de11be3a2fd806929adf48acc556d812c75aa6"
38
+ "gitHead": "118ac6f810720378fa954e9620abf2516293c148"
39
39
  }
@@ -0,0 +1,8 @@
1
+ # pgpm-jwt-claims extension
2
+ comment = 'pgpm-jwt-claims extension'
3
+ default_version = '0.14.0'
4
+ module_pathname = '$libdir/pgpm-jwt-claims'
5
+ requires = 'plpgsql,uuid-ossp,pgpm-types,pgpm-verify'
6
+ relocatable = false
7
+ superuser = false
8
+
package/pgpm.plan CHANGED
@@ -1,6 +1,6 @@
1
1
  %syntax-version=1.0.0
2
- %project=launchql-jwt-claims
3
- %uri=launchql-jwt-claims
2
+ %project=pgpm-jwt-claims
3
+ %uri=pgpm-jwt-claims
4
4
 
5
5
  schemas/ctx/schema 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/ctx/schema
6
6
  schemas/ctx/procedures/ip_address [schemas/ctx/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/ctx/procedures/ip_address
@@ -1,4 +1,4 @@
1
- \echo Use "CREATE EXTENSION launchql-jwt-claims" to load this file. \quit
1
+ \echo Use "CREATE EXTENSION pgpm-jwt-claims" to load this file. \quit
2
2
  CREATE SCHEMA ctx;
3
3
 
4
4
  GRANT USAGE ON SCHEMA ctx TO authenticated, anonymous;
@@ -6,20 +6,6 @@ GRANT USAGE ON SCHEMA ctx TO authenticated, anonymous;
6
6
  ALTER DEFAULT PRIVILEGES IN SCHEMA ctx
7
7
  GRANT EXECUTE ON FUNCTIONS TO authenticated;
8
8
 
9
- CREATE SCHEMA jwt_public;
10
-
11
- GRANT USAGE ON SCHEMA jwt_public TO authenticated, anonymous;
12
-
13
- ALTER DEFAULT PRIVILEGES IN SCHEMA jwt_public
14
- GRANT EXECUTE ON FUNCTIONS TO authenticated;
15
-
16
- CREATE SCHEMA jwt_private;
17
-
18
- GRANT USAGE ON SCHEMA jwt_private TO authenticated, anonymous;
19
-
20
- ALTER DEFAULT PRIVILEGES IN SCHEMA jwt_private
21
- GRANT EXECUTE ON FUNCTIONS TO authenticated;
22
-
23
9
  CREATE FUNCTION ctx.ip_address() RETURNS inet AS $EOFCODE$
24
10
  SELECT nullif(current_setting('jwt.claims.ip_address', true), '')::inet;
25
11
  $EOFCODE$ LANGUAGE sql STABLE;
@@ -36,7 +22,7 @@ CREATE FUNCTION ctx.user_id() RETURNS uuid AS $EOFCODE$
36
22
  SELECT nullif(current_setting('jwt.claims.user_id', true), '')::uuid;
37
23
  $EOFCODE$ LANGUAGE sql STABLE;
38
24
 
39
- DO $LQLMIGRATION$
25
+ DO $EOFCODE$
40
26
  DECLARE
41
27
  BEGIN
42
28
  EXECUTE format('CREATE FUNCTION ctx.security_definer() returns text as $FUNC$
@@ -48,11 +34,19 @@ LANGUAGE ''sql'';', current_user);
48
34
  $FUNC$
49
35
  LANGUAGE ''sql'';', current_user);
50
36
  END;
51
- $LQLMIGRATION$;
37
+ $EOFCODE$;
52
38
 
53
39
  GRANT EXECUTE ON FUNCTION ctx.security_definer() TO PUBLIC;
40
+
54
41
  GRANT EXECUTE ON FUNCTION ctx.is_security_definer() TO PUBLIC;
55
42
 
43
+ CREATE SCHEMA jwt_public;
44
+
45
+ GRANT USAGE ON SCHEMA jwt_public TO authenticated, anonymous;
46
+
47
+ ALTER DEFAULT PRIVILEGES IN SCHEMA jwt_public
48
+ GRANT EXECUTE ON FUNCTIONS TO authenticated;
49
+
56
50
  CREATE FUNCTION jwt_public.current_user_id() RETURNS uuid AS $EOFCODE$
57
51
  DECLARE
58
52
  v_identifier_id uuid;
@@ -93,10 +87,6 @@ BEGIN
93
87
  END;
94
88
  $EOFCODE$ LANGUAGE plpgsql STABLE;
95
89
 
96
- CREATE FUNCTION jwt_public.current_origin() RETURNS origin AS $EOFCODE$
97
- SELECT nullif(current_setting('jwt.claims.origin', TRUE), '')::origin;
98
- $EOFCODE$ LANGUAGE sql STABLE;
99
-
100
90
  CREATE FUNCTION jwt_public.current_user_agent() RETURNS text AS $EOFCODE$
101
91
  DECLARE
102
92
  v_uagent text;
@@ -117,46 +107,57 @@ BEGIN
117
107
  END;
118
108
  $EOFCODE$ LANGUAGE plpgsql STABLE;
119
109
 
120
- CREATE FUNCTION jwt_private.current_database_id() RETURNS uuid AS $EOFCODE$
110
+ CREATE FUNCTION jwt_public.current_origin() RETURNS origin AS $EOFCODE$
111
+ SELECT nullif(current_setting('jwt.claims.origin', true), '')::origin;
112
+ $EOFCODE$ LANGUAGE sql STABLE;
113
+
114
+ CREATE FUNCTION jwt_public.current_group_ids() RETURNS uuid[] AS $EOFCODE$
121
115
  DECLARE
122
- v_identifier_id uuid;
116
+ v_identifier_ids uuid[];
123
117
  BEGIN
124
- IF current_setting('jwt.claims.database_id', TRUE)
118
+ IF current_setting('jwt.claims.group_ids', TRUE)
125
119
  IS NOT NULL THEN
126
120
  BEGIN
127
- v_identifier_id = current_setting('jwt.claims.database_id', TRUE)::uuid;
121
+ v_identifier_ids = current_setting('jwt.claims.group_ids', TRUE)::uuid[];
128
122
  EXCEPTION
129
123
  WHEN OTHERS THEN
130
124
  RAISE NOTICE 'Invalid UUID value';
131
- RETURN NULL;
125
+ RETURN ARRAY[]::uuid[];
132
126
  END;
133
- RETURN v_identifier_id;
127
+ RETURN v_identifier_ids;
134
128
  ELSE
135
- RETURN NULL;
129
+ RETURN ARRAY[]::uuid[];
136
130
  END IF;
137
131
  END;
138
132
  $EOFCODE$ LANGUAGE plpgsql STABLE;
139
133
 
140
- CREATE FUNCTION jwt_private.current_token_id() RETURNS uuid AS $EOFCODE$
141
- SELECT nullif(current_setting('jwt.claims.token_id', TRUE), '')::uuid;
142
- $EOFCODE$ LANGUAGE sql STABLE;
134
+ CREATE SCHEMA jwt_private;
143
135
 
144
- CREATE FUNCTION jwt_public.current_group_ids() RETURNS uuid[] AS $EOFCODE$
136
+ GRANT USAGE ON SCHEMA jwt_private TO authenticated, anonymous;
137
+
138
+ ALTER DEFAULT PRIVILEGES IN SCHEMA jwt_private
139
+ GRANT EXECUTE ON FUNCTIONS TO authenticated;
140
+
141
+ CREATE FUNCTION jwt_private.current_database_id() RETURNS uuid AS $EOFCODE$
145
142
  DECLARE
146
- v_identifier_ids uuid[];
143
+ v_identifier_id uuid;
147
144
  BEGIN
148
- IF current_setting('jwt.claims.group_ids', TRUE)
145
+ IF current_setting('jwt.claims.database_id', TRUE)
149
146
  IS NOT NULL THEN
150
147
  BEGIN
151
- v_identifier_ids = current_setting('jwt.claims.group_ids', TRUE)::uuid[];
148
+ v_identifier_id = current_setting('jwt.claims.database_id', TRUE)::uuid;
152
149
  EXCEPTION
153
150
  WHEN OTHERS THEN
154
151
  RAISE NOTICE 'Invalid UUID value';
155
- RETURN ARRAY[]::uuid[];
152
+ RETURN NULL;
156
153
  END;
157
- RETURN v_identifier_ids;
154
+ RETURN v_identifier_id;
158
155
  ELSE
159
- RETURN ARRAY[]::uuid[];
156
+ RETURN NULL;
160
157
  END IF;
161
158
  END;
162
159
  $EOFCODE$ LANGUAGE plpgsql STABLE;
160
+
161
+ CREATE FUNCTION jwt_private.current_token_id() RETURNS uuid AS $EOFCODE$
162
+ SELECT nullif(current_setting('jwt.claims.token_id', true), '')::uuid;
163
+ $EOFCODE$ LANGUAGE sql STABLE;
@@ -1,8 +0,0 @@
1
- # launchql-jwt-claims extension
2
- comment = 'launchql-jwt-claims extension'
3
- default_version = '0.9.0'
4
- module_pathname = '$libdir/launchql-jwt-claims'
5
- requires = 'plpgsql,uuid-ossp,launchql-types,launchql-verify'
6
- relocatable = false
7
- superuser = false
8
-