@dhilipsiva/nf_ndc_connect_public 0.4.0 → 0.4.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.
@@ -5,8 +5,8 @@ export class IdpAuthHelper {
5
5
  free(): void;
6
6
  [Symbol.dispose](): void;
7
7
  getOrgAuthorisations(jwt: string): any;
8
- hasPermission(jwt: string, org_id: string, perm_name: string): boolean;
9
- hasRole(jwt: string, org_id: string, role_name: string): boolean;
8
+ hasPermission(jwt: string, org_id: string | null | undefined, perm_name: string): boolean;
9
+ hasRole(jwt: string, org_id: string | null | undefined, role_name: string): boolean;
10
10
  isValid(jwt: string): boolean;
11
11
  constructor(public_key_pem: string);
12
12
  }
@@ -17,8 +17,8 @@ export interface InitOutput {
17
17
  readonly memory: WebAssembly.Memory;
18
18
  readonly __wbg_idpauthhelper_free: (a: number, b: number) => void;
19
19
  readonly idpauthhelper_getOrgAuthorisations: (a: number, b: number, c: number) => [number, number, number];
20
- readonly idpauthhelper_hasPermission: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
21
- readonly idpauthhelper_hasRole: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
20
+ readonly idpauthhelper_hasPermission: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
21
+ readonly idpauthhelper_hasRole: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
22
22
  readonly idpauthhelper_isValid: (a: number, b: number, c: number) => number;
23
23
  readonly idpauthhelper_new: (a: number, b: number) => [number, number, number];
24
24
  readonly __wbindgen_malloc: (a: number, b: number) => number;
@@ -26,35 +26,41 @@ export class IdpAuthHelper {
26
26
  }
27
27
  /**
28
28
  * @param {string} jwt
29
- * @param {string} org_id
29
+ * @param {string | null | undefined} org_id
30
30
  * @param {string} perm_name
31
31
  * @returns {boolean}
32
32
  */
33
33
  hasPermission(jwt, org_id, perm_name) {
34
34
  const ptr0 = passStringToWasm0(jwt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
35
35
  const len0 = WASM_VECTOR_LEN;
36
- const ptr1 = passStringToWasm0(org_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
37
- const len1 = WASM_VECTOR_LEN;
36
+ var ptr1 = isLikeNone(org_id) ? 0 : passStringToWasm0(org_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
37
+ var len1 = WASM_VECTOR_LEN;
38
38
  const ptr2 = passStringToWasm0(perm_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
39
39
  const len2 = WASM_VECTOR_LEN;
40
40
  const ret = wasm.idpauthhelper_hasPermission(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
41
- return ret !== 0;
41
+ if (ret[2]) {
42
+ throw takeFromExternrefTable0(ret[1]);
43
+ }
44
+ return ret[0] !== 0;
42
45
  }
43
46
  /**
44
47
  * @param {string} jwt
45
- * @param {string} org_id
48
+ * @param {string | null | undefined} org_id
46
49
  * @param {string} role_name
47
50
  * @returns {boolean}
48
51
  */
49
52
  hasRole(jwt, org_id, role_name) {
50
53
  const ptr0 = passStringToWasm0(jwt, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
51
54
  const len0 = WASM_VECTOR_LEN;
52
- const ptr1 = passStringToWasm0(org_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
53
- const len1 = WASM_VECTOR_LEN;
55
+ var ptr1 = isLikeNone(org_id) ? 0 : passStringToWasm0(org_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
56
+ var len1 = WASM_VECTOR_LEN;
54
57
  const ptr2 = passStringToWasm0(role_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
55
58
  const len2 = WASM_VECTOR_LEN;
56
59
  const ret = wasm.idpauthhelper_hasRole(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
57
- return ret !== 0;
60
+ if (ret[2]) {
61
+ throw takeFromExternrefTable0(ret[1]);
62
+ }
63
+ return ret[0] !== 0;
58
64
  }
59
65
  /**
60
66
  * @param {string} jwt
@@ -168,6 +174,10 @@ function getUint8ArrayMemory0() {
168
174
  return cachedUint8ArrayMemory0;
169
175
  }
170
176
 
177
+ function isLikeNone(x) {
178
+ return x === undefined || x === null;
179
+ }
180
+
171
181
  function passStringToWasm0(arg, malloc, realloc) {
172
182
  if (realloc === undefined) {
173
183
  const buf = cachedTextEncoder.encode(arg);
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@dhilipsiva/nf_ndc_connect_public",
3
3
  "type": "module",
4
4
  "description": "Shared IDP Claims & Auth Logic for Rust, Python (Maturin), and Wasm (Wasm-Pack)",
5
- "version": "0.4.0",
5
+ "version": "0.4.1",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",