@pax2pay/model-banking 0.1.181 → 0.1.182

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/Identity.ts CHANGED
@@ -3,11 +3,11 @@ import { Key } from "./Key"
3
3
  import { Realm } from "./Realm"
4
4
 
5
5
  export class Identity {
6
- constructor(readonly key: Key) {}
6
+ constructor(readonly key: Key, readonly realm?: Realm, readonly organization?: string) {}
7
7
  check(constraint: Key.Permissions, realm?: Realm, organization?: string) {
8
8
  return [
9
- { [`${this.key.realm ?? realm}-${this.key.organization ?? organization}`]: constraint },
10
- { [`${this.key.realm ?? realm}-*`]: constraint },
9
+ { [`${realm ?? this.realm}-${organization ?? this.organization}`]: constraint },
10
+ { [`${realm ?? this.realm}-*`]: constraint },
11
11
  { [`*-*`]: constraint },
12
12
  ].some(e => userwidgets.User.Permissions.check(this.key.permissions, e))
13
13
  }
@@ -18,8 +18,10 @@ export class Identity {
18
18
  verifier: userwidgets.User.Key.Verifier<Key> = productionVerifier
19
19
  ): Promise<Identity | undefined> {
20
20
  const key: Key | undefined = await verifier.verify(header.authorization)
21
- const result = key && new Identity(key)
22
- return result?.check(constraint, header.realm, header.organization) ? result : undefined
21
+ const result =
22
+ key &&
23
+ new Identity(key, (key.realm ?? header.realm) as Realm, (key.organization ?? header.organization) as string)
24
+ return result?.check(constraint) ? result : undefined
23
25
  }
24
26
  }
25
27
  const publicKey =
@@ -3,7 +3,9 @@ import { Key } from "./Key";
3
3
  import { Realm } from "./Realm";
4
4
  export declare class Identity {
5
5
  readonly key: Key;
6
- constructor(key: Key);
6
+ readonly realm?: "eu" | "uk" | "test" | "testUK" | "upcheck" | undefined;
7
+ readonly organization?: string | undefined;
8
+ constructor(key: Key, realm?: "eu" | "uk" | "test" | "testUK" | "upcheck" | undefined, organization?: string | undefined);
7
9
  check(constraint: Key.Permissions, realm?: Realm, organization?: string): boolean;
8
10
  static authenticate(header: {
9
11
  authorization?: string | undefined;
package/dist/Identity.js CHANGED
@@ -1,19 +1,22 @@
1
1
  import { userwidgets } from "@userwidgets/model";
2
2
  export class Identity {
3
- constructor(key) {
3
+ constructor(key, realm, organization) {
4
4
  this.key = key;
5
+ this.realm = realm;
6
+ this.organization = organization;
5
7
  }
6
8
  check(constraint, realm, organization) {
7
9
  return [
8
- { [`${this.key.realm ?? realm}-${this.key.organization ?? organization}`]: constraint },
9
- { [`${this.key.realm ?? realm}-*`]: constraint },
10
+ { [`${realm ?? this.realm}-${organization ?? this.organization}`]: constraint },
11
+ { [`${realm ?? this.realm}-*`]: constraint },
10
12
  { [`*-*`]: constraint },
11
13
  ].some(e => userwidgets.User.Permissions.check(this.key.permissions, e));
12
14
  }
13
15
  static async authenticate(header, constraint, verifier = productionVerifier) {
14
16
  const key = await verifier.verify(header.authorization);
15
- const result = key && new Identity(key);
16
- return result?.check(constraint, header.realm, header.organization) ? result : undefined;
17
+ const result = key &&
18
+ new Identity(key, (key.realm ?? header.realm), (key.organization ?? header.organization));
19
+ return result?.check(constraint) ? result : undefined;
17
20
  }
18
21
  }
19
22
  const publicKey = "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtEHMQ+myaJa+0MvItYX936J78rgykGpMaf7qeQ+UENauyjzAJIPGyjMMim/t1cdnhf4a4i8v4EaQMyQXcOheIyZDs6ps7s5HDqvq9WrPVevP6N8QiFT1n5WKyMakzVtDSh6wva9PTihFoRQcZEvaio9fUXNLT0qxiB6bmwXMA+oGuVWCymqLcOY3ZLbKBYt1symO9YSpTR1jaUiGtzWtaYZ2QrWZ25LimhVkgv1ewgtMx9ybH/MiRvL29u8tttvVdFoAgABP+LHJrUQG0ykWopgNQHoWNUusqplSinHJy1avgG/xH2g8wiGR8byBsnEITq6qk3ShTV/pZfHo2ckvQzYaL17/sU4+G1lscJNoB0nQkwgTopCWbBHjxV9xNyM3CbQbdo113QcqXKlNWxeUUEVttIat+zZhcr43JZPvTfHxzLLVnsT7d9FTgsJpiolOirCJ4u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Q,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;QACxE,MAAM,MAAM,GACX,GAAG;YACH,IAAI,QAAQ,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,CAAU,EAAE,CAAC,GAAG,CAAC,YAAY,IAAI,MAAM,CAAC,YAAY,CAAW,CAAC,CAAA;QAC7G,OAAO,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;IACtD,CAAC;CACD;AACD,MAAM,SAAS,GACd,kuBAAkuB,CAAA;AACnuB,MAAM,kBAAkB,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAM,SAAS,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pax2pay/model-banking",
3
- "version": "0.1.181",
3
+ "version": "0.1.182",
4
4
  "description": "Library containing data model types and functions for the Pax2Pay Banking API.",
5
5
  "author": "Pax2Pay Ltd",
6
6
  "license": "MIT",