@pgpm/jwt-claims 0.28.0 → 0.28.4
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/README.md +1 -16
- package/deploy/schemas/jwt_public/procedures/current_principal_id.sql +34 -0
- package/package.json +5 -5
- package/pgpm.plan +1 -0
- package/revert/schemas/jwt_public/procedures/current_principal_id.sql +7 -0
- package/verify/schemas/jwt_public/procedures/current_principal_id.sql +10 -0
package/README.md
CHANGED
|
@@ -306,7 +306,7 @@ pnpm test
|
|
|
306
306
|
|
|
307
307
|
## Related Tooling
|
|
308
308
|
|
|
309
|
-
* [pgpm](https://github.com/constructive-io/constructive/tree/main/pgpm/
|
|
309
|
+
* [pgpm](https://github.com/constructive-io/constructive/tree/main/pgpm/cli): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
|
|
310
310
|
* [pgsql-test](https://github.com/constructive-io/constructive/tree/main/postgres/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
|
|
311
311
|
* [supabase-test](https://github.com/constructive-io/constructive/tree/main/postgres/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
|
|
312
312
|
* [graphile-test](https://github.com/constructive-io/constructive/tree/main/graphile/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
|
|
@@ -314,21 +314,6 @@ pnpm test
|
|
|
314
314
|
* [libpg-query-node](https://github.com/constructive-io/libpg-query-node): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
|
|
315
315
|
* [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.
|
|
316
316
|
|
|
317
|
-
### 📚 Documentation & Skills
|
|
318
|
-
|
|
319
|
-
* [constructive-skills](https://github.com/constructive-io/constructive-skills): **📖 Platform documentation and AI agent skills** — feature catalog, blueprint reference, SDK guides, and deployment guides.
|
|
320
|
-
|
|
321
|
-
Install skills for AI coding agents:
|
|
322
|
-
|
|
323
|
-
```bash
|
|
324
|
-
# All platform skills (security, blueprints, codegen, billing, etc.)
|
|
325
|
-
npx skills add constructive-io/constructive-skills
|
|
326
|
-
|
|
327
|
-
# Individual repo skills (pgpm, testing, CLI, search, etc.)
|
|
328
|
-
npx skills add https://github.com/constructive-io/constructive --skill pgpm
|
|
329
|
-
npx skills add https://github.com/constructive-io/constructive --skill constructive-testing
|
|
330
|
-
```
|
|
331
|
-
|
|
332
317
|
## Disclaimer
|
|
333
318
|
|
|
334
319
|
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
-- Deploy schemas/jwt_public/procedures/current_principal_id to pg
|
|
2
|
+
-- Retrieves the current principal's ID from JWT claims with validation
|
|
3
|
+
|
|
4
|
+
-- requires: schemas/jwt_public/schema
|
|
5
|
+
|
|
6
|
+
BEGIN;
|
|
7
|
+
|
|
8
|
+
-- Returns the current principal's UUID from the JWT claims
|
|
9
|
+
-- Includes error handling for invalid UUID values
|
|
10
|
+
-- Returns NULL if the claim is not set or invalid
|
|
11
|
+
CREATE FUNCTION jwt_public.current_principal_id()
|
|
12
|
+
RETURNS uuid
|
|
13
|
+
AS $$
|
|
14
|
+
DECLARE
|
|
15
|
+
v_identifier_id uuid;
|
|
16
|
+
BEGIN
|
|
17
|
+
IF current_setting('jwt.claims.principal_id', TRUE)
|
|
18
|
+
IS NOT NULL THEN
|
|
19
|
+
BEGIN
|
|
20
|
+
v_identifier_id = current_setting('jwt.claims.principal_id', TRUE)::uuid;
|
|
21
|
+
EXCEPTION
|
|
22
|
+
WHEN OTHERS THEN
|
|
23
|
+
RAISE NOTICE 'Invalid UUID value';
|
|
24
|
+
RETURN NULL;
|
|
25
|
+
END;
|
|
26
|
+
RETURN v_identifier_id;
|
|
27
|
+
ELSE
|
|
28
|
+
RETURN NULL;
|
|
29
|
+
END IF;
|
|
30
|
+
END;
|
|
31
|
+
$$
|
|
32
|
+
LANGUAGE 'plpgsql' STABLE;
|
|
33
|
+
|
|
34
|
+
COMMIT;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpm/jwt-claims",
|
|
3
|
-
"version": "0.28.
|
|
3
|
+
"version": "0.28.4",
|
|
4
4
|
"description": "JWT claim handling and validation functions",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"test:watch": "jest --watch"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"pgpm": "^4.
|
|
24
|
+
"pgpm": "^4.28.7"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@pgpm/types": "0.28.
|
|
28
|
-
"@pgpm/verify": "0.28.
|
|
27
|
+
"@pgpm/types": "0.28.4",
|
|
28
|
+
"@pgpm/verify": "0.28.4"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/constructive-io/pgpm-modules/issues"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "08979b82f1f68af396b540c6ce0cda4b438d34f0"
|
|
39
39
|
}
|
package/pgpm.plan
CHANGED
|
@@ -13,6 +13,7 @@ schemas/jwt_public/procedures/current_user_id [schemas/jwt_public/schema] 2020-1
|
|
|
13
13
|
schemas/jwt_public/procedures/current_ip_address [schemas/jwt_public/schema] 2020-12-17T23:19:17Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/jwt_public/procedures/current_ip_address
|
|
14
14
|
schemas/jwt_public/procedures/current_user_agent [schemas/jwt_public/schema] 2020-12-17T23:20:04Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/jwt_public/procedures/current_user_agent
|
|
15
15
|
schemas/jwt_public/procedures/current_origin [schemas/jwt_public/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/jwt_public/procedures/current_origin
|
|
16
|
+
schemas/jwt_public/procedures/current_principal_id [schemas/jwt_public/schema] 2026-06-26T02:05:00Z Dan Lynch <dlynch@constructive.io> # add schemas/jwt_public/procedures/current_principal_id
|
|
16
17
|
schemas/jwt_private/schema 2020-12-17T06:47:34Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/jwt_private/schema
|
|
17
18
|
schemas/jwt_private/procedures/current_database_id [schemas/jwt_private/schema] 2020-12-17T23:22:28Z Dan Lynch <dlynch@Dans-MBP-3> # add schemas/jwt_private/procedures/current_database_id
|
|
18
19
|
schemas/jwt_private/procedures/current_token_id [schemas/jwt_private/schema] 2017-08-11T08:11:51Z skitch <skitch@5b0c196eeb62> # add schemas/jwt_private/procedures/current_token_id
|