@unisim/sdk 0.141.6 → 0.141.8
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/README.md +95 -3
- package/android/src/main/AndroidManifest.xml +24 -0
- package/android/src/main/java/uk/co/unisim/sdk/OAuthCallbackActivity.java +72 -0
- package/android/src/main/java/uk/co/unisim/sdk/UnisimSuiteAuthPlugin.java +129 -0
- package/dist/DeleteAccountDialog.d.ts +12 -0
- package/dist/DeleteAccountDialog.d.ts.map +1 -0
- package/dist/DeleteAccountDialog.js +185 -0
- package/dist/DeleteAccountDialog.js.map +1 -0
- package/dist/SignInDialog.d.ts.map +1 -1
- package/dist/SignInDialog.js +49 -3
- package/dist/SignInDialog.js.map +1 -1
- package/dist/UniversalAppsNavBar.d.ts +8 -1
- package/dist/UniversalAppsNavBar.d.ts.map +1 -1
- package/dist/UniversalAppsNavBar.js +2 -2
- package/dist/UniversalAppsNavBar.js.map +1 -1
- package/dist/UserProfile.d.ts +22 -1
- package/dist/UserProfile.d.ts.map +1 -1
- package/dist/UserProfile.js +26 -4
- package/dist/UserProfile.js.map +1 -1
- package/dist/deleteAccount.d.ts +32 -0
- package/dist/deleteAccount.d.ts.map +1 -0
- package/dist/deleteAccount.js +61 -0
- package/dist/deleteAccount.js.map +1 -0
- package/dist/deleteAccountCopy.d.ts +22 -0
- package/dist/deleteAccountCopy.d.ts.map +1 -0
- package/dist/deleteAccountCopy.js +217 -0
- package/dist/deleteAccountCopy.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/nativeOAuth.d.ts +208 -0
- package/dist/nativeOAuth.d.ts.map +1 -0
- package/dist/nativeOAuth.js +372 -0
- package/dist/nativeOAuth.js.map +1 -0
- package/dist/oauth.d.ts +6 -0
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +9 -1
- package/dist/oauth.js.map +1 -1
- package/ios/Sources/UnisimSuiteAuthPlugin/SuiteOAuth.swift +257 -0
- package/ios/Sources/UnisimSuiteAuthPlugin/UnisimSuiteAuthPlugin.swift +14 -1
- package/package.json +3 -1
package/dist/oauth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAoDZ;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAA6B,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;AAErF,8DAA8D;AAC9D,MAAM,UAAU,kBAAkB,CAAC,QAAuB;IACxD,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,WAAW,CAAA;IAC5C,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,OAAO,CAAA;IACxC,OAAO,QAAQ,CAAA;AACjB,CAAC;AAmCD;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAuB,EACvB,IAAa;IAEb,MAAM,KAAK,GAAG,IAAI,EAAE,IAAI,EAAE,CAAA;IAC1B,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,SAAS,CAAA;IAC5E,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAA;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAkB,EAClB,QAAuB,EACvB,UAA6B,EAAE;IAE/B,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,iBAAiB,EAAE,CAAA;IAC5D,MAAM,WAAW,GAAG,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;IAEhE,IAAI,SAAS,GAAG,KAAK,CAAA;IACrB,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;QAC7B,MAAM,EAAE,IA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AAG,CAAC,CAAA;IAC5F,GAAG,CAAC,IAAI,GAAG,EAAE,CAAA;IACb,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAA;AACvB,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,MAAM,CAAC,GAAG,KAA6D,CAAA;IACvE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,IAAI,gBAAgB,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,IAAI,IAAI,EAAE,CAAA;AAC3E,CAAC"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import AuthenticationServices
|
|
3
|
+
import CryptoKit
|
|
4
|
+
import Capacitor
|
|
5
|
+
import Security
|
|
6
|
+
import UIKit
|
|
7
|
+
import WebKit
|
|
8
|
+
|
|
9
|
+
/// Apple / Google / Microsoft sign-in for the suite's Capacitor apps — the iOS
|
|
10
|
+
/// half of `src/nativeOAuth.ts`, exposed as three methods on
|
|
11
|
+
/// `UnisimSuiteAuthPlugin` (see the note there on why not a plugin of its own).
|
|
12
|
+
///
|
|
13
|
+
/// Two mechanisms, because Apple and the others are held to different rules:
|
|
14
|
+
///
|
|
15
|
+
/// • **Google / Microsoft → `ASWebAuthenticationSession`.** The system's own
|
|
16
|
+
/// sign-in sheet: Safari's engine and cookies, not our WKWebView, which is
|
|
17
|
+
/// what Google insists on (it answers an embedded web view with
|
|
18
|
+
/// `403 disallowed_useragent`). The session watches for the app's callback
|
|
19
|
+
/// scheme and hands the URL straight back to us — iOS never routes it
|
|
20
|
+
/// through `CFBundleURLTypes`, so no other app can intercept it and no
|
|
21
|
+
/// Info.plist entry is needed.
|
|
22
|
+
///
|
|
23
|
+
/// • **Apple → `ASAuthorizationAppleIDProvider`.** The native sheet (Face ID,
|
|
24
|
+
/// no password), which App Review expects of an iPhone app. Its identity
|
|
25
|
+
/// token goes to Supabase's id_token grant. The nonce is minted here, sent to
|
|
26
|
+
/// Apple as its SHA-256 and returned RAW to JS, which is the pairing Supabase
|
|
27
|
+
/// checks.
|
|
28
|
+
///
|
|
29
|
+
/// ⚠️ **The callback scheme is the bundle id, lower-cased** —
|
|
30
|
+
/// `uk.co.unisim.qr://auth-callback`. It is derived at runtime rather than
|
|
31
|
+
/// configured so thirteen apps cannot carry thirteen typos, and it must appear
|
|
32
|
+
/// VERBATIM on the Supabase redirect allowlist. When it is missing there,
|
|
33
|
+
/// GoTrue silently sends the browser to the project's Site URL instead, and
|
|
34
|
+
/// the sheet simply sits on a web page and never comes back.
|
|
35
|
+
///
|
|
36
|
+
/// ⚠️ **Sign in with Apple needs the `com.apple.developer.applesignin`
|
|
37
|
+
/// entitlement** (`scripts/add-sign-in-with-apple.mjs`) AND the capability on
|
|
38
|
+
/// the App ID. Without the entitlement the sheet fails with
|
|
39
|
+
/// `ASAuthorizationError.unknown` (1000) — the same code a simulator with no
|
|
40
|
+
/// Apple ID signed in gets — so the rejection message says both.
|
|
41
|
+
final class SuiteOAuthCoordinator: NSObject,
|
|
42
|
+
ASWebAuthenticationPresentationContextProviding,
|
|
43
|
+
ASAuthorizationControllerDelegate,
|
|
44
|
+
ASAuthorizationControllerPresentationContextProviding {
|
|
45
|
+
|
|
46
|
+
static let callbackHost = "auth-callback"
|
|
47
|
+
|
|
48
|
+
/// This app's callback scheme: its bundle id, lower-cased. URL schemes are
|
|
49
|
+
/// case-insensitive but the allowlist comparison is not.
|
|
50
|
+
static var callbackScheme: String {
|
|
51
|
+
(Bundle.main.bundleIdentifier ?? "").lowercased()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static var callbackURL: String {
|
|
55
|
+
"\(callbackScheme)://\(callbackHost)"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private weak var plugin: CAPPlugin?
|
|
59
|
+
|
|
60
|
+
/// Retained while a browser sign-in is up — ASWebAuthenticationSession is
|
|
61
|
+
/// torn down (and its sheet dismissed) the moment nothing holds it.
|
|
62
|
+
private var webSession: ASWebAuthenticationSession?
|
|
63
|
+
|
|
64
|
+
private var appleController: ASAuthorizationController?
|
|
65
|
+
private var appleCall: CAPPluginCall?
|
|
66
|
+
private var appleNonce: String?
|
|
67
|
+
|
|
68
|
+
init(plugin: CAPPlugin) {
|
|
69
|
+
self.plugin = plugin
|
|
70
|
+
super.init()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// MARK: - What this build can do
|
|
74
|
+
|
|
75
|
+
func support(_ call: CAPPluginCall) {
|
|
76
|
+
call.resolve([
|
|
77
|
+
"platform": "ios",
|
|
78
|
+
"callbackUrl": Self.callbackURL,
|
|
79
|
+
"appleNative": true
|
|
80
|
+
])
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// MARK: - Google / Microsoft (and anything else) in the system sheet
|
|
84
|
+
|
|
85
|
+
func start(_ call: CAPPluginCall) {
|
|
86
|
+
guard let raw = call.getString("url"),
|
|
87
|
+
let url = URL(string: raw),
|
|
88
|
+
url.scheme?.lowercased() == "https" else {
|
|
89
|
+
call.reject("url must be an https:// address", "invalid_url")
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
let scheme = Self.callbackScheme
|
|
93
|
+
guard !scheme.isEmpty else {
|
|
94
|
+
call.reject("This app has no bundle identifier to call back to", "no_callback_scheme")
|
|
95
|
+
return
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
DispatchQueue.main.async {
|
|
99
|
+
// One at a time. Cancelling an earlier sheet runs ITS completion
|
|
100
|
+
// handler, which settles ITS call as cancelled — each handler owns
|
|
101
|
+
// the call it was created for, so the two cannot cross.
|
|
102
|
+
self.webSession?.cancel()
|
|
103
|
+
|
|
104
|
+
let completion: (URL?, Error?) -> Void = { callbackURL, error in
|
|
105
|
+
if let callbackURL = callbackURL {
|
|
106
|
+
call.resolve(["url": callbackURL.absoluteString])
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
if let authError = error as? ASWebAuthenticationSessionError,
|
|
110
|
+
authError.code == .canceledLogin {
|
|
111
|
+
// The person closed the sheet (or declined the "wants to
|
|
112
|
+
// use … to sign in" prompt). Not an error.
|
|
113
|
+
call.resolve(["cancelled": true])
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
let nsError = error as NSError?
|
|
117
|
+
call.reject(
|
|
118
|
+
"The sign-in window failed: \(nsError?.localizedDescription ?? "unknown error")",
|
|
119
|
+
nsError.map { String($0.code) } ?? "web_auth_failed"
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let session: ASWebAuthenticationSession
|
|
124
|
+
if #available(iOS 17.4, *) {
|
|
125
|
+
session = ASWebAuthenticationSession(url: url, callback: .customScheme(scheme), completionHandler: completion)
|
|
126
|
+
} else {
|
|
127
|
+
session = ASWebAuthenticationSession(url: url, callbackURLScheme: scheme, completionHandler: completion)
|
|
128
|
+
}
|
|
129
|
+
session.presentationContextProvider = self
|
|
130
|
+
// Shared with Safari: someone already signed in to Google there is
|
|
131
|
+
// not asked for a password again. The price is iOS's one-line
|
|
132
|
+
// "wants to use … to sign in" prompt, which is the system's, not ours.
|
|
133
|
+
session.prefersEphemeralWebBrowserSession = false
|
|
134
|
+
self.webSession = session
|
|
135
|
+
|
|
136
|
+
if !session.start() {
|
|
137
|
+
call.reject("The sign-in window could not be opened", "web_auth_not_started")
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// MARK: - Sign in with Apple, the native sheet
|
|
143
|
+
|
|
144
|
+
func appleSignIn(_ call: CAPPluginCall) {
|
|
145
|
+
DispatchQueue.main.async {
|
|
146
|
+
// A sheet that never answered (it should always answer) gives way.
|
|
147
|
+
if let stale = self.appleCall {
|
|
148
|
+
stale.resolve(["cancelled": true])
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
let nonce = Self.randomNonce()
|
|
152
|
+
let request = ASAuthorizationAppleIDProvider().createRequest()
|
|
153
|
+
request.requestedScopes = [.fullName, .email]
|
|
154
|
+
request.nonce = Self.sha256Hex(nonce)
|
|
155
|
+
|
|
156
|
+
let controller = ASAuthorizationController(authorizationRequests: [request])
|
|
157
|
+
controller.delegate = self
|
|
158
|
+
controller.presentationContextProvider = self
|
|
159
|
+
|
|
160
|
+
self.appleController = controller
|
|
161
|
+
self.appleCall = call
|
|
162
|
+
self.appleNonce = nonce
|
|
163
|
+
controller.performRequests()
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
func authorizationController(controller: ASAuthorizationController,
|
|
168
|
+
didCompleteWithAuthorization authorization: ASAuthorization) {
|
|
169
|
+
guard controller === appleController, let call = appleCall else { return }
|
|
170
|
+
let nonce = appleNonce
|
|
171
|
+
clearApple()
|
|
172
|
+
|
|
173
|
+
guard let credential = authorization.credential as? ASAuthorizationAppleIDCredential,
|
|
174
|
+
let tokenData = credential.identityToken,
|
|
175
|
+
let token = String(data: tokenData, encoding: .utf8),
|
|
176
|
+
let rawNonce = nonce else {
|
|
177
|
+
call.reject("Apple returned no identity token", "apple_no_token")
|
|
178
|
+
return
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Apple sends the name and email ONCE, on the first sign-in for this
|
|
182
|
+
// app, and never again — the JS side saves the name to the account.
|
|
183
|
+
call.resolve([
|
|
184
|
+
"identityToken": token,
|
|
185
|
+
"nonce": rawNonce,
|
|
186
|
+
"user": credential.user,
|
|
187
|
+
"email": Self.orNull(credential.email),
|
|
188
|
+
"givenName": Self.orNull(credential.fullName?.givenName),
|
|
189
|
+
"familyName": Self.orNull(credential.fullName?.familyName)
|
|
190
|
+
])
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
func authorizationController(controller: ASAuthorizationController,
|
|
194
|
+
didCompleteWithError error: Error) {
|
|
195
|
+
guard controller === appleController, let call = appleCall else { return }
|
|
196
|
+
clearApple()
|
|
197
|
+
|
|
198
|
+
let code = (error as? ASAuthorizationError)?.code
|
|
199
|
+
if code == .canceled {
|
|
200
|
+
call.resolve(["cancelled": true])
|
|
201
|
+
return
|
|
202
|
+
}
|
|
203
|
+
let hint = code == .unknown
|
|
204
|
+
? " — usually this build lacks the Sign in with Apple entitlement (com.apple.developer.applesignin) or its App ID lacks the capability, or the device has no Apple ID signed in"
|
|
205
|
+
: ""
|
|
206
|
+
call.reject("Sign in with Apple failed: \(error.localizedDescription)\(hint)", String((error as NSError).code))
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
private func clearApple() {
|
|
210
|
+
appleController = nil
|
|
211
|
+
appleCall = nil
|
|
212
|
+
appleNonce = nil
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// MARK: - Presentation
|
|
216
|
+
|
|
217
|
+
private func anchor() -> ASPresentationAnchor {
|
|
218
|
+
if let window = plugin?.bridge?.webView?.window {
|
|
219
|
+
return window
|
|
220
|
+
}
|
|
221
|
+
let windows = UIApplication.shared.connectedScenes
|
|
222
|
+
.compactMap { $0 as? UIWindowScene }
|
|
223
|
+
.flatMap { $0.windows }
|
|
224
|
+
return windows.first(where: { $0.isKeyWindow }) ?? windows.first ?? ASPresentationAnchor()
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
|
|
228
|
+
anchor()
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor {
|
|
232
|
+
anchor()
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// MARK: - Helpers
|
|
236
|
+
|
|
237
|
+
private static func orNull(_ value: String?) -> Any {
|
|
238
|
+
if let value = value { return value }
|
|
239
|
+
return NSNull()
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/// 64 hex characters from the system CSPRNG.
|
|
243
|
+
private static func randomNonce() -> String {
|
|
244
|
+
var bytes = [UInt8](repeating: 0, count: 32)
|
|
245
|
+
if SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes) != errSecSuccess {
|
|
246
|
+
// Never seen in practice; still unguessable, just less tidy.
|
|
247
|
+
return (UUID().uuidString + UUID().uuidString).replacingOccurrences(of: "-", with: "").lowercased()
|
|
248
|
+
}
|
|
249
|
+
return bytes.map { String(format: "%02x", $0) }.joined()
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/// Lower-case hex SHA-256 — the form Supabase hashes the raw nonce into
|
|
253
|
+
/// before comparing it with the token's `nonce` claim.
|
|
254
|
+
private static func sha256Hex(_ value: String) -> String {
|
|
255
|
+
SHA256.hash(data: Data(value.utf8)).map { String(format: "%02x", $0) }.joined()
|
|
256
|
+
}
|
|
257
|
+
}
|
|
@@ -40,9 +40,22 @@ public class UnisimSuiteAuthPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
40
40
|
CAPPluginMethod(name: "remove", returnType: CAPPluginReturnPromise),
|
|
41
41
|
CAPPluginMethod(name: "status", returnType: CAPPluginReturnPromise),
|
|
42
42
|
CAPPluginMethod(name: "installedApps", returnType: CAPPluginReturnPromise),
|
|
43
|
-
CAPPluginMethod(name: "openApp", returnType: CAPPluginReturnPromise)
|
|
43
|
+
CAPPluginMethod(name: "openApp", returnType: CAPPluginReturnPromise),
|
|
44
|
+
CAPPluginMethod(name: "oauthSupport", returnType: CAPPluginReturnPromise),
|
|
45
|
+
CAPPluginMethod(name: "oauthStart", returnType: CAPPluginReturnPromise),
|
|
46
|
+
CAPPluginMethod(name: "appleSignIn", returnType: CAPPluginReturnPromise)
|
|
44
47
|
]
|
|
45
48
|
|
|
49
|
+
/// Provider sign-in lives in SuiteOAuth.swift; these three methods only
|
|
50
|
+
/// forward to it. On THIS class for the reason the app-opening methods
|
|
51
|
+
/// below are: a new plugin class would be absent from every app's
|
|
52
|
+
/// generated plugin list until each one re-synced.
|
|
53
|
+
private lazy var oauth = SuiteOAuthCoordinator(plugin: self)
|
|
54
|
+
|
|
55
|
+
@objc func oauthSupport(_ call: CAPPluginCall) { oauth.support(call) }
|
|
56
|
+
@objc func oauthStart(_ call: CAPPluginCall) { oauth.start(call) }
|
|
57
|
+
@objc func appleSignIn(_ call: CAPPluginCall) { oauth.appleSignIn(call) }
|
|
58
|
+
|
|
46
59
|
/// One service for the whole suite. The `key` the JS side passes (Supabase's
|
|
47
60
|
/// `storageKey`, i.e. `universal-suite-auth`) becomes the account, so other
|
|
48
61
|
/// suite keys can share the same group later without colliding.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unisim/sdk",
|
|
3
|
-
"version": "0.141.
|
|
3
|
+
"version": "0.141.8",
|
|
4
4
|
"description": "Shared React SDK for the Universal Suite — auth, entitlements, usage telemetry, changelog, org admin.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Universal Simulation Ltd",
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"test:email-auth": "npm run build && node tests/email-auth.mjs",
|
|
67
67
|
"test:about-credits": "npm run build && node tests/about-credits.browser.mjs",
|
|
68
68
|
"test:profile-menu-order": "npm run build && node tests/profile-menu-order.browser.mjs",
|
|
69
|
+
"test:delete-account": "npm run build && node tests/delete-account.browser.mjs",
|
|
69
70
|
"test:reveal-on-expand": "npm run build && node tests/reveal-on-expand.browser.mjs",
|
|
70
71
|
"test:dropdown-scroll": "npm run build && node tests/dropdown-scroll.browser.mjs",
|
|
71
72
|
"test:about-authorship": "npm run build && node tests/about-authorship.browser.mjs",
|
|
@@ -77,6 +78,7 @@
|
|
|
77
78
|
"test:i18n": "npm run build && node tests/i18n.mjs",
|
|
78
79
|
"test:privacy-note": "npm run build && node tests/privacy-note-i18n.browser.mjs",
|
|
79
80
|
"test:oauth": "npm run build && node tests/oauth-providers.mjs",
|
|
81
|
+
"test:native-oauth": "npm run build && node tests/native-oauth.mjs",
|
|
80
82
|
"test:email-code": "npm run build && node tests/email-code.mjs",
|
|
81
83
|
"test:signin-sso": "npm run build && node tests/signin-sso.browser.mjs",
|
|
82
84
|
"prepublishOnly": "npm run typecheck && npm run build",
|