@pgpm/totp 0.6.0 → 0.7.1
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/Makefile +1 -1
- package/README.md +31 -150
- package/launchql-totp.control +1 -1
- package/package.json +10 -4
- /package/sql/{launchql-totp--0.5.0.sql → launchql-totp--0.6.0.sql} +0 -0
package/Makefile
CHANGED
package/README.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @pgpm/totp
|
|
2
2
|
|
|
3
|
+
<p align="center" width="100%">
|
|
4
|
+
<img height="250" src="https://raw.githubusercontent.com/launchql/launchql/refs/heads/main/assets/outline-logo.svg" />
|
|
5
|
+
</p>
|
|
6
|
+
|
|
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" />
|
|
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/totp"><img height="20" src="https://img.shields.io/github/package-json/v/launchql/pgpm-modules?filename=packages%2Fsecurity%2Ftotp%2Fpackage.json"/></a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
3
15
|
TOTP implementation in pure PostgreSQL plpgsql
|
|
4
16
|
|
|
5
17
|
This extension provides the HMAC Time-Based One-Time Password Algorithm (TOTP) as specified in RFC 4226 as pure plpgsql functions.
|
|
@@ -32,40 +44,42 @@ This is a quick way to get started. The sections below provide more detailed ins
|
|
|
32
44
|
### Prerequisites
|
|
33
45
|
|
|
34
46
|
```bash
|
|
35
|
-
# Install pgpm
|
|
47
|
+
# Install pgpm CLI
|
|
36
48
|
npm install -g pgpm
|
|
37
49
|
|
|
38
|
-
# Start
|
|
50
|
+
# Start local Postgres (via Docker) and export env vars
|
|
39
51
|
pgpm docker start
|
|
40
|
-
|
|
41
|
-
# Set environment variables
|
|
42
52
|
eval "$(pgpm env)"
|
|
43
53
|
```
|
|
44
54
|
|
|
45
|
-
|
|
55
|
+
> **Tip:** Already running Postgres? Skip the Docker step and just export your `PG*` environment variables.
|
|
46
56
|
|
|
47
|
-
|
|
57
|
+
### **Add to an Existing Package**
|
|
48
58
|
|
|
49
59
|
```bash
|
|
60
|
+
# 1. Install the package
|
|
50
61
|
pgpm install @pgpm/totp
|
|
51
|
-
|
|
62
|
+
|
|
63
|
+
# 2. Deploy locally
|
|
64
|
+
pgpm deploy
|
|
52
65
|
```
|
|
53
66
|
|
|
54
|
-
|
|
67
|
+
### **Add to a New Project**
|
|
55
68
|
|
|
56
69
|
```bash
|
|
57
|
-
|
|
58
|
-
pgpm
|
|
59
|
-
|
|
70
|
+
# 1. Create a workspace
|
|
71
|
+
pgpm init --workspace
|
|
72
|
+
cd my-app
|
|
60
73
|
|
|
61
|
-
|
|
74
|
+
# 2. Create your first module
|
|
75
|
+
pgpm init
|
|
76
|
+
cd packages/your-module
|
|
62
77
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
pnpm install
|
|
78
|
+
# 3. Install a package
|
|
79
|
+
pgpm install @pgpm/totp
|
|
66
80
|
|
|
67
|
-
# Deploy
|
|
68
|
-
pgpm deploy
|
|
81
|
+
# 4. Deploy everything
|
|
82
|
+
pgpm deploy --createdb --database mydb1
|
|
69
83
|
```
|
|
70
84
|
|
|
71
85
|
## Usage
|
|
@@ -241,139 +255,6 @@ https://gist.github.com/bwbroersma/676d0de32263ed554584ab132434ebd9
|
|
|
241
255
|
|
|
242
256
|
---
|
|
243
257
|
|
|
244
|
-
## Development
|
|
245
|
-
|
|
246
|
-
## start the postgres db process
|
|
247
|
-
|
|
248
|
-
First you'll want to start the postgres docker (you can also just use `docker-compose up -d`):
|
|
249
|
-
|
|
250
|
-
```sh
|
|
251
|
-
make up
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
## install modules
|
|
255
|
-
|
|
256
|
-
Install modules
|
|
257
|
-
|
|
258
|
-
```sh
|
|
259
|
-
yarn install
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
## install the Postgres extensions
|
|
263
|
-
|
|
264
|
-
Now that the postgres process is running, install the extensions:
|
|
265
|
-
|
|
266
|
-
```sh
|
|
267
|
-
make install
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
This basically `ssh`s into the postgres instance with the `packages/` folder mounted as a volume, and installs the bundled sql code as pgxn extensions.
|
|
271
|
-
|
|
272
|
-
## testing
|
|
273
|
-
|
|
274
|
-
Testing will load all your latest sql changes and create fresh, populated databases for each sqitch module in `packages/`.
|
|
275
|
-
|
|
276
|
-
```sh
|
|
277
|
-
yarn test:watch
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
## building new modules
|
|
281
|
-
|
|
282
|
-
Create a new folder in `packages/`
|
|
283
|
-
|
|
284
|
-
```sh
|
|
285
|
-
pgpm init
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
Then, run a generator:
|
|
289
|
-
|
|
290
|
-
```sh
|
|
291
|
-
pgpm generate
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
You can also add arguments if you already know what you want to do:
|
|
295
|
-
|
|
296
|
-
```sh
|
|
297
|
-
pgpm generate schema --schema myschema
|
|
298
|
-
pgpm generate table --schema myschema --table mytable
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
## deploy code as extensions
|
|
302
|
-
|
|
303
|
-
`cd` into `packages/<module>`, and run `pgpm package`. This will make an sql file in `packages/<module>/sql/` used for `CREATE EXTENSION` calls to install your sqitch module as an extension.
|
|
304
|
-
|
|
305
|
-
## recursive deploy
|
|
306
|
-
|
|
307
|
-
You can also deploy all modules utilizing versioning as sqtich modules. Remove `--createdb` if you already created your db:
|
|
308
|
-
|
|
309
|
-
```sh
|
|
310
|
-
pgpm deploy mydb1 --yes --createdb
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
---
|
|
314
|
-
|
|
315
|
-
### **Before You Begin**
|
|
316
|
-
|
|
317
|
-
```bash
|
|
318
|
-
# 1. Install pgpm
|
|
319
|
-
npm install -g pgpm
|
|
320
|
-
|
|
321
|
-
# 2. Start Postgres (Docker or local)
|
|
322
|
-
pgpm docker start
|
|
323
|
-
|
|
324
|
-
# 3. Load PG* environment variables (PGHOST, PGUSER, ...)
|
|
325
|
-
eval "$(pgpm env)"
|
|
326
|
-
```
|
|
327
|
-
|
|
328
|
-
---
|
|
329
|
-
|
|
330
|
-
### **Starting a New Project**
|
|
331
|
-
|
|
332
|
-
```bash
|
|
333
|
-
# 1. Create a workspace
|
|
334
|
-
pgpm init --workspace
|
|
335
|
-
cd my-app
|
|
336
|
-
|
|
337
|
-
# 2. Create your first module
|
|
338
|
-
pgpm init
|
|
339
|
-
|
|
340
|
-
# 3. Add a migration
|
|
341
|
-
pgpm add some_change
|
|
342
|
-
|
|
343
|
-
# 4. Deploy (auto-creates database)
|
|
344
|
-
pgpm deploy --createdb
|
|
345
|
-
```
|
|
346
|
-
|
|
347
|
-
---
|
|
348
|
-
|
|
349
|
-
### **Working With an Existing Project**
|
|
350
|
-
|
|
351
|
-
```bash
|
|
352
|
-
# 1. Clone and enter the project
|
|
353
|
-
git clone <repo> && cd <project>
|
|
354
|
-
|
|
355
|
-
# 2. Install dependencies
|
|
356
|
-
pnpm install
|
|
357
|
-
|
|
358
|
-
# 3. Deploy locally
|
|
359
|
-
pgpm deploy --createdb
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
---
|
|
363
|
-
|
|
364
|
-
### **Testing a Module Inside a Workspace**
|
|
365
|
-
|
|
366
|
-
```bash
|
|
367
|
-
# 1. Install workspace deps
|
|
368
|
-
pnpm install
|
|
369
|
-
|
|
370
|
-
# 2. Enter the module directory
|
|
371
|
-
cd packages/<some-module>
|
|
372
|
-
|
|
373
|
-
# 3. Run tests in watch mode
|
|
374
|
-
pnpm test:watch
|
|
375
|
-
```
|
|
376
|
-
|
|
377
258
|
## Related Tooling
|
|
378
259
|
|
|
379
260
|
* [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.
|
package/launchql-totp.control
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgpm/totp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Time-based One-Time Password (TOTP) authentication",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"postgresql",
|
|
7
|
+
"pgpm",
|
|
8
|
+
"totp",
|
|
9
|
+
"2fa"
|
|
10
|
+
],
|
|
5
11
|
"publishConfig": {
|
|
6
12
|
"access": "public"
|
|
7
13
|
},
|
|
@@ -11,8 +17,8 @@
|
|
|
11
17
|
"test:watch": "jest --watch"
|
|
12
18
|
},
|
|
13
19
|
"dependencies": {
|
|
14
|
-
"@pgpm/base32": "0.
|
|
15
|
-
"@pgpm/verify": "0.
|
|
20
|
+
"@pgpm/base32": "0.7.1",
|
|
21
|
+
"@pgpm/verify": "0.7.1"
|
|
16
22
|
},
|
|
17
23
|
"devDependencies": {
|
|
18
24
|
"pgpm": "^0.2.0"
|
|
@@ -25,5 +31,5 @@
|
|
|
25
31
|
"bugs": {
|
|
26
32
|
"url": "https://github.com/launchql/pgpm-modules/issues"
|
|
27
33
|
},
|
|
28
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "f3156553b409bd27b66ac03562151d439d779f53"
|
|
29
35
|
}
|
|
File without changes
|