@arkstack/common 0.20.1 → 0.21.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/dist/{helpers-Dq0l34ve.d.ts → helpers-CiymRnyw.d.ts} +8 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/{utils-DwfM0lt4.js → utils-B3uw4pWD.js} +17 -3
- package/package.json +4 -4
- package/dist/{dist-kNVDZ1C_.js → dist-kJyHYqUy.js} +1 -1
|
@@ -594,6 +594,14 @@ declare class Hash {
|
|
|
594
594
|
* @returns
|
|
595
595
|
*/
|
|
596
596
|
static otp(digits?: number, label?: string, period?: number): TOTP;
|
|
597
|
+
/**
|
|
598
|
+
* The OTP secret for a label, derived from the application key so codes
|
|
599
|
+
* differ per label and cannot be computed without the key.
|
|
600
|
+
*
|
|
601
|
+
* @param label
|
|
602
|
+
* @returns
|
|
603
|
+
*/
|
|
604
|
+
private static otpSecret;
|
|
597
605
|
static totp(secret: string, label: string, issuer?: string, period?: number): TOTP;
|
|
598
606
|
}
|
|
599
607
|
//#endregion
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference path="./app.d.ts" />
|
|
2
|
-
import { $ as HookPos, A as SealedBox, B as ConfigShape, C as Encryption, D as KeyPair, E as KeyInput, F as ArkstackErrorShape, G as EnvRegistry, H as DotPathValue, I as Choice, J as GlobalConfig, K as EnvReturn, L as Choices, M as SerializedKeyPair, N as AppConfig, O as Keys, P as ArkstackErrorPayload, Q as HookName, R as Concrete, S as DerivedKey, T as FingerprintOptions, U as EnvKey, V as DotPath, W as EnvLookup, X as HookArgs, Y as GlobalEnv, Z as HookFor, _ as ChannelOptions, a as abort, at as LoggerLog, b as Codec, c as getModel, ct as PaginationOptions, d as isClass, dt as PublishEntry, et as HookPositions, f as normalizePositiveInteger, ft as PublishFilter, g as Hash, h as setModelResolver, ht as Logger, i as ModelResolver, it as LoggerChalk, j as SecureChannel, k as NodeCipher, l as getModelSync, lt as Primitive, m as resolvePagination, mt as UnionToIntersection, n as ModelConstructor, nt as HookResult, o as abortIf, ot as LoggerParseSignature, p as perPage, pt as PublishGroup, q as FileImporter, r as ModelRegistry, rt as IHook, s as assertFound, st as MergedConfig, t as AbstractModelConstructor, tt as HookRegistry, u as initializeGlobalContext, ut as PublishConfirmation, v as Cipher, w as EncryptionKey, x as DeriveOptions, y as CipherOptions, z as ConfigRegistry } from "./helpers-
|
|
2
|
+
import { $ as HookPos, A as SealedBox, B as ConfigShape, C as Encryption, D as KeyPair, E as KeyInput, F as ArkstackErrorShape, G as EnvRegistry, H as DotPathValue, I as Choice, J as GlobalConfig, K as EnvReturn, L as Choices, M as SerializedKeyPair, N as AppConfig, O as Keys, P as ArkstackErrorPayload, Q as HookName, R as Concrete, S as DerivedKey, T as FingerprintOptions, U as EnvKey, V as DotPath, W as EnvLookup, X as HookArgs, Y as GlobalEnv, Z as HookFor, _ as ChannelOptions, a as abort, at as LoggerLog, b as Codec, c as getModel, ct as PaginationOptions, d as isClass, dt as PublishEntry, et as HookPositions, f as normalizePositiveInteger, ft as PublishFilter, g as Hash, h as setModelResolver, ht as Logger, i as ModelResolver, it as LoggerChalk, j as SecureChannel, k as NodeCipher, l as getModelSync, lt as Primitive, m as resolvePagination, mt as UnionToIntersection, n as ModelConstructor, nt as HookResult, o as abortIf, ot as LoggerParseSignature, p as perPage, pt as PublishGroup, q as FileImporter, r as ModelRegistry, rt as IHook, s as assertFound, st as MergedConfig, t as AbstractModelConstructor, tt as HookRegistry, u as initializeGlobalContext, ut as PublishConfirmation, v as Cipher, w as EncryptionKey, x as DeriveOptions, y as CipherOptions, z as ConfigRegistry } from "./helpers-CiymRnyw.js";
|
|
3
3
|
import { Hook } from "@arkstack/foundry";
|
|
4
4
|
import { Arkstack } from "@arkstack/contract";
|
|
5
5
|
import { ForkOptions } from "node:child_process";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as EnvLoader, a as env, c as nodeEnv, d as resolveRuntimeDir, f as resolveRuntimeModule, g as configLoader, h as ConfigLoader, i as discoverCommands, l as outputDir, m as CONFIG_KEY, n as appUrl, o as importFile, p as toOutputPath, r as config, s as interopDefault, t as appKey, u as rebuildOutput, v as envLoader } from "./system-DzAzwH__.js";
|
|
2
|
-
import { A as SecureChannel, C as Codec, D as Keys, E as KeyPair, O as NodeCipher, S as Cipher, T as EncryptionKey, _ as setModelResolver, b as Exception, c as abortIf, d as getModelSync, f as initializeGlobalContext, g as resolvePagination, h as perPage, k as SealedBox, l as assertFound, m as normalizePositiveInteger, p as isClass, s as abort, u as getModel, v as RequestException, w as Encryption, x as Hash, y as AppException } from "./utils-
|
|
2
|
+
import { A as SecureChannel, C as Codec, D as Keys, E as KeyPair, O as NodeCipher, S as Cipher, T as EncryptionKey, _ as setModelResolver, b as Exception, c as abortIf, d as getModelSync, f as initializeGlobalContext, g as resolvePagination, h as perPage, k as SealedBox, l as assertFound, m as normalizePositiveInteger, p as isClass, s as abort, u as getModel, v as RequestException, w as Encryption, x as Hash, y as AppException } from "./utils-B3uw4pWD.js";
|
|
3
3
|
import { Hook, Hook as Hook$1 } from "@arkstack/foundry";
|
|
4
4
|
import { Arkstack } from "@arkstack/contract";
|
|
5
5
|
import { str } from "@h3ravel/support";
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as SealedBox, C as Encryption, D as KeyPair, E as KeyInput, M as SerializedKeyPair, O as Keys, S as DerivedKey, T as FingerprintOptions, _ as ChannelOptions, a as abort, b as Codec, c as getModel, d as isClass, f as normalizePositiveInteger, g as Hash, h as setModelResolver, i as ModelResolver, j as SecureChannel, k as NodeCipher, l as getModelSync, m as resolvePagination, n as ModelConstructor, o as abortIf, p as perPage, r as ModelRegistry, s as assertFound, t as AbstractModelConstructor, u as initializeGlobalContext, v as Cipher, w as EncryptionKey, x as DeriveOptions, y as CipherOptions } from "../helpers-
|
|
1
|
+
import { A as SealedBox, C as Encryption, D as KeyPair, E as KeyInput, M as SerializedKeyPair, O as Keys, S as DerivedKey, T as FingerprintOptions, _ as ChannelOptions, a as abort, b as Codec, c as getModel, d as isClass, f as normalizePositiveInteger, g as Hash, h as setModelResolver, i as ModelResolver, j as SecureChannel, k as NodeCipher, l as getModelSync, m as resolvePagination, n as ModelConstructor, o as abortIf, p as perPage, r as ModelRegistry, s as assertFound, t as AbstractModelConstructor, u as initializeGlobalContext, v as Cipher, w as EncryptionKey, x as DeriveOptions, y as CipherOptions } from "../helpers-CiymRnyw.js";
|
|
2
2
|
import { Model } from "arkormx";
|
|
3
3
|
//#region src/utils/traits.d.ts
|
|
4
4
|
declare const crc32: (str: string) => number;
|
package/dist/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as SecureChannel, C as Codec, D as Keys, E as KeyPair, O as NodeCipher, S as Cipher, T as EncryptionKey, _ as setModelResolver, a as use, c as abortIf, d as getModelSync, f as initializeGlobalContext, g as resolvePagination, h as perPage, i as trait, k as SealedBox, l as assertFound, m as normalizePositiveInteger, n as crc32, o as uses, p as isClass, r as getTraitMethods, s as abort, t as callTraitMethods, u as getModel, w as Encryption, x as Hash } from "../utils-
|
|
1
|
+
import { A as SecureChannel, C as Codec, D as Keys, E as KeyPair, O as NodeCipher, S as Cipher, T as EncryptionKey, _ as setModelResolver, a as use, c as abortIf, d as getModelSync, f as initializeGlobalContext, g as resolvePagination, h as perPage, i as trait, k as SealedBox, l as assertFound, m as normalizePositiveInteger, n as crc32, o as uses, p as isClass, r as getTraitMethods, s as abort, t as callTraitMethods, u as getModel, w as Encryption, x as Hash } from "../utils-B3uw4pWD.js";
|
|
2
2
|
export { Cipher, Codec, Encryption, EncryptionKey, Hash, KeyPair, Keys, NodeCipher, SealedBox, SecureChannel, abort, abortIf, assertFound, callTraitMethods, crc32, getModel, getModelSync, getTraitMethods, initializeGlobalContext, isClass, normalizePositiveInteger, perPage, resolvePagination, setModelResolver, trait, use, uses };
|
|
@@ -3,6 +3,7 @@ import { Cipher, Codec, EncryptionKey, KeyPair, Keys, SealedBox, SecureChannel }
|
|
|
3
3
|
import { NodeCipher } from "@arkstack/encryption/node";
|
|
4
4
|
import { Secret, TOTP } from "otpauth";
|
|
5
5
|
import { compare, genSalt, hash } from "bcryptjs";
|
|
6
|
+
import { createHmac } from "node:crypto";
|
|
6
7
|
//#region src/utils/encryption.ts
|
|
7
8
|
/**
|
|
8
9
|
* Application facing encryption, bound to the app key.
|
|
@@ -199,7 +200,7 @@ var Encryption = class {
|
|
|
199
200
|
};
|
|
200
201
|
//#endregion
|
|
201
202
|
//#region src/utils/hash.ts
|
|
202
|
-
var Hash = class {
|
|
203
|
+
var Hash = class Hash {
|
|
203
204
|
/**
|
|
204
205
|
* Hash a value using bcrypt
|
|
205
206
|
*
|
|
@@ -235,9 +236,22 @@ var Hash = class {
|
|
|
235
236
|
issuer: env("APP_NAME", "Roseed"),
|
|
236
237
|
algorithm: "SHA1",
|
|
237
238
|
period,
|
|
238
|
-
secret:
|
|
239
|
+
secret: Hash.otpSecret(label)
|
|
239
240
|
});
|
|
240
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* The OTP secret for a label, derived from the application key so codes
|
|
244
|
+
* differ per label and cannot be computed without the key.
|
|
245
|
+
*
|
|
246
|
+
* @param label
|
|
247
|
+
* @returns
|
|
248
|
+
*/
|
|
249
|
+
static otpSecret(label) {
|
|
250
|
+
const key = appKey();
|
|
251
|
+
if (!key) throw new Error("APP_KEY is required to generate one-time passwords. Run `ark key:generate`.");
|
|
252
|
+
const digest = createHmac("sha256", key).update(`otp:${label}`).digest();
|
|
253
|
+
return new Secret({ buffer: new Uint8Array(digest).buffer });
|
|
254
|
+
}
|
|
241
255
|
static totp(secret, label, issuer = env("APP_NAME", "Roseed"), period = 30) {
|
|
242
256
|
return new TOTP({
|
|
243
257
|
issuer,
|
|
@@ -388,7 +402,7 @@ function getModelSync(modelName) {
|
|
|
388
402
|
}
|
|
389
403
|
const initializeGlobalContext = async ({ Request, Response, Session } = {}) => {
|
|
390
404
|
try {
|
|
391
|
-
const { Request: Req, Response: Res, Session: Ses } = await import("./dist-
|
|
405
|
+
const { Request: Req, Response: Res, Session: Ses } = await import("./dist-kJyHYqUy.js");
|
|
392
406
|
Session ??= new Ses();
|
|
393
407
|
Request ??= new Req();
|
|
394
408
|
Response ??= new Res();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/common",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core utilities, primitives, and shared infrastructure for the Arkstack ecosystem.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"otpauth": "^9.5.1",
|
|
44
44
|
"pino": "^10.3.1",
|
|
45
45
|
"selfsigned": "^2.4.1",
|
|
46
|
-
"@arkstack/encryption": "^0.
|
|
46
|
+
"@arkstack/encryption": "^0.21.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@h3ravel/support": "^2.2.7",
|
|
50
50
|
"arkormx": "^2.12.8",
|
|
51
|
-
"@arkstack/contract": "^0.
|
|
52
|
-
"@arkstack/foundry": "^0.
|
|
51
|
+
"@arkstack/contract": "^0.21.0",
|
|
52
|
+
"@arkstack/foundry": "^0.21.0"
|
|
53
53
|
},
|
|
54
54
|
"optionalDependencies": {
|
|
55
55
|
"@faker-js/faker": "^10.4.0"
|
|
@@ -4,8 +4,8 @@ import "@arkstack/contract";
|
|
|
4
4
|
import { isAbsolute, join, resolve } from "node:path";
|
|
5
5
|
import { pathToFileURL } from "node:url";
|
|
6
6
|
import { readdir, stat } from "node:fs/promises";
|
|
7
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
7
|
import "node:crypto";
|
|
8
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
9
|
//#region \0rolldown/runtime.js
|
|
10
10
|
var __create = Object.create;
|
|
11
11
|
var __defProp = Object.defineProperty;
|