@secrecy/lib 1.8.0 → 1.9.0
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/dist/lib/base-client.js +4 -3
- package/dist/lib/client/convert/node.js +5 -5
- package/dist/lib/client/index.js +3 -1
- package/dist/lib/client.js +1 -1
- package/dist/types/base-client.d.ts +2 -2
- package/dist/types/client.d.ts +565 -505
- package/dist/types/utils/promise.d.ts +1 -1
- package/package.json +27 -27
package/dist/lib/base-client.js
CHANGED
|
@@ -17,10 +17,11 @@ export class BaseClient {
|
|
|
17
17
|
static getBaseClient = (session, onAccessDenied) => createTRPCClient(session, onAccessDenied);
|
|
18
18
|
client;
|
|
19
19
|
sessionId;
|
|
20
|
-
constructor(session) {
|
|
20
|
+
constructor(session, onAccessDenied) {
|
|
21
21
|
this.sessionId = session;
|
|
22
|
-
this.client = BaseClient.getBaseClient(session, () => {
|
|
23
|
-
|
|
22
|
+
this.client = BaseClient.getBaseClient(session, async () => {
|
|
23
|
+
await onAccessDenied?.();
|
|
24
|
+
await this.logout();
|
|
24
25
|
location.reload();
|
|
25
26
|
});
|
|
26
27
|
}
|
|
@@ -10,10 +10,8 @@ export async function apiNodeToInternal(apiNode, keyPair) {
|
|
|
10
10
|
access: apiNode.access,
|
|
11
11
|
name: apiNode.name,
|
|
12
12
|
isFavorite: apiNode.isFavorite,
|
|
13
|
+
breadcrumb: 'breadcrumb' in apiNode ? apiNode.breadcrumb : [],
|
|
13
14
|
// TODO
|
|
14
|
-
// breadcrumb: apiNode.breadcrumb,
|
|
15
|
-
// createdBy: apiNode.createdBy.user,
|
|
16
|
-
breadcrumb: [],
|
|
17
15
|
createdBy: {
|
|
18
16
|
firstname: apiNode.createdBy.userId,
|
|
19
17
|
lastname: apiNode.createdBy.userId,
|
|
@@ -93,8 +91,10 @@ export function internalNodeFullToNodeFull(internal) {
|
|
|
93
91
|
};
|
|
94
92
|
}
|
|
95
93
|
export async function apiNodeToExternalNodeFull(apiNodeFull, keyPair) {
|
|
96
|
-
|
|
94
|
+
const apiNode = await apiNodeFullToInternalFull(apiNodeFull, keyPair);
|
|
95
|
+
return internalNodeFullToNodeFull(apiNode);
|
|
97
96
|
}
|
|
98
97
|
export async function apiNodeToExternal(apiNode, keyPair) {
|
|
99
|
-
|
|
98
|
+
const internal = await apiNodeToInternal(apiNode, keyPair);
|
|
99
|
+
return internalNodeToNode(internal);
|
|
100
100
|
}
|
package/dist/lib/client/index.js
CHANGED
|
@@ -26,7 +26,9 @@ export class SecrecyClient extends BaseClient {
|
|
|
26
26
|
pay;
|
|
27
27
|
user;
|
|
28
28
|
constructor(uaSession, uaKeys, uaJwt) {
|
|
29
|
-
super(uaSession)
|
|
29
|
+
super(uaSession, async () => {
|
|
30
|
+
await this.logout();
|
|
31
|
+
});
|
|
30
32
|
this.#keys = uaKeys;
|
|
31
33
|
this.care = new SecrecyCareClient(this, this.#keys, this.client);
|
|
32
34
|
this.cloud = new SecrecyCloudClient(this, this.#keys, this.client);
|
package/dist/lib/client.js
CHANGED
|
@@ -11,7 +11,7 @@ export const createTRPCClient = (session, onAccessDenied) => createTRPCProxyClie
|
|
|
11
11
|
if (op.direction === 'down' &&
|
|
12
12
|
isTRPCClientError(op.result) &&
|
|
13
13
|
op.result.data?.code === 'UNAUTHORIZED') {
|
|
14
|
-
onAccessDenied?.();
|
|
14
|
+
void onAccessDenied?.();
|
|
15
15
|
}
|
|
16
16
|
return (process.env.NODE_ENV === 'development' ||
|
|
17
17
|
(op.direction === 'down' && op.result instanceof Error));
|
|
@@ -3,10 +3,10 @@ import { type InfuraNetwork, type PublicUser } from './index.js';
|
|
|
3
3
|
import { type SelfUser } from './client/types/user.js';
|
|
4
4
|
export declare class BaseClient {
|
|
5
5
|
#private;
|
|
6
|
-
static readonly getBaseClient: (session?: string | null | undefined, onAccessDenied?: () => void) => ApiClient;
|
|
6
|
+
static readonly getBaseClient: (session?: string | null | undefined, onAccessDenied?: () => void | Promise<void>) => ApiClient;
|
|
7
7
|
protected client: ApiClient;
|
|
8
8
|
sessionId: string;
|
|
9
|
-
constructor(session: string);
|
|
9
|
+
constructor(session: string, onAccessDenied?: () => void | Promise<void>);
|
|
10
10
|
logout(sessionId?: string | null | undefined): Promise<void>;
|
|
11
11
|
me(): Promise<SelfUser>;
|
|
12
12
|
static getUser(userId: string, sessionId?: string | null | undefined): Promise<PublicUser>;
|