dep update
- typescript 5.9 업데이트: Uint8Array 문제 해결 - jest -> vitest (이후엔 그냥 node.test ?) - @trpc 준비 - node 24
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
"@strpc/def": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
"zod": "^3.22.4"
|
||||
"zod": "^4.1.12"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"zod": "^3.22.2"
|
||||
|
||||
+21
-21
@@ -21,31 +21,31 @@
|
||||
"@sammo/util": "workspace:^",
|
||||
"@strpc/client_ky": "workspace:^",
|
||||
"@strpc/def": "workspace:^",
|
||||
"bootstrap": "^5.3.3",
|
||||
"bootstrap-vue-next": "^0.16.6",
|
||||
"bson": "^6.4.0",
|
||||
"date-fns": "^3.3.1",
|
||||
"ky": "^1.2.2",
|
||||
"@trpc/client": "^11.6.0",
|
||||
"bootstrap": "^5.3.8",
|
||||
"bootstrap-vue-next": "^0.40.6",
|
||||
"bson": "^6.10.4",
|
||||
"date-fns": "^4.1.0",
|
||||
"ky": "^1.11.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"pinia": "^2.1.7",
|
||||
"vue": "^3.4.21",
|
||||
"vue-router": "^4.3.0"
|
||||
"pinia": "^3.0.3",
|
||||
"vue": "^3.5.22",
|
||||
"vue-router": "^4.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/node20": "^20.1.2",
|
||||
"@tsconfig/node22": "^22.0.2",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^20.11.24",
|
||||
"@vue/eslint-config-prettier": "^9.0.0",
|
||||
"@vue/eslint-config-typescript": "^12.0.0",
|
||||
"@vue/tsconfig": "^0.5.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-vue": "^9.22.0",
|
||||
"prettier": "^3.2.5",
|
||||
"ts-node": "^10.9.2",
|
||||
"tslib": "^2.6.2",
|
||||
"vite": "^5.1.5",
|
||||
"vue-tsc": "^2.0.5",
|
||||
"zod": "^3.22.4"
|
||||
"@types/node": "^24.7.0",
|
||||
"@vue/eslint-config-prettier": "^10.2.0",
|
||||
"@vue/eslint-config-typescript": "^14.6.0",
|
||||
"@vue/tsconfig": "^0.8.1",
|
||||
"eslint": "^9.37.0",
|
||||
"eslint-plugin-vue": "^10.5.0",
|
||||
"prettier": "^3.6.2",
|
||||
"tslib": "^2.8.1",
|
||||
"vite": "^7.1.9",
|
||||
"vue-tsc": "^3.1.1",
|
||||
"zod": "^4.1.12"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"zod": "^3.22.2"
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
||||
const jestConfig = {
|
||||
preset: 'ts-jest/presets/default-esm',
|
||||
extensionsToTreatAsEsm: ['.ts'],
|
||||
testEnvironment: 'node',
|
||||
rootDir: '.',
|
||||
transform: {
|
||||
'^.+\\.tsx?$': [
|
||||
'ts-jest',
|
||||
{
|
||||
useESM: true,
|
||||
tsconfig: 'tsconfig.jest.json',
|
||||
},
|
||||
],
|
||||
},
|
||||
moduleFileExtensions: [
|
||||
'js',
|
||||
'mjs',
|
||||
'ts',
|
||||
'mts',
|
||||
'tsx',
|
||||
'jsx',
|
||||
],
|
||||
moduleNameMapper: {
|
||||
'^(\\.{1,2}/.*)\\.js$': '$1',
|
||||
"^lodash-es$": "lodash",
|
||||
"^lodash-es/(.*)$": "<rootDir>/node_modules/lodash/$1",
|
||||
},
|
||||
modulePathIgnorePatterns: [
|
||||
'<rootDir>/dist/',
|
||||
],
|
||||
moduleDirectories: [
|
||||
"node_modules",
|
||||
".*/@sammo/util"
|
||||
],
|
||||
};
|
||||
|
||||
export default jestConfig
|
||||
+10
-13
@@ -16,29 +16,26 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --build",
|
||||
"test": "jest"
|
||||
"test": "vitest"
|
||||
},
|
||||
"author": "Hide_D <hided62@gmail.com>",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@sammo/util": "workspace:^"
|
||||
"@sammo/util": "workspace:^",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/lodash": "^4.14.202",
|
||||
"@types/lodash": "^4.17.20",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^20.11.24",
|
||||
"@typescript-eslint/eslint-plugin": "^7.1.1",
|
||||
"@typescript-eslint/parser": "^7.1.1",
|
||||
"bson": "^6.4.0",
|
||||
"@types/node": "^24.7.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.46.0",
|
||||
"@typescript-eslint/parser": "^8.46.0",
|
||||
"bson": "^6.10.4",
|
||||
"buffer": "^6.0.3",
|
||||
"eslint": "^8.57.0",
|
||||
"jest": "^29.7.0",
|
||||
"eslint": "^9.37.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"ts-jest": "^29.1.2",
|
||||
"tslib": "^2.6.2",
|
||||
"typescript": "^5.3.3"
|
||||
"tslib": "^2.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bson": "^5.4.0",
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { expect, test } from "vitest";
|
||||
import { AES_GCM_Decrypt, AES_GCM_Encrypt } from "./AES.js";
|
||||
|
||||
type TestType = {
|
||||
key: Buffer,
|
||||
IV: Buffer,
|
||||
PT: Buffer,
|
||||
AAD?: Buffer,
|
||||
CT: Buffer,
|
||||
key: Buffer<ArrayBuffer>,
|
||||
IV: Buffer<ArrayBuffer>,
|
||||
PT: Buffer<ArrayBuffer>,
|
||||
AAD?: Buffer<ArrayBuffer>,
|
||||
CT: Buffer<ArrayBuffer>,
|
||||
failed?: boolean,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import type { BufferSource } from "@sammo/util";
|
||||
|
||||
const subtle = globalThis.crypto.subtle;
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { expect, test } from "vitest";
|
||||
import { ECDSA_sign_bson, ECDSA_verify_bson } from "./ECDSA.js";
|
||||
import { genKey } from "./ECKey.js";
|
||||
import { randomBytes } from "./utils.js";
|
||||
|
||||
+39
-16
@@ -3,7 +3,6 @@ import { type Bsonifiable, bsonify, type Jsonifiable, jsonify } from "@sammo/uti
|
||||
import { importSignKey, importVerifyKey } from "./ECKey.js";
|
||||
import type { ECDSASignature, ECDSA_PKCS8_P384_SignKey, ECDSA_P384_VerifyKey, ECDSASignatureBSON, ECDSASignatureJSON, ECDSASignatureRaw } from "./RawTypes.js";
|
||||
import { isBufferSource } from './types.js';
|
||||
import { isArray, isDate, isObject } from "lodash-es";
|
||||
|
||||
// 간편하게 저장하기 위해서 그냥! 매번 복잡한 일을 하도록 하자
|
||||
const subtle = globalThis.crypto.subtle;
|
||||
@@ -13,35 +12,53 @@ const hashName: EcdsaParams = {
|
||||
hash: 'SHA-512'
|
||||
}
|
||||
|
||||
export async function ECDSA_sign(sign_key: ECDSA_PKCS8_P384_SignKey, msg: BufferSource): Promise<ECDSASignatureRaw> {
|
||||
export async function ECDSA_sign(sign_key: ECDSA_PKCS8_P384_SignKey, msg: BufferSource | Uint8Array): Promise<ECDSASignatureRaw> {
|
||||
const subtleSignKeyP = importSignKey(sign_key);
|
||||
if (msg instanceof Uint8Array){
|
||||
if(!(msg.buffer instanceof ArrayBuffer)){
|
||||
const nmsg = new Uint8Array(new ArrayBuffer(msg.length));
|
||||
nmsg.set(msg);
|
||||
return Buffer.from(await subtle.sign(hashName, await subtleSignKeyP, nmsg));
|
||||
}
|
||||
//XXX: 멍청한 TS 5.9 버그. 신 버전 나오면 Uint8Array 해결할 것
|
||||
return Buffer.from(await subtle.sign(hashName, await subtleSignKeyP, msg as Uint8Array<ArrayBuffer>));
|
||||
}
|
||||
return Buffer.from(await subtle.sign(hashName, await subtleSignKeyP, msg));
|
||||
}
|
||||
|
||||
|
||||
export async function ECDSA_sign_bson(sign_key: ECDSA_PKCS8_P384_SignKey, msg: Bsonifiable): Promise<ECDSASignatureBSON>
|
||||
export async function ECDSA_sign_bson(sign_key: ECDSA_PKCS8_P384_SignKey, msg: BufferSource): Promise<ECDSASignatureRaw>
|
||||
export async function ECDSA_sign_bson(sign_key: ECDSA_PKCS8_P384_SignKey, msg: Bsonifiable | BufferSource): Promise<ECDSASignatureRaw | ECDSASignatureBSON> {
|
||||
export async function ECDSA_sign_bson(sign_key: ECDSA_PKCS8_P384_SignKey, msg: BufferSource | Uint8Array): Promise<ECDSASignatureRaw>
|
||||
export async function ECDSA_sign_bson(sign_key: ECDSA_PKCS8_P384_SignKey, msg: Bsonifiable | BufferSource | Uint8Array): Promise<ECDSASignatureRaw | ECDSASignatureBSON> {
|
||||
if (!isBufferSource(msg)) {
|
||||
msg = BSON.serialize(bsonify(msg as Record<string, string>));
|
||||
return await ECDSA_sign(sign_key, msg) as ECDSASignatureBSON;
|
||||
const nmsg = BSON.serialize(bsonify(msg as Record<string, string>));
|
||||
return await ECDSA_sign(sign_key, nmsg) as ECDSASignatureBSON;
|
||||
}
|
||||
return ECDSA_sign(sign_key, msg);
|
||||
}
|
||||
|
||||
export async function ECDSA_sign_json(sign_key: ECDSA_PKCS8_P384_SignKey, msg: Bsonifiable): Promise<ECDSASignatureJSON>
|
||||
export async function ECDSA_sign_json(sign_key: ECDSA_PKCS8_P384_SignKey, msg: BufferSource): Promise<ECDSASignatureRaw>
|
||||
export async function ECDSA_sign_json(sign_key: ECDSA_PKCS8_P384_SignKey, msg: Jsonifiable | BufferSource): Promise<ECDSASignatureRaw | ECDSASignatureJSON> {
|
||||
export async function ECDSA_sign_json(sign_key: ECDSA_PKCS8_P384_SignKey, msg: BufferSource | Uint8Array): Promise<ECDSASignatureRaw>
|
||||
export async function ECDSA_sign_json(sign_key: ECDSA_PKCS8_P384_SignKey, msg: Jsonifiable | BufferSource | Uint8Array): Promise<ECDSASignatureRaw | ECDSASignatureJSON> {
|
||||
if (!isBufferSource(msg)) {
|
||||
msg = Buffer.from(JSON.stringify(jsonify(msg as Record<string, string>)), 'utf-8');
|
||||
return await ECDSA_sign(sign_key, msg) as ECDSASignatureJSON;
|
||||
const nmsg = Buffer.from(JSON.stringify(jsonify(msg as Record<string, string>)), 'utf-8') as Uint8Array<ArrayBuffer>;
|
||||
return await ECDSA_sign(sign_key, nmsg) as ECDSASignatureJSON;
|
||||
}
|
||||
return ECDSA_sign(sign_key, msg);
|
||||
}
|
||||
|
||||
export async function ECDSA_verify(verify_key: ECDSA_P384_VerifyKey, msg: BufferSource, sign: ECDSASignature): Promise<boolean> {
|
||||
export async function ECDSA_verify(verify_key: ECDSA_P384_VerifyKey, msg: BufferSource | Uint8Array, sign: ECDSASignature): Promise<boolean> {
|
||||
try {
|
||||
//XXX: 멍청한 TS 5.9 버그. 신 버전 나오면 Uint8Array 해결할 것
|
||||
const subtleVerifyKeyP = importVerifyKey(verify_key);
|
||||
if (msg instanceof Uint8Array){
|
||||
if(!(msg.buffer instanceof ArrayBuffer)){
|
||||
const nmsg = new Uint8Array(new ArrayBuffer(msg.length));
|
||||
nmsg.set(msg);
|
||||
return await subtle.verify(hashName, await subtleVerifyKeyP, sign, nmsg);
|
||||
}
|
||||
return await subtle.verify(hashName, await subtleVerifyKeyP, sign, msg as Uint8Array<ArrayBuffer>);
|
||||
}
|
||||
return await subtle.verify(hashName, await subtleVerifyKeyP, sign, msg);
|
||||
}
|
||||
catch (e) {
|
||||
@@ -50,10 +67,13 @@ export async function ECDSA_verify(verify_key: ECDSA_P384_VerifyKey, msg: Buffer
|
||||
}
|
||||
|
||||
export async function ECDSA_verify_bson(verify_key: ECDSA_P384_VerifyKey, msg: Bsonifiable, sign: ECDSASignatureBSON): Promise<boolean>;
|
||||
export async function ECDSA_verify_bson(verify_key: ECDSA_P384_VerifyKey, msg: BufferSource, sign: ECDSASignatureRaw): Promise<boolean>;
|
||||
export async function ECDSA_verify_bson(verify_key: ECDSA_P384_VerifyKey, msg: Bsonifiable | BufferSource, sign: ECDSASignatureBSON | ECDSASignatureRaw): Promise<boolean> {
|
||||
export async function ECDSA_verify_bson(verify_key: ECDSA_P384_VerifyKey, msg: BufferSource | Uint8Array, sign: ECDSASignatureRaw): Promise<boolean>;
|
||||
export async function ECDSA_verify_bson(verify_key: ECDSA_P384_VerifyKey, msg: Bsonifiable | BufferSource | Uint8Array, sign: ECDSASignatureBSON | ECDSASignatureRaw): Promise<boolean> {
|
||||
|
||||
try {
|
||||
if (msg instanceof Uint8Array){
|
||||
return ECDSA_verify(verify_key, msg, sign);
|
||||
}
|
||||
if (!isBufferSource(msg)) {
|
||||
msg = BSON.serialize(bsonify(msg as Record<string, string>));
|
||||
}
|
||||
@@ -65,13 +85,16 @@ export async function ECDSA_verify_bson(verify_key: ECDSA_P384_VerifyKey, msg: B
|
||||
}
|
||||
|
||||
export async function ECDSA_verify_json(verify_key: ECDSA_P384_VerifyKey, msg: Bsonifiable, sign: ECDSASignatureJSON): Promise<boolean>;
|
||||
export async function ECDSA_verify_json(verify_key: ECDSA_P384_VerifyKey, msg: BufferSource, sign: ECDSASignatureRaw): Promise<boolean>;
|
||||
export async function ECDSA_verify_json(verify_key: ECDSA_P384_VerifyKey, msg: Jsonifiable | BufferSource, sign: ECDSASignatureJSON | ECDSASignatureRaw): Promise<boolean> {
|
||||
export async function ECDSA_verify_json(verify_key: ECDSA_P384_VerifyKey, msg: BufferSource | Uint8Array, sign: ECDSASignatureRaw): Promise<boolean>;
|
||||
export async function ECDSA_verify_json(verify_key: ECDSA_P384_VerifyKey, msg: Jsonifiable | BufferSource | Uint8Array, sign: ECDSASignatureJSON | ECDSASignatureRaw): Promise<boolean> {
|
||||
|
||||
try {
|
||||
if (msg instanceof Uint8Array){
|
||||
return ECDSA_verify(verify_key, msg, sign);
|
||||
}
|
||||
if (!isBufferSource(msg)) {
|
||||
const x = JSON.stringify(jsonify(msg as Record<string, string>));
|
||||
msg = Buffer.from(x, 'utf-8');
|
||||
return ECDSA_verify(verify_key, Buffer.from(x, 'utf-8'), sign);
|
||||
}
|
||||
return ECDSA_verify(verify_key, msg, sign);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { expect, test } from "vitest";
|
||||
import { genKey, verifyKeyFromSignKey, pemFromVerifyKey, importVerifyKey, importSignKey, pemFromSignKey } from "./ECKey.js";
|
||||
import { TypeLength } from "./TypeLength.js";
|
||||
import { decodePEM } from "./utils.js";
|
||||
|
||||
@@ -80,7 +80,7 @@ export class LiteHashDRBG implements RNG {
|
||||
|
||||
protected buffer!: ArrayBuffer;
|
||||
protected bufferIdx!: number;
|
||||
protected hq: DataView;
|
||||
protected hq: DataView<ArrayBuffer>;
|
||||
protected hqIdxPos: number;
|
||||
|
||||
protected ready: Promise<void>;
|
||||
@@ -120,7 +120,7 @@ export class LiteHashDRBG implements RNG {
|
||||
return maxInt;
|
||||
}
|
||||
|
||||
public async nextBytes(bytes: number, baseBytes?: number): Promise<Uint8Array> {
|
||||
public async nextBytes(bytes: number, baseBytes?: number): Promise<Uint8Array<ArrayBuffer>> {
|
||||
bytes |= 0;
|
||||
if (bytes <= 0) {
|
||||
throw new Error(`${bytes} <= 0`);
|
||||
@@ -128,7 +128,7 @@ export class LiteHashDRBG implements RNG {
|
||||
|
||||
const ticket = this.ready;
|
||||
|
||||
let waiter: Promise<Uint8Array | undefined> = Promise.resolve(undefined);
|
||||
let waiter: Promise<Uint8Array<ArrayBuffer> | undefined> = Promise.resolve(undefined);
|
||||
|
||||
let nextBlockWait: (() => void) | null = (() => { throw 'something wrong'; });
|
||||
|
||||
@@ -194,10 +194,11 @@ export class LiteHashDRBG implements RNG {
|
||||
if (nextBlockWait) {
|
||||
nextBlockWait();
|
||||
}
|
||||
return nextBlock as Uint8Array;
|
||||
if(!nextBlock){ throw new Error("Internal error: nextBlock is undefined"); }
|
||||
return nextBlock;
|
||||
}
|
||||
|
||||
public async nextBits(bits: number, baseBytes?: number): Promise<Uint8Array> {
|
||||
public async nextBits(bits: number, baseBytes?: number): Promise<Uint8Array<ArrayBuffer>> {
|
||||
await this.ready;
|
||||
|
||||
bits |= 0;
|
||||
|
||||
@@ -5,8 +5,8 @@ export interface RNG {
|
||||
*/
|
||||
getMaxInt(): number;
|
||||
|
||||
nextBytes(bytes: number): Promise<Uint8Array>;
|
||||
nextBits(bits: number): Promise<Uint8Array>;
|
||||
nextBytes(bytes: number): Promise<Uint8Array<ArrayBuffer>>;
|
||||
nextBits(bits: number): Promise<Uint8Array<ArrayBuffer>>;
|
||||
|
||||
nextInt(max?: number): Promise<number>;
|
||||
nextFloat1(): Promise<number>;
|
||||
|
||||
@@ -24,8 +24,8 @@ export class RandUtil {
|
||||
}
|
||||
|
||||
public async nextBit(): Promise<boolean> {
|
||||
const view = new DataView(await this.rng.nextBits(1) as ArrayBufferLike);
|
||||
return view.getUint8(0) != 0;
|
||||
const view = await this.rng.nextBits(1);
|
||||
return view[0] != 0;
|
||||
}
|
||||
|
||||
public async nextBool(prob = 0.5): Promise<boolean> {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { expect, test } from "vitest";
|
||||
import { sha256, sha512 } from "./SHA2.js";
|
||||
|
||||
test('sha2', async () => {
|
||||
|
||||
@@ -1,19 +1,44 @@
|
||||
import { isBufferSource } from "./types.js";
|
||||
import { BSON } from "bson";
|
||||
import { type Bsonifiable, bsonify } from "@sammo/util";
|
||||
import { isArray, isDate, isObject } from "lodash-es";
|
||||
const subtle = globalThis.crypto.subtle;
|
||||
|
||||
export async function sha256(msg: Bsonifiable | BufferSource): Promise<ArrayBuffer> {
|
||||
export async function sha256(msg: Bsonifiable | BufferSource | Uint8Array): Promise<ArrayBuffer> {
|
||||
if (msg instanceof Uint8Array){
|
||||
if(!(msg.buffer instanceof ArrayBuffer)){
|
||||
const nmsg = new Uint8Array(new ArrayBuffer(msg.length));
|
||||
nmsg.set(msg);
|
||||
return await subtle.digest('SHA-256', nmsg);
|
||||
}
|
||||
//XXX: 멍청한 TS 5.9 버그. 신 버전 나오면 Uint8Array 해결할 것
|
||||
const nmsg = msg as Uint8Array<ArrayBuffer>;
|
||||
return await subtle.digest('SHA-256', nmsg);
|
||||
}
|
||||
if (!isBufferSource(msg)) {
|
||||
msg = BSON.serialize(bsonify(msg));
|
||||
//XXX: 멍청한 TS 5.9 버그. 신 버전 나오면 Uint8Array 해결할 것
|
||||
const nmsg = BSON.serialize(bsonify(msg)) as Uint8Array<ArrayBuffer>;
|
||||
if (!(nmsg.buffer instanceof ArrayBuffer)){ throw new Error("Internal error: BSON.serialize did not return ArrayBuffer"); }
|
||||
return await subtle.digest('SHA-256', nmsg);
|
||||
}
|
||||
return await subtle.digest('SHA-256', msg);
|
||||
}
|
||||
|
||||
export async function sha512(msg: Bsonifiable | BufferSource): Promise<ArrayBuffer> {
|
||||
export async function sha512(msg: Bsonifiable | BufferSource | Uint8Array): Promise<ArrayBuffer> {
|
||||
if (msg instanceof Uint8Array){
|
||||
if(!(msg.buffer instanceof ArrayBuffer)){
|
||||
const nmsg = new Uint8Array(new ArrayBuffer(msg.length));
|
||||
nmsg.set(msg);
|
||||
return await subtle.digest('SHA-512', nmsg);
|
||||
}
|
||||
//XXX: 멍청한 TS 5.9 버그. 신 버전 나오면 Uint8Array 해결할 것
|
||||
const nmsg = msg as Uint8Array<ArrayBuffer>;
|
||||
return await subtle.digest('SHA-512', nmsg);
|
||||
}
|
||||
if (!isBufferSource(msg)) {
|
||||
msg = BSON.serialize(bsonify(msg));
|
||||
//XXX: 멍청한 TS 5.9 버그. 신 버전 나오면 Uint8Array 해결할 것
|
||||
const nmsg = BSON.serialize(bsonify(msg)) as Uint8Array<ArrayBuffer>;
|
||||
if (!(nmsg.buffer instanceof ArrayBuffer)){ throw new Error("Internal error: BSON.serialize did not return ArrayBuffer"); }
|
||||
return await subtle.digest('SHA-512', nmsg);
|
||||
}
|
||||
return await subtle.digest('SHA-512', msg);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export class PrivilegedGenViolation extends RuntimeError {
|
||||
export type MergeableBuffer = MergeableBuffer[] | Buffer;
|
||||
|
||||
export function calcMergeableBuffer(item: MergeableBuffer): number {
|
||||
if (item instanceof Buffer) {
|
||||
if (item instanceof Uint8Array) {
|
||||
return item.byteLength;
|
||||
}
|
||||
let bufferSize = 0;
|
||||
@@ -57,7 +57,7 @@ export function mergeBuffer(...buffers: MergeableBuffer[]): Buffer {
|
||||
}
|
||||
|
||||
const fillBuffer = function (item: MergeableBuffer, bufferIdx: number): number {
|
||||
if (item instanceof Buffer) {
|
||||
if (item instanceof Uint8Array) {
|
||||
result.set(item, bufferIdx);
|
||||
bufferIdx += item.byteLength;
|
||||
return bufferIdx;
|
||||
|
||||
@@ -3,9 +3,6 @@ export function isBufferSource(obj: unknown): obj is BufferSource {
|
||||
if (obj instanceof ArrayBuffer){
|
||||
return true;
|
||||
}
|
||||
if('SharedArrayBuffer' in globalThis && obj instanceof SharedArrayBuffer){
|
||||
return true;
|
||||
}
|
||||
if (ArrayBuffer.isView(obj)){
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -41,12 +41,12 @@ type InferPEMBuffer<T extends PEMString<any, any>> = Exclude<undefined, T['_pem_
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function decodePEM<T extends PEMString<any, any>>(pem: T, pemType: InferPEMType<T>): InferPEMBuffer<T>[];
|
||||
export function decodePEM(pem: string, pemType?: ValidPEMType): Buffer[];
|
||||
export function decodePEM(pem: string, pemType?: ValidPEMType): Buffer[] {
|
||||
export function decodePEM(pem: string, pemType?: ValidPEMType): Buffer<ArrayBuffer>[];
|
||||
export function decodePEM(pem: string, pemType?: ValidPEMType): Buffer<ArrayBuffer>[] {
|
||||
const tag = pemType ?? "[A-Z0-9 ]+";
|
||||
const pattern = new RegExp(`-{5}BEGIN ${tag}-{5}([a-zA-Z0-9=+\\/\\n\\r]+)-{5}END ${tag}-{5}`, "g");
|
||||
|
||||
const res: Buffer[] = [];
|
||||
const res: Buffer<ArrayBuffer>[] = [];
|
||||
let matches: RegExpExecArray | null = null;
|
||||
// eslint-disable-next-line no-cond-assign
|
||||
while (matches = pattern.exec(pem)) {
|
||||
@@ -63,11 +63,11 @@ export function decodePEM(pem: string, pemType?: ValidPEMType): Buffer[] {
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function decodeSinglePEM<T extends PEMString<any, any>>(pem: T, pemType: InferPEMType<T>): InferPEMBuffer<T>;
|
||||
export function decodeSinglePEM(pem: string, pemType?: ValidPEMType): Buffer;
|
||||
export function decodeSinglePEM(pem: string, pemType?: ValidPEMType): Buffer {
|
||||
export function decodeSinglePEM(pem: string, pemType?: ValidPEMType): Buffer<ArrayBuffer>;
|
||||
export function decodeSinglePEM(pem: string, pemType?: ValidPEMType): Buffer<ArrayBuffer> {
|
||||
const res = decodePEM(pem, pemType);
|
||||
if (res.length != 1) {
|
||||
throw new Error("invalid pem");
|
||||
}
|
||||
return res[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"verbatimModuleSyntax": false,
|
||||
}
|
||||
}
|
||||
@@ -15,12 +15,12 @@
|
||||
"@sammo/server_util": "workspace:^",
|
||||
"@sammo/util": "workspace:^",
|
||||
"@strpc/express": "workspace:^",
|
||||
"date-fns": "^3.3.1",
|
||||
"dotenv": "^16.4.5",
|
||||
"mongoose": "^8.2.1",
|
||||
"zod": "^3.22.4"
|
||||
"date-fns": "^4.1.0",
|
||||
"dotenv": "^17.2.3",
|
||||
"mongoose": "^8.19.1",
|
||||
"zod": "^4.1.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.11.24"
|
||||
"@types/node": "^24.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,33 +20,30 @@
|
||||
"@sammo/util": "workspace:^",
|
||||
"@strpc/client_ky": "workspace:^",
|
||||
"@strpc/def": "workspace:^",
|
||||
"bootstrap": "^5.3.3",
|
||||
"bootstrap-vue-next": "^0.16.6",
|
||||
"bson": "^6.4.0",
|
||||
"date-fns": "^3.3.1",
|
||||
"ky": "^1.2.2",
|
||||
"@trpc/client": "^11.6.0",
|
||||
"bootstrap": "^5.3.8",
|
||||
"bootstrap-vue-next": "^0.40.6",
|
||||
"bson": "^6.10.4",
|
||||
"date-fns": "^4.1.0",
|
||||
"ky": "^1.11.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"pinia": "^2.1.7",
|
||||
"vue": "^3.4.21",
|
||||
"vue-router": "^4.3.0"
|
||||
"pinia": "^3.0.3",
|
||||
"vue": "^3.5.22",
|
||||
"vue-router": "^4.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/node20": "^20.1.2",
|
||||
"@tsconfig/node20": "^20.1.6",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^20.11.24",
|
||||
"@vue/eslint-config-prettier": "^9.0.0",
|
||||
"@vue/eslint-config-typescript": "^12.0.0",
|
||||
"@vue/tsconfig": "^0.5.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-vue": "^9.22.0",
|
||||
"prettier": "^3.2.5",
|
||||
"ts-node": "^10.9.2",
|
||||
"tslib": "^2.6.2",
|
||||
"vite": "^5.1.5",
|
||||
"vue-tsc": "^2.0.5",
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"zod": "^3.22.2"
|
||||
"@types/node": "^24.7.0",
|
||||
"@vue/eslint-config-prettier": "^10.2.0",
|
||||
"@vue/eslint-config-typescript": "^14.6.0",
|
||||
"@vue/tsconfig": "^0.8.1",
|
||||
"eslint": "^9.37.0",
|
||||
"eslint-plugin-vue": "^10.5.0",
|
||||
"prettier": "^3.6.2",
|
||||
"tslib": "^2.8.1",
|
||||
"vite": "^7.1.9",
|
||||
"vue-tsc": "^3.1.1",
|
||||
"zod": "^4.1.12"
|
||||
}
|
||||
}
|
||||
@@ -20,19 +20,21 @@
|
||||
"@sammo/server_util": "workspace:^",
|
||||
"@sammo/util": "workspace:^",
|
||||
"@strpc/express": "workspace:^",
|
||||
"date-fns": "^3.3.1",
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.18.3",
|
||||
"express-session": "^1.18.0",
|
||||
"@trpc/client": "^11.6.0",
|
||||
"@trpc/server": "^11.6.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"dotenv": "^17.2.3",
|
||||
"express": "^5.1.0",
|
||||
"express-session": "^1.18.2",
|
||||
"lodash-es": "^4.17.21",
|
||||
"mongoose": "^8.2.1",
|
||||
"reflect-metadata": "^0.2.1",
|
||||
"tslib": "^2.6.2",
|
||||
"zod": "^3.22.4"
|
||||
"mongoose": "^8.19.1",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"tslib": "^2.8.1",
|
||||
"zod": "^4.1.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.21",
|
||||
"@types/express-session": "^1.18.0",
|
||||
"@types/node": "^20.11.24"
|
||||
"@types/express": "^5.0.3",
|
||||
"@types/express-session": "^1.18.2",
|
||||
"@types/node": "^24.7.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
"@sammo/util": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bson": "^6.4.0",
|
||||
"bson": "^6.10.4",
|
||||
"buffer": "^6.0.3",
|
||||
"zod": "^3.22.4"
|
||||
"zod": "^4.1.12"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bson": "^5.4.0",
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
"@sammo/server_util": "workspace:^",
|
||||
"@sammo/util": "workspace:^",
|
||||
"@strpc/express": "workspace:^",
|
||||
"@trpc/client": "^11.6.0",
|
||||
"@trpc/server": "^11.6.0",
|
||||
"date-fns": "^3.3.1",
|
||||
"denque": "^2.1.0",
|
||||
"dotenv": "^16.4.5",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"@strpc/express": "workspace:^"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express-session": "^1.18.0",
|
||||
"@types/express-session": "^1.18.2",
|
||||
"lodash-es": "^4.17.21"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
"author": "Hide_D <hided62@gmail.com>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.11.24",
|
||||
"date-fns": "^3.3.1",
|
||||
"@types/node": "^24.7.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"lodash-es": "^4.17.21"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -5,7 +5,7 @@ type BsonifiableLite = string | number | boolean | bigint | null | undefined;
|
||||
|
||||
export type PlainBsonItem =
|
||||
string | number | boolean | null | undefined |
|
||||
Date | ArrayBuffer | SharedArrayBuffer | ArrayBufferView |
|
||||
Date | ArrayBuffer | ArrayBufferView |
|
||||
PlainBsonItem[] |
|
||||
{ [key: string]: PlainBsonItem };
|
||||
|
||||
@@ -14,7 +14,7 @@ export type PlainBson =
|
||||
|
||||
export type BsonifiableItem =
|
||||
BsonifiableLite |
|
||||
Date | ArrayBuffer | SharedArrayBuffer | ArrayBufferView |
|
||||
Date | ArrayBuffer | ArrayBufferView |
|
||||
Array<BsonifiableItem> |
|
||||
Map<BsonifiableLite, BsonifiableItem> |
|
||||
Set<BsonifiableLite> |
|
||||
|
||||
@@ -36,9 +36,6 @@ export function isBufferSource(obj: unknown): obj is BufferSource {
|
||||
if (obj instanceof ArrayBuffer){
|
||||
return true;
|
||||
}
|
||||
if('SharedArrayBuffer' in globalThis && obj instanceof SharedArrayBuffer){
|
||||
return true;
|
||||
}
|
||||
if (ArrayBuffer.isView(obj)){
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
|
||||
|
||||
/** Buffer이지만 ts에서 타입 구분 편의를 제공 */
|
||||
export interface WrappedBuffer extends Buffer {
|
||||
export interface WrappedBuffer extends Buffer<ArrayBuffer> {
|
||||
/** 타입구분자. 항상 undefined일 것이다 */
|
||||
_w_type?: string;
|
||||
}
|
||||
@@ -9,27 +7,27 @@ export interface WrappedBuffer extends Buffer {
|
||||
|
||||
/** ArrayBuffer,Uint8Array,Buffer를 WrappedBuffer로 변환
|
||||
*/
|
||||
export function wrapBuffer<T extends WrappedBuffer>(buffer: BufferSource): T {
|
||||
export function wrapBuffer<T extends WrappedBuffer>(buffer: BufferSource | Uint8Array): T {
|
||||
/**
|
||||
* Buffer라면 wrapBuffer없이 그대로 대입 가능
|
||||
* ArrayBuffer, Uint8Array 등이라면 Buffer.from을 사용 가능
|
||||
* DataView 등인 경우는 ArrayBufferView 활용
|
||||
* 그냥 써도 되지만, 위 방법보다 아무렇게나 쓰기 좋다는 장점은 있음
|
||||
*/
|
||||
if (buffer instanceof Buffer) {
|
||||
if (buffer instanceof Buffer && buffer.buffer instanceof ArrayBuffer) {
|
||||
return buffer as T;
|
||||
}
|
||||
if (buffer instanceof ArrayBuffer) {
|
||||
if (buffer instanceof Uint8Array) {
|
||||
return Buffer.from(buffer) as T;
|
||||
}
|
||||
if (buffer instanceof SharedArrayBuffer) {
|
||||
if (buffer instanceof ArrayBuffer) {
|
||||
return Buffer.from(buffer) as T;
|
||||
}
|
||||
return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength) as T;
|
||||
}
|
||||
|
||||
/** 호출할 필요 없이 바로 Buffer에 대입해도 되지만, 누군가 찾을 수 있어서. */
|
||||
export function unwrapBuffer<T extends WrappedBuffer>(buffer: T): Buffer {
|
||||
export function unwrapBuffer<T extends WrappedBuffer>(buffer: T): Buffer<ArrayBuffer> {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@@ -42,7 +40,7 @@ export type Base64String<T extends Buffer> = string & {
|
||||
_b_type?: T;
|
||||
}
|
||||
|
||||
export function base64FromWrappedBuffer<T extends WrappedBuffer>(buffer: T | ArrayBuffer | Uint8Array): Base64String<T> {
|
||||
export function base64FromWrappedBuffer<T extends WrappedBuffer>(buffer: T): Base64String<T> {
|
||||
return Buffer.from(buffer).toString('base64');
|
||||
}
|
||||
|
||||
|
||||
@@ -11,5 +11,4 @@ export type Entries<T> = {
|
||||
}[keyof T][];
|
||||
|
||||
|
||||
export type BufferSource = ArrayBufferView | ArrayBuffer | SharedArrayBuffer;
|
||||
export type BytesLike = BufferSource | string;
|
||||
|
||||
+13
-13
@@ -22,22 +22,22 @@
|
||||
"type-check:gateway_server": "pnpm --filter @sammo/gateway_server type-check",
|
||||
"type-check:gateway_client": "pnpm --filter @sammo/gateway_client type-check",
|
||||
"lint": "lint",
|
||||
"test": "jest"
|
||||
"test": "vitest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rushstack/eslint-patch": "^1.7.2",
|
||||
"@rushstack/eslint-patch": "^1.13.0",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^20.11.24",
|
||||
"@vitejs/plugin-vue": "^5.0.4",
|
||||
"@vue/eslint-config-prettier": "^9.0.0",
|
||||
"@vue/eslint-config-typescript": "^12.0.0",
|
||||
"@vue/tsconfig": "^0.5.1",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-vue": "^9.22.0",
|
||||
"@types/node": "^24.7.0",
|
||||
"@vitejs/plugin-vue": "^6.0.1",
|
||||
"@vue/eslint-config-prettier": "^10.2.0",
|
||||
"@vue/eslint-config-typescript": "^14.6.0",
|
||||
"@vue/tsconfig": "^0.8.1",
|
||||
"eslint": "^9.37.0",
|
||||
"eslint-plugin-vue": "^10.5.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^3.2.5",
|
||||
"tsx": "^4.7.1",
|
||||
"typescript": "~5.3.3"
|
||||
"prettier": "^3.6.2",
|
||||
"tsx": "^4.20.6",
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"packageManager": "pnpm@8.7.6"
|
||||
"packageManager": "pnpm@10.18.1"
|
||||
}
|
||||
|
||||
Generated
+4171
-4765
File diff suppressed because it is too large
Load Diff
+4
-1
@@ -1,4 +1,7 @@
|
||||
packages:
|
||||
- '@sammo/*'
|
||||
- '@strpc/*'
|
||||
- '!**/test/**'
|
||||
- '!**/test/**'
|
||||
|
||||
onlyBuiltDependencies:
|
||||
- unrs-resolver
|
||||
|
||||
+3
-7
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"module": "node16",
|
||||
"moduleResolution": "node16",
|
||||
"module": "nodenext",
|
||||
"moduleResolution": "nodenext",
|
||||
"resolveJsonModule": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
@@ -21,10 +21,6 @@
|
||||
"incremental": true,
|
||||
"sourceMap": true,
|
||||
"composite": true
|
||||
},
|
||||
"ts-node": {
|
||||
"esm": true,
|
||||
"experimentalSpecifierResolution": "node"
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user