cpace-ts 0.1.1 → 0.1.3

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 CHANGED
@@ -5,7 +5,7 @@
5
5
  [![types](https://img.shields.io/badge/types-.d.ts-blue.svg)](#)
6
6
  [![license](https://img.shields.io/badge/license-MIT-green.svg)](#)
7
7
 
8
- **What is it?** Minimal, audit-friendly implementation in strict accordance with version 15 of the [IETF draft](https://datatracker.ietf.org/doc/draft-irtf-cfrg-cpace/) CPace for TS
8
+ **What is it?** Minimal, audit-friendly implementation in strict accordance with version **18** of the [IETF draft](https://datatracker.ietf.org/doc/draft-irtf-cfrg-cpace/) CPace for TS
9
9
  **Why?** Clean API, strict validation, audit hooks, test-driven.
10
10
 
11
11
  ## Features
package/package.json CHANGED
@@ -1,59 +1,58 @@
1
1
  {
2
- "name": "cpace-ts",
3
- "version": "0.1.1",
4
- "description": "CPace for TypeScript",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/slava-nikulin/cpace-ts.git"
8
- },
9
- "license": "MIT",
10
- "keywords": [
11
- "cpace",
12
- "pake"
13
- ],
14
- "devDependencies": {
15
- "@biomejs/biome": "2.3.2",
16
- "@types/node": "^24.9.2",
17
- "@typescript-eslint/parser": "^8.46.2",
18
- "rimraf": "^6.1.0",
19
- "ts-node": "^10.9.2",
20
- "tsup": "^8.5.0",
21
- "typescript": "^5.9.3",
22
- "vitest": "^4.0.4"
23
- },
24
- "type": "module",
25
- "main": "./dist/index.cjs",
26
- "module": "./dist/index.js",
27
- "types": "./dist/index.d.ts",
28
- "exports": {
29
- ".": {
30
- "types": "./dist/index.d.ts",
31
- "import": "./dist/index.js",
32
- "require": "./dist/index.cjs"
33
- },
34
- "./wasm": {
35
- "types": "./wasm/pkg/cpace_wasm.d.ts",
36
- "import": "./wasm/pkg/cpace_wasm.js"
37
- }
38
- },
39
- "files": [
40
- "dist/**",
41
- "wasm/pkg/**",
42
- "README.md",
43
- "LICENSE"
44
- ],
45
- "scripts": {
46
- "prepack": "pnpm build",
47
- "build": "pnpm clean && pnpm build:wasm && tsup",
48
- "build:wasm": "wasm-pack build crates/cpace-wasm --target web --release --out-dir ../../wasm/pkg",
49
- "dev": "tsup --watch",
50
- "typecheck": "tsc -p tsconfig.json",
51
- "clean": "rimraf dist",
52
- "test:unit": "vitest run --project unit",
53
- "test:int": "vitest run --project integration",
54
- "test": "pnpm test:unit && pnpm test:int"
55
- },
56
- "dependencies": {
57
- "@noble/curves": "^2.0.1"
58
- }
59
- }
2
+ "name": "cpace-ts",
3
+ "version": "0.1.3",
4
+ "description": "CPace for TypeScript",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/slava-nikulin/cpace-ts.git"
8
+ },
9
+ "license": "MIT",
10
+ "keywords": [
11
+ "cpace",
12
+ "pake"
13
+ ],
14
+ "devDependencies": {
15
+ "@biomejs/biome": "2.3.2",
16
+ "@types/node": "^24.9.2",
17
+ "@typescript-eslint/parser": "^8.46.2",
18
+ "rimraf": "^6.1.0",
19
+ "ts-node": "^10.9.2",
20
+ "tsup": "^8.5.0",
21
+ "typescript": "^5.9.3",
22
+ "vitest": "^4.0.4"
23
+ },
24
+ "type": "module",
25
+ "main": "./dist/index.cjs",
26
+ "module": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js",
32
+ "require": "./dist/index.cjs"
33
+ },
34
+ "./wasm": {
35
+ "types": "./wasm/pkg/cpace_wasm.d.ts",
36
+ "import": "./wasm/pkg/cpace_wasm.js"
37
+ }
38
+ },
39
+ "files": [
40
+ "dist/**",
41
+ "wasm/pkg/**",
42
+ "README.md",
43
+ "LICENSE"
44
+ ],
45
+ "dependencies": {
46
+ "@noble/curves": "^2.0.1"
47
+ },
48
+ "scripts": {
49
+ "build": "pnpm clean && pnpm build:wasm && tsup",
50
+ "build:wasm": "wasm-pack build crates/cpace-wasm --target web --release --out-dir ../../wasm/pkg",
51
+ "dev": "tsup --watch",
52
+ "typecheck": "tsc -p tsconfig.json",
53
+ "clean": "rimraf dist",
54
+ "test:unit": "vitest run --project unit",
55
+ "test:int": "vitest run --project integration",
56
+ "test": "pnpm test:unit && pnpm test:int"
57
+ }
58
+ }
@@ -0,0 +1 @@
1
+ *
@@ -0,0 +1,38 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function elligator2_curve25519_u(rep: Uint8Array): Uint8Array;
5
+
6
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
7
+
8
+ export interface InitOutput {
9
+ readonly memory: WebAssembly.Memory;
10
+ readonly elligator2_curve25519_u: (a: number, b: number) => [number, number, number, number];
11
+ readonly __wbindgen_externrefs: WebAssembly.Table;
12
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
13
+ readonly __externref_table_dealloc: (a: number) => void;
14
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
15
+ readonly __wbindgen_start: () => void;
16
+ }
17
+
18
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
19
+
20
+ /**
21
+ * Instantiates the given `module`, which can either be bytes or
22
+ * a precompiled `WebAssembly.Module`.
23
+ *
24
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
25
+ *
26
+ * @returns {InitOutput}
27
+ */
28
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
29
+
30
+ /**
31
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
32
+ * for everything else, calls `WebAssembly.instantiate` directly.
33
+ *
34
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
35
+ *
36
+ * @returns {Promise<InitOutput>}
37
+ */
38
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,180 @@
1
+ /* @ts-self-types="./cpace_wasm.d.ts" */
2
+
3
+ /**
4
+ * @param {Uint8Array} rep
5
+ * @returns {Uint8Array}
6
+ */
7
+ export function elligator2_curve25519_u(rep) {
8
+ const ptr0 = passArray8ToWasm0(rep, wasm.__wbindgen_malloc);
9
+ const len0 = WASM_VECTOR_LEN;
10
+ const ret = wasm.elligator2_curve25519_u(ptr0, len0);
11
+ if (ret[3]) {
12
+ throw takeFromExternrefTable0(ret[2]);
13
+ }
14
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
15
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
16
+ return v2;
17
+ }
18
+
19
+ function __wbg_get_imports() {
20
+ const import0 = {
21
+ __proto__: null,
22
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
23
+ // Cast intrinsic for `Ref(String) -> Externref`.
24
+ const ret = getStringFromWasm0(arg0, arg1);
25
+ return ret;
26
+ },
27
+ __wbindgen_init_externref_table: function() {
28
+ const table = wasm.__wbindgen_externrefs;
29
+ const offset = table.grow(4);
30
+ table.set(0, undefined);
31
+ table.set(offset + 0, undefined);
32
+ table.set(offset + 1, null);
33
+ table.set(offset + 2, true);
34
+ table.set(offset + 3, false);
35
+ },
36
+ };
37
+ return {
38
+ __proto__: null,
39
+ "./cpace_wasm_bg.js": import0,
40
+ };
41
+ }
42
+
43
+ function getArrayU8FromWasm0(ptr, len) {
44
+ ptr = ptr >>> 0;
45
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
46
+ }
47
+
48
+ function getStringFromWasm0(ptr, len) {
49
+ ptr = ptr >>> 0;
50
+ return decodeText(ptr, len);
51
+ }
52
+
53
+ let cachedUint8ArrayMemory0 = null;
54
+ function getUint8ArrayMemory0() {
55
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
56
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
57
+ }
58
+ return cachedUint8ArrayMemory0;
59
+ }
60
+
61
+ function passArray8ToWasm0(arg, malloc) {
62
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
63
+ getUint8ArrayMemory0().set(arg, ptr / 1);
64
+ WASM_VECTOR_LEN = arg.length;
65
+ return ptr;
66
+ }
67
+
68
+ function takeFromExternrefTable0(idx) {
69
+ const value = wasm.__wbindgen_externrefs.get(idx);
70
+ wasm.__externref_table_dealloc(idx);
71
+ return value;
72
+ }
73
+
74
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
75
+ cachedTextDecoder.decode();
76
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
77
+ let numBytesDecoded = 0;
78
+ function decodeText(ptr, len) {
79
+ numBytesDecoded += len;
80
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
81
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
82
+ cachedTextDecoder.decode();
83
+ numBytesDecoded = len;
84
+ }
85
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
86
+ }
87
+
88
+ let WASM_VECTOR_LEN = 0;
89
+
90
+ let wasmModule, wasm;
91
+ function __wbg_finalize_init(instance, module) {
92
+ wasm = instance.exports;
93
+ wasmModule = module;
94
+ cachedUint8ArrayMemory0 = null;
95
+ wasm.__wbindgen_start();
96
+ return wasm;
97
+ }
98
+
99
+ async function __wbg_load(module, imports) {
100
+ if (typeof Response === 'function' && module instanceof Response) {
101
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
102
+ try {
103
+ return await WebAssembly.instantiateStreaming(module, imports);
104
+ } catch (e) {
105
+ const validResponse = module.ok && expectedResponseType(module.type);
106
+
107
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
108
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
109
+
110
+ } else { throw e; }
111
+ }
112
+ }
113
+
114
+ const bytes = await module.arrayBuffer();
115
+ return await WebAssembly.instantiate(bytes, imports);
116
+ } else {
117
+ const instance = await WebAssembly.instantiate(module, imports);
118
+
119
+ if (instance instanceof WebAssembly.Instance) {
120
+ return { instance, module };
121
+ } else {
122
+ return instance;
123
+ }
124
+ }
125
+
126
+ function expectedResponseType(type) {
127
+ switch (type) {
128
+ case 'basic': case 'cors': case 'default': return true;
129
+ }
130
+ return false;
131
+ }
132
+ }
133
+
134
+ function initSync(module) {
135
+ if (wasm !== undefined) return wasm;
136
+
137
+
138
+ if (module !== undefined) {
139
+ if (Object.getPrototypeOf(module) === Object.prototype) {
140
+ ({module} = module)
141
+ } else {
142
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
143
+ }
144
+ }
145
+
146
+ const imports = __wbg_get_imports();
147
+ if (!(module instanceof WebAssembly.Module)) {
148
+ module = new WebAssembly.Module(module);
149
+ }
150
+ const instance = new WebAssembly.Instance(module, imports);
151
+ return __wbg_finalize_init(instance, module);
152
+ }
153
+
154
+ async function __wbg_init(module_or_path) {
155
+ if (wasm !== undefined) return wasm;
156
+
157
+
158
+ if (module_or_path !== undefined) {
159
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
160
+ ({module_or_path} = module_or_path)
161
+ } else {
162
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
163
+ }
164
+ }
165
+
166
+ if (module_or_path === undefined) {
167
+ module_or_path = new URL('cpace_wasm_bg.wasm', import.meta.url);
168
+ }
169
+ const imports = __wbg_get_imports();
170
+
171
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
172
+ module_or_path = fetch(module_or_path);
173
+ }
174
+
175
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
176
+
177
+ return __wbg_finalize_init(instance, module);
178
+ }
179
+
180
+ export { initSync, __wbg_init as default };
Binary file
@@ -0,0 +1,9 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const elligator2_curve25519_u: (a: number, b: number) => [number, number, number, number];
5
+ export const __wbindgen_externrefs: WebAssembly.Table;
6
+ export const __wbindgen_malloc: (a: number, b: number) => number;
7
+ export const __externref_table_dealloc: (a: number) => void;
8
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
9
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "cpace-wasm",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "files": [
6
+ "cpace_wasm_bg.wasm",
7
+ "cpace_wasm.js",
8
+ "cpace_wasm.d.ts"
9
+ ],
10
+ "main": "cpace_wasm.js",
11
+ "types": "cpace_wasm.d.ts",
12
+ "sideEffects": [
13
+ "./snippets/*"
14
+ ]
15
+ }