@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,47 @@
1
+ import BxBApi from '@bytexbyte/bxb-api';
2
+ declare type SendBody = {
3
+ provider: 'email' | 'phone';
4
+ identifier: string;
5
+ };
6
+ declare type SendResult = {
7
+ error?: 'You are not logged in.';
8
+ endTimeMilliseconds?: undefined;
9
+ } | {
10
+ error: 'Code already exists. Please check your email or messages.';
11
+ endTimeMilliseconds: number;
12
+ };
13
+ declare type VerifyBody = {
14
+ code: number;
15
+ };
16
+ declare type VerifyResult = {
17
+ error?: 'You are not logged in.' | 'invalid code' | 'Timeout.';
18
+ };
19
+ declare type RedeemBody = {
20
+ address: string;
21
+ tokenId: string;
22
+ digitalCustomizationId: number;
23
+ };
24
+ declare type RedeemResult = {
25
+ error?: 'Invalid tag.' | 'Missing blockChainTokenId.' | 'Status error.' | 'NFT submission not found.' | 'Contract not found.' | 'Unknown error.' | 'This is not your tag.' | 'You are not logged in.' | "Transfer failed: no transaction hash returned.";
26
+ };
27
+ declare class IKEAppMfaApi extends BxBApi {
28
+ constructor({ host, onSuccess, onError }: {
29
+ host: string;
30
+ onSuccess?: () => void;
31
+ onError?: (error: any) => void;
32
+ });
33
+ sendVerify(form: SendBody): Promise<SendResult>;
34
+ verify(form: VerifyBody): Promise<VerifyResult>;
35
+ biometricsVerify(form: {
36
+ publicKey: string;
37
+ signature: string;
38
+ }): Promise<{
39
+ id: string;
40
+ error?: undefined;
41
+ } | {
42
+ id?: undefined;
43
+ error: 'You are not logged in.' | 'Field(s) cannot be empty.' | 'id not found.' | 'Biometrics not set yet.' | 'New device login requires password credentials.' | 'signature error.';
44
+ }>;
45
+ redeem(form: RedeemBody): Promise<RedeemResult>;
46
+ }
47
+ export default IKEAppMfaApi;
@@ -0,0 +1,139 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ 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;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ /* eslint-disable no-undef */
55
+ var bxb_api_1 = require("@bytexbyte/bxb-api");
56
+ var config_1 = require("../config");
57
+ var IKEAppMfaApi = /** @class */ (function (_super) {
58
+ __extends(IKEAppMfaApi, _super);
59
+ function IKEAppMfaApi(_a) {
60
+ var host = _a.host, onSuccess = _a.onSuccess, onError = _a.onError;
61
+ return _super.call(this, {
62
+ host: host,
63
+ secretKey: config_1.localSecretKey, secret: '',
64
+ moduleName: 'redeem-nft',
65
+ onSuccess: onSuccess,
66
+ onError: onError
67
+ }) || this;
68
+ }
69
+ IKEAppMfaApi.prototype.sendVerify = function (form) {
70
+ return __awaiter(this, void 0, void 0, function () {
71
+ var response;
72
+ return __generator(this, function (_a) {
73
+ switch (_a.label) {
74
+ case 0: return [4 /*yield*/, this.bxbFetch({
75
+ method: 'POST',
76
+ headers: { 'Content-Type': 'application/json' },
77
+ body: JSON.stringify(form)
78
+ }, 'send-verify')];
79
+ case 1:
80
+ response = _a.sent();
81
+ return [2 /*return*/, response.json()];
82
+ }
83
+ });
84
+ });
85
+ };
86
+ IKEAppMfaApi.prototype.verify = function (form) {
87
+ return __awaiter(this, void 0, void 0, function () {
88
+ var response;
89
+ return __generator(this, function (_a) {
90
+ switch (_a.label) {
91
+ case 0: return [4 /*yield*/, this.bxbFetch({
92
+ method: 'POST',
93
+ headers: { 'Content-Type': 'application/json' },
94
+ body: JSON.stringify(form)
95
+ }, 'verify')];
96
+ case 1:
97
+ response = _a.sent();
98
+ return [2 /*return*/, response.json()];
99
+ }
100
+ });
101
+ });
102
+ };
103
+ IKEAppMfaApi.prototype.biometricsVerify = function (form) {
104
+ return __awaiter(this, void 0, void 0, function () {
105
+ var response;
106
+ return __generator(this, function (_a) {
107
+ switch (_a.label) {
108
+ case 0: return [4 /*yield*/, this.bxbFetch({
109
+ method: 'POST',
110
+ headers: { 'Content-Type': 'application/json' },
111
+ body: JSON.stringify(form)
112
+ }, 'biometrics-verify')];
113
+ case 1:
114
+ response = _a.sent();
115
+ return [2 /*return*/, response.json()];
116
+ }
117
+ });
118
+ });
119
+ };
120
+ IKEAppMfaApi.prototype.redeem = function (form) {
121
+ return __awaiter(this, void 0, void 0, function () {
122
+ var response;
123
+ return __generator(this, function (_a) {
124
+ switch (_a.label) {
125
+ case 0: return [4 /*yield*/, this.bxbFetch({
126
+ method: 'POST',
127
+ headers: { 'Content-Type': 'application/json' },
128
+ body: JSON.stringify(form)
129
+ }, 'redeem')];
130
+ case 1:
131
+ response = _a.sent();
132
+ return [2 /*return*/, response.json()];
133
+ }
134
+ });
135
+ });
136
+ };
137
+ return IKEAppMfaApi;
138
+ }(bxb_api_1.default));
139
+ exports.default = IKEAppMfaApi;
@@ -0,0 +1,23 @@
1
+ import BxBApi from '@bytexbyte/bxb-api';
2
+ declare type FreeForm = {
3
+ id: number;
4
+ value: string;
5
+ };
6
+ declare type RedeemBody = {
7
+ email: string;
8
+ goldenTicketId: number;
9
+ tokenId: string;
10
+ freeForm: FreeForm[];
11
+ };
12
+ declare type RedeemResult = {
13
+ error?: 'You are not logged in.' | 'Contact email not found.' | 'batch not found.' | 'company not found.' | 'This is not your tag.';
14
+ };
15
+ declare class IKEAppRedeemApi extends BxBApi {
16
+ constructor({ host, onSuccess, onError }: {
17
+ host: string;
18
+ onSuccess?: () => void;
19
+ onError?: (error: any) => void;
20
+ });
21
+ redeemGoldenTicket(form: RedeemBody): Promise<RedeemResult>;
22
+ }
23
+ export default IKEAppRedeemApi;
@@ -0,0 +1,90 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ 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;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ /* eslint-disable no-undef */
55
+ var bxb_api_1 = require("@bytexbyte/bxb-api");
56
+ var config_1 = require("../config");
57
+ var IKEAppRedeemApi = /** @class */ (function (_super) {
58
+ __extends(IKEAppRedeemApi, _super);
59
+ function IKEAppRedeemApi(_a) {
60
+ var host = _a.host, onSuccess = _a.onSuccess, onError = _a.onError;
61
+ return _super.call(this, {
62
+ host: host,
63
+ secretKey: config_1.localSecretKey, secret: '',
64
+ moduleName: 'redeem-godenticket',
65
+ onSuccess: onSuccess,
66
+ onError: onError
67
+ }) || this;
68
+ }
69
+ IKEAppRedeemApi.prototype.redeemGoldenTicket = function (form) {
70
+ return __awaiter(this, void 0, void 0, function () {
71
+ var response;
72
+ return __generator(this, function (_a) {
73
+ switch (_a.label) {
74
+ case 0: return [4 /*yield*/, this.bxbFetch({
75
+ method: 'POST',
76
+ headers: {
77
+ 'Content-Type': 'application/json'
78
+ },
79
+ body: JSON.stringify(form)
80
+ }, 'redeem')];
81
+ case 1:
82
+ response = _a.sent();
83
+ return [2 /*return*/, response.json()];
84
+ }
85
+ });
86
+ });
87
+ };
88
+ return IKEAppRedeemApi;
89
+ }(bxb_api_1.default));
90
+ exports.default = IKEAppRedeemApi;
@@ -0,0 +1,18 @@
1
+ import BxBApi from '@bytexbyte/bxb-api';
2
+ declare type RegisterBody = {
3
+ token: string;
4
+ device: string;
5
+ deviceOsType: 'ios' | 'android' | 'windows' | 'macos' | 'web';
6
+ };
7
+ declare type RegisterResult = {
8
+ error?: 'You are not logged in.';
9
+ };
10
+ declare class IKEAppRegisterDeviceCodeApi extends BxBApi {
11
+ constructor({ host, onSuccess, onError }: {
12
+ host: string;
13
+ onSuccess?: () => void;
14
+ onError?: (error: any) => void;
15
+ });
16
+ register(form: RegisterBody): Promise<RegisterResult>;
17
+ }
18
+ export default IKEAppRegisterDeviceCodeApi;
@@ -0,0 +1,88 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ 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;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ /* eslint-disable no-undef */
55
+ var bxb_api_1 = require("@bytexbyte/bxb-api");
56
+ var config_1 = require("../config");
57
+ var IKEAppRegisterDeviceCodeApi = /** @class */ (function (_super) {
58
+ __extends(IKEAppRegisterDeviceCodeApi, _super);
59
+ function IKEAppRegisterDeviceCodeApi(_a) {
60
+ var host = _a.host, onSuccess = _a.onSuccess, onError = _a.onError;
61
+ return _super.call(this, {
62
+ host: host,
63
+ secretKey: config_1.localSecretKey, secret: '',
64
+ moduleName: 'register-device-code',
65
+ onSuccess: onSuccess,
66
+ onError: onError
67
+ }) || this;
68
+ }
69
+ IKEAppRegisterDeviceCodeApi.prototype.register = function (form) {
70
+ return __awaiter(this, void 0, void 0, function () {
71
+ var response;
72
+ return __generator(this, function (_a) {
73
+ switch (_a.label) {
74
+ case 0: return [4 /*yield*/, this.bxbFetch({
75
+ method: 'POST',
76
+ headers: { 'Content-Type': 'application/json' },
77
+ body: JSON.stringify(form)
78
+ })];
79
+ case 1:
80
+ response = _a.sent();
81
+ return [2 /*return*/, response.json()];
82
+ }
83
+ });
84
+ });
85
+ };
86
+ return IKEAppRegisterDeviceCodeApi;
87
+ }(bxb_api_1.default));
88
+ exports.default = IKEAppRegisterDeviceCodeApi;
@@ -0,0 +1,39 @@
1
+ import BxBApi from '@bytexbyte/bxb-api';
2
+ import { Scan } from '../types';
3
+ declare type ScanBody = Pick<Scan, 'isAppClip' | 'latitude' | 'longitude' | 'tagTokenId' | 'deviceId' | 'tail'> & {
4
+ uid: string;
5
+ deviceOsType: 'ios' | 'android' | 'windows' | 'macos' | 'web';
6
+ };
7
+ declare type UpdateBody = {
8
+ isVisitedPromo: Pick<Scan, 'isVisitedPromo'>['isVisitedPromo'];
9
+ isVisitedShop?: undefined;
10
+ isVisitedExplore?: undefined;
11
+ } | {
12
+ isVisitedPromo?: undefined;
13
+ isVisitedShop: Pick<Scan, 'isVisitedShop'>['isVisitedShop'];
14
+ isVisitedExplore?: undefined;
15
+ } | {
16
+ isVisitedPromo?: undefined;
17
+ isVisitedShop?: undefined;
18
+ isVisitedExplore: Pick<Scan, 'isVisitedExplore'>['isVisitedExplore'];
19
+ };
20
+ declare type ScanResult = {
21
+ scan: Scan;
22
+ error?: undefined;
23
+ } | {
24
+ scan?: undefined;
25
+ error: 'Token is not exist.' | 'tokenId and UID do not match.' | 'This tag is deactivated.' | 'Server timeout.' | 'The device does not support';
26
+ };
27
+ declare type UpdateResult = {
28
+ error?: 'scanId type error.' | 'scanId not found.' | 'This is a IKE tag, You are not authorized to call this API.' | 'Scan not found.';
29
+ };
30
+ declare class IKEAppScanApi extends BxBApi {
31
+ constructor({ host, onSuccess, onError }: {
32
+ host: string;
33
+ onSuccess?: () => void;
34
+ onError?: (error: any) => void;
35
+ });
36
+ create(form: ScanBody, userId?: string): Promise<ScanResult>;
37
+ update(scanId: number, form: UpdateBody): Promise<UpdateResult>;
38
+ }
39
+ export default IKEAppScanApi;
@@ -0,0 +1,121 @@
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ 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;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ /* eslint-disable no-undef */
55
+ var bxb_api_1 = require("@bytexbyte/bxb-api");
56
+ var config_1 = require("../config");
57
+ var IKEAppScanApi = /** @class */ (function (_super) {
58
+ __extends(IKEAppScanApi, _super);
59
+ function IKEAppScanApi(_a) {
60
+ var host = _a.host, onSuccess = _a.onSuccess, onError = _a.onError;
61
+ return _super.call(this, {
62
+ host: host,
63
+ secretKey: config_1.localSecretKey, secret: '',
64
+ moduleName: 'scan',
65
+ onSuccess: onSuccess,
66
+ onError: onError
67
+ }) || this;
68
+ }
69
+ IKEAppScanApi.prototype.create = function (form, userId) {
70
+ return __awaiter(this, void 0, void 0, function () {
71
+ var controller, timeoutId, response, error_1;
72
+ return __generator(this, function (_a) {
73
+ switch (_a.label) {
74
+ case 0:
75
+ controller = new AbortController();
76
+ timeoutId = setTimeout(function () { return controller.abort(); }, 4000);
77
+ _a.label = 1;
78
+ case 1:
79
+ _a.trys.push([1, 3, , 4]);
80
+ return [4 /*yield*/, this.bxbFetch({
81
+ method: 'POST',
82
+ headers: userId ? {
83
+ 'Content-Type': 'application/json',
84
+ 'IKE-App-User-Id': userId
85
+ } : {
86
+ 'Content-Type': 'application/json'
87
+ },
88
+ body: JSON.stringify(form),
89
+ signal: controller.signal
90
+ })];
91
+ case 2:
92
+ response = _a.sent();
93
+ return [2 /*return*/, response.json()];
94
+ case 3:
95
+ error_1 = _a.sent();
96
+ return [2 /*return*/, { error: 'Server timeout.' }];
97
+ case 4: return [2 /*return*/];
98
+ }
99
+ });
100
+ });
101
+ };
102
+ IKEAppScanApi.prototype.update = function (scanId, form) {
103
+ return __awaiter(this, void 0, void 0, function () {
104
+ var response;
105
+ return __generator(this, function (_a) {
106
+ switch (_a.label) {
107
+ case 0: return [4 /*yield*/, this.bxbFetch({
108
+ method: 'PUT',
109
+ headers: { 'Content-Type': 'application/json' },
110
+ body: JSON.stringify(form)
111
+ }, scanId.toString())];
112
+ case 1:
113
+ response = _a.sent();
114
+ return [2 /*return*/, response.json()];
115
+ }
116
+ });
117
+ });
118
+ };
119
+ return IKEAppScanApi;
120
+ }(bxb_api_1.default));
121
+ exports.default = IKEAppScanApi;
@@ -0,0 +1,75 @@
1
+ import BxBApi from '@bytexbyte/bxb-api';
2
+ import { ikeApi } from '../config';
3
+ import { BlockChainStatusType } from '../types';
4
+ declare type GetResult = {
5
+ tokenId: string;
6
+ batchId: string;
7
+ batchSerialNumber: number;
8
+ batch: {
9
+ experience: {
10
+ isGlobal: boolean | null;
11
+ }[];
12
+ };
13
+ } | null;
14
+ declare type GetManyQuery = {
15
+ batchId: string;
16
+ batchSerialNumberGte?: string;
17
+ batchSerialNumberLte?: string;
18
+ };
19
+ declare type GetManyResult = {
20
+ tokenId: string;
21
+ batchSerialNumber: number;
22
+ }[];
23
+ declare type PostBody = {
24
+ ownerId: string;
25
+ };
26
+ declare type PostResult = {
27
+ tagTokenId: string;
28
+ error?: undefined;
29
+ } | {
30
+ tagTokenId?: undefined;
31
+ error: 'this is not your account.' | 'create error.' | 'this is not your tag.' | 'undo expired.' | 'delete error.';
32
+ };
33
+ declare type PutBody = Parameters<typeof ikeApi.tags.updateMany>[0];
34
+ declare type PutResult = Awaited<ReturnType<typeof ikeApi.tags.updateMany>>;
35
+ declare type TransferBody = {
36
+ ownerId: string;
37
+ transferId: string;
38
+ };
39
+ declare type UndoTransferBody = {
40
+ ownerId: string;
41
+ };
42
+ declare type PutInfoVisible = {
43
+ ownerId: string;
44
+ isInfoVisible: boolean;
45
+ };
46
+ declare type PutInfoVisibleResult = {
47
+ error?: 'this is not your account.' | 'this is not your tag.' | 'update error.';
48
+ };
49
+ declare type PutUpdateDisplayName = {
50
+ displayName: string;
51
+ };
52
+ declare type PutUpdateDisplayNameResult = {
53
+ error?: 'update error.';
54
+ };
55
+ declare class IKEAppTagsApi extends BxBApi {
56
+ constructor({ host, onSuccess, onError }: {
57
+ host: string;
58
+ onSuccess?: () => void;
59
+ onError?: (error: any) => void;
60
+ });
61
+ get(tokenId: string): Promise<GetResult>;
62
+ getMany(query: GetManyQuery, userId?: string): Promise<GetManyResult>;
63
+ getBlockchainStatus(tokenId: string): Promise<{
64
+ blockchainStatus: BlockChainStatusType;
65
+ } | {
66
+ error: 'tokenId type error.';
67
+ }>;
68
+ update(tokenId: string, form: PostBody): Promise<PostResult>;
69
+ updateMany(form: PutBody, userId?: string): Promise<PutResult>;
70
+ transferOwner(tokenId: string, form: TransferBody): Promise<PostResult>;
71
+ undoTransferOwner(tokenId: string, form: UndoTransferBody): Promise<PostResult>;
72
+ updateInfoVisible(tokenId: string, form: PutInfoVisible): Promise<PutInfoVisibleResult>;
73
+ updateDisplayName(tokenId: string, displayName: PutUpdateDisplayName): Promise<PutUpdateDisplayNameResult>;
74
+ }
75
+ export default IKEAppTagsApi;