@newgameplusinc/odyssey-sso 1.0.2 → 2.0.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/config.d.ts +27 -0
- package/dist/config.js +31 -0
- package/dist/{lib/database.d.ts → database.d.ts} +1 -1
- package/dist/{lib/database.js → database.js} +4 -2
- package/dist/main.d.ts +249 -0
- package/dist/main.js +948 -0
- package/dist/types.d.ts +466 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +1 -0
- package/package.json +7 -10
- package/README.md +0 -3
- package/dist/config/index.d.ts +0 -7
- package/dist/config/index.js +0 -7
- package/dist/index.d.ts +0 -27
- package/dist/index.js +0 -158
- package/dist/lib/axios.d.ts +0 -6
- package/dist/lib/axios.js +0 -20
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Database from "./database";
|
|
2
|
+
export declare const db: Database;
|
|
3
|
+
export declare const ssoClientUrl = "https://odyssey-sso-client.vercel.app";
|
|
4
|
+
export declare const ssoServerUrl = "https://api-gateway.tenant-newgame.ord1.ingress.coreweave.cloud/sso/api/v1";
|
|
5
|
+
export declare const actions: {
|
|
6
|
+
login: "login";
|
|
7
|
+
logout: "logout";
|
|
8
|
+
refresh: "refresh";
|
|
9
|
+
profile_fetch: "profile.fetch";
|
|
10
|
+
profile_update: "profile.update";
|
|
11
|
+
profile_photo_update: "profile-photo.update";
|
|
12
|
+
cloth_add: "cloth.add";
|
|
13
|
+
cloth_fetch_all: "cloth.fetch-all";
|
|
14
|
+
cloth_fetch: "cloth.fetch";
|
|
15
|
+
cloth_update: "cloth.update";
|
|
16
|
+
cloth_delete: "cloth.delete";
|
|
17
|
+
material_add: "material.add";
|
|
18
|
+
material_fetch_all: "material.fetch-all";
|
|
19
|
+
material_fetch: "material.fetch";
|
|
20
|
+
material_update: "material.update";
|
|
21
|
+
material_delete: "material.delete";
|
|
22
|
+
skull_add: "skull.add";
|
|
23
|
+
skull_update: "skull.update";
|
|
24
|
+
skull_fetch_all: "skull.fetch-all";
|
|
25
|
+
skull_fetch: "skull.fetch";
|
|
26
|
+
skull_delete: "skull.delete";
|
|
27
|
+
};
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Database from "./database";
|
|
2
|
+
export const db = new Database({
|
|
3
|
+
dbName: "sso-sdk",
|
|
4
|
+
dbVersion: 1,
|
|
5
|
+
storeName: "credentials",
|
|
6
|
+
});
|
|
7
|
+
export const ssoClientUrl = "https://odyssey-sso-client.vercel.app";
|
|
8
|
+
export const ssoServerUrl = "https://api-gateway.tenant-newgame.ord1.ingress.coreweave.cloud/sso/api/v1";
|
|
9
|
+
export const actions = {
|
|
10
|
+
login: "login",
|
|
11
|
+
logout: "logout",
|
|
12
|
+
refresh: "refresh",
|
|
13
|
+
profile_fetch: "profile.fetch",
|
|
14
|
+
profile_update: "profile.update",
|
|
15
|
+
profile_photo_update: "profile-photo.update",
|
|
16
|
+
cloth_add: "cloth.add",
|
|
17
|
+
cloth_fetch_all: "cloth.fetch-all",
|
|
18
|
+
cloth_fetch: "cloth.fetch",
|
|
19
|
+
cloth_update: "cloth.update",
|
|
20
|
+
cloth_delete: "cloth.delete",
|
|
21
|
+
material_add: "material.add",
|
|
22
|
+
material_fetch_all: "material.fetch-all",
|
|
23
|
+
material_fetch: "material.fetch",
|
|
24
|
+
material_update: "material.update",
|
|
25
|
+
material_delete: "material.delete",
|
|
26
|
+
skull_add: "skull.add",
|
|
27
|
+
skull_update: "skull.update",
|
|
28
|
+
skull_fetch_all: "skull.fetch-all",
|
|
29
|
+
skull_fetch: "skull.fetch",
|
|
30
|
+
skull_delete: "skull.delete",
|
|
31
|
+
};
|
|
@@ -10,7 +10,7 @@ export default class Database {
|
|
|
10
10
|
id: string;
|
|
11
11
|
[key: string]: any;
|
|
12
12
|
}) => Promise<unknown>;
|
|
13
|
-
getById: (id: string) => Promise<
|
|
13
|
+
getById: <T = unknown>(id: string) => Promise<T | null>;
|
|
14
14
|
getAll: () => Promise<unknown>;
|
|
15
15
|
update: (id: string, updates: Partial<Record<string, any>>) => Promise<unknown>;
|
|
16
16
|
delete: (id: string) => Promise<unknown>;
|
|
@@ -15,6 +15,7 @@ export default class Database {
|
|
|
15
15
|
request.onsuccess = () => resolve(request.result);
|
|
16
16
|
});
|
|
17
17
|
};
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
19
|
this.create = async (user) => {
|
|
19
20
|
const db = await this.open();
|
|
20
21
|
return new Promise((resolve, reject) => {
|
|
@@ -30,8 +31,8 @@ export default class Database {
|
|
|
30
31
|
return new Promise((resolve, reject) => {
|
|
31
32
|
const tx = db.transaction(this.config.storeName, "readonly");
|
|
32
33
|
const store = tx.objectStore(this.config.storeName);
|
|
33
|
-
const request = store.get(id);
|
|
34
|
-
request.onsuccess = () => resolve(request.result
|
|
34
|
+
const request = store.get(id) ?? null;
|
|
35
|
+
request.onsuccess = () => resolve(request.result);
|
|
35
36
|
request.onerror = () => reject(request.error);
|
|
36
37
|
});
|
|
37
38
|
};
|
|
@@ -45,6 +46,7 @@ export default class Database {
|
|
|
45
46
|
request.onerror = () => reject(request.error);
|
|
46
47
|
});
|
|
47
48
|
};
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
50
|
this.update = async (id, updates) => {
|
|
49
51
|
const db = await this.open();
|
|
50
52
|
return new Promise((resolve, reject) => {
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { AddClothFilePayload, AddMaterialFilePayload, AddSkullFilePayload, Cb, Config, GetClothsOptions, GetMaterialsOptions, UpdateClothPayload, UpdateMaterialPayload, UpdateProfilePayload, UpdateSkullPayload } from "./types";
|
|
2
|
+
export type { Profile } from "./types";
|
|
3
|
+
export default class SSO {
|
|
4
|
+
private readonly config;
|
|
5
|
+
private readonly db;
|
|
6
|
+
private readonly ssoClientUrl;
|
|
7
|
+
private readonly ssoServerUrl;
|
|
8
|
+
private readonly dbId;
|
|
9
|
+
private cb;
|
|
10
|
+
constructor(config: Config);
|
|
11
|
+
readonly login: (redirectUrl: string) => Promise<void>;
|
|
12
|
+
readonly exchange: () => Promise<{
|
|
13
|
+
tokens: {
|
|
14
|
+
accessToken: string;
|
|
15
|
+
refreshToken: string;
|
|
16
|
+
};
|
|
17
|
+
id: string;
|
|
18
|
+
firstName: string;
|
|
19
|
+
lastName: string;
|
|
20
|
+
email: string;
|
|
21
|
+
photoURL: null;
|
|
22
|
+
pending: boolean;
|
|
23
|
+
anonymous: boolean;
|
|
24
|
+
bodyHeight: null;
|
|
25
|
+
bodyShape: null;
|
|
26
|
+
clothingIdBottom: null;
|
|
27
|
+
clothingIdShoes: null;
|
|
28
|
+
clothingIdTop: null;
|
|
29
|
+
clothingIdMaterial: null;
|
|
30
|
+
skullId: null;
|
|
31
|
+
additionalInfo: null;
|
|
32
|
+
skull: null;
|
|
33
|
+
clothingTop: null;
|
|
34
|
+
clothingBottom: null;
|
|
35
|
+
clothingShoes: null;
|
|
36
|
+
clothingMaterial: null;
|
|
37
|
+
deviceId: string;
|
|
38
|
+
} | undefined>;
|
|
39
|
+
readonly fetchProfile: () => Promise<{
|
|
40
|
+
id: string;
|
|
41
|
+
firstName: string;
|
|
42
|
+
lastName: string;
|
|
43
|
+
email: string;
|
|
44
|
+
photoURL: null;
|
|
45
|
+
pending: boolean;
|
|
46
|
+
anonymous: boolean;
|
|
47
|
+
bodyHeight: null;
|
|
48
|
+
bodyShape: null;
|
|
49
|
+
clothingIdBottom: null;
|
|
50
|
+
clothingIdShoes: null;
|
|
51
|
+
clothingIdTop: null;
|
|
52
|
+
clothingIdMaterial: null;
|
|
53
|
+
skullId: null;
|
|
54
|
+
additionalInfo: null;
|
|
55
|
+
skull: null;
|
|
56
|
+
clothingTop: null;
|
|
57
|
+
clothingBottom: null;
|
|
58
|
+
clothingShoes: null;
|
|
59
|
+
clothingMaterial: null;
|
|
60
|
+
deviceId: string;
|
|
61
|
+
} | undefined>;
|
|
62
|
+
readonly refresh: () => Promise<{
|
|
63
|
+
accessToken: string;
|
|
64
|
+
refreshToken: string;
|
|
65
|
+
} | undefined>;
|
|
66
|
+
readonly logout: () => Promise<true | undefined>;
|
|
67
|
+
readonly onEvents: (cb: Cb) => void;
|
|
68
|
+
private readonly withRefresh;
|
|
69
|
+
readonly profileUpdate: (payload: UpdateProfilePayload) => Promise<{
|
|
70
|
+
id: string;
|
|
71
|
+
firstName: string;
|
|
72
|
+
lastName: string;
|
|
73
|
+
email: string;
|
|
74
|
+
photoURL: null;
|
|
75
|
+
pending: boolean;
|
|
76
|
+
anonymous: boolean;
|
|
77
|
+
bodyHeight: null;
|
|
78
|
+
bodyShape: null;
|
|
79
|
+
clothingIdBottom: null;
|
|
80
|
+
clothingIdShoes: null;
|
|
81
|
+
clothingIdTop: null;
|
|
82
|
+
clothingIdMaterial: null;
|
|
83
|
+
skullId: null;
|
|
84
|
+
additionalInfo: null;
|
|
85
|
+
skull: null;
|
|
86
|
+
clothingTop: null;
|
|
87
|
+
clothingBottom: null;
|
|
88
|
+
clothingShoes: null;
|
|
89
|
+
clothingMaterial: null;
|
|
90
|
+
deviceId: string;
|
|
91
|
+
} | undefined>;
|
|
92
|
+
readonly avatarUpdate: (file: File) => Promise<{
|
|
93
|
+
id: string;
|
|
94
|
+
firstName: string;
|
|
95
|
+
lastName: string;
|
|
96
|
+
email: string;
|
|
97
|
+
photoURL: string;
|
|
98
|
+
pending: boolean;
|
|
99
|
+
anonymous: boolean;
|
|
100
|
+
} | undefined>;
|
|
101
|
+
private readonly fileUpload;
|
|
102
|
+
readonly clothAdd: (payload: AddClothFilePayload) => Promise<{
|
|
103
|
+
id: string;
|
|
104
|
+
ownerId: string;
|
|
105
|
+
sdkKeyId: null;
|
|
106
|
+
name: string;
|
|
107
|
+
bodyDefinition: string;
|
|
108
|
+
description: string;
|
|
109
|
+
public: boolean;
|
|
110
|
+
thumb: string;
|
|
111
|
+
type: string;
|
|
112
|
+
updatedAt: Date;
|
|
113
|
+
createdAt: Date;
|
|
114
|
+
} | undefined>;
|
|
115
|
+
readonly clothGetAll: (options?: GetClothsOptions) => Promise<{
|
|
116
|
+
id: string;
|
|
117
|
+
ownerId: string;
|
|
118
|
+
sdkKeyId: null;
|
|
119
|
+
name: string;
|
|
120
|
+
bodyDefinition: string;
|
|
121
|
+
description: string;
|
|
122
|
+
public: boolean;
|
|
123
|
+
thumb: string;
|
|
124
|
+
type: string;
|
|
125
|
+
updatedAt: Date;
|
|
126
|
+
createdAt: Date;
|
|
127
|
+
}[] | undefined>;
|
|
128
|
+
readonly clothGetById: (clothId: string) => Promise<{
|
|
129
|
+
id: string;
|
|
130
|
+
ownerId: string;
|
|
131
|
+
sdkKeyId: null;
|
|
132
|
+
name: string;
|
|
133
|
+
bodyDefinition: string;
|
|
134
|
+
description: string;
|
|
135
|
+
public: boolean;
|
|
136
|
+
thumb: string;
|
|
137
|
+
type: string;
|
|
138
|
+
updatedAt: Date;
|
|
139
|
+
createdAt: Date;
|
|
140
|
+
} | undefined>;
|
|
141
|
+
readonly clothUpdate: (clothId: string, payload: UpdateClothPayload) => Promise<{
|
|
142
|
+
id: string;
|
|
143
|
+
ownerId: string;
|
|
144
|
+
sdkKeyId: null;
|
|
145
|
+
name: string;
|
|
146
|
+
bodyDefinition: string;
|
|
147
|
+
description: string;
|
|
148
|
+
public: boolean;
|
|
149
|
+
thumb: string;
|
|
150
|
+
type: string;
|
|
151
|
+
updatedAt: Date;
|
|
152
|
+
createdAt: Date;
|
|
153
|
+
} | undefined>;
|
|
154
|
+
readonly clothDelete: (clothId: string) => Promise<string | undefined>;
|
|
155
|
+
readonly materialAdd: (payload: AddMaterialFilePayload) => Promise<{
|
|
156
|
+
id: string;
|
|
157
|
+
ownerId: string;
|
|
158
|
+
sdkKeyId: null;
|
|
159
|
+
name: string;
|
|
160
|
+
description: string;
|
|
161
|
+
public: boolean;
|
|
162
|
+
thumb: string;
|
|
163
|
+
type: string;
|
|
164
|
+
updatedAt: Date;
|
|
165
|
+
createdAt: Date;
|
|
166
|
+
} | undefined>;
|
|
167
|
+
readonly materialGetAll: (options?: GetMaterialsOptions) => Promise<{
|
|
168
|
+
id: string;
|
|
169
|
+
ownerId: string;
|
|
170
|
+
sdkKeyId: null;
|
|
171
|
+
name: string;
|
|
172
|
+
description: string;
|
|
173
|
+
public: boolean;
|
|
174
|
+
thumb: string;
|
|
175
|
+
type: string;
|
|
176
|
+
updatedAt: Date;
|
|
177
|
+
createdAt: Date;
|
|
178
|
+
}[] | undefined>;
|
|
179
|
+
readonly materialGetById: (materialId: string) => Promise<{
|
|
180
|
+
id: string;
|
|
181
|
+
ownerId: string;
|
|
182
|
+
sdkKeyId: null;
|
|
183
|
+
name: string;
|
|
184
|
+
description: string;
|
|
185
|
+
public: boolean;
|
|
186
|
+
thumb: string;
|
|
187
|
+
type: string;
|
|
188
|
+
updatedAt: Date;
|
|
189
|
+
createdAt: Date;
|
|
190
|
+
} | undefined>;
|
|
191
|
+
readonly materialUpdate: (materialId: string, payload: UpdateMaterialPayload) => Promise<{
|
|
192
|
+
id: string;
|
|
193
|
+
ownerId: string;
|
|
194
|
+
sdkKeyId: null;
|
|
195
|
+
name: string;
|
|
196
|
+
description: string;
|
|
197
|
+
public: boolean;
|
|
198
|
+
thumb: string;
|
|
199
|
+
type: string;
|
|
200
|
+
updatedAt: Date;
|
|
201
|
+
createdAt: Date;
|
|
202
|
+
} | undefined>;
|
|
203
|
+
readonly materialDelete: (materialId: string) => Promise<string | undefined>;
|
|
204
|
+
readonly skullAdd: (payload: AddSkullFilePayload) => Promise<{
|
|
205
|
+
id: string;
|
|
206
|
+
ownerId: string;
|
|
207
|
+
sdkKeyId: null;
|
|
208
|
+
name: string;
|
|
209
|
+
previewUrl: string;
|
|
210
|
+
url3d: string;
|
|
211
|
+
public: boolean;
|
|
212
|
+
updatedAt: Date;
|
|
213
|
+
createdAt: Date;
|
|
214
|
+
} | undefined>;
|
|
215
|
+
readonly skullUpdate: (skullId: string, payload: UpdateSkullPayload) => Promise<{
|
|
216
|
+
id: string;
|
|
217
|
+
ownerId: string;
|
|
218
|
+
sdkKeyId: null;
|
|
219
|
+
name: string;
|
|
220
|
+
previewUrl: string;
|
|
221
|
+
url3d: string;
|
|
222
|
+
public: boolean;
|
|
223
|
+
updatedAt: Date;
|
|
224
|
+
createdAt: Date;
|
|
225
|
+
} | undefined>;
|
|
226
|
+
readonly skullGetAll: () => Promise<{
|
|
227
|
+
id: string;
|
|
228
|
+
ownerId: string;
|
|
229
|
+
sdkKeyId: null;
|
|
230
|
+
name: string;
|
|
231
|
+
previewUrl: string;
|
|
232
|
+
url3d: string;
|
|
233
|
+
public: boolean;
|
|
234
|
+
updatedAt: Date;
|
|
235
|
+
createdAt: Date;
|
|
236
|
+
}[] | undefined>;
|
|
237
|
+
readonly skullGetById: (skullId: string) => Promise<{
|
|
238
|
+
id: string;
|
|
239
|
+
ownerId: string;
|
|
240
|
+
sdkKeyId: null;
|
|
241
|
+
name: string;
|
|
242
|
+
previewUrl: string;
|
|
243
|
+
url3d: string;
|
|
244
|
+
public: boolean;
|
|
245
|
+
updatedAt: Date;
|
|
246
|
+
createdAt: Date;
|
|
247
|
+
} | undefined>;
|
|
248
|
+
readonly skullDelete: (skullId: string) => Promise<string | undefined>;
|
|
249
|
+
}
|