@pax2pay/model-banking 0.1.181 → 0.1.183

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/Client/index.ts CHANGED
@@ -25,10 +25,11 @@ export class Client extends rest.Client<gracely.Error> {
25
25
  readonly transactions = new Transactions(this.client)
26
26
  readonly treasury = new Treasury(this.client)
27
27
  readonly flags = new Flags(this.client)
28
- readonly userwidgets = new userwidgets.ClientCollection(this.client, { pathPrefix: "/widgets" })
28
+ readonly userwidgets = (server: string, application: string) =>
29
+ new userwidgets.ClientCollection(new http.Client(server), { application })
29
30
  readonly version = new Version(this.client)
30
31
 
31
- static create<T = Record<string, any>>(server: string, key: string, load?: (client: http.Client) => T): Client & T {
32
+ static create<T = Record<string, any>>(server: string, key?: string, load?: (client: http.Client) => T): Client & T {
32
33
  let httpClient: http.Client<gracely.Error>
33
34
  const result: Client = new Client(
34
35
  (httpClient = new http.Client<gracely.Error>(server, key, {
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 =
@@ -24,9 +24,9 @@ export declare class Client extends rest.Client<gracely.Error> {
24
24
  readonly transactions: Transactions;
25
25
  readonly treasury: Treasury;
26
26
  readonly flags: Flags;
27
- readonly userwidgets: userwidgets.ClientCollection;
27
+ readonly userwidgets: (server: string, application: string) => userwidgets.ClientCollection;
28
28
  readonly version: Version;
29
- static create<T = Record<string, any>>(server: string, key: string, load?: (client: http.Client) => T): Client & T;
29
+ static create<T = Record<string, any>>(server: string, key?: string, load?: (client: http.Client) => T): Client & T;
30
30
  }
31
31
  export declare namespace Client {
32
32
  type Unauthorized = (client: rest.Client<never>) => Promise<boolean>;
@@ -23,7 +23,7 @@ export class Client extends rest.Client {
23
23
  this.transactions = new Transactions(this.client);
24
24
  this.treasury = new Treasury(this.client);
25
25
  this.flags = new Flags(this.client);
26
- this.userwidgets = new userwidgets.ClientCollection(this.client, { pathPrefix: "/widgets" });
26
+ this.userwidgets = (server, application) => new userwidgets.ClientCollection(new http.Client(server), { application });
27
27
  this.version = new Version(this.client);
28
28
  }
29
29
  static create(server, key, load) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"../","sources":["Client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EA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,CAAC,CACH,CAAA;QACD,IAAI,IAAI;YACP,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;QACxC,OAAO,MAAoB,CAAA;IAC5B,CAAC;CACD"}
@@ -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+zZhcr43JZPvTfHxzLLVnsT7d9FTgsJpiolOirCJ4uW4YUKmngTNWV1dkjhe5cFAX346YcwdO0oDUcWdiGg1zD739HDsMZy9s8CPcRWHZlYntVfELqoILlaO3GEaGaY3dEV2TgWOwYwIWgTTfXWC+LO+ybxafb/DyHKmPZMhox2mITuodigNtRrfhLk2xVYQjeBpQd++nbChj2GLeGCOaLAqq2ZpVOEMgG9jHpUiGeqhk81D4YCRJvy0ubRVg/oqrfUTQtnFiURQy4UCAwEAAQ==";
@@ -1 +1 @@
1
- {"version":3,"file":"Identity.js","sourceRoot":"../","sources":["Identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAIhD,MAAM,OAAO,QAAQ;IACpB,YAAqB,GAAQ;QAAR,QAAG,GAAH,GAAG,CAAK;IAAG,CAAC;IACjC,KAAK,CAAC,UAA2B,EAAE,KAAa,EAAE,YAAqB;QACtE,OAAO;YACN,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,YAAY,IAAI,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE;YACvF,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG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AC,KAAK,IAAI,YAAY,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC,EAAE,UAAU,EAAE;YAC/E,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,EAAE,UAAU,EAAE;YAC5C,EAAE,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE;SACvB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAA;IACzE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,YAAY,CACxB,MAAoF,EACpF,UAA2B,EAC3B,WAA+C,kBAAkB;QAEjE,MAAM,GAAG,GAAoB,MAAM,QAAQ,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.183",
4
4
  "description": "Library containing data model types and functions for the Pax2Pay Banking API.",
5
5
  "author": "Pax2Pay Ltd",
6
6
  "license": "MIT",
@@ -70,7 +70,7 @@
70
70
  "typescript": "^5.2.2"
71
71
  },
72
72
  "dependencies": {
73
- "@userwidgets/model": "0.8.12",
73
+ "@userwidgets/model": "0.8.15",
74
74
  "authly": "^3.0.11",
75
75
  "cloudly-http": "^0.1.6",
76
76
  "cloudly-rest": "^0.1.3",