@spfn/auth 0.3.0-beta.6 → 0.3.0-beta.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/dist/index.js CHANGED
@@ -137,6 +137,39 @@ var KeyNotFoundError = class extends NotFoundError {
137
137
  this.name = "KeyNotFoundError";
138
138
  }
139
139
  };
140
+ var DeviceAuthNotFoundError = class extends NotFoundError {
141
+ constructor(data = {}) {
142
+ super({ message: data.message || "Device authorization not found", details: data.details });
143
+ this.name = "DeviceAuthNotFoundError";
144
+ }
145
+ };
146
+ var DeviceAuthExpiredError = class extends ValidationError {
147
+ constructor(data = {}) {
148
+ super({
149
+ message: data.message || "This device code has expired. Start again on the other device.",
150
+ details: data.details
151
+ });
152
+ this.name = "DeviceAuthExpiredError";
153
+ }
154
+ };
155
+ var DeviceAuthAlreadyHandledError = class extends ConflictError {
156
+ constructor(data = {}) {
157
+ super({
158
+ message: data.message || "This device request has already been answered",
159
+ details: data.details
160
+ });
161
+ this.name = "DeviceAuthAlreadyHandledError";
162
+ }
163
+ };
164
+ var DeviceAuthDeniedError = class extends ForbiddenError {
165
+ constructor(data = {}) {
166
+ super({
167
+ message: data.message || "This device request was denied",
168
+ details: data.details
169
+ });
170
+ this.name = "DeviceAuthDeniedError";
171
+ }
172
+ };
140
173
  var NonceKeyBindingError = class extends ValidationError {
141
174
  constructor(data = {}) {
142
175
  super({
@@ -268,6 +301,10 @@ authErrorRegistry.append([
268
301
  InvalidSignupSetupSessionError,
269
302
  KeyNotFoundError,
270
303
  KeyIdAlreadyRegisteredError,
304
+ DeviceAuthNotFoundError,
305
+ DeviceAuthExpiredError,
306
+ DeviceAuthAlreadyHandledError,
307
+ DeviceAuthDeniedError,
271
308
  VerificationTokenPurposeMismatchError,
272
309
  VerificationTokenTargetMismatchError,
273
310
  InsufficientPermissionsError,
@@ -283,6 +320,11 @@ var routeMap = {
283
320
  confirmSignupLink: { method: "POST", path: "/_auth/signup/email/confirm" },
284
321
  completeSignup: { method: "POST", path: "/_auth/signup/password" },
285
322
  login: { method: "POST", path: "/_auth/login" },
323
+ startDeviceAuth: { method: "POST", path: "/_auth/device/start" },
324
+ pollDeviceAuth: { method: "POST", path: "/_auth/device/poll" },
325
+ getDeviceAuthInfo: { method: "POST", path: "/_auth/device/info" },
326
+ approveDeviceAuth: { method: "POST", path: "/_auth/device/approve" },
327
+ denyDeviceAuth: { method: "POST", path: "/_auth/device/deny" },
286
328
  logout: { method: "POST", path: "/_auth/logout" },
287
329
  rotateKey: { method: "POST", path: "/_auth/keys/rotate" },
288
330
  listKeys: { method: "POST", path: "/_auth/keys/list" },
@@ -3098,6 +3140,39 @@ var PlatformSchema = Type.Union(
3098
3140
  KEY_PLATFORM.map((platform) => Type.Literal(platform)),
3099
3141
  { description: "Platform the key lives on" }
3100
3142
  );
3143
+ var PublicKeySchema = Type.String({
3144
+ maxLength: 2048,
3145
+ description: "Client public key, SPKI DER in base64"
3146
+ });
3147
+ var KeyIdSchema = Type.String({
3148
+ maxLength: 64,
3149
+ description: "Key identifier"
3150
+ });
3151
+ var FingerprintSchema = Type.String({
3152
+ maxLength: 128,
3153
+ description: "SHA-256 hex fingerprint of the public key"
3154
+ });
3155
+ var UserCodeSchema = Type.String({
3156
+ minLength: 8,
3157
+ maxLength: 16,
3158
+ description: "Device user code as displayed, e.g. WXYZ-2345. Dashes, spaces and case are ignored."
3159
+ });
3160
+ var DeviceAuthPollResponseSchema = Type.Union([
3161
+ Type.Object({
3162
+ status: Type.Literal("pending"),
3163
+ intervalMillis: Type.Integer({ description: "Milliseconds to wait before polling again" })
3164
+ }),
3165
+ Type.Object({
3166
+ status: Type.Literal("approved"),
3167
+ userId: Type.String(),
3168
+ publicId: Type.String(),
3169
+ email: Type.Optional(Type.String()),
3170
+ phone: Type.Optional(Type.String()),
3171
+ passwordChangeRequired: Type.Boolean()
3172
+ })
3173
+ ], {
3174
+ description: "Pending, or the login the approval produced"
3175
+ });
3101
3176
  var PasswordSchema = Type.String({
3102
3177
  minLength: 8,
3103
3178
  maxLength: 72,