@secrecy/lib 1.73.2 → 1.73.4
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.
|
@@ -45,10 +45,10 @@ export function getSecrecyClient(opts = {}) {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
export async function login({ appId, context, path, redirect, scopes, backPath, session, secrecyUrls, }) {
|
|
48
|
-
return await new Promise((resolve, reject) => {
|
|
48
|
+
return await new Promise(async (resolve, reject) => {
|
|
49
49
|
const appUrl = window.location.origin;
|
|
50
50
|
const client = getSecrecyClient({ secrecyUrls });
|
|
51
|
-
|
|
51
|
+
const innerLogin = () => {
|
|
52
52
|
const infos = {
|
|
53
53
|
appUrl,
|
|
54
54
|
appId,
|
|
@@ -102,8 +102,19 @@ export async function login({ appId, context, path, redirect, scopes, backPath,
|
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
+
};
|
|
106
|
+
if (client === null) {
|
|
107
|
+
innerLogin();
|
|
105
108
|
}
|
|
106
109
|
else {
|
|
110
|
+
if (context) {
|
|
111
|
+
const me = await client.me();
|
|
112
|
+
if ((context.userId && context.userId !== me.id) ||
|
|
113
|
+
(context.orgId && context.orgId !== me.organization.id)) {
|
|
114
|
+
innerLogin();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
107
118
|
resolve(client);
|
|
108
119
|
}
|
|
109
120
|
});
|
|
@@ -3,7 +3,7 @@ import { type SecrecyUserApp } from './types/index.js';
|
|
|
3
3
|
import type { SecrecyUrls } from '../base-client.js';
|
|
4
4
|
export declare function parseInfos(): SecrecyUserApp | null;
|
|
5
5
|
export interface HashInfos {
|
|
6
|
-
appId
|
|
6
|
+
appId?: string;
|
|
7
7
|
context?: {
|
|
8
8
|
userId?: string;
|
|
9
9
|
orgId?: string;
|
package/package.json
CHANGED