@bytexbyte/ike-app-api 1.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.
Files changed (42) hide show
  1. package/README.md +17 -0
  2. package/lib/App.d.ts +23 -0
  3. package/lib/App.js +126 -0
  4. package/lib/Auth/index.d.ts +156 -0
  5. package/lib/Auth/index.js +392 -0
  6. package/lib/Auth/type.d.ts +73 -0
  7. package/lib/Auth/type.js +2 -0
  8. package/lib/Batch/index.d.ts +26 -0
  9. package/lib/Batch/index.js +136 -0
  10. package/lib/Contract/index.d.ts +26 -0
  11. package/lib/Contract/index.js +109 -0
  12. package/lib/DigitalCustomization/index.d.ts +34 -0
  13. package/lib/DigitalCustomization/index.js +128 -0
  14. package/lib/DigitalCustomization/shopifyType.d.ts +72 -0
  15. package/lib/DigitalCustomization/shopifyType.js +2 -0
  16. package/lib/File/UploadFileType.d.ts +5 -0
  17. package/lib/File/UploadFileType.js +16 -0
  18. package/lib/File/index.d.ts +34 -0
  19. package/lib/File/index.js +131 -0
  20. package/lib/InAppNotification/index.d.ts +23 -0
  21. package/lib/InAppNotification/index.js +89 -0
  22. package/lib/InAppNotification/type.d.ts +1 -0
  23. package/lib/InAppNotification/type.js +2 -0
  24. package/lib/Mfa/index.d.ts +47 -0
  25. package/lib/Mfa/index.js +139 -0
  26. package/lib/Redeem/index.d.ts +23 -0
  27. package/lib/Redeem/index.js +90 -0
  28. package/lib/RegisterDeviceCode/index.d.ts +18 -0
  29. package/lib/RegisterDeviceCode/index.js +88 -0
  30. package/lib/Scan/index.d.ts +39 -0
  31. package/lib/Scan/index.js +121 -0
  32. package/lib/Tags/index.d.ts +75 -0
  33. package/lib/Tags/index.js +264 -0
  34. package/lib/User/index.d.ts +140 -0
  35. package/lib/User/index.js +478 -0
  36. package/lib/config.d.ts +3 -0
  37. package/lib/config.js +8 -0
  38. package/lib/index.d.ts +42 -0
  39. package/lib/index.js +98 -0
  40. package/lib/types.d.ts +587 -0
  41. package/lib/types.js +64 -0
  42. package/package.json +79 -0
@@ -0,0 +1,392 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
37
+ var __generator = (this && this.__generator) || function (thisArg, body) {
38
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
+ function verb(n) { return function (v) { return step([n, v]); }; }
41
+ function step(op) {
42
+ if (f) throw new TypeError("Generator is already executing.");
43
+ while (_) try {
44
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
+ if (y = 0, t) op = [op[0] & 2, t.value];
46
+ switch (op[0]) {
47
+ case 0: case 1: t = op; break;
48
+ case 4: _.label++; return { value: op[1], done: false };
49
+ case 5: _.label++; y = op[1]; op = [0]; continue;
50
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
+ default:
52
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
+ if (t[2]) _.ops.pop();
57
+ _.trys.pop(); continue;
58
+ }
59
+ op = body.call(thisArg, _);
60
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
+ }
63
+ };
64
+ Object.defineProperty(exports, "__esModule", { value: true });
65
+ var bxb_api_1 = require("@bytexbyte/bxb-api");
66
+ var config_1 = require("../config");
67
+ var toFormUrlencodedString = function (form) {
68
+ var searchParams = new URLSearchParams;
69
+ Object.keys(form).forEach(function (key) {
70
+ searchParams.append(key, form[key]);
71
+ });
72
+ return searchParams.toString();
73
+ };
74
+ var IKEAppAuthApi = /** @class */ (function (_super) {
75
+ __extends(IKEAppAuthApi, _super);
76
+ function IKEAppAuthApi(_a) {
77
+ var host = _a.host, secretKey = _a.secretKey, secret = _a.secret, onSuccess = _a.onSuccess, onError = _a.onError;
78
+ return _super.call(this, {
79
+ host: host,
80
+ secretKey: secretKey !== null && secretKey !== void 0 ? secretKey : config_1.localSecretKey,
81
+ secret: secret !== null && secret !== void 0 ? secret : '',
82
+ moduleName: 'auth',
83
+ onSuccess: onSuccess,
84
+ onError: onError
85
+ }) || this;
86
+ }
87
+ IKEAppAuthApi.prototype.getCsrfToken = function () {
88
+ return __awaiter(this, void 0, void 0, function () {
89
+ var response;
90
+ return __generator(this, function (_a) {
91
+ switch (_a.label) {
92
+ case 0: return [4 /*yield*/, this.bxbFetch({
93
+ method: 'GET',
94
+ headers: {
95
+ 'Content-Type': 'application/json'
96
+ }
97
+ }, 'csrf')];
98
+ case 1:
99
+ response = _a.sent();
100
+ return [2 /*return*/, response.json()];
101
+ }
102
+ });
103
+ });
104
+ };
105
+ IKEAppAuthApi.prototype.checkVerify = function (body) {
106
+ return __awaiter(this, void 0, void 0, function () {
107
+ var response;
108
+ return __generator(this, function (_a) {
109
+ switch (_a.label) {
110
+ case 0: return [4 /*yield*/, this.bxbFetch({
111
+ method: 'POST',
112
+ headers: {
113
+ 'Content-Type': 'application/json'
114
+ },
115
+ body: JSON.stringify(body)
116
+ }, "verify/check")];
117
+ case 1:
118
+ response = _a.sent();
119
+ return [2 /*return*/, response.json()];
120
+ }
121
+ });
122
+ });
123
+ };
124
+ IKEAppAuthApi.prototype.signUp = function (provider, form) {
125
+ return __awaiter(this, void 0, void 0, function () {
126
+ var response;
127
+ return __generator(this, function (_a) {
128
+ switch (_a.label) {
129
+ case 0: return [4 /*yield*/, this.bxbFetch({
130
+ method: 'POST',
131
+ headers: {
132
+ 'Content-Type': 'application/json'
133
+ },
134
+ body: JSON.stringify(form)
135
+ }, "sign-up/".concat(provider))];
136
+ case 1:
137
+ response = _a.sent();
138
+ return [2 /*return*/, response.json()];
139
+ }
140
+ });
141
+ });
142
+ };
143
+ IKEAppAuthApi.prototype.createBiometrics = function (form) {
144
+ return __awaiter(this, void 0, void 0, function () {
145
+ var response;
146
+ return __generator(this, function (_a) {
147
+ switch (_a.label) {
148
+ case 0: return [4 /*yield*/, this.bxbFetch({
149
+ method: 'POST',
150
+ headers: {
151
+ 'Content-Type': 'application/json'
152
+ },
153
+ body: JSON.stringify(form)
154
+ }, "biometrics")];
155
+ case 1:
156
+ response = _a.sent();
157
+ return [2 /*return*/, response.json()];
158
+ }
159
+ });
160
+ });
161
+ };
162
+ IKEAppAuthApi.prototype.deleteBiometrics = function () {
163
+ return __awaiter(this, void 0, void 0, function () {
164
+ var response;
165
+ return __generator(this, function (_a) {
166
+ switch (_a.label) {
167
+ case 0: return [4 /*yield*/, this.bxbFetch({
168
+ method: 'DELETE',
169
+ headers: {
170
+ 'Content-Type': 'application/json'
171
+ },
172
+ }, "biometrics")];
173
+ case 1:
174
+ response = _a.sent();
175
+ return [2 /*return*/, response.json()];
176
+ }
177
+ });
178
+ });
179
+ };
180
+ IKEAppAuthApi.prototype.sendVerify = function (provider, body) {
181
+ return __awaiter(this, void 0, void 0, function () {
182
+ var response;
183
+ return __generator(this, function (_a) {
184
+ switch (_a.label) {
185
+ case 0: return [4 /*yield*/, this.bxbFetch({
186
+ method: 'POST',
187
+ headers: {
188
+ 'Content-Type': 'application/json'
189
+ },
190
+ body: JSON.stringify(body)
191
+ }, "send-verify/".concat(provider))];
192
+ case 1:
193
+ response = _a.sent();
194
+ return [2 /*return*/, response.json()];
195
+ }
196
+ });
197
+ });
198
+ };
199
+ IKEAppAuthApi.prototype.verify = function (provider, body) {
200
+ return __awaiter(this, void 0, void 0, function () {
201
+ var response;
202
+ return __generator(this, function (_a) {
203
+ switch (_a.label) {
204
+ case 0: return [4 /*yield*/, this.bxbFetch({
205
+ method: 'POST',
206
+ headers: {
207
+ 'Content-Type': 'application/json'
208
+ },
209
+ body: JSON.stringify(body)
210
+ }, "verify/".concat(provider))];
211
+ case 1:
212
+ response = _a.sent();
213
+ return [2 /*return*/, response.json()];
214
+ }
215
+ });
216
+ });
217
+ };
218
+ IKEAppAuthApi.prototype.forgetPassword = function (provider, body) {
219
+ return __awaiter(this, void 0, void 0, function () {
220
+ var response;
221
+ return __generator(this, function (_a) {
222
+ switch (_a.label) {
223
+ case 0: return [4 /*yield*/, this.bxbFetch({
224
+ method: 'POST',
225
+ headers: {
226
+ 'Content-Type': 'application/json'
227
+ },
228
+ body: JSON.stringify(body)
229
+ }, "forget-password/".concat(provider))];
230
+ case 1:
231
+ response = _a.sent();
232
+ return [2 /*return*/, response.json()];
233
+ }
234
+ });
235
+ });
236
+ };
237
+ IKEAppAuthApi.prototype.resetPassword = function (provider, body) {
238
+ return __awaiter(this, void 0, void 0, function () {
239
+ var response;
240
+ return __generator(this, function (_a) {
241
+ switch (_a.label) {
242
+ case 0: return [4 /*yield*/, this.bxbFetch({
243
+ method: 'POST',
244
+ headers: {
245
+ 'Content-Type': 'application/json'
246
+ },
247
+ body: JSON.stringify(body)
248
+ }, "reset-password/".concat(provider))];
249
+ case 1:
250
+ response = _a.sent();
251
+ return [2 /*return*/, response.json()];
252
+ }
253
+ });
254
+ });
255
+ };
256
+ IKEAppAuthApi.prototype.signIn = function (provider, form) {
257
+ return __awaiter(this, void 0, void 0, function () {
258
+ var csrfToken, response;
259
+ return __generator(this, function (_a) {
260
+ switch (_a.label) {
261
+ case 0: return [4 /*yield*/, this.getCsrfToken()];
262
+ case 1:
263
+ csrfToken = (_a.sent()).csrfToken;
264
+ return [4 /*yield*/, this.bxbFetch({
265
+ method: 'POST',
266
+ headers: {
267
+ 'Content-Type': 'application/json'
268
+ },
269
+ body: JSON.stringify(__assign(__assign({ callbackUrl: this.host, json: true }, form), { csrfToken: csrfToken }))
270
+ }, "callback/".concat(provider))];
271
+ case 2:
272
+ response = _a.sent();
273
+ return [2 /*return*/, response.json()];
274
+ }
275
+ });
276
+ });
277
+ };
278
+ IKEAppAuthApi.prototype.signOut = function () {
279
+ return __awaiter(this, void 0, void 0, function () {
280
+ var csrfToken, response;
281
+ return __generator(this, function (_a) {
282
+ switch (_a.label) {
283
+ case 0: return [4 /*yield*/, this.getCsrfToken()];
284
+ case 1:
285
+ csrfToken = (_a.sent()).csrfToken;
286
+ return [4 /*yield*/, this.bxbFetch({
287
+ method: 'POST',
288
+ headers: {
289
+ 'Content-Type': 'application/x-www-form-urlencoded'
290
+ },
291
+ body: toFormUrlencodedString({ callbackUrl: this.host, json: true, csrfToken: csrfToken })
292
+ }, 'signout')];
293
+ case 2:
294
+ response = _a.sent();
295
+ return [2 /*return*/, response.json()];
296
+ }
297
+ });
298
+ });
299
+ };
300
+ IKEAppAuthApi.prototype.getSession = function () {
301
+ return __awaiter(this, void 0, void 0, function () {
302
+ var response;
303
+ return __generator(this, function (_a) {
304
+ switch (_a.label) {
305
+ case 0: return [4 /*yield*/, this.bxbFetch({
306
+ method: 'GET'
307
+ }, 'session')];
308
+ case 1:
309
+ response = _a.sent();
310
+ return [2 /*return*/, response.json()];
311
+ }
312
+ });
313
+ });
314
+ };
315
+ IKEAppAuthApi.prototype.createToken = function () {
316
+ return __awaiter(this, void 0, void 0, function () {
317
+ var response;
318
+ return __generator(this, function (_a) {
319
+ switch (_a.label) {
320
+ case 0: return [4 /*yield*/, this.bxbFetch({
321
+ method: 'POST',
322
+ headers: {
323
+ 'Content-Type': 'application/json'
324
+ }
325
+ }, 'token')];
326
+ case 1:
327
+ response = _a.sent();
328
+ return [2 /*return*/, response.json()];
329
+ }
330
+ });
331
+ });
332
+ };
333
+ IKEAppAuthApi.prototype.deleteToken = function (body) {
334
+ return __awaiter(this, void 0, void 0, function () {
335
+ var response;
336
+ return __generator(this, function (_a) {
337
+ switch (_a.label) {
338
+ case 0: return [4 /*yield*/, this.bxbFetch({
339
+ method: 'DELETE',
340
+ headers: {
341
+ 'Content-Type': 'application/json'
342
+ },
343
+ body: JSON.stringify(body)
344
+ }, 'token')];
345
+ case 1:
346
+ response = _a.sent();
347
+ return [2 /*return*/, response.json()];
348
+ }
349
+ });
350
+ });
351
+ };
352
+ IKEAppAuthApi.prototype.facebookToEmail = function (body) {
353
+ return __awaiter(this, void 0, void 0, function () {
354
+ var response;
355
+ return __generator(this, function (_a) {
356
+ switch (_a.label) {
357
+ case 0: return [4 /*yield*/, this.bxbFetch({
358
+ method: 'PUT',
359
+ headers: {
360
+ 'Content-Type': 'application/json'
361
+ },
362
+ body: JSON.stringify(body)
363
+ }, 'account-transition/facebook-to-email')];
364
+ case 1:
365
+ response = _a.sent();
366
+ return [2 /*return*/, response.json()];
367
+ }
368
+ });
369
+ });
370
+ };
371
+ IKEAppAuthApi.prototype.resetWalletPasscode = function (form) {
372
+ return __awaiter(this, void 0, void 0, function () {
373
+ var response;
374
+ return __generator(this, function (_a) {
375
+ switch (_a.label) {
376
+ case 0: return [4 /*yield*/, this.bxbFetch({
377
+ method: 'POST',
378
+ headers: {
379
+ 'Content-Type': 'application/json'
380
+ },
381
+ body: JSON.stringify(form)
382
+ }, "reset-wallet/passcode")];
383
+ case 1:
384
+ response = _a.sent();
385
+ return [2 /*return*/, response.json()];
386
+ }
387
+ });
388
+ });
389
+ };
390
+ return IKEAppAuthApi;
391
+ }(bxb_api_1.default));
392
+ exports.default = IKEAppAuthApi;
@@ -0,0 +1,73 @@
1
+ export declare type SignInEmailPassword = (provider: 'email-password', form: {
2
+ email: string;
3
+ password: string;
4
+ csrfToken?: string;
5
+ }) => Promise<{
6
+ id: string;
7
+ error?: undefined;
8
+ } | {
9
+ id?: undefined;
10
+ error: 'Authentication error.' | 'Field(s) cannot be empty.' | 'Email not found.' | 'Email not verified.' | 'Email associated with third-party login.' | 'Password incorrect.' | 'URL not found.';
11
+ }>;
12
+ export declare type SignInGoogleIos = (provider: 'google-ios', form: {
13
+ scope: string;
14
+ token: string;
15
+ csrfToken?: string;
16
+ }) => Promise<{
17
+ id: string;
18
+ error?: undefined;
19
+ } | {
20
+ id?: undefined;
21
+ error: 'Authentication error.' | 'Field(s) cannot be empty.' | 'URL not found.';
22
+ }>;
23
+ export declare type SignInGoogleAndroid = (provider: 'google-android', form: {
24
+ scope: string;
25
+ token: string;
26
+ csrfToken?: string;
27
+ }) => Promise<{
28
+ id: string;
29
+ error?: undefined;
30
+ } | {
31
+ id?: undefined;
32
+ error: 'Authentication error.' | 'Field(s) cannot be empty.' | 'URL not found.';
33
+ }>;
34
+ export declare type SignInFacebookMobile = (provider: 'facebook-mobile', form: {
35
+ scope: string;
36
+ token: string;
37
+ expires_at: string;
38
+ csrfToken?: string;
39
+ }) => Promise<{
40
+ id: string;
41
+ error?: undefined;
42
+ } | {
43
+ id?: undefined;
44
+ error: 'Authentication error.' | 'Field(s) cannot be empty.' | 'payload error.' | 'URL not found.';
45
+ }>;
46
+ export declare type SignInAppleMobile = (provider: 'apple-mobile', form: {
47
+ token: string;
48
+ account_token: string;
49
+ providerAccountId: string;
50
+ email?: string;
51
+ firstName?: string;
52
+ lastName?: string;
53
+ csrfToken?: string;
54
+ }) => Promise<{
55
+ id: string;
56
+ error?: undefined;
57
+ } | {
58
+ id?: undefined;
59
+ error: 'Authentication error.' | 'Field(s) cannot be empty.' | 'URL not found.';
60
+ }>;
61
+ export declare type SignInEmailBiometrics = (provider: 'email-biometrics', form: {
62
+ publicKey: string;
63
+ id: string;
64
+ signature: string;
65
+ csrfToken?: string;
66
+ }) => Promise<{
67
+ id: string;
68
+ error?: undefined;
69
+ } | {
70
+ id?: undefined;
71
+ error: 'Authentication error.' | 'Field(s) cannot be empty.' | 'id not found.' | 'Email not verified.' | 'Sign in to turn on biometrics.' | 'New device login requires password credentials.' | 'signature error.' | 'URL not found.';
72
+ }>;
73
+ export declare type SignIn = SignInEmailPassword | SignInGoogleIos | SignInGoogleAndroid | SignInFacebookMobile | SignInAppleMobile | SignInEmailBiometrics;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,26 @@
1
+ import BxBApi from '@bytexbyte/bxb-api';
2
+ import { ikeApi } from '../config';
3
+ declare type PutBody = Parameters<typeof ikeApi.batch.assignToMember>[1];
4
+ declare type PutResult = Awaited<ReturnType<typeof ikeApi.batch.assignToMember>>;
5
+ declare type RenamePutBody = Parameters<typeof ikeApi.batch.rename>[1];
6
+ declare type RenamePutResult = Awaited<ReturnType<typeof ikeApi.batch.rename>>;
7
+ declare enum ScanningStatusType {
8
+ LOADING = 0,
9
+ EMPTY = 1,
10
+ ACTIVE = 2,
11
+ INACTIVE = 3,
12
+ MIXED = 4
13
+ }
14
+ declare class IKEAppBatchApi extends BxBApi {
15
+ constructor({ host, onSuccess, onError }: {
16
+ host: string;
17
+ onSuccess?: () => void;
18
+ onError?: (error: any) => void;
19
+ });
20
+ assignToMember(batchId: string, form: PutBody): Promise<PutResult>;
21
+ rename(batchId: string, form: RenamePutBody): Promise<RenamePutResult>;
22
+ getScanningStatus(batchId: string, ids: string[]): Promise<{
23
+ scanningStatus: ScanningStatusType;
24
+ }>;
25
+ }
26
+ export default IKEAppBatchApi;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ /* eslint-disable no-undef */
3
+ var __extends = (this && this.__extends) || (function () {
4
+ var extendStatics = function (d, b) {
5
+ extendStatics = Object.setPrototypeOf ||
6
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
7
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
8
+ return extendStatics(d, b);
9
+ };
10
+ return function (d, b) {
11
+ if (typeof b !== "function" && b !== null)
12
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
13
+ extendStatics(d, b);
14
+ function __() { this.constructor = d; }
15
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16
+ };
17
+ })();
18
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
19
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
20
+ return new (P || (P = Promise))(function (resolve, reject) {
21
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
22
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
23
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
24
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
25
+ });
26
+ };
27
+ var __generator = (this && this.__generator) || function (thisArg, body) {
28
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
29
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
30
+ function verb(n) { return function (v) { return step([n, v]); }; }
31
+ function step(op) {
32
+ if (f) throw new TypeError("Generator is already executing.");
33
+ while (_) try {
34
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
35
+ if (y = 0, t) op = [op[0] & 2, t.value];
36
+ switch (op[0]) {
37
+ case 0: case 1: t = op; break;
38
+ case 4: _.label++; return { value: op[1], done: false };
39
+ case 5: _.label++; y = op[1]; op = [0]; continue;
40
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
41
+ default:
42
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
43
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
44
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
45
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
46
+ if (t[2]) _.ops.pop();
47
+ _.trys.pop(); continue;
48
+ }
49
+ op = body.call(thisArg, _);
50
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
51
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
52
+ }
53
+ };
54
+ Object.defineProperty(exports, "__esModule", { value: true });
55
+ var bxb_api_1 = require("@bytexbyte/bxb-api");
56
+ var config_1 = require("../config");
57
+ var ScanningStatusType;
58
+ (function (ScanningStatusType) {
59
+ ScanningStatusType[ScanningStatusType["LOADING"] = 0] = "LOADING";
60
+ ScanningStatusType[ScanningStatusType["EMPTY"] = 1] = "EMPTY";
61
+ ScanningStatusType[ScanningStatusType["ACTIVE"] = 2] = "ACTIVE";
62
+ ScanningStatusType[ScanningStatusType["INACTIVE"] = 3] = "INACTIVE";
63
+ ScanningStatusType[ScanningStatusType["MIXED"] = 4] = "MIXED";
64
+ })(ScanningStatusType || (ScanningStatusType = {}));
65
+ var IKEAppBatchApi = /** @class */ (function (_super) {
66
+ __extends(IKEAppBatchApi, _super);
67
+ function IKEAppBatchApi(_a) {
68
+ var host = _a.host, onSuccess = _a.onSuccess, onError = _a.onError;
69
+ return _super.call(this, {
70
+ host: host,
71
+ secretKey: config_1.localSecretKey,
72
+ secret: '',
73
+ moduleName: 'batch',
74
+ onSuccess: onSuccess,
75
+ onError: onError
76
+ }) || this;
77
+ }
78
+ IKEAppBatchApi.prototype.assignToMember = function (batchId, form) {
79
+ return __awaiter(this, void 0, void 0, function () {
80
+ var response;
81
+ return __generator(this, function (_a) {
82
+ switch (_a.label) {
83
+ case 0: return [4 /*yield*/, this.bxbFetch({
84
+ method: 'PUT',
85
+ headers: {
86
+ 'Content-Type': 'application/json'
87
+ },
88
+ body: JSON.stringify(form)
89
+ }, "".concat(batchId, "/assign-to-member"))];
90
+ case 1:
91
+ response = _a.sent();
92
+ return [2 /*return*/, response.json()];
93
+ }
94
+ });
95
+ });
96
+ };
97
+ IKEAppBatchApi.prototype.rename = function (batchId, form) {
98
+ return __awaiter(this, void 0, void 0, function () {
99
+ var response;
100
+ return __generator(this, function (_a) {
101
+ switch (_a.label) {
102
+ case 0: return [4 /*yield*/, this.bxbFetch({
103
+ method: 'PUT',
104
+ headers: {
105
+ 'Content-Type': 'application/json',
106
+ },
107
+ body: JSON.stringify(form),
108
+ }, "".concat(batchId, "/rename"))];
109
+ case 1:
110
+ response = _a.sent();
111
+ return [2 /*return*/, response.json()];
112
+ }
113
+ });
114
+ });
115
+ };
116
+ IKEAppBatchApi.prototype.getScanningStatus = function (batchId, ids) {
117
+ return __awaiter(this, void 0, void 0, function () {
118
+ var response;
119
+ return __generator(this, function (_a) {
120
+ switch (_a.label) {
121
+ case 0: return [4 /*yield*/, this.bxbFetch({
122
+ method: 'Get',
123
+ headers: {
124
+ 'Content-Type': 'application/json',
125
+ },
126
+ }, "".concat(batchId, "/scanning-status?ids=").concat(ids.join(',')))];
127
+ case 1:
128
+ response = _a.sent();
129
+ return [2 /*return*/, response.json()];
130
+ }
131
+ });
132
+ });
133
+ };
134
+ return IKEAppBatchApi;
135
+ }(bxb_api_1.default));
136
+ exports.default = IKEAppBatchApi;
@@ -0,0 +1,26 @@
1
+ import BxBApi from '@bytexbyte/bxb-api';
2
+ declare class IKEAppContractApi extends BxBApi {
3
+ constructor({ host, onSuccess, onError }: {
4
+ host: string;
5
+ onSuccess?: () => void;
6
+ onError?: (error: any) => void;
7
+ });
8
+ getAddresses(): Promise<{
9
+ addresses: string[];
10
+ error?: undefined;
11
+ } | {
12
+ addresses?: undefined;
13
+ error: 'You are not logged in.';
14
+ }>;
15
+ getNftImage(form: {
16
+ contractAddress: string;
17
+ blockChainTokenId: string;
18
+ }): Promise<{
19
+ imageUrl: string;
20
+ error?: undefined;
21
+ } | {
22
+ imageUrl?: undefined;
23
+ error: 'url not found.' | 'imageURI convert error.';
24
+ }>;
25
+ }
26
+ export default IKEAppContractApi;