@armoury/fivem-framework-common 1.0.24 → 1.0.25

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.
@@ -2,11 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Session = void 0;
4
4
  class Session {
5
- constructor(id, platformId, lastKnownName, principal) {
5
+ constructor(id, platformId, lastKnownName, principal, claims = {}) {
6
6
  this.id = id;
7
7
  this.platformId = platformId;
8
8
  this.lastKnownName = lastKnownName;
9
9
  this.principal = principal;
10
+ this.claims = claims;
11
+ }
12
+ getClaimValue(claimName) {
13
+ var _a;
14
+ return (_a = this.claims[claimName]) !== null && _a !== void 0 ? _a : null;
15
+ }
16
+ setClaim(claimName, value) {
17
+ this.claims[claimName] = value;
18
+ return value;
10
19
  }
11
20
  }
12
21
  exports.Session = Session;
@@ -1,8 +1,17 @@
1
1
  export class Session {
2
- constructor(id, platformId, lastKnownName, principal) {
2
+ constructor(id, platformId, lastKnownName, principal, claims = {}) {
3
3
  this.id = id;
4
4
  this.platformId = platformId;
5
5
  this.lastKnownName = lastKnownName;
6
6
  this.principal = principal;
7
+ this.claims = claims;
8
+ }
9
+ getClaimValue(claimName) {
10
+ var _a;
11
+ return (_a = this.claims[claimName]) !== null && _a !== void 0 ? _a : null;
12
+ }
13
+ setClaim(claimName, value) {
14
+ this.claims[claimName] = value;
15
+ return value;
7
16
  }
8
17
  }
@@ -1,10 +1,12 @@
1
1
  import { Provider } from 'injection-js';
2
2
  export type ResourceExportsReader = (resourceName: string) => unknown;
3
- export declare class ResourceRef<T = Record<string, (...args: any[]) => any>> {
3
+ type ResourceExport = <T = any>(...args: any[]) => any;
4
+ export declare class ResourceRef<T = Record<string, ResourceExport>> {
4
5
  readonly resourceName: string;
5
6
  private readonly readExports;
6
7
  constructor(resourceName: string, readExports: ResourceExportsReader);
7
8
  get instance(): T;
8
9
  }
9
- export declare function Resource<T = Record<string, (...args: any[]) => any>>(resourceName: string): ParameterDecorator;
10
+ export declare function Resource<T = Record<string, ResourceExport>>(resourceName: string): ParameterDecorator;
10
11
  export declare function createResourceProviders(targets: Function[], readExports: ResourceExportsReader): Provider[];
12
+ export {};
@@ -3,11 +3,15 @@ export interface Session {
3
3
  readonly platformId: string;
4
4
  readonly lastKnownName: string;
5
5
  principal?: number;
6
+ readonly claims: Record<string, unknown>;
6
7
  }
7
8
  export declare class Session {
8
9
  readonly id: number;
9
10
  readonly platformId: string;
10
11
  readonly lastKnownName: string;
11
12
  principal?: number | undefined;
12
- constructor(id: number, platformId: string, lastKnownName: string, principal?: number | undefined);
13
+ readonly claims: Record<string, unknown>;
14
+ constructor(id: number, platformId: string, lastKnownName: string, principal?: number | undefined, claims?: Record<string, unknown>);
15
+ getClaimValue<T>(claimName: string): T | null;
16
+ setClaim<T>(claimName: string, value: T): T;
13
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@armoury/fivem-framework-common",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "description": "Shared APIs for the Armoury FiveM framework",
5
5
  "main": "dist/cjs/common/index.js",
6
6
  "module": "dist/esm/common/index.js",