@yhgale/shared 0.1.1 → 0.1.3
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/chunk-DWPSHK7F.js +68 -0
- package/dist/chunk-Y75EVVGQ.js +108 -0
- package/dist/errors/index.d.ts +54 -0
- package/dist/errors/index.js +24 -0
- package/dist/index.d.ts +4 -765
- package/dist/index.js +20 -158
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +0 -0
- package/dist/types/index.d.ts +719 -0
- package/dist/types/index.js +12 -0
- package/package.json +38 -18
package/dist/index.js
CHANGED
|
@@ -1,160 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
paths: {
|
|
20
|
-
signIn: "/sign-in",
|
|
21
|
-
signUp: "/sign-up",
|
|
22
|
-
userProfile: "/user",
|
|
23
|
-
organizationProfile: "/organizations",
|
|
24
|
-
createOrganization: "/organizations",
|
|
25
|
-
unauthorizedSignIn: "/unauthorized-sign-in"
|
|
26
|
-
},
|
|
27
|
-
redirects: {
|
|
28
|
-
afterSignUpFallback: "",
|
|
29
|
-
afterSignInFallback: "",
|
|
30
|
-
logoLink: ""
|
|
31
|
-
},
|
|
32
|
-
appearance: {
|
|
33
|
-
mode: "auto",
|
|
34
|
-
light: {
|
|
35
|
-
primaryColor: "#6C47FF",
|
|
36
|
-
backgroundColor: "#FFFFFF"
|
|
37
|
-
},
|
|
38
|
-
dark: {
|
|
39
|
-
primaryColor: "#6C47FF",
|
|
40
|
-
backgroundColor: "#1F1F23"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// src/types/captcha.ts
|
|
47
|
-
var DEFAULT_CAPTCHA_SETTINGS = {
|
|
48
|
-
provider: "none",
|
|
49
|
-
publicKey: null,
|
|
50
|
-
secretKey: null,
|
|
51
|
-
widgetType: "smart",
|
|
52
|
-
protectedFlows: [],
|
|
53
|
-
oauthBypass: true,
|
|
54
|
-
testBypassToken: null
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
// src/types/index.ts
|
|
58
|
-
var UUID_V7_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
59
|
-
function isUuidV7(value) {
|
|
60
|
-
return UUID_V7_REGEX.test(value);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// src/errors/fapi.ts
|
|
64
|
-
function isFapiErrorEnvelope(v) {
|
|
65
|
-
if (typeof v !== "object" || v === null) return false;
|
|
66
|
-
const errs = v.errors;
|
|
67
|
-
return Array.isArray(errs) && errs.length > 0 && typeof errs[0] === "object";
|
|
68
|
-
}
|
|
69
|
-
function fapiErrorToGaleError(status, body) {
|
|
70
|
-
if (isFapiErrorEnvelope(body)) {
|
|
71
|
-
const [first, ...rest] = body.errors;
|
|
72
|
-
if (!first) {
|
|
73
|
-
return new GaleError({
|
|
74
|
-
code: "gale_unknown_error",
|
|
75
|
-
message: "fapi returned empty errors[]",
|
|
76
|
-
status
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
const meta = { ...first.meta ?? {} };
|
|
80
|
-
if (rest.length > 0) meta["additional"] = rest;
|
|
81
|
-
return new GaleError({
|
|
82
|
-
code: first.code,
|
|
83
|
-
message: first.message,
|
|
84
|
-
longMessage: first.longMessage,
|
|
85
|
-
meta,
|
|
86
|
-
status
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
const message = typeof body === "object" && body !== null && "message" in body && typeof body.message === "string" ? body.message : `fapi http ${status}`;
|
|
90
|
-
return new GaleError({
|
|
91
|
-
code: status === 401 ? "gale_unauthorized" : "gale_http_error",
|
|
92
|
-
message,
|
|
93
|
-
status,
|
|
94
|
-
meta: { rawBody: body }
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
function networkErrorToGaleError(cause) {
|
|
98
|
-
const message = cause instanceof Error ? cause.message : "network request failed";
|
|
99
|
-
return new GaleError({
|
|
100
|
-
code: "gale_network_error",
|
|
101
|
-
message,
|
|
102
|
-
status: 0,
|
|
103
|
-
meta: cause instanceof Error ? { name: cause.name } : void 0
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// src/errors/index.ts
|
|
108
|
-
var GaleError = class extends Error {
|
|
109
|
-
code;
|
|
110
|
-
status;
|
|
111
|
-
longMessage;
|
|
112
|
-
meta;
|
|
113
|
-
constructor(payload) {
|
|
114
|
-
super(payload.message);
|
|
115
|
-
this.name = "GaleError";
|
|
116
|
-
this.code = payload.code;
|
|
117
|
-
this.status = payload.status ?? 500;
|
|
118
|
-
this.longMessage = payload.longMessage;
|
|
119
|
-
this.meta = payload.meta;
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
var GaleValidationError = class extends GaleError {
|
|
123
|
-
constructor(payload) {
|
|
124
|
-
super({ ...payload, status: 422 });
|
|
125
|
-
this.name = "GaleValidationError";
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
var GaleAuthError = class extends GaleError {
|
|
129
|
-
constructor(payload) {
|
|
130
|
-
super({ ...payload, status: 401 });
|
|
131
|
-
this.name = "GaleAuthError";
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
var GalePermissionError = class extends GaleError {
|
|
135
|
-
constructor(payload) {
|
|
136
|
-
super({ ...payload, status: 403 });
|
|
137
|
-
this.name = "GalePermissionError";
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
var GaleNotFoundError = class extends GaleError {
|
|
141
|
-
constructor(payload) {
|
|
142
|
-
super({ ...payload, status: 404 });
|
|
143
|
-
this.name = "GaleNotFoundError";
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
var GaleConflictError = class extends GaleError {
|
|
147
|
-
constructor(payload) {
|
|
148
|
-
super({ ...payload, status: 409 });
|
|
149
|
-
this.name = "GaleConflictError";
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
var GaleRateLimitError = class extends GaleError {
|
|
153
|
-
constructor(payload) {
|
|
154
|
-
super({ ...payload, status: 429 });
|
|
155
|
-
this.name = "GaleRateLimitError";
|
|
156
|
-
}
|
|
157
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_AUTH_CONFIG,
|
|
3
|
+
DEFAULT_CAPTCHA_SETTINGS,
|
|
4
|
+
UUID_V7_REGEX,
|
|
5
|
+
isUuidV7
|
|
6
|
+
} from "./chunk-DWPSHK7F.js";
|
|
7
|
+
import {
|
|
8
|
+
GaleAuthError,
|
|
9
|
+
GaleConflictError,
|
|
10
|
+
GaleError,
|
|
11
|
+
GaleNotFoundError,
|
|
12
|
+
GalePermissionError,
|
|
13
|
+
GaleRateLimitError,
|
|
14
|
+
GaleValidationError,
|
|
15
|
+
fapiErrorToGaleError,
|
|
16
|
+
isFapiErrorEnvelope,
|
|
17
|
+
networkErrorToGaleError
|
|
18
|
+
} from "./chunk-Y75EVVGQ.js";
|
|
158
19
|
|
|
159
20
|
// src/defaults.ts
|
|
160
21
|
var DEFAULT_ROOT_DOMAIN = "onered.net";
|
|
@@ -346,7 +207,8 @@ function parseSignInAttempt(json) {
|
|
|
346
207
|
supportedSecondFactors: json.supportedSecondFactors ?? [],
|
|
347
208
|
firstFactorVerification: json.firstFactorVerification ?? null,
|
|
348
209
|
secondFactorVerification: json.secondFactorVerification ?? null,
|
|
349
|
-
createdSessionId: json.createdSessionId ?? null
|
|
210
|
+
createdSessionId: json.createdSessionId ?? null,
|
|
211
|
+
secondFactorEnrollmentRecommended: json.secondFactorEnrollmentRecommended ?? false
|
|
350
212
|
};
|
|
351
213
|
}
|
|
352
214
|
function parseSignInResponse(json) {
|
|
File without changes
|