@haatlabs-core/auth-contracts 0.0.0-stage → 0.10.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/LICENSE +201 -0
- package/README.md +15 -2
- package/dist/api-keys.d.ts +38 -0
- package/dist/api-keys.js +14 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/auth.d.ts +142 -0
- package/dist/auth.js +84 -0
- package/dist/auth.js.map +1 -0
- package/dist/cjs/api-keys.d.ts +38 -0
- package/dist/cjs/api-keys.js +44 -0
- package/dist/cjs/auth.d.ts +142 -0
- package/dist/cjs/auth.js +106 -0
- package/dist/cjs/extension-keys.d.ts +45 -0
- package/dist/cjs/extension-keys.js +56 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +8 -0
- package/dist/extension-keys.d.ts +45 -0
- package/dist/extension-keys.js +26 -0
- package/dist/extension-keys.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/package.json +51 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Haatlabs
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @haatlabs-core/auth-contracts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The request and response schemas of sign-in and API keys, shared by an app's API and its
|
|
4
|
+
web pages: roles and their rank, the sign-in code's length and lifetime, and the `me`
|
|
5
|
+
response. An app adds its own `me` fields:
|
|
6
|
+
|
|
7
|
+
import { meResponseSchema } from '@haatlabs-core/auth-contracts';
|
|
8
|
+
export const MeResponseSchema = meResponseSchema({ features: AccountFeaturesSchema });
|
|
9
|
+
|
|
10
|
+
`zod` is a peer: the app's own copy is used.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
pnpm add @haatlabs-core/auth-contracts
|
|
15
|
+
|
|
16
|
+
It leaves one package to your app, so the app holds one copy: `zod`.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CreateApiKeyRequestSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
export type CreateApiKeyRequest = z.infer<typeof CreateApiKeyRequestSchema>;
|
|
6
|
+
export declare const ApiKeySchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodUUID;
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
prefix: z.ZodString;
|
|
10
|
+
createdAt: z.ZodISODateTime;
|
|
11
|
+
lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
12
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type ApiKey = z.infer<typeof ApiKeySchema>;
|
|
15
|
+
/** The full key is returned exactly once, at creation. */
|
|
16
|
+
export declare const CreateApiKeyResponseSchema: z.ZodObject<{
|
|
17
|
+
apiKey: z.ZodObject<{
|
|
18
|
+
id: z.ZodUUID;
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
prefix: z.ZodString;
|
|
21
|
+
createdAt: z.ZodISODateTime;
|
|
22
|
+
lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
23
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
key: z.ZodString;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type CreateApiKeyResponse = z.infer<typeof CreateApiKeyResponseSchema>;
|
|
28
|
+
export declare const ApiKeyListResponseSchema: z.ZodObject<{
|
|
29
|
+
apiKeys: z.ZodArray<z.ZodObject<{
|
|
30
|
+
id: z.ZodUUID;
|
|
31
|
+
name: z.ZodString;
|
|
32
|
+
prefix: z.ZodString;
|
|
33
|
+
createdAt: z.ZodISODateTime;
|
|
34
|
+
lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
35
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type ApiKeyListResponse = z.infer<typeof ApiKeyListResponseSchema>;
|
package/dist/api-keys.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const CreateApiKeyRequestSchema = z.object({ name: z.string().trim().min(1).max(80) });
|
|
3
|
+
export const ApiKeySchema = z.object({
|
|
4
|
+
id: z.uuid(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
prefix: z.string(),
|
|
7
|
+
createdAt: z.iso.datetime(),
|
|
8
|
+
lastUsedAt: z.iso.datetime().nullable(),
|
|
9
|
+
revokedAt: z.iso.datetime().nullable(),
|
|
10
|
+
});
|
|
11
|
+
/** The full key is returned exactly once, at creation. */
|
|
12
|
+
export const CreateApiKeyResponseSchema = z.object({ apiKey: ApiKeySchema, key: z.string() });
|
|
13
|
+
export const ApiKeyListResponseSchema = z.object({ apiKeys: z.array(ApiKeySchema) });
|
|
14
|
+
//# sourceMappingURL=api-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../src/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAG9F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE;IACZ,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;IAC3B,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACvC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAC;AAGH,0DAA0D;AAC1D,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAG9F,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC"}
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const Role: {
|
|
3
|
+
readonly OWNER: "OWNER";
|
|
4
|
+
readonly ADMIN: "ADMIN";
|
|
5
|
+
readonly MEMBER: "MEMBER";
|
|
6
|
+
readonly VIEWER: "VIEWER";
|
|
7
|
+
};
|
|
8
|
+
export type Role = (typeof Role)[keyof typeof Role];
|
|
9
|
+
export declare const ROLE_RANK: Record<Role, number>;
|
|
10
|
+
/** A platform administrator's sign-in: the only one that still uses a password. */
|
|
11
|
+
export declare const LoginRequestSchema: z.ZodObject<{
|
|
12
|
+
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
|
|
13
|
+
password: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type LoginRequest = z.infer<typeof LoginRequestSchema>;
|
|
16
|
+
/**
|
|
17
|
+
* How long a sign-in code is. Eight digits, not six: a code can be guessed at from any
|
|
18
|
+
* number of addresses, a few guesses for each one sent, and across every account at once.
|
|
19
|
+
* A hundred million codes keep that hopeless where a million would not.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SIGN_IN_CODE_DIGITS = 8;
|
|
22
|
+
export declare const SIGN_IN_CODE_MINUTES = 10;
|
|
23
|
+
/** Asks for a sign-in code to be sent. Answered the same whether or not the email has an account. */
|
|
24
|
+
export declare const SignInCodeRequestSchema: z.ZodObject<{
|
|
25
|
+
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
export type SignInCodeRequest = z.infer<typeof SignInCodeRequestSchema>;
|
|
28
|
+
/**
|
|
29
|
+
* Signs in with the code that was sent. An email with no account gets one, with an
|
|
30
|
+
* organization of its own: holding the code proves the address is theirs.
|
|
31
|
+
*/
|
|
32
|
+
export declare const SignInVerifyRequestSchema: z.ZodObject<{
|
|
33
|
+
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
|
|
34
|
+
code: z.ZodString;
|
|
35
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strict>;
|
|
37
|
+
export type SignInVerifyRequest = z.infer<typeof SignInVerifyRequestSchema>;
|
|
38
|
+
/** The email a store installed from Shopify gives its owner to sign in with. */
|
|
39
|
+
export declare const EmailSignInCodeRequestSchema: z.ZodObject<{
|
|
40
|
+
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
|
|
41
|
+
}, z.core.$strict>;
|
|
42
|
+
export type EmailSignInCodeRequest = z.infer<typeof EmailSignInCodeRequestSchema>;
|
|
43
|
+
/** The same email with the code sent to it, which proves it reaches the person setting it. */
|
|
44
|
+
export declare const EmailSignInRequestSchema: z.ZodObject<{
|
|
45
|
+
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
|
|
46
|
+
code: z.ZodString;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
export type EmailSignInRequest = z.infer<typeof EmailSignInRequestSchema>;
|
|
49
|
+
export declare const EmailSignInResponseSchema: z.ZodObject<{
|
|
50
|
+
email: z.ZodNullable<z.ZodString>;
|
|
51
|
+
dashboardUrl: z.ZodString;
|
|
52
|
+
canCreate: z.ZodBoolean;
|
|
53
|
+
suggestedEmail: z.ZodNullable<z.ZodString>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
export type EmailSignInResponse = z.infer<typeof EmailSignInResponseSchema>;
|
|
56
|
+
/**
|
|
57
|
+
* Who is signed in, as every app answers it. An app adds its own fields with
|
|
58
|
+
* `meResponseSchema`.
|
|
59
|
+
*/
|
|
60
|
+
export declare const BaseMeResponseSchema: z.ZodObject<{
|
|
61
|
+
user: z.ZodNullable<z.ZodObject<{
|
|
62
|
+
id: z.ZodUUID;
|
|
63
|
+
email: z.ZodNullable<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
organization: z.ZodObject<{
|
|
66
|
+
id: z.ZodUUID;
|
|
67
|
+
name: z.ZodString;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
role: z.ZodEnum<{
|
|
70
|
+
readonly OWNER: "OWNER";
|
|
71
|
+
readonly ADMIN: "ADMIN";
|
|
72
|
+
readonly MEMBER: "MEMBER";
|
|
73
|
+
readonly VIEWER: "VIEWER";
|
|
74
|
+
}>;
|
|
75
|
+
via: z.ZodEnum<{
|
|
76
|
+
session: "session";
|
|
77
|
+
embedded: "embedded";
|
|
78
|
+
api_key: "api_key";
|
|
79
|
+
}>;
|
|
80
|
+
csrfToken: z.ZodNullable<z.ZodString>;
|
|
81
|
+
storeOnly: z.ZodDefault<z.ZodBoolean>;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
export type BaseMeResponse = z.infer<typeof BaseMeResponseSchema>;
|
|
84
|
+
/** The shared fields of `me` with the app's own on top. */
|
|
85
|
+
export declare function meResponseSchema<S extends z.ZodRawShape>(extras: S): z.ZodObject<(("user" | "organization" | "role" | "via" | "csrfToken" | "storeOnly") & keyof S extends never ? {
|
|
86
|
+
user: z.ZodNullable<z.ZodObject<{
|
|
87
|
+
id: z.ZodUUID;
|
|
88
|
+
email: z.ZodNullable<z.ZodString>;
|
|
89
|
+
}, z.core.$strip>>;
|
|
90
|
+
organization: z.ZodObject<{
|
|
91
|
+
id: z.ZodUUID;
|
|
92
|
+
name: z.ZodString;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
role: z.ZodEnum<{
|
|
95
|
+
readonly OWNER: "OWNER";
|
|
96
|
+
readonly ADMIN: "ADMIN";
|
|
97
|
+
readonly MEMBER: "MEMBER";
|
|
98
|
+
readonly VIEWER: "VIEWER";
|
|
99
|
+
}>;
|
|
100
|
+
via: z.ZodEnum<{
|
|
101
|
+
session: "session";
|
|
102
|
+
embedded: "embedded";
|
|
103
|
+
api_key: "api_key";
|
|
104
|
+
}>;
|
|
105
|
+
csrfToken: z.ZodNullable<z.ZodString>;
|
|
106
|
+
storeOnly: z.ZodDefault<z.ZodBoolean>;
|
|
107
|
+
} & { -readonly [P in keyof S]: S[P]; } : ({
|
|
108
|
+
user: z.ZodNullable<z.ZodObject<{
|
|
109
|
+
id: z.ZodUUID;
|
|
110
|
+
email: z.ZodNullable<z.ZodString>;
|
|
111
|
+
}, z.core.$strip>>;
|
|
112
|
+
organization: z.ZodObject<{
|
|
113
|
+
id: z.ZodUUID;
|
|
114
|
+
name: z.ZodString;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
role: z.ZodEnum<{
|
|
117
|
+
readonly OWNER: "OWNER";
|
|
118
|
+
readonly ADMIN: "ADMIN";
|
|
119
|
+
readonly MEMBER: "MEMBER";
|
|
120
|
+
readonly VIEWER: "VIEWER";
|
|
121
|
+
}>;
|
|
122
|
+
via: z.ZodEnum<{
|
|
123
|
+
session: "session";
|
|
124
|
+
embedded: "embedded";
|
|
125
|
+
api_key: "api_key";
|
|
126
|
+
}>;
|
|
127
|
+
csrfToken: z.ZodNullable<z.ZodString>;
|
|
128
|
+
storeOnly: z.ZodDefault<z.ZodBoolean>;
|
|
129
|
+
} extends infer T_1 extends z.core.util.SomeObject ? { [K in keyof T_1 as K extends keyof S ? never : K]: T_1[K]; } : never) & { [K_1 in keyof { -readonly [P in keyof S]: S[P]; }]: { -readonly [P in keyof S]: S[P]; }[K_1]; }) extends infer T ? { [k in keyof T]: T[k]; } : never, z.core.$strip>;
|
|
130
|
+
/** A platform administrator's sign-in. */
|
|
131
|
+
export declare const AdminLoginRequestSchema: z.ZodObject<{
|
|
132
|
+
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
|
|
133
|
+
password: z.ZodString;
|
|
134
|
+
}, z.core.$strip>;
|
|
135
|
+
export type AdminLoginRequest = z.infer<typeof AdminLoginRequestSchema>;
|
|
136
|
+
/** The platform administrator who is signed in. Not a merchant's user. */
|
|
137
|
+
export declare const AdminMeSchema: z.ZodObject<{
|
|
138
|
+
id: z.ZodUUID;
|
|
139
|
+
email: z.ZodString;
|
|
140
|
+
csrfToken: z.ZodString;
|
|
141
|
+
}, z.core.$strip>;
|
|
142
|
+
export type AdminMe = z.infer<typeof AdminMeSchema>;
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const Role = { OWNER: 'OWNER', ADMIN: 'ADMIN', MEMBER: 'MEMBER', VIEWER: 'VIEWER' };
|
|
3
|
+
export const ROLE_RANK = { VIEWER: 0, MEMBER: 1, ADMIN: 2, OWNER: 3 };
|
|
4
|
+
const MAX_PASSWORD_LENGTH = 200;
|
|
5
|
+
/** A platform administrator's sign-in: the only one that still uses a password. */
|
|
6
|
+
export const LoginRequestSchema = z.object({
|
|
7
|
+
email: z
|
|
8
|
+
.email()
|
|
9
|
+
.max(320)
|
|
10
|
+
.transform((value) => value.toLowerCase()),
|
|
11
|
+
password: z.string().min(1).max(MAX_PASSWORD_LENGTH),
|
|
12
|
+
});
|
|
13
|
+
const email = z
|
|
14
|
+
.email()
|
|
15
|
+
.max(320)
|
|
16
|
+
.transform((value) => value.toLowerCase());
|
|
17
|
+
/**
|
|
18
|
+
* How long a sign-in code is. Eight digits, not six: a code can be guessed at from any
|
|
19
|
+
* number of addresses, a few guesses for each one sent, and across every account at once.
|
|
20
|
+
* A hundred million codes keep that hopeless where a million would not.
|
|
21
|
+
*/
|
|
22
|
+
export const SIGN_IN_CODE_DIGITS = 8;
|
|
23
|
+
export const SIGN_IN_CODE_MINUTES = 10;
|
|
24
|
+
/** Digits only, sent to the email address; it works once and for ten minutes. */
|
|
25
|
+
const code = z
|
|
26
|
+
.string()
|
|
27
|
+
.regex(new RegExp(`^\\d{${SIGN_IN_CODE_DIGITS}}$`), `The code is ${SIGN_IN_CODE_DIGITS} digits`);
|
|
28
|
+
/** Asks for a sign-in code to be sent. Answered the same whether or not the email has an account. */
|
|
29
|
+
export const SignInCodeRequestSchema = z.strictObject({ email });
|
|
30
|
+
/**
|
|
31
|
+
* Signs in with the code that was sent. An email with no account gets one, with an
|
|
32
|
+
* organization of its own: holding the code proves the address is theirs.
|
|
33
|
+
*/
|
|
34
|
+
export const SignInVerifyRequestSchema = z.strictObject({
|
|
35
|
+
email,
|
|
36
|
+
code,
|
|
37
|
+
/** For a new account: what to call its organization. Left out: the email address. */
|
|
38
|
+
organizationName: z.string().trim().min(1).max(120).optional(),
|
|
39
|
+
});
|
|
40
|
+
/** The email a store installed from Shopify gives its owner to sign in with. */
|
|
41
|
+
export const EmailSignInCodeRequestSchema = z.strictObject({ email });
|
|
42
|
+
/** The same email with the code sent to it, which proves it reaches the person setting it. */
|
|
43
|
+
export const EmailSignInRequestSchema = z.strictObject({ email, code });
|
|
44
|
+
export const EmailSignInResponseSchema = z.object({
|
|
45
|
+
/** Null until the store's owner has been given one. */
|
|
46
|
+
email: z.string().nullable(),
|
|
47
|
+
/** Where that email signs in. */
|
|
48
|
+
dashboardUrl: z.string(),
|
|
49
|
+
/** Whether the person asking may create it: there is none yet and they own the store. */
|
|
50
|
+
canCreate: z.boolean(),
|
|
51
|
+
/** The email Shopify has verified for them, to start the form with. */
|
|
52
|
+
suggestedEmail: z.string().nullable(),
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* Who is signed in, as every app answers it. An app adds its own fields with
|
|
56
|
+
* `meResponseSchema`.
|
|
57
|
+
*/
|
|
58
|
+
export const BaseMeResponseSchema = z.object({
|
|
59
|
+
user: z.object({ id: z.uuid(), email: z.string().nullable() }).nullable(),
|
|
60
|
+
organization: z.object({ id: z.uuid(), name: z.string() }),
|
|
61
|
+
role: z.enum(Role),
|
|
62
|
+
via: z.enum(['session', 'embedded', 'api_key']),
|
|
63
|
+
csrfToken: z.string().nullable(),
|
|
64
|
+
/**
|
|
65
|
+
* Inside Shopify admin, for a store connected from a dashboard account: only the store is
|
|
66
|
+
* reachable, not what is the whole organization's, and `organization.name` is the
|
|
67
|
+
* store's. A server from before says nothing: false.
|
|
68
|
+
*/
|
|
69
|
+
storeOnly: z.boolean().default(false),
|
|
70
|
+
});
|
|
71
|
+
/** The shared fields of `me` with the app's own on top. */
|
|
72
|
+
export function meResponseSchema(extras) {
|
|
73
|
+
return BaseMeResponseSchema.extend(extras);
|
|
74
|
+
}
|
|
75
|
+
/** A platform administrator's sign-in. */
|
|
76
|
+
export const AdminLoginRequestSchema = LoginRequestSchema;
|
|
77
|
+
/** The platform administrator who is signed in. Not a merchant's user. */
|
|
78
|
+
export const AdminMeSchema = z.object({
|
|
79
|
+
id: z.uuid(),
|
|
80
|
+
email: z.string(),
|
|
81
|
+
/** Sent back in a header with every request that changes something. */
|
|
82
|
+
csrfToken: z.string(),
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CreateApiKeyRequestSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
export type CreateApiKeyRequest = z.infer<typeof CreateApiKeyRequestSchema>;
|
|
6
|
+
export declare const ApiKeySchema: z.ZodObject<{
|
|
7
|
+
id: z.ZodUUID;
|
|
8
|
+
name: z.ZodString;
|
|
9
|
+
prefix: z.ZodString;
|
|
10
|
+
createdAt: z.ZodISODateTime;
|
|
11
|
+
lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
12
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type ApiKey = z.infer<typeof ApiKeySchema>;
|
|
15
|
+
/** The full key is returned exactly once, at creation. */
|
|
16
|
+
export declare const CreateApiKeyResponseSchema: z.ZodObject<{
|
|
17
|
+
apiKey: z.ZodObject<{
|
|
18
|
+
id: z.ZodUUID;
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
prefix: z.ZodString;
|
|
21
|
+
createdAt: z.ZodISODateTime;
|
|
22
|
+
lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
23
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
key: z.ZodString;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type CreateApiKeyResponse = z.infer<typeof CreateApiKeyResponseSchema>;
|
|
28
|
+
export declare const ApiKeyListResponseSchema: z.ZodObject<{
|
|
29
|
+
apiKeys: z.ZodArray<z.ZodObject<{
|
|
30
|
+
id: z.ZodUUID;
|
|
31
|
+
name: z.ZodString;
|
|
32
|
+
prefix: z.ZodString;
|
|
33
|
+
createdAt: z.ZodISODateTime;
|
|
34
|
+
lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
35
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type ApiKeyListResponse = z.infer<typeof ApiKeyListResponseSchema>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var api_keys_exports = {};
|
|
19
|
+
__export(api_keys_exports, {
|
|
20
|
+
ApiKeyListResponseSchema: () => ApiKeyListResponseSchema,
|
|
21
|
+
ApiKeySchema: () => ApiKeySchema,
|
|
22
|
+
CreateApiKeyRequestSchema: () => CreateApiKeyRequestSchema,
|
|
23
|
+
CreateApiKeyResponseSchema: () => CreateApiKeyResponseSchema
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(api_keys_exports);
|
|
26
|
+
var import_zod = require("zod");
|
|
27
|
+
const CreateApiKeyRequestSchema = import_zod.z.object({ name: import_zod.z.string().trim().min(1).max(80) });
|
|
28
|
+
const ApiKeySchema = import_zod.z.object({
|
|
29
|
+
id: import_zod.z.uuid(),
|
|
30
|
+
name: import_zod.z.string(),
|
|
31
|
+
prefix: import_zod.z.string(),
|
|
32
|
+
createdAt: import_zod.z.iso.datetime(),
|
|
33
|
+
lastUsedAt: import_zod.z.iso.datetime().nullable(),
|
|
34
|
+
revokedAt: import_zod.z.iso.datetime().nullable()
|
|
35
|
+
});
|
|
36
|
+
const CreateApiKeyResponseSchema = import_zod.z.object({ apiKey: ApiKeySchema, key: import_zod.z.string() });
|
|
37
|
+
const ApiKeyListResponseSchema = import_zod.z.object({ apiKeys: import_zod.z.array(ApiKeySchema) });
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
ApiKeyListResponseSchema,
|
|
41
|
+
ApiKeySchema,
|
|
42
|
+
CreateApiKeyRequestSchema,
|
|
43
|
+
CreateApiKeyResponseSchema
|
|
44
|
+
});
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const Role: {
|
|
3
|
+
readonly OWNER: "OWNER";
|
|
4
|
+
readonly ADMIN: "ADMIN";
|
|
5
|
+
readonly MEMBER: "MEMBER";
|
|
6
|
+
readonly VIEWER: "VIEWER";
|
|
7
|
+
};
|
|
8
|
+
export type Role = (typeof Role)[keyof typeof Role];
|
|
9
|
+
export declare const ROLE_RANK: Record<Role, number>;
|
|
10
|
+
/** A platform administrator's sign-in: the only one that still uses a password. */
|
|
11
|
+
export declare const LoginRequestSchema: z.ZodObject<{
|
|
12
|
+
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
|
|
13
|
+
password: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type LoginRequest = z.infer<typeof LoginRequestSchema>;
|
|
16
|
+
/**
|
|
17
|
+
* How long a sign-in code is. Eight digits, not six: a code can be guessed at from any
|
|
18
|
+
* number of addresses, a few guesses for each one sent, and across every account at once.
|
|
19
|
+
* A hundred million codes keep that hopeless where a million would not.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SIGN_IN_CODE_DIGITS = 8;
|
|
22
|
+
export declare const SIGN_IN_CODE_MINUTES = 10;
|
|
23
|
+
/** Asks for a sign-in code to be sent. Answered the same whether or not the email has an account. */
|
|
24
|
+
export declare const SignInCodeRequestSchema: z.ZodObject<{
|
|
25
|
+
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
|
|
26
|
+
}, z.core.$strict>;
|
|
27
|
+
export type SignInCodeRequest = z.infer<typeof SignInCodeRequestSchema>;
|
|
28
|
+
/**
|
|
29
|
+
* Signs in with the code that was sent. An email with no account gets one, with an
|
|
30
|
+
* organization of its own: holding the code proves the address is theirs.
|
|
31
|
+
*/
|
|
32
|
+
export declare const SignInVerifyRequestSchema: z.ZodObject<{
|
|
33
|
+
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
|
|
34
|
+
code: z.ZodString;
|
|
35
|
+
organizationName: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strict>;
|
|
37
|
+
export type SignInVerifyRequest = z.infer<typeof SignInVerifyRequestSchema>;
|
|
38
|
+
/** The email a store installed from Shopify gives its owner to sign in with. */
|
|
39
|
+
export declare const EmailSignInCodeRequestSchema: z.ZodObject<{
|
|
40
|
+
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
|
|
41
|
+
}, z.core.$strict>;
|
|
42
|
+
export type EmailSignInCodeRequest = z.infer<typeof EmailSignInCodeRequestSchema>;
|
|
43
|
+
/** The same email with the code sent to it, which proves it reaches the person setting it. */
|
|
44
|
+
export declare const EmailSignInRequestSchema: z.ZodObject<{
|
|
45
|
+
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
|
|
46
|
+
code: z.ZodString;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
export type EmailSignInRequest = z.infer<typeof EmailSignInRequestSchema>;
|
|
49
|
+
export declare const EmailSignInResponseSchema: z.ZodObject<{
|
|
50
|
+
email: z.ZodNullable<z.ZodString>;
|
|
51
|
+
dashboardUrl: z.ZodString;
|
|
52
|
+
canCreate: z.ZodBoolean;
|
|
53
|
+
suggestedEmail: z.ZodNullable<z.ZodString>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
export type EmailSignInResponse = z.infer<typeof EmailSignInResponseSchema>;
|
|
56
|
+
/**
|
|
57
|
+
* Who is signed in, as every app answers it. An app adds its own fields with
|
|
58
|
+
* `meResponseSchema`.
|
|
59
|
+
*/
|
|
60
|
+
export declare const BaseMeResponseSchema: z.ZodObject<{
|
|
61
|
+
user: z.ZodNullable<z.ZodObject<{
|
|
62
|
+
id: z.ZodUUID;
|
|
63
|
+
email: z.ZodNullable<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
organization: z.ZodObject<{
|
|
66
|
+
id: z.ZodUUID;
|
|
67
|
+
name: z.ZodString;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
role: z.ZodEnum<{
|
|
70
|
+
readonly OWNER: "OWNER";
|
|
71
|
+
readonly ADMIN: "ADMIN";
|
|
72
|
+
readonly MEMBER: "MEMBER";
|
|
73
|
+
readonly VIEWER: "VIEWER";
|
|
74
|
+
}>;
|
|
75
|
+
via: z.ZodEnum<{
|
|
76
|
+
session: "session";
|
|
77
|
+
embedded: "embedded";
|
|
78
|
+
api_key: "api_key";
|
|
79
|
+
}>;
|
|
80
|
+
csrfToken: z.ZodNullable<z.ZodString>;
|
|
81
|
+
storeOnly: z.ZodDefault<z.ZodBoolean>;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
export type BaseMeResponse = z.infer<typeof BaseMeResponseSchema>;
|
|
84
|
+
/** The shared fields of `me` with the app's own on top. */
|
|
85
|
+
export declare function meResponseSchema<S extends z.ZodRawShape>(extras: S): z.ZodObject<(("user" | "organization" | "role" | "via" | "csrfToken" | "storeOnly") & keyof S extends never ? {
|
|
86
|
+
user: z.ZodNullable<z.ZodObject<{
|
|
87
|
+
id: z.ZodUUID;
|
|
88
|
+
email: z.ZodNullable<z.ZodString>;
|
|
89
|
+
}, z.core.$strip>>;
|
|
90
|
+
organization: z.ZodObject<{
|
|
91
|
+
id: z.ZodUUID;
|
|
92
|
+
name: z.ZodString;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
role: z.ZodEnum<{
|
|
95
|
+
readonly OWNER: "OWNER";
|
|
96
|
+
readonly ADMIN: "ADMIN";
|
|
97
|
+
readonly MEMBER: "MEMBER";
|
|
98
|
+
readonly VIEWER: "VIEWER";
|
|
99
|
+
}>;
|
|
100
|
+
via: z.ZodEnum<{
|
|
101
|
+
session: "session";
|
|
102
|
+
embedded: "embedded";
|
|
103
|
+
api_key: "api_key";
|
|
104
|
+
}>;
|
|
105
|
+
csrfToken: z.ZodNullable<z.ZodString>;
|
|
106
|
+
storeOnly: z.ZodDefault<z.ZodBoolean>;
|
|
107
|
+
} & { -readonly [P in keyof S]: S[P]; } : ({
|
|
108
|
+
user: z.ZodNullable<z.ZodObject<{
|
|
109
|
+
id: z.ZodUUID;
|
|
110
|
+
email: z.ZodNullable<z.ZodString>;
|
|
111
|
+
}, z.core.$strip>>;
|
|
112
|
+
organization: z.ZodObject<{
|
|
113
|
+
id: z.ZodUUID;
|
|
114
|
+
name: z.ZodString;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
role: z.ZodEnum<{
|
|
117
|
+
readonly OWNER: "OWNER";
|
|
118
|
+
readonly ADMIN: "ADMIN";
|
|
119
|
+
readonly MEMBER: "MEMBER";
|
|
120
|
+
readonly VIEWER: "VIEWER";
|
|
121
|
+
}>;
|
|
122
|
+
via: z.ZodEnum<{
|
|
123
|
+
session: "session";
|
|
124
|
+
embedded: "embedded";
|
|
125
|
+
api_key: "api_key";
|
|
126
|
+
}>;
|
|
127
|
+
csrfToken: z.ZodNullable<z.ZodString>;
|
|
128
|
+
storeOnly: z.ZodDefault<z.ZodBoolean>;
|
|
129
|
+
} extends infer T_1 extends z.core.util.SomeObject ? { [K in keyof T_1 as K extends keyof S ? never : K]: T_1[K]; } : never) & { [K_1 in keyof { -readonly [P in keyof S]: S[P]; }]: { -readonly [P in keyof S]: S[P]; }[K_1]; }) extends infer T ? { [k in keyof T]: T[k]; } : never, z.core.$strip>;
|
|
130
|
+
/** A platform administrator's sign-in. */
|
|
131
|
+
export declare const AdminLoginRequestSchema: z.ZodObject<{
|
|
132
|
+
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
|
|
133
|
+
password: z.ZodString;
|
|
134
|
+
}, z.core.$strip>;
|
|
135
|
+
export type AdminLoginRequest = z.infer<typeof AdminLoginRequestSchema>;
|
|
136
|
+
/** The platform administrator who is signed in. Not a merchant's user. */
|
|
137
|
+
export declare const AdminMeSchema: z.ZodObject<{
|
|
138
|
+
id: z.ZodUUID;
|
|
139
|
+
email: z.ZodString;
|
|
140
|
+
csrfToken: z.ZodString;
|
|
141
|
+
}, z.core.$strip>;
|
|
142
|
+
export type AdminMe = z.infer<typeof AdminMeSchema>;
|
package/dist/cjs/auth.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var auth_exports = {};
|
|
19
|
+
__export(auth_exports, {
|
|
20
|
+
AdminLoginRequestSchema: () => AdminLoginRequestSchema,
|
|
21
|
+
AdminMeSchema: () => AdminMeSchema,
|
|
22
|
+
BaseMeResponseSchema: () => BaseMeResponseSchema,
|
|
23
|
+
EmailSignInCodeRequestSchema: () => EmailSignInCodeRequestSchema,
|
|
24
|
+
EmailSignInRequestSchema: () => EmailSignInRequestSchema,
|
|
25
|
+
EmailSignInResponseSchema: () => EmailSignInResponseSchema,
|
|
26
|
+
LoginRequestSchema: () => LoginRequestSchema,
|
|
27
|
+
ROLE_RANK: () => ROLE_RANK,
|
|
28
|
+
Role: () => Role,
|
|
29
|
+
SIGN_IN_CODE_DIGITS: () => SIGN_IN_CODE_DIGITS,
|
|
30
|
+
SIGN_IN_CODE_MINUTES: () => SIGN_IN_CODE_MINUTES,
|
|
31
|
+
SignInCodeRequestSchema: () => SignInCodeRequestSchema,
|
|
32
|
+
SignInVerifyRequestSchema: () => SignInVerifyRequestSchema,
|
|
33
|
+
meResponseSchema: () => meResponseSchema
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(auth_exports);
|
|
36
|
+
var import_zod = require("zod");
|
|
37
|
+
const Role = { OWNER: "OWNER", ADMIN: "ADMIN", MEMBER: "MEMBER", VIEWER: "VIEWER" };
|
|
38
|
+
const ROLE_RANK = { VIEWER: 0, MEMBER: 1, ADMIN: 2, OWNER: 3 };
|
|
39
|
+
const MAX_PASSWORD_LENGTH = 200;
|
|
40
|
+
const LoginRequestSchema = import_zod.z.object({
|
|
41
|
+
email: import_zod.z.email().max(320).transform((value) => value.toLowerCase()),
|
|
42
|
+
password: import_zod.z.string().min(1).max(MAX_PASSWORD_LENGTH)
|
|
43
|
+
});
|
|
44
|
+
const email = import_zod.z.email().max(320).transform((value) => value.toLowerCase());
|
|
45
|
+
const SIGN_IN_CODE_DIGITS = 8;
|
|
46
|
+
const SIGN_IN_CODE_MINUTES = 10;
|
|
47
|
+
const code = import_zod.z.string().regex(new RegExp(`^\\d{${SIGN_IN_CODE_DIGITS}}$`), `The code is ${SIGN_IN_CODE_DIGITS} digits`);
|
|
48
|
+
const SignInCodeRequestSchema = import_zod.z.strictObject({ email });
|
|
49
|
+
const SignInVerifyRequestSchema = import_zod.z.strictObject({
|
|
50
|
+
email,
|
|
51
|
+
code,
|
|
52
|
+
/** For a new account: what to call its organization. Left out: the email address. */
|
|
53
|
+
organizationName: import_zod.z.string().trim().min(1).max(120).optional()
|
|
54
|
+
});
|
|
55
|
+
const EmailSignInCodeRequestSchema = import_zod.z.strictObject({ email });
|
|
56
|
+
const EmailSignInRequestSchema = import_zod.z.strictObject({ email, code });
|
|
57
|
+
const EmailSignInResponseSchema = import_zod.z.object({
|
|
58
|
+
/** Null until the store's owner has been given one. */
|
|
59
|
+
email: import_zod.z.string().nullable(),
|
|
60
|
+
/** Where that email signs in. */
|
|
61
|
+
dashboardUrl: import_zod.z.string(),
|
|
62
|
+
/** Whether the person asking may create it: there is none yet and they own the store. */
|
|
63
|
+
canCreate: import_zod.z.boolean(),
|
|
64
|
+
/** The email Shopify has verified for them, to start the form with. */
|
|
65
|
+
suggestedEmail: import_zod.z.string().nullable()
|
|
66
|
+
});
|
|
67
|
+
const BaseMeResponseSchema = import_zod.z.object({
|
|
68
|
+
user: import_zod.z.object({ id: import_zod.z.uuid(), email: import_zod.z.string().nullable() }).nullable(),
|
|
69
|
+
organization: import_zod.z.object({ id: import_zod.z.uuid(), name: import_zod.z.string() }),
|
|
70
|
+
role: import_zod.z.enum(Role),
|
|
71
|
+
via: import_zod.z.enum(["session", "embedded", "api_key"]),
|
|
72
|
+
csrfToken: import_zod.z.string().nullable(),
|
|
73
|
+
/**
|
|
74
|
+
* Inside Shopify admin, for a store connected from a dashboard account: only the store is
|
|
75
|
+
* reachable, not what is the whole organization's, and `organization.name` is the
|
|
76
|
+
* store's. A server from before says nothing: false.
|
|
77
|
+
*/
|
|
78
|
+
storeOnly: import_zod.z.boolean().default(false)
|
|
79
|
+
});
|
|
80
|
+
function meResponseSchema(extras) {
|
|
81
|
+
return BaseMeResponseSchema.extend(extras);
|
|
82
|
+
}
|
|
83
|
+
const AdminLoginRequestSchema = LoginRequestSchema;
|
|
84
|
+
const AdminMeSchema = import_zod.z.object({
|
|
85
|
+
id: import_zod.z.uuid(),
|
|
86
|
+
email: import_zod.z.string(),
|
|
87
|
+
/** Sent back in a header with every request that changes something. */
|
|
88
|
+
csrfToken: import_zod.z.string()
|
|
89
|
+
});
|
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
+
0 && (module.exports = {
|
|
92
|
+
AdminLoginRequestSchema,
|
|
93
|
+
AdminMeSchema,
|
|
94
|
+
BaseMeResponseSchema,
|
|
95
|
+
EmailSignInCodeRequestSchema,
|
|
96
|
+
EmailSignInRequestSchema,
|
|
97
|
+
EmailSignInResponseSchema,
|
|
98
|
+
LoginRequestSchema,
|
|
99
|
+
ROLE_RANK,
|
|
100
|
+
Role,
|
|
101
|
+
SIGN_IN_CODE_DIGITS,
|
|
102
|
+
SIGN_IN_CODE_MINUTES,
|
|
103
|
+
SignInCodeRequestSchema,
|
|
104
|
+
SignInVerifyRequestSchema,
|
|
105
|
+
meResponseSchema
|
|
106
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** A Chrome extension's id: 32 letters a to p. */
|
|
3
|
+
export declare const ExtensionIdSchema: z.ZodString;
|
|
4
|
+
export declare const CreateExtensionKeyRequestSchema: z.ZodObject<{
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
extensionId: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type CreateExtensionKeyRequest = z.infer<typeof CreateExtensionKeyRequestSchema>;
|
|
9
|
+
/** A key a browser extension acts with, as the person who connected it. */
|
|
10
|
+
export declare const ExtensionKeySchema: z.ZodObject<{
|
|
11
|
+
id: z.ZodUUID;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
extensionId: z.ZodString;
|
|
14
|
+
prefix: z.ZodString;
|
|
15
|
+
createdAt: z.ZodISODateTime;
|
|
16
|
+
lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
17
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type ExtensionKey = z.infer<typeof ExtensionKeySchema>;
|
|
20
|
+
/** The key itself is returned once, here, and never again. */
|
|
21
|
+
export declare const CreateExtensionKeyResponseSchema: z.ZodObject<{
|
|
22
|
+
extensionKey: z.ZodObject<{
|
|
23
|
+
id: z.ZodUUID;
|
|
24
|
+
name: z.ZodString;
|
|
25
|
+
extensionId: z.ZodString;
|
|
26
|
+
prefix: z.ZodString;
|
|
27
|
+
createdAt: z.ZodISODateTime;
|
|
28
|
+
lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
29
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
key: z.ZodString;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type CreateExtensionKeyResponse = z.infer<typeof CreateExtensionKeyResponseSchema>;
|
|
34
|
+
export declare const ExtensionKeyListResponseSchema: z.ZodObject<{
|
|
35
|
+
extensionKeys: z.ZodArray<z.ZodObject<{
|
|
36
|
+
id: z.ZodUUID;
|
|
37
|
+
name: z.ZodString;
|
|
38
|
+
extensionId: z.ZodString;
|
|
39
|
+
prefix: z.ZodString;
|
|
40
|
+
createdAt: z.ZodISODateTime;
|
|
41
|
+
lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
42
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export type ExtensionKeyListResponse = z.infer<typeof ExtensionKeyListResponseSchema>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var extension_keys_exports = {};
|
|
19
|
+
__export(extension_keys_exports, {
|
|
20
|
+
CreateExtensionKeyRequestSchema: () => CreateExtensionKeyRequestSchema,
|
|
21
|
+
CreateExtensionKeyResponseSchema: () => CreateExtensionKeyResponseSchema,
|
|
22
|
+
ExtensionIdSchema: () => ExtensionIdSchema,
|
|
23
|
+
ExtensionKeyListResponseSchema: () => ExtensionKeyListResponseSchema,
|
|
24
|
+
ExtensionKeySchema: () => ExtensionKeySchema
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(extension_keys_exports);
|
|
27
|
+
var import_zod = require("zod");
|
|
28
|
+
const ExtensionIdSchema = import_zod.z.string().regex(/^[a-p]{32}$/);
|
|
29
|
+
const CreateExtensionKeyRequestSchema = import_zod.z.object({
|
|
30
|
+
name: import_zod.z.string().trim().min(1).max(80),
|
|
31
|
+
extensionId: ExtensionIdSchema
|
|
32
|
+
});
|
|
33
|
+
const ExtensionKeySchema = import_zod.z.object({
|
|
34
|
+
id: import_zod.z.uuid(),
|
|
35
|
+
name: import_zod.z.string(),
|
|
36
|
+
extensionId: import_zod.z.string(),
|
|
37
|
+
prefix: import_zod.z.string(),
|
|
38
|
+
createdAt: import_zod.z.iso.datetime(),
|
|
39
|
+
lastUsedAt: import_zod.z.iso.datetime().nullable(),
|
|
40
|
+
revokedAt: import_zod.z.iso.datetime().nullable()
|
|
41
|
+
});
|
|
42
|
+
const CreateExtensionKeyResponseSchema = import_zod.z.object({
|
|
43
|
+
extensionKey: ExtensionKeySchema,
|
|
44
|
+
key: import_zod.z.string()
|
|
45
|
+
});
|
|
46
|
+
const ExtensionKeyListResponseSchema = import_zod.z.object({
|
|
47
|
+
extensionKeys: import_zod.z.array(ExtensionKeySchema)
|
|
48
|
+
});
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
CreateExtensionKeyRequestSchema,
|
|
52
|
+
CreateExtensionKeyResponseSchema,
|
|
53
|
+
ExtensionIdSchema,
|
|
54
|
+
ExtensionKeyListResponseSchema,
|
|
55
|
+
ExtensionKeySchema
|
|
56
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var index_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(index_exports);
|
|
17
|
+
__reExport(index_exports, require("./api-keys.js"), module.exports);
|
|
18
|
+
__reExport(index_exports, require("./auth.js"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./extension-keys.js"), module.exports);
|
|
20
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require("./api-keys.js"),
|
|
23
|
+
...require("./auth.js"),
|
|
24
|
+
...require("./extension-keys.js")
|
|
25
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** A Chrome extension's id: 32 letters a to p. */
|
|
3
|
+
export declare const ExtensionIdSchema: z.ZodString;
|
|
4
|
+
export declare const CreateExtensionKeyRequestSchema: z.ZodObject<{
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
extensionId: z.ZodString;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type CreateExtensionKeyRequest = z.infer<typeof CreateExtensionKeyRequestSchema>;
|
|
9
|
+
/** A key a browser extension acts with, as the person who connected it. */
|
|
10
|
+
export declare const ExtensionKeySchema: z.ZodObject<{
|
|
11
|
+
id: z.ZodUUID;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
extensionId: z.ZodString;
|
|
14
|
+
prefix: z.ZodString;
|
|
15
|
+
createdAt: z.ZodISODateTime;
|
|
16
|
+
lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
17
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export type ExtensionKey = z.infer<typeof ExtensionKeySchema>;
|
|
20
|
+
/** The key itself is returned once, here, and never again. */
|
|
21
|
+
export declare const CreateExtensionKeyResponseSchema: z.ZodObject<{
|
|
22
|
+
extensionKey: z.ZodObject<{
|
|
23
|
+
id: z.ZodUUID;
|
|
24
|
+
name: z.ZodString;
|
|
25
|
+
extensionId: z.ZodString;
|
|
26
|
+
prefix: z.ZodString;
|
|
27
|
+
createdAt: z.ZodISODateTime;
|
|
28
|
+
lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
29
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
key: z.ZodString;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export type CreateExtensionKeyResponse = z.infer<typeof CreateExtensionKeyResponseSchema>;
|
|
34
|
+
export declare const ExtensionKeyListResponseSchema: z.ZodObject<{
|
|
35
|
+
extensionKeys: z.ZodArray<z.ZodObject<{
|
|
36
|
+
id: z.ZodUUID;
|
|
37
|
+
name: z.ZodString;
|
|
38
|
+
extensionId: z.ZodString;
|
|
39
|
+
prefix: z.ZodString;
|
|
40
|
+
createdAt: z.ZodISODateTime;
|
|
41
|
+
lastUsedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
42
|
+
revokedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export type ExtensionKeyListResponse = z.infer<typeof ExtensionKeyListResponseSchema>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** A Chrome extension's id: 32 letters a to p. */
|
|
3
|
+
export const ExtensionIdSchema = z.string().regex(/^[a-p]{32}$/);
|
|
4
|
+
export const CreateExtensionKeyRequestSchema = z.object({
|
|
5
|
+
name: z.string().trim().min(1).max(80),
|
|
6
|
+
extensionId: ExtensionIdSchema,
|
|
7
|
+
});
|
|
8
|
+
/** A key a browser extension acts with, as the person who connected it. */
|
|
9
|
+
export const ExtensionKeySchema = z.object({
|
|
10
|
+
id: z.uuid(),
|
|
11
|
+
name: z.string(),
|
|
12
|
+
extensionId: z.string(),
|
|
13
|
+
prefix: z.string(),
|
|
14
|
+
createdAt: z.iso.datetime(),
|
|
15
|
+
lastUsedAt: z.iso.datetime().nullable(),
|
|
16
|
+
revokedAt: z.iso.datetime().nullable(),
|
|
17
|
+
});
|
|
18
|
+
/** The key itself is returned once, here, and never again. */
|
|
19
|
+
export const CreateExtensionKeyResponseSchema = z.object({
|
|
20
|
+
extensionKey: ExtensionKeySchema,
|
|
21
|
+
key: z.string(),
|
|
22
|
+
});
|
|
23
|
+
export const ExtensionKeyListResponseSchema = z.object({
|
|
24
|
+
extensionKeys: z.array(ExtensionKeySchema),
|
|
25
|
+
});
|
|
26
|
+
//# sourceMappingURL=extension-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-keys.js","sourceRoot":"","sources":["../src/extension-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,kDAAkD;AAClD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;AAEjE,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC,MAAM,CAAC;IACtD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;IACtC,WAAW,EAAE,iBAAiB;CAC/B,CAAC,CAAC;AAGH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE;IACZ,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE;IAC3B,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACvC,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAC;AAGH,8DAA8D;AAC9D,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,YAAY,EAAE,kBAAkB;IAChC,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;CAChB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,MAAM,CAAC;IACrD,aAAa,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC;CAC3C,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haatlabs-core/auth-contracts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"description": "Sign-in and API-key request and response schemas shared by an app's API and web pages.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"haatlabs"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://haatlabs.shop/docs/packages/auth-contracts/",
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=24"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/Haatlabs/haatlabs-platform.git",
|
|
17
|
+
"directory": "packages/auth-contracts"
|
|
18
|
+
},
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public",
|
|
21
|
+
"registry": "https://registry.npmjs.org"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/cjs/index.d.ts",
|
|
34
|
+
"default": "./dist/cjs/index.js"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"zod": "^4.6.5"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"zod": "^4.6.5",
|
|
43
|
+
"@haatlabs-core/tsconfig": "0.10.0",
|
|
44
|
+
"@haatlabs-core/vitest-config": "0.10.0"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && node ../../scripts/build-cjs.mjs",
|
|
48
|
+
"typecheck": "tsc --noEmit",
|
|
49
|
+
"test": "vitest run --typecheck",
|
|
50
|
+
"check:package": "publint --strict && attw --pack . --profile node16"
|
|
51
|
+
},
|
|
52
|
+
"platformRegistry": "npm"
|
|
53
|
+
}
|