proto.io 0.0.139 → 0.0.141

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.
@@ -276,12 +276,9 @@ type ProtoFunctionOptions<E> = {
276
276
  validator?: Validator;
277
277
  };
278
278
 
279
- declare const session: <E>(proto: ProtoService<E>, request: Request) => Promise<{
280
- roles?: string[] | undefined;
281
- user?: TObjectType<"User", E> | undefined;
282
- sessionId: string | undefined;
283
- }>;
284
- type Session = Awaited<ReturnType<typeof session>>;
279
+ type Session = jwt.JwtPayload & {
280
+ sessionId: string;
281
+ };
285
282
 
286
283
  type TransactionMode = 'default' | 'committed' | 'repeatable' | 'serializable';
287
284
  type TransactionOptions = {
@@ -705,8 +702,20 @@ declare class ProtoService<Ext> extends ProtoType<Ext> {
705
702
  Query<T extends string>(className: T): TQuery<T, Ext, boolean, this>;
706
703
  InsecureQuery<T extends string>(className: T): TQuery<T, Ext, true, this>;
707
704
  get sessionId(): string | undefined;
708
- currentUser(): Promise<TUser | undefined>;
709
- currentRoles(): Promise<string[]>;
705
+ sessionInfo(): Promise<Session | {
706
+ roles?: string[] | undefined;
707
+ user?: TObjectType<"User", Ext> | undefined;
708
+ iss?: string | undefined;
709
+ sub?: string | undefined;
710
+ aud?: string | string[] | undefined;
711
+ exp?: number | undefined;
712
+ nbf?: number | undefined;
713
+ iat?: number | undefined;
714
+ jti?: string | undefined;
715
+ sessionId?: string | undefined;
716
+ } | undefined>;
717
+ currentUser(): Promise<any>;
718
+ currentRoles(): Promise<any>;
710
719
  get isMaster(): boolean;
711
720
  get isInvalidMasterToken(): boolean;
712
721
  connect<R extends Request, T extends object>(req: R, attrs?: T | ((x: this & {
@@ -771,4 +780,4 @@ declare class ProtoService<Ext> extends ProtoType<Ext> {
771
780
  }
772
781
 
773
782
  export { type TQueryRandomOptions as A, type TPubSub as B, type TFileInfo as C, type DeserializeOptions as D, type ExtraOptions as E, type FindOptions as F, type InsertOptions as I, ProtoService as P, QuerySelector as Q, type SerializeOptions as S, TSchema as T, type _TValue as _, type ProtoServiceOptions as a, type ProtoServiceKeyOptions as b, type TFileStorage as c, type TSerializable as d, deserialize as e, type TExtensions as f, TQuery as g, TObject as h, TUser as i, TRole as j, TFile as k, ProtoType as l, type ProtoInternalType as m, type TObjectType as n, type EventData as o, PVK as p, type DecodedQuery as q, type DecodedSortOption as r, serialize as s, type TValue as t, type FindOneOptions as u, type TUpdateOp as v, FieldSelectorExpression as w, QueryExpression as x, type TStorage as y, type TransactionOptions as z };
774
- //# sourceMappingURL=index-rcLPSrw6.d.ts.map
783
+ //# sourceMappingURL=index-BabXTvEZ.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BabXTvEZ.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { f as TExtensions, g as TQuery, h as TObject, i as TUser, j as TRole, k as TFile, l as ProtoType, E as ExtraOptions, S as SerializeOptions, m as ProtoInternalType, d as TSerializable, n as TObjectType, _ as _TValue, T as TSchema, o as EventData, p as PVK } from './index-rcLPSrw6.js';
1
+ import { f as TExtensions, g as TQuery, h as TObject, i as TUser, j as TRole, k as TFile, l as ProtoType, E as ExtraOptions, S as SerializeOptions, m as ProtoInternalType, d as TSerializable, n as TObjectType, _ as _TValue, T as TSchema, o as EventData, p as PVK } from './index-BabXTvEZ.js';
2
2
  import * as _o2ter_utils_js from '@o2ter/utils-js';
3
3
  import * as socket_io_client from 'socket.io-client';
4
4
  import { Socket } from 'socket.io-client';
@@ -57,6 +57,7 @@ declare class ProtoClientInternal<Ext, P extends ProtoType<any>> implements Prot
57
57
  constructor(options: ProtoOptions<Ext>);
58
58
  request(proto: P, data?: TSerializable, options?: Parameters<Service<Ext, P>['request']>[0]): Promise<TSerializable>;
59
59
  setSessionToken(proto: P, token?: string): void;
60
+ sessionInfo(proto: P, options?: RequestOptions<boolean, P>): Promise<TSerializable>;
60
61
  currentUser(proto: P, options?: RequestOptions<boolean, P>): Promise<TObjectType<'User', Ext> | undefined>;
61
62
  config(options?: RequestOptions<boolean, P>): Promise<Record<string, _TValue>>;
62
63
  configAcl(options: RequestOptions<boolean, P>): Promise<Record<string, string[]>>;
@@ -95,6 +96,7 @@ declare class ProtoClient<Ext> extends ProtoType<Ext> {
95
96
  }): Promise<void>;
96
97
  run(name: string, data?: TSerializable, options?: RequestOptions<boolean, this>): Promise<void | TSerializable>;
97
98
  setSessionToken(token?: string): void;
99
+ sessionInfo(options?: RequestOptions<boolean, this>): Promise<TSerializable>;
98
100
  currentUser(options?: RequestOptions<boolean, this>): Promise<TObjectType<"User", Ext> | undefined>;
99
101
  logout(options?: RequestOptions<boolean, this>): Promise<void>;
100
102
  setPassword(user: TUser, password: string, options: RequestOptions<true, this>): Promise<void>;
@@ -111,4 +113,4 @@ declare class ProtoClient<Ext> extends ProtoType<Ext> {
111
113
  }
112
114
 
113
115
  export { ProtoClient as P, isObject as a, isUser as b, classExtends as c, isRole as d, isFile as e, isQuery as i };
114
- //# sourceMappingURL=index-DRgmWum4.d.ts.map
116
+ //# sourceMappingURL=index-BtnEuEVn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BtnEuEVn.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1138,6 +1138,17 @@ class ProtoClientInternal {
1138
1138
  setSessionToken(proto, token) {
1139
1139
  this.service.setSessionToken(token);
1140
1140
  }
1141
+ async sessionInfo(proto, options) {
1142
+ const { serializeOpts, context, ...opts } = options ?? {};
1143
+ const res = await this.service.request({
1144
+ method: 'get',
1145
+ baseURL: this.options.endpoint,
1146
+ url: 'sessionInfo',
1147
+ responseType: 'text',
1148
+ ...opts,
1149
+ });
1150
+ return proto.rebind(deserialize(res.data));
1151
+ }
1141
1152
  async currentUser(proto, options) {
1142
1153
  const { serializeOpts, context, ...opts } = options ?? {};
1143
1154
  const res = await this.service.request({
@@ -1424,6 +1435,9 @@ class ProtoClient extends ProtoType {
1424
1435
  setSessionToken(token) {
1425
1436
  this[_private.PVK].setSessionToken(this, token);
1426
1437
  }
1438
+ sessionInfo(options) {
1439
+ return this[_private.PVK].sessionInfo(this, options);
1440
+ }
1427
1441
  currentUser(options) {
1428
1442
  return this[_private.PVK].currentUser(this, options);
1429
1443
  }
@@ -1466,4 +1480,4 @@ exports.isQuery = isQuery;
1466
1480
  exports.isRole = isRole;
1467
1481
  exports.isUser = isUser;
1468
1482
  exports.serialize = serialize;
1469
- //# sourceMappingURL=index-CTyYPai3.js.map
1483
+ //# sourceMappingURL=index-D5nf79vF.js.map